From 3b078d55daccd13332e2cba1fd5c76f775505d7a Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 8 Jul 2018 20:06:33 -0400 Subject: add GameLoop events for SMAPI 3.0 (#310) --- src/SMAPI/Framework/Events/ModGameLoopEvents.cs | 39 +++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/SMAPI/Framework/Events/ModGameLoopEvents.cs (limited to 'src/SMAPI/Framework/Events/ModGameLoopEvents.cs') diff --git a/src/SMAPI/Framework/Events/ModGameLoopEvents.cs b/src/SMAPI/Framework/Events/ModGameLoopEvents.cs new file mode 100644 index 00000000..1a142b0f --- /dev/null +++ b/src/SMAPI/Framework/Events/ModGameLoopEvents.cs @@ -0,0 +1,39 @@ +using System; +using StardewModdingAPI.Events; + +namespace StardewModdingAPI.Framework.Events +{ + /// Events linked to the game's update loop. The update loop runs roughly ≈60 times/second to run game logic like state changes, action handling, etc. These can be useful, but you should consider more semantic events like if possible. + internal class ModGameLoopEvents : ModEventsBase, IGameLoopEvents + { + /********* + ** Accessors + *********/ + /// Raised after the game is launched, right before the first update tick. + public event EventHandler Launched; + + /// Raised before the game performs its overall update tick (≈60 times per second). + public event EventHandler Updating + { + add => this.EventManager.GameLoop_Updating.Add(value); + remove => this.EventManager.GameLoop_Updating.Remove(value); + } + + /// Raised after the game performs its overall update tick (≈60 times per second). + public event EventHandler Updated + { + add => this.EventManager.GameLoop_Updated.Add(value); + remove => this.EventManager.GameLoop_Updated.Remove(value); + } + + + /********* + ** Public methods + *********/ + /// Construct an instance. + /// The mod which uses this instance. + /// The underlying event manager. + internal ModGameLoopEvents(IModMetadata mod, EventManager eventManager) + : base(mod, eventManager) { } + } +} -- cgit From fbf8356452db76f902578072aab3d757497e4cd1 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Mon, 9 Jul 2018 00:35:09 -0400 Subject: fix new event (#310) --- src/SMAPI/Framework/Events/ModGameLoopEvents.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/SMAPI/Framework/Events/ModGameLoopEvents.cs') diff --git a/src/SMAPI/Framework/Events/ModGameLoopEvents.cs b/src/SMAPI/Framework/Events/ModGameLoopEvents.cs index 1a142b0f..379a4e96 100644 --- a/src/SMAPI/Framework/Events/ModGameLoopEvents.cs +++ b/src/SMAPI/Framework/Events/ModGameLoopEvents.cs @@ -10,7 +10,11 @@ namespace StardewModdingAPI.Framework.Events ** Accessors *********/ /// Raised after the game is launched, right before the first update tick. - public event EventHandler Launched; + public event EventHandler Launched + { + add => this.EventManager.GameLoop_Launched.Add(value); + remove => this.EventManager.GameLoop_Launched.Remove(value); + } /// Raised before the game performs its overall update tick (≈60 times per second). public event EventHandler Updating -- cgit