using System;
namespace StardewModdingAPI.Events
{
/// Events raised when the in-game date or time changes.
public static class TimeEvents
{
/*********
** Events
*********/
/// Raised after the in-game clock changes.
public static event EventHandler TimeOfDayChanged = delegate { };
/// Raised after the day-of-month value changes, including when loading a save (unlike ).
public static event EventHandler DayOfMonthChanged = delegate { };
/// Raised after the year value changes.
public static event EventHandler YearOfGameChanged = delegate { };
/// Raised after the season value changes.
public static event EventHandler SeasonOfYearChanged = delegate { };
/// Raised when the player is transitioning to a new day and the game is performing its day update logic. This event is triggered twice: once after the game starts transitioning, and again after it finishes.
public static event EventHandler OnNewDay = delegate { };
/*********
** Internal methods
*********/
/// Raise a event.
/// 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(int priorTime, int newTime)
{
TimeEvents.TimeOfDayChanged.Invoke(null, new EventArgsIntChanged(priorTime, newTime));
}
/// Raise a event.
/// The previous day value.
/// The current day value.
internal static void InvokeDayOfMonthChanged(int priorDay, int newDay)
{
TimeEvents.DayOfMonthChanged.Invoke(null, new EventArgsIntChanged(priorDay, newDay));
}
/// Raise a event.
/// The previous year value.
/// The current year value.
internal static void InvokeYearOfGameChanged(int priorYear, int newYear)
{
TimeEvents.YearOfGameChanged.Invoke(null, new EventArgsIntChanged(priorYear, newYear));
}
/// Raise a event.
/// The previous season name.
/// The current season name.
internal static void InvokeSeasonOfYearChanged(string priorSeason, string newSeason)
{
TimeEvents.SeasonOfYearChanged.Invoke(null, new EventArgsStringChanged(priorSeason, newSeason));
}
/// Raise a event.
/// The previous day value.
/// The current day value.
/// Whether the game just started the transition (true) or finished it (false).
internal static void InvokeOnNewDay(int priorDay, int newDay, bool isTransitioning)
{
TimeEvents.OnNewDay.Invoke(null, new EventArgsNewDay(priorDay, newDay, isTransitioning));
}
}
}