WarpDriveProgramPluginManager() { VanillaWarpDriveProgramMaxType = Enum.GetValues(typeof(EWarpDriveProgramType)).Length; Logger.Info($"MaxTypeint = {VanillaWarpDriveProgramMaxType - 1}"); foreach (PulsarPlugin plugin in PluginManager.Instance.GetAllPlugins()) { Assembly asm = plugin.GetType().Assembly; Type WarpDriveProgramPlugin = typeof(WarpDriveProgramPlugin); foreach (Type t in asm.GetTypes()) { if (WarpDriveProgramPlugin.IsAssignableFrom(t) && !t.IsInterface && !t.IsAbstract) { Logger.Info("Loading WarpDriveProgram from assembly"); WarpDriveProgramPlugin WarpDriveProgramPluginHandler = (WarpDriveProgramPlugin)Activator.CreateInstance(t); if (GetWarpDriveProgramIDFromName(WarpDriveProgramPluginHandler.Name) == -1) { WarpDriveProgramTypes.Add(WarpDriveProgramPluginHandler); Logger.Info($"Added WarpDriveProgram: '{WarpDriveProgramPluginHandler.Name}' with ID '{GetWarpDriveProgramIDFromName(WarpDriveProgramPluginHandler.Name)}'"); } else { Logger.Info($"Could not add WarpDriveProgram from {plugin.Name} with the duplicate name of '{WarpDriveProgramPluginHandler.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 (Global.DebugLogging) { Logger.Info($"Subtype for modded is {subtypeformodded}"); } if (subtypeformodded <= Instance.WarpDriveProgramTypes.Count && subtypeformodded > -1) { if (Global.DebugLogging) { Logger.Info("Creating WarpDriveProgram from list info"); } WarpDriveProgramPlugin WarpDriveProgramType = Instance.WarpDriveProgramTypes[Subtype - Instance.VanillaWarpDriveProgramMaxType]; InWarpDriveProgram.SubType = Subtype; InWarpDriveProgram.Name = WarpDriveProgramType.Name; InWarpDriveProgram.Desc = WarpDriveProgramType.Description; InWarpDriveProgram.MaxLevelCharges = WarpDriveProgramType.MaxLevelCharges; InWarpDriveProgram.GetType().GetField("m_IconTexture", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InWarpDriveProgram, WarpDriveProgramType.IconTexture); InWarpDriveProgram.ShortName = WarpDriveProgramType.ShortName; InWarpDriveProgram.GetType().GetField("ShieldBooster_BoostAmount", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InWarpDriveProgram, 0f); InWarpDriveProgram.GetType().GetField("m_MarketPrice", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InWarpDriveProgram, (ObscuredInt)WarpDriveProgramType.MarketPrice); InWarpDriveProgram.CargoVisualPrefabID = WarpDriveProgramType.CargoVisualID; InWarpDriveProgram.CanBeDroppedOnShipDeath = WarpDriveProgramType.CanBeDroppedOnShipDeath; InWarpDriveProgram.Experimental = WarpDriveProgramType.Experimental; InWarpDriveProgram.Unstable = WarpDriveProgramType.Unstable; InWarpDriveProgram.Contraband = WarpDriveProgramType.Contraband; InWarpDriveProgram.GetType().GetField("Price_LevelMultiplierExponent", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InWarpDriveProgram, (ObscuredFloat)WarpDriveProgramType.Price_LevelMultiplierExponent); if (PhotonNetwork.isMasterClient) { InWarpDriveProgram.Level = InWarpDriveProgram.MaxLevelCharges; } } } else { InWarpDriveProgram = new PLWarpDriveProgram((EWarpDriveProgramType)Subtype, level); } return(InWarpDriveProgram); }