Exemple #1
0
        public static bool Prefix(ref string path, Action <Object> call)
        {
            // Use mark as a workaround to resolve the original call.
            // Reverse patch needs to update the melonloader version.
            const string mark = "//?/";

            MelonDebug.Msg(path);

            if (path.StartsWith(mark))
            {
                path = path.Substring(mark.Length);
                return(true);
            }

            var worker = Worker.Pick(path);

            if (worker == null)
            {
                return(true);
            }

            var tp = worker.TemplatePath;

            // It's a workaround for `call` that used in `Wrapper` got freed in Il2cpp domain
            // I have no idea why/how this could work. But, though, anyway, it just WORKS.
            // A reason might be the `native` will keep a gc handle to prevent `call` from freeing.
            Il2CppSystem.Action <Object> native = call;

            void Wrapper(Object obj)
            {
                var p = new GameObject {
                    active = false
                };
                var go = Object.Instantiate(obj.Cast <GameObject>(), p.transform);

                native.Invoke(worker.Rework(go));
                Object.Destroy(p);
            }

            if (GoCache.Cache.ContainsKey(tp))
            {
                native.Invoke(worker.Rework(GoCache.Cache[tp]));
            }
            else
            {
                var a = new Action <Object>(Wrapper);
                g.res.LoadAsync(mark + tp, a);
            }

            return(false);
        }
        public static bool Prefix(ref string path, Action <Object> call)
        {
            MelonDebug.Msg($"ResMgr::LoadAsync({path})");

            var exist = GoCache.TryGet(path, out var go);

            if (!exist)
            {
                return(true);
            }

            // It's a workaround for `call` that used in `Wrapper` got freed in Il2cpp domain
            // I have no idea why/how this could work. But, though, anyway, it just WORKS.
            // A reason might be the `native` will keep a gc handle to prevent `call` from freeing.
            Il2CppSystem.Action <Object> native = call;

            native.Invoke(go);

            return(false);
        }
Exemple #3
0
        public static bool Prefix(LG_ComputerTerminalCommandInterpreter __instance, string param1, string param2, ref bool __result)
        {
            if (__instance.m_terminal.UplinkPuzzle.Connected)
            {
                __instance.AddOutput(TerminalLineType.SpinningWaitNoDone, "Attempting uplink verification ", 5f);
                if (__instance.m_terminal.UplinkPuzzle.CurrentRound.CorrectCode.ToUpper() == param1.ToUpper())
                {
                    __instance.AddOutput("Verfication code ", true);

                    __instance.AddOutput(TerminalLineType.Warning, StringTools.RandomChars(true, 20, 40), 0.8f);
                    __instance.AddOutput(TerminalLineType.Warning, StringTools.RandomChars(true, 20, 40), 0.8f);
                    __instance.AddOutput(TerminalLineType.Warning, StringTools.RandomChars(true, 20, 40), 0.8f);
                    __instance.AddOutput(TerminalLineType.Warning, StringTools.RandomChars(true, 20, 40), 0.8f);
                    __instance.AddOutput(TerminalLineType.Warning, StringTools.RandomChars(true, 20, 40), 0.8f);


                    __instance.AddOutput("correct!", true);
                    if (__instance.m_terminal.UplinkPuzzle.TryGoToNextRound())
                    {
                        __instance.AddOutput(TerminalLineType.ProgressWait, "Building uplink verification signature", 12f);
                        __instance.AddOutput("", true);
                        __instance.AddOutput("Verfication code", true);

                        __instance.AddOutput(TerminalLineType.Warning, StringTools.RandomChars(true, 20, 40), 0.8f);
                        __instance.AddOutput(TerminalLineType.Warning, StringTools.RandomChars(true, 20, 40), 0.8f);
                        __instance.AddOutput(TerminalLineType.Warning, StringTools.RandomChars(true, 20, 40), 0.8f);
                        __instance.AddOutput(TerminalLineType.Warning, StringTools.RandomChars(true, 20, 40), 0.8f);

                        __instance.AddOutput(string.Concat(new string[]
                        {
                            "needed! Use public key <color=orange>",
                            __instance.m_terminal.UplinkPuzzle.CurrentRound.CorrectPrefix,
                            "</color> to obtain the code."
                        }), true);


                        __instance.OnEndOfQueue = new Action(() => {
                            __instance.m_terminal.UplinkPuzzle.CurrentRound.ShowGui = true;
                        });
                    }
                    else
                    {
                        __instance.AddOutput(TerminalLineType.SpinningWaitNoDone, "Waiting for uplink host response..", 3f);
                        __instance.AddOutput("", true);
                        __instance.AddOutput(TerminalLineType.Normal, "SUCCESS! Uplink to " + __instance.m_terminal.UplinkPuzzle.TerminalUplinkIP + " Established Successfully!", 2f);
                        __instance.AddOutput("", true);
                        __instance.AddOutput(TerminalLineType.Warning, "<color=red>An unknown system error occured!</color>", 0.8f);
                        __instance.AddOutput(TerminalLineType.Normal, "Please contact your network administrator.");

                        __instance.OnEndOfQueue = new Action(() =>
                        {
                            //WardenObjectiveManager.StopAllWardenObjectiveEnemyWaves();
                            __instance.m_terminal.UplinkPuzzle.Solved = true;
                            Il2CppSystem.Action onPuzzleSolved        = __instance.m_terminal.UplinkPuzzle.OnPuzzleSolved;
                            if (onPuzzleSolved == null)
                            {
                                return;
                            }
                            onPuzzleSolved.Invoke();
                        });
                    }
                }
                else
                {
                    __instance.AddOutput("", true);
                    __instance.AddOutput(TerminalLineType.Fail, "Verfication failed! Use public key <color=orange>" + __instance.m_terminal.UplinkPuzzle.CurrentRound.CorrectPrefix + "</color> to obtain the code", 0f);
                    __instance.AddOutput(TerminalLineType.Normal, "Returning to root..", 6f);
                }
            }
            else
            {
                __instance.AddOutput("", true);
                __instance.AddOutput("Uplink not connected! Use UPLINK_CONNECT to initialize a connection.", true);
            }
            __result = false;
            return(false);
        }