public static PLMissionShipComponent CreateMissionShipComponent(int Subtype, int level) { PLMissionShipComponent InMissionShipComponent; if (Subtype >= Instance.VanillaMissionShipComponentMaxType) { InMissionShipComponent = new PLMissionShipComponent(0, level); int subtypeformodded = Subtype - Instance.VanillaMissionShipComponentMaxType; if (subtypeformodded <= Instance.MissionShipComponentTypes.Count && subtypeformodded > -1) { MissionShipComponentMod MissionShipComponentType = Instance.MissionShipComponentTypes[Subtype - Instance.VanillaMissionShipComponentMaxType]; InMissionShipComponent.SubType = Subtype; InMissionShipComponent.Name = MissionShipComponentType.Name; InMissionShipComponent.Desc = MissionShipComponentType.Description; InMissionShipComponent.m_IconTexture = MissionShipComponentType.IconTexture; InMissionShipComponent.m_MarketPrice = MissionShipComponentType.MarketPrice; InMissionShipComponent.CargoVisualPrefabID = MissionShipComponentType.CargoVisualID; InMissionShipComponent.CanBeDroppedOnShipDeath = MissionShipComponentType.CanBeDroppedOnShipDeath; InMissionShipComponent.Experimental = MissionShipComponentType.Experimental; InMissionShipComponent.Unstable = MissionShipComponentType.Unstable; InMissionShipComponent.Contraband = MissionShipComponentType.Contraband; InMissionShipComponent.Price_LevelMultiplierExponent = MissionShipComponentType.Price_LevelMultiplierExponent; } } else { InMissionShipComponent = new PLMissionShipComponent(Subtype, level); } return(InMissionShipComponent); }
MissionShipComponentModManager() { VanillaMissionShipComponentMaxType = 13; Logger.Info($"MaxTypeint = {VanillaMissionShipComponentMaxType - 1}"); foreach (PulsarMod mod in ModManager.Instance.GetAllMods()) { Assembly asm = mod.GetType().Assembly; Type MissionShipComponentMod = typeof(MissionShipComponentMod); foreach (Type t in asm.GetTypes()) { if (MissionShipComponentMod.IsAssignableFrom(t) && !t.IsInterface && !t.IsAbstract) { Logger.Info("Loading MissionShipComponent from assembly"); MissionShipComponentMod MissionShipComponentModHandler = (MissionShipComponentMod)Activator.CreateInstance(t); if (GetMissionShipComponentIDFromName(MissionShipComponentModHandler.Name) == -1) { MissionShipComponentTypes.Add(MissionShipComponentModHandler); Logger.Info($"Added MissionShipComponent: '{MissionShipComponentModHandler.Name}' with ID '{GetMissionShipComponentIDFromName(MissionShipComponentModHandler.Name)}'"); } else { Logger.Info($"Could not add MissionShipComponent from {mod.Name} with the duplicate name of '{MissionShipComponentModHandler.Name}'"); } } } } }