diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-08-02 00:26:56 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-08-02 00:26:56 -0400 |
commit | 3ffcac3f1f46d696056b665e0f485b0d6f7da53c (patch) | |
tree | b261f081a1195740135e19bfc8eb9cf80eeef038 | |
parent | 201d54bbeb2af5d44c35ad4cf77aadb84f09e135 (diff) | |
download | SMAPI-3ffcac3f1f46d696056b665e0f485b0d6f7da53c.tar.gz SMAPI-3ffcac3f1f46d696056b665e0f485b0d6f7da53c.tar.bz2 SMAPI-3ffcac3f1f46d696056b665e0f485b0d6f7da53c.zip |
fix Context.IsPlayerFree being false when player can't move (#330)
For example, the value was false when the player used a tool which wasn't intended.
-rw-r--r-- | release-notes.md | 1 | ||||
-rw-r--r-- | src/StardewModdingAPI/Context.cs | 7 |
2 files changed, 6 insertions, 2 deletions
diff --git a/release-notes.md b/release-notes.md index a1d78334..f1e75153 100644 --- a/release-notes.md +++ b/release-notes.md @@ -25,6 +25,7 @@ For mod developers: * Restrict mods from accessing SMAPI internals using its reflection helper, to discourage fragile mods. * Fixed `GraphicsEvents.Resize` being raised before the game updates its window data. * Fixed `TimeEvents.AfterDayStarted` being raised during the new-game intro. +* Fixed `Context.IsPlayerFree` being incorrectly false in some cases (e.g. when using a tool). ## 1.15.2 For players: diff --git a/src/StardewModdingAPI/Context.cs b/src/StardewModdingAPI/Context.cs index 6c5ae40e..119e14c8 100644 --- a/src/StardewModdingAPI/Context.cs +++ b/src/StardewModdingAPI/Context.cs @@ -16,8 +16,11 @@ namespace StardewModdingAPI /// <summary>Whether the player has loaded a save and the world has finished initialising.</summary> public static bool IsWorldReady { get; internal set; } - /// <summary>Whether the player is free to move around (e.g. save is loaded, no menu is displayed, no cutscene is in progress, etc).</summary> - public static bool IsPlayerFree => Context.IsWorldReady && Game1.activeClickableMenu == null && Game1.player.CanMove && !Game1.dialogueUp && !Game1.eventUp; + /// <summary>Whether <see cref="IsWorldReady"/> is true and the player is free to act in the world (no menu is displayed, no cutscene is in progress, etc).</summary> + public static bool IsPlayerFree => Context.IsWorldReady && Game1.activeClickableMenu == null && !Game1.dialogueUp && !Game1.eventUp; + + /// <summary>Whether <see cref="IsPlayerFree"/> is true and the player is free to move (e.g. not using a tool).</summary> + public static bool CanPlayerMove => Context.IsPlayerFree && Game1.player.CanMove; /// <summary>Whether the game is currently running the draw loop. This isn't relevant to most mods, since you should use <see cref="GraphicsEvents.OnPostRenderEvent"/> to draw to the screen.</summary> public static bool IsInDrawLoop { get; internal set; } |