Skip to content

Commit

Permalink
extra commands
Browse files Browse the repository at this point in the history
  • Loading branch information
MegaPiggy committed Sep 2, 2024
1 parent 7cb5b23 commit fb0ab50
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions Winch/Patches/TerminalPatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

0 comments on commit fb0ab50

Please sign in to comment.