/// <summary> /// Replaces a nuclear battery modules with Depleted Reactor Rods when they fully drained. /// </summary> /// <param name="modules">The equipment modules.</param> /// <param name="slotName">Th slot name.</param> /// <param name="nuclearBattery">The nuclear battery that just ran out.</param> private void DepleteNuclearBattery(Equipment modules, string slotName, Battery nuclearBattery) { // Drained nuclear batteries are handled just like how the Nuclear Reactor handles depleated reactor rods InventoryItem inventoryItem = modules.RemoveItem(slotName, true, false); Object.Destroy(inventoryItem.item.gameObject); modules.AddItem(slotName, CyclopsModule.SpawnCyclopsModule(CyclopsModule.DepletedNuclearModuleID), true); ErrorMessage.AddMessage("Nuclear Reactor Module depleted"); }
private static void PatchUpgradeModules(bool enableNewUpgradeModules) { if (enableNewUpgradeModules) { QuickLogger.Info("Patching new upgrade modules"); } else { QuickLogger.Info("New upgrade modules disabled by config settings"); } CyclopsModule.PatchAllModules(enableNewUpgradeModules); }
public static void Patch() { try { var modConfig = new EmModPatchConfig(); modConfig.Initialize(); bool hasVehicleUpgradesInCyclops = Directory.Exists(@"./QMods/VehicleUpgradesInCyclops"); // ---------------------------------------------- Console.WriteLine("[MoreCyclopsUpgrades] Patching new upgrade modules"); CyclopsModule.PatchAllModules(hasVehicleUpgradesInCyclops, modConfig.EnableNewUpgradeModules); if (!modConfig.EnableNewUpgradeModules) { Console.WriteLine("[MoreCyclopsUpgrades] New upgrade modules disabled by config settings"); } // ---------------------------------------------- Console.WriteLine("[MoreCyclopsUpgrades] Patching Auxiliary Upgrade Console"); var auxConsole = new AuxCyUpgradeConsole(); auxConsole.Patch(modConfig.EnableAuxiliaryUpgradeConsoles); if (!modConfig.EnableAuxiliaryUpgradeConsoles) { Console.WriteLine("[MoreCyclopsUpgrades] Auxiliary Upgrade Console disabled by config settings"); } // ---------------------------------------------- HarmonyInstance harmony = HarmonyInstance.Create("com.morecyclopsupgrades.psmod"); harmony.PatchAll(Assembly.GetExecutingAssembly()); Console.WriteLine("[MoreCyclopsUpgrades] Finished Patching"); } catch (Exception ex) { Console.WriteLine("[MoreCyclopsUpgrades] ERROR: " + ex.ToString()); } }
public static void Patch() { try { QuickLogger.Message("Started patching " + QuickLogger.GetAssemblyVersion()); OtherMods.VehicleUpgradesInCyclops = Directory.Exists(@"./QMods/VehicleUpgradesInCyclops"); if (OtherMods.VehicleUpgradesInCyclops) { QuickLogger.Message("VehicleUpgradesInCyclops detected. Correcting placement of craft nodes in Cyclops Fabricator."); } var modConfig = new EmModPatchConfig(); modConfig.Initialize(); QuickLogger.Message("Patching new upgrade modules"); CyclopsModule.PatchAllModules(modConfig.EnableNewUpgradeModules); if (!modConfig.EnableNewUpgradeModules) { QuickLogger.Message("New upgrade modules disabled by config settings"); } QuickLogger.Message("Patching Auxiliary Upgrade Console"); var auxConsole = new AuxCyUpgradeConsole(); auxConsole.Patch(modConfig.EnableAuxiliaryUpgradeConsoles); if (!modConfig.EnableAuxiliaryUpgradeConsoles) { QuickLogger.Message("Auxiliary Upgrade Console disabled by config settings"); } var harmony = HarmonyInstance.Create("com.morecyclopsupgrades.psmod"); harmony.PatchAll(Assembly.GetExecutingAssembly()); QuickLogger.Message("Finished Patching"); } catch (Exception ex) { QuickLogger.Error(ex); } }
public static InventoryItem SpawnCyclopsModule(TechType techTypeID) { GameObject gameObject; if (techTypeID < TechType.Databox) // This is a standard upgrade module { gameObject = GameObject.Instantiate(CraftData.GetPrefabForTechType(techTypeID)); } else if (ModulesEnabled) // Safety check in case these are disabled in the config { if (!CyclopsModulesByTechType.ContainsKey(techTypeID)) { return(null); // error condition } // Get the CyclopsModule child class instance associated to this TechType CyclopsModule cyclopsModule = CyclopsModulesByTechType[techTypeID]; // Instantiate a new prefab of the appripriate template TechType gameObject = cyclopsModule.GetGameObject(); var ider = gameObject.GetComponent <PrefabIdentifier>(); // Set the TechType value on the TechTag var tag = gameObject.GetComponent <TechTag>(); if (tag != null) { tag.type = techTypeID; } else // Add if needed since this is how these are identified throughout the mod { gameObject.AddComponent <TechTag>().type = techTypeID; } // Set the class ID ider.ClassId = cyclopsModule.NameID; } else { return(null); // error condition } Pickupable pickupable = gameObject.GetComponent <Pickupable>().Pickup(false); return(new InventoryItem(pickupable)); }
public void OnProtoDeserializeObjectTree(ProtobufSerializer serializer) { bool hasSaveData = this.SaveData.Load(); if (hasSaveData) { // Because the items here aren't being serialized with everything else normally, // I've used custom save data to handle whatever gets left in these slots. // The following is a recreation of the essential parts of the Equipment.ResponseEquipment method. foreach (string slot in SlotHelper.SlotNames) { // These slots need to be added before we can add items to them this.Modules.AddSlot(slot); EmModuleSaveData savedModule = SaveData.GetModuleInSlot(slot); if (savedModule.ItemID == (int)TechType.None) { continue; } InventoryItem spanwedItem = CyclopsModule.SpawnCyclopsModule((TechType)savedModule.ItemID); if (spanwedItem is null) { continue; } if (savedModule.BatteryCharge > 0f) // Modules without batteries are stored with a -1 value for charge { spanwedItem.item.GetComponent <Battery>().charge = savedModule.BatteryCharge; } this.Modules.AddItem(slot, spanwedItem, true); } } else { this.UnlockDefaultModuleSlots(); } }
internal static void PatchAllModules(bool vehicleUpgradesInCyclopsFabricator, bool modulesEnabled) { ModulesEnabled = modulesEnabled; CyclopsModulesByModuleType.Add(ModuleTypes.Solar, new SolarCharger(vehicleUpgradesInCyclopsFabricator)); CyclopsModulesByModuleType.Add(ModuleTypes.SolarMk2, new SolarChargerMk2()); CyclopsModulesByModuleType.Add(ModuleTypes.ThermalMk2, new ThermalChargerMk2()); CyclopsModulesByModuleType.Add(ModuleTypes.PowerMk2, new PowerUpgradeMk2()); CyclopsModulesByModuleType.Add(ModuleTypes.PowerMk3, new PowerUpgradeMk3()); CyclopsModulesByModuleType.Add(ModuleTypes.Speed, new CyclopsSpeedBooster(vehicleUpgradesInCyclopsFabricator)); CyclopsModulesByModuleType.Add(ModuleTypes.Nuclear, new NuclearCharger()); CyclopsModulesByModuleType.Add(ModuleTypes.DepletedNuclear, new DepletedNuclearModule()); foreach (ModuleTypes m in Enum.GetValues(typeof(ModuleTypes))) { CyclopsModule module = CyclopsModulesByModuleType[m]; Console.WriteLine($"[MoreCyclopsUpgrades] Patching {module.NameID}"); module.Patch(); CyclopsModulesByTechType.Add(module.TechType, module); } }