diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-05-10 23:44:58 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-05-10 23:44:58 -0400 |
commit | d88050fceeba58f8357bbd20d3acbd97d05c18e4 (patch) | |
tree | 32a007c7573aba0ae0af9235309e0da52a0d66f6 /src | |
parent | b4584afda897b695c5fc306db9facc0690b5ab75 (diff) | |
download | SMAPI-d88050fceeba58f8357bbd20d3acbd97d05c18e4.tar.gz SMAPI-d88050fceeba58f8357bbd20d3acbd97d05c18e4.tar.bz2 SMAPI-d88050fceeba58f8357bbd20d3acbd97d05c18e4.zip |
deprecate GameEvents.GameLoaded and GameEvents.FirstUpdateTick
Diffstat (limited to 'src')
-rw-r--r-- | src/StardewModdingAPI/Events/GameEvents.cs | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/src/StardewModdingAPI/Events/GameEvents.cs b/src/StardewModdingAPI/Events/GameEvents.cs index 029ec1f9..be06a03b 100644 --- a/src/StardewModdingAPI/Events/GameEvents.cs +++ b/src/StardewModdingAPI/Events/GameEvents.cs @@ -28,9 +28,11 @@ namespace StardewModdingAPI.Events public static event EventHandler LoadContent; /// <summary>Raised during launch after configuring Stardew Valley, loading it into memory, and opening the game window. The window is still blank by this point.</summary> + [Obsolete("The " + nameof(Mod) + "." + nameof(Mod.Entry) + " method is now called after the game loads, so any contained logic can be done directly in " + nameof(Mod.Entry) + ".")] public static event EventHandler GameLoaded; /// <summary>Raised during the first game update tick.</summary> + [Obsolete("The " + nameof(Mod) + "." + nameof(Mod.Entry) + " method is now called after the game loads, so any contained logic can be done directly in " + nameof(Mod.Entry) + ".")] public static event EventHandler FirstUpdateTick; /// <summary>Raised when the game updates its state (≈60 times per second).</summary> @@ -99,7 +101,28 @@ namespace StardewModdingAPI.Events /// <param name="monitor">Encapsulates monitoring and logging.</param> internal static void InvokeGameLoaded(IMonitor monitor) { - monitor.SafelyRaisePlainEvent($"{nameof(GameEvents)}.{nameof(GameEvents.GameLoaded)}", GameEvents.GameLoaded?.GetInvocationList()); + if (GameEvents.GameLoaded == null) + return; + + string name = $"{nameof(GameEvents)}.{nameof(GameEvents.GameLoaded)}"; + Delegate[] handlers = GameEvents.GameLoaded.GetInvocationList(); + + GameEvents.DeprecationManager.WarnForEvent(handlers, name, "1.12", DeprecationLevel.Info); + monitor.SafelyRaisePlainEvent(name, handlers); + } + + /// <summary>Raise a <see cref="FirstUpdateTick"/> event.</summary> + /// <param name="monitor">Encapsulates monitoring and logging.</param> + internal static void InvokeFirstUpdateTick(IMonitor monitor) + { + if (GameEvents.FirstUpdateTick == null) + return; + + string name = $"{nameof(GameEvents)}.{nameof(GameEvents.FirstUpdateTick)}"; + Delegate[] handlers = GameEvents.FirstUpdateTick.GetInvocationList(); + + GameEvents.DeprecationManager.WarnForEvent(handlers, name, "1.12", DeprecationLevel.Info); + monitor.SafelyRaisePlainEvent(name, handlers); } /// <summary>Raise an <see cref="UpdateTick"/> event.</summary> @@ -150,12 +173,5 @@ namespace StardewModdingAPI.Events { monitor.SafelyRaisePlainEvent($"{nameof(GameEvents)}.{nameof(GameEvents.OneSecondTick)}", GameEvents.OneSecondTick?.GetInvocationList()); } - - /// <summary>Raise a <see cref="FirstUpdateTick"/> event.</summary> - /// <param name="monitor">Encapsulates monitoring and logging.</param> - internal static void InvokeFirstUpdateTick(IMonitor monitor) - { - monitor.SafelyRaisePlainEvent($"{nameof(GameEvents)}.{nameof(GameEvents.FirstUpdateTick)}", GameEvents.FirstUpdateTick?.GetInvocationList()); - } } } |