summaryrefslogtreecommitdiff
path: root/src/SMAPI.Mods.ConsoleCommands
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2021-08-27 19:14:41 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2021-09-01 19:32:23 -0400
commit9316fe303827cb31f38f4a5bb068f8fa0190ac5e (patch)
tree75ef49c54c86e9b474f6063dfe904d806738600d /src/SMAPI.Mods.ConsoleCommands
parent4ee96a20bb6c74bc7ff6176a03e7f15d47cddfa8 (diff)
downloadSMAPI-9316fe303827cb31f38f4a5bb068f8fa0190ac5e.tar.gz
SMAPI-9316fe303827cb31f38f4a5bb068f8fa0190ac5e.tar.bz2
SMAPI-9316fe303827cb31f38f4a5bb068f8fa0190ac5e.zip
add hurry_all console command
Diffstat (limited to 'src/SMAPI.Mods.ConsoleCommands')
-rw-r--r--src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/HurryAllCommand.cs54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/HurryAllCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/HurryAllCommand.cs
new file mode 100644
index 00000000..2deac5f8
--- /dev/null
+++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/HurryAllCommand.cs
@@ -0,0 +1,54 @@
+using System;
+using StardewValley;
+
+namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.World
+{
+ /// <summary>A command which immediately warps all NPCs to their scheduled positions. To hurry a single NPC, see <c>debug hurry npc-name</c> instead.</summary>
+ internal class HurryAllCommand : ConsoleCommand
+ {
+ /*********
+ ** Public methods
+ *********/
+ /// <summary>Construct an instance.</summary>
+ public HurryAllCommand()
+ : base(
+ name: "hurry_all",
+ description: "Immediately warps all NPCs to their scheduled positions. (To hurry a single NPC, use `debug hurry npc-name` instead.)\n\n"
+ + "Usage: hurry_all"
+ )
+ { }
+
+ /// <summary>Handle the command.</summary>
+ /// <param name="monitor">Writes messages to the console and log file.</param>
+ /// <param name="command">The command name.</param>
+ /// <param name="args">The command arguments.</param>
+ public override void Handle(IMonitor monitor, string command, ArgumentParser args)
+ {
+ // check context
+ if (!Context.IsWorldReady)
+ {
+ monitor.Log("You need to load a save to use this command.", LogLevel.Error);
+ return;
+ }
+
+ // hurry all NPCs
+ foreach (NPC npc in Utility.getAllCharacters())
+ {
+ if (!npc.isVillager())
+ continue;
+
+ monitor.Log($"Hurrying {npc.Name}...");
+ try
+ {
+ npc.warpToPathControllerDestination();
+ }
+ catch (Exception ex)
+ {
+ monitor.Log($"Failed hurrying {npc.Name}. Technical details:\n{ex}", LogLevel.Error);
+ }
+ }
+
+ monitor.Log("Done!", LogLevel.Info);
+ }
+ }
+}