Пример #1
0
        static bool OnToggle(UnityModManager.ModEntry modEntry, bool value)
        {
            if (value == enabled)
            {
                return(true);
            }
            enabled = value;

            if (enabled)
            {
                harmonyInstance = HarmonyInstance.Create(modEntry.Info.Id);
                harmonyInstance.PatchAll(Assembly.GetExecutingAssembly());

                menu       = new GameObject().AddComponent <MultiplayerMenu>();
                statusMenu = new GameObject().AddComponent <MultiplayerStatusMenu>();
                UnityEngine.Object.DontDestroyOnLoad(menu.gameObject);
                UnityEngine.Object.DontDestroyOnLoad(statusMenu.gameObject);
                MultiplayerUtils.StartMapLoading();
            }
            else
            {
                harmonyInstance.UnpatchAll(harmonyInstance.Id);
                menu.EndMultiplayer();
                UnityEngine.Object.Destroy(menu.gameObject);
                UnityEngine.Object.Destroy(statusMenu.gameObject);
                MultiplayerUtils.StopMapLoading();
            }

            return(true);
        }
Пример #2
0
        static bool OnToggle(UnityModManager.ModEntry modEntry, bool value)
        {
            if (value == enabled)
            {
                return(true);
            }
            enabled = value;

            if (enabled)
            {
                //Patch the replay editor
                harmonyInstance = HarmonyInstance.Create(modEntry.Info.Id);
                harmonyInstance.PatchAll(Assembly.GetExecutingAssembly());

                menu        = ModMenu.Instance.gameObject.AddComponent <MultiplayerMenu>();
                utilityMenu = ModMenu.Instance.gameObject.AddComponent <MultiplayerUtilityMenu>();

                uiBox = ModMenu.Instance.RegisterModMaker("Silentbaws", "Silentbaws", 0);
                uiBox.AddCustom("Patreon", DisplayPatreon, () => enabled);

                MultiplayerUtils.StartMapLoading();
            }
            else
            {
                //Unpatch the replay editor
                harmonyInstance.UnpatchAll(harmonyInstance.Id);

                MultiplayerUtils.StopMapLoading();

                if (multiplayerController != null)
                {
                    multiplayerController.DisconnectFromServer();
                }
                menu.CloseMultiplayerMenu();

                UnityEngine.Object.Destroy(menu);
                UnityEngine.Object.Destroy(utilityMenu);
            }

            return(true);
        }