using NightclubArcadia.Core;
using TMPro;
using UnityEngine;
namespace NightclubArcadia.Interaction
{
///
/// The "[F]" that appears when the player is close enough to interact, showing the
/// glyph for whichever input device was last used.
///
/// Separated from the interactor so the prompt can be positioned and styled in a
/// prefab rather than constructed in code, and so anything else that needs a
/// proximity prompt can reuse it.
///
[RequireComponent(typeof(TextMeshPro))]
public sealed class InteractionPrompt : MonoBehaviour
{
TextMeshPro text;
bool shown;
void Awake()
{
text = GetComponent();
SetShown(false);
}
public void SetShown(bool value)
{
shown = value;
if (text != null)
{
text.enabled = value;
}
}
void Update()
{
if (shown && text != null)
{
text.text = GlyphFor(InputDeviceTracker.Current);
}
}
static string GlyphFor(InputDeviceTracker.DeviceType type)
{
switch (type)
{
case InputDeviceTracker.DeviceType.Xbox: return "(X)";
case InputDeviceTracker.DeviceType.PlayStation: return "(✕)";
default: return "[F]";
}
}
}
}