add Context.IsPlayerFree

This commit is contained in:
Jesse Plamondon-Willard 2017-05-27 23:48:16 -04:00
parent 55fa8198ff
commit 173dd8cd03
2 changed files with 4 additions and 0 deletions

View File

@ -29,6 +29,7 @@ For modders:
* You can now load unpacked `.tbin` files from your mod folder through the content API.
* SMAPI now automatically fixes tilesheet references for maps loaded from the mod folder.
<small>_When loading a map from the mod folder, SMAPI will automatically use tilesheets relative to the map file if they exists. Otherwise it will default to tilesheets in the game content._</small>
* Added `Context.IsPlayerFree` for mods that need to check if the player can act (i.e. save is loaded, no menu is displayed, no cutscene is in progress, etc).
* Added `Context.IsInDrawLoop` for specialised mods.
* Fixed `smapi-crash.txt` being copied from the default log even if a different path is specified with `--log-path`.
* Fixed the content API not matching XNB filenames with two dots (like `a.b.xnb`) if you don't specify the `.xnb` extension.

View File

@ -16,6 +16,9 @@ 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 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; }