using UnityEngine;

namespace DayNightCycle
{
    public class ExampleUses : MonoBehaviour
    {
        [Header("Debug Options")]
        [SerializeField] private bool showTimeDebugInfo;
        [SerializeField] private bool showHourlyEvents;

        private void Update()
        {
            if (showTimeDebugInfo)
            {
                Debug.Log($"{LightingManager.Instance.CurrentHour}:{LightingManager.Instance.CurrentMinute:D2}");
                Debug.Log($"Day: {LightingManager.Instance.CurrentDay}");
            }
        }

        /// <summary>
        /// Event handler method for hourly events, checks for midday and midnight.
        /// </summary>
        private void HandleHourlyEvents(object sender, LightingManager.HourPassedEventArgs e)
        {
            if (showHourlyEvents)
            {
                if (e.Hour == 12)
                {
                    Debug.Log("It is Noon!!");
                }
                else if (e.Hour == 0)
                {
                    Debug.Log("It is Midnight!!");
                }
            }
        }

        /// <summary>
        /// Subscribe to the HourPassed event.
        /// </summary>
        private void OnEnable()
        {
            LightingManager.HourPassed += HandleHourlyEvents;
        }

        /// <summary>
        /// Unsubscribe from the HourPassed event.
        /// </summary>
        private void OnDisable()
        {
            LightingManager.HourPassed -= HandleHourlyEvents;
        }
    }
}
