static void Postfix(Dialog_DebugOptionLister __instance, string label, Action toolAction, Container <DebugTool>?__state) { // New tool chosen if (__state != null && DebugTools.curTool != __state?.Inner) { var originalAction = (toolAction.Target as DebugListerContext)?.originalAction ?? toolAction; int hash = Gen.HashCombineInt(GenText.StableStringHash(originalAction.Method.MethodDesc()), GenText.StableStringHash(label)); if (__instance is Dialog_DebugActionsMenu) { var source = MpDebugTools.ListingSource(); if (source == DebugSource.None) { return; } Map map = source == DebugSource.ListingMap ? Find.CurrentMap : null; MpDebugTools.SendCmd(source, hash, map); DebugTools.curTool = null; } if (__instance is Dialog_DebugOptionListLister lister) { var context = (DebugListerContext)toolAction.Target; MpDebugTools.SendCmd(DebugSource.Lister, hash, context.map); DebugTools.curTool = null; } } }
static void Postfix(Dialog_DebugOptionLister __instance, string label, Action toolAction, Container <DebugTool>?__state) { // New tool chosen if (!__state.HasValue || DebugTools.curTool == __state?.Inner) { return; } int hash = Gen.HashCombineInt(GenText.StableStringHash(toolAction.Method.MethodDesc()), GenText.StableStringHash(label)); if (__instance is Dialog_DebugActionsMenu) { var source = MpDebugTools.ListingSource(); if (source == DebugSource.None) { return; } Map map = source == DebugSource.ListingMap ? Find.CurrentMap : null; MpDebugTools.SendCmd(source, hash, map); DebugTools.curTool = null; } else if (__instance is Dialog_DebugOptionListLister lister) { Map map = MpDebugTools.CurrentPlayerState.Map; if (ListingMapMarker.drawing) { map = Find.CurrentMap; } MpDebugTools.SendCmd(DebugSource.Lister, hash, map); DebugTools.curTool = null; } }
static bool Prefix(Dialog_DebugOptionLister __instance, string label, ref Action action) { if (Multiplayer.Client == null) { return(true); } if (Current.ProgramState == ProgramState.Playing && !Multiplayer.WorldComp.debugMode) { return(true); } var originalAction = (action.Target as DebugListerContext)?.originalAction ?? action; int hash = Gen.HashCombineInt( GenText.StableStringHash(originalAction.Method.MethodDesc()), GenText.StableStringHash(label) ); if (Multiplayer.ExecutingCmds) { if (hash == MpDebugTools.currentHash) { action(); } return(false); } if (__instance is Dialog_DebugActionsMenu) { var source = MpDebugTools.ListingSource(); if (source == DebugSource.None) { return(true); } Map map = source == DebugSource.ListingMap ? Find.CurrentMap : null; if (ListingIncidentMarker.target != null) { map = ListingIncidentMarker.target as Map; } action = () => MpDebugTools.SendCmd(source, hash, map); } if (__instance is Dialog_DebugOptionListLister) { var context = (DebugListerContext)action.Target; action = () => MpDebugTools.SendCmd(DebugSource.Lister, hash, context.map); } return(true); }