Example #1
0
        /// <summary>
        /// Clears all loaded mods and loads them again
        /// </summary>
        public void ReloadMods()
        {
            UpgradePagesManager.Reset();
            ClearCache();
            _mods.Clear();
            PassOnMod = new PassOnToModsManager();

            List <string> errors = new List <string>();
            List <string> invalidModsFilePaths = new List <string>();

            string[] dllFiles = Directory.GetFiles(getModsFolderPath(), "*.dll", SearchOption.TopDirectoryOnly);
            for (int i = 0; i < dllFiles.Length; i++)
            {
                byte[] modBytes = File.ReadAllBytes(dllFiles[i]);
                if (!LoadMod(modBytes, true, out string error))
                {
                    errors.Add(error);
                    invalidModsFilePaths.Add(dllFiles[i]);
                }
            }

            if (errors.Count > 0)
            {
                StartCoroutine(showModInvalidMessage(invalidModsFilePaths, errors));
            }
        }
            public static bool UpgradeDescription_IsUpgradeCurrentlyVisible_Postfix(bool __result, UpgradeDescription __instance)
            {
                if (!UpgradePagesManager.IsUpgradeVisible(__instance.UpgradeType, __instance.Level))
                {
                    return(false);
                }

                if (UpgradePagesManager.ForceUpgradeVisible(__instance.UpgradeType, __instance.Level))
                {
                    return(true);
                }

                return(__result);
            }
Example #3
0
        static void setAngleOfUpgrade(UpgradeUIIcon icon, float newAngle)
        {
            UpgradeDescription upgradeDescription = icon.GetDescription();

            if (upgradeDescription == null)
            {
                return;
            }

            // Old mod loading system
            upgradeDescription.SetAngleOffset(newAngle, UpgradePagesManager.TryGetModForPage(UpgradePagesManager.CurrentPage));

            // New mod loading system
            // upgradeDescription.SetAngleOffset(newAngle, ModsManager.Instance.GetLoadedModWithID(UpgradePagesManager.TryGetModIDForPage(UpgradePagesManager.CurrentPage)).ModReference);
        }
Example #4
0
        /// <summary>
        /// Disables a mod, this will call on OnModDeactivated on the mod, and Mod-Bot will not make any more calls to the mod until activated again
        /// </summary>
        /// <param name="mod"></param>
        public void DisableMod(Mod mod)
        {
            PlayerPrefs.SetInt(mod.GetUniqueID(), 0);

            for (int i = 0; i < _mods.Count; i++)
            {
                if (_mods[i].Mod == mod)
                {
                    _mods[i].IsDeactivated = true;
                    break;
                }
            }

            CustomUpgradeManager.NextClicked();
            UpgradePagesManager.RemoveModdedUpgradesFor(mod);

            new Harmony(mod.HarmonyID).UnpatchAll(mod.HarmonyID);             // unpatches all of the patches made by the mod

            mod.OnModDeactivated();
        }
Example #5
0
        static float getAngleForIconAtCurrentPage(UpgradeUIIcon icon)
        {
            UpgradeDescription upgradeDescription = icon.GetDescription();

            return(UpgradePagesManager.GetAngleOfUpgrade(upgradeDescription.UpgradeType, upgradeDescription.Level));
        }
 public static float UpgradeDescription_GetAngleOffset_Postfix(float __result, UpgradeDescription __instance)
 {
     return(UpgradePagesManager.GetAngleOfUpgrade(__instance.UpgradeType, __instance.Level));
 }