From fb0ab50098c9e2f8c2cbf0fa197ffa873fa895a2 Mon Sep 17 00:00:00 2001 From: Noah Pilarski Date: Sun, 1 Sep 2024 20:21:38 -0400 Subject: [PATCH] extra commands --- Winch/Patches/TerminalPatcher.cs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/Winch/Patches/TerminalPatcher.cs b/Winch/Patches/TerminalPatcher.cs index 0db35939..99ad0f74 100644 --- a/Winch/Patches/TerminalPatcher.cs +++ b/Winch/Patches/TerminalPatcher.cs @@ -342,5 +342,34 @@ public static bool WorldEventManager_TestWorldEvent_Prefix(WorldEventManager __i } return false; } + + [HarmonyPostfix] + [HarmonyPatch(typeof(HarvestValidator), nameof(HarvestValidator.AddTerminalCommands))] + public static void HarvestValidator_AddTerminalCommands_Postfix(HarvestValidator __instance) + { + Terminal.Shell.AddCommand("restock.all", __instance.RestockHarvestSpots, 0, 0, "fully stocks ALL harvest spots in the world"); + Terminal.Shell.AddCommand("harvest.list", __instance.ListHarvestSpots, 0, 0, "lists every harvest spot in the world"); + } + + [HarmonyPostfix] + [HarmonyPatch(typeof(HarvestValidator), nameof(HarvestValidator.RemoveTerminalCommands))] + public static void HarvestValidator_RemoveTerminalCommands_Postfix() + { + Terminal.Shell.RemoveCommand("restock.all"); + Terminal.Shell.RemoveCommand("harvest.list"); + } + + public static void RestockHarvestSpots(this HarvestValidator harvestValidator, CommandArg[] args) + { + WinchCore.Log.Debug("[HarvestValidator] RestockHarvestSpots()"); + harvestValidator.allHarvestPOIs.ForEach(harvestPOI => harvestPOI.AddStock(harvestPOI.MaxStock)); + } + + public static void ListHarvestSpots(this HarvestValidator harvestValidator, CommandArg[] args) + { + string pois = harvestValidator.allHarvestPOIs.Reduce((pois, i) => pois + i.Harvestable.GetId() + ", ", ""); + WinchCore.Log.Debug("[HarvestValidator] ListHarvestSpots(): " + pois); + Terminal.Buffer.HandleLog(pois, TerminalLogType.Message); + } } }