static bool Prefix(Window window) { if (Multiplayer.Client == null) { return(true); } if (!Multiplayer.ExecutingCmds) { return(true); } if (!Multiplayer.GameComp.debugMode) { return(true); } bool keepOpen = TickPatch.currentExecutingCmdIssuedBySelf; var map = Multiplayer.MapContext; if (window is Dialog_DebugOptionListLister lister) { MpDebugTools.CurrentPlayerState.window = lister.options; MpDebugTools.CurrentPlayerState.mapId = map?.uniqueID ?? -1; return(keepOpen); } if (window is FloatMenu menu) { var options = menu.options; if (keepOpen) { menu.options = new List <FloatMenuOption>(); foreach (var option in options) { var copy = new FloatMenuOption(option.labelInt, option.action); int hash = copy.Hash(); copy.action = () => MpDebugTools.SendCmd(DebugSource.FloatMenu, hash, map); menu.options.Add(copy); } } MpDebugTools.CurrentPlayerState.window = options; return(keepOpen); } return(true); }
static bool Prefix(Window window) { if (Multiplayer.Client == null) { return(true); } if (!Multiplayer.ExecutingCmds) { return(true); } if (!Multiplayer.WorldComp.debugMode) { return(true); } bool keepOpen = TickPatch.currentExecutingCmdIssuedBySelf; var map = Multiplayer.MapContext; if (window is Dialog_DebugOptionListLister lister) { var options = lister.options; if (keepOpen) { lister.options = new List <DebugMenuOption>(); foreach (var option in options) { var copy = option; copy.method = new DebugListerContext() { map = map, originalAction = copy.method }.Do; lister.options.Add(copy); } } Multiplayer.game.playerDebugState.GetOrAddNew(MpDebugTools.currentPlayer).window = options; return(keepOpen); } if (window is FloatMenu menu) { var options = menu.options; if (keepOpen) { menu.options = new List <FloatMenuOption>(); foreach (var option in options) { var copy = new FloatMenuOption(option.labelInt, option.action); int hash = copy.Hash(); copy.action = () => MpDebugTools.SendCmd(DebugSource.FloatMenu, hash, map); menu.options.Add(copy); } } Multiplayer.game.playerDebugState.GetOrAddNew(MpDebugTools.currentPlayer).window = options; return(keepOpen); } return(true); }