using UnityEngine.Scripting; [Preserve] public class NetPackageCheckSleeperVolumes : NetPackage { public NetPackageCheckSleeperVolumes Setup(int _entityPlayerID, int _maxSleeperVolumeCount) { this.entityPlayerID = _entityPlayerID; this.maxSleeperVolumeCount = _maxSleeperVolumeCount; return this; } public override void read(PooledBinaryReader _reader) { this.entityPlayerID = _reader.ReadInt32(); this.maxSleeperVolumeCount = _reader.ReadInt32(); } public override void write(PooledBinaryWriter _writer) { base.write(_writer); _writer.Write(this.entityPlayerID); _writer.Write(this.maxSleeperVolumeCount); } public override void ProcessPackage(World _world, GameManager _callbacks) { //Log.Out("NetPackageCheckSleeperVolumes-ProcessPackage START"); EntityPlayer player = _world.GetEntity(this.entityPlayerID) as EntityPlayer; if (player != null) { //Log.Out("NetPackageCheckSleeperVolumes-ProcessPackage PLAYER EXISTS"); int totalKills = RebirthManager.GetTotalKills(player.entityId); player.Buffs.SetCustomVar("$totalPurgeKills", totalKills); //Log.Out("NetPackageCheckSleeperVolumes-ProcessPackage totalKills: " + totalKills); //Log.Out("NetPackageCheckSleeperVolumes-ProcessPackage $purgeKills: " + player.Buffs.GetCustomVar("$purgeKills")); int numKills = RebirthManager.AutoRedeemKills(player.entityId); //Log.Out("NetPackageCheckSleeperVolumes-ProcessPackage numKills: " + numKills); if (numKills > 0) { player.Buffs.SetCustomVar("$purgeKills", player.Buffs.GetCustomVar("$purgeKills") + numKills); int numInterations = 0; //Log.Out("EntityPlayerLocalPatches-OnUpdateLive RebirthVariables.purgeAirDropNumKills: " + RebirthVariables.purgeAirDropNumKills); //Log.Out("EntityPlayerLocalPatches-OnUpdateLive RebirthVariables.purgeAirDropNumKillsIncrement: " + RebirthVariables.purgeAirDropNumKillsIncrement); //Log.Out("EntityPlayerLocalPatches-OnUpdateLive A $purgeKillsIncrement: " + __instance.Buffs.GetCustomVar("$purgeKillsIncrement")); //Log.Out("EntityPlayerLocalPatches-OnUpdateLive compared to: " + RebirthVariables.purgeAirDropNumKills + RebirthVariables.purgeAirDropNumKillsIncrement * (int)__instance.Buffs.GetCustomVar("$purgeKillsIncrement")); int purgeAirDropNumKills = RebirthVariables.purgeAirDropNumKills - (int)player.Buffs.GetCustomVar("$ModPurge") * 10; // Enter the while loop as long as the condition holds true while (player.Buffs.GetCustomVar("$purgeKills") >= (purgeAirDropNumKills + RebirthVariables.purgeAirDropNumKillsIncrement * (int)player.Buffs.GetCustomVar("$purgeKillsIncrement"))) { // Recalculate target kills for each iteration int numTargetKills = purgeAirDropNumKills + RebirthVariables.purgeAirDropNumKillsIncrement * (int)player.Buffs.GetCustomVar("$purgeKillsIncrement"); //Log.Out("EntityPlayerLocalPatches-OnUpdateLive numTargetKills: " + numTargetKills); numInterations++; //Log.Out("EntityPlayerLocalPatches-OnUpdateLive numInterations: " + numInterations); float purgeKillsIncrement = player.Buffs.GetCustomVar("$purgeKillsIncrement"); //Log.Out("EntityPlayerLocalPatches-OnUpdateLive purgeKillsIncrement: " + purgeKillsIncrement); // Reduce $purgeKills by the number of target kills player.Buffs.SetCustomVar("$purgeKills", player.Buffs.GetCustomVar("$purgeKills") - numTargetKills); //Log.Out("EntityPlayerLocalPatches-OnUpdateLive B $purgeKills: " + player.Buffs.GetCustomVar("$purgeKills")); // Check if the incremented kills are below the max and increase accordingly if ((RebirthVariables.purgeAirDropNumKillsIncrement * purgeKillsIncrement) < RebirthVariables.purgeAirDropNumKillsMax) { player.Buffs.SetCustomVar("$purgeKillsIncrement", purgeKillsIncrement + 1); } //Log.Out("EntityPlayerLocalPatches-OnUpdateLive B $purgeKillsIncrement: " + player.Buffs.GetCustomVar("$purgeKillsIncrement")); } if (numInterations > 0) { //Log.Out("EntityPlayerLocalPatches-OnUpdateLive numInterations: " + numInterations); player.Buffs.SetCustomVar("$numSupplyDrops", numInterations); } } PrefabInstance poiatPosition = RebirthUtilities.GetPrefabAtPosition(player.position); // player.world.GetPOIAtPosition(player.position, false); if (poiatPosition != null) { //Log.Out("NetPackageCheckSleeperVolumes-ProcessPackage POI EXISTS, prefabName: " + poiatPosition.prefab.PrefabName); //Log.Out("NetPackageCheckSleeperVolumes-ProcessPackage POI EXISTS, RebirthVariables.checkSleeperVolumes: " + RebirthVariables.checkSleeperVolumes); if (!RebirthVariables.checkSleeperVolumes) { GameManager.Instance.StartCoroutine(RebirthUtilities.checkSleeperVolumes(poiatPosition, player, this.maxSleeperVolumeCount, true)); } } else { //Log.Out("NetPackageCheckSleeperVolumes-ProcessPackage POI DOES NOT EXIST, TURN DISPLAY OFF"); SingletonMonoBehaviour.Instance.SendPackage(NetPackageManager.GetPackage().Setup(1, false), false, this.entityPlayerID); } } } public override int GetLength() { return 4; } private int entityPlayerID; private int maxSleeperVolumeCount; }