Skip to main content

GameCommandPatches

A static class in TavernLib, TavernLib.Patches.

Patches for game console commands that answered Success having done nothing: time set, time ofday, settings possible, select move/rotate exact, wacky destroy and world caves teleport. Applied by hand in OnLateInitializeMelon, not by attribute.

Methods​

MemberWhat it is
static void CheckDestroy(uint id)Prefix on WackyCommandModule.Destroy: throws when the id has no entity, the entity has a parent, or it isn't its prefab's root.
static void CheckMoveSelection()Prefix on SelectionCommandModule.MovingModule.Exact that throws "Nothing is selected" when the console's context has no selection.
static void CheckPossibleValues(string settingsTarget, string setting, object __result)Postfix on SettingsCommandModules.ListPossivleValues that throws when it found no such setting with a set of choices.
static void CheckRotateSelection()Prefix on SelectionCommandModule.RotatingModule.Exact that throws "Nothing is selected" when the console's context has no selection.
static void CheckTimeSet(string time)Prefix on TimeCommandModule.Set: throws for a word that isn't a time keyword, or when there's no GameTimeManager. Numbers pass.
static bool ReplaceCaveTeleport(PlayerList players, int layer, ref Task __result)Prefix on WorldCommandModule.CaveCommandModule.CaveTeleport that skips it, making the layer if needed and teleporting the players to its portal.
7 private and internal methods
MemberWhat it is
internal static void Apply(Harmony harmony)Internal: patches each command, and swaps time ofday for a version that returns the time. Logs a warning and skips any method the game lacks.
private static void Patch(Harmony harmony, Type type, string name, string prefix = null, string postfix = null)Applies a prefix or postfix to a game method, and logs a warning instead of throwing if it is missing or can't be patched.
private static void Replace(string moduleName, string name, MethodInfo method)Swaps a console command for a new one built on the given method, keeping the old one's aliases, requirements and priority.
private static void RequireSelection()Throws a CommandException when nothing is selected.
private static async Task<string> TeleportToCaveLayer(PlayerList players, int layer)Teleports the players to a cave layer's portal, generating the layers first if needed, and answers who it moved.
private static GameTimeManager TimeManager()Returns GameTimeManager.Instance, or throws a CommandException if the server has no day and night.
private static float TimeOfDay(bool isNormalised = false)Replacement for the time ofday command; returns the current time, normalised if asked.