diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-05-15 22:51:49 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-05-15 22:51:49 -0400 |
commit | bca78cd682c0d583913811f632815db142fbde8b (patch) | |
tree | 55bf25fe2853396cc0ab2b483f0604cf7242ddd3 /src/StardewModdingAPI/Framework | |
parent | aafb3315cb20e17682569d19ae85d333b13cd3e0 (diff) | |
download | SMAPI-bca78cd682c0d583913811f632815db142fbde8b.tar.gz SMAPI-bca78cd682c0d583913811f632815db142fbde8b.tar.bz2 SMAPI-bca78cd682c0d583913811f632815db142fbde8b.zip |
add Context.IsWorldReady flag
Diffstat (limited to 'src/StardewModdingAPI/Framework')
-rw-r--r-- | src/StardewModdingAPI/Framework/SGame.cs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/StardewModdingAPI/Framework/SGame.cs b/src/StardewModdingAPI/Framework/SGame.cs index f318517d..4f3a29fc 100644 --- a/src/StardewModdingAPI/Framework/SGame.cs +++ b/src/StardewModdingAPI/Framework/SGame.cs @@ -39,9 +39,6 @@ namespace StardewModdingAPI.Framework /// <summary>The number of consecutive failed draws.</summary> private int FailedDraws; - /// <summary>Whether the player has loaded a save and the world has finished initialising.</summary> - private bool IsWorldReady => this.AfterLoadTimer < 0; - /// <summary>Whether the game is returning to the menu.</summary> private bool IsExiting; @@ -309,6 +306,7 @@ namespace StardewModdingAPI.Framework if (this.AfterLoadTimer == 0) { this.Monitor.Log($"Context: loaded saved game '{Constants.SaveFolderName}', starting {Game1.currentSeason} {Game1.dayOfMonth} Y{Game1.year}.", LogLevel.Trace); + Context.IsWorldReady = true; SaveEvents.InvokeAfterLoad(this.Monitor); PlayerEvents.InvokeLoadedGame(this.Monitor, new EventArgsLoadedGameChanged(Game1.hasLoadedGame)); @@ -325,9 +323,11 @@ namespace StardewModdingAPI.Framework this.IsExiting = true; // after exit to title - if (this.IsWorldReady && this.IsExiting && Game1.activeClickableMenu is TitleMenu) + if (Context.IsWorldReady && this.IsExiting && Game1.activeClickableMenu is TitleMenu) { this.Monitor.Log("Context: returned to title", LogLevel.Trace); + Context.IsWorldReady = false; + SaveEvents.InvokeAfterReturnToTitle(this.Monitor); this.AfterLoadTimer = 5; this.IsExiting = false; @@ -421,7 +421,7 @@ namespace StardewModdingAPI.Framework /********* ** World & player events *********/ - if (this.IsWorldReady) + if (Context.IsWorldReady) { // raise events (only when something changes, not on the initial load) if (Game1.uniqueIDForThisGame == this.PreviousSaveID) |