summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework/Events
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2018-12-29 20:09:33 -0500
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2018-12-29 20:09:33 -0500
commitf046091fe637963fd6a8cc8c1324daf81b64899f (patch)
treeadeffec4a5d31503548ef5dead7d67b3bff9e694 /src/SMAPI/Framework/Events
parent82beefd8531467de318c1881afd15a258d489f37 (diff)
parentca18a2867b457fd6bfda71d9828884032ecadfb8 (diff)
downloadSMAPI-f046091fe637963fd6a8cc8c1324daf81b64899f.tar.gz
SMAPI-f046091fe637963fd6a8cc8c1324daf81b64899f.tar.bz2
SMAPI-f046091fe637963fd6a8cc8c1324daf81b64899f.zip
Merge branch 'develop' into stable
Diffstat (limited to 'src/SMAPI/Framework/Events')
-rw-r--r--src/SMAPI/Framework/Events/EventManager.cs14
-rw-r--r--src/SMAPI/Framework/Events/ManagedEvent.cs6
-rw-r--r--src/SMAPI/Framework/Events/ManagedEventBase.cs2
-rw-r--r--src/SMAPI/Framework/Events/ModEventsBase.cs2
-rw-r--r--src/SMAPI/Framework/Events/ModGameLoopEvents.cs16
-rw-r--r--src/SMAPI/Framework/Events/ModSpecialisedEvents.cs7
6 files changed, 41 insertions, 6 deletions
diff --git a/src/SMAPI/Framework/Events/EventManager.cs b/src/SMAPI/Framework/Events/EventManager.cs
index 0ad85adf..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;
@@ -70,7 +76,7 @@ namespace StardewModdingAPI.Framework.Events
/// <summary>Raised after the game finishes writing data to the save file (except the initial save creation).</summary>
public readonly ManagedEvent<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>
public readonly ManagedEvent<SaveLoadedEventArgs> SaveLoaded;
/// <summary>Raised after the game begins a new day, including when loading a save.</summary>
@@ -151,6 +157,9 @@ namespace StardewModdingAPI.Framework.Events
/****
** Specialised
****/
+ /// <summary>Raised when the low-level stage in the game's loading process has changed. See notes on <see cref="ISpecialisedEvents.LoadStageChanged"/>.</summary>
+ public readonly ManagedEvent<LoadStageChangedEventArgs> LoadStageChanged;
+
/// <summary>Raised before the game performs its overall update tick (≈60 times per second). See notes on <see cref="ISpecialisedEvents.UnvalidatedUpdateTicking"/>.</summary>
public readonly ManagedEvent<UnvalidatedUpdateTickingEventArgs> UnvalidatedUpdateTicking;
@@ -377,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));
@@ -408,6 +419,7 @@ namespace StardewModdingAPI.Framework.Events
this.ObjectListChanged = ManageEventOf<ObjectListChangedEventArgs>(nameof(IModEvents.World), nameof(IWorldEvents.ObjectListChanged));
this.TerrainFeatureListChanged = ManageEventOf<TerrainFeatureListChangedEventArgs>(nameof(IModEvents.World), nameof(IWorldEvents.TerrainFeatureListChanged));
+ this.LoadStageChanged = ManageEventOf<LoadStageChangedEventArgs>(nameof(IModEvents.Specialised), nameof(ISpecialisedEvents.LoadStageChanged));
this.UnvalidatedUpdateTicking = ManageEventOf<UnvalidatedUpdateTickingEventArgs>(nameof(IModEvents.Specialised), nameof(ISpecialisedEvents.UnvalidatedUpdateTicking));
this.UnvalidatedUpdateTicked = ManageEventOf<UnvalidatedUpdateTickedEventArgs>(nameof(IModEvents.Specialised), nameof(ISpecialisedEvents.UnvalidatedUpdateTicked));
diff --git a/src/SMAPI/Framework/Events/ManagedEvent.cs b/src/SMAPI/Framework/Events/ManagedEvent.cs
index 65f6e38e..f9e7f6ec 100644
--- a/src/SMAPI/Framework/Events/ManagedEvent.cs
+++ b/src/SMAPI/Framework/Events/ManagedEvent.cs
@@ -8,7 +8,7 @@ namespace StardewModdingAPI.Framework.Events
internal class ManagedEvent<TEventArgs> : ManagedEventBase<EventHandler<TEventArgs>>
{
/*********
- ** Properties
+ ** Fields
*********/
/// <summary>The underlying event.</summary>
private event EventHandler<TEventArgs> Event;
@@ -93,11 +93,12 @@ namespace StardewModdingAPI.Framework.Events
}
}
+#if !SMAPI_3_0_STRICT
/// <summary>An event wrapper which intercepts and logs errors in handler code.</summary>
internal class ManagedEvent : ManagedEventBase<EventHandler>
{
/*********
- ** Properties
+ ** Fields
*********/
/// <summary>The underlying event.</summary>
private event EventHandler Event;
@@ -156,4 +157,5 @@ namespace StardewModdingAPI.Framework.Events
}
}
}
+#endif
}
diff --git a/src/SMAPI/Framework/Events/ManagedEventBase.cs b/src/SMAPI/Framework/Events/ManagedEventBase.cs
index defd903a..c8c3516b 100644
--- a/src/SMAPI/Framework/Events/ManagedEventBase.cs
+++ b/src/SMAPI/Framework/Events/ManagedEventBase.cs
@@ -8,7 +8,7 @@ namespace StardewModdingAPI.Framework.Events
internal abstract class ManagedEventBase<TEventHandler>
{
/*********
- ** Properties
+ ** Fields
*********/
/// <summary>A human-readable name for the event.</summary>
private readonly string EventName;
diff --git a/src/SMAPI/Framework/Events/ModEventsBase.cs b/src/SMAPI/Framework/Events/ModEventsBase.cs
index 545c58a8..77708fc1 100644
--- a/src/SMAPI/Framework/Events/ModEventsBase.cs
+++ b/src/SMAPI/Framework/Events/ModEventsBase.cs
@@ -4,7 +4,7 @@ namespace StardewModdingAPI.Framework.Events
internal abstract class ModEventsBase
{
/*********
- ** Properties
+ ** Fields
*********/
/// <summary>The underlying event manager.</summary>
protected readonly EventManager EventManager;
diff --git a/src/SMAPI/Framework/Events/ModGameLoopEvents.cs b/src/SMAPI/Framework/Events/ModGameLoopEvents.cs
index a5beac99..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
{
@@ -58,7 +72,7 @@ namespace StardewModdingAPI.Framework.Events
remove => this.EventManager.Saved.Remove(value);
}
- /// <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>
public event EventHandler<SaveLoadedEventArgs> SaveLoaded
{
add => this.EventManager.SaveLoaded.Add(value);
diff --git a/src/SMAPI/Framework/Events/ModSpecialisedEvents.cs b/src/SMAPI/Framework/Events/ModSpecialisedEvents.cs
index 17c32bb8..7c3e9dee 100644
--- a/src/SMAPI/Framework/Events/ModSpecialisedEvents.cs
+++ b/src/SMAPI/Framework/Events/ModSpecialisedEvents.cs
@@ -9,6 +9,13 @@ namespace StardewModdingAPI.Framework.Events
/*********
** Accessors
*********/
+ /// <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>
+ public event EventHandler<LoadStageChangedEventArgs> LoadStageChanged
+ {
+ add => this.EventManager.LoadStageChanged.Add(value);
+ remove => this.EventManager.LoadStageChanged.Remove(value);
+ }
+
/// <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>
public event EventHandler<UnvalidatedUpdateTickingEventArgs> UnvalidatedUpdateTicking
{