Exemple #1
0
        static bool Prefix(int inSubType, int inLevel, ref PLShipComponent __result)
        {
            int subtypeformodded = inSubType - TurretPluginManager.Instance.VanillaTurretMaxType;

            if (subtypeformodded <= TurretPluginManager.Instance.TurretTypes.Count && subtypeformodded > -1)
            {
                Logger.Info("Creating Turret from list info");
                __result       = TurretPluginManager.Instance.TurretTypes[subtypeformodded].PLTurret;
                __result.Level = inLevel;
                return(false);
            }
            return(true);
        }
Exemple #2
0
        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);
        }
Exemple #6
0
        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 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 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);
        }
Exemple #9
0
        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);
        }
Exemple #10
0
        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);
        }
Exemple #12
0
        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);
        }