diff --git a/Source/AkiSupport/Airdrops/AirdropBox.cs b/Source/AkiSupport/Airdrops/AirdropBox.cs
index 51f56f61c..b39e3b5ad 100644
--- a/Source/AkiSupport/Airdrops/AirdropBox.cs
+++ b/Source/AkiSupport/Airdrops/AirdropBox.cs
@@ -2,16 +2,18 @@
using EFT.Airdrop;
using EFT.Interactive;
using EFT.SynchronizableObjects;
+using StayInTarkov.Coop.Matchmaker;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
+using UnityEngine.AI;
namespace StayInTarkov.AkiSupport.Airdrops
{
///
/// Created by: SPT-Aki team
- /// Link: https://dev.sp-tarkov.com/SPT-AKI/Modules/src/branch/master/project/Aki.Custom/Airdrops/AirdropBox.cs
+ /// Link: https://dev.sp-tarkov.com/SPT/Modules/src/branch/master/project/SPT.Custom/Airdrops/AirdropBox.cs
///
public class AirdropBox : MonoBehaviour
{
@@ -20,6 +22,8 @@ public class AirdropBox : MonoBehaviour
private readonly int CROSSFADE = Shader.PropertyToID("_Crossfade");
private readonly int COLLISION = Animator.StringToHash("collision");
+ private static int AirdropContainerCount = 0;
+
public LootableContainer Container { get; set; }
private float fallSpeed;
private AirdropSynchronizableObject boxSync;
@@ -44,12 +48,16 @@ private BetterSource AudioSource
}
}
+ public Vector3 ClientSyncPosition { get; internal set; }
+
public static async Task Init(float crateFallSpeed)
{
var instance = (await LoadCrate()).AddComponent();
instance.soundsDictionary = await LoadSounds();
instance.Container = instance.GetComponentInChildren();
+ instance.Container.Id = $"AirdropBox_{AirdropContainerCount}";
+ AirdropContainerCount++;
instance.boxSync = instance.GetComponent();
instance.boxLogic = new AirdropLogicClass();
@@ -121,6 +129,19 @@ public IEnumerator DropCrate(Vector3 position)
OpenParachute();
while (RaycastBoxDistance(LayerMaskClass.TerrainLowPoly, out _))
{
+ if (SITMatchmaking.IsClient)
+ {
+
+ if (transform.position.x != this.ClientSyncPosition.x)
+ transform.position = ClientSyncPosition;
+
+ // only do this if the box is higher than the client sync
+ if (transform.position.y > this.ClientSyncPosition.y)
+ transform.position = ClientSyncPosition;
+
+ if (transform.position.z != this.ClientSyncPosition.z)
+ transform.position = ClientSyncPosition;
+ }
transform.Translate(Vector3.down * (Time.deltaTime * fallSpeed));
transform.Rotate(Vector3.up, Time.deltaTime * 6f);
yield return null;
@@ -147,6 +168,15 @@ private void OnBoxLand(out float clipLength)
Falloff = (int)surfaceSet.LandingSoundBank.Rolloff,
Volume = surfaceSet.LandingSoundBank.BaseVolume
});
+
+ AddNavMeshObstacle();
+ }
+
+ private void AddNavMeshObstacle()
+ {
+ var navMeshObstacle = this.GetOrAddComponent();
+ navMeshObstacle.size = boxSync.CollisionCollider.bounds.size;
+ navMeshObstacle.carving = true;
}
private bool RaycastBoxDistance(LayerMask layerMask, out RaycastHit hitInfo)
diff --git a/Source/AkiSupport/Airdrops/Patches/AirdropFlarePatch.cs b/Source/AkiSupport/Airdrops/Patches/AirdropFlarePatch.cs
index e1c63b1b7..b0bed908d 100644
--- a/Source/AkiSupport/Airdrops/Patches/AirdropFlarePatch.cs
+++ b/Source/AkiSupport/Airdrops/Patches/AirdropFlarePatch.cs
@@ -20,18 +20,19 @@ public class AirdropFlarePatch : ModulePatch
protected override MethodBase GetTargetMethod()
{
- return ReflectionHelpers.GetMethodForType(typeof(FlareCartridge), nameof(FlareCartridge.Init), false, true);
+ return typeof(FlareCartridge).GetMethod(nameof(FlareCartridge.Init),
+ BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly);
}
[PatchPostfix]
- private static void PatchPostfix(FlareCartridgeSettings flareCartridgeSettings, IPlayer player, BulletClass flareCartridge, Weapon weapon)
+ private static void PatchPostfix(BulletClass flareCartridge)
{
var gameWorld = Singleton.Instance;
var points = LocationScene.GetAll().Any();
if (gameWorld != null && points && _usableFlares.Any(x => x == flareCartridge.Template._id))
{
- gameWorld.gameObject.AddComponent().isFlareDrop = true;
+ gameWorld.gameObject.AddComponent().IsFlareDrop = true;
}
}
}
diff --git a/Source/Coop/Airdrops/SITAirdropsManager.cs b/Source/Coop/Airdrops/SITAirdropsManager.cs
index 3ad144943..61816ab35 100644
--- a/Source/Coop/Airdrops/SITAirdropsManager.cs
+++ b/Source/Coop/Airdrops/SITAirdropsManager.cs
@@ -3,19 +3,16 @@
using BepInEx.Logging;
using Comfort.Common;
using EFT;
-using EFT.Game.Spawning;
-using EFT.Interactive;
using StayInTarkov;
using StayInTarkov.AkiSupport.Airdrops;
using StayInTarkov.AkiSupport.Airdrops.Models;
using StayInTarkov.AkiSupport.Airdrops.Utils;
using StayInTarkov.Coop.Components.CoopGameComponents;
using StayInTarkov.Coop.Matchmaker;
-using StayInTarkov.Coop.NetworkPacket;
-using StayInTarkov.Coop.Web;
+using StayInTarkov.Coop.NetworkPacket.Airdrop;
using StayInTarkov.Networking;
+using System;
using System.Collections;
-using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
@@ -29,16 +26,23 @@ namespace Aki.Custom.Airdrops
public class SITAirdropsManager : MonoBehaviour
{
private AirdropPlane airdropPlane;
- public AirdropBox AirdropBox { get; private set; }
private ItemFactoryUtil factory;
- public bool isFlareDrop;
+ private float distanceTravelled = 0;
+
+ private DateTime LastSyncTime { get; set; }
+ private ManualLogSource Logger { get; } = BepInEx.Logging.Logger.CreateLogSource(nameof(SITAirdropsManager));
+
+ public AirdropBox AirdropBox { get; private set; }
public AirdropParametersModel AirdropParameters { get; set; }
- private ManualLogSource Logger { get; set; }
+ public bool ClientPlaneSpawned { get; private set; }
+ public AirdropLootResultModel ClientAirdropLootResultModel { get; private set; }
+ public AirdropConfigModel ClientAirdropConfigModel { get; private set; }
+ public bool ClientLootBuilt { get; private set; }
+ public bool IsFlareDrop { get; set; }
void Awake()
{
- Logger = BepInEx.Logging.Logger.CreateLogSource("SITAirdropsManager");
Logger.LogInfo("Awake");
Singleton.Create(this);
}
@@ -68,7 +72,7 @@ public async void Start()
// The server will generate stuff ready for the packet
- AirdropParameters = await AirdropUtil.InitAirdropParams(gameWorld, isFlareDrop);
+ AirdropParameters = await AirdropUtil.InitAirdropParams(gameWorld, IsFlareDrop);
if (!AirdropParameters.AirdropAvailable)
{
@@ -102,7 +106,6 @@ public async void Start()
await BuildLootContainer(AirdropParameters.Config);
StartCoroutine(SendParamsToClients());
-
}
public IEnumerator SendParamsToClients()
@@ -113,11 +116,11 @@ public IEnumerator SendParamsToClients()
yield return new WaitForSeconds(AirdropParameters.TimeToStart);
Logger.LogDebug("Sending Airdrop Params");
- var packet = new Dictionary();
- packet.Add("serverId", SITGameComponent.GetServerId());
- packet.Add("m", "AirdropPacket");
- packet.Add("model", AirdropParameters);
- GameClient.SendData(packet.SITToJson());
+ AirdropPacket airdropPacket = new()
+ {
+ AirdropParametersModelJson = AirdropParameters.SITToJson()
+ };
+ GameClient.SendData(airdropPacket.Serialize());
yield break;
}
@@ -148,16 +151,11 @@ public async void FixedUpdate()
factory.BuildContainer(AirdropBox.Container, ClientAirdropConfigModel, ClientAirdropLootResultModel.DropType);
factory.AddLoot(AirdropBox.Container, ClientAirdropLootResultModel);
- if (AirdropBox.Container != null)
+
+ if (AirdropBox.Container != null && SITGameComponent.TryGetCoopGameComponent(out SITGameComponent coopGameComponent))
{
- if (SITGameComponent.TryGetCoopGameComponent(out var coopGameComponent))
- {
- List oldInteractiveObjectList = new List(coopGameComponent.ListOfInteractiveObjects)
- {
- AirdropBox.Container
- };
- coopGameComponent.ListOfInteractiveObjects = [.. oldInteractiveObjectList];
- }
+ Logger.LogDebug($"Adding Airdrop box with id {AirdropBox.Container.Id}");
+ coopGameComponent.WorldnteractiveObjects.TryAdd(AirdropBox.Container.Id, AirdropBox.Container);
}
}
@@ -198,6 +196,20 @@ public async void FixedUpdate()
StartBox();
}
+ if (AirdropParameters.BoxSpawned && !SITMatchmaking.IsClient)
+ {
+ if (this.LastSyncTime < DateTime.Now.AddSeconds(-1))
+ {
+ this.LastSyncTime = DateTime.Now;
+
+ AirdropBoxPositionSyncPacket packet = new()
+ {
+ Position = AirdropBox.transform.position
+ };
+ GameClient.SendData(packet.Serialize());
+ }
+ }
+
if (distanceTravelled < AirdropParameters.DistanceToTravel)
{
distanceTravelled += Time.deltaTime * AirdropParameters.Config.PlaneSpeed;
@@ -211,8 +223,6 @@ public async void FixedUpdate()
}
}
- float distanceTravelled = 0;
-
private void StartPlane()
{
airdropPlane.gameObject.SetActive(true);
@@ -228,50 +238,36 @@ private void StartBox()
AirdropBox.StartCoroutine(AirdropBox.DropCrate(dropPos));
}
- public bool ClientPlaneSpawned { get; private set; }
- public AirdropLootResultModel ClientAirdropLootResultModel { get; private set; }
- public AirdropConfigModel ClientAirdropConfigModel { get; private set; }
- public bool ClientLootBuilt { get; private set; }
-
private async Task BuildLootContainer(AirdropConfigModel config)
{
- if (SITMatchmaking.IsClient)
+ if (!SITMatchmaking.IsServer)
return;
- var lootData = await factory.GetLoot();
+ // Get the lootData for this Raid
+ AirdropLootResultModel lootData = await factory.GetLoot() ?? throw new Exception("Airdrops. Tried to BuildLootContainer without any Loot.");
- // Get the lootData. Sent to Clients.
- if (SITMatchmaking.IsServer)
+ // Send the lootData to Clients.
+ AirdropLootPacket airdropLootPacket = new()
{
- var packet = new Dictionary();
- packet.Add("serverId", SITGameComponent.GetServerId());
- packet.Add("m", "AirdropLootPacket");
- packet.Add("config", config);
- packet.Add("result", lootData);
- GameClient.SendData(packet.SITToJson());
- }
+ AirdropLootResultModelJson = lootData.SITToJson(),
+ AirdropConfigModelJson = config.SITToJson()
+ };
+ GameClient.SendData(airdropLootPacket.Serialize());
- if (lootData == null)
- throw new System.Exception("Airdrops. Tried to BuildLootContainer without any Loot.");
-
factory.BuildContainer(AirdropBox.Container, config, lootData.DropType);
factory.AddLoot(AirdropBox.Container, lootData);
ClientLootBuilt = true;
- if (AirdropBox.Container != null)
+
+ if (AirdropBox.Container != null && SITGameComponent.TryGetCoopGameComponent(out SITGameComponent coopGameComponent))
{
- if (SITGameComponent.TryGetCoopGameComponent(out var coopGameComponent))
- {
- List oldInteractiveObjectList = new List(coopGameComponent.ListOfInteractiveObjects)
- {
- AirdropBox.Container
- };
- coopGameComponent.ListOfInteractiveObjects = [.. oldInteractiveObjectList];
- }
+ Logger.LogDebug($"Adding Airdrop box with id {AirdropBox.Container.Id}");
+ coopGameComponent.WorldnteractiveObjects.TryAdd(AirdropBox.Container.Id, AirdropBox.Container);
}
}
public void ReceiveBuildLootContainer(AirdropLootResultModel lootData, AirdropConfigModel config)
{
+ Logger.LogDebug(nameof(ReceiveBuildLootContainer));
ClientAirdropConfigModel = config;
ClientAirdropLootResultModel = lootData;
}
@@ -282,5 +278,11 @@ private void SetDistanceToDrop()
new Vector3(AirdropParameters.RandomAirdropPoint.x, AirdropParameters.DropHeight, AirdropParameters.RandomAirdropPoint.z),
airdropPlane.transform.position);
}
+
+ protected void OnDestroy()
+ {
+ if (Singleton.Instantiated)
+ Singleton.Release(Singleton.Instance);
+ }
}
}
\ No newline at end of file
diff --git a/Source/Coop/Components/CoopGameComponents/SITGameComponent.cs b/Source/Coop/Components/CoopGameComponents/SITGameComponent.cs
index a1aced0d0..866b3fd07 100644
--- a/Source/Coop/Components/CoopGameComponents/SITGameComponent.cs
+++ b/Source/Coop/Components/CoopGameComponents/SITGameComponent.cs
@@ -41,7 +41,7 @@ namespace StayInTarkov.Coop.Components.CoopGameComponents
public class SITGameComponent : MonoBehaviour
{
#region Fields/Properties
- public WorldInteractiveObject[] ListOfInteractiveObjects { get; set; }
+ public ConcurrentDictionary WorldnteractiveObjects { get; set; } = [];
private AkiBackendCommunication RequestingObj { get; set; }
public SITConfig SITConfig { get; private set; } = new SITConfig();
public string ServerId { get; set; } = null;
@@ -379,7 +379,10 @@ private void GameWorld_AfterGameStarted()
}
// Get a List of Interactive Objects (this is a slow method), so run once here to maintain a reference
- ListOfInteractiveObjects = FindObjectsOfType();
+ foreach (WorldInteractiveObject worldInteractiveObject in FindObjectsOfType())
+ {
+ this.WorldnteractiveObjects.TryAdd(worldInteractiveObject.Id, worldInteractiveObject);
+ }
}
diff --git a/Source/Coop/Controllers/HandControllers/SITFirearmController.cs b/Source/Coop/Controllers/HandControllers/SITFirearmController.cs
index 63f1c56ba..4a95d7061 100644
--- a/Source/Coop/Controllers/HandControllers/SITFirearmController.cs
+++ b/Source/Coop/Controllers/HandControllers/SITFirearmController.cs
@@ -335,11 +335,11 @@ public override bool ToggleLauncher()
public override void CreateFlareShot(BulletClass flareItem, Vector3 shotPosition, Vector3 forward)
{
+ Logger.LogDebug(nameof(CreateFlareShot));
var createFlareShotPacket = new CreateFlareShotPacket(_player.ProfileId, shotPosition, forward, flareItem.TemplateId);
GameClient.SendData(createFlareShotPacket.Serialize());
base.CreateFlareShot(flareItem, shotPosition, forward);
}
-
}
}
diff --git a/Source/Coop/NetworkPacket/Airdrop/AirdropBoxPositionSyncPacket.cs b/Source/Coop/NetworkPacket/Airdrop/AirdropBoxPositionSyncPacket.cs
new file mode 100644
index 000000000..956d4b87d
--- /dev/null
+++ b/Source/Coop/NetworkPacket/Airdrop/AirdropBoxPositionSyncPacket.cs
@@ -0,0 +1,60 @@
+using Aki.Custom.Airdrops;
+using BepInEx.Logging;
+using Comfort.Common;
+using StayInTarkov.Coop.Matchmaker;
+using System.IO;
+using UnityEngine;
+using static StayInTarkov.Networking.SITSerialization;
+
+namespace StayInTarkov.Coop.NetworkPacket.Airdrop
+{
+ public sealed class AirdropBoxPositionSyncPacket : BasePacket
+ {
+ static AirdropBoxPositionSyncPacket()
+ {
+ Logger = BepInEx.Logging.Logger.CreateLogSource(nameof(AirdropPacket));
+ }
+
+ public AirdropBoxPositionSyncPacket() : base(nameof(AirdropBoxPositionSyncPacket))
+ {
+ }
+
+ public Vector3 Position { get; set; }
+ public static ManualLogSource Logger { get; }
+
+ public override byte[] Serialize()
+ {
+ var ms = new MemoryStream();
+ using BinaryWriter writer = new(ms);
+ WriteHeader(writer);
+ Vector3Utils.Serialize(writer, this.Position);
+ return ms.ToArray();
+ }
+
+ public override ISITPacket Deserialize(byte[] bytes)
+ {
+ using BinaryReader reader = new(new MemoryStream(bytes));
+ ReadHeader(reader);
+ Position = Vector3Utils.Deserialize(reader);
+ return this;
+ }
+
+ public override void Process()
+ {
+ if (!SITMatchmaking.IsClient)
+ return;
+
+ if (!Singleton.Instantiated)
+ {
+ Logger.LogError($"{nameof(SITAirdropsManager)} has not been instantiated!");
+ return;
+ }
+
+
+ //Logger.LogDebug($"{nameof(Process)}");
+
+ Singleton.Instance.AirdropBox.ClientSyncPosition = Position;
+ }
+
+ }
+}
diff --git a/Source/Coop/NetworkPacket/Airdrop/AirdropLootPacket.cs b/Source/Coop/NetworkPacket/Airdrop/AirdropLootPacket.cs
index 8c285cd90..3af47fc16 100644
--- a/Source/Coop/NetworkPacket/Airdrop/AirdropLootPacket.cs
+++ b/Source/Coop/NetworkPacket/Airdrop/AirdropLootPacket.cs
@@ -1,33 +1,41 @@
-using Aki.Custom.Airdrops.Models;
-using StayInTarkov.AkiSupport.Airdrops.Models;
-using System;
-using System.Collections.Generic;
+using Aki.Custom.Airdrops;
+using Aki.Custom.Airdrops.Models;
+using BepInEx.Logging;
+using Comfort.Common;
+using StayInTarkov.Coop.Matchmaker;
+using System.Collections;
using System.IO;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+using UnityEngine;
namespace StayInTarkov.Coop.NetworkPacket.Airdrop
{
public sealed class AirdropLootPacket : BasePacket
{
+
+ static AirdropLootPacket()
+ {
+ Logger = BepInEx.Logging.Logger.CreateLogSource(nameof(AirdropLootPacket));
+ }
+
+ private static ManualLogSource Logger { get; set; }
+
public string AirdropLootResultModelJson { get; set; }
public string AirdropConfigModelJson { get; set; }
- public AirdropLootPacket(AirdropLootResultModel airdropLootResultModel, AirdropConfigModel airdropConfigModel) : base("AirdropLootPacket")
+ public AirdropLootPacket(AirdropLootResultModel airdropLootResultModel, AirdropConfigModel airdropConfigModel) : base(nameof(AirdropLootPacket))
{
AirdropLootResultModelJson = airdropLootResultModel.SITToJson();
AirdropConfigModelJson = airdropConfigModel.SITToJson();
}
- public AirdropLootPacket() : base("AirdropLootPacket")
+ public AirdropLootPacket() : base(nameof(AirdropLootPacket))
{
}
public override byte[] Serialize()
{
var ms = new MemoryStream();
- using BinaryWriter writer = new BinaryWriter(ms);
+ using BinaryWriter writer = new(ms);
WriteHeader(writer);
writer.Write(AirdropLootResultModelJson);
writer.Write(AirdropConfigModelJson);
@@ -36,11 +44,54 @@ public override byte[] Serialize()
public override ISITPacket Deserialize(byte[] bytes)
{
- using BinaryReader reader = new BinaryReader(new MemoryStream(bytes));
+ using BinaryReader reader = new(new MemoryStream(bytes));
ReadHeader(reader);
AirdropLootResultModelJson = reader.ReadString();
AirdropConfigModelJson = reader.ReadString();
return this;
}
+
+ public override void Process()
+ {
+ if (!SITMatchmaking.IsClient)
+ return;
+
+ if (!Singleton.Instantiated)
+ {
+ Logger.LogDebug($"{nameof(SITAirdropsManager)} has not been instantiated! Waiting...");
+ StayInTarkovPlugin.Instance.StartCoroutine(AirdropLootPacketWaitAndProcess());
+ return;
+ }
+
+
+ if (!this.AirdropLootResultModelJson.TrySITParseJson(out var airdropLootResultModel))
+ {
+ Logger.LogError($"{nameof(AirdropLootResultModel)} failed to deserialize!");
+ return;
+ }
+
+ if (!this.AirdropConfigModelJson.TrySITParseJson(out var airdropConfigModel))
+ {
+ Logger.LogError($"{nameof(AirdropConfigModel)} failed to deserialize!");
+ return;
+ }
+
+
+ Singleton.Instance.ReceiveBuildLootContainer(
+ airdropLootResultModel,
+ airdropConfigModel
+ );
+
+
+ }
+
+ private IEnumerator AirdropLootPacketWaitAndProcess()
+ {
+ var waitForSec = new WaitForSeconds(5);
+ while (!Singleton.Instantiated)
+ yield return waitForSec;
+
+ Process();
+ }
}
}
diff --git a/Source/Coop/NetworkPacket/Airdrop/AirdropPacket.cs b/Source/Coop/NetworkPacket/Airdrop/AirdropPacket.cs
index 2055e6796..3b360eb03 100644
--- a/Source/Coop/NetworkPacket/Airdrop/AirdropPacket.cs
+++ b/Source/Coop/NetworkPacket/Airdrop/AirdropPacket.cs
@@ -1,30 +1,36 @@
-using StayInTarkov.AkiSupport.Airdrops.Models;
-using System;
-using System.Collections.Generic;
+using Aki.Custom.Airdrops;
+using BepInEx.Logging;
+using Comfort.Common;
+using StayInTarkov.AkiSupport.Airdrops.Models;
+using StayInTarkov.Coop.Matchmaker;
using System.IO;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace StayInTarkov.Coop.NetworkPacket.Airdrop
{
public sealed class AirdropPacket : BasePacket
{
+ static AirdropPacket()
+ {
+ Logger = BepInEx.Logging.Logger.CreateLogSource(nameof(AirdropPacket));
+ }
+
+ private static ManualLogSource Logger;
+
public string AirdropParametersModelJson { get; set; }
- public AirdropPacket(AirdropParametersModel airdropParametersModel) : base("AirdropPacket")
+ public AirdropPacket(AirdropParametersModel airdropParametersModel) : base(nameof(AirdropPacket))
{
AirdropParametersModelJson = airdropParametersModel.SITToJson();
}
- public AirdropPacket() : base("AirdropPacket")
+ public AirdropPacket() : base(nameof(AirdropPacket))
{
}
public override byte[] Serialize()
{
var ms = new MemoryStream();
- using BinaryWriter writer = new BinaryWriter(ms);
+ using BinaryWriter writer = new(ms);
WriteHeader(writer);
writer.Write(AirdropParametersModelJson);
return ms.ToArray();
@@ -32,10 +38,30 @@ public override byte[] Serialize()
public override ISITPacket Deserialize(byte[] bytes)
{
- using BinaryReader reader = new BinaryReader(new MemoryStream(bytes));
+ using BinaryReader reader = new(new MemoryStream(bytes));
ReadHeader(reader);
AirdropParametersModelJson = reader.ReadString();
return this;
}
+
+ public override void Process()
+ {
+ if (!SITMatchmaking.IsClient)
+ return;
+
+ if (!Singleton.Instantiated)
+ {
+ Logger.LogError($"{nameof(SITAirdropsManager)} has not been instantiated!");
+ return;
+ }
+
+ Singleton.Instance.AirdropParameters = this.AirdropParametersModelJson.SITParseJson();
+
+#if DEBUG
+ Logger.LogDebug($"{nameof(SITAirdropsManager)}{nameof(Singleton.Instance.AirdropParameters)}");
+ Logger.LogDebug($"{Singleton.Instance.AirdropParameters.SITToJson()}");
+#endif
+
+ }
}
}
diff --git a/Source/Coop/NetworkPacket/Player/PlayerInteractWithDoorPacket.cs b/Source/Coop/NetworkPacket/Player/PlayerInteractWithDoorPacket.cs
index cf6047327..d2e6558b7 100644
--- a/Source/Coop/NetworkPacket/Player/PlayerInteractWithDoorPacket.cs
+++ b/Source/Coop/NetworkPacket/Player/PlayerInteractWithDoorPacket.cs
@@ -1,16 +1,11 @@
-using Comfort.Common;
-using EFT;
+using EFT;
using EFT.Interactive;
using EFT.InventoryLogic;
using Newtonsoft.Json.Linq;
using StayInTarkov.Coop.Components.CoopGameComponents;
using StayInTarkov.Coop.Players;
-using System;
-using System.Collections.Generic;
using System.IO;
-using System.Linq;
using System.Text;
-using System.Threading.Tasks;
namespace StayInTarkov.Coop.NetworkPacket.Player
{
@@ -95,9 +90,7 @@ protected override void Process(CoopPlayerClient client)
}
}
-
- WorldInteractiveObject worldInteractiveObject = SITGameComponent.GetCoopGameComponent().ListOfInteractiveObjects.FirstOrDefault(x => x.Id == ProcessJson["WIOId"].ToString());
- if (worldInteractiveObject == null)
+ if (!SITGameComponent.GetCoopGameComponent().WorldnteractiveObjects.TryGetValue(ProcessJson["WIOId"].ToString(), out WorldInteractiveObject worldInteractiveObject))
{
StayInTarkovHelperConstants.Logger.LogError($"Player_ExecuteDoorInteraction_Patch:Replicated:Could not find {nameof(worldInteractiveObject)}");
return;
diff --git a/Source/Coop/NetworkPacket/Player/PlayerInteractWithObjectPacket.cs b/Source/Coop/NetworkPacket/Player/PlayerInteractWithObjectPacket.cs
index 19829de89..07ae22935 100644
--- a/Source/Coop/NetworkPacket/Player/PlayerInteractWithObjectPacket.cs
+++ b/Source/Coop/NetworkPacket/Player/PlayerInteractWithObjectPacket.cs
@@ -5,7 +5,6 @@
using StayInTarkov.Coop.Components.CoopGameComponents;
using StayInTarkov.Coop.Players;
using System.IO;
-using System.Linq;
using System.Text;
namespace StayInTarkov.Coop.NetworkPacket.Player
@@ -56,9 +55,7 @@ protected override void Process(CoopPlayerClient client)
return;
}
- WorldInteractiveObject worldInteractiveObject = SITGameComponent.GetCoopGameComponent().ListOfInteractiveObjects.FirstOrDefault(x => x.Id == ProcessJson["WIOId"].ToString());
-
- if (worldInteractiveObject == null)
+ if (!SITGameComponent.GetCoopGameComponent().WorldnteractiveObjects.TryGetValue(ProcessJson["WIOId"].ToString(), out WorldInteractiveObject worldInteractiveObject))
{
StayInTarkovHelperConstants.Logger.LogError($"Player_ExecuteDoorInteraction_Patch:Replicated:Could not find {nameof(worldInteractiveObject)}");
return;
diff --git a/Source/Coop/NetworkPacket/Raid/LootableContainerInteractionPacket.cs b/Source/Coop/NetworkPacket/Raid/LootableContainerInteractionPacket.cs
index 1eae6bc1e..273baf1f2 100644
--- a/Source/Coop/NetworkPacket/Raid/LootableContainerInteractionPacket.cs
+++ b/Source/Coop/NetworkPacket/Raid/LootableContainerInteractionPacket.cs
@@ -43,10 +43,12 @@ public override ISITPacket Deserialize(byte[] bytes)
public override void Process()
{
SITGameComponent coopGameComponent = SITGameComponent.GetCoopGameComponent();
- LootableContainer lootableContainer = coopGameComponent.ListOfInteractiveObjects.FirstOrDefault(x => x.Id == this.LootableContainerId) as LootableContainer;
-
- if (lootableContainer == null)
+ if (!coopGameComponent.WorldnteractiveObjects.TryGetValue(LootableContainerId, out WorldInteractiveObject worldInteractiveObject))
+ {
+ StayInTarkovHelperConstants.Logger.LogError($"LootableContainerInteractionPacket:Process:Could not find {nameof(worldInteractiveObject)}");
return;
+ }
+ LootableContainer lootableContainer = worldInteractiveObject as LootableContainer;
string methodName = string.Empty;
switch (InteractionType)
diff --git a/Source/Coop/NetworkPacket/Raid/TimeAndWeatherPacket.cs b/Source/Coop/NetworkPacket/Raid/TimeAndWeatherPacket.cs
index 3358f6890..f9cb3d962 100644
--- a/Source/Coop/NetworkPacket/Raid/TimeAndWeatherPacket.cs
+++ b/Source/Coop/NetworkPacket/Raid/TimeAndWeatherPacket.cs
@@ -2,12 +2,10 @@
using StayInTarkov.Coop.Matchmaker;
using StayInTarkov.Coop.SITGameModes;
using StayInTarkov.Networking;
-using System.Collections.Generic;
using System;
using System.IO;
using System.Linq;
using UnityEngine;
-using EFT;
namespace StayInTarkov.Coop.NetworkPacket.Raid
{
@@ -29,7 +27,7 @@ public TimeAndWeatherPacket() : base(nameof(TimeAndWeatherPacket))
public override byte[] Serialize()
{
var ms = new MemoryStream();
- using BinaryWriter writer = new BinaryWriter(ms);
+ using BinaryWriter writer = new(ms);
WriteHeader(writer);
//writer.Write(GameDateTime);
writer.Write(CloudDensity);
@@ -45,7 +43,7 @@ public override byte[] Serialize()
public override ISITPacket Deserialize(byte[] bytes)
{
- using BinaryReader reader = new BinaryReader(new MemoryStream(bytes));
+ using BinaryReader reader = new(new MemoryStream(bytes));
ReadHeader(reader);
//GameDateTime = reader.ReadSingle();
CloudDensity = reader.ReadSingle();
@@ -72,10 +70,10 @@ void ReplicateTimeAndWeather()
if (!SITMatchmaking.IsClient)
return;
-#if DEBUG
- StayInTarkov.StayInTarkovHelperConstants.Logger.LogDebug($"{nameof(ReplicateTimeAndWeather)}");
+ //#if DEBUG
+ // StayInTarkov.StayInTarkovHelperConstants.Logger.LogDebug($"{nameof(ReplicateTimeAndWeather)}");
-#endif
+ //#endif
var gameDateTime = new DateTime(long.Parse(GameDateTime.ToString()));
if (coopGameComponent.LocalGameInstance is CoopSITGame coopGame && coopGame.GameDateTime != null)
diff --git a/Source/Coop/NetworkPacket/World/UpdateExfiltrationPointPacket.cs b/Source/Coop/NetworkPacket/World/UpdateExfiltrationPointPacket.cs
index 630620e81..48f03e647 100644
--- a/Source/Coop/NetworkPacket/World/UpdateExfiltrationPointPacket.cs
+++ b/Source/Coop/NetworkPacket/World/UpdateExfiltrationPointPacket.cs
@@ -13,12 +13,12 @@ public sealed class UpdateExfiltrationPointPacket : BasePacket
public EFT.Interactive.EExfiltrationStatus Command;
public List QueuedPlayers;
- public UpdateExfiltrationPointPacket() : base(nameof(UpdateExfiltrationPointPacket)) {}
+ public UpdateExfiltrationPointPacket() : base(nameof(UpdateExfiltrationPointPacket)) { }
public override byte[] Serialize()
{
var ms = new MemoryStream();
- using BinaryWriter writer = new BinaryWriter(ms);
+ using BinaryWriter writer = new(ms);
WriteHeader(writer);
writer.Write(PointName);
writer.Write((byte)Command);
@@ -32,7 +32,7 @@ public override byte[] Serialize()
public override ISITPacket Deserialize(byte[] bytes)
{
- using BinaryReader reader = new BinaryReader(new MemoryStream(bytes));
+ using BinaryReader reader = new(new MemoryStream(bytes));
ReadHeader(reader);
PointName = reader.ReadString();
Command = (EFT.Interactive.EExfiltrationStatus)reader.ReadByte();
@@ -46,7 +46,13 @@ public override ISITPacket Deserialize(byte[] bytes)
}
public override void Process()
{
- var point = ExfiltrationControllerClass.Instance.ExfiltrationPoints.First(x => x.Settings.Name == PointName);
+ if (ExfiltrationControllerClass.Instance == null)
+ return;
+
+ if (ExfiltrationControllerClass.Instance.ExfiltrationPoints == null)
+ return;
+
+ var point = ExfiltrationControllerClass.Instance.ExfiltrationPoints.FirstOrDefault(x => x.Settings != null && x.Settings.Name == PointName);
if (point == null)
{
return;
diff --git a/Source/Coop/SITGameModes/CoopSITGame.cs b/Source/Coop/SITGameModes/CoopSITGame.cs
index cba429fd3..a19de8a54 100644
--- a/Source/Coop/SITGameModes/CoopSITGame.cs
+++ b/Source/Coop/SITGameModes/CoopSITGame.cs
@@ -30,7 +30,6 @@
using StayInTarkov.Coop.Components.CoopGameComponents;
using StayInTarkov.Coop.FreeCamera;
using StayInTarkov.Coop.Matchmaker;
-using StayInTarkov.Coop.NetworkPacket.Player;
using StayInTarkov.Coop.NetworkPacket.Raid;
using StayInTarkov.Coop.NetworkPacket.World;
using StayInTarkov.Coop.Players;
@@ -41,7 +40,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
-using System.Security.Permissions;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;