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}'"); } } } } }
VirusPluginManager() { VanillaVirusMaxType = Enum.GetValues(typeof(EVirusType)).Length - 1; Logger.Info($"MaxTypeint = {VanillaVirusMaxType - 1}"); foreach (PulsarPlugin plugin in PluginManager.Instance.GetAllPlugins()) { Assembly asm = plugin.GetType().Assembly; Type VirusPlugin = typeof(VirusPlugin); foreach (Type t in asm.GetTypes()) { if (VirusPlugin.IsAssignableFrom(t) && !t.IsInterface && !t.IsAbstract) { Logger.Info("Loading Virus from assembly"); VirusPlugin VirusPluginHandler = (VirusPlugin)Activator.CreateInstance(t); if (GetVirusIDFromName(VirusPluginHandler.Name) == -1) { VirusTypes.Add(VirusPluginHandler); Logger.Info($"Added Virus: '{VirusPluginHandler.Name}' with ID '{GetVirusIDFromName(VirusPluginHandler.Name)}'"); } else { Logger.Info($"Could not add Virus from {plugin.Name} with the duplicate name of '{VirusPluginHandler.Name}'"); } } } } }
ShieldPluginManager() { VanillaShieldMaxType = Enum.GetValues(typeof(EShieldGeneratorType)).Length; Logger.Info($"MaxTypeint = {VanillaShieldMaxType - 1}"); foreach (PulsarPlugin plugin in PluginManager.Instance.GetAllPlugins()) { Assembly asm = plugin.GetType().Assembly; Type ShieldPlugin = typeof(ShieldPlugin); foreach (Type t in asm.GetTypes()) { if (ShieldPlugin.IsAssignableFrom(t) && !t.IsInterface && !t.IsAbstract) { Logger.Info("Loading Shield from assembly"); ShieldPlugin ShieldPluginHandler = (ShieldPlugin)Activator.CreateInstance(t); if (GetShieldIDFromName(ShieldPluginHandler.Name) == -1) { ShieldTypes.Add(ShieldPluginHandler); Logger.Info($"Added Shield: '{ShieldPluginHandler.Name}' with ID '{GetShieldIDFromName(ShieldPluginHandler.Name)}'"); } else { Logger.Info($"Could not add Shield from {plugin.Name} with the duplicate name of '{ShieldPluginHandler.Name}'"); } } } } }
InertiaThrusterPluginManager() { VanillaInertiaThrusterMaxType = Enum.GetValues(typeof(EInertiaThrusterType)).Length; Logger.Info($"MaxTypeint = {VanillaInertiaThrusterMaxType - 1}"); foreach (PulsarPlugin plugin in PluginManager.Instance.GetAllPlugins()) { Assembly asm = plugin.GetType().Assembly; Type InertiaThrusterPlugin = typeof(InertiaThrusterPlugin); foreach (Type t in asm.GetTypes()) { if (InertiaThrusterPlugin.IsAssignableFrom(t) && !t.IsInterface && !t.IsAbstract) { Logger.Info("Loading InertiaThruster from assembly"); InertiaThrusterPlugin InertiaThrusterPluginHandler = (InertiaThrusterPlugin)Activator.CreateInstance(t); if (GetInertiaThrusterIDFromName(InertiaThrusterPluginHandler.Name) == -1) { InertiaThrusterTypes.Add(InertiaThrusterPluginHandler); Logger.Info($"Added InertiaThruster: '{InertiaThrusterPluginHandler.Name}' with ID '{GetInertiaThrusterIDFromName(InertiaThrusterPluginHandler.Name)}'"); } else { Logger.Info($"Could not add InertiaThruster from {plugin.Name} with the duplicate name of '{InertiaThrusterPluginHandler.Name}'"); } } } } }
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}'"); } } } } }
MegaTurretPluginManager() { VanillaMegaTurretMaxType = 7; Logger.Info($"MaxTypeint = {VanillaMegaTurretMaxType - 1}"); foreach (PulsarPlugin plugin in PluginManager.Instance.GetAllPlugins()) { Assembly asm = plugin.GetType().Assembly; Type MegaTurretPlugin = typeof(MegaTurretPlugin); foreach (Type t in asm.GetTypes()) { if (MegaTurretPlugin.IsAssignableFrom(t) && !t.IsInterface && !t.IsAbstract) { Logger.Info("Loading MegaTurret from assembly"); MegaTurretPlugin MegaTurretPluginHandler = (MegaTurretPlugin)Activator.CreateInstance(t); if (GetMegaTurretIDFromName(MegaTurretPluginHandler.Name) == -1) { MegaTurretTypes.Add(MegaTurretPluginHandler); Logger.Info($"Added MegaTurret: '{MegaTurretPluginHandler.Name}' with ID '{GetMegaTurretIDFromName(MegaTurretPluginHandler.Name)}'"); } else { Logger.Info($"Could not add MegaTurret from {plugin.Name} with the duplicate name of '{MegaTurretPluginHandler.Name}'"); } } } } }
MissilePluginManager() { VanillaMissileMaxType = Enum.GetValues(typeof(ETrackerMissileType)).Length; Logger.Info($"MaxTypeint = {VanillaMissileMaxType - 1}"); foreach (PulsarPlugin plugin in PluginManager.Instance.GetAllPlugins()) { Assembly asm = plugin.GetType().Assembly; Type MissilePlugin = typeof(MissilePlugin); foreach (Type t in asm.GetTypes()) { if (MissilePlugin.IsAssignableFrom(t) && !t.IsInterface && !t.IsAbstract) { Logger.Info("Loading Missile from assembly"); MissilePlugin MissilePluginHandler = (MissilePlugin)Activator.CreateInstance(t); if (GetMissileIDFromName(MissilePluginHandler.Name) == -1) { MissileTypes.Add(MissilePluginHandler); Logger.Info($"Added Missile: '{MissilePluginHandler.Name}' with ID '{GetMissileIDFromName(MissilePluginHandler.Name)}'"); } else { Logger.Info($"Could not add Missile from {plugin.Name} with the duplicate name of '{MissilePluginHandler.Name}'"); } } } } }
static void Prefix(PhotonPlayer connected) { if (PhotonNetwork.isMasterClient) { Logger.Info("Sending Ping (asking for mod list/Pong)"); ModMessageHelper.Instance.photonView.RPC("SendConnectionMessage", connected, new object[0]); } }
public static PLShieldGenerator CreateShield(int Subtype, int level) { PLShieldGenerator InShield; if (Subtype >= Instance.VanillaShieldMaxType) { InShield = new PLShieldGenerator(EShieldGeneratorType.E_SG_ID_MAX, level); int subtypeformodded = Subtype - Instance.VanillaShieldMaxType; if (Global.DebugLogging) { Logger.Info($"Subtype for modded is {subtypeformodded}"); } if (subtypeformodded <= Instance.ShieldTypes.Count && subtypeformodded > -1) { if (Global.DebugLogging) { Logger.Info("Creating Shield from list info"); } ShieldPlugin ShieldType = Instance.ShieldTypes[Subtype - Instance.VanillaShieldMaxType]; InShield.SubType = Subtype; InShield.Name = ShieldType.Name; InShield.Desc = ShieldType.Description; InShield.GetType().GetField("m_IconTexture", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InShield, ShieldType.IconTexture); InShield.Max = ShieldType.ShieldMax; InShield.ChargeRateMax = ShieldType.ChargeRateMax; InShield.RecoveryRate = ShieldType.RecoveryRate; InShield.Deflection = ShieldType.Deflection; InShield.MinIntegrityPercentForQuantumShield = ShieldType.MinIntegrityPercentForQuantumShield; InShield.MinIntegrityAfterDamage = ShieldType.MinIntegrityAfterDamage; InShield.GetType().GetField("m_MaxPowerUsage_Watts", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InShield, (ShieldType.MaxPowerUsage_Watts * 1.4f)); InShield.GetType().GetField("m_MarketPrice", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InShield, (ObscuredInt)ShieldType.MarketPrice); InShield.CargoVisualPrefabID = ShieldType.CargoVisualID; InShield.CanBeDroppedOnShipDeath = ShieldType.CanBeDroppedOnShipDeath; InShield.Experimental = ShieldType.Experimental; InShield.Unstable = ShieldType.Unstable; InShield.Contraband = ShieldType.Contraband; InShield.GetType().GetField("Price_LevelMultiplierExponent", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InShield, (ObscuredFloat)ShieldType.Price_LevelMultiplierExponent); if (InShield.MinIntegrityAfterDamage == -1) { InShield.MinIntegrityAfterDamage = Mathf.RoundToInt(InShield.Max * 0.15f); } InShield.MinIntegrityAfterDamage = Mathf.RoundToInt(InShield.MinIntegrityAfterDamage * (1f - Mathf.Clamp(0.05f * InShield.Level, 0f, 0.8f))); InShield.CurrentMax = InShield.Max; InShield.Current = InShield.Max; } } else { InShield = new PLShieldGenerator((EShieldGeneratorType)Subtype, level); } return(InShield); }
static bool Prefix(int inSubType, int inLevel, ref PLShipComponent __result) { int subtypeformodded = inSubType - MegaTurretPluginManager.Instance.VanillaMegaTurretMaxType; if (subtypeformodded <= MegaTurretPluginManager.Instance.MegaTurretTypes.Count && subtypeformodded > -1) { Logger.Info("Creating MegaTurret from list info"); __result = MegaTurretPluginManager.Instance.MegaTurretTypes[subtypeformodded].PLMegaTurret; __result.Level = inLevel; return(false); } return(true); }
static bool Prefix(int inSubType, int inLevel, ref PLShipComponent __result) { int subtypeformodded = inSubType - HullPlatingPluginManager.Instance.VanillaHullPlatingMaxType; if (subtypeformodded <= HullPlatingPluginManager.Instance.HullPlatingTypes.Count && subtypeformodded > -1) { Logger.Info("Creating HullPlating from list info"); __result = HullPlatingPluginManager.Instance.HullPlatingTypes[subtypeformodded].PLHullPlating; __result.Level = inLevel; return(false); } return(true); }
static bool Prefix(ref RoomInfo room) { //overall basic description: checks if it is possible to join room based on mods installed locally and on the server string LocalMods = MPModChecks.GetMPModList(); string MPMods = MPModChecks.GetHostModList(room); Logger.Info($"Joining room: {room.Name} MPmodlist: {room.CustomProperties["modList"]} Localmodlist: {LocalMods}"); if (!string.IsNullOrEmpty(LocalMods)) { Logger.Info("Modlist != NullOrEmpty"); if (MPMods != LocalMods) { string missingmods = string.Empty; string[] localmodlist = LocalMods.Split('\n'); foreach (string plugin in localmodlist) { //Logger.Info("Checking client mod " + plugin); if (!string.IsNullOrEmpty(plugin) && !MPMods.Contains(plugin)) { missingmods += plugin + "\n"; } } string[] MPmodlist = MPMods.Split('\n'); if (missingmods != string.Empty) { Logger.Info("Client mods good, checking server mods"); foreach (string plugin in MPmodlist) { //Logger.Info("Checking Server mod " + plugin); if (!string.IsNullOrEmpty(plugin) && !LocalMods.Contains(plugin) && plugin.Contains("MPF3")) { missingmods += plugin + "\n"; } } if (missingmods != string.Empty) { Logger.Info("Server plugin list is not equal to local plugin list"); PLNetworkManager.Instance.MainMenu.AddActiveMenu(new PLErrorMessageMenu($"Failed to join crew! The Server is missing the following mods or is not up to date (try uninstalling/updating):\n{missingmods}")); return(false); } } PLNetworkManager.Instance.MainMenu.AddActiveMenu(new PLErrorMessageMenu($"Failed to join crew! You are missing the following mods or the mods are not up to date:\n{missingmods}")); Logger.Info("Local Plugin list is not equal to Server plugin list"); return(false); } } Logger.Info("Modcheck passed, proceding ondwards"); return(true); }
public static PLTrackerMissile CreateMissile(int Subtype, int level, int inSubTypeData = 0) { PLTrackerMissile InMissile; if (Subtype >= Instance.VanillaMissileMaxType) { InMissile = new PLTrackerMissile(ETrackerMissileType.MAX, level, inSubTypeData); int subtypeformodded = Subtype - Instance.VanillaMissileMaxType; if (Global.DebugLogging) { Logger.Info($"Subtype for modded is {subtypeformodded}"); } if (subtypeformodded <= Instance.MissileTypes.Count && subtypeformodded > -1) { if (Global.DebugLogging) { Logger.Info("Creating Missile from list info"); } MissilePlugin MissileType = Instance.MissileTypes[Subtype - Instance.VanillaMissileMaxType]; InMissile.SubType = Subtype; InMissile.Name = MissileType.Name; InMissile.Desc = MissileType.Description; InMissile.GetType().GetField("m_IconTexture", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InMissile, MissileType.IconTexture); InMissile.Damage = MissileType.Damage; InMissile.Speed = MissileType.Speed; InMissile.DamageType = MissileType.DamageType; InMissile.MissileRefillPrice = MissileType.MissileRefillPrice; InMissile.AmmoCapacity = MissileType.AmmoCapacity; InMissile.PrefabID = MissileType.PrefabID; InMissile.GetType().GetField("m_MarketPrice", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InMissile, (ObscuredInt)MissileType.MarketPrice); InMissile.CargoVisualPrefabID = MissileType.CargoVisualID; InMissile.CanBeDroppedOnShipDeath = MissileType.CanBeDroppedOnShipDeath; InMissile.Experimental = MissileType.Experimental; InMissile.Unstable = MissileType.Unstable; InMissile.Contraband = MissileType.Contraband; InMissile.GetType().GetField("Price_LevelMultiplierExponent", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InMissile, (ObscuredFloat)MissileType.Price_LevelMultiplierExponent); if (PhotonNetwork.isMasterClient) { InMissile.SubTypeData = (short)InMissile.AmmoCapacity; } } } else { InMissile = new PLTrackerMissile((ETrackerMissileType)Subtype, level, inSubTypeData); } return(InMissile); }
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); }
public static PLNuclearDevice CreateNuclearDevice(int Subtype, int level) { PLNuclearDevice InNuclearDevice; if (Subtype >= Instance.VanillaNuclearDeviceMaxType) { InNuclearDevice = new PLNuclearDevice(ENuclearDeviceType.MAX, level); int subtypeformodded = Subtype - Instance.VanillaNuclearDeviceMaxType; if (Global.DebugLogging) { Logger.Info($"Subtype for modded is {subtypeformodded}"); } if (subtypeformodded <= Instance.NuclearDeviceTypes.Count && subtypeformodded > -1) { if (Global.DebugLogging) { Logger.Info("Creating NuclearDevice from list info"); } NuclearDevicePlugin NuclearDeviceType = Instance.NuclearDeviceTypes[Subtype - Instance.VanillaNuclearDeviceMaxType]; InNuclearDevice.SubType = Subtype; InNuclearDevice.Name = NuclearDeviceType.Name; InNuclearDevice.Desc = NuclearDeviceType.Description; InNuclearDevice.GetType().GetField("m_IconTexture", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InNuclearDevice, NuclearDeviceType.IconTexture); InNuclearDevice.GetType().GetField("m_MaxDamage", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InNuclearDevice, NuclearDeviceType.MaxDamage); InNuclearDevice.GetType().GetField("m_Range", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InNuclearDevice, NuclearDeviceType.Range); InNuclearDevice.GetType().GetField("m_FuelBurnRate", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InNuclearDevice, NuclearDeviceType.FuelBurnRate); InNuclearDevice.GetType().GetField("m_TurnRate", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InNuclearDevice, NuclearDeviceType.TurnRate); InNuclearDevice.GetType().GetField("m_IntimidationBonus", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InNuclearDevice, NuclearDeviceType.IntimidationBonus); InNuclearDevice.GetType().GetField("m_TurnRate", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InNuclearDevice, NuclearDeviceType.TurnRate); InNuclearDevice.GetType().GetField("m_Health", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InNuclearDevice, NuclearDeviceType.Health); InNuclearDevice.GetType().GetField("m_MarketPrice", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InNuclearDevice, (ObscuredInt)NuclearDeviceType.MarketPrice); InNuclearDevice.CargoVisualPrefabID = NuclearDeviceType.CargoVisualID; InNuclearDevice.CanBeDroppedOnShipDeath = NuclearDeviceType.CanBeDroppedOnShipDeath; InNuclearDevice.Experimental = NuclearDeviceType.Experimental; InNuclearDevice.Unstable = NuclearDeviceType.Unstable; InNuclearDevice.Contraband = NuclearDeviceType.Contraband; InNuclearDevice.GetType().GetField("Price_LevelMultiplierExponent", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InNuclearDevice, (ObscuredFloat)NuclearDeviceType.Price_LevelMultiplierExponent); } } else { InNuclearDevice = new PLNuclearDevice((ENuclearDeviceType)Subtype, level); } return(InNuclearDevice); }
public static PLHull CreateHull(int Subtype, int level) { PLHull InHull; if (Subtype >= Instance.VanillaHullMaxType) { InHull = new PLHull(EHullType.E_MAX, level); int subtypeformodded = Subtype - Instance.VanillaHullMaxType; if (Global.DebugLogging) { Logger.Info($"Subtype for modded is {subtypeformodded}"); } if (subtypeformodded <= Instance.HullTypes.Count && subtypeformodded > -1) { if (Global.DebugLogging) { Logger.Info("Creating Hull from list info"); } HullPlugin HullType = Instance.HullTypes[Subtype - Instance.VanillaHullMaxType]; InHull.SubType = Subtype; InHull.Name = HullType.Name; InHull.Desc = HullType.Description; InHull.GetType().GetField("m_IconTexture", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InHull, HullType.IconTexture); InHull.Max = HullType.HullMax; InHull.Armor = HullType.Armor; InHull.Defense = HullType.Defense; InHull.GetType().GetField("m_MarketPrice", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InHull, (ObscuredInt)HullType.MarketPrice); InHull.CargoVisualPrefabID = HullType.CargoVisualID; InHull.CanBeDroppedOnShipDeath = HullType.CanBeDroppedOnShipDeath; InHull.Experimental = HullType.Experimental; InHull.Unstable = HullType.Unstable; InHull.Contraband = HullType.Contraband; InHull.GetType().GetField("Price_LevelMultiplierExponent", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InHull, (ObscuredFloat)HullType.Price_LevelMultiplierExponent); InHull.Max *= 2f; InHull.Current = InHull.Max; } } else { InHull = new PLHull((EHullType)Subtype, level); } return(InHull); }
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); }
public static PLWarpDrive CreateWarpDrive(int Subtype, int level) { PLWarpDrive InWarpDrive; if (Subtype >= Instance.VanillaWarpDriveMaxType) { InWarpDrive = new PLWarpDrive(EWarpDriveType.E_MAX, level); int subtypeformodded = Subtype - Instance.VanillaWarpDriveMaxType; if (Global.DebugLogging) { Logger.Info($"Subtype for modded is {subtypeformodded}"); } if (subtypeformodded <= Instance.WarpDriveTypes.Count && subtypeformodded > -1) { if (Global.DebugLogging) { Logger.Info("Creating WarpDrive from list info"); } WarpDrivePlugin WarpDriveType = Instance.WarpDriveTypes[Subtype - Instance.VanillaWarpDriveMaxType]; InWarpDrive.SubType = Subtype; InWarpDrive.Name = WarpDriveType.Name; InWarpDrive.Desc = WarpDriveType.Description; InWarpDrive.GetType().GetField("m_IconTexture", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InWarpDrive, WarpDriveType.IconTexture); InWarpDrive.ChargeSpeed = WarpDriveType.ChargeSpeed; InWarpDrive.WarpRange = WarpDriveType.WarpRange; InWarpDrive.EnergySignatureAmt = WarpDriveType.EnergySignature; InWarpDrive.NumberOfChargingNodes = WarpDriveType.NumberOfChargesPerFuel; InWarpDrive.GetType().GetField("m_MarketPrice", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InWarpDrive, (ObscuredInt)WarpDriveType.MarketPrice); InWarpDrive.CargoVisualPrefabID = WarpDriveType.CargoVisualID; InWarpDrive.CanBeDroppedOnShipDeath = WarpDriveType.CanBeDroppedOnShipDeath; InWarpDrive.Experimental = WarpDriveType.Experimental; InWarpDrive.Unstable = WarpDriveType.Unstable; InWarpDrive.Contraband = WarpDriveType.Contraband; InWarpDrive.GetType().GetField("Price_LevelMultiplierExponent", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InWarpDrive, (ObscuredFloat)WarpDriveType.Price_LevelMultiplierExponent); } } else { InWarpDrive = new PLWarpDrive((EWarpDriveType)Subtype, level); } return(InWarpDrive); }
public static PLManeuverThruster CreateManeuverThruster(int Subtype, int level) { PLManeuverThruster InManeuverThruster; if (Subtype >= Instance.VanillaManeuverThrusterMaxType) { InManeuverThruster = new PLManeuverThruster(EManeuverThrusterType.E_MAX, level); int subtypeformodded = Subtype - Instance.VanillaManeuverThrusterMaxType; if (Global.DebugLogging) { Logger.Info($"Subtype for modded is {subtypeformodded}"); } if (subtypeformodded <= Instance.ManeuverThrusterTypes.Count && subtypeformodded > -1) { if (Global.DebugLogging) { Logger.Info("Creating ManeuverThruster from list info"); } ManeuverThrusterPlugin ManeuverThrusterType = Instance.ManeuverThrusterTypes[Subtype - Instance.VanillaManeuverThrusterMaxType]; InManeuverThruster.SubType = Subtype; InManeuverThruster.Name = ManeuverThrusterType.Name; InManeuverThruster.Desc = ManeuverThrusterType.Description; InManeuverThruster.GetType().GetField("m_IconTexture", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InManeuverThruster, ManeuverThrusterType.IconTexture); InManeuverThruster.GetType().GetField("m_MaxOutput", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InManeuverThruster, ManeuverThrusterType.MaxOutput); InManeuverThruster.GetType().GetField("m_MaxPowerUsage_Watts", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InManeuverThruster, ManeuverThrusterType.MaxPowerUsage_Watts); InManeuverThruster.GetType().GetField("m_MarketPrice", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InManeuverThruster, (ObscuredInt)ManeuverThrusterType.MarketPrice); InManeuverThruster.CargoVisualPrefabID = ManeuverThrusterType.CargoVisualID; InManeuverThruster.CanBeDroppedOnShipDeath = ManeuverThrusterType.CanBeDroppedOnShipDeath; InManeuverThruster.Experimental = ManeuverThrusterType.Experimental; InManeuverThruster.Unstable = ManeuverThrusterType.Unstable; InManeuverThruster.Contraband = ManeuverThrusterType.Contraband; InManeuverThruster.GetType().GetMethod("UpdateMaxPowerWatts", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(InManeuverThruster, new object[0]); InManeuverThruster.GetType().GetField("Price_LevelMultiplierExponent", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InManeuverThruster, (ObscuredFloat)ManeuverThrusterType.Price_LevelMultiplierExponent); } } else { InManeuverThruster = new PLManeuverThruster((EManeuverThrusterType)Subtype, level); } return(InManeuverThruster); }
public static PLExtractor CreateExtractor(int Subtype, int level) { PLExtractor InExtractor; if (Subtype >= Instance.VanillaExtractorMaxType) { InExtractor = new PLExtractor(EExtractorType.E_MAX, level); int subtypeformodded = Subtype - Instance.VanillaExtractorMaxType; if (Global.DebugLogging) { Logger.Info($"Subtype for modded is {subtypeformodded}"); } if (subtypeformodded <= Instance.ExtractorTypes.Count && subtypeformodded > -1) { if (Global.DebugLogging) { Logger.Info("Creating Extractor from list info"); } ExtractorPlugin ExtractorType = Instance.ExtractorTypes[Subtype - Instance.VanillaExtractorMaxType]; InExtractor.SubType = Subtype; InExtractor.Name = ExtractorType.Name; InExtractor.Desc = ExtractorType.Description; InExtractor.GetType().GetField("m_IconTexture", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InExtractor, ExtractorType.IconTexture); InExtractor.GetType().GetField("m_Stability", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InExtractor, ExtractorType.Stability); InExtractor.GetType().GetField("m_MarketPrice", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InExtractor, (ObscuredInt)ExtractorType.MarketPrice); InExtractor.CargoVisualPrefabID = ExtractorType.CargoVisualID; InExtractor.CanBeDroppedOnShipDeath = ExtractorType.CanBeDroppedOnShipDeath; InExtractor.Experimental = ExtractorType.Experimental; InExtractor.Unstable = ExtractorType.Unstable; InExtractor.Contraband = ExtractorType.Contraband; InExtractor.GetType().GetField("Price_LevelMultiplierExponent", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InExtractor, (ObscuredFloat)ExtractorType.Price_LevelMultiplierExponent); } } else { InExtractor = new PLExtractor((EExtractorType)Subtype, level); } return(InExtractor); }
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 (Global.DebugLogging) { Logger.Info($"Subtype for modded is {subtypeformodded}"); } if (subtypeformodded <= Instance.MissionShipComponentTypes.Count && subtypeformodded > -1) { if (Global.DebugLogging) { Logger.Info("Creating MissionShipComponent from list info"); } MissionShipComponentPlugin MissionShipComponentType = Instance.MissionShipComponentTypes[Subtype - Instance.VanillaMissionShipComponentMaxType]; InMissionShipComponent.SubType = Subtype; InMissionShipComponent.Name = MissionShipComponentType.Name; InMissionShipComponent.Desc = MissionShipComponentType.Description; InMissionShipComponent.GetType().GetField("m_IconTexture", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InMissionShipComponent, MissionShipComponentType.IconTexture); InMissionShipComponent.GetType().GetField("m_MarketPrice", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InMissionShipComponent, (ObscuredInt)MissionShipComponentType.MarketPrice); InMissionShipComponent.CargoVisualPrefabID = MissionShipComponentType.CargoVisualID; InMissionShipComponent.CanBeDroppedOnShipDeath = MissionShipComponentType.CanBeDroppedOnShipDeath; InMissionShipComponent.Experimental = MissionShipComponentType.Experimental; InMissionShipComponent.Unstable = MissionShipComponentType.Unstable; InMissionShipComponent.Contraband = MissionShipComponentType.Contraband; InMissionShipComponent.GetType().GetField("Price_LevelMultiplierExponent", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InMissionShipComponent, (ObscuredFloat)MissionShipComponentType.Price_LevelMultiplierExponent); } } else { InMissionShipComponent = new PLMissionShipComponent(Subtype, level); } return(InMissionShipComponent); }
public static PLVirus CreateVirus(int Subtype, int level) { PLVirus InVirus; if (Subtype >= Instance.VanillaVirusMaxType) { InVirus = new PLVirus(EVirusType.NONE, level); int subtypeformodded = Subtype - Instance.VanillaVirusMaxType; if (Global.DebugLogging) { Logger.Info($"Subtype for modded is {subtypeformodded}"); } if (subtypeformodded <= Instance.VirusTypes.Count && subtypeformodded > -1) { if (Global.DebugLogging) { Logger.Info("Creating Virus from list info"); } VirusPlugin VirusType = Instance.VirusTypes[Subtype - Instance.VanillaVirusMaxType]; InVirus.SubType = Subtype; InVirus.Name = VirusType.Name; InVirus.Desc = VirusType.Description; InVirus.GetType().GetField("m_IconTexture", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InVirus, VirusType.IconTexture); InVirus.GetType().GetField("m_MarketPrice", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InVirus, (ObscuredInt)VirusType.MarketPrice); InVirus.CargoVisualPrefabID = VirusType.CargoVisualID; InVirus.CanBeDroppedOnShipDeath = VirusType.CanBeDroppedOnShipDeath; InVirus.Experimental = VirusType.Experimental; InVirus.Unstable = VirusType.Unstable; InVirus.Contraband = VirusType.Contraband; InVirus.GetType().GetField("Price_LevelMultiplierExponent", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InVirus, (ObscuredFloat)VirusType.Price_LevelMultiplierExponent); } } else { InVirus = new PLVirus((EVirusType)Subtype, level); } return(InVirus); }
static bool Prefix(ref PhotonMessageInfo pmi) { //Utilities.Logger.Info("About to check if containskey. isMasterClient: " + PhotonNetwork.isMasterClient.ToString()); bool foundplayer = false; if (ModMessageHelper.Instance.GetPlayerMods(pmi.sender) != "NoPlayer") { //checks if server has received mod list from client. request for mod list is sent in the class 'PrefixServerOnClientJoin' foundplayer = true; } Utilities.Logger.Info("tried finding player, returned " + foundplayer.ToString()); //Checks mod list if (foundplayer) //If server received mod list from client { string missingmods = string.Empty; string LocalMods = MPModChecks.GetMPModList(); string clientmods = ModMessageHelper.Instance.GetPlayerMods(pmi.sender); Logger.Info($"Starting Serverside Mod check"); if (clientmods != LocalMods) //if the client's modlist isn't equal to the local mod list { Logger.Info($"Checking if client is missing required mods"); string[] localmodlist = LocalMods.Split('\n'); foreach (string plugin in localmodlist) //check local multiplayer mods to see if the client has required mods { if (!string.IsNullOrWhiteSpace(plugin) && !clientmods.Contains(plugin) && plugin.Contains("MPF3")) { missingmods += plugin; } } if (missingmods == string.Empty) //if nothing was added to the missing mod list check if the client needs something the server doesn't. { Logger.Info($"Client isn't missing mods, checking if client has mods that require server installation"); string[] clientmodlist = clientmods.Split('\n'); foreach (string plugin in clientmodlist) { if (!string.IsNullOrWhiteSpace(plugin) && !LocalMods.Contains(plugin) && (plugin.Contains("MPF2") || plugin.Contains("MPF3"))) { missingmods += plugin; } } if (missingmods != string.Empty) //Client has non-server mods { Logger.Info("Client has non-server multiplayer mods"); string message = $"You have been disconnected for having the following mods (try removing them):\n{missingmods}"; ModMessageHelper.Instance.photonView.RPC("RecieveErrorMessage", pmi.sender, new object[] { message }); if (SteamManager.Initialized && pmi.sender.SteamID != CSteamID.Nil) { SteamUser.EndAuthSession(pmi.sender.SteamID); } PhotonNetwork.CloseConnection(pmi.sender); return(false); } } else //client is missing server mods { Logger.Info("client is missing server mods"); string message = $"You have been disconnected for not having the following mods (try installing them):\n{missingmods}"; ModMessageHelper.Instance.photonView.RPC("RecieveErrorMessage", pmi.sender, new object[] { message }); if (SteamManager.Initialized && pmi.sender.SteamID != CSteamID.Nil) { SteamUser.EndAuthSession(pmi.sender.SteamID); } PhotonNetwork.CloseConnection(pmi.sender); return(false); } } Logger.Info("Modcheck passed, proceding ondwards"); } else //client wasn't found in mod list { if (ModMessageHelper.ServerHasMPMods) //small vulnerability: if a client with mods disables the pong message, they can still connect with their multiplayer mods { Utilities.Logger.Info("Didn't receive message or proper modlist. proceeding to kick PhotonPlayer"); string message = $"You have been disconnected for not having the mod loader installed"; ModMessageHelper.Instance.photonView.RPC("RecieveErrorMessage", pmi.sender, new object[] { message }); if (SteamManager.Initialized && pmi.sender.SteamID != CSteamID.Nil) { SteamUser.EndAuthSession(pmi.sender.SteamID); } PhotonNetwork.CloseConnection(pmi.sender); return(false); } Utilities.Logger.Info("Didn't receive message or proper modlist, but the server doesn't have multiplayer explicit mods. Proceeding onwards"); } return(true); }