summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--release-notes.md1
-rw-r--r--src/StardewModdingAPI/Events/GameEvents.cs32
2 files changed, 25 insertions, 8 deletions
diff --git a/release-notes.md b/release-notes.md
index 08824630..e6e594a5 100644
--- a/release-notes.md
+++ b/release-notes.md
@@ -23,6 +23,7 @@ For mod developers:
* Added `debug` console command to TrainerMod which lets you pass debug commands to the game (e.g. `debug warp FarmHouse 1 1` warps the player to the farmhouse).
* Added a warning for mods that don't set the `UniqueID` manifest field, which will be required in SMAPI 2.0.
* Mods now implement `IDisposable` to let them release any unmanaged resources.
+* Deprecated `GameEvents.GameLoaded` and `GameEvents.FirstUpdateTick`, since any logic in the mod's `Entry` method will happen after the game is loaded.
## 1.12
See [log](https://github.com/Pathoschild/SMAPI/compare/1.11...1.12).
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());
- }
}
}