From 041bd2d6ba726eeea88afed3be307343a6f9286b Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 23 Dec 2018 19:26:02 -0500 Subject: add Specialised.SavePreloaded event --- src/SMAPI/Events/IGameLoopEvents.cs | 2 +- src/SMAPI/Events/ISpecialisedEvents.cs | 3 +++ src/SMAPI/Events/SavePreloadedEventArgs.cs | 7 +++++++ 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 src/SMAPI/Events/SavePreloadedEventArgs.cs (limited to 'src/SMAPI/Events') diff --git a/src/SMAPI/Events/IGameLoopEvents.cs b/src/SMAPI/Events/IGameLoopEvents.cs index e1900f79..ea79aa74 100644 --- a/src/SMAPI/Events/IGameLoopEvents.cs +++ b/src/SMAPI/Events/IGameLoopEvents.cs @@ -26,7 +26,7 @@ namespace StardewModdingAPI.Events /// Raised after the game finishes writing data to the save file (except the initial save creation). event EventHandler Saved; - /// Raised after the player loads a save slot. + /// Raised after the player loads a save slot and the world is initialised. event EventHandler SaveLoaded; /// Raised after the game begins a new day (including when the player loads a save). diff --git a/src/SMAPI/Events/ISpecialisedEvents.cs b/src/SMAPI/Events/ISpecialisedEvents.cs index 928cd05d..2a19113c 100644 --- a/src/SMAPI/Events/ISpecialisedEvents.cs +++ b/src/SMAPI/Events/ISpecialisedEvents.cs @@ -5,6 +5,9 @@ namespace StardewModdingAPI.Events /// Events serving specialised edge cases that shouldn't be used by most mods. public interface ISpecialisedEvents { + /// Raised immediately after the player loads a save slot, but before the world is fully initialised. The save and game data are available at this point, but some in-game content (like location maps) haven't been initialised yet. + event EventHandler SavePreloaded; + /// Raised before the game state is updated (≈60 times per second), regardless of normal SMAPI validation. This event is not thread-safe and may be invoked while game logic is running asynchronously. Changes to game state in this method may crash the game or corrupt an in-progress save. Do not use this event unless you're fully aware of the context in which your code will be run. Mods using this event will trigger a stability warning in the SMAPI console. event EventHandler UnvalidatedUpdateTicking; diff --git a/src/SMAPI/Events/SavePreloadedEventArgs.cs b/src/SMAPI/Events/SavePreloadedEventArgs.cs new file mode 100644 index 00000000..03990f5a --- /dev/null +++ b/src/SMAPI/Events/SavePreloadedEventArgs.cs @@ -0,0 +1,7 @@ +using System; + +namespace StardewModdingAPI.Events +{ + /// Event arguments for an event. + public class SavePreloadedEventArgs : EventArgs { } +} -- cgit From 6ad52d607c49b16c6933060375086830edd9a1f9 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Mon, 24 Dec 2018 17:28:58 -0500 Subject: add Specialised.LoadStageChanged event --- src/SMAPI/Events/ISpecialisedEvents.cs | 4 ++-- src/SMAPI/Events/LoadStageChangedEventArgs.cs | 31 +++++++++++++++++++++++++++ src/SMAPI/Events/SavePreloadedEventArgs.cs | 7 ------ 3 files changed, 33 insertions(+), 9 deletions(-) create mode 100644 src/SMAPI/Events/LoadStageChangedEventArgs.cs delete mode 100644 src/SMAPI/Events/SavePreloadedEventArgs.cs (limited to 'src/SMAPI/Events') diff --git a/src/SMAPI/Events/ISpecialisedEvents.cs b/src/SMAPI/Events/ISpecialisedEvents.cs index 2a19113c..ecb109e6 100644 --- a/src/SMAPI/Events/ISpecialisedEvents.cs +++ b/src/SMAPI/Events/ISpecialisedEvents.cs @@ -5,8 +5,8 @@ namespace StardewModdingAPI.Events /// Events serving specialised edge cases that shouldn't be used by most mods. public interface ISpecialisedEvents { - /// Raised immediately after the player loads a save slot, but before the world is fully initialised. The save and game data are available at this point, but some in-game content (like location maps) haven't been initialised yet. - event EventHandler SavePreloaded; + /// Raised when the low-level stage in the game's loading process has changed. This is an advanced event for mods which need to run code at specific points in the loading process. The available stages or when they happen might change without warning in future versions (e.g. due to changes in the game's load process), so mods using this event are more likely to break or have bugs. Most mods should use instead. + event EventHandler LoadStageChanged; /// Raised before the game state is updated (≈60 times per second), regardless of normal SMAPI validation. This event is not thread-safe and may be invoked while game logic is running asynchronously. Changes to game state in this method may crash the game or corrupt an in-progress save. Do not use this event unless you're fully aware of the context in which your code will be run. Mods using this event will trigger a stability warning in the SMAPI console. event EventHandler UnvalidatedUpdateTicking; diff --git a/src/SMAPI/Events/LoadStageChangedEventArgs.cs b/src/SMAPI/Events/LoadStageChangedEventArgs.cs new file mode 100644 index 00000000..e837a5f1 --- /dev/null +++ b/src/SMAPI/Events/LoadStageChangedEventArgs.cs @@ -0,0 +1,31 @@ +using System; +using StardewModdingAPI.Enums; + +namespace StardewModdingAPI.Events +{ + /// Event arguments for an event. + public class LoadStageChangedEventArgs : EventArgs + { + /********* + ** Accessors + *********/ + /// The previous load stage. + public LoadStage OldStage { get; } + + /// The new load stage. + public LoadStage NewStage { get; } + + + /********* + ** Public methods + *********/ + /// Construct an instance. + /// The previous load stage. + /// The new load stage. + public LoadStageChangedEventArgs(LoadStage old, LoadStage current) + { + this.OldStage = old; + this.NewStage = current; + } + } +} diff --git a/src/SMAPI/Events/SavePreloadedEventArgs.cs b/src/SMAPI/Events/SavePreloadedEventArgs.cs deleted file mode 100644 index 03990f5a..00000000 --- a/src/SMAPI/Events/SavePreloadedEventArgs.cs +++ /dev/null @@ -1,7 +0,0 @@ -using System; - -namespace StardewModdingAPI.Events -{ - /// Event arguments for an event. - public class SavePreloadedEventArgs : EventArgs { } -} -- cgit From 8e0573d7d9f18792a19e741660b6a090cca1fb38 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Tue, 25 Dec 2018 15:10:22 -0500 Subject: add GameLoop.OneSecondUpdateTicking/Ticked --- src/SMAPI/Events/IGameLoopEvents.cs | 6 ++++ src/SMAPI/Events/OneSecondUpdateTickedEventArgs.cs | 32 ++++++++++++++++++++++ .../Events/OneSecondUpdateTickingEventArgs.cs | 32 ++++++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 src/SMAPI/Events/OneSecondUpdateTickedEventArgs.cs create mode 100644 src/SMAPI/Events/OneSecondUpdateTickingEventArgs.cs (limited to 'src/SMAPI/Events') diff --git a/src/SMAPI/Events/IGameLoopEvents.cs b/src/SMAPI/Events/IGameLoopEvents.cs index ea79aa74..6fb56c8b 100644 --- a/src/SMAPI/Events/IGameLoopEvents.cs +++ b/src/SMAPI/Events/IGameLoopEvents.cs @@ -14,6 +14,12 @@ namespace StardewModdingAPI.Events /// Raised after the game state is updated (≈60 times per second). event EventHandler UpdateTicked; + /// Raised once per second before the game state is updated. + event EventHandler OneSecondUpdateTicking; + + /// Raised once per second after the game state is updated. + event EventHandler OneSecondUpdateTicked; + /// Raised before the game creates a new save file. event EventHandler SaveCreating; diff --git a/src/SMAPI/Events/OneSecondUpdateTickedEventArgs.cs b/src/SMAPI/Events/OneSecondUpdateTickedEventArgs.cs new file mode 100644 index 00000000..d330502a --- /dev/null +++ b/src/SMAPI/Events/OneSecondUpdateTickedEventArgs.cs @@ -0,0 +1,32 @@ +using System; + +namespace StardewModdingAPI.Events +{ + /// Event arguments for an event. + public class OneSecondUpdateTickedEventArgs : EventArgs + { + /********* + ** Accessors + *********/ + /// The number of ticks elapsed since the game started, including the current tick. + public uint Ticks { get; } + + + /********* + ** Public methods + *********/ + /// Construct an instance. + /// The number of ticks elapsed since the game started, including the current tick. + internal OneSecondUpdateTickedEventArgs(uint ticks) + { + this.Ticks = ticks; + } + + /// Get whether is a multiple of the given . This is mainly useful if you want to run logic intermittently (e.g. e.IsMultipleOf(30) for every half-second). + /// The factor to check. + public bool IsMultipleOf(uint number) + { + return this.Ticks % number == 0; + } + } +} diff --git a/src/SMAPI/Events/OneSecondUpdateTickingEventArgs.cs b/src/SMAPI/Events/OneSecondUpdateTickingEventArgs.cs new file mode 100644 index 00000000..cdd9f4cc --- /dev/null +++ b/src/SMAPI/Events/OneSecondUpdateTickingEventArgs.cs @@ -0,0 +1,32 @@ +using System; + +namespace StardewModdingAPI.Events +{ + /// Event arguments for an event. + public class OneSecondUpdateTickingEventArgs : EventArgs + { + /********* + ** Accessors + *********/ + /// The number of ticks elapsed since the game started, including the current tick. + public uint Ticks { get; } + + + /********* + ** Public methods + *********/ + /// Construct an instance. + /// The number of ticks elapsed since the game started, including the current tick. + internal OneSecondUpdateTickingEventArgs(uint ticks) + { + this.Ticks = ticks; + } + + /// Get whether is a multiple of the given . This is mainly useful if you want to run logic intermittently (e.g. e.IsMultipleOf(30) for every half-second). + /// The factor to check. + public bool IsMultipleOf(uint number) + { + return this.Ticks % number == 0; + } + } +} -- cgit From 382b5fe914894b87e44462060ca7ae8415c9533e Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Tue, 25 Dec 2018 15:12:58 -0500 Subject: minor performance optimisation --- src/SMAPI/Events/OneSecondUpdateTickedEventArgs.cs | 10 ++-------- src/SMAPI/Events/OneSecondUpdateTickingEventArgs.cs | 10 ++-------- src/SMAPI/Events/UnvalidatedUpdateTickedEventArgs.cs | 13 +++---------- src/SMAPI/Events/UnvalidatedUpdateTickingEventArgs.cs | 13 +++---------- src/SMAPI/Events/UpdateTickedEventArgs.cs | 13 +++---------- src/SMAPI/Events/UpdateTickingEventArgs.cs | 13 +++---------- 6 files changed, 16 insertions(+), 56 deletions(-) (limited to 'src/SMAPI/Events') diff --git a/src/SMAPI/Events/OneSecondUpdateTickedEventArgs.cs b/src/SMAPI/Events/OneSecondUpdateTickedEventArgs.cs index d330502a..dadbb71a 100644 --- a/src/SMAPI/Events/OneSecondUpdateTickedEventArgs.cs +++ b/src/SMAPI/Events/OneSecondUpdateTickedEventArgs.cs @@ -1,4 +1,5 @@ using System; +using StardewValley; namespace StardewModdingAPI.Events { @@ -9,19 +10,12 @@ namespace StardewModdingAPI.Events ** Accessors *********/ /// The number of ticks elapsed since the game started, including the current tick. - public uint Ticks { get; } + public uint Ticks => (uint)Game1.ticks; /********* ** Public methods *********/ - /// Construct an instance. - /// The number of ticks elapsed since the game started, including the current tick. - internal OneSecondUpdateTickedEventArgs(uint ticks) - { - this.Ticks = ticks; - } - /// Get whether is a multiple of the given . This is mainly useful if you want to run logic intermittently (e.g. e.IsMultipleOf(30) for every half-second). /// The factor to check. public bool IsMultipleOf(uint number) diff --git a/src/SMAPI/Events/OneSecondUpdateTickingEventArgs.cs b/src/SMAPI/Events/OneSecondUpdateTickingEventArgs.cs index cdd9f4cc..e9bb46c6 100644 --- a/src/SMAPI/Events/OneSecondUpdateTickingEventArgs.cs +++ b/src/SMAPI/Events/OneSecondUpdateTickingEventArgs.cs @@ -1,4 +1,5 @@ using System; +using StardewValley; namespace StardewModdingAPI.Events { @@ -9,19 +10,12 @@ namespace StardewModdingAPI.Events ** Accessors *********/ /// The number of ticks elapsed since the game started, including the current tick. - public uint Ticks { get; } + public uint Ticks => (uint)Game1.ticks; /********* ** Public methods *********/ - /// Construct an instance. - /// The number of ticks elapsed since the game started, including the current tick. - internal OneSecondUpdateTickingEventArgs(uint ticks) - { - this.Ticks = ticks; - } - /// Get whether is a multiple of the given . This is mainly useful if you want to run logic intermittently (e.g. e.IsMultipleOf(30) for every half-second). /// The factor to check. public bool IsMultipleOf(uint number) diff --git a/src/SMAPI/Events/UnvalidatedUpdateTickedEventArgs.cs b/src/SMAPI/Events/UnvalidatedUpdateTickedEventArgs.cs index 95ae59d8..d15e9531 100644 --- a/src/SMAPI/Events/UnvalidatedUpdateTickedEventArgs.cs +++ b/src/SMAPI/Events/UnvalidatedUpdateTickedEventArgs.cs @@ -1,4 +1,5 @@ using System; +using StardewValley; namespace StardewModdingAPI.Events { @@ -9,23 +10,15 @@ namespace StardewModdingAPI.Events ** Accessors *********/ /// The number of ticks elapsed since the game started, including the current tick. - public uint Ticks { get; } + public uint Ticks => (uint)Game1.ticks; /// Whether is a multiple of 60, which happens approximately once per second. - public bool IsOneSecond { get; } + public bool IsOneSecond => Game1.ticks % 60 == 0; /********* ** Public methods *********/ - /// Construct an instance. - /// The number of ticks elapsed since the game started, including the current tick. - internal UnvalidatedUpdateTickedEventArgs(uint ticks) - { - this.Ticks = ticks; - this.IsOneSecond = this.IsMultipleOf(60); - } - /// Get whether is a multiple of the given . This is mainly useful if you want to run logic intermittently (e.g. e.IsMultipleOf(30) for every half-second). /// The factor to check. public bool IsMultipleOf(uint number) diff --git a/src/SMAPI/Events/UnvalidatedUpdateTickingEventArgs.cs b/src/SMAPI/Events/UnvalidatedUpdateTickingEventArgs.cs index 4ed781e0..577f0776 100644 --- a/src/SMAPI/Events/UnvalidatedUpdateTickingEventArgs.cs +++ b/src/SMAPI/Events/UnvalidatedUpdateTickingEventArgs.cs @@ -1,4 +1,5 @@ using System; +using StardewValley; namespace StardewModdingAPI.Events { @@ -9,23 +10,15 @@ namespace StardewModdingAPI.Events ** Accessors *********/ /// The number of ticks elapsed since the game started, including the current tick. - public uint Ticks { get; } + public uint Ticks => (uint)Game1.ticks; /// Whether is a multiple of 60, which happens approximately once per second. - public bool IsOneSecond { get; } + public bool IsOneSecond => Game1.ticks % 60 == 0; /********* ** Public methods *********/ - /// Construct an instance. - /// The number of ticks elapsed since the game started, including the current tick. - internal UnvalidatedUpdateTickingEventArgs(uint ticks) - { - this.Ticks = ticks; - this.IsOneSecond = this.IsMultipleOf(60); - } - /// Get whether is a multiple of the given . This is mainly useful if you want to run logic intermittently (e.g. e.IsMultipleOf(30) for every half-second). /// The factor to check. public bool IsMultipleOf(uint number) diff --git a/src/SMAPI/Events/UpdateTickedEventArgs.cs b/src/SMAPI/Events/UpdateTickedEventArgs.cs index 3466b731..aa710b44 100644 --- a/src/SMAPI/Events/UpdateTickedEventArgs.cs +++ b/src/SMAPI/Events/UpdateTickedEventArgs.cs @@ -1,4 +1,5 @@ using System; +using StardewValley; namespace StardewModdingAPI.Events { @@ -9,23 +10,15 @@ namespace StardewModdingAPI.Events ** Accessors *********/ /// The number of ticks elapsed since the game started, including the current tick. - public uint Ticks { get; } + public uint Ticks => (uint)Game1.ticks; /// Whether is a multiple of 60, which happens approximately once per second. - public bool IsOneSecond { get; } + public bool IsOneSecond => Game1.ticks % 60 == 0; /********* ** Public methods *********/ - /// Construct an instance. - /// The number of ticks elapsed since the game started, including the current tick. - internal UpdateTickedEventArgs(uint ticks) - { - this.Ticks = ticks; - this.IsOneSecond = this.IsMultipleOf(60); - } - /// Get whether is a multiple of the given . This is mainly useful if you want to run logic intermittently (e.g. e.IsMultipleOf(30) for every half-second). /// The factor to check. public bool IsMultipleOf(uint number) diff --git a/src/SMAPI/Events/UpdateTickingEventArgs.cs b/src/SMAPI/Events/UpdateTickingEventArgs.cs index d4913268..cacf5a54 100644 --- a/src/SMAPI/Events/UpdateTickingEventArgs.cs +++ b/src/SMAPI/Events/UpdateTickingEventArgs.cs @@ -1,4 +1,5 @@ using System; +using StardewValley; namespace StardewModdingAPI.Events { @@ -9,23 +10,15 @@ namespace StardewModdingAPI.Events ** Accessors *********/ /// The number of ticks elapsed since the game started, including the current tick. - public uint Ticks { get; } + public uint Ticks => (uint)Game1.ticks; /// Whether is a multiple of 60, which happens approximately once per second. - public bool IsOneSecond { get; } + public bool IsOneSecond => Game1.ticks % 60 == 0; /********* ** Public methods *********/ - /// Construct an instance. - /// The number of ticks elapsed since the game started, including the current tick. - internal UpdateTickingEventArgs(uint ticks) - { - this.Ticks = ticks; - this.IsOneSecond = this.IsMultipleOf(60); - } - /// Get whether is a multiple of the given . This is mainly useful if you want to run logic intermittently (e.g. e.IsMultipleOf(30) for every half-second). /// The factor to check. public bool IsMultipleOf(uint number) -- cgit From c4a82418ac8b09a6965052f5c9173928457fba52 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Thu, 27 Dec 2018 12:39:10 -0500 Subject: tweak comment header convention --- src/SMAPI/Events/ButtonPressedEventArgs.cs | 2 +- src/SMAPI/Events/ButtonReleasedEventArgs.cs | 2 +- src/SMAPI/Events/ContentEvents.cs | 2 +- src/SMAPI/Events/ControlEvents.cs | 2 +- src/SMAPI/Events/EventArgsInput.cs | 2 +- src/SMAPI/Events/GameEvents.cs | 2 +- src/SMAPI/Events/GraphicsEvents.cs | 2 +- src/SMAPI/Events/InputEvents.cs | 2 +- src/SMAPI/Events/LocationEvents.cs | 2 +- src/SMAPI/Events/MenuEvents.cs | 2 +- src/SMAPI/Events/MineEvents.cs | 2 +- src/SMAPI/Events/ModMessageReceivedEventArgs.cs | 2 +- src/SMAPI/Events/MultiplayerEvents.cs | 2 +- src/SMAPI/Events/PlayerEvents.cs | 2 +- src/SMAPI/Events/SaveEvents.cs | 2 +- src/SMAPI/Events/SpecialisedEvents.cs | 2 +- src/SMAPI/Events/TimeEvents.cs | 2 +- 17 files changed, 17 insertions(+), 17 deletions(-) (limited to 'src/SMAPI/Events') diff --git a/src/SMAPI/Events/ButtonPressedEventArgs.cs b/src/SMAPI/Events/ButtonPressedEventArgs.cs index 9e6c187f..5d922666 100644 --- a/src/SMAPI/Events/ButtonPressedEventArgs.cs +++ b/src/SMAPI/Events/ButtonPressedEventArgs.cs @@ -7,7 +7,7 @@ namespace StardewModdingAPI.Events public class ButtonPressedEventArgs : EventArgs { /********* - ** Properties + ** Fields *********/ /// The game's current input state. private readonly SInputState InputState; diff --git a/src/SMAPI/Events/ButtonReleasedEventArgs.cs b/src/SMAPI/Events/ButtonReleasedEventArgs.cs index 2a289bc7..f5282230 100644 --- a/src/SMAPI/Events/ButtonReleasedEventArgs.cs +++ b/src/SMAPI/Events/ButtonReleasedEventArgs.cs @@ -7,7 +7,7 @@ namespace StardewModdingAPI.Events public class ButtonReleasedEventArgs : EventArgs { /********* - ** Properties + ** Fields *********/ /// The game's current input state. private readonly SInputState InputState; diff --git a/src/SMAPI/Events/ContentEvents.cs b/src/SMAPI/Events/ContentEvents.cs index 1a2dd526..aca76ef7 100644 --- a/src/SMAPI/Events/ContentEvents.cs +++ b/src/SMAPI/Events/ContentEvents.cs @@ -10,7 +10,7 @@ namespace StardewModdingAPI.Events public static class ContentEvents { /********* - ** Properties + ** Fields *********/ /// The core event manager. private static EventManager EventManager; diff --git a/src/SMAPI/Events/ControlEvents.cs b/src/SMAPI/Events/ControlEvents.cs index be849f95..45aedc9b 100644 --- a/src/SMAPI/Events/ControlEvents.cs +++ b/src/SMAPI/Events/ControlEvents.cs @@ -11,7 +11,7 @@ namespace StardewModdingAPI.Events public static class ControlEvents { /********* - ** Properties + ** Fields *********/ /// The core event manager. private static EventManager EventManager; diff --git a/src/SMAPI/Events/EventArgsInput.cs b/src/SMAPI/Events/EventArgsInput.cs index 837de2f8..5cff3408 100644 --- a/src/SMAPI/Events/EventArgsInput.cs +++ b/src/SMAPI/Events/EventArgsInput.cs @@ -8,7 +8,7 @@ namespace StardewModdingAPI.Events public class EventArgsInput : EventArgs { /********* - ** Properties + ** Fields *********/ /// The buttons to suppress. private readonly HashSet SuppressButtons; diff --git a/src/SMAPI/Events/GameEvents.cs b/src/SMAPI/Events/GameEvents.cs index 6069a185..9d945277 100644 --- a/src/SMAPI/Events/GameEvents.cs +++ b/src/SMAPI/Events/GameEvents.cs @@ -10,7 +10,7 @@ namespace StardewModdingAPI.Events public static class GameEvents { /********* - ** Properties + ** Fields *********/ /// The core event manager. private static EventManager EventManager; diff --git a/src/SMAPI/Events/GraphicsEvents.cs b/src/SMAPI/Events/GraphicsEvents.cs index 88a32c3f..24a16a29 100644 --- a/src/SMAPI/Events/GraphicsEvents.cs +++ b/src/SMAPI/Events/GraphicsEvents.cs @@ -10,7 +10,7 @@ namespace StardewModdingAPI.Events public static class GraphicsEvents { /********* - ** Properties + ** Fields *********/ /// The core event manager. private static EventManager EventManager; diff --git a/src/SMAPI/Events/InputEvents.cs b/src/SMAPI/Events/InputEvents.cs index 900e53ea..c5ab8c83 100644 --- a/src/SMAPI/Events/InputEvents.cs +++ b/src/SMAPI/Events/InputEvents.cs @@ -10,7 +10,7 @@ namespace StardewModdingAPI.Events public static class InputEvents { /********* - ** Properties + ** Fields *********/ /// The core event manager. private static EventManager EventManager; diff --git a/src/SMAPI/Events/LocationEvents.cs b/src/SMAPI/Events/LocationEvents.cs index 5eb228b7..0761bdd8 100644 --- a/src/SMAPI/Events/LocationEvents.cs +++ b/src/SMAPI/Events/LocationEvents.cs @@ -10,7 +10,7 @@ namespace StardewModdingAPI.Events public static class LocationEvents { /********* - ** Properties + ** Fields *********/ /// The core event manager. private static EventManager EventManager; diff --git a/src/SMAPI/Events/MenuEvents.cs b/src/SMAPI/Events/MenuEvents.cs index 914948dd..8647c268 100644 --- a/src/SMAPI/Events/MenuEvents.cs +++ b/src/SMAPI/Events/MenuEvents.cs @@ -10,7 +10,7 @@ namespace StardewModdingAPI.Events public static class MenuEvents { /********* - ** Properties + ** Fields *********/ /// The core event manager. private static EventManager EventManager; diff --git a/src/SMAPI/Events/MineEvents.cs b/src/SMAPI/Events/MineEvents.cs index fd35237e..929da35b 100644 --- a/src/SMAPI/Events/MineEvents.cs +++ b/src/SMAPI/Events/MineEvents.cs @@ -10,7 +10,7 @@ namespace StardewModdingAPI.Events public static class MineEvents { /********* - ** Properties + ** Fields *********/ /// The core event manager. private static EventManager EventManager; diff --git a/src/SMAPI/Events/ModMessageReceivedEventArgs.cs b/src/SMAPI/Events/ModMessageReceivedEventArgs.cs index 49366ec6..d4370028 100644 --- a/src/SMAPI/Events/ModMessageReceivedEventArgs.cs +++ b/src/SMAPI/Events/ModMessageReceivedEventArgs.cs @@ -7,7 +7,7 @@ namespace StardewModdingAPI.Events public class ModMessageReceivedEventArgs : EventArgs { /********* - ** Properties + ** Fields *********/ /// The underlying message model. private readonly ModMessageModel Message; diff --git a/src/SMAPI/Events/MultiplayerEvents.cs b/src/SMAPI/Events/MultiplayerEvents.cs index 5e6a22dc..0650a8e2 100644 --- a/src/SMAPI/Events/MultiplayerEvents.cs +++ b/src/SMAPI/Events/MultiplayerEvents.cs @@ -10,7 +10,7 @@ namespace StardewModdingAPI.Events public static class MultiplayerEvents { /********* - ** Properties + ** Fields *********/ /// The core event manager. private static EventManager EventManager; diff --git a/src/SMAPI/Events/PlayerEvents.cs b/src/SMAPI/Events/PlayerEvents.cs index 98bc3da5..11ba1e54 100644 --- a/src/SMAPI/Events/PlayerEvents.cs +++ b/src/SMAPI/Events/PlayerEvents.cs @@ -10,7 +10,7 @@ namespace StardewModdingAPI.Events public static class PlayerEvents { /********* - ** Properties + ** Fields *********/ /// The core event manager. private static EventManager EventManager; diff --git a/src/SMAPI/Events/SaveEvents.cs b/src/SMAPI/Events/SaveEvents.cs index 959fb5d2..da276d22 100644 --- a/src/SMAPI/Events/SaveEvents.cs +++ b/src/SMAPI/Events/SaveEvents.cs @@ -10,7 +10,7 @@ namespace StardewModdingAPI.Events public static class SaveEvents { /********* - ** Properties + ** Fields *********/ /// The core event manager. private static EventManager EventManager; diff --git a/src/SMAPI/Events/SpecialisedEvents.cs b/src/SMAPI/Events/SpecialisedEvents.cs index 2c6d0230..4f16e4da 100644 --- a/src/SMAPI/Events/SpecialisedEvents.cs +++ b/src/SMAPI/Events/SpecialisedEvents.cs @@ -10,7 +10,7 @@ namespace StardewModdingAPI.Events public static class SpecialisedEvents { /********* - ** Properties + ** Fields *********/ /// The core event manager. private static EventManager EventManager; diff --git a/src/SMAPI/Events/TimeEvents.cs b/src/SMAPI/Events/TimeEvents.cs index 40892491..389532d9 100644 --- a/src/SMAPI/Events/TimeEvents.cs +++ b/src/SMAPI/Events/TimeEvents.cs @@ -10,7 +10,7 @@ namespace StardewModdingAPI.Events public static class TimeEvents { /********* - ** Properties + ** Fields *********/ /// The core event manager. private static EventManager EventManager; -- cgit From dae12c16e5ecb88e8043272c9d8ffdc88bc351ca Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 29 Dec 2018 18:31:23 -0500 Subject: add IsCurrentLocation event arg to World events --- src/SMAPI/Events/BuildingListChangedEventArgs.cs | 3 +++ src/SMAPI/Events/DebrisListChangedEventArgs.cs | 3 +++ src/SMAPI/Events/LargeTerrainFeatureListChangedEventArgs.cs | 3 +++ src/SMAPI/Events/NpcListChangedEventArgs.cs | 3 +++ src/SMAPI/Events/ObjectListChangedEventArgs.cs | 3 +++ src/SMAPI/Events/TerrainFeatureListChangedEventArgs.cs | 3 +++ 6 files changed, 18 insertions(+) (limited to 'src/SMAPI/Events') diff --git a/src/SMAPI/Events/BuildingListChangedEventArgs.cs b/src/SMAPI/Events/BuildingListChangedEventArgs.cs index 0237342f..74f37710 100644 --- a/src/SMAPI/Events/BuildingListChangedEventArgs.cs +++ b/src/SMAPI/Events/BuildingListChangedEventArgs.cs @@ -21,6 +21,9 @@ namespace StardewModdingAPI.Events /// The buildings removed from the location. public IEnumerable Removed { get; } + /// Whether this is the location containing the local player. + public bool IsCurrentLocation => object.ReferenceEquals(this.Location, Game1.player?.currentLocation); + /********* ** Public methods diff --git a/src/SMAPI/Events/DebrisListChangedEventArgs.cs b/src/SMAPI/Events/DebrisListChangedEventArgs.cs index 68328885..61b7590a 100644 --- a/src/SMAPI/Events/DebrisListChangedEventArgs.cs +++ b/src/SMAPI/Events/DebrisListChangedEventArgs.cs @@ -20,6 +20,9 @@ namespace StardewModdingAPI.Events /// The debris removed from the location. public IEnumerable Removed { get; } + /// Whether this is the location containing the local player. + public bool IsCurrentLocation => object.ReferenceEquals(this.Location, Game1.player?.currentLocation); + /********* ** Public methods diff --git a/src/SMAPI/Events/LargeTerrainFeatureListChangedEventArgs.cs b/src/SMAPI/Events/LargeTerrainFeatureListChangedEventArgs.cs index c7d55bf8..59d79f0f 100644 --- a/src/SMAPI/Events/LargeTerrainFeatureListChangedEventArgs.cs +++ b/src/SMAPI/Events/LargeTerrainFeatureListChangedEventArgs.cs @@ -21,6 +21,9 @@ namespace StardewModdingAPI.Events /// The large terrain features removed from the location. public IEnumerable Removed { get; } + /// Whether this is the location containing the local player. + public bool IsCurrentLocation => object.ReferenceEquals(this.Location, Game1.player?.currentLocation); + /********* ** Public methods diff --git a/src/SMAPI/Events/NpcListChangedEventArgs.cs b/src/SMAPI/Events/NpcListChangedEventArgs.cs index a9ec2a3b..3a37f1e7 100644 --- a/src/SMAPI/Events/NpcListChangedEventArgs.cs +++ b/src/SMAPI/Events/NpcListChangedEventArgs.cs @@ -20,6 +20,9 @@ namespace StardewModdingAPI.Events /// The NPCs removed from the location. public IEnumerable Removed { get; } + /// Whether this is the location containing the local player. + public bool IsCurrentLocation => object.ReferenceEquals(this.Location, Game1.player?.currentLocation); + /********* ** Public methods diff --git a/src/SMAPI/Events/ObjectListChangedEventArgs.cs b/src/SMAPI/Events/ObjectListChangedEventArgs.cs index d0cf9e7b..b21d2867 100644 --- a/src/SMAPI/Events/ObjectListChangedEventArgs.cs +++ b/src/SMAPI/Events/ObjectListChangedEventArgs.cs @@ -22,6 +22,9 @@ namespace StardewModdingAPI.Events /// The objects removed from the location. public IEnumerable> Removed { get; } + /// Whether this is the location containing the local player. + public bool IsCurrentLocation => object.ReferenceEquals(this.Location, Game1.player?.currentLocation); + /********* ** Public methods diff --git a/src/SMAPI/Events/TerrainFeatureListChangedEventArgs.cs b/src/SMAPI/Events/TerrainFeatureListChangedEventArgs.cs index 0992633e..cdf1e6dc 100644 --- a/src/SMAPI/Events/TerrainFeatureListChangedEventArgs.cs +++ b/src/SMAPI/Events/TerrainFeatureListChangedEventArgs.cs @@ -22,6 +22,9 @@ namespace StardewModdingAPI.Events /// The terrain features removed from the location. public IEnumerable> Removed { get; } + /// Whether this is the location containing the local player. + public bool IsCurrentLocation => object.ReferenceEquals(this.Location, Game1.player?.currentLocation); + /********* ** Public methods -- cgit