diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-08-01 11:07:29 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-08-01 11:07:29 -0400 |
commit | 60b41195778af33fd609eab66d9ae3f1d1165e8f (patch) | |
tree | 7128b906d40e94c56c34ed6058f27bc31c31a08b /src/SMAPI/Events/GameLoopUpdatedEventArgs.cs | |
parent | b9bc1a6d17cafa0a97b46ffecda432cfc2f23b51 (diff) | |
parent | 52cf953f685c65b2b6814e375ec9a5ffa03c440a (diff) | |
download | SMAPI-60b41195778af33fd609eab66d9ae3f1d1165e8f.tar.gz SMAPI-60b41195778af33fd609eab66d9ae3f1d1165e8f.tar.bz2 SMAPI-60b41195778af33fd609eab66d9ae3f1d1165e8f.zip |
Merge branch 'develop' into stable
Diffstat (limited to 'src/SMAPI/Events/GameLoopUpdatedEventArgs.cs')
-rw-r--r-- | src/SMAPI/Events/GameLoopUpdatedEventArgs.cs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/SMAPI/Events/GameLoopUpdatedEventArgs.cs b/src/SMAPI/Events/GameLoopUpdatedEventArgs.cs new file mode 100644 index 00000000..3ad34b69 --- /dev/null +++ b/src/SMAPI/Events/GameLoopUpdatedEventArgs.cs @@ -0,0 +1,36 @@ +using System; + +namespace StardewModdingAPI.Events +{ + /// <summary>Event arguments for an <see cref="IGameLoopEvents.Updated"/> event.</summary> + public class GameLoopUpdatedEventArgs : EventArgs + { + /********* + ** Accessors + *********/ + /// <summary>The number of ticks elapsed since the game started, including the current tick.</summary> + public uint Ticks { get; } + + /// <summary>Whether <see cref="Ticks"/> is a multiple of 60, which happens approximately once per second.</summary> + public bool IsOneSecond { get; } + + + /********* + ** Public methods + *********/ + /// <summary>Construct an instance.</summary> + /// <param name="ticks">The number of ticks elapsed since the game started, including the current tick.</param> + public GameLoopUpdatedEventArgs(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) + { + return this.Ticks % number == 0; + } + } +} |