diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-02-23 19:05:23 -0500 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-02-23 19:05:23 -0500 |
commit | 68528f7decadccb4c5ed62f3fff10aeff22dcd43 (patch) | |
tree | eb73bbc7d1e808064bc7abc55946f9b650bd8c1a /src/SMAPI/Events/MineEvents.cs | |
parent | c8162c2fb624f1c963615d79b557d7df5a23ff09 (diff) | |
download | SMAPI-68528f7decadccb4c5ed62f3fff10aeff22dcd43.tar.gz SMAPI-68528f7decadccb4c5ed62f3fff10aeff22dcd43.tar.bz2 SMAPI-68528f7decadccb4c5ed62f3fff10aeff22dcd43.zip |
overhaul events to track the mod which added each handler, and log errors under their name (#451)
Diffstat (limited to 'src/SMAPI/Events/MineEvents.cs')
-rw-r--r-- | src/SMAPI/Events/MineEvents.cs | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/src/SMAPI/Events/MineEvents.cs b/src/SMAPI/Events/MineEvents.cs index 9cf7edac..5ee4001b 100644 --- a/src/SMAPI/Events/MineEvents.cs +++ b/src/SMAPI/Events/MineEvents.cs @@ -1,5 +1,5 @@ -using System; -using StardewModdingAPI.Framework; +using System; +using StardewModdingAPI.Framework.Events; namespace StardewModdingAPI.Events { @@ -7,22 +7,31 @@ namespace StardewModdingAPI.Events public static class MineEvents { /********* + ** Properties + *********/ + /// <summary>The core event manager.</summary> + private static EventManager EventManager; + + + /********* ** Events *********/ /// <summary>Raised after the player warps to a new level of the mine.</summary> - public static event EventHandler<EventArgsMineLevelChanged> MineLevelChanged; + public static event EventHandler<EventArgsMineLevelChanged> MineLevelChanged + { + add => MineEvents.EventManager.Mine_LevelChanged.Add(value); + remove => MineEvents.EventManager.Mine_LevelChanged.Remove(value); + } /********* - ** Internal methods + ** Public methods *********/ - /// <summary>Raise a <see cref="MineLevelChanged"/> event.</summary> - /// <param name="monitor">Encapsulates monitoring and logging.</param> - /// <param name="previousMineLevel">The previous mine level.</param> - /// <param name="currentMineLevel">The current mine level.</param> - internal static void InvokeMineLevelChanged(IMonitor monitor, int previousMineLevel, int currentMineLevel) + /// <summary>Initialise the events.</summary> + /// <param name="eventManager">The core event manager.</param> + internal static void Init(EventManager eventManager) { - monitor.SafelyRaiseGenericEvent($"{nameof(MineEvents)}.{nameof(MineEvents.MineLevelChanged)}", MineEvents.MineLevelChanged?.GetInvocationList(), null, new EventArgsMineLevelChanged(previousMineLevel, currentMineLevel)); + MineEvents.EventManager = eventManager; } } } |