summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI/Events/PlayerEvents.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2017-01-16 16:10:57 -0500
committerJesse Plamondon-Willard <github@jplamondonw.com>2017-01-16 16:10:57 -0500
commit6adf199987a506f8a65f6c1ddfad5aa9fa2a6a9f (patch)
treefaa9155fae99533110853567003325486f208937 /src/StardewModdingAPI/Events/PlayerEvents.cs
parente8825947ca82c8f28ad9bc8a225fb4fb749814cb (diff)
parent1f3d3c8c93c7a427486b60cf649b86cef140e88b (diff)
downloadSMAPI-6adf199987a506f8a65f6c1ddfad5aa9fa2a6a9f.tar.gz
SMAPI-6adf199987a506f8a65f6c1ddfad5aa9fa2a6a9f.tar.bz2
SMAPI-6adf199987a506f8a65f6c1ddfad5aa9fa2a6a9f.zip
Merge branch 'develop' into stable
Diffstat (limited to 'src/StardewModdingAPI/Events/PlayerEvents.cs')
-rw-r--r--src/StardewModdingAPI/Events/PlayerEvents.cs20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/StardewModdingAPI/Events/PlayerEvents.cs b/src/StardewModdingAPI/Events/PlayerEvents.cs
index 3f301b07..dd3ff220 100644
--- a/src/StardewModdingAPI/Events/PlayerEvents.cs
+++ b/src/StardewModdingAPI/Events/PlayerEvents.cs
@@ -14,9 +14,11 @@ namespace StardewModdingAPI.Events
** Events
*********/
/// <summary>Raised after the player loads a saved game.</summary>
+ [Obsolete("Use " + nameof(SaveEvents) + "." + nameof(SaveEvents.AfterLoad) + " instead")]
public static event EventHandler<EventArgsLoadedGameChanged> LoadedGame;
/// <summary>Raised after the game assigns a new player character. This happens just before <see cref="LoadedGame"/>; it's unclear how this would happen any other time.</summary>
+ [Obsolete("should no longer be used")]
public static event EventHandler<EventArgsFarmerChanged> FarmerChanged;
/// <summary>Raised after the player's inventory changes in any way (added or removed item, sorted, etc).</summary>
@@ -34,7 +36,14 @@ namespace StardewModdingAPI.Events
/// <param name="loaded">Whether the save has been loaded. This is always true.</param>
internal static void InvokeLoadedGame(IMonitor monitor, EventArgsLoadedGameChanged loaded)
{
- monitor.SafelyRaiseGenericEvent($"{nameof(PlayerEvents)}.{nameof(PlayerEvents.LoadedGame)}", PlayerEvents.LoadedGame?.GetInvocationList(), null, loaded);
+ if (PlayerEvents.LoadedGame == null)
+ return;
+
+ string name = $"{nameof(PlayerEvents)}.{nameof(PlayerEvents.LoadedGame)}";
+ Delegate[] handlers = PlayerEvents.LoadedGame.GetInvocationList();
+
+ Program.DeprecationManager.WarnForEvent(handlers, name, "1.6", DeprecationLevel.Notice);
+ monitor.SafelyRaiseGenericEvent(name, handlers, null, loaded);
}
/// <summary>Raise a <see cref="FarmerChanged"/> event.</summary>
@@ -43,7 +52,14 @@ namespace StardewModdingAPI.Events
/// <param name="newFarmer">The new player character.</param>
internal static void InvokeFarmerChanged(IMonitor monitor, Farmer priorFarmer, Farmer newFarmer)
{
- monitor.SafelyRaiseGenericEvent($"{nameof(PlayerEvents)}.{nameof(PlayerEvents.FarmerChanged)}", PlayerEvents.FarmerChanged?.GetInvocationList(), null, new EventArgsFarmerChanged(priorFarmer, newFarmer));
+ if (PlayerEvents.FarmerChanged == null)
+ return;
+
+ string name = $"{nameof(PlayerEvents)}.{nameof(PlayerEvents.FarmerChanged)}";
+ Delegate[] handlers = PlayerEvents.FarmerChanged.GetInvocationList();
+
+ Program.DeprecationManager.WarnForEvent(handlers, name, "1.6", DeprecationLevel.Notice);
+ monitor.SafelyRaiseGenericEvent(name, handlers, null, new EventArgsFarmerChanged(priorFarmer, newFarmer));
}
/// <summary>Raise an <see cref="InventoryChanged"/> event.</summary>