CPUPluginManager()
 {
     VanillaCPUMaxType = Enum.GetValues(typeof(ECPUClass)).Length;
     Logger.Info($"MaxTypeint = {VanillaCPUMaxType - 1}");
     foreach (PulsarPlugin plugin in PluginManager.Instance.GetAllPlugins())
     {
         Assembly asm       = plugin.GetType().Assembly;
         Type     CPUPlugin = typeof(CPUPlugin);
         foreach (Type t in asm.GetTypes())
         {
             if (CPUPlugin.IsAssignableFrom(t) && !t.IsInterface && !t.IsAbstract)
             {
                 Logger.Info("Loading CPU from assembly");
                 CPUPlugin CPUPluginHandler = (CPUPlugin)Activator.CreateInstance(t);
                 if (GetCPUIDFromName(CPUPluginHandler.Name) == -1)
                 {
                     CPUTypes.Add(CPUPluginHandler);
                     Logger.Info($"Added CPU: '{CPUPluginHandler.Name}' with ID '{GetCPUIDFromName(CPUPluginHandler.Name)}'");
                 }
                 else
                 {
                     Logger.Info($"Could not add CPU from {plugin.Name} with the duplicate name of '{CPUPluginHandler.Name}'");
                 }
             }
         }
     }
 }
        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 (Global.DebugLogging)
                {
                    Logger.Info($"Subtype for modded is {subtypeformodded}");
                }
                if (subtypeformodded <= Instance.CPUTypes.Count && subtypeformodded > -1)
                {
                    if (Global.DebugLogging)
                    {
                        Logger.Info("Creating CPU from list info");
                    }
                    CPUPlugin CPUType = Instance.CPUTypes[Subtype - Instance.VanillaCPUMaxType];
                    InCPU.SubType = Subtype;
                    InCPU.Name    = CPUType.Name;
                    InCPU.Desc    = CPUType.Description;
                    InCPU.GetType().GetField("m_IconTexture", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InCPU, CPUType.IconTexture);
                    InCPU.GetType().GetField("m_MarketPrice", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InCPU, (ObscuredInt)CPUType.MarketPrice);
                    InCPU.GetType().GetField("m_MaxPowerUsage_Watts", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InCPU, (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.GetType().GetField("m_Defense", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InCPU, CPUType.Defense);
                    InCPU.GetType().GetField("m_MaxCompUpgradeLevelBoost", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InCPU, CPUType.MaxCompUpgradeLevelBoost);
                    InCPU.GetType().GetField("m_MaxPawnItemUpgradeLevelBoost", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InCPU, CPUType.MaxItemUpgradeLevelBoost);
                    InCPU.GetType().GetField("Price_LevelMultiplierExponent", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InCPU, (ObscuredFloat)CPUType.Price_LevelMultiplierExponent);
                }
            }
            else
            {
                InCPU = new PLCPU((ECPUClass)Subtype, level);
            }
            return(InCPU);
        }