Beispiel #1
0
        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;
                }

                else if (__instance is Dialog_DebugOptionListLister lister)
                {
                    var context = (DebugListerContext)toolAction.Target;
                    MpDebugTools.SendCmd(DebugSource.Lister, hash, context.map);
                    DebugTools.curTool = null;
                }
            }
        }
Beispiel #2
0
        static bool Prefix(Dialog_DebugOptionLister __instance, string label, Action toolAction, ref Container <DebugTool>?__state)
        {
            if (Multiplayer.Client == null)
            {
                return(true);
            }
            if (Current.ProgramState == ProgramState.Playing && !Multiplayer.WorldComp.debugMode)
            {
                return(true);
            }

            if (Multiplayer.ExecutingCmds)
            {
                int hash = Gen.HashCombineInt(GenText.StableStringHash(toolAction.Method.MethodDesc()), GenText.StableStringHash(label));
                if (hash == MpDebugTools.currentHash)
                {
                    DebugTools.curTool = new DebugTool(label, toolAction);
                }

                return(false);
            }

            __state = DebugTools.curTool;

            return(true);
        }