using System;
using StardewModdingAPI.Framework;
namespace StardewModdingAPI.Events
{
/// Events raised when the in-game date or time changes.
public static class TimeEvents
{
/*********
** Events
*********/
/// Raised after the game begins a new day, including when loading a save.
public static event EventHandler AfterDayStarted;
/// Raised after the in-game clock changes.
public static event EventHandler TimeOfDayChanged;
/*********
** Internal methods
*********/
/// Raise an event.
/// Encapsulates monitoring and logging.
internal static void InvokeAfterDayStarted(IMonitor monitor)
{
monitor.SafelyRaisePlainEvent($"{nameof(TimeEvents)}.{nameof(TimeEvents.AfterDayStarted)}", TimeEvents.AfterDayStarted?.GetInvocationList(), null, EventArgs.Empty);
}
/// Raise a event.
/// Encapsulates monitoring and logging.
/// The previous time in military time format (e.g. 6:00pm is 1800).
/// The current time in military time format (e.g. 6:10pm is 1810).
internal static void InvokeTimeOfDayChanged(IMonitor monitor, int priorTime, int newTime)
{
monitor.SafelyRaiseGenericEvent($"{nameof(TimeEvents)}.{nameof(TimeEvents.TimeOfDayChanged)}", TimeEvents.TimeOfDayChanged?.GetInvocationList(), null, new EventArgsIntChanged(priorTime, newTime));
}
}
}