diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/StardewModdingAPI/Events/TimeEvents.cs | 50 |
1 files changed, 44 insertions, 6 deletions
diff --git a/src/StardewModdingAPI/Events/TimeEvents.cs b/src/StardewModdingAPI/Events/TimeEvents.cs index 572898c7..5dadf567 100644 --- a/src/StardewModdingAPI/Events/TimeEvents.cs +++ b/src/StardewModdingAPI/Events/TimeEvents.cs @@ -18,6 +18,17 @@ namespace StardewModdingAPI.Events [SuppressMessage("ReSharper", "InconsistentNaming")] private static event EventHandler<EventArgsNewDay> _OnNewDay; + /// <summary>The backing field for <see cref="DayOfMonthChanged"/>.</summary> + [SuppressMessage("ReSharper", "InconsistentNaming")] + private static event EventHandler<EventArgsIntChanged> _DayOfMonthChanged; + + /// <summary>The backing field for <see cref="SeasonOfYearChanged"/>.</summary> + [SuppressMessage("ReSharper", "InconsistentNaming")] + private static event EventHandler<EventArgsStringChanged> _SeasonOfYearChanged; + + /// <summary>The backing field for <see cref="YearOfGameChanged"/>.</summary> + [SuppressMessage("ReSharper", "InconsistentNaming")] + private static event EventHandler<EventArgsIntChanged> _YearOfGameChanged; /********* ** Events @@ -29,13 +40,40 @@ namespace StardewModdingAPI.Events public static event EventHandler<EventArgsIntChanged> TimeOfDayChanged; /// <summary>Raised after the day-of-month value changes, including when loading a save. This may happen before save; in most cases you should use <see cref="AfterDayStarted"/> instead.</summary> - public static event EventHandler<EventArgsIntChanged> DayOfMonthChanged; + [Obsolete("Use " + nameof(TimeEvents) + "." + nameof(TimeEvents.AfterDayStarted) + " or " + nameof(SaveEvents) + " instead")] + public static event EventHandler<EventArgsIntChanged> DayOfMonthChanged + { + add + { + TimeEvents.DeprecationManager.Warn($"{nameof(TimeEvents)}.{nameof(TimeEvents.DayOfMonthChanged)}", "1.14", DeprecationLevel.Info); + TimeEvents._DayOfMonthChanged += value; + } + remove => TimeEvents._DayOfMonthChanged -= value; + } /// <summary>Raised after the year value changes.</summary> - public static event EventHandler<EventArgsIntChanged> YearOfGameChanged; + [Obsolete("Use " + nameof(TimeEvents) + "." + nameof(TimeEvents.AfterDayStarted) + " or " + nameof(SaveEvents) + " instead")] + public static event EventHandler<EventArgsIntChanged> YearOfGameChanged + { + add + { + TimeEvents.DeprecationManager.Warn($"{nameof(TimeEvents)}.{nameof(TimeEvents.YearOfGameChanged)}", "1.14", DeprecationLevel.Info); + TimeEvents._YearOfGameChanged += value; + } + remove => TimeEvents._YearOfGameChanged -= value; + } /// <summary>Raised after the season value changes.</summary> - public static event EventHandler<EventArgsStringChanged> SeasonOfYearChanged; + [Obsolete("Use " + nameof(TimeEvents) + "." + nameof(TimeEvents.AfterDayStarted) + " or " + nameof(SaveEvents) + " instead")] + public static event EventHandler<EventArgsStringChanged> SeasonOfYearChanged + { + add + { + TimeEvents.DeprecationManager.Warn($"{nameof(TimeEvents)}.{nameof(TimeEvents.SeasonOfYearChanged)}", "1.14", DeprecationLevel.Info); + TimeEvents._SeasonOfYearChanged += value; + } + remove => TimeEvents._SeasonOfYearChanged -= value; + } /// <summary>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.</summary> [Obsolete("Use " + nameof(TimeEvents) + "." + nameof(TimeEvents.AfterDayStarted) + " or " + nameof(SaveEvents) + " instead")] @@ -82,7 +120,7 @@ namespace StardewModdingAPI.Events /// <param name="newDay">The current day value.</param> internal static void InvokeDayOfMonthChanged(IMonitor monitor, int priorDay, int newDay) { - monitor.SafelyRaiseGenericEvent($"{nameof(TimeEvents)}.{nameof(TimeEvents.DayOfMonthChanged)}", TimeEvents.DayOfMonthChanged?.GetInvocationList(), null, new EventArgsIntChanged(priorDay, newDay)); + monitor.SafelyRaiseGenericEvent($"{nameof(TimeEvents)}.{nameof(TimeEvents.DayOfMonthChanged)}", TimeEvents._DayOfMonthChanged?.GetInvocationList(), null, new EventArgsIntChanged(priorDay, newDay)); } /// <summary>Raise a <see cref="YearOfGameChanged"/> event.</summary> @@ -91,7 +129,7 @@ namespace StardewModdingAPI.Events /// <param name="newYear">The current year value.</param> internal static void InvokeYearOfGameChanged(IMonitor monitor, int priorYear, int newYear) { - monitor.SafelyRaiseGenericEvent($"{nameof(TimeEvents)}.{nameof(TimeEvents.YearOfGameChanged)}", TimeEvents.YearOfGameChanged?.GetInvocationList(), null, new EventArgsIntChanged(priorYear, newYear)); + monitor.SafelyRaiseGenericEvent($"{nameof(TimeEvents)}.{nameof(TimeEvents.YearOfGameChanged)}", TimeEvents._YearOfGameChanged?.GetInvocationList(), null, new EventArgsIntChanged(priorYear, newYear)); } /// <summary>Raise a <see cref="SeasonOfYearChanged"/> event.</summary> @@ -100,7 +138,7 @@ namespace StardewModdingAPI.Events /// <param name="newSeason">The current season name.</param> internal static void InvokeSeasonOfYearChanged(IMonitor monitor, string priorSeason, string newSeason) { - monitor.SafelyRaiseGenericEvent($"{nameof(TimeEvents)}.{nameof(TimeEvents.SeasonOfYearChanged)}", TimeEvents.SeasonOfYearChanged?.GetInvocationList(), null, new EventArgsStringChanged(priorSeason, newSeason)); + monitor.SafelyRaiseGenericEvent($"{nameof(TimeEvents)}.{nameof(TimeEvents.SeasonOfYearChanged)}", TimeEvents._SeasonOfYearChanged?.GetInvocationList(), null, new EventArgsStringChanged(priorSeason, newSeason)); } /// <summary>Raise a <see cref="OnNewDay"/> event.</summary> |