示例#1
0
        public static PLPolytechModule CreatePolytechModule(int Subtype, int level)
        {
            PLPolytechModule InPolytechModule;

            if (Subtype >= Instance.VanillaPolytechModuleMaxType)
            {
                InPolytechModule = new PLPolytechModule(EPolytechModuleType.E_MAX, level);
                int subtypeformodded = Subtype - Instance.VanillaPolytechModuleMaxType;
                if (subtypeformodded <= Instance.PolytechModuleTypes.Count && subtypeformodded > -1)
                {
                    PolytechModuleMod PolytechModuleType = Instance.PolytechModuleTypes[Subtype - Instance.VanillaPolytechModuleMaxType];
                    InPolytechModule.SubType                       = Subtype;
                    InPolytechModule.Name                          = PolytechModuleType.Name;
                    InPolytechModule.Desc                          = PolytechModuleType.Description;
                    InPolytechModule.m_IconTexture                 = PolytechModuleType.IconTexture;
                    InPolytechModule.m_MarketPrice                 = PolytechModuleType.MarketPrice;
                    InPolytechModule.CargoVisualPrefabID           = PolytechModuleType.CargoVisualID;
                    InPolytechModule.CanBeDroppedOnShipDeath       = PolytechModuleType.CanBeDroppedOnShipDeath;
                    InPolytechModule.Experimental                  = PolytechModuleType.Experimental;
                    InPolytechModule.Unstable                      = PolytechModuleType.Unstable;
                    InPolytechModule.Contraband                    = PolytechModuleType.Contraband;
                    InPolytechModule.Price_LevelMultiplierExponent = PolytechModuleType.Price_LevelMultiplierExponent;
                    InPolytechModule.m_MaxPowerUsage_Watts         = PolytechModuleType.MaxPowerUsage_Watts;
                }
            }
            else
            {
                InPolytechModule = new PLPolytechModule((EPolytechModuleType)Subtype, level);
            }
            return(InPolytechModule);
        }
示例#2
0
 PolytechModuleModManager()
 {
     VanillaPolytechModuleMaxType = Enum.GetValues(typeof(EPolytechModuleType)).Length;
     Logger.Info($"MaxTypeint = {VanillaPolytechModuleMaxType - 1}");
     foreach (PulsarMod mod in ModManager.Instance.GetAllMods())
     {
         Assembly asm = mod.GetType().Assembly;
         Type     PolytechModuleMod = typeof(PolytechModuleMod);
         foreach (Type t in asm.GetTypes())
         {
             if (PolytechModuleMod.IsAssignableFrom(t) && !t.IsInterface && !t.IsAbstract)
             {
                 Logger.Info("Loading PolytechModule from assembly");
                 PolytechModuleMod PolytechModuleModHandler = (PolytechModuleMod)Activator.CreateInstance(t);
                 if (GetPolytechModuleIDFromName(PolytechModuleModHandler.Name) == -1)
                 {
                     PolytechModuleTypes.Add(PolytechModuleModHandler);
                     Logger.Info($"Added PolytechModule: '{PolytechModuleModHandler.Name}' with ID '{GetPolytechModuleIDFromName(PolytechModuleModHandler.Name)}'");
                 }
                 else
                 {
                     Logger.Info($"Could not add PolytechModule from {mod.Name} with the duplicate name of '{PolytechModuleModHandler.Name}'");
                 }
             }
         }
     }
 }