public static PLCPU CreateCPU(int Subtype, int level) { PLCPU InCPU; if (Subtype >= Instance.VanillaCPUMaxType) { InCPU = new PLCPU(ECPUClass.E_MAX, level); int subtypeformodded = Subtype - Instance.VanillaCPUMaxType; if (subtypeformodded <= Instance.CPUTypes.Count && subtypeformodded > -1) { CPUMod CPUType = Instance.CPUTypes[Subtype - Instance.VanillaCPUMaxType]; InCPU.SubType = Subtype; InCPU.Name = CPUType.Name; InCPU.Desc = CPUType.Description; InCPU.m_IconTexture = CPUType.IconTexture; InCPU.m_MarketPrice = CPUType.MarketPrice; InCPU.m_MaxPowerUsage_Watts = CPUType.MaxPowerUsage_Watts; InCPU.CargoVisualPrefabID = CPUType.CargoVisualID; InCPU.CanBeDroppedOnShipDeath = CPUType.CanBeDroppedOnShipDeath; InCPU.Experimental = CPUType.Experimental; InCPU.Unstable = CPUType.Unstable; InCPU.Contraband = CPUType.Contraband; InCPU.Speed = CPUType.Speed; InCPU.m_Defense = CPUType.Defense; InCPU.m_MaxCompUpgradeLevelBoost = CPUType.MaxCompUpgradeLevelBoost; InCPU.m_MaxPawnItemUpgradeLevelBoost = CPUType.MaxItemUpgradeLevelBoost; InCPU.Price_LevelMultiplierExponent = CPUType.Price_LevelMultiplierExponent; } } else { InCPU = new PLCPU((ECPUClass)Subtype, level); } return(InCPU); }
CPUModManager() { VanillaCPUMaxType = Enum.GetValues(typeof(ECPUClass)).Length; Logger.Info($"MaxTypeint = {VanillaCPUMaxType - 1}"); foreach (PulsarMod mod in ModManager.Instance.GetAllMods()) { Assembly asm = mod.GetType().Assembly; Type CPUMod = typeof(CPUMod); foreach (Type t in asm.GetTypes()) { if (CPUMod.IsAssignableFrom(t) && !t.IsInterface && !t.IsAbstract) { Logger.Info("Loading CPU from assembly"); CPUMod CPUModHandler = (CPUMod)Activator.CreateInstance(t); if (GetCPUIDFromName(CPUModHandler.Name) == -1) { CPUTypes.Add(CPUModHandler); Logger.Info($"Added CPU: '{CPUModHandler.Name}' with ID '{GetCPUIDFromName(CPUModHandler.Name)}'"); } else { Logger.Info($"Could not add CPU from {mod.Name} with the duplicate name of '{CPUModHandler.Name}'"); } } } } }