Ejemplo n.º 1
0
        /// <summary>
        /// Adds an upgrade to the page of the specified <see cref="Mod"/>, if the upgrade is a modded upgrade or not currently used it will also be added to <see cref="UpgradeManager.UpgradeDescriptions"/>
        /// </summary>
        /// <param name="upgradeManager"></param>
        /// <param name="upgrade">The <see cref="UpgradeDescription"/> of the upgrade to add</param>
        /// <param name="mod">The <see cref="Mod"/> that owns the upgrade</param>
        public static void AddUpgrade(this UpgradeManager upgradeManager, UpgradeDescription upgrade, Mod mod)
        {
            if (upgrade.IsModdedUpgradeType() || !UpgradeManager.Instance.IsUpgradeTypeAndLevelUsed(upgrade.UpgradeType, upgrade.Level))
            {
                UpgradeManager.Instance.UpgradeDescriptions.Add(upgrade);
            }

            // Old mod loading system
            UpgradePagesManager.AddUpgrade(upgrade.UpgradeType, upgrade.Level, mod);

            // New mod loading system
            // UpgradePagesManager.AddUpgrade(upgrade.UpgradeType, upgrade.Level, mod.ModInfo.UniqueID);

            if (upgrade is AbilityUpgrade)
            {
                Dictionary <UpgradeType, bool> _abilityUpgradeTypes = Accessor.GetPrivateField <UpgradeManager, Dictionary <UpgradeType, bool> >("_abilityUpgradeTypes", UpgradeManager.Instance);
                _abilityUpgradeTypes[upgrade.UpgradeType] = true;
            }

            if (upgrade.Requirement != null)
            {
                recursivelyAddRequirments(upgrade, mod);
            }

            string nameID = upgrade.UpgradeName.ToLower().Trim();

            ModBotLocalizationManager.TryAddModdedUpgradeLocalizationStringToDictionary(nameID, upgrade.UpgradeName);

            string descriptionID = upgrade.Description.ToLower().Trim();

            ModBotLocalizationManager.TryAddModdedUpgradeLocalizationStringToDictionary(descriptionID, upgrade.Description);
        }
Ejemplo n.º 2
0
        static void recursivelyAddRequirments(UpgradeDescription upgrade, Mod mod)
        {
            if (upgrade == null)
            {
                return;
            }

            // Old mod loading system
            UpgradePagesManager.AddUpgrade(upgrade.UpgradeType, upgrade.Level, mod);

            // New mod loading system
            // UpgradePagesManager.AddUpgrade(upgrade.UpgradeType, upgrade.Level, mod.ModInfo.UniqueID);

            if (upgrade.Requirement2 != null)
            {
                recursivelyAddRequirments(upgrade.Requirement2, mod);
            }

            recursivelyAddRequirments(upgrade.Requirement, mod);
        }