WarpDriveProgramModManager() { VanillaWarpDriveProgramMaxType = Enum.GetValues(typeof(EWarpDriveProgramType)).Length; Logger.Info($"MaxTypeint = {VanillaWarpDriveProgramMaxType - 1}"); foreach (PulsarMod mod in ModManager.Instance.GetAllMods()) { Assembly asm = mod.GetType().Assembly; Type WarpDriveProgramMod = typeof(WarpDriveProgramMod); foreach (Type t in asm.GetTypes()) { if (WarpDriveProgramMod.IsAssignableFrom(t) && !t.IsInterface && !t.IsAbstract) { Logger.Info("Loading WarpDriveProgram from assembly"); WarpDriveProgramMod WarpDriveProgramModHandler = (WarpDriveProgramMod)Activator.CreateInstance(t); if (GetWarpDriveProgramIDFromName(WarpDriveProgramModHandler.Name) == -1) { WarpDriveProgramTypes.Add(WarpDriveProgramModHandler); Logger.Info($"Added WarpDriveProgram: '{WarpDriveProgramModHandler.Name}' with ID '{GetWarpDriveProgramIDFromName(WarpDriveProgramModHandler.Name)}'"); } else { Logger.Info($"Could not add WarpDriveProgram from {mod.Name} with the duplicate name of '{WarpDriveProgramModHandler.Name}'"); } } } } }
public static PLWarpDriveProgram CreateWarpDriveProgram(int Subtype, int level) { PLWarpDriveProgram InWarpDriveProgram; if (Subtype >= Instance.VanillaWarpDriveProgramMaxType) { InWarpDriveProgram = new PLWarpDriveProgram(EWarpDriveProgramType.SHIELD_BOOSTER, level); int subtypeformodded = Subtype - Instance.VanillaWarpDriveProgramMaxType; if (subtypeformodded <= Instance.WarpDriveProgramTypes.Count && subtypeformodded > -1) { WarpDriveProgramMod WarpDriveProgramType = Instance.WarpDriveProgramTypes[Subtype - Instance.VanillaWarpDriveProgramMaxType]; InWarpDriveProgram.SubType = Subtype; InWarpDriveProgram.Name = WarpDriveProgramType.Name; InWarpDriveProgram.Desc = WarpDriveProgramType.Description; InWarpDriveProgram.MaxLevelCharges = WarpDriveProgramType.MaxLevelCharges; InWarpDriveProgram.m_IconTexture = WarpDriveProgramType.IconTexture; InWarpDriveProgram.ShortName = WarpDriveProgramType.ShortName; InWarpDriveProgram.ShieldBooster_BoostAmount = 0f; InWarpDriveProgram.m_MarketPrice = WarpDriveProgramType.MarketPrice; InWarpDriveProgram.CargoVisualPrefabID = WarpDriveProgramType.CargoVisualID; InWarpDriveProgram.CanBeDroppedOnShipDeath = WarpDriveProgramType.CanBeDroppedOnShipDeath; InWarpDriveProgram.Experimental = WarpDriveProgramType.Experimental; InWarpDriveProgram.Unstable = WarpDriveProgramType.Unstable; InWarpDriveProgram.Contraband = WarpDriveProgramType.Contraband; InWarpDriveProgram.Price_LevelMultiplierExponent = WarpDriveProgramType.Price_LevelMultiplierExponent; if (PhotonNetwork.isMasterClient) { InWarpDriveProgram.Level = InWarpDriveProgram.MaxLevelCharges; } } } else { InWarpDriveProgram = new PLWarpDriveProgram((EWarpDriveProgramType)Subtype, level); } return(InWarpDriveProgram); }