summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework/SGame.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/SMAPI/Framework/SGame.cs')
-rw-r--r--src/SMAPI/Framework/SGame.cs32
1 files changed, 19 insertions, 13 deletions
diff --git a/src/SMAPI/Framework/SGame.cs b/src/SMAPI/Framework/SGame.cs
index 9f8a07e6..ae2c028d 100644
--- a/src/SMAPI/Framework/SGame.cs
+++ b/src/SMAPI/Framework/SGame.cs
@@ -41,6 +41,15 @@ namespace StardewModdingAPI.Framework
/// <summary>Immediately exit the game without saving. This should only be invoked when an irrecoverable fatal error happens that risks save corruption or game-breaking bugs.</summary>
private readonly Action<string> ExitGameImmediately;
+ /// <summary>Raised after the game finishes loading its initial content.</summary>
+ private readonly Action OnGameContentLoaded;
+
+ /// <summary>Raised when the game is updating its state (roughly 60 times per second).</summary>
+ private readonly Action<GameTime, Action> OnGameUpdating;
+
+ /// <summary>Raised before the game exits.</summary>
+ private readonly Action OnGameExiting;
+
/*********
** Accessors
@@ -58,15 +67,6 @@ namespace StardewModdingAPI.Framework
/// <remarks>This must be static because the game accesses it before the <see cref="SGame"/> constructor is called.</remarks>
public static Func<IServiceProvider, string, LocalizedContentManager> CreateContentManagerImpl;
- /// <summary>Raised after the game finishes loading its initial content.</summary>
- public event Action OnGameContentLoaded;
-
- /// <summary>Raised before the game exits.</summary>
- public event Action OnGameExiting;
-
- /// <summary>Raised when the game is updating its state (roughly 60 times per second).</summary>
- public event Action<GameTime, Action> OnGameUpdating;
-
/*********
** Public methods
@@ -78,7 +78,10 @@ namespace StardewModdingAPI.Framework
/// <param name="modHooks">Handles mod hooks provided by the game.</param>
/// <param name="multiplayer">The core multiplayer logic.</param>
/// <param name="exitGameImmediately">Immediately exit the game without saving. This should only be invoked when an irrecoverable fatal error happens that risks save corruption or game-breaking bugs.</param>
- public SGame(Monitor monitor, Reflector reflection, EventManager eventManager, SModHooks modHooks, SMultiplayer multiplayer, Action<string> exitGameImmediately)
+ /// <param name="onGameContentLoaded">Raised after the game finishes loading its initial content.</param>
+ /// <param name="onGameUpdating">Raised when the game is updating its state (roughly 60 times per second).</param>
+ /// <param name="onGameExiting">Raised before the game exits.</param>
+ public SGame(Monitor monitor, Reflector reflection, EventManager eventManager, SModHooks modHooks, SMultiplayer multiplayer, Action<string> exitGameImmediately, Action onGameContentLoaded, Action<GameTime, Action> onGameUpdating, Action onGameExiting)
{
// init XNA
Game1.graphics.GraphicsProfile = GraphicsProfile.HiDef;
@@ -94,6 +97,9 @@ namespace StardewModdingAPI.Framework
this.Events = eventManager;
this.Reflection = reflection;
this.ExitGameImmediately = exitGameImmediately;
+ this.OnGameContentLoaded = onGameContentLoaded;
+ this.OnGameUpdating = onGameUpdating;
+ this.OnGameExiting = onGameExiting;
}
/// <summary>Get the observable location list.</summary>
@@ -111,7 +117,7 @@ namespace StardewModdingAPI.Framework
{
base.LoadContent();
- this.OnGameContentLoaded?.Invoke();
+ this.OnGameContentLoaded();
}
/// <summary>Perform cleanup logic when the game exits.</summary>
@@ -120,7 +126,7 @@ namespace StardewModdingAPI.Framework
/// <remarks>This overrides the logic in <see cref="Game1.exitEvent"/> to let SMAPI clean up before exit.</remarks>
protected override void OnExiting(object sender, EventArgs args)
{
- this.OnGameExiting?.Invoke();
+ this.OnGameExiting();
}
/// <summary>Construct a content manager to read game content files.</summary>
@@ -138,7 +144,7 @@ namespace StardewModdingAPI.Framework
/// <param name="gameTime">A snapshot of the game timing state.</param>
protected override void Update(GameTime gameTime)
{
- this.OnGameUpdating?.Invoke(gameTime, () => base.Update(gameTime));
+ this.OnGameUpdating(gameTime, () => base.Update(gameTime));
}
/// <summary>The method called to draw everything to the screen.</summary>