public void HandleUpgrades() { if (!initialized) { InitializeUpgradeHandlers(); } QuickLogger.Debug($"UpgradeManager clearing cyclops upgrades"); // Turn off all upgrades and clear all values for (int i = 0; i < upgradeHandlers.Length; i++) { UpgradeHandler upgradeType = upgradeHandlers[i]; if (upgradeType.HasUpgrade) { QuickLogger.Debug($"UpgradeManager clearing {upgradeType.TechType.AsString()}"); } upgradeType.UpgradesCleared(); // UpgradeHandler event } bool foundUpgrades = false; // Go through all slots and check what upgrades are available QuickLogger.Debug($"UpgradeManager checking upgrade slots"); foreach (UpgradeSlot upgradeSlot in this.UpgradeSlots) { TechType techTypeInSlot = upgradeSlot.GetTechTypeInSlot(); if (techTypeInSlot == TechType.None) { continue; } foundUpgrades = true; if (KnownsUpgradeModules.TryGetValue(techTypeInSlot, out UpgradeHandler handler)) { QuickLogger.Debug($"UpgradeManager counting cyclops upgrade '{techTypeInSlot.AsString()}'"); handler.UpgradeCounted(upgradeSlot); // UpgradeHandler event } else { QuickLogger.Warning($"UpgradeManager encountered unmanaged cyclops upgrade '{techTypeInSlot.AsString()}'"); } } for (int i = 0; i < upgradeHandlers.Length; i++) { upgradeHandlers[i].UpgradesFinished(); // UpgradeHandler event } // If any upgrades were found, play the sound to alert the player if (foundUpgrades) { Cyclops.slotModSFX?.Play(); PdaOverlayManager.RemapItems(); } }
public void HandleUpgrades() { if (!initialized) { InitializeUpgradeHandlers(); } QuickLogger.Debug($"UpgradeManager clearing cyclops upgrades"); // Turn off all upgrades and clear all values for (int i = 0; i < upgradeHandlers.Length; i++) { UpgradeHandler upgradeType = upgradeHandlers[i]; if (upgradeType.HasUpgrade) { QuickLogger.Debug($"UpgradeManager clearing {upgradeType.TechType.AsString()}"); } upgradeType.UpgradesCleared(); // UpgradeHandler event } var foundUpgrades = new List <TechType>(); // Go through all slots and check what upgrades are available QuickLogger.Debug($"UpgradeManager checking upgrade slots"); foreach (UpgradeSlot upgradeSlot in this.UpgradeSlots) { Equipment modules = upgradeSlot.Modules; string slot = upgradeSlot.Slot; TechType techTypeInSlot = modules.GetTechTypeInSlot(slot); if (techTypeInSlot == TechType.None) { continue; } foundUpgrades.Add(techTypeInSlot); if (KnownsUpgradeModules.TryGetValue(techTypeInSlot, out UpgradeHandler handler)) { QuickLogger.Debug($"UpgradeManager counting cyclops upgrade '{techTypeInSlot.AsString()}'"); handler.UpgradeCounted(modules, slot); // UpgradeHandler event } else { QuickLogger.Warning($"UpgradeManager encountered unmanaged cyclops upgrade '{techTypeInSlot.AsString()}'"); } } for (int i = 0; i < upgradeHandlers.Length; i++) { upgradeHandlers[i].UpgradesFinished(); // UpgradeHandler event } // If any upgrades were found, play the sound to alert the player if (foundUpgrades.Count > 0) { Cyclops.slotModSFX?.Play(); PdaOverlayManager.RemapItems(); } Cyclops.BroadcastMessage("RefreshUpgradeConsoleIcons", foundUpgrades.ToArray(), SendMessageOptions.RequireReceiver); }