summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2018-12-25 15:10:22 -0500
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2018-12-25 15:10:22 -0500
commit8e0573d7d9f18792a19e741660b6a090cca1fb38 (patch)
tree8a23c73502a6ab17a0fbac8934107a89fe543be8 /src/SMAPI/Framework
parent6ad52d607c49b16c6933060375086830edd9a1f9 (diff)
downloadSMAPI-8e0573d7d9f18792a19e741660b6a090cca1fb38.tar.gz
SMAPI-8e0573d7d9f18792a19e741660b6a090cca1fb38.tar.bz2
SMAPI-8e0573d7d9f18792a19e741660b6a090cca1fb38.zip
add GameLoop.OneSecondUpdateTicking/Ticked
Diffstat (limited to 'src/SMAPI/Framework')
-rw-r--r--src/SMAPI/Framework/Events/EventManager.cs8
-rw-r--r--src/SMAPI/Framework/Events/ModGameLoopEvents.cs14
-rw-r--r--src/SMAPI/Framework/SGame.cs5
3 files changed, 27 insertions, 0 deletions
diff --git a/src/SMAPI/Framework/Events/EventManager.cs b/src/SMAPI/Framework/Events/EventManager.cs
index b7f00f52..13244601 100644
--- a/src/SMAPI/Framework/Events/EventManager.cs
+++ b/src/SMAPI/Framework/Events/EventManager.cs
@@ -58,6 +58,12 @@ namespace StardewModdingAPI.Framework.Events
/// <summary>Raised after the game performs its overall update tick (≈60 times per second).</summary>
public readonly ManagedEvent<UpdateTickedEventArgs> UpdateTicked;
+ /// <summary>Raised once per second before the game performs its overall update tick.</summary>
+ public readonly ManagedEvent<OneSecondUpdateTickingEventArgs> OneSecondUpdateTicking;
+
+ /// <summary>Raised once per second after the game performs its overall update tick.</summary>
+ public readonly ManagedEvent<OneSecondUpdateTickedEventArgs> OneSecondUpdateTicked;
+
/// <summary>Raised before the game creates the save file.</summary>
public readonly ManagedEvent<SaveCreatingEventArgs> SaveCreating;
@@ -380,6 +386,8 @@ namespace StardewModdingAPI.Framework.Events
this.GameLaunched = ManageEventOf<GameLaunchedEventArgs>(nameof(IModEvents.GameLoop), nameof(IGameLoopEvents.GameLaunched));
this.UpdateTicking = ManageEventOf<UpdateTickingEventArgs>(nameof(IModEvents.GameLoop), nameof(IGameLoopEvents.UpdateTicking));
this.UpdateTicked = ManageEventOf<UpdateTickedEventArgs>(nameof(IModEvents.GameLoop), nameof(IGameLoopEvents.UpdateTicked));
+ this.OneSecondUpdateTicking = ManageEventOf<OneSecondUpdateTickingEventArgs>(nameof(IModEvents.GameLoop), nameof(IGameLoopEvents.OneSecondUpdateTicking));
+ this.OneSecondUpdateTicked = ManageEventOf<OneSecondUpdateTickedEventArgs>(nameof(IModEvents.GameLoop), nameof(IGameLoopEvents.OneSecondUpdateTicked));
this.SaveCreating = ManageEventOf<SaveCreatingEventArgs>(nameof(IModEvents.GameLoop), nameof(IGameLoopEvents.SaveCreating));
this.SaveCreated = ManageEventOf<SaveCreatedEventArgs>(nameof(IModEvents.GameLoop), nameof(IGameLoopEvents.SaveCreated));
this.Saving = ManageEventOf<SavingEventArgs>(nameof(IModEvents.GameLoop), nameof(IGameLoopEvents.Saving));
diff --git a/src/SMAPI/Framework/Events/ModGameLoopEvents.cs b/src/SMAPI/Framework/Events/ModGameLoopEvents.cs
index 3a764ab0..0177c22e 100644
--- a/src/SMAPI/Framework/Events/ModGameLoopEvents.cs
+++ b/src/SMAPI/Framework/Events/ModGameLoopEvents.cs
@@ -30,6 +30,20 @@ namespace StardewModdingAPI.Framework.Events
remove => this.EventManager.UpdateTicked.Remove(value);
}
+ /// <summary>Raised once per second before the game state is updated.</summary>
+ public event EventHandler<OneSecondUpdateTickingEventArgs> OneSecondUpdateTicking
+ {
+ add => this.EventManager.OneSecondUpdateTicking.Add(value);
+ remove => this.EventManager.OneSecondUpdateTicking.Remove(value);
+ }
+
+ /// <summary>Raised once per second after the game state is updated.</summary>
+ public event EventHandler<OneSecondUpdateTickedEventArgs> OneSecondUpdateTicked
+ {
+ add => this.EventManager.OneSecondUpdateTicked.Add(value);
+ remove => this.EventManager.OneSecondUpdateTicked.Remove(value);
+ }
+
/// <summary>Raised before the game creates a new save file.</summary>
public event EventHandler<SaveCreatingEventArgs> SaveCreating
{
diff --git a/src/SMAPI/Framework/SGame.cs b/src/SMAPI/Framework/SGame.cs
index cb62de2a..8abe4d16 100644
--- a/src/SMAPI/Framework/SGame.cs
+++ b/src/SMAPI/Framework/SGame.cs
@@ -878,8 +878,11 @@ namespace StardewModdingAPI.Framework
this.OnLoadStageChanged(LoadStage.Loaded);
// update tick
+ bool isOneSecond = this.TicksElapsed % 60 == 0;
this.Events.UnvalidatedUpdateTicking.Raise(new UnvalidatedUpdateTickingEventArgs(this.TicksElapsed));
this.Events.UpdateTicking.Raise(new UpdateTickingEventArgs(this.TicksElapsed));
+ if (isOneSecond)
+ this.Events.OneSecondUpdateTicking.Raise(new OneSecondUpdateTickingEventArgs(this.TicksElapsed));
try
{
this.Input.UpdateSuppression();
@@ -891,6 +894,8 @@ namespace StardewModdingAPI.Framework
}
this.Events.UnvalidatedUpdateTicked.Raise(new UnvalidatedUpdateTickedEventArgs(this.TicksElapsed));
this.Events.UpdateTicked.Raise(new UpdateTickedEventArgs(this.TicksElapsed));
+ if (isOneSecond)
+ this.Events.OneSecondUpdateTicked.Raise(new OneSecondUpdateTickedEventArgs(this.TicksElapsed));
/*********
** Update events