using NightclubArcadia.UI; using UnityEngine; namespace NightclubArcadia.UI.HUD { /// /// Bottom-right player portrait. Visible only when dialogue is inactive /// and the player menu is closed. /// public sealed class PortraitHudView : MonoBehaviour { [SerializeField] GameObject panelRoot; void OnEnable() { if (UIStateController.Instance != null) { UIStateController.Instance.StateChanged += OnStateChanged; } } void Start() { // Re-subscribe in case Instance was not ready during OnEnable, // and apply the initial visibility. if (UIStateController.Instance != null) { UIStateController.Instance.StateChanged -= OnStateChanged; UIStateController.Instance.StateChanged += OnStateChanged; } ApplyVisibility(); } void OnDisable() { if (UIStateController.Instance != null) { UIStateController.Instance.StateChanged -= OnStateChanged; } } void OnStateChanged() => ApplyVisibility(); void ApplyVisibility() { if (panelRoot == null) { return; } var state = UIStateController.Instance; var visible = state == null || (!state.IsDialogueActive && !state.IsMenuOpen); if (visible) { PanelVisibility.Show(panelRoot); } else { PanelVisibility.Hide(panelRoot); } } } }