diff options
Diffstat (limited to 'src/SMAPI/Events')
32 files changed, 140 insertions, 58 deletions
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 /// <summary>The buildings removed from the location.</summary> public IEnumerable<Building> Removed { get; } + /// <summary>Whether this is the location containing the local player.</summary> + public bool IsCurrentLocation => object.ReferenceEquals(this.Location, Game1.player?.currentLocation); + /********* ** Public methods 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 *********/ /// <summary>The game's current input state.</summary> 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 *********/ /// <summary>The game's current input state.</summary> 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 *********/ /// <summary>The core event manager.</summary> 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 *********/ /// <summary>The core event manager.</summary> private static EventManager EventManager; 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 /// <summary>The debris removed from the location.</summary> public IEnumerable<Debris> Removed { get; } + /// <summary>Whether this is the location containing the local player.</summary> + public bool IsCurrentLocation => object.ReferenceEquals(this.Location, Game1.player?.currentLocation); + /********* ** Public methods 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 *********/ /// <summary>The buttons to suppress.</summary> private readonly HashSet<SButton> 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 *********/ /// <summary>The core event manager.</summary> 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 *********/ /// <summary>The core event manager.</summary> private static EventManager EventManager; diff --git a/src/SMAPI/Events/IGameLoopEvents.cs b/src/SMAPI/Events/IGameLoopEvents.cs index e1900f79..6fb56c8b 100644 --- a/src/SMAPI/Events/IGameLoopEvents.cs +++ b/src/SMAPI/Events/IGameLoopEvents.cs @@ -14,6 +14,12 @@ namespace StardewModdingAPI.Events /// <summary>Raised after the game state is updated (≈60 times per second).</summary> event EventHandler<UpdateTickedEventArgs> UpdateTicked; + /// <summary>Raised once per second before the game state is updated.</summary> + event EventHandler<OneSecondUpdateTickingEventArgs> OneSecondUpdateTicking; + + /// <summary>Raised once per second after the game state is updated.</summary> + event EventHandler<OneSecondUpdateTickedEventArgs> OneSecondUpdateTicked; + /// <summary>Raised before the game creates a new save file.</summary> event EventHandler<SaveCreatingEventArgs> SaveCreating; @@ -26,7 +32,7 @@ namespace StardewModdingAPI.Events /// <summary>Raised after the game finishes writing data to the save file (except the initial save creation).</summary> event EventHandler<SavedEventArgs> Saved; - /// <summary>Raised after the player loads a save slot.</summary> + /// <summary>Raised after the player loads a save slot and the world is initialised.</summary> event EventHandler<SaveLoadedEventArgs> SaveLoaded; /// <summary>Raised after the game begins a new day (including when the player loads a save).</summary> diff --git a/src/SMAPI/Events/ISpecialisedEvents.cs b/src/SMAPI/Events/ISpecialisedEvents.cs index 928cd05d..ecb109e6 100644 --- a/src/SMAPI/Events/ISpecialisedEvents.cs +++ b/src/SMAPI/Events/ISpecialisedEvents.cs @@ -5,6 +5,9 @@ namespace StardewModdingAPI.Events /// <summary>Events serving specialised edge cases that shouldn't be used by most mods.</summary> public interface ISpecialisedEvents { + /// <summary>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 <see cref="IGameLoopEvents"/> instead.</summary> + event EventHandler<LoadStageChangedEventArgs> LoadStageChanged; + /// <summary>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.</summary> event EventHandler<UnvalidatedUpdateTickingEventArgs> UnvalidatedUpdateTicking; 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 *********/ /// <summary>The core event manager.</summary> private static EventManager EventManager; 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 /// <summary>The large terrain features removed from the location.</summary> public IEnumerable<LargeTerrainFeature> Removed { get; } + /// <summary>Whether this is the location containing the local player.</summary> + public bool IsCurrentLocation => object.ReferenceEquals(this.Location, Game1.player?.currentLocation); + /********* ** Public methods 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 +{ + /// <summary>Event arguments for an <see cref="ISpecialisedEvents.LoadStageChanged"/> event.</summary> + public class LoadStageChangedEventArgs : EventArgs + { + /********* + ** Accessors + *********/ + /// <summary>The previous load stage.</summary> + public LoadStage OldStage { get; } + + /// <summary>The new load stage.</summary> + public LoadStage NewStage { get; } + + + /********* + ** Public methods + *********/ + /// <summary>Construct an instance.</summary> + /// <param name="old">The previous load stage.</param> + /// <param name="current">The new load stage.</param> + public LoadStageChangedEventArgs(LoadStage old, LoadStage current) + { + this.OldStage = old; + this.NewStage = current; + } + } +} 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 *********/ /// <summary>The core event manager.</summary> 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 *********/ /// <summary>The core event manager.</summary> 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 *********/ /// <summary>The core event manager.</summary> 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 *********/ /// <summary>The underlying message model.</summary> 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 *********/ /// <summary>The core event manager.</summary> private static EventManager EventManager; 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 /// <summary>The NPCs removed from the location.</summary> public IEnumerable<NPC> Removed { get; } + /// <summary>Whether this is the location containing the local player.</summary> + 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 /// <summary>The objects removed from the location.</summary> public IEnumerable<KeyValuePair<Vector2, Object>> Removed { get; } + /// <summary>Whether this is the location containing the local player.</summary> + public bool IsCurrentLocation => object.ReferenceEquals(this.Location, Game1.player?.currentLocation); + /********* ** Public methods diff --git a/src/SMAPI/Events/OneSecondUpdateTickedEventArgs.cs b/src/SMAPI/Events/OneSecondUpdateTickedEventArgs.cs new file mode 100644 index 00000000..dadbb71a --- /dev/null +++ b/src/SMAPI/Events/OneSecondUpdateTickedEventArgs.cs @@ -0,0 +1,26 @@ +using System; +using StardewValley; + +namespace StardewModdingAPI.Events +{ + /// <summary>Event arguments for an <see cref="IGameLoopEvents.OneSecondUpdateTicked"/> event.</summary> + public class OneSecondUpdateTickedEventArgs : EventArgs + { + /********* + ** Accessors + *********/ + /// <summary>The number of ticks elapsed since the game started, including the current tick.</summary> + public uint Ticks => (uint)Game1.ticks; + + + /********* + ** Public methods + *********/ + /// <summary>Get whether <see cref="Ticks"/> is a multiple of the given <paramref name="number"/>. This is mainly useful if you want to run logic intermittently (e.g. <code>e.IsMultipleOf(30)</code> for every half-second).</summary> + /// <param name="number">The factor to check.</param> + 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..e9bb46c6 --- /dev/null +++ b/src/SMAPI/Events/OneSecondUpdateTickingEventArgs.cs @@ -0,0 +1,26 @@ +using System; +using StardewValley; + +namespace StardewModdingAPI.Events +{ + /// <summary>Event arguments for an <see cref="IGameLoopEvents.OneSecondUpdateTicking"/> event.</summary> + public class OneSecondUpdateTickingEventArgs : EventArgs + { + /********* + ** Accessors + *********/ + /// <summary>The number of ticks elapsed since the game started, including the current tick.</summary> + public uint Ticks => (uint)Game1.ticks; + + + /********* + ** Public methods + *********/ + /// <summary>Get whether <see cref="Ticks"/> is a multiple of the given <paramref name="number"/>. This is mainly useful if you want to run logic intermittently (e.g. <code>e.IsMultipleOf(30)</code> for every half-second).</summary> + /// <param name="number">The factor to check.</param> + public bool IsMultipleOf(uint number) + { + return this.Ticks % number == 0; + } + } +} 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 *********/ /// <summary>The core event manager.</summary> 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 *********/ /// <summary>The core event manager.</summary> 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 *********/ /// <summary>The core event manager.</summary> private static EventManager EventManager; 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 /// <summary>The terrain features removed from the location.</summary> public IEnumerable<KeyValuePair<Vector2, TerrainFeature>> Removed { get; } + /// <summary>Whether this is the location containing the local player.</summary> + public bool IsCurrentLocation => object.ReferenceEquals(this.Location, Game1.player?.currentLocation); + /********* ** Public methods 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 *********/ /// <summary>The core event manager.</summary> private static EventManager EventManager; 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 *********/ /// <summary>The number of ticks elapsed since the game started, including the current tick.</summary> - public uint Ticks { get; } + public uint Ticks => (uint)Game1.ticks; /// <summary>Whether <see cref="Ticks"/> is a multiple of 60, which happens approximately once per second.</summary> - public bool IsOneSecond { get; } + public bool IsOneSecond => Game1.ticks % 60 == 0; /********* ** Public methods *********/ - /// <summary>Construct an instance.</summary> - /// <param name="ticks">The number of ticks elapsed since the game started, including the current tick.</param> - internal UnvalidatedUpdateTickedEventArgs(uint ticks) - { - this.Ticks = ticks; - this.IsOneSecond = this.IsMultipleOf(60); - } - /// <summary>Get whether <see cref="Ticks"/> is a multiple of the given <paramref name="number"/>. This is mainly useful if you want to run logic intermittently (e.g. <code>e.IsMultipleOf(30)</code> for every half-second).</summary> /// <param name="number">The factor to check.</param> 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 *********/ /// <summary>The number of ticks elapsed since the game started, including the current tick.</summary> - public uint Ticks { get; } + public uint Ticks => (uint)Game1.ticks; /// <summary>Whether <see cref="Ticks"/> is a multiple of 60, which happens approximately once per second.</summary> - public bool IsOneSecond { get; } + public bool IsOneSecond => Game1.ticks % 60 == 0; /********* ** Public methods *********/ - /// <summary>Construct an instance.</summary> - /// <param name="ticks">The number of ticks elapsed since the game started, including the current tick.</param> - internal UnvalidatedUpdateTickingEventArgs(uint ticks) - { - this.Ticks = ticks; - this.IsOneSecond = this.IsMultipleOf(60); - } - /// <summary>Get whether <see cref="Ticks"/> is a multiple of the given <paramref name="number"/>. This is mainly useful if you want to run logic intermittently (e.g. <code>e.IsMultipleOf(30)</code> for every half-second).</summary> /// <param name="number">The factor to check.</param> 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 *********/ /// <summary>The number of ticks elapsed since the game started, including the current tick.</summary> - public uint Ticks { get; } + public uint Ticks => (uint)Game1.ticks; /// <summary>Whether <see cref="Ticks"/> is a multiple of 60, which happens approximately once per second.</summary> - public bool IsOneSecond { get; } + public bool IsOneSecond => Game1.ticks % 60 == 0; /********* ** Public methods *********/ - /// <summary>Construct an instance.</summary> - /// <param name="ticks">The number of ticks elapsed since the game started, including the current tick.</param> - internal UpdateTickedEventArgs(uint ticks) - { - this.Ticks = ticks; - this.IsOneSecond = this.IsMultipleOf(60); - } - /// <summary>Get whether <see cref="Ticks"/> is a multiple of the given <paramref name="number"/>. This is mainly useful if you want to run logic intermittently (e.g. <code>e.IsMultipleOf(30)</code> for every half-second).</summary> /// <param name="number">The factor to check.</param> 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 *********/ /// <summary>The number of ticks elapsed since the game started, including the current tick.</summary> - public uint Ticks { get; } + public uint Ticks => (uint)Game1.ticks; /// <summary>Whether <see cref="Ticks"/> is a multiple of 60, which happens approximately once per second.</summary> - public bool IsOneSecond { get; } + public bool IsOneSecond => Game1.ticks % 60 == 0; /********* ** Public methods *********/ - /// <summary>Construct an instance.</summary> - /// <param name="ticks">The number of ticks elapsed since the game started, including the current tick.</param> - internal UpdateTickingEventArgs(uint ticks) - { - this.Ticks = ticks; - this.IsOneSecond = this.IsMultipleOf(60); - } - /// <summary>Get whether <see cref="Ticks"/> is a multiple of the given <paramref name="number"/>. This is mainly useful if you want to run logic intermittently (e.g. <code>e.IsMultipleOf(30)</code> for every half-second).</summary> /// <param name="number">The factor to check.</param> public bool IsMultipleOf(uint number) |