private void InitializeUpgradeHandlers()
        {
            QuickLogger.Debug($"UpgradeManager adding new UpgradeHandlers from external mods");
            // First, register upgrades from other mods.
            foreach (KeyValuePair <CreateUpgradeHandler, string> pair in HandlerCreators)
            {
                CreateUpgradeHandler upgradeHandlerCreator = pair.Key;
                string         assemblyName = pair.Value;
                UpgradeHandler upgrade      = upgradeHandlerCreator.Invoke(Cyclops);

                if (upgrade == null)
                {
                    QuickLogger.Warning($"UpgradeHandler from '{assemblyName}' was null");
                }
                else if (!KnownsUpgradeModules.ContainsKey(upgrade.TechType))
                {
                    upgrade.RegisterSelf(KnownsUpgradeModules);
                }
                else
                {
                    QuickLogger.Warning($"Duplicate UpgradeHandler for '{upgrade.TechType.AsString()}' from '{assemblyName}' was blocked");
                }
            }

            // Next, if no external mod has provided an UpgradeHandler for the vanilla upgrades, they will be added here.
            // This is to allow other mods to provide new functionality to the original upgrades.

            QuickLogger.Debug($"UpgradeManager adding default UpgradeHandlers for unmanaged vanilla upgrades");

            for (int i = 0; i < vanillaUpgrades.OriginalUpgradeIDs.Count; i++)
            {
                TechType upgradeID = vanillaUpgrades.OriginalUpgradeIDs[i];
                if (!KnownsUpgradeModules.ContainsKey(upgradeID))
                {
                    UpgradeHandler vanillaUpgrade = vanillaUpgrades.CreateUpgradeHandler(upgradeID, Cyclops);
                    vanillaUpgrade.RegisterSelf(KnownsUpgradeModules);
                }
            }

            upgradeHandlers = new UpgradeHandler[KnownsUpgradeModules.Count];

            int u = 0;

            foreach (UpgradeHandler upgrade in KnownsUpgradeModules.Values)
            {
                upgradeHandlers[u++] = upgrade;
            }

            QuickLogger.Debug("Attaching events to Engine Room Upgrade Console");

            if (engineRoomUpgradeConsole == null)
            {
                engineRoomUpgradeConsole = Cyclops.upgradeConsole.modules;
            }

            AttachEquipmentEvents(ref engineRoomUpgradeConsole);

            initialized       = true;
            TooLateToRegister = true;
        }
Пример #2
0
        private void RegisterUpgradeHandlers()
        {
            // Register upgrades from other mods
            foreach (HandlerCreator upgradeHandlerCreator in ReusableUpgradeHandlers)
            {
                UpgradeHandler upgrade = upgradeHandlerCreator.Invoke();
                upgrade.RegisterSelf(KnownsUpgradeModules);
            }

            foreach (HandlerCreator upgradeHandlerCreator in OneTimeUseUpgradeHandlers)
            {
                UpgradeHandler upgrade = upgradeHandlerCreator.Invoke();
                upgrade.RegisterSelf(KnownsUpgradeModules);
            }

            OneTimeUseUpgradeHandlers.Clear();
        }