diff --git a/.gitmodules b/.gitmodules
deleted file mode 100644
index a647a612..00000000
--- a/.gitmodules
+++ /dev/null
@@ -1,3 +0,0 @@
-[submodule "References"]
- path = References
- url = https://github.com/project-fika/References.git
diff --git a/Fika.Core/AkiSupport/Airdrops/Models/FikaAirdropConfigModel.cs b/Fika.Core/AkiSupport/Airdrops/Models/FikaAirdropConfigModel.cs
index 44eb19b4..8043069c 100644
--- a/Fika.Core/AkiSupport/Airdrops/Models/FikaAirdropConfigModel.cs
+++ b/Fika.Core/AkiSupport/Airdrops/Models/FikaAirdropConfigModel.cs
@@ -1,7 +1,7 @@
using Newtonsoft.Json;
using System.Collections.Generic;
-namespace Aki.Custom.Airdrops.Models
+namespace SPT.Custom.Airdrops.Models
{
///
/// Created by: SPT-Aki team
diff --git a/Fika.Core/AkiSupport/Airdrops/Models/FikaAirdropLootModel.cs b/Fika.Core/AkiSupport/Airdrops/Models/FikaAirdropLootModel.cs
index b089f877..2d4c40ca 100644
--- a/Fika.Core/AkiSupport/Airdrops/Models/FikaAirdropLootModel.cs
+++ b/Fika.Core/AkiSupport/Airdrops/Models/FikaAirdropLootModel.cs
@@ -1,7 +1,7 @@
using Newtonsoft.Json;
using System.Collections.Generic;
-namespace Aki.Custom.Airdrops.Models
+namespace SPT.Custom.Airdrops.Models
{
///
/// Created by: SPT-Aki team
diff --git a/Fika.Core/AkiSupport/Airdrops/Models/FikaAirdropParametersModel.cs b/Fika.Core/AkiSupport/Airdrops/Models/FikaAirdropParametersModel.cs
index dd3f8ba6..6a63b241 100644
--- a/Fika.Core/AkiSupport/Airdrops/Models/FikaAirdropParametersModel.cs
+++ b/Fika.Core/AkiSupport/Airdrops/Models/FikaAirdropParametersModel.cs
@@ -1,5 +1,5 @@
-using Aki.Custom.Airdrops.Models;
-using Newtonsoft.Json;
+using Newtonsoft.Json;
+using SPT.Custom.Airdrops.Models;
using UnityEngine;
namespace Fika.Core.AkiSupport.Airdrops.Models
diff --git a/Fika.Core/AkiSupport/Airdrops/Patches/FikaAirdropFlare_Patch.cs b/Fika.Core/AkiSupport/Airdrops/Patches/FikaAirdropFlare_Patch.cs
index 854e0f89..301ccdff 100644
--- a/Fika.Core/AkiSupport/Airdrops/Patches/FikaAirdropFlare_Patch.cs
+++ b/Fika.Core/AkiSupport/Airdrops/Patches/FikaAirdropFlare_Patch.cs
@@ -1,7 +1,7 @@
-using Aki.Reflection.Patching;
-using Comfort.Common;
+using Comfort.Common;
using EFT;
using EFT.Airdrop;
+using SPT.Reflection.Patching;
using System.Linq;
using System.Reflection;
diff --git a/Fika.Core/AkiSupport/Airdrops/Utils/FikaAirdropUtil.cs b/Fika.Core/AkiSupport/Airdrops/Utils/FikaAirdropUtil.cs
index 2ddf970b..78d9c6dd 100644
--- a/Fika.Core/AkiSupport/Airdrops/Utils/FikaAirdropUtil.cs
+++ b/Fika.Core/AkiSupport/Airdrops/Utils/FikaAirdropUtil.cs
@@ -1,9 +1,9 @@
-using Aki.Common.Http;
-using Aki.Custom.Airdrops.Models;
-using EFT;
+using EFT;
using EFT.Airdrop;
using Fika.Core.AkiSupport.Airdrops.Models;
using Newtonsoft.Json;
+using SPT.Common.Http;
+using SPT.Custom.Airdrops.Models;
using System;
using System.Collections.Generic;
using System.Linq;
diff --git a/Fika.Core/AkiSupport/Airdrops/Utils/FikaItemFactoryUtil.cs b/Fika.Core/AkiSupport/Airdrops/Utils/FikaItemFactoryUtil.cs
index ad94d25e..847431b0 100644
--- a/Fika.Core/AkiSupport/Airdrops/Utils/FikaItemFactoryUtil.cs
+++ b/Fika.Core/AkiSupport/Airdrops/Utils/FikaItemFactoryUtil.cs
@@ -1,12 +1,12 @@
-using Aki.Common.Http;
-using Aki.Custom.Airdrops.Models;
-using BepInEx.Logging;
+using BepInEx.Logging;
using Comfort.Common;
using EFT;
using EFT.Interactive;
using EFT.InventoryLogic;
using Fika.Core;
using Newtonsoft.Json;
+using SPT.Common.Http;
+using SPT.Custom.Airdrops.Models;
using System.Linq;
namespace Aki.Custom.Airdrops.Utils
@@ -28,7 +28,7 @@ public void BuildContainer(LootableContainer container, FikaAirdropConfigModel c
if (itemFactory.ItemTemplates.TryGetValue(containerId, out ItemTemplate template))
{
Item item = itemFactory.CreateItem(containerId, template._id, null);
- item.Id = Singleton.Instance.MainPlayer.GClass2761_0.NextId;
+ item.Id = Singleton.Instance.MainPlayer.GClass2774_0.NextId;
LootItem.CreateLootContainer(container, item, "CRATE", Singleton.Instance);
}
else
diff --git a/Fika.Core/AkiSupport/Overrides/AddEnemyToAllGroupsInBotZonePatch_Override.cs b/Fika.Core/AkiSupport/Overrides/AddEnemyToAllGroupsInBotZonePatch_Override.cs
index e8e229b8..9cb97666 100644
--- a/Fika.Core/AkiSupport/Overrides/AddEnemyToAllGroupsInBotZonePatch_Override.cs
+++ b/Fika.Core/AkiSupport/Overrides/AddEnemyToAllGroupsInBotZonePatch_Override.cs
@@ -1,7 +1,7 @@
-using Aki.Reflection.Patching;
-using EFT;
+using EFT;
using Fika.Core.Coop.Players;
using HarmonyLib;
+using SPT.Reflection.Patching;
using System.Collections.Generic;
using System.Reflection;
@@ -43,7 +43,7 @@ private static bool PatchPrefix(BotsController __instance, IPlayer aggressor, IP
}
BotZone botZone = groupOwner.AIData.BotOwner.BotsGroup.BotZone;
- foreach (KeyValuePair item in __instance.Groups())
+ foreach (KeyValuePair item in __instance.Groups())
{
if (item.Key != botZone)
{
diff --git a/Fika.Core/AkiSupport/Overrides/BotDifficultyPatch_Override.cs b/Fika.Core/AkiSupport/Overrides/BotDifficultyPatch_Override.cs
index d75a8300..781de494 100644
--- a/Fika.Core/AkiSupport/Overrides/BotDifficultyPatch_Override.cs
+++ b/Fika.Core/AkiSupport/Overrides/BotDifficultyPatch_Override.cs
@@ -1,7 +1,7 @@
-using Aki.Common.Http;
-using Aki.Reflection.Patching;
-using EFT;
+using EFT;
using Fika.Core.Coop.Matchmaker;
+using SPT.Common.Http;
+using SPT.Reflection.Patching;
using System.Reflection;
namespace Fika.Core.AkiSupport.Overrides
@@ -10,7 +10,7 @@ public class BotDifficultyPatch_Override : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
- return typeof(GClass532).GetMethod(nameof(GClass532.LoadDifficultyStringInternal));
+ return typeof(GClass531).GetMethod(nameof(GClass531.LoadDifficultyStringInternal));
}
[PatchPrefix]
diff --git a/Fika.Core/AkiSupport/Overrides/BotTemplateLimitPatch_Override.cs b/Fika.Core/AkiSupport/Overrides/BotTemplateLimitPatch_Override.cs
index c6e98227..403f80cf 100644
--- a/Fika.Core/AkiSupport/Overrides/BotTemplateLimitPatch_Override.cs
+++ b/Fika.Core/AkiSupport/Overrides/BotTemplateLimitPatch_Override.cs
@@ -1,7 +1,7 @@
-using Aki.Common.Http;
-using Aki.Reflection.Patching;
-using Fika.Core.Coop.Matchmaker;
+using Fika.Core.Coop.Matchmaker;
using HarmonyLib;
+using SPT.Common.Http;
+using SPT.Reflection.Patching;
using System;
using System.Collections.Generic;
using System.Reflection;
diff --git a/Fika.Core/AkiSupport/Overrides/MaxBotPatch_Override.cs b/Fika.Core/AkiSupport/Overrides/MaxBotPatch_Override.cs
index f6e7edac..10505681 100644
--- a/Fika.Core/AkiSupport/Overrides/MaxBotPatch_Override.cs
+++ b/Fika.Core/AkiSupport/Overrides/MaxBotPatch_Override.cs
@@ -1,22 +1,29 @@
-using Aki.Common.Http;
-using Aki.Reflection.Patching;
-using Aki.Reflection.Utils;
+using Comfort.Common;
+using EFT;
using Fika.Core.Coop.Matchmaker;
+using SPT.Common.Http;
+using SPT.Reflection.Patching;
+using SPT.Reflection.Utils;
using System.Reflection;
namespace Fika.Core.AkiSupport.Overrides
{
+ ///
+ /// Override of SPT patch to reduce data requests to server.
+ /// Source
+ ///
+ ///
internal class MaxBotPatch_Override : ModulePatch
- {
+ {
protected override MethodBase GetTargetMethod()
{
const BindingFlags flags = BindingFlags.Public | BindingFlags.Instance;
const string methodName = "SetSettings";
- var desiredType = PatchConstants.EftTypes.SingleCustom(x => x.GetMethod(methodName, flags) != null && IsTargetMethod(x.GetMethod(methodName, flags)));
- var desiredMethod = desiredType.GetMethod(methodName, flags);
+ System.Type desiredType = PatchConstants.EftTypes.SingleCustom(x => x.GetMethod(methodName, flags) != null && IsTargetMethod(x.GetMethod(methodName, flags)));
+ MethodInfo desiredMethod = desiredType.GetMethod(methodName, flags);
- Logger.LogDebug($"{this.GetType().Name} Type: {desiredType?.Name}");
- Logger.LogDebug($"{this.GetType().Name} Method: {desiredMethod?.Name}");
+ Logger.LogDebug($"{GetType().Name} Type: {desiredType?.Name}");
+ Logger.LogDebug($"{GetType().Name} Method: {desiredMethod?.Name}");
return desiredMethod;
}
@@ -32,7 +39,10 @@ private static void PatchPreFix(ref int maxCount)
{
if (MatchmakerAcceptPatches.IsServer)
{
- if (int.TryParse(RequestHandler.GetJson("/singleplayer/settings/bot/maxCap"), out int parsedMaxCount))
+ GameWorld gameWorld = Singleton.Instance;
+ string location = gameWorld.MainPlayer.Location;
+
+ if (int.TryParse(RequestHandler.GetJson($"/singleplayer/settings/bot/maxCap/{location ?? "default"}"), out int parsedMaxCount))
{
Logger.LogWarning($"Set max bot cap to: {parsedMaxCount}");
maxCount = parsedMaxCount;
diff --git a/Fika.Core/AkiSupport/Overrides/OfflineRaidSettingsMenuPatch_Override.cs b/Fika.Core/AkiSupport/Overrides/OfflineRaidSettingsMenuPatch_Override.cs
index 8b76e5e7..4a07ae38 100644
--- a/Fika.Core/AkiSupport/Overrides/OfflineRaidSettingsMenuPatch_Override.cs
+++ b/Fika.Core/AkiSupport/Overrides/OfflineRaidSettingsMenuPatch_Override.cs
@@ -1,7 +1,7 @@
-using Aki.Reflection.Patching;
-using EFT.UI;
+using EFT.UI;
using EFT.UI.Matchmaker;
using HarmonyLib;
+using SPT.Reflection.Patching;
using System;
using System.Collections.Generic;
using System.Reflection;
@@ -42,7 +42,7 @@ private static void PatchPostfix(RaidSettingsWindow __instance, UiElementBlocker
}
// Remove redundant settings and add our own "Random" to make the setting clear, while also renaming index 0 to "Together"
- List labelList = Traverse.Create(____playersSpawnPlaceDropdown).Field("list_0").GetValue>();
+ List labelList = Traverse.Create(____playersSpawnPlaceDropdown).Field("list_0").GetValue>();
labelList.Clear();
labelList.Add(new()
{
diff --git a/Fika.Core/AkiSupport/Scav/ScavProfileLoad_Override.cs b/Fika.Core/AkiSupport/Scav/ScavProfileLoad_Override.cs
index ae7caec2..93be45ec 100644
--- a/Fika.Core/AkiSupport/Scav/ScavProfileLoad_Override.cs
+++ b/Fika.Core/AkiSupport/Scav/ScavProfileLoad_Override.cs
@@ -1,12 +1,12 @@
-using Aki.Reflection.Patching;
-using EFT;
+using EFT;
+using SPT.Reflection.Patching;
using System.Reflection;
namespace Fika.Core.AkiSupport.Scav
{
internal class ScavProfileLoad_Override : ModulePatch
{
- protected override MethodBase GetTargetMethod() => typeof(TarkovApplication).GetMethod(nameof(TarkovApplication.method_46));
+ protected override MethodBase GetTargetMethod() => typeof(TarkovApplication).GetMethod(nameof(TarkovApplication.method_50));
[PatchPrefix]
private static void PatchPrefix(ref string profileId, Profile savageProfile, RaidSettings ____raidSettings)
diff --git a/Fika.Core/Bundles/Files/newmatchmakerui.bundle b/Fika.Core/Bundles/Files/newmatchmakerui.bundle
index b4ebb1cb..b904ac13 100644
Binary files a/Fika.Core/Bundles/Files/newmatchmakerui.bundle and b/Fika.Core/Bundles/Files/newmatchmakerui.bundle differ
diff --git a/Fika.Core/Console/FikaCommands.cs b/Fika.Core/Console/FikaCommands.cs
index 3da46551..ffe8b9b6 100644
--- a/Fika.Core/Console/FikaCommands.cs
+++ b/Fika.Core/Console/FikaCommands.cs
@@ -91,6 +91,26 @@ public static void God(bool state)
}
}
+ [ConsoleCommand("debug", "", null, "Toggle debug window", [])]
+ public static void Debug(bool state)
+ {
+ CoopGame coopGame = (CoopGame)Singleton.Instance;
+
+ if (coopGame == null)
+ {
+ ConsoleScreen.LogWarning("You are not in a game.");
+ return;
+ }
+
+ if (coopGame.Status != GameStatus.Started)
+ {
+ ConsoleScreen.LogWarning("Game is not running.");
+ return;
+ }
+
+ coopGame.ToggleDebug(state);
+ }
+
[ConsoleCommand("clear", "", null, "Clears the console output", [])]
public static void Clear()
{
diff --git a/Fika.Core/Coop/Airdrops/FikaAirdropsManager.cs b/Fika.Core/Coop/Airdrops/FikaAirdropsManager.cs
index 32bc1dbd..b5472778 100644
--- a/Fika.Core/Coop/Airdrops/FikaAirdropsManager.cs
+++ b/Fika.Core/Coop/Airdrops/FikaAirdropsManager.cs
@@ -1,5 +1,4 @@
-using Aki.Custom.Airdrops.Models;
-using Aki.Custom.Airdrops.Utils;
+using Aki.Custom.Airdrops.Utils;
using BepInEx.Logging;
using Comfort.Common;
using EFT;
@@ -13,6 +12,7 @@
using Fika.Core.Networking;
using LiteNetLib;
using LiteNetLib.Utils;
+using SPT.Custom.Airdrops.Models;
using System;
using System.Collections;
using UnityEngine;
diff --git a/Fika.Core/Coop/BTR/FikaBTRManager_Client.cs b/Fika.Core/Coop/BTR/FikaBTRManager_Client.cs
index 1f06af9d..5fe4f077 100644
--- a/Fika.Core/Coop/BTR/FikaBTRManager_Client.cs
+++ b/Fika.Core/Coop/BTR/FikaBTRManager_Client.cs
@@ -1,7 +1,4 @@
-using Aki.Custom.BTR;
-using Aki.Custom.BTR.Utils;
-using Aki.SinglePlayer.Utils.TraderServices;
-using BepInEx.Logging;
+using BepInEx.Logging;
using Comfort.Common;
using EFT;
using EFT.AssetsManager;
@@ -13,6 +10,9 @@
using Fika.Core.Networking;
using HarmonyLib;
using LiteNetLib.Utils;
+using SPT.Custom.BTR;
+using SPT.Custom.BTR.Utils;
+using SPT.SinglePlayer.Utils.TraderServices;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -360,8 +360,8 @@ private BTRDataPacket UpdateDataPacket()
btrDataPacket.rotation = btrServerSide.transform.rotation;
if (btrTurretServer != null && btrTurretServer.gunsBlockRoot != null)
{
- btrDataPacket.turretRotation = btrTurretServer.transform.rotation;
- btrDataPacket.gunsBlockRotation = btrTurretServer.gunsBlockRoot.rotation;
+ btrDataPacket.turretRotation = btrTurretServer.transform.localEulerAngles.y;
+ btrDataPacket.gunsBlockRotation = btrTurretServer.gunsBlockRoot.localEulerAngles.x;
}
btrDataPacket.State = (byte)btrServerSide.BtrState;
btrDataPacket.RouteState = (byte)btrServerSide.VehicleRouteState;
diff --git a/Fika.Core/Coop/BTR/FikaBTRManager_Host.cs b/Fika.Core/Coop/BTR/FikaBTRManager_Host.cs
index e0ef2313..6ea53700 100644
--- a/Fika.Core/Coop/BTR/FikaBTRManager_Host.cs
+++ b/Fika.Core/Coop/BTR/FikaBTRManager_Host.cs
@@ -1,7 +1,4 @@
-using Aki.Custom.BTR;
-using Aki.Custom.BTR.Utils;
-using Aki.SinglePlayer.Utils.TraderServices;
-using BepInEx.Logging;
+using BepInEx.Logging;
using Comfort.Common;
using EFT;
using EFT.GlobalEvents;
@@ -13,6 +10,9 @@
using HarmonyLib;
using LiteNetLib;
using LiteNetLib.Utils;
+using SPT.Custom.BTR;
+using SPT.Custom.BTR.Utils;
+using SPT.SinglePlayer.Utils.TraderServices;
using System;
using System.Collections;
using System.Collections.Generic;
@@ -456,7 +456,7 @@ private void UpdateBTRSideDoorState(byte state)
{
try
{
- BTRSide btrSide = lastInteractPlayer.BtrInteractionSide ?? lastInteractedBtrSide;
+ BTRSide btrSide = lastInteractPlayer.BtrInteractionSide != null ? lastInteractPlayer.BtrInteractionSide : lastInteractedBtrSide;
byte sideId = btrClientSide.GetSideId(btrSide);
switch (sideId)
{
@@ -481,8 +481,8 @@ private BTRDataPacket UpdateDataPacket()
btrDataPacket.rotation = btrServerSide.transform.rotation;
if (btrTurretServer != null && btrTurretServer.gunsBlockRoot != null)
{
- btrDataPacket.turretRotation = btrTurretServer.transform.rotation;
- btrDataPacket.gunsBlockRotation = btrTurretServer.gunsBlockRoot.rotation;
+ btrDataPacket.turretRotation = btrTurretServer.transform.localEulerAngles.y;
+ btrDataPacket.gunsBlockRotation = btrTurretServer.gunsBlockRoot.localEulerAngles.x;
}
btrDataPacket.State = (byte)btrServerSide.BtrState;
btrDataPacket.RouteState = (byte)btrServerSide.VehicleRouteState;
diff --git a/Fika.Core/Coop/BotClasses/CoopBotHealthController.cs b/Fika.Core/Coop/BotClasses/CoopBotHealthController.cs
index 67876d7f..029644b6 100644
--- a/Fika.Core/Coop/BotClasses/CoopBotHealthController.cs
+++ b/Fika.Core/Coop/BotClasses/CoopBotHealthController.cs
@@ -6,7 +6,7 @@
namespace Fika.Core.Coop.ClientClasses
{
- public sealed class CoopBotHealthController(Profile.GClass1756 healthInfo, Player player, InventoryControllerClass inventoryController, SkillManager skillManager, bool aiHealth)
+ public sealed class CoopBotHealthController(Profile.GClass1766 healthInfo, Player player, InventoryControllerClass inventoryController, SkillManager skillManager, bool aiHealth)
: PlayerHealthController(healthInfo, player, inventoryController, skillManager, aiHealth)
{
private readonly CoopBot coopBot = (CoopBot)player;
@@ -18,15 +18,15 @@ public override bool _sendNetworkSyncPackets
}
}
- public override void SendNetworkSyncPacket(GStruct346 packet)
+ public override void SendNetworkSyncPacket(GStruct347 packet)
{
- if (packet.SyncType == GStruct346.ESyncType.IsAlive && !packet.Data.IsAlive.IsAlive)
+ if (packet.SyncType == GStruct347.ESyncType.IsAlive && !packet.Data.IsAlive.IsAlive)
{
- coopBot?.PacketSender?.HealthSyncPackets.Enqueue(coopBot.SetupDeathPacket(packet));
+ coopBot.PacketSender.HealthSyncPackets.Enqueue(coopBot.SetupDeathPacket(packet));
return;
}
- coopBot?.PacketSender?.HealthSyncPackets.Enqueue(new(coopBot.NetId)
+ coopBot.PacketSender.HealthSyncPackets.Enqueue(new(coopBot.NetId)
{
Packet = packet
});
diff --git a/Fika.Core/Coop/BotClasses/CoopBotInventoryController.cs b/Fika.Core/Coop/BotClasses/CoopBotInventoryController.cs
index 3dd9336a..86e75b2c 100644
--- a/Fika.Core/Coop/BotClasses/CoopBotInventoryController.cs
+++ b/Fika.Core/Coop/BotClasses/CoopBotInventoryController.cs
@@ -14,7 +14,7 @@ public class CoopBotInventoryController(Player player, Profile profile, bool exa
{
private readonly CoopBot CoopBot = (CoopBot)player;
- public override void Execute(GClass2837 operation, [CanBeNull] Callback callback)
+ public override void Execute(GClass2850 operation, [CanBeNull] Callback callback)
{
base.Execute(operation, callback);
@@ -25,7 +25,7 @@ public override void Execute(GClass2837 operation, [CanBeNull] Callback callback
using MemoryStream memoryStream = new();
using BinaryWriter binaryWriter = new(memoryStream);
- binaryWriter.WritePolymorph(GClass1632.FromInventoryOperation(operation, false));
+ binaryWriter.WritePolymorph(GClass1642.FromInventoryOperation(operation, false));
byte[] opBytes = memoryStream.ToArray();
packet.ItemControllerExecutePacket = new()
{
@@ -33,7 +33,7 @@ public override void Execute(GClass2837 operation, [CanBeNull] Callback callback
OperationBytes = opBytes
};
- CoopBot.PacketSender?.InventoryPackets?.Enqueue(packet);
+ CoopBot.PacketSender.InventoryPackets.Enqueue(packet);
}
}
}
diff --git a/Fika.Core/Coop/ClientClasses/CoopClientHealthController.cs b/Fika.Core/Coop/ClientClasses/CoopClientHealthController.cs
index 8ab98cf0..9f1bed49 100644
--- a/Fika.Core/Coop/ClientClasses/CoopClientHealthController.cs
+++ b/Fika.Core/Coop/ClientClasses/CoopClientHealthController.cs
@@ -6,7 +6,7 @@
namespace Fika.Core.Coop.ClientClasses
{
- public sealed class CoopClientHealthController(Profile.GClass1756 healthInfo, Player player, InventoryControllerClass inventoryController, SkillManager skillManager, bool aiHealth)
+ public sealed class CoopClientHealthController(Profile.GClass1766 healthInfo, Player player, InventoryControllerClass inventoryController, SkillManager skillManager, bool aiHealth)
: PlayerHealthController(healthInfo, player, inventoryController, skillManager, aiHealth)
{
private readonly CoopPlayer coopPlayer = (CoopPlayer)player;
@@ -18,15 +18,15 @@ public override bool _sendNetworkSyncPackets
}
}
- public override void SendNetworkSyncPacket(GStruct346 packet)
+ public override void SendNetworkSyncPacket(GStruct347 packet)
{
- if (packet.SyncType == GStruct346.ESyncType.IsAlive && !packet.Data.IsAlive.IsAlive)
+ if (packet.SyncType == GStruct347.ESyncType.IsAlive && !packet.Data.IsAlive.IsAlive)
{
- coopPlayer?.PacketSender?.HealthSyncPackets.Enqueue(coopPlayer.SetupDeathPacket(packet));
+ coopPlayer.PacketSender.HealthSyncPackets.Enqueue(coopPlayer.SetupDeathPacket(packet));
return;
}
- coopPlayer?.PacketSender?.HealthSyncPackets.Enqueue(new(coopPlayer.NetId)
+ coopPlayer.PacketSender.HealthSyncPackets.Enqueue(new(coopPlayer.NetId)
{
Packet = packet
});
diff --git a/Fika.Core/Coop/ClientClasses/CoopClientInventoryController.cs b/Fika.Core/Coop/ClientClasses/CoopClientInventoryController.cs
index 355164a4..f4e79cb4 100644
--- a/Fika.Core/Coop/ClientClasses/CoopClientInventoryController.cs
+++ b/Fika.Core/Coop/ClientClasses/CoopClientInventoryController.cs
@@ -26,34 +26,40 @@ public override void CallMalfunctionRepaired(Weapon weapon)
base.CallMalfunctionRepaired(weapon);
if (!Player.IsAI && (bool)Singleton.Instance.Game.Settings.MalfunctionVisability)
{
- MonoBehaviourSingleton.Instance.MalfunctionGlow.ShowGlow(BattleUIMalfunctionGlow.GlowType.Repaired, force: true, method_44());
+ MonoBehaviourSingleton.Instance.MalfunctionGlow.ShowGlow(BattleUIMalfunctionGlow.GlowType.Repaired, true, method_44());
}
}
- public override void Execute(GClass2837 operation, [CanBeNull] Callback callback)
+ public override void Execute(GClass2850 operation, [CanBeNull] Callback callback)
{
+#if DEBUG
+ ConsoleScreen.Log("InvOperation: " + operation.GetType().Name);
+#endif
+
+ // Do not replicate picking up quest items, throws an error on the other clients
+ if (operation is GClass2852 pickupOperation)
+ {
+ if (pickupOperation.Item.Template.QuestItem)
+ {
+ base.Execute(operation, callback);
+ return;
+ }
+ }
+
if (MatchmakerAcceptPatches.IsServer)
{
+ // Do not replicate quest operations
+ if (operation is GClass2866 or GClass2879)
+ {
+ base.Execute(operation, callback);
+ return;
+ }
+
HostInventoryOperationManager operationManager = new(this, operation, callback);
if (vmethod_0(operationManager.operation))
{
operationManager.operation.vmethod_0(operationManager.HandleResult);
- // Do not replicate picking up quest items, throws an error on the other clients
- if (operation is GClass2839 pickupOperation)
- {
- if (pickupOperation.Item.Template.QuestItem)
- {
- return;
- }
- }
-
- // TODO: Check for glass increments
- if (operation is GClass2870)
- {
- return;
- }
-
InventoryPacket packet = new()
{
HasItemControllerExecutePacket = true
@@ -61,7 +67,7 @@ public override void Execute(GClass2837 operation, [CanBeNull] Callback callback
using MemoryStream memoryStream = new();
using BinaryWriter binaryWriter = new(memoryStream);
- binaryWriter.WritePolymorph(GClass1632.FromInventoryOperation(operation, false));
+ binaryWriter.WritePolymorph(GClass1642.FromInventoryOperation(operation, false));
byte[] opBytes = memoryStream.ToArray();
packet.ItemControllerExecutePacket = new()
{
@@ -69,7 +75,7 @@ public override void Execute(GClass2837 operation, [CanBeNull] Callback callback
OperationBytes = opBytes
};
- CoopPlayer.PacketSender?.InventoryPackets?.Enqueue(packet);
+ CoopPlayer.PacketSender.InventoryPackets.Enqueue(packet);
return;
}
@@ -78,14 +84,11 @@ public override void Execute(GClass2837 operation, [CanBeNull] Callback callback
}
else if (MatchmakerAcceptPatches.IsClient)
{
- // Do not replicate picking up quest items, throws an error on the other clients
- if (operation is GClass2839 pickupOperation)
+ // Do not replicate quest operations
+ if (operation is GClass2866 or GClass2879)
{
- if (pickupOperation.Item.Template.QuestItem)
- {
- base.Execute(operation, callback);
- return;
- }
+ base.Execute(operation, callback);
+ return;
}
InventoryPacket packet = new()
@@ -100,12 +103,12 @@ public override void Execute(GClass2837 operation, [CanBeNull] Callback callback
inventoryController = this
};
- clientOperationManager.callback ??= new Callback(ClientPlayer.Control0.Class1400.class1400_0.method_0);
+ clientOperationManager.callback ??= new Callback(ClientPlayer.Control0.Class1422.class1422_0.method_0);
uint operationNum = AddOperationCallback(operation, new Callback(clientOperationManager.HandleResult));
using MemoryStream memoryStream = new();
using BinaryWriter binaryWriter = new(memoryStream);
- binaryWriter.WritePolymorph(GClass1632.FromInventoryOperation(operation, false));
+ binaryWriter.WritePolymorph(GClass1642.FromInventoryOperation(operation, false));
byte[] opBytes = memoryStream.ToArray();
packet.ItemControllerExecutePacket = new()
{
@@ -113,21 +116,21 @@ public override void Execute(GClass2837 operation, [CanBeNull] Callback callback
OperationBytes = opBytes
};
- CoopPlayer.PacketSender?.InventoryPackets?.Enqueue(packet);
+ CoopPlayer.PacketSender.InventoryPackets.Enqueue(packet);
}
}
- private uint AddOperationCallback(GClass2837 operation, Callback callback)
+ private uint AddOperationCallback(GClass2850 operation, Callback callback)
{
ushort id = operation.Id;
CoopPlayer.OperationCallbacks.Add(id, callback);
return id;
}
- private class HostInventoryOperationManager(CoopClientInventoryController inventoryController, GClass2837 operation, Callback callback)
+ private class HostInventoryOperationManager(CoopClientInventoryController inventoryController, GClass2850 operation, Callback callback)
{
public readonly CoopClientInventoryController inventoryController = inventoryController;
- public GClass2837 operation = operation;
+ public GClass2850 operation = operation;
public readonly Callback callback = callback;
public void HandleResult(IResult result)
@@ -144,7 +147,7 @@ private class ClientInventoryOperationManager
{
public EOperationStatus? serverOperationStatus;
public EOperationStatus? localOperationStatus;
- public GClass2837 operation;
+ public GClass2850 operation;
public Callback callback;
public CoopClientInventoryController inventoryController;
diff --git a/Fika.Core/Coop/ClientClasses/CoopClientStatisticsManager.cs b/Fika.Core/Coop/ClientClasses/CoopClientStatisticsManager.cs
index ee90a2ee..8e0d2b33 100644
--- a/Fika.Core/Coop/ClientClasses/CoopClientStatisticsManager.cs
+++ b/Fika.Core/Coop/ClientClasses/CoopClientStatisticsManager.cs
@@ -3,7 +3,7 @@
namespace Fika.Core.Coop.ClientClasses
{
- public sealed class CoopClientStatisticsManager(Profile profile) : GClass1790()
+ public sealed class CoopClientStatisticsManager(Profile profile) : GClass1800()
{
public Profile Profile = profile;
@@ -17,7 +17,7 @@ public override void ShowStatNotification(LocalizationKey localizationKey1, Loca
{
if (value > 0)
{
- NotificationManagerClass.DisplayNotification(new GClass2040(localizationKey1, localizationKey2, value));
+ NotificationManagerClass.DisplayNotification(new GClass2053(localizationKey1, localizationKey2, value));
}
}
}
diff --git a/Fika.Core/Coop/ClientClasses/HandsControllers/CoopClientFirearmController.cs b/Fika.Core/Coop/ClientClasses/HandsControllers/CoopClientFirearmController.cs
index e442c781..1aa8982d 100644
--- a/Fika.Core/Coop/ClientClasses/HandsControllers/CoopClientFirearmController.cs
+++ b/Fika.Core/Coop/ClientClasses/HandsControllers/CoopClientFirearmController.cs
@@ -47,7 +47,7 @@ public override Dictionary GetOperationFactoryDe
return operationFactoryDelegates;
}
- public Player.GClass1583 Weapon1()
+ public Player.GClass1593 Weapon1()
{
if (Item.ReloadMode == Weapon.EReloadMode.InternalMagazine && Item.Chambers.Length == 0)
{
@@ -60,32 +60,32 @@ public Player.GClass1583 Weapon1()
return new FirearmClass2(this);
}
- public Player.GClass1583 Weapon2()
+ public Player.GClass1593 Weapon2()
{
return new FirearmClass1(this);
}
- public Player.GClass1583 Weapon3()
+ public Player.GClass1593 Weapon3()
{
if (Item.IsFlareGun)
{
- return new GClass1605(this);
+ return new GClass1615(this);
}
if (Item.IsOneOff)
{
- return new GClass1607(this);
+ return new GClass1617(this);
}
if (Item.ReloadMode == Weapon.EReloadMode.OnlyBarrel)
{
- return new GClass1604(this);
+ return new GClass1614(this);
}
- if (Item is GClass2696)
+ if (Item is GClass2708)
{
- return new GClass1603(this);
+ return new GClass1613(this);
}
if (!Item.BoltAction)
{
- return new GClass1601(this);
+ return new GClass1611(this);
}
return new FirearmClass4(this);
}
@@ -95,7 +95,7 @@ public override bool CheckChamber()
bool flag = base.CheckChamber();
if (flag)
{
- coopPlayer.PacketSender?.FirearmPackets?.Enqueue(new()
+ coopPlayer.PacketSender.FirearmPackets.Enqueue(new()
{
CheckChamber = true
});
@@ -108,7 +108,7 @@ public override bool CheckAmmo()
bool flag = base.CheckAmmo();
if (flag)
{
- coopPlayer.PacketSender?.FirearmPackets?.Enqueue(new()
+ coopPlayer.PacketSender.FirearmPackets.Enqueue(new()
{
CheckAmmo = true
});
@@ -121,7 +121,7 @@ public override bool ChangeFireMode(Weapon.EFireMode fireMode)
bool flag = base.ChangeFireMode(fireMode);
if (flag)
{
- coopPlayer.PacketSender?.FirearmPackets?.Enqueue(new()
+ coopPlayer.PacketSender.FirearmPackets.Enqueue(new()
{
ChangeFireMode = true,
FireMode = fireMode
@@ -133,7 +133,7 @@ public override bool ChangeFireMode(Weapon.EFireMode fireMode)
public override void ChangeAimingMode()
{
base.ChangeAimingMode();
- coopPlayer.PacketSender?.FirearmPackets?.Enqueue(new()
+ coopPlayer.PacketSender.FirearmPackets.Enqueue(new()
{
ToggleAim = true,
AimingIndex = IsAiming ? Item.AimIndex.Value : -1
@@ -147,7 +147,7 @@ public override void SetAim(bool value)
base.SetAim(value);
if (IsAiming != isAiming || aimingInterruptedByOverlap)
{
- coopPlayer.PacketSender?.FirearmPackets?.Enqueue(new()
+ coopPlayer.PacketSender.FirearmPackets.Enqueue(new()
{
ToggleAim = true,
AimingIndex = IsAiming ? Item.AimIndex.Value : -1
@@ -160,7 +160,7 @@ public override bool CheckFireMode()
bool flag = base.CheckFireMode();
if (flag)
{
- coopPlayer.PacketSender?.FirearmPackets?.Enqueue(new()
+ coopPlayer.PacketSender.FirearmPackets.Enqueue(new()
{
CheckFireMode = true
});
@@ -171,12 +171,11 @@ public override bool CheckFireMode()
public override void DryShot(int chamberIndex = 0, bool underbarrelShot = false)
{
base.DryShot(chamberIndex, underbarrelShot);
- coopPlayer.PacketSender?.FirearmPackets?.Enqueue(new()
+ coopPlayer.PacketSender.FirearmPackets.Enqueue(new()
{
HasShotInfo = true,
ShotInfoPacket = new()
{
- IsPrimaryActive = true,
ShotType = EShotType.DryFire,
AmmoAfterShot = underbarrelShot ? 0 : Item.GetCurrentMagazineCount(),
ChamberIndex = chamberIndex,
@@ -190,7 +189,7 @@ public override bool ExamineWeapon()
bool flag = base.ExamineWeapon();
if (flag)
{
- coopPlayer.PacketSender?.FirearmPackets?.Enqueue(new()
+ coopPlayer.PacketSender.FirearmPackets.Enqueue(new()
{
ExamineWeapon = true
});
@@ -198,9 +197,9 @@ public override bool ExamineWeapon()
return flag;
}
- public override void InitiateShot(GInterface322 weapon, BulletClass ammo, Vector3 shotPosition, Vector3 shotDirection, Vector3 fireportPosition, int chamberIndex, float overheat)
+ public override void InitiateShot(GInterface336 weapon, BulletClass ammo, Vector3 shotPosition, Vector3 shotDirection, Vector3 fireportPosition, int chamberIndex, float overheat)
{
- EShotType shotType = new();
+ EShotType shotType = default;
switch (weapon.MalfState.State)
{
@@ -224,12 +223,11 @@ public override void InitiateShot(GInterface322 weapon, BulletClass ammo, Vector
break;
}
- coopPlayer.PacketSender?.FirearmPackets?.Enqueue(new()
+ coopPlayer.PacketSender.FirearmPackets.Enqueue(new()
{
HasShotInfo = true,
ShotInfoPacket = new()
{
- IsPrimaryActive = (weapon == Item),
ShotType = shotType,
AmmoAfterShot = weapon.GetCurrentMagazineCount(),
ShotPosition = shotPosition,
@@ -237,7 +235,7 @@ public override void InitiateShot(GInterface322 weapon, BulletClass ammo, Vector
FireportPosition = fireportPosition,
ChamberIndex = chamberIndex,
Overheat = overheat,
- UnderbarrelShot = weapon.IsUnderbarrelWeapon,
+ UnderbarrelShot = Weapon.IsUnderBarrelDeviceActive,
AmmoTemplate = ammo.AmmoTemplate._id,
LastShotOverheat = weapon.MalfState.LastShotOverheat,
LastShotTime = weapon.MalfState.LastShotTime,
@@ -259,7 +257,7 @@ public override void QuickReloadMag(MagazineClass magazine, Callback callback)
base.QuickReloadMag(magazine, callback);
- coopPlayer.PacketSender?.FirearmPackets?.Enqueue(new()
+ coopPlayer.PacketSender.FirearmPackets.Enqueue(new()
{
HasQuickReloadMagPacket = true,
QuickReloadMagPacket = new()
@@ -270,7 +268,7 @@ public override void QuickReloadMag(MagazineClass magazine, Callback callback)
});
}
- public override void ReloadBarrels(GClass2495 ammoPack, GClass2769 placeToPutContainedAmmoMagazine, Callback callback)
+ public override void ReloadBarrels(GClass2506 ammoPack, GClass2782 placeToPutContainedAmmoMagazine, Callback callback)
{
if (!CanStartReload() && ammoPack.AmmoCount < 1)
{
@@ -281,7 +279,7 @@ public override void ReloadBarrels(GClass2495 ammoPack, GClass2769 placeToPutCon
CurrentOperation.ReloadBarrels(ammoPack, placeToPutContainedAmmoMagazine, callback, new Callback(handler.Process));
}
- public override void ReloadCylinderMagazine(GClass2495 ammoPack, Callback callback, bool quickReload = false)
+ public override void ReloadCylinderMagazine(GClass2506 ammoPack, Callback callback, bool quickReload = false)
{
if (Blindfire)
{
@@ -301,7 +299,7 @@ public override void ReloadCylinderMagazine(GClass2495 ammoPack, Callback callba
CurrentOperation.ReloadCylinderMagazine(ammoPack, callback, new Callback(handler.Process), handler.quickReload);
}
- public override void ReloadGrenadeLauncher(GClass2495 ammoPack, Callback callback)
+ public override void ReloadGrenadeLauncher(GClass2506 ammoPack, Callback callback)
{
if (!CanStartReload())
{
@@ -312,7 +310,7 @@ public override void ReloadGrenadeLauncher(GClass2495 ammoPack, Callback callbac
string[] reloadingAmmoIds = ammoPack.GetReloadingAmmoIds();
- coopPlayer.PacketSender?.FirearmPackets?.Enqueue(new()
+ coopPlayer.PacketSender.FirearmPackets.Enqueue(new()
{
ReloadLauncher = new()
{
@@ -322,7 +320,7 @@ public override void ReloadGrenadeLauncher(GClass2495 ammoPack, Callback callbac
});
}
- public override void ReloadMag(MagazineClass magazine, GClass2769 gridItemAddress, Callback callback)
+ public override void ReloadMag(MagazineClass magazine, GClass2782 gridItemAddress, Callback callback)
{
if (!CanStartReload() || Blindfire)
{
@@ -333,7 +331,7 @@ public override void ReloadMag(MagazineClass magazine, GClass2769 gridItemAddres
CurrentOperation.ReloadMag(magazine, gridItemAddress, callback, new Callback(handler.Process));
}
- public override void ReloadWithAmmo(GClass2495 ammoPack, Callback callback)
+ public override void ReloadWithAmmo(GClass2506 ammoPack, Callback callback)
{
if (Item.GetCurrentMagazine() == null)
{
@@ -348,11 +346,11 @@ public override void ReloadWithAmmo(GClass2495 ammoPack, Callback callback)
CurrentOperation.ReloadWithAmmo(ammoPack, callback, new Callback(handler.Process));
}
- public override void SetLightsState(GStruct163[] lightsStates, bool force = false)
+ public override void SetLightsState(GStruct164[] lightsStates, bool force = false)
{
if (force || CurrentOperation.CanChangeLightState(lightsStates))
{
- coopPlayer.PacketSender?.FirearmPackets?.Enqueue(new()
+ coopPlayer.PacketSender.FirearmPackets.Enqueue(new()
{
ToggleTacticalCombo = true,
LightStatesPacket = new()
@@ -365,24 +363,39 @@ public override void SetLightsState(GStruct163[] lightsStates, bool force = fals
base.SetLightsState(lightsStates, force);
}
- public override void SetScopeMode(GStruct164[] scopeStates)
+ public override void SetScopeMode(GStruct165[] scopeStates)
+ {
+ SendScopeStates(scopeStates);
+ base.SetScopeMode(scopeStates);
+ }
+ public override void OpticCalibrationSwitchUp(GStruct165[] scopeStates)
+ {
+ SendScopeStates(scopeStates);
+ base.OpticCalibrationSwitchUp(scopeStates);
+ }
+
+ public override void OpticCalibrationSwitchDown(GStruct165[] scopeStates)
+ {
+ SendScopeStates(scopeStates);
+ base.OpticCalibrationSwitchDown(scopeStates);
+ }
+
+ private void SendScopeStates(GStruct165[] scopeStates)
{
if (!CurrentOperation.CanChangeScopeStates(scopeStates))
{
return;
}
- coopPlayer.PacketSender?.FirearmPackets?.Enqueue(new()
+ coopPlayer.PacketSender.FirearmPackets.Enqueue(new()
{
ChangeSightMode = true,
ScopeStatesPacket = new()
{
Amount = scopeStates.Length,
- GStruct164 = scopeStates
+ GStruct165 = scopeStates
}
});
-
- base.SetScopeMode(scopeStates);
}
public override void ShotMisfired(BulletClass ammo, Weapon.EMalfunctionState malfunctionState, float overheat)
@@ -408,12 +421,11 @@ public override void ShotMisfired(BulletClass ammo, Weapon.EMalfunctionState mal
break;
}
- coopPlayer.PacketSender?.FirearmPackets?.Enqueue(new()
+ coopPlayer.PacketSender.FirearmPackets.Enqueue(new()
{
HasShotInfo = true,
ShotInfoPacket = new()
{
- IsPrimaryActive = true,
ShotType = shotType,
AmmoAfterShot = Item.GetCurrentMagazineCount(),
Overheat = overheat,
@@ -429,7 +441,7 @@ public override bool ToggleLauncher()
bool flag = base.ToggleLauncher();
if (flag)
{
- coopPlayer.PacketSender?.FirearmPackets?.Enqueue(new()
+ coopPlayer.PacketSender.FirearmPackets.Enqueue(new()
{
ToggleLauncher = true
});
@@ -440,7 +452,7 @@ public override bool ToggleLauncher()
public override void Loot(bool p)
{
base.Loot(p);
- coopPlayer.PacketSender?.FirearmPackets?.Enqueue(new()
+ coopPlayer.PacketSender.FirearmPackets.Enqueue(new()
{
Loot = p
});
@@ -449,7 +461,7 @@ public override void Loot(bool p)
public override void SetInventoryOpened(bool opened)
{
base.SetInventoryOpened(opened);
- coopPlayer.PacketSender?.FirearmPackets?.Enqueue(new()
+ coopPlayer.PacketSender.FirearmPackets.Enqueue(new()
{
EnableInventory = true,
InventoryStatus = opened
@@ -459,7 +471,7 @@ public override void SetInventoryOpened(bool opened)
public override void ChangeLeftStance()
{
base.ChangeLeftStance();
- coopPlayer.PacketSender?.FirearmPackets?.Enqueue(new()
+ coopPlayer.PacketSender.FirearmPackets.Enqueue(new()
{
HasStanceChange = true,
LeftStanceState = coopPlayer.MovementContext.LeftStanceEnabled
@@ -473,7 +485,7 @@ public override void SendStartOneShotFire()
public override void CreateFlareShot(BulletClass flareItem, Vector3 shotPosition, Vector3 forward)
{
- coopPlayer.PacketSender?.FirearmPackets?.Enqueue(new()
+ coopPlayer.PacketSender.FirearmPackets.Enqueue(new()
{
HasFlareShot = true,
FlareShotPacket = new()
@@ -488,7 +500,7 @@ public override void CreateFlareShot(BulletClass flareItem, Vector3 shotPosition
private void SendAbortReloadPacket(int amount)
{
- coopPlayer.PacketSender?.FirearmPackets?.Enqueue(new()
+ coopPlayer.PacketSender.FirearmPackets.Enqueue(new()
{
HasReloadWithAmmoPacket = true,
ReloadWithAmmo = new()
@@ -507,7 +519,7 @@ public override void RollCylinder(bool rollToZeroCamora)
return;
}
- coopPlayer.PacketSender?.FirearmPackets?.Enqueue(new()
+ coopPlayer.PacketSender.FirearmPackets.Enqueue(new()
{
HasRollCylinder = true,
RollToZeroCamora = rollToZeroCamora
@@ -518,7 +530,7 @@ public override void RollCylinder(bool rollToZeroCamora)
private void SendEndReloadPacket(int amount)
{
- coopPlayer.PacketSender?.FirearmPackets?.Enqueue(new()
+ coopPlayer.PacketSender.FirearmPackets.Enqueue(new()
{
HasReloadWithAmmoPacket = true,
ReloadWithAmmo = new()
@@ -532,13 +544,13 @@ private void SendEndReloadPacket(int amount)
private void SendBoltActionReloadPacket()
{
- coopPlayer.PacketSender?.FirearmPackets?.Enqueue(new()
+ coopPlayer.PacketSender.FirearmPackets.Enqueue(new()
{
ReloadBoltAction = true
});
}
- private class FirearmClass1(Player.FirearmController controller) : GClass1589(controller)
+ private class FirearmClass1(Player.FirearmController controller) : GClass1599(controller)
{
public override void SetTriggerPressed(bool pressed)
{
@@ -560,7 +572,7 @@ public override void SwitchToIdle()
private CoopClientFirearmController coopClientFirearmController = (CoopClientFirearmController)controller;
}
- private class FirearmClass2(Player.FirearmController controller) : GClass1590(controller)
+ private class FirearmClass2(Player.FirearmController controller) : GClass1600(controller)
{
public override void SetTriggerPressed(bool pressed)
{
@@ -581,7 +593,7 @@ public override void SwitchToIdle()
private readonly CoopClientFirearmController coopClientFirearmController = (CoopClientFirearmController)controller;
}
- private class FirearmClass3(Player.FirearmController controller) : GClass1591(controller)
+ private class FirearmClass3(Player.FirearmController controller) : GClass1601(controller)
{
public override void SetTriggerPressed(bool pressed)
{
@@ -602,7 +614,7 @@ public override void SwitchToIdle()
private readonly CoopClientFirearmController coopClientFirearmController = (CoopClientFirearmController)controller;
}
- private class FirearmClass4(Player.FirearmController controller) : GClass1602(controller)
+ private class FirearmClass4(Player.FirearmController controller) : GClass1612(controller)
{
public override void Start()
{
@@ -622,7 +634,7 @@ public override void SetInventoryOpened(bool opened)
SendBoltActionReloadPacket(true);
}
- public override void ReloadMag(MagazineClass magazine, GClass2769 gridItemAddress, Callback finishCallback, Callback startCallback)
+ public override void ReloadMag(MagazineClass magazine, GClass2782 gridItemAddress, Callback finishCallback, Callback startCallback)
{
base.ReloadMag(magazine, gridItemAddress, finishCallback, startCallback);
SendBoltActionReloadPacket(true);
@@ -634,7 +646,7 @@ public override void QuickReloadMag(MagazineClass magazine, Callback finishCallb
SendBoltActionReloadPacket(true);
}
- public override void ReloadWithAmmo(GClass2495 ammoPack, Callback finishCallback, Callback startCallback)
+ public override void ReloadWithAmmo(GClass2506 ammoPack, Callback finishCallback, Callback startCallback)
{
base.ReloadWithAmmo(ammoPack, finishCallback, startCallback);
SendBoltActionReloadPacket(true);
@@ -659,15 +671,15 @@ public override void Reset()
private bool hasSent;
}
- private class ReloadMagHandler(CoopPlayer coopPlayer, GClass2769 gridItemAddress, MagazineClass magazine)
+ private class ReloadMagHandler(CoopPlayer coopPlayer, GClass2782 gridItemAddress, MagazineClass magazine)
{
private readonly CoopPlayer coopPlayer = coopPlayer;
- private readonly GClass2769 gridItemAddress = gridItemAddress;
+ private readonly GClass2782 gridItemAddress = gridItemAddress;
private readonly MagazineClass magazine = magazine;
public void Process(IResult error)
{
- GClass1528 gridItemAddressDescriptor = (gridItemAddress == null) ? null : GClass1632.FromGridItemAddress(gridItemAddress);
+ GClass1538 gridItemAddressDescriptor = (gridItemAddress == null) ? null : GClass1642.FromGridItemAddress(gridItemAddress);
using MemoryStream memoryStream = new();
using BinaryWriter binaryWriter = new(memoryStream);
@@ -684,7 +696,7 @@ public void Process(IResult error)
if (error.Succeed)
{
- coopPlayer.PacketSender?.FirearmPackets?.Enqueue(new()
+ coopPlayer.PacketSender.FirearmPackets.Enqueue(new()
{
HasReloadMagPacket = true,
ReloadMagPacket = new()
@@ -709,7 +721,7 @@ private class ReloadCylinderMagazineHandler(CoopPlayer coopPlayer, CoopClientFir
public void Process(IResult error)
{
- coopPlayer.PacketSender?.FirearmPackets?.Enqueue(new()
+ coopPlayer.PacketSender.FirearmPackets.Enqueue(new()
{
HasReloadWithAmmoPacket = true,
ReloadWithAmmo = new()
@@ -729,15 +741,15 @@ public void Process(IResult error)
}
}
- private class ReloadBarrelsHandler(CoopPlayer coopPlayer, GClass2769 placeToPutContainedAmmoMagazine, GClass2495 ammoPack)
+ private class ReloadBarrelsHandler(CoopPlayer coopPlayer, GClass2782 placeToPutContainedAmmoMagazine, GClass2506 ammoPack)
{
private readonly CoopPlayer coopPlayer = coopPlayer;
- private readonly GClass2769 placeToPutContainedAmmoMagazine = placeToPutContainedAmmoMagazine;
- private readonly GClass2495 ammoPack = ammoPack;
+ private readonly GClass2782 placeToPutContainedAmmoMagazine = placeToPutContainedAmmoMagazine;
+ private readonly GClass2506 ammoPack = ammoPack;
public void Process(IResult error)
{
- GClass1528 gridItemAddressDescriptor = (placeToPutContainedAmmoMagazine == null) ? null : GClass1632.FromGridItemAddress(placeToPutContainedAmmoMagazine);
+ GClass1538 gridItemAddressDescriptor = (placeToPutContainedAmmoMagazine == null) ? null : GClass1642.FromGridItemAddress(placeToPutContainedAmmoMagazine);
string[] ammoIds = ammoPack.GetReloadingAmmoIds();
@@ -756,7 +768,7 @@ public void Process(IResult error)
if (coopPlayer.HealthController.IsAlive)
{
- coopPlayer.PacketSender?.FirearmPackets?.Enqueue(new()
+ coopPlayer.PacketSender.FirearmPackets.Enqueue(new()
{
HasReloadBarrelsPacket = true,
ReloadBarrels = new()
@@ -779,7 +791,7 @@ public void Process(IResult error)
{
if (error.Succeed)
{
- coopPlayer.PacketSender?.FirearmPackets?.Enqueue(new()
+ coopPlayer.PacketSender.FirearmPackets.Enqueue(new()
{
HasReloadWithAmmoPacket = true,
ReloadWithAmmo = new()
diff --git a/Fika.Core/Coop/ClientClasses/HandsControllers/CoopClientGrenadeController.cs b/Fika.Core/Coop/ClientClasses/HandsControllers/CoopClientGrenadeController.cs
index ee72f5d9..a34d3617 100644
--- a/Fika.Core/Coop/ClientClasses/HandsControllers/CoopClientGrenadeController.cs
+++ b/Fika.Core/Coop/ClientClasses/HandsControllers/CoopClientGrenadeController.cs
@@ -24,7 +24,7 @@ public static CoopClientGrenadeController Create(CoopPlayer player, GrenadeClass
public override void ExamineWeapon()
{
- coopPlayer.PacketSender?.FirearmPackets?.Enqueue(new()
+ coopPlayer.PacketSender.FirearmPackets.Enqueue(new()
{
HasGrenadePacket = true,
GrenadePacket = new()
@@ -37,7 +37,7 @@ public override void ExamineWeapon()
public override void HighThrow()
{
- coopPlayer.PacketSender?.FirearmPackets?.Enqueue(new()
+ coopPlayer.PacketSender.FirearmPackets.Enqueue(new()
{
HasGrenadePacket = true,
GrenadePacket = new()
@@ -50,7 +50,7 @@ public override void HighThrow()
public override void LowThrow()
{
- coopPlayer.PacketSender?.FirearmPackets?.Enqueue(new()
+ coopPlayer.PacketSender.FirearmPackets.Enqueue(new()
{
HasGrenadePacket = true,
GrenadePacket = new()
@@ -63,7 +63,7 @@ public override void LowThrow()
public override void PullRingForHighThrow()
{
- coopPlayer.PacketSender?.FirearmPackets?.Enqueue(new()
+ coopPlayer.PacketSender.FirearmPackets.Enqueue(new()
{
HasGrenadePacket = true,
GrenadePacket = new()
@@ -76,7 +76,7 @@ public override void PullRingForHighThrow()
public override void PullRingForLowThrow()
{
- coopPlayer.PacketSender?.FirearmPackets?.Enqueue(new()
+ coopPlayer.PacketSender.FirearmPackets.Enqueue(new()
{
HasGrenadePacket = true,
GrenadePacket = new()
@@ -89,7 +89,7 @@ public override void PullRingForLowThrow()
public override void vmethod_2(float timeSinceSafetyLevelRemoved, Vector3 position, Quaternion rotation, Vector3 force, bool lowThrow)
{
- coopPlayer.PacketSender?.FirearmPackets?.Enqueue(new()
+ coopPlayer.PacketSender.FirearmPackets.Enqueue(new()
{
HasGrenadePacket = true,
GrenadePacket = new()
@@ -109,7 +109,7 @@ public override void ActualDrop(Result controller, float
{
// TODO: Override Class1025
- coopPlayer.PacketSender?.FirearmPackets?.Enqueue(new()
+ coopPlayer.PacketSender.FirearmPackets.Enqueue(new()
{
CancelGrenade = true
});
diff --git a/Fika.Core/Coop/ClientClasses/HandsControllers/CoopClientKnifeController.cs b/Fika.Core/Coop/ClientClasses/HandsControllers/CoopClientKnifeController.cs
index df26a601..273560a8 100644
--- a/Fika.Core/Coop/ClientClasses/HandsControllers/CoopClientKnifeController.cs
+++ b/Fika.Core/Coop/ClientClasses/HandsControllers/CoopClientKnifeController.cs
@@ -23,7 +23,7 @@ public override void ExamineWeapon()
{
base.ExamineWeapon();
- coopPlayer.PacketSender?.FirearmPackets?.Enqueue(new()
+ coopPlayer.PacketSender.FirearmPackets.Enqueue(new()
{
HasKnifePacket = true,
KnifePacket = new()
@@ -39,7 +39,7 @@ public override bool MakeKnifeKick()
if (knifeKick)
{
- coopPlayer.PacketSender?.FirearmPackets?.Enqueue(new()
+ coopPlayer.PacketSender.FirearmPackets.Enqueue(new()
{
HasKnifePacket = true,
KnifePacket = new()
@@ -58,7 +58,7 @@ public override bool MakeAlternativeKick()
if (alternateKnifeKick)
{
- coopPlayer.PacketSender?.FirearmPackets?.Enqueue(new()
+ coopPlayer.PacketSender.FirearmPackets.Enqueue(new()
{
HasKnifePacket = true,
KnifePacket = new()
@@ -75,7 +75,7 @@ public override void BrakeCombo()
{
base.BrakeCombo();
- coopPlayer.PacketSender?.FirearmPackets?.Enqueue(new()
+ coopPlayer.PacketSender.FirearmPackets.Enqueue(new()
{
HasKnifePacket = true,
KnifePacket = new()
diff --git a/Fika.Core/Coop/ClientClasses/HandsControllers/CoopClientQuickGrenadeController.cs b/Fika.Core/Coop/ClientClasses/HandsControllers/CoopClientQuickGrenadeController.cs
index 131a71b1..aa1d8316 100644
--- a/Fika.Core/Coop/ClientClasses/HandsControllers/CoopClientQuickGrenadeController.cs
+++ b/Fika.Core/Coop/ClientClasses/HandsControllers/CoopClientQuickGrenadeController.cs
@@ -25,7 +25,7 @@ public static CoopClientQuickGrenadeController Create(CoopPlayer player, Grenade
public override void vmethod_2(float timeSinceSafetyLevelRemoved, Vector3 position, Quaternion rotation, Vector3 force, bool lowThrow)
{
- coopPlayer.PacketSender?.FirearmPackets?.Enqueue(new()
+ coopPlayer.PacketSender.FirearmPackets.Enqueue(new()
{
HasGrenadePacket = true,
GrenadePacket = new()
diff --git a/Fika.Core/Coop/Components/CoopExfilManager.cs b/Fika.Core/Coop/Components/CoopExfilManager.cs
index 7e3ef0ee..66bfc26c 100644
--- a/Fika.Core/Coop/Components/CoopExfilManager.cs
+++ b/Fika.Core/Coop/Components/CoopExfilManager.cs
@@ -73,7 +73,7 @@ protected void Update()
if (!exfiltrationPoint.UnmetRequirements(player).Any())
{
game.MyExitLocation = exfiltrationPoint.Settings.Name;
- game.Extract(player, exfiltrationPoint);
+ game.Extract((CoopPlayer)player, exfiltrationPoint);
}
}
@@ -201,16 +201,16 @@ private void ExfiltrationPoint_OnStatusChanged(ExfiltrationPoint point, EExfiltr
ExfilStartTime = point.ExfiltrationStartTime
};
- NetDataWriter writer = mainPlayer.PacketSender?.Writer;
+ NetDataWriter writer = mainPlayer.PacketSender.Writer;
writer.Reset();
if (MatchmakerAcceptPatches.IsServer)
{
- mainPlayer.PacketSender?.Server?.SendDataToAll(writer, ref packet, DeliveryMethod.ReliableOrdered);
+ mainPlayer.PacketSender.Server.SendDataToAll(writer, ref packet, DeliveryMethod.ReliableOrdered);
}
else if (MatchmakerAcceptPatches.IsClient)
{
- mainPlayer.PacketSender?.Client?.SendData(writer, ref packet, DeliveryMethod.ReliableOrdered);
+ mainPlayer.PacketSender.Client.SendData(writer, ref packet, DeliveryMethod.ReliableOrdered);
}
}
countdownPoints.Add(point);
diff --git a/Fika.Core/Coop/Components/CoopHandler.cs b/Fika.Core/Coop/Components/CoopHandler.cs
index 8ef25c45..96369912 100644
--- a/Fika.Core/Coop/Components/CoopHandler.cs
+++ b/Fika.Core/Coop/Components/CoopHandler.cs
@@ -315,7 +315,7 @@ private void ReadFromServerCharacters()
if (writer != null)
{
writer.Reset();
- Singleton.Instance?.SendData(writer, ref requestPacket, DeliveryMethod.ReliableOrdered);
+ Singleton.Instance.SendData(writer, ref requestPacket, DeliveryMethod.ReliableOrdered);
}
}
@@ -353,19 +353,19 @@ await Singleton.Instance.LoadBundlesAndCreatePools(PoolManager.Pool
{
if (x.IsCompleted)
{
- Logger.LogDebug($"SpawnPlayer::{spawnObject.Profile.Info.Nickname}::Load Complete.");
+ Logger.LogDebug($"SpawnPlayer::{spawnObject.Profile.Info.Nickname}::Load Complete");
}
else if (x.IsFaulted)
{
- Logger.LogError($"SpawnPlayer::{spawnObject.Profile.Info.Nickname}::Load Failed.");
+ Logger.LogError($"SpawnPlayer::{spawnObject.Profile.Info.Nickname}::Load Failed");
}
else if (x.IsCanceled)
{
- Logger.LogError($"SpawnPlayer::{spawnObject.Profile.Info.Nickname}::Load Cancelled?");
+ Logger.LogError($"SpawnPlayer::{spawnObject.Profile.Info.Nickname}::Load Cancelled");
}
});
- LocalPlayer otherPlayer = SpawnObservedPlayer(spawnObject.Profile, spawnObject.Position, playerId, spawnObject.IsAI, spawnObject.NetId);
+ ObservedCoopPlayer otherPlayer = SpawnObservedPlayer(spawnObject.Profile, spawnObject.Position, playerId, spawnObject.IsAI, spawnObject.NetId);
if (!spawnObject.IsAlive)
{
@@ -453,22 +453,22 @@ public WorldInteractiveObject GetInteractiveObject(string objectId, out WorldInt
return null;
}
- private LocalPlayer SpawnObservedPlayer(Profile profile, Vector3 position, int playerId, bool isAI, int netId)
+ private ObservedCoopPlayer SpawnObservedPlayer(Profile profile, Vector3 position, int playerId, bool isAI, int netId)
{
- LocalPlayer otherPlayer = ObservedCoopPlayer.CreateObservedPlayer(playerId, position, Quaternion.identity,
+ ObservedCoopPlayer otherPlayer = ObservedCoopPlayer.CreateObservedPlayer(playerId, position, Quaternion.identity,
"Player", isAI == true ? "Bot_" : $"Player_{profile.Nickname}_", EPointOfView.ThirdPerson, profile, isAI,
EUpdateQueue.Update, Player.EUpdateMode.Manual, Player.EUpdateMode.Auto,
- GClass549.Config.CharacterController.ObservedPlayerMode,
+ GClass548.Config.CharacterController.ObservedPlayerMode,
() => Singleton.Instance.Control.Settings.MouseSensitivity,
() => Singleton.Instance.Control.Settings.MouseAimingSensitivity,
- GClass1446.Default).Result;
+ GClass1456.Default).Result;
if (otherPlayer == null)
{
return null;
}
- ((CoopPlayer)otherPlayer).NetId = netId;
+ otherPlayer.NetId = netId;
Logger.LogInfo($"SpawnObservedPlayer: {profile.Nickname} spawning with NetId {netId}");
if (!isAI)
{
@@ -477,7 +477,7 @@ private LocalPlayer SpawnObservedPlayer(Profile profile, Vector3 position, int p
if (!Players.ContainsKey(netId))
{
- Players.Add(netId, (CoopPlayer)otherPlayer);
+ Players.Add(netId, otherPlayer);
}
else
{
@@ -532,6 +532,8 @@ private LocalPlayer SpawnObservedPlayer(Profile profile, Vector3 position, int p
}
}
+ otherPlayer.InitObservedPlayer();
+
Logger.LogDebug($"CreateLocalPlayer::{profile.Info.Nickname}::Spawned.");
SetWeaponInHandsOfNewPlayer(otherPlayer, () => { });
@@ -636,7 +638,7 @@ public void SetWeaponInHandsOfNewPlayer(Player person, Action successCallback)
});
}
- public BaseLocalGame LocalGameInstance { get; internal set; }
+ public BaseLocalGame LocalGameInstance { get; internal set; }
}
public enum ESpawnState
diff --git a/Fika.Core/Coop/Components/CoopTimeManager.cs b/Fika.Core/Coop/Components/CoopTimeManager.cs
new file mode 100644
index 00000000..1dfb9f95
--- /dev/null
+++ b/Fika.Core/Coop/Components/CoopTimeManager.cs
@@ -0,0 +1,33 @@
+using Comfort.Common;
+using EFT;
+using Fika.Core.Coop.GameMode;
+using Fika.Core.Coop.Players;
+using UnityEngine;
+
+namespace Fika.Core.Coop.Components
+{
+ internal class CoopTimeManager : MonoBehaviour
+ {
+ public CoopGame CoopGame;
+ public GameTimerClass GameTimer;
+
+ public static CoopTimeManager Create(CoopGame game)
+ {
+ CoopTimeManager timeManager = game.gameObject.AddComponent();
+ timeManager.CoopGame = game;
+ timeManager.GameTimer = game.GameTimer;
+ return timeManager;
+ }
+
+ protected void Update()
+ {
+ if (CoopGame.Status == GameStatus.Started && GameTimer != null && GameTimer.SessionTime != null && GameTimer.PastTime >= GameTimer.SessionTime)
+ {
+ CoopGame.MyExitStatus = ExitStatus.MissingInAction;
+ CoopPlayer coopPlayer = (CoopPlayer)Singleton.Instance.MainPlayer;
+ CoopGame.Extract(coopPlayer, null);
+ enabled = false;
+ }
+ }
+ }
+}
diff --git a/Fika.Core/Coop/Custom/FikaDebug.cs b/Fika.Core/Coop/Custom/FikaDebug.cs
new file mode 100644
index 00000000..802f3a4a
--- /dev/null
+++ b/Fika.Core/Coop/Custom/FikaDebug.cs
@@ -0,0 +1,162 @@
+using Comfort.Common;
+using Fika.Core.Coop.Components;
+using Fika.Core.Coop.Matchmaker;
+using Fika.Core.Coop.Players;
+using Fika.Core.Networking;
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace Fika.Core.Coop.Custom
+{
+ internal class FikaDebug : MonoBehaviour
+ {
+ private CoopHandler coopHandler;
+ private Rect windowRect = new(20, 20, 200, 200);
+ private int frameCounter = 0;
+
+ private int Ping
+ {
+ get
+ {
+ return Singleton.Instance.Ping;
+ }
+ }
+
+ private int RTT
+ {
+ get
+ {
+ return Singleton.Instance.NetClient.FirstPeer.RoundTripTime;
+ }
+ }
+
+ private bool isServer = false;
+
+ private List alivePlayers;
+ private List aliveBots;
+
+ protected void Awake()
+ {
+ coopHandler = CoopHandler.GetCoopHandler();
+ if (coopHandler == null)
+ {
+ FikaPlugin.Instance.FikaLogger.LogError("FikaDebug: CoopHandlera was null!");
+ Destroy(this);
+ }
+
+ if (MatchmakerAcceptPatches.IsServer)
+ {
+ isServer = true;
+ }
+
+ alivePlayers = [];
+ aliveBots = [];
+
+ enabled = false;
+ }
+
+ protected void Update()
+ {
+ frameCounter++;
+ if (frameCounter % 300 == 0)
+ {
+ frameCounter = 0;
+
+ CheckAndAdd();
+ }
+ }
+
+ private void CheckAndAdd()
+ {
+ foreach (CoopPlayer player in coopHandler.Players.Values)
+ {
+ if (player.gameObject.name.StartsWith("Player_") || player.IsYourPlayer)
+ {
+ if (!alivePlayers.Contains(player) && player.HealthController.IsAlive)
+ {
+ AddPlayer(player);
+ }
+ }
+ else
+ {
+ if (!aliveBots.Contains(player) && player.HealthController.IsAlive)
+ {
+ AddBot(player);
+ }
+ }
+ }
+ }
+
+ protected void OnEnable()
+ {
+ CheckAndAdd();
+ }
+
+ protected void OnDisable()
+ {
+ foreach (CoopPlayer player in alivePlayers)
+ {
+ player.OnPlayerDead -= PlayerDied;
+ }
+ alivePlayers.Clear();
+
+ foreach (CoopPlayer bot in aliveBots)
+ {
+ bot.OnPlayerDead -= BotDied;
+ }
+ aliveBots.Clear();
+ }
+
+ private void AddPlayer(CoopPlayer player)
+ {
+ player.OnPlayerDead += PlayerDied;
+ alivePlayers.Add(player);
+ }
+
+ private void PlayerDied(EFT.Player player, EFT.IPlayer lastAggressor, DamageInfo damageInfo, EBodyPart part)
+ {
+ player.OnPlayerDead -= PlayerDied;
+ alivePlayers.Remove((CoopPlayer)player);
+ }
+
+ private void AddBot(CoopPlayer bot)
+ {
+ bot.OnPlayerDead += BotDied;
+ aliveBots.Add(bot);
+ }
+
+ private void BotDied(EFT.Player player, EFT.IPlayer lastAggressor, DamageInfo damageInfo, EBodyPart part)
+ {
+ player.OnPlayerDead -= BotDied;
+ aliveBots.Remove((CoopPlayer)player);
+ }
+
+ protected void OnGUI()
+ {
+ GUI.skin.label.alignment = TextAnchor.MiddleLeft;
+ GUI.skin.window.alignment = TextAnchor.UpperCenter;
+
+ GUI.Window(0, windowRect, DrawWindow, "Fika Debug");
+ }
+
+ private void DrawWindow(int windowId)
+ {
+ Rect rect = new(5, 15, 150, 25);
+ GUI.Label(rect, $"Alive Players: {alivePlayers.Count}");
+ rect.y += 15;
+ GUI.Label(rect, $"Alive Bots: {aliveBots.Count}");
+ if (isServer)
+ {
+ rect.y += 15;
+ GUI.Label(rect, $"Clients: {Singleton.Instance.NetServer.ConnectedPeersCount}");
+ }
+ else
+ {
+ rect.y += 15;
+ GUI.Label(rect, $"Ping: {Ping}");
+ rect.y += 15;
+ GUI.Label(rect, $"RTT: {RTT}");
+ }
+ }
+ }
+}
diff --git a/Fika.Core/Coop/Custom/FikaDynamicAI.cs b/Fika.Core/Coop/Custom/FikaDynamicAI.cs
index 4728bdb1..e981fd0d 100644
--- a/Fika.Core/Coop/Custom/FikaDynamicAI.cs
+++ b/Fika.Core/Coop/Custom/FikaDynamicAI.cs
@@ -5,196 +5,216 @@
using EFT;
using Fika.Core.Coop.Components;
using Fika.Core.Coop.Players;
-using System;
using System.Collections.Generic;
using UnityEngine;
namespace Fika.Core.Coop.Custom
{
- public class FikaDynamicAI : MonoBehaviour
- {
- private readonly ManualLogSource logger = BepInEx.Logging.Logger.CreateLogSource("DynamicAI");
- private CoopHandler coopHandler;
- private int frameCounter;
- private int resetCounter;
- private readonly List humanPlayers = [];
- private readonly List bots = [];
- private readonly HashSet disabledBots = [];
- private BotSpawner spawner;
-
- protected void Awake()
- {
- if (FikaPlugin.Instance.ModHandler.QuestingBotsLoaded)
- {
- logger.LogWarning("QuestingBots detected, destroying DynamicAI component. Use QuestingBots AI limiter instead!");
- Destroy(this);
- }
-
- if (!CoopHandler.TryGetCoopHandler(out coopHandler))
- {
- logger.LogError("Could not find CoopHandler! Destroying self");
- Destroy(this);
- return;
- }
-
- resetCounter = FikaPlugin.DynamicAIRate.Value switch
- {
- FikaPlugin.DynamicAIRates.Low => 600,
- FikaPlugin.DynamicAIRates.Medium => 300,
- FikaPlugin.DynamicAIRates.High => 120,
- _ => 300,
- };
-
- spawner = Singleton.Instance.BotsController.BotSpawner;
- if (spawner == null)
- {
- logger.LogError("Could not find BotSpawner! Destroying self");
- Destroy(this);
- return;
- }
-
- spawner.OnBotCreated += Spawner_OnBotCreated;
- spawner.OnBotRemoved += Spawner_OnBotRemoved;
- }
-
- private void Spawner_OnBotRemoved(BotOwner botOwner)
- {
- if (!bots.Remove((CoopBot)botOwner.GetPlayer))
- {
- logger.LogWarning($"Could not remove {botOwner.gameObject.name} from bots list.");
- }
- }
-
- private void Spawner_OnBotCreated(BotOwner botOwner)
- {
- if (botOwner.IsYourPlayer || !botOwner.IsAI)
- {
- return;
- }
-
- bots.Add((CoopBot)botOwner.GetPlayer);
- }
-
- protected void Update()
- {
- if (!FikaPlugin.DynamicAI.Value)
- {
- return;
- }
-
- frameCounter++;
-
- if (frameCounter % resetCounter == 0)
- {
- frameCounter = 0;
- foreach (CoopBot bot in bots)
- {
- CheckForPlayers(bot);
- }
- }
- }
-
- public void AddHumans()
- {
- foreach (CoopPlayer player in coopHandler.Players.Values)
- {
- if (player.IsYourPlayer || player is ObservedCoopPlayer)
- {
- humanPlayers.Add(player);
- }
- }
- }
-
- private void DeactivateBot(CoopBot bot)
- {
+ public class FikaDynamicAI : MonoBehaviour
+ {
+ private readonly ManualLogSource logger = BepInEx.Logging.Logger.CreateLogSource("DynamicAI");
+ private CoopHandler coopHandler;
+ private int frameCounter;
+ private int resetCounter;
+ private readonly List humanPlayers = [];
+ private readonly List bots = [];
+ private readonly HashSet disabledBots = [];
+ private BotSpawner spawner;
+
+ protected void Awake()
+ {
+ if (FikaPlugin.Instance.ModHandler.QuestingBotsLoaded)
+ {
+ logger.LogWarning("QuestingBots detected, destroying DynamicAI component. Use QuestingBots AI limiter instead!");
+ Destroy(this);
+ }
+
+ if (!CoopHandler.TryGetCoopHandler(out coopHandler))
+ {
+ logger.LogError("Could not find CoopHandler! Destroying self");
+ Destroy(this);
+ return;
+ }
+
+ resetCounter = FikaPlugin.DynamicAIRate.Value switch
+ {
+ FikaPlugin.DynamicAIRates.Low => 600,
+ FikaPlugin.DynamicAIRates.Medium => 300,
+ FikaPlugin.DynamicAIRates.High => 120,
+ _ => 300,
+ };
+
+ spawner = Singleton.Instance.BotsController.BotSpawner;
+ if (spawner == null)
+ {
+ logger.LogError("Could not find BotSpawner! Destroying self");
+ Destroy(this);
+ return;
+ }
+
+ spawner.OnBotCreated += Spawner_OnBotCreated;
+ spawner.OnBotRemoved += Spawner_OnBotRemoved;
+ }
+
+ private void Spawner_OnBotRemoved(BotOwner botOwner)
+ {
+ CoopBot bot = (CoopBot)botOwner.GetPlayer;
+ if (!bots.Remove(bot))
+ {
+ logger.LogWarning($"Could not remove {botOwner.gameObject.name} from bots list.");
+ }
+
+ if (disabledBots.Contains(bot))
+ {
+ disabledBots.Remove(bot);
+ }
+ }
+
+ private void Spawner_OnBotCreated(BotOwner botOwner)
+ {
+ if (botOwner.IsYourPlayer || !botOwner.IsAI)
+ {
+ return;
+ }
+
+ bots.Add((CoopBot)botOwner.GetPlayer);
+ }
+
+ protected void Update()
+ {
+ if (!FikaPlugin.DynamicAI.Value)
+ {
+ return;
+ }
+
+ frameCounter++;
+
+ if (frameCounter % resetCounter == 0)
+ {
+ frameCounter = 0;
+ foreach (CoopBot bot in bots)
+ {
+ CheckForPlayers(bot);
+ }
+ }
+ }
+
+ public void AddHumans()
+ {
+ foreach (CoopPlayer player in coopHandler.Players.Values)
+ {
+ if (player.IsYourPlayer || player is ObservedCoopPlayer)
+ {
+ humanPlayers.Add(player);
+ }
+ }
+ }
+
+ private void DeactivateBot(CoopBot bot)
+ {
#if DEBUG
- logger.LogWarning($"Disabling {bot.gameObject.name}");
+ logger.LogWarning($"Disabling {bot.gameObject.name}");
#endif
- bot.AIData.BotOwner.DecisionQueue.Clear();
- bot.AIData.BotOwner.Memory.GoalEnemy = null;
- bot.AIData.BotOwner.PatrollingData.Pause();
- bot.gameObject.SetActive(false);
-
- if (!disabledBots.Contains(bot))
- {
- disabledBots.Add(bot);
- }
- else
- {
- logger.LogError($"{bot.gameObject.name} was already in the disabled bots list when adding!");
- }
- }
-
- private void ActivateBot(CoopBot bot)
- {
+ bot.AIData.BotOwner.DecisionQueue.Clear();
+ bot.AIData.BotOwner.Memory.GoalEnemy = null;
+ bot.AIData.BotOwner.PatrollingData.Pause();
+ bot.AIData.BotOwner.ShootData.EndShoot();
+ bot.ActiveHealthController.PauseAllEffects();
+ bot.gameObject.SetActive(false);
+
+ if (!disabledBots.Contains(bot))
+ {
+ disabledBots.Add(bot);
+ }
+ else
+ {
+ logger.LogError($"{bot.gameObject.name} was already in the disabled bots list when adding!");
+ }
+ }
+
+ private void ActivateBot(CoopBot bot)
+ {
#if DEBUG
- logger.LogWarning($"Enabling {bot.gameObject.name}");
+ logger.LogWarning($"Enabling {bot.gameObject.name}");
#endif
- bot.gameObject.SetActive(true);
- bot.AIData.BotOwner.PatrollingData.Unpause();
- bot.AIData.BotOwner.PostActivate();
- disabledBots.Remove(bot);
- }
-
- private void CheckForPlayers(CoopBot bot)
- {
- // Do not run on bots that have no initialized yet
- if (bot.AIData.BotOwner.BotState is EBotState.NonActive or EBotState.PreActive)
- {
- return;
- }
-
- if (!bot.HealthController.IsAlive)
- {
- return;
- }
-
- int notInRange = 0;
-
- foreach (CoopPlayer humanPlayer in humanPlayers)
- {
- if (humanPlayer == null)
- {
- notInRange++;
- continue;
- }
-
- if (!humanPlayer.HealthController.IsAlive)
- {
- notInRange++;
- continue;
- }
-
- float distance = Vector3.SqrMagnitude(bot.Position - humanPlayer.Position);
- float range = FikaPlugin.DynamicAIRange.Value;
-
- if (distance > range * range)
- {
- notInRange++;
- }
- }
-
- if (notInRange >= humanPlayers.Count && bot.gameObject.activeSelf)
- {
- DeactivateBot(bot);
- }
- else if (notInRange < humanPlayers.Count && !bot.gameObject.activeSelf)
- {
- ActivateBot(bot);
- }
- }
-
- public void SettingChanged(bool value)
- {
- if (!value)
- {
- foreach (CoopBot bot in disabledBots)
- {
- bot.gameObject.SetActive(true);
- }
-
- disabledBots.Clear();
- }
- }
- }
+ bot.gameObject.SetActive(true);
+ bot.AIData.BotOwner.PatrollingData.Unpause();
+ bot.AIData.BotOwner.PostActivate();
+ bot.ActiveHealthController.UnpauseAllEffects();
+ disabledBots.Remove(bot);
+ }
+
+ private void CheckForPlayers(CoopBot bot)
+ {
+ // Do not run on bots that have no initialized yet
+ if (bot.AIData.BotOwner.BotState is EBotState.NonActive or EBotState.PreActive)
+ {
+ return;
+ }
+
+ if (!bot.HealthController.IsAlive)
+ {
+ return;
+ }
+
+ int notInRange = 0;
+ float range = FikaPlugin.DynamicAIRange.Value;
+
+ foreach (CoopPlayer humanPlayer in humanPlayers)
+ {
+ if (humanPlayer == null)
+ {
+ notInRange++;
+ continue;
+ }
+
+ if (!humanPlayer.HealthController.IsAlive)
+ {
+ notInRange++;
+ continue;
+ }
+
+ float distance = Vector3.SqrMagnitude(bot.Position - humanPlayer.Position);
+
+ if (distance > range * range)
+ {
+ notInRange++;
+ }
+ }
+
+ if (notInRange >= humanPlayers.Count && bot.gameObject.activeSelf)
+ {
+ DeactivateBot(bot);
+ }
+ else if (notInRange < humanPlayers.Count && !bot.gameObject.activeSelf)
+ {
+ ActivateBot(bot);
+ }
+ }
+
+ public void EnabledChange(bool value)
+ {
+ if (!value)
+ {
+ CoopBot[] disabledBotsArray = [.. disabledBots];
+ for (int i = 0; i < disabledBotsArray.Length; i++)
+ {
+ ActivateBot(disabledBotsArray[i]);
+ }
+
+ disabledBots.Clear();
+ }
+ }
+
+ internal void RateChanged(FikaPlugin.DynamicAIRates value)
+ {
+ resetCounter = value switch
+ {
+ FikaPlugin.DynamicAIRates.Low => 600,
+ FikaPlugin.DynamicAIRates.Medium => 300,
+ FikaPlugin.DynamicAIRates.High => 120,
+ _ => 300,
+ };
+ }
+ }
}
diff --git a/Fika.Core/Coop/Custom/FikaHealthBar.cs b/Fika.Core/Coop/Custom/FikaHealthBar.cs
index e638956a..db3bdfc0 100644
--- a/Fika.Core/Coop/Custom/FikaHealthBar.cs
+++ b/Fika.Core/Coop/Custom/FikaHealthBar.cs
@@ -98,7 +98,7 @@ private void UpdateScreenSpacePosition(bool throttleUpdate)
playerPlate.ScalarObjectScreen.active = true;
float processedDistance = Mathf.Clamp(sqrDistance / 625, 0.6f, 1f);
- Vector3 position = new(currentPlayer.PlayerBones.Neck.position.x, currentPlayer.PlayerBones.Neck.position.y + (1f * processedDistance), currentPlayer.PlayerBones.Neck.position.z);
+ Vector3 position = new(currentPlayer.PlayerBones.Neck.position.x, currentPlayer.PlayerBones.Neck.position.y + (1f * processedDistance), currentPlayer.PlayerBones.Neck.position.z);
if (!WorldToScreen.GetScreenPoint(position, mainPlayer, out Vector3 screenPoint, FikaPlugin.NamePlateUseOpticZoom.Value))
{
diff --git a/Fika.Core/Coop/FreeCamera/FreeCamera.cs b/Fika.Core/Coop/FreeCamera/FreeCamera.cs
index a47b058c..8bcf7684 100644
--- a/Fika.Core/Coop/FreeCamera/FreeCamera.cs
+++ b/Fika.Core/Coop/FreeCamera/FreeCamera.cs
@@ -1,7 +1,9 @@
-using Comfort.Common;
+using BSG.CameraEffects;
+using Comfort.Common;
using EFT;
using Fika.Core.Coop.Components;
using Fika.Core.Coop.Players;
+using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
@@ -22,6 +24,7 @@ public class FreeCamera : MonoBehaviour
public bool IsActive = false;
private CoopPlayer CurrentPlayer;
private bool isFollowing = false;
+ private bool leftMode = false;
private bool disableInput = false;
private KeyCode forwardKey = KeyCode.W;
@@ -240,8 +243,24 @@ protected void Update()
}
}
+ if (Input.GetKeyDown(KeyCode.N))
+ {
+ ToggleVision();
+ }
+
if (isFollowing)
{
+ if (CurrentPlayer != null)
+ {
+ if (CurrentPlayer.MovementContext.LeftStanceEnabled && !leftMode)
+ {
+ SetLeftShoulderMode(true);
+ }
+ else if (!CurrentPlayer.MovementContext.LeftStanceEnabled && leftMode)
+ {
+ SetLeftShoulderMode(false);
+ }
+ }
return;
}
@@ -317,6 +336,59 @@ protected void Update()
transform.localEulerAngles = new Vector3(newRotationY, newRotationX, 0f);
}
+ private void SetLeftShoulderMode(bool enabled)
+ {
+ if (enabled)
+ {
+ // Use different coordinates for headcam
+ if (transform.localPosition.z == -0.17f)
+ {
+ transform.localPosition = new(transform.localPosition.x, transform.localPosition.y, -transform.localPosition.z);
+ }
+ else
+ {
+ transform.localPosition = new(-transform.localPosition.x, transform.localPosition.y, transform.localPosition.z);
+ }
+ leftMode = true;
+
+ return;
+ }
+
+ // Use different coordinates for headcam
+ if (transform.localPosition.z == 0.17f)
+ {
+ transform.localPosition = new(transform.localPosition.x, transform.localPosition.y, -transform.localPosition.z);
+ }
+ else
+ {
+ transform.localPosition = new(-transform.localPosition.x, transform.localPosition.y, transform.localPosition.z);
+ }
+ leftMode = false;
+ }
+
+ private void ToggleVision()
+ {
+ NightVision nightVision = CameraClass.Instance.NightVision;
+ ThermalVision thermalVision = CameraClass.Instance.ThermalVision;
+
+ if (nightVision != null && thermalVision != null)
+ {
+ if (!nightVision.On && !thermalVision.On)
+ {
+ nightVision.On = true;
+ }
+ else if (nightVision.On && !thermalVision.On)
+ {
+ nightVision.On = false;
+ thermalVision.On = true;
+ }
+ else if (thermalVision.On)
+ {
+ thermalVision.On = false;
+ }
+ }
+ }
+
public void JumpToPlayer()
{
transform.position = new Vector3(CurrentPlayer.Transform.position.x - 2, CurrentPlayer.Transform.position.y + 2, CurrentPlayer.Transform.position.z);
@@ -324,6 +396,7 @@ public void JumpToPlayer()
if (isFollowing)
{
isFollowing = false;
+ leftMode = false;
transform.parent = null;
}
}
@@ -346,8 +419,57 @@ public void Attach3rdPerson()
public void SetActive(bool status)
{
+ if (!status)
+ {
+ NightVision nightVision = CameraClass.Instance.NightVision;
+ ThermalVision thermalVision = CameraClass.Instance.ThermalVision;
+
+ if (nightVision != null && nightVision.On)
+ {
+ nightVision.method_1(false);
+ }
+
+ if (thermalVision != null && thermalVision.On)
+ {
+ thermalVision.method_1(false);
+ }
+ }
+
+ if (status)
+ {
+ Player player = Singleton.Instance.MainPlayer;
+ if (player != null && player.HealthController.IsAlive)
+ {
+ if (player.NightVisionObserver.Component != null && player.NightVisionObserver.Component.Togglable.On)
+ {
+ player.NightVisionObserver.Component.Togglable.ForceToggle(false);
+ }
+
+ if (player.ThermalVisionObserver.Component != null && player.ThermalVisionObserver.Component.Togglable.On)
+ {
+ player.ThermalVisionObserver.Component.Togglable.ForceToggle(false);
+ }
+ }
+ else if (player != null && !player.HealthController.IsAlive)
+ {
+ NightVision nightVision = CameraClass.Instance.NightVision;
+ ThermalVision thermalVision = CameraClass.Instance.ThermalVision;
+
+ if (nightVision != null && nightVision.On)
+ {
+ nightVision.method_1(false);
+ }
+
+ if (thermalVision != null && thermalVision.On)
+ {
+ thermalVision.method_1(false);
+ }
+ }
+ }
+
IsActive = status;
isFollowing = false;
+ leftMode = false;
transform.parent = null;
}
diff --git a/Fika.Core/Coop/FreeCamera/FreeCameraController.cs b/Fika.Core/Coop/FreeCamera/FreeCameraController.cs
index 8c7d2d9e..9ac217b5 100644
--- a/Fika.Core/Coop/FreeCamera/FreeCameraController.cs
+++ b/Fika.Core/Coop/FreeCamera/FreeCameraController.cs
@@ -6,8 +6,10 @@
using Fika.Core.Coop.GameMode;
using Fika.Core.Coop.Players;
using Fika.Core.UI;
+using HarmonyLib;
using Koenigz.PerfectCulling;
using Koenigz.PerfectCulling.EFT;
+using System.Collections;
using System.Collections.Generic;
using System.Linq;
using TMPro;
@@ -25,13 +27,14 @@ public class FreeCameraController : MonoBehaviour
//private GameObject _mainCamera;
private FreeCamera _freeCamScript;
- private BattleUIScreen _playerUi;
+ private EftBattleUIScreen _playerUi;
private bool _uiHidden;
private bool _effectsCleared = false;
private GamePlayerOwner _gamePlayerOwner;
- private Player _player => Singleton.Instance.MainPlayer;
+ private CoopPlayer _player => (CoopPlayer)Singleton.Instance.MainPlayer;
+ private CoopHandler coopHandler;
public GameObject CameraParent;
public Camera CameraFreeCamera { get; private set; }
@@ -41,7 +44,6 @@ public class FreeCameraController : MonoBehaviour
private bool extracted = false;
private DeathFade deathFade;
private bool deathFadeEnabled;
- private float DeadTime = 0f;
private DisablerCullingObjectBase[] allCullingObjects;
private List previouslyActiveBakeGroups;
@@ -80,32 +82,41 @@ protected void Start()
allCullingObjects = FindObjectsOfType();
previouslyActiveBakeGroups = [];
- }
- protected void Update()
- {
- if (_gamePlayerOwner == null)
+ _player.ActiveHealthController.DiedEvent += MainPlayer_DiedEvent;
+
+ if (CoopHandler.TryGetCoopHandler(out CoopHandler cHandler))
{
- return;
+ coopHandler = cHandler;
}
+ }
- if (_player == null)
+ private void MainPlayer_DiedEvent(EDamageType obj)
+ {
+ _player.ActiveHealthController.DiedEvent -= MainPlayer_DiedEvent;
+
+ if (!deathFadeEnabled)
{
- return;
+ deathFade.EnableEffect();
+ deathFadeEnabled = true;
}
- if (_player.PlayerHealthController == null)
+ StartCoroutine(DeathRoutine());
+ }
+
+ protected void Update()
+ {
+ if (_gamePlayerOwner == null)
{
return;
}
- if (!CoopHandler.TryGetCoopHandler(out CoopHandler coopHandler))
+ if (_player == null)
{
return;
}
- CoopGame coopGame = (CoopGame)coopHandler.LocalGameInstance;
- if (coopGame == null)
+ if (_player.PlayerHealthController == null)
{
return;
}
@@ -134,7 +145,8 @@ protected void Update()
if (quitState == CoopHandler.EQuitState.YouHaveExtracted && !extracted)
{
- if (coopGame.ExtractedPlayers.Contains(((CoopPlayer)_player).NetId))
+ CoopGame coopGame = (CoopGame)coopHandler.LocalGameInstance;
+ if (coopGame.ExtractedPlayers.Contains((_player).NetId))
{
extracted = true;
ShowExtractMessage();
@@ -161,56 +173,50 @@ protected void Update()
_effectsCleared = true;
}
}
+ }
- if (!_player.HealthController.IsAlive)
+ private IEnumerator DeathRoutine()
+ {
+ yield return new WaitForSeconds(5);
+
+ CameraClass cameraClassInstance = CameraClass.Instance;
+ if (cameraClassInstance == null)
{
- DeadTime += Time.deltaTime;
- if (!deathFadeEnabled)
- {
- deathFade.EnableEffect();
- deathFadeEnabled = true;
- }
+ yield break;
}
- // Player is dead. Remove all effects!
- if (!_player.HealthController.IsAlive && !_freeCamScript.IsActive && DeadTime > 5f)
+ if (cameraClassInstance.EffectsController == null)
{
- CameraClass cameraClassInstance = CameraClass.Instance;
- if (cameraClassInstance == null)
- {
- return;
- }
-
- if (cameraClassInstance.EffectsController == null)
- {
- return;
- }
+ yield break;
+ }
- if (cameraClassInstance.Camera != null)
- {
- cameraClassInstance.Camera.fieldOfView = Singleton.Instance.Game.Settings.FieldOfView;
- }
+ if (cameraClassInstance.Camera != null)
+ {
+ cameraClassInstance.Camera.fieldOfView = Singleton.Instance.Game.Settings.FieldOfView;
+ }
- // Disable the DeathFade effect & Toggle the Camera
- deathFade.DisableEffect();
+ // Disable the DeathFade effect & Toggle the Camera
+ deathFade.DisableEffect();
+ if (!_freeCamScript.IsActive)
+ {
ToggleCamera();
ToggleUi();
- ShowExtractMessage();
+ }
+ ShowExtractMessage();
- if (!_effectsCleared)
+ if (!_effectsCleared)
+ {
+ if (_player != null)
{
- if (_player != null)
- {
- _player.Muffled = false;
- _player.HeavyBreath = false;
- }
+ _player.Muffled = false;
+ _player.HeavyBreath = false;
+ }
- if (CameraClass.Exist)
- {
- ClearEffects();
- }
- _effectsCleared = true;
+ if (CameraClass.Exist)
+ {
+ ClearEffects();
}
+ _effectsCleared = true;
}
}
@@ -218,14 +224,57 @@ private void ClearEffects()
{
CameraClass cameraClass = CameraClass.Instance;
cameraClass.EffectsController.method_4(false);
- cameraClass.EffectsController.enabled = false;
+
+ Traverse effectsController = Traverse.Create(cameraClass.EffectsController);
+
+ BloodOnScreen bloodOnScreen = effectsController.Field("bloodOnScreen_0").GetValue();
+ if (bloodOnScreen != null)
+ {
+ Destroy(bloodOnScreen);
+ }
+
+ List effectsManagerList = effectsController.Field("list_0").GetValue>();
+ if (effectsManagerList != null)
+ {
+ foreach (EffectsController.Class572 effectsManager in effectsManagerList)
+ {
+ while (effectsManager.ActiveEffects.Count > 0)
+ {
+ IEffect effect = effectsManager.ActiveEffects[0];
+ effectsManager.DeleteEffect(effect);
+ }
+ }
+ effectsManagerList.Clear();
+ }
+
+ CC_Wiggle wiggleEffect = cameraClass.Camera.gameObject.GetComponent();
+ if (wiggleEffect != null)
+ {
+ wiggleEffect.enabled = false;
+ }
+
+ CC_Blend[] blendEffects = cameraClass.Camera.gameObject.GetComponents();
+ if (blendEffects.Length > 0)
+ {
+ foreach (CC_Blend blendEffect in blendEffects)
+ {
+ blendEffect.enabled = false;
+ }
+ }
+
Destroy(cameraClass.EffectsController);
cameraClass.VisorEffect.Clear();
Destroy(cameraClass.VisorEffect);
cameraClass.VisorSwitcher.Deinit();
Destroy(cameraClass.VisorSwitcher);
- Destroy(cameraClass.NightVision);
- Destroy(cameraClass.ThermalVision);
+ if (cameraClass.NightVision.On)
+ {
+ cameraClass.NightVision.method_1(false);
+ }
+ if (cameraClass.ThermalVision.On)
+ {
+ cameraClass.ThermalVision.method_1(false);
+ }
}
private void ShowExtractMessage()
@@ -283,7 +332,7 @@ private void ToggleUi()
return;
}
- _playerUi = gameObject.GetComponent();
+ _playerUi = gameObject.GetComponent();
if (_playerUi == null)
{
@@ -432,11 +481,11 @@ public void OnDestroy()
// Destroy FreeCamScript before FreeCamController if exists
Destroy(_freeCamScript);
- Destroy(this);
if (extractText != null)
{
Destroy(extractText);
}
+ Destroy(this);
}
}
}
diff --git a/Fika.Core/Coop/FreeCamera/Patches/DeathFade_Patch.cs b/Fika.Core/Coop/FreeCamera/Patches/DeathFade_Patch.cs
index c130fe39..3dda5851 100644
--- a/Fika.Core/Coop/FreeCamera/Patches/DeathFade_Patch.cs
+++ b/Fika.Core/Coop/FreeCamera/Patches/DeathFade_Patch.cs
@@ -1,4 +1,4 @@
-using Aki.Reflection.Patching;
+using SPT.Reflection.Patching;
using System;
using System.Reflection;
using UnityEngine;
diff --git a/Fika.Core/Coop/FreeCamera/FadeBlackScreen_Patch.cs b/Fika.Core/Coop/FreeCamera/Patches/FadeBlackScreen_Patch.cs
similarity index 93%
rename from Fika.Core/Coop/FreeCamera/FadeBlackScreen_Patch.cs
rename to Fika.Core/Coop/FreeCamera/Patches/FadeBlackScreen_Patch.cs
index 9bd93c5d..d0655da6 100644
--- a/Fika.Core/Coop/FreeCamera/FadeBlackScreen_Patch.cs
+++ b/Fika.Core/Coop/FreeCamera/Patches/FadeBlackScreen_Patch.cs
@@ -1,11 +1,11 @@
-using Aki.Reflection.Patching;
-using EFT.UI;
+using EFT.UI;
+using SPT.Reflection.Patching;
using System;
using System.Reflection;
using UnityEngine;
using UnityEngine.UI;
-namespace Fika.Core.Coop.FreeCamera
+namespace Fika.Core.Coop.FreeCamera.Patches
{
internal class FadeBlackScreen_Patch : ModulePatch
{
diff --git a/Fika.Core/Coop/GameMode/AMPTGame.cs b/Fika.Core/Coop/GameMode/AMPTGame.cs
deleted file mode 100644
index 54ff351c..00000000
--- a/Fika.Core/Coop/GameMode/AMPTGame.cs
+++ /dev/null
@@ -1,118 +0,0 @@
-using Aki.Reflection.Utils;
-using BepInEx.Logging;
-using Comfort.Common;
-using EFT;
-using EFT.InputSystem;
-using EFT.UI;
-using EFT.Weather;
-using JsonType;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection;
-
-namespace Fika.Core.Coop.GameMode
-{
- public abstract class AFikaGame : BaseLocalGame, IBotGame
- {
- public new bool InRaid { get { return true; } }
-
- public ISession BackEndSession { get { return PatchConstants.BackEndSession; } }
-
- BotsController IBotGame.BotsController
- {
- get
- {
- BotsController ??= (BotsController)GetType().GetFields().Where(x => x.FieldType == typeof(BotsController)).FirstOrDefault().GetValue(this);
- return BotsController;
- }
- }
-
- private static BotsController BotsController;
-
- public BotsController PBotsController
- {
- get
- {
- BotsController ??= (BotsController)GetType().GetFields().Where(x => x.FieldType == typeof(BotsController)).FirstOrDefault().GetValue(this);
- return BotsController;
- }
- }
-
- public IWeatherCurve WeatherCurve
- {
- get
- {
- return WeatherController.Instance.WeatherCurve;
- }
- }
-
- ManualLogSource Logger { get; set; }
-
- public static T Create(InputTree inputTree, Profile profile, GameDateTime backendDateTime, InsuranceCompanyClass insurance, MenuUI menuUI,
- CommonUI commonUI, PreloaderUI preloaderUI, GameUI gameUI, LocationSettingsClass.Location location, TimeAndWeatherSettings timeAndWeather,
- WavesSettings wavesSettings, EDateTime dateTime, Callback callback, float fixedDeltaTime, EUpdateQueue updateQueue,
- ISession backEndSession, TimeSpan sessionTime) where T : AFikaGame
- {
-
- var r = smethod_0(inputTree, profile, backendDateTime, insurance, menuUI, commonUI, preloaderUI, gameUI, location, timeAndWeather, wavesSettings, dateTime,
- callback, fixedDeltaTime, updateQueue, backEndSession, new TimeSpan?(sessionTime));
-
- r.Logger = BepInEx.Logging.Logger.CreateLogSource("Coop Game Mode");
- r.Logger.LogInfo("CoopGame::Create");
-
- // Non Waves Scenario setup
- r.nonWavesSpawnScenario_0 = (NonWavesSpawnScenario)typeof(NonWavesSpawnScenario).GetMethod(nameof(NonWavesSpawnScenario.smethod_0), BindingFlags.Static | BindingFlags.Public).Invoke
- (null, [r, location, r.PBotsController]);
- r.nonWavesSpawnScenario_0.ImplementWaveSettings(wavesSettings);
-
- // Waves Scenario setup
- r.wavesSpawnScenario_0 = (WavesSpawnScenario)typeof(WavesSpawnScenario).GetMethod(nameof(WavesSpawnScenario.smethod_0), BindingFlags.Static | BindingFlags.Public).Invoke
- (null, [r.gameObject, location.waves, new Action(r.PBotsController.ActivateBotsByWave), location]);
-
- var bosswavemanagerValue = typeof(GClass579).GetMethod(nameof(GClass579.smethod_0), BindingFlags.Static | BindingFlags.Public).Invoke
- (null, [location.BossLocationSpawn, new Action(r.PBotsController.ActivateBotsByWave)]);
-
- r.GetType().GetFields(BindingFlags.NonPublic).Where(x => x.FieldType == typeof(GClass579)).FirstOrDefault().SetValue(r, bosswavemanagerValue);
-
- r.GClass579 = bosswavemanagerValue as GClass579;
-
- r.func_1 = (player) => GamePlayerOwner.Create(player, inputTree, insurance, backEndSession, commonUI, preloaderUI, gameUI, r.GameDateTime, location);
-
- return r;
- }
-
- public Dictionary Bots { get; set; } = new Dictionary();
-
- ///
- /// Matchmaker countdown
- ///
- ///
- public override void vmethod_1(float timeBeforeDeploy)
- {
- base.vmethod_1(timeBeforeDeploy);
- }
-
- ///
- /// Reconnection handling.
- ///
- public override void vmethod_3()
- {
- base.vmethod_3();
- }
-
- private GClass579 GClass579;
-
- private WavesSpawnScenario wavesSpawnScenario_0;
-
- private NonWavesSpawnScenario nonWavesSpawnScenario_0;
-
- private Func func_1;
-
- public new void method_6(string backendUrl, string locationId, int variantId)
- {
- Logger.LogInfo("CoopGame:method_6");
- return;
- }
- }
-}
diff --git a/Fika.Core/Coop/GameMode/CoopGame.cs b/Fika.Core/Coop/GameMode/CoopGame.cs
index f177d7ba..a068bcb6 100644
--- a/Fika.Core/Coop/GameMode/CoopGame.cs
+++ b/Fika.Core/Coop/GameMode/CoopGame.cs
@@ -1,6 +1,4 @@
using Aki.Custom.Airdrops;
-using Aki.Reflection.Utils;
-using BepInEx.Configuration;
using BepInEx.Logging;
using Comfort.Common;
using CommonAssets.Scripts.Game;
@@ -11,11 +9,11 @@
using EFT.Counters;
using EFT.EnvironmentEffect;
using EFT.Game.Spawning;
-using EFT.InputSystem;
using EFT.Interactive;
using EFT.InventoryLogic;
using EFT.UI;
using EFT.UI.BattleTimer;
+using EFT.UI.Matchmaker;
using EFT.UI.Screens;
using EFT.Weather;
using Fika.Core.Coop.BTR;
@@ -25,6 +23,7 @@
using Fika.Core.Coop.FreeCamera;
using Fika.Core.Coop.Matchmaker;
using Fika.Core.Coop.Players;
+using Fika.Core.Coop.Utils;
using Fika.Core.Modding;
using Fika.Core.Modding.Events;
using Fika.Core.Networking;
@@ -35,6 +34,13 @@
using HarmonyLib;
using JsonType;
using LiteNetLib.Utils;
+using Newtonsoft.Json;
+using SPT.Common.Http;
+using SPT.Reflection.Utils;
+using SPT.SinglePlayer.Models.Progression;
+using SPT.SinglePlayer.Utils.Healing;
+using SPT.SinglePlayer.Utils.Insurance;
+using SPT.SinglePlayer.Utils.Progression;
using System;
using System.Collections;
using System.Collections.Generic;
@@ -48,28 +54,37 @@ namespace Fika.Core.Coop.GameMode
///
/// A custom Game Type
///
- internal sealed class CoopGame : BaseLocalGame, IBotGame, IFikaGame
+ internal sealed class CoopGame : BaseLocalGame, IBotGame, IFikaGame
{
- public new bool InRaid { get => true; }
-
public string InfiltrationPoint;
-
public bool HasAddedFenceRep = false;
-
public bool forceStart = false;
- private CoopExfilManager exfilManager;
- private GameObject fikaStartButton;
+ public ExitStatus MyExitStatus { get; set; } = ExitStatus.Survived;
+ public string MyExitLocation { get; set; } = null;
+ public ISpawnSystem SpawnSystem;
+
+ public Dictionary Bots = [];
+ //private GameObject fikaStartButton;
private readonly Dictionary botQueue = [];
- private FikaDynamicAI dynamicAI;
+ private Coroutine extractRoutine;
+ private GClass2945 spawnPoints = null;
+ private ISpawnPoint spawnPoint = null;
+ private GClass579 GClass579;
+ private WavesSpawnScenario wavesSpawnScenario_0;
+ private NonWavesSpawnScenario nonWavesSpawnScenario_0;
+ private Func func_1;
+ private bool hasSaved = false;
+ private CoopExfilManager exfilManager;
+ private CoopTimeManager timeManager;
+ private FikaDebug fikaDebug;
+ private bool isServer;
+ public FikaDynamicAI DynamicAI { get; private set; }
public RaidSettings RaidSettings { get; private set; }
-
//WildSpawnType for sptUsec and sptBear
const int sptUsecValue = 47;
const int sptBearValue = 48;
-
public ISession BackEndSession { get => PatchConstants.BackEndSession; }
-
BotsController IBotGame.BotsController
{
get
@@ -77,7 +92,6 @@ BotsController IBotGame.BotsController
return botsController_0;
}
}
-
public BotsController BotsController
{
get
@@ -85,7 +99,6 @@ public BotsController BotsController
return botsController_0;
}
}
-
public IWeatherCurve WeatherCurve
{
get
@@ -94,12 +107,12 @@ public IWeatherCurve WeatherCurve
}
}
-
private static ManualLogSource Logger;
- internal static CoopGame Create(InputTree inputTree, Profile profile, GameDateTime backendDateTime, InsuranceCompanyClass insurance, MenuUI menuUI,
- CommonUI commonUI, PreloaderUI preloaderUI, GameUI gameUI, LocationSettingsClass.Location location, TimeAndWeatherSettings timeAndWeather,
- WavesSettings wavesSettings, EDateTime dateTime, Callback callback, float fixedDeltaTime, EUpdateQueue updateQueue,
+ internal static CoopGame Create(GInterface170 inputTree, Profile profile, GameDateTime backendDateTime,
+ InsuranceCompanyClass insurance, MenuUI menuUI, GameUI gameUI, LocationSettingsClass.Location location,
+ TimeAndWeatherSettings timeAndWeather, WavesSettings wavesSettings, EDateTime dateTime,
+ Callback callback, float fixedDeltaTime, EUpdateQueue updateQueue,
ISession backEndSession, TimeSpan sessionTime, RaidSettings raidSettings)
{
Logger = BepInEx.Logging.Logger.CreateLogSource("Coop Game Mode");
@@ -108,8 +121,11 @@ internal static CoopGame Create(InputTree inputTree, Profile profile, GameDateTi
bool useCustomWeather = timeAndWeather.IsRandomWeather;
timeAndWeather.IsRandomWeather = false;
- CoopGame coopGame = smethod_0(inputTree, profile, backendDateTime, insurance, menuUI, commonUI,
- preloaderUI, gameUI, location, timeAndWeather, wavesSettings, dateTime, callback, fixedDeltaTime, updateQueue, backEndSession, new TimeSpan?(sessionTime));
+ CoopGame coopGame = smethod_0(inputTree, profile, backendDateTime, insurance, menuUI, gameUI,
+ location, timeAndWeather, wavesSettings, dateTime, callback, fixedDeltaTime, updateQueue, backEndSession,
+ new TimeSpan?(sessionTime));
+
+ coopGame.isServer = MatchmakerAcceptPatches.IsServer;
// Non Waves Scenario setup
coopGame.nonWavesSpawnScenario_0 = NonWavesSpawnScenario.smethod_0(coopGame, location, coopGame.botsController_0);
@@ -122,17 +138,31 @@ internal static CoopGame Create(InputTree inputTree, Profile profile, GameDateTi
BossLocationSpawn[] bossSpawns = LocalGame.smethod_8(wavesSettings, location.BossLocationSpawn);
coopGame.GClass579 = GClass579.smethod_0(bossSpawns, new Action(coopGame.botsController_0.ActivateBotsByWave));
- if (useCustomWeather && MatchmakerAcceptPatches.IsServer)
+ if (useCustomWeather && coopGame.isServer)
{
Logger.LogInfo("Custom weather enabled, initializing curves");
coopGame.SetupCustomWeather(timeAndWeather);
}
- coopGame.func_1 = (Player player) => GamePlayerOwner.Create(player, inputTree, insurance, backEndSession, commonUI, preloaderUI, gameUI, coopGame.GameDateTime, location);
+ coopGame.func_1 = (Player player) => EftGamePlayerOwner.Create(player, inputTree, insurance, backEndSession, gameUI, coopGame.GameDateTime, location);
Singleton.Create(coopGame);
FikaEventDispatcher.DispatchEvent(new FikaGameCreatedEvent(coopGame));
+ EndByExitTrigerScenario endByExitTrigger = coopGame.GetComponent();
+ EndByTimerScenario endByTimerScenario = coopGame.GetComponent();
+
+ if (endByExitTrigger != null)
+ {
+ Destroy(endByExitTrigger);
+ }
+ if (endByTimerScenario != null)
+ {
+ Destroy(endByTimerScenario);
+ }
+
+ coopGame.timeManager = CoopTimeManager.Create(coopGame);
+
coopGame.RaidSettings = raidSettings;
return coopGame;
@@ -145,7 +175,7 @@ private void SetupCustomWeather(TimeAndWeatherSettings timeAndWeather)
return;
}
- DateTime dateTime = GClass1296.StartOfDay();
+ DateTime dateTime = GClass1304.StartOfDay();
DateTime dateTime2 = dateTime.AddDays(1);
WeatherClass weather = WeatherClass.CreateDefault();
@@ -156,10 +186,18 @@ private void SetupCustomWeather(TimeAndWeatherSettings timeAndWeather)
weather.ScaterringFogDensity = weather2.ScaterringFogDensity = timeAndWeather.FogType.ToValue();
weather.Time = dateTime.Ticks;
weather2.Time = dateTime2.Ticks;
- WeatherController.Instance.method_4([weather, weather2]);
+ WeatherController.Instance.method_0([weather, weather2]);
}
- public async Task CreateCoopHandler()
+ public override void SetMatchmakerStatus(string status, float? progress = null)
+ {
+ if (GClass3126.Instance.CurrentScreenController is MatchmakerTimeHasCome.GClass3182 gclass)
+ {
+ gclass.ChangeStatus(status, progress);
+ }
+ }
+
+ public Task CreateCoopHandler()
{
CoopHandler coopHandler = CoopHandler.GetCoopHandler();
if (coopHandler != null)
@@ -193,30 +231,9 @@ public async Task CreateCoopHandler()
throw new Exception("No Server Id found");
}
- if (MatchmakerAcceptPatches.IsServer)
- {
- FikaServer server = gameObject.AddComponent();
-
- while (!server.ServerReady)
- {
- await Task.Delay(100);
- }
- Logger.LogInfo("FikaServer has started!");
- }
- else if (MatchmakerAcceptPatches.IsClient)
- {
- FikaClient client = gameObject.AddComponent();
-
- while (!client.ClientReady)
- {
- await Task.Delay(100);
- }
- Logger.LogInfo("FikaClient has started!");
- }
+ return Task.CompletedTask;
}
- public Dictionary Bots { get; set; } = [];
-
private List GetPlayers(CoopHandler coopHandler)
{
List humanPlayers = [];
@@ -248,13 +265,11 @@ private float GetDistanceFromPlayers(Vector3 position, List humanPla
return distance;
}
- private string GetFurthestBot(Dictionary bots, CoopHandler coopHandler, out float furthestDistance)
+ private string GetFurthestBot(Dictionary bots, CoopHandler coopHandler, List humanPlayers, out float furthestDistance)
{
string furthestBot = string.Empty;
furthestDistance = 0f;
- List humanPlayers = GetPlayers(coopHandler);
-
foreach (var botKeyValuePair in Bots)
{
if (IsInvalidBotForDespawning(botKeyValuePair))
@@ -310,14 +325,14 @@ private async Task CreateBot(Profile profile, Vector3 position)
#if DEBUG
Logger.LogWarning($"Creating bot {profile.Info.Settings.Role} at {position}");
#endif
- if (MatchmakerAcceptPatches.IsClient)
+ if (!isServer)
{
return null;
}
if (!CoopHandler.TryGetCoopHandler(out CoopHandler coopHandler))
{
- Logger.LogDebug($"{nameof(CreateBot)}:Unable to find {nameof(CoopHandler)}");
+ Logger.LogError($"{nameof(CreateBot)}: Unable to find {nameof(CoopHandler)}");
return null;
}
@@ -331,7 +346,7 @@ private async Task CreateBot(Profile profile, Vector3 position)
isSpecial = true;
}
- if (FikaPlugin.EnforcedSpawnLimits.Value && botsController_0.AliveAndLoadingBotsCount >= botsController_0.BotSpawner.MaxBots)
+ if (FikaPlugin.EnforcedSpawnLimits.Value && Bots.Count >= botsController_0.BotSpawner.MaxBots)
{
bool despawned = false;
@@ -344,7 +359,7 @@ private async Task CreateBot(Profile profile, Vector3 position)
if (!isSpecial && !despawned)
{
#if DEBUG
- Logger.LogWarning($"Stopping spawn of bot {profile.Nickname}, max count reached and enforced limits enabled. Current: {botsController_0.AliveAndLoadingBotsCount}, Max: {botsController_0.BotSpawner.MaxBots}");
+ Logger.LogWarning($"Stopping spawn of bot {profile.Nickname}, max count reached and enforced limits enabled. Current: {Bots.Count}, Max: {botsController_0.BotSpawner.MaxBots}, Alive & Loading: {botsController_0.BotSpawner.AliveAndLoadingBotsCount}");
#endif
return null;
}
@@ -370,7 +385,7 @@ private async Task CreateBot(Profile profile, Vector3 position)
netId = server.PopNetId();
SendCharacterPacket packet = new(new FikaSerialization.PlayerInfoPacket() { Profile = profile }, true, true, position, netId);
- Singleton.Instance?.SendDataToAll(new NetDataWriter(), ref packet, LiteNetLib.DeliveryMethod.ReliableUnordered);
+ Singleton.Instance.SendDataToAll(new NetDataWriter(), ref packet, LiteNetLib.DeliveryMethod.ReliableUnordered);
if (server.NetServer.ConnectedPeersCount > 0)
{
@@ -379,8 +394,8 @@ private async Task CreateBot(Profile profile, Vector3 position)
localPlayer = await CoopBot.CreateBot(num, position, Quaternion.identity, "Player",
"Bot_", EPointOfView.ThirdPerson, profile, true, UpdateQueue, Player.EUpdateMode.Manual,
- Player.EUpdateMode.Auto, GClass549.Config.CharacterController.BotPlayerMode, () => 1f,
- () => 1f, GClass1446.Default);
+ Player.EUpdateMode.Auto, GClass548.Config.CharacterController.BotPlayerMode, () => 1f,
+ () => 1f, GClass1456.Default);
localPlayer.Location = Location_0.Id;
@@ -475,14 +490,19 @@ private async Task WaitForPlayersToLoadBotProfile(int netId)
private bool TryDespawnFurthest(Profile profile, Vector3 position, CoopHandler coopHandler)
{
- string botKey = GetFurthestBot(Bots, coopHandler, out float furthestDistance);
+ List humanPlayers = GetPlayers(coopHandler);
+
+ string botKey = GetFurthestBot(Bots, coopHandler, humanPlayers, out float furthestDistance);
if (botKey == string.Empty)
{
+#if DEBUG
+ Logger.LogWarning("TryDespawnFurthest: botKey was empty");
+#endif
return false;
}
- if (furthestDistance > GetDistanceFromPlayers(position, GetPlayers(coopHandler)))
+ if (furthestDistance > GetDistanceFromPlayers(position, humanPlayers))
{
#if DEBUG
Logger.LogWarning($"We're not despawning anything. The furthest bot is closer than the one we wanted to spawn.");
@@ -500,7 +520,7 @@ private bool TryDespawnFurthest(Profile profile, Vector3 position, CoopHandler c
}
Player bot = Bots[botKey];
#if DEBUG
- Logger.LogWarning($"Removing {bot.Profile.Info.Settings.Role} at a distance of {Math.Sqrt(furthestDistance)}m from ITs nearest player.");
+ Logger.LogWarning($"Removing {bot.Profile.Info.Settings.Role} at a distance of {Math.Sqrt(furthestDistance)}m from its nearest player.");
#endif
DespawnBot(coopHandler, bot);
#if DEBUG
@@ -517,7 +537,10 @@ private void DespawnBot(CoopHandler coopHandler, Player bot)
BotsController.Bots.Remove(botOwner);
bot.HealthController.DiedEvent -= botOwner.method_6; // Unsubscribe from the event to prevent errors.
BotUnspawn(botOwner);
- botOwner?.Dispose();
+ if (botOwner != null)
+ {
+ botOwner.Dispose();
+ }
CoopPlayer coopPlayer = (CoopPlayer)bot;
coopHandler.Players.Remove(coopPlayer.NetId);
@@ -525,54 +548,79 @@ private void DespawnBot(CoopHandler coopHandler, Player bot)
}
///
- /// We use instead
+ /// The countdown deploy screen
///
- ///
- public override void vmethod_1(float timeBeforeDeploy)
+ ///
+ public override IEnumerator vmethod_1()
{
- /// Do nothing
+ CoopPlayer coopPlayer = (CoopPlayer)PlayerOwner.Player;
+ coopPlayer.PacketSender.Init();
+
+ int timeBeforeDeployLocal = Singleton.Instance.TimeBeforeDeployLocal;
+ DateTime dateTime = GClass1304.Now.AddSeconds(timeBeforeDeployLocal);
+ new MatchmakerFinalCountdown.GClass3181(Profile_0, dateTime).ShowScreen(EScreenState.Root);
+ MonoBehaviourSingleton.Instance.FadeInVolumeBeforeRaid(timeBeforeDeployLocal);
+ Singleton.Instance.StopMenuBackgroundMusicWithDelay(timeBeforeDeployLocal);
+ GameUi.gameObject.SetActive(true);
+ GameUi.TimerPanel.ProfileId = ProfileId;
+ yield return new WaitForSeconds(timeBeforeDeployLocal);
}
///
- /// Matchmaker countdown
+ /// This task ensures that all players are joined and loaded before continuing
///
- /// Time in seconds to count down
- private async void DeployScreen(float timeBeforeDeploy)
+ ///
+ private IEnumerator WaitForOtherPlayers()
{
if (CoopHandler.TryGetCoopHandler(out CoopHandler coopHandler))
{
- if (MatchmakerAcceptPatches.IsServer && MatchmakerAcceptPatches.HostExpectedNumberOfPlayers <= 1)
+ if (isServer && MatchmakerAcceptPatches.HostExpectedNumberOfPlayers <= 1)
{
- if (fikaStartButton != null)
+ /*if (fikaStartButton != null)
{
Destroy(fikaStartButton);
- }
+ }*/
- dynamicAI?.AddHumans();
+ if (DynamicAI != null)
+ {
+ DynamicAI.AddHumans();
+ }
SetStatusModel status = new(coopHandler.MyPlayer.ProfileId, LobbyEntry.ELobbyStatus.IN_GAME);
- await FikaRequestHandler.UpdateSetStatus(status);
+ Task updateStatus = FikaRequestHandler.UpdateSetStatus(status);
+
+ while (!updateStatus.IsCompleted)
+ {
+ yield return null;
+ }
Singleton.Instance.ReadyClients++;
- base.vmethod_1(timeBeforeDeploy);
- return;
+ yield break;
}
NetDataWriter writer = new();
forceStart = false;
- MatchmakerAcceptPatches.GClass3163.ChangeStatus("Waiting for other players to finish loading...");
+ MatchmakerAcceptPatches.GClass3182.ChangeStatus("Waiting for other players to finish loading...");
- fikaStartButton?.SetActive(true);
+ /*if (fikaStartButton != null)
+ {
+ fikaStartButton.SetActive(true);
+ }*/
- if (MatchmakerAcceptPatches.IsServer)
+ if (isServer)
{
SetStatusModel status = new(coopHandler.MyPlayer.ProfileId, LobbyEntry.ELobbyStatus.IN_GAME);
- await FikaRequestHandler.UpdateSetStatus(status);
+ Task updateStatus = FikaRequestHandler.UpdateSetStatus(status);
+
+ while (!updateStatus.IsCompleted)
+ {
+ yield return null;
+ }
do
{
- await Task.Delay(100);
+ yield return null;
} while (coopHandler.HumanPlayers < MatchmakerAcceptPatches.HostExpectedNumberOfPlayers && !forceStart);
FikaServer server = Singleton.Instance;
@@ -587,7 +635,7 @@ private async void DeployScreen(float timeBeforeDeploy)
do
{
- await Task.Delay(250);
+ yield return null;
} while (Singleton.Instance.ReadyClients < MatchmakerAcceptPatches.HostExpectedNumberOfPlayers && !forceStart);
foreach (CoopPlayer player in coopHandler.Players.Values)
@@ -598,13 +646,16 @@ private async void DeployScreen(float timeBeforeDeploy)
Singleton.Instance.SendDataToAll(writer, ref syncPacket, LiteNetLib.DeliveryMethod.ReliableUnordered);
}
- dynamicAI?.AddHumans();
+ if (DynamicAI != null)
+ {
+ DynamicAI.AddHumans();
+ }
}
- else if (MatchmakerAcceptPatches.IsClient)
+ else
{
do
{
- await Task.Delay(100);
+ yield return null;
} while (coopHandler.HumanPlayers < MatchmakerAcceptPatches.HostExpectedNumberOfPlayers && !forceStart);
FikaClient client = Singleton.Instance;
@@ -617,23 +668,20 @@ private async void DeployScreen(float timeBeforeDeploy)
do
{
- await Task.Delay(250);
+ yield return null;
} while (Singleton.Instance.ReadyClients < MatchmakerAcceptPatches.HostExpectedNumberOfPlayers && !forceStart);
}
- if (fikaStartButton != null)
+ /*if (fikaStartButton != null)
{
Destroy(fikaStartButton);
- }
-
+ }*/
}
-
- base.vmethod_1(timeBeforeDeploy);
}
private async Task SendOrReceiveSpawnPoint()
{
- if (MatchmakerAcceptPatches.IsServer)
+ if (isServer)
{
bool spawnTogether = RaidSettings.PlayersSpawnPlace == EPlayersSpawnPlace.SamePlace;
UpdateSpawnPointRequest body = new(spawnTogether ? spawnPoint.Id : "");
@@ -648,7 +696,7 @@ private async Task SendOrReceiveSpawnPoint()
}
await FikaRequestHandler.UpdateSpawnPoint(body);
}
- else if (MatchmakerAcceptPatches.IsClient)
+ else
{
SpawnPointRequest body = new();
SpawnPointResponse response = await FikaRequestHandler.RaidSpawnPoint(body);
@@ -676,9 +724,6 @@ private async Task SendOrReceiveSpawnPoint()
}
}
- GClass2928 spawnPoints = null;
- ISpawnPoint spawnPoint = null;
-
///
/// Creating the EFT.LocalPlayer
///
@@ -705,30 +750,29 @@ public override async Task vmethod_2(int playerId, Vector3 position
CharacterControllerSpawner.Mode characterControllerMode, Func getSensitivity, Func getAimingSensitivity,
IStatisticsManager statisticsManager, AbstractQuestControllerClass questController, AbstractAchievementControllerClass achievementsController)
{
- Logger.LogInfo("Creating CoopHandler!");
+ Logger.LogInfo("Creating CoopHandler");
await CreateCoopHandler();
CoopHandler.GetCoopHandler().LocalGameInstance = this;
+ profile.SetSpawnedInSession(profile.Side == EPlayerSide.Savage);
+
LocalPlayer myPlayer = await CoopPlayer.Create(playerId, spawnPoint.Position, spawnPoint.Rotation, "Player", "Main_", EPointOfView.FirstPerson, profile,
false, UpdateQueue, armsUpdateMode, bodyUpdateMode,
- GClass549.Config.CharacterController.ClientPlayerMode, getSensitivity,
- getAimingSensitivity, new GClass1445(), MatchmakerAcceptPatches.IsServer ? 0 : 1000, statisticsManager);
+ GClass548.Config.CharacterController.ClientPlayerMode, getSensitivity,
+ getAimingSensitivity, new GClass1455(), isServer ? 0 : 1000, statisticsManager);
- profile.SetSpawnedInSession(profile.Side == EPlayerSide.Savage);
+ await NetManagerUtils.InitNetManager(isServer);
if (!CoopHandler.TryGetCoopHandler(out CoopHandler coopHandler))
{
Logger.LogDebug($"{nameof(vmethod_2)}:Unable to find {nameof(CoopHandler)}");
- await Task.Delay(5000);
+ throw new MissingComponentException("CoopHandler was missing during CoopGame init");
}
- if (MatchmakerAcceptPatches.IsServer)
+ if (RaidSettings.MetabolismDisabled)
{
- if (RaidSettings.MetabolismDisabled)
- {
- myPlayer.HealthController.DisableMetabolism();
- NotificationManagerClass.DisplayMessageNotification("Metabolism disabled", iconType: EFT.Communications.ENotificationIconType.Alert);
- }
+ myPlayer.HealthController.DisableMetabolism();
+ NotificationManagerClass.DisplayMessageNotification("Metabolism disabled", iconType: EFT.Communications.ENotificationIconType.Alert);
}
CoopPlayer coopPlayer = (CoopPlayer)myPlayer;
@@ -740,7 +784,9 @@ public override async Task vmethod_2(int playerId, Vector3 position
myPlayer.SpawnPoint = spawnPoint;
GameObject customButton = null;
- GameObject customButtonStart = null;
+ //GameObject customButtonStart = null;
+
+ await NetManagerUtils.SetupGameVariables(isServer, coopPlayer);
// This creates a "custom" Back button so that we can back out if we get stuck
if (MenuUI.Instantiated)
@@ -767,7 +813,7 @@ public override async Task vmethod_2(int playerId, Vector3 position
});
Traverse.Create(backButtonComponent).Field("OnClick").SetValue(newEvent);
- if (MatchmakerAcceptPatches.IsServer)
+ /*if (isServer)
{
DefaultUIButton startButton = Traverse.Create(menuUI.MatchmakerTimeHasCome).Field("_cancelButton").GetValue();
customButtonStart = Instantiate(backButton.gameObject, backButton.gameObject.transform.parent);
@@ -793,44 +839,40 @@ public override async Task vmethod_2(int playerId, Vector3 position
writer.Reset();
Singleton.Instance.SendDataToAll(writer, ref packet, LiteNetLib.DeliveryMethod.ReliableOrdered);
- fikaStartButton?.SetActive(false);
+ if (fikaStartButton != null)
+ {
+ fikaStartButton.SetActive(false);
+ }
});
Traverse.Create(startButtonComponent).Field("OnClick").SetValue(newStartEvent);
- customButton?.SetActive(true);
+ if (customButton != null)
+ {
+ customButton.SetActive(true);
+ }
fikaStartButton = customButtonStart;
- }
+ }*/
}
SendCharacterPacket packet = new(new FikaSerialization.PlayerInfoPacket() { Profile = myPlayer.Profile }, myPlayer.HealthController.IsAlive, false, myPlayer.Transform.position, (myPlayer as CoopPlayer).NetId);
- if (MatchmakerAcceptPatches.IsServer)
+ if (isServer)
{
await SetStatus(myPlayer, LobbyEntry.ELobbyStatus.COMPLETE);
}
else
{
- Singleton.Instance?.SendData(new NetDataWriter(), ref packet, LiteNetLib.DeliveryMethod.ReliableUnordered);
- }
-
- if (MatchmakerAcceptPatches.IsServer)
- {
- while (!Singleton.Instantiated && !Singleton.Instance.ServerReady)
- {
- await Task.Delay(100);
- }
- }
- else if (MatchmakerAcceptPatches.IsClient)
- {
- while (!Singleton.Instantiated && !Singleton.Instance.ClientReady)
- {
- await Task.Delay(100);
- }
+ Singleton.Instance.SendData(new NetDataWriter(), ref packet, LiteNetLib.DeliveryMethod.ReliableUnordered);
}
await WaitForPlayers();
+ fikaDebug = gameObject.AddComponent();
+
Destroy(customButton);
- fikaStartButton?.SetActive(false);
+ /*if (fikaStartButton != null)
+ {
+ fikaStartButton.SetActive(false);
+ }*/
myPlayer.ActiveHealthController.DiedEvent += MainPlayerDied;
@@ -839,10 +881,9 @@ public override async Task vmethod_2(int playerId, Vector3 position
private void MainPlayerDied(EDamageType obj)
{
- EndByTimerScenario endByTimerScenario = GetComponent();
- if (endByTimerScenario != null)
+ if (timeManager != null)
{
- Destroy(endByTimerScenario);
+ Destroy(timeManager);
}
if (GameUi.TimerPanel.enabled)
{
@@ -850,10 +891,10 @@ private void MainPlayerDied(EDamageType obj)
}
}
- public async Task InitPlayer(BotControllerSettings botsSettings, string backendUrl, InventoryControllerClass inventoryController, Callback runCallback)
+ public async Task InitPlayer(BotControllerSettings botsSettings, string backendUrl, Callback runCallback)
{
Status = GameStatus.Running;
- UnityEngine.Random.InitState((int)GClass1296.Now.Ticks);
+ UnityEngine.Random.InitState((int)GClass1304.Now.Ticks);
LocationSettingsClass.Location location;
if (Location_0.IsHideout)
@@ -866,7 +907,7 @@ public async Task InitPlayer(BotControllerSettings botsSettings, string backendU
{
int num = UnityEngine.Random.Range(1, 6);
method_6(backendUrl, Location_0.Id, num);
- location = await ginterface145_0.LoadLocationLoot(Location_0.Id, num);
+ location = await ginterface158_0.LoadLocationLoot(Location_0.Id, num);
}
}
@@ -883,7 +924,7 @@ public async Task InitPlayer(BotControllerSettings botsSettings, string backendU
Logger.LogError("Can't find event prefab in resources. Path : Prefabs/HALLOWEEN_CONTROLLER");
}
}
- GClass785 config = GClass549.Config;
+ GClass786 config = GClass548.Config;
if (config.FixedFrameRate > 0f)
{
FixedDeltaTime = 1f / config.FixedFrameRate;
@@ -904,9 +945,9 @@ public async Task InitPlayer(BotControllerSettings botsSettings, string backendU
await method_11(location, startHandler.FinishLoading);
}
- private class StartHandler(BaseLocalGame localGame, BotControllerSettings botSettings, ISpawnSystem spawnSystem, Callback runCallback)
+ private class StartHandler(BaseLocalGame localGame, BotControllerSettings botSettings, ISpawnSystem spawnSystem, Callback runCallback)
{
- private readonly BaseLocalGame localGame = localGame;
+ private readonly BaseLocalGame localGame = localGame;
private readonly BotControllerSettings botSettings = botSettings;
private readonly ISpawnSystem spawnSystem = spawnSystem;
private readonly Callback runCallback = runCallback;
@@ -922,23 +963,23 @@ private async Task CreateLocalPlayer()
int num = method_12();
Player.EUpdateMode eupdateMode = Player.EUpdateMode.Auto;
- if (GClass549.Config.UseHandsFastAnimator)
+ if (GClass548.Config.UseHandsFastAnimator)
{
eupdateMode = Player.EUpdateMode.Manual;
}
- spawnPoints = GClass2928.CreateFromScene(new DateTime?(GClass1296.LocalDateTimeFromUnixTime(Location_0.UnixDateTime)), Location_0.SpawnPointParams);
+ spawnPoints = GClass2945.CreateFromScene(new DateTime?(GClass1304.LocalDateTimeFromUnixTime(Location_0.UnixDateTime)), Location_0.SpawnPointParams);
int spawnSafeDistance = (Location_0.SpawnSafeDistanceMeters > 0) ? Location_0.SpawnSafeDistanceMeters : 100;
GStruct380 settings = new(Location_0.MinDistToFreePoint, Location_0.MaxDistToFreePoint, Location_0.MaxBotPerZone, spawnSafeDistance);
- SpawnSystem = GClass2929.CreateSpawnSystem(settings, () => Time.time, Singleton.Instance, zones: botsController_0, spawnPoints);
+ SpawnSystem = GClass2946.CreateSpawnSystem(settings, () => Time.time, Singleton.Instance, zones: botsController_0, spawnPoints);
- if (MatchmakerAcceptPatches.IsServer)
+ if (isServer)
{
spawnPoint = SpawnSystem.SelectSpawnPoint(ESpawnCategory.Player, Profile_0.Info.Side);
await SendOrReceiveSpawnPoint();
}
- if (MatchmakerAcceptPatches.IsClient)
+ if (!isServer)
{
await SendOrReceiveSpawnPoint();
if (spawnPoint == null)
@@ -951,8 +992,8 @@ private async Task CreateLocalPlayer()
IStatisticsManager statisticsManager = new CoopClientStatisticsManager(Profile_0);
LocalPlayer myPlayer = await vmethod_2(num, spawnPoint.Position, spawnPoint.Rotation, "Player", "Main_", EPointOfView.FirstPerson, Profile_0, false,
- UpdateQueue, eupdateMode, Player.EUpdateMode.Auto, GClass549.Config.CharacterController.ClientPlayerMode,
- new Func(Class1362.class1362_0.method_1), new Func(Class1362.class1362_0.method_2),
+ UpdateQueue, eupdateMode, Player.EUpdateMode.Auto, GClass548.Config.CharacterController.ClientPlayerMode,
+ new Func(Class1380.class1380_0.method_3), new Func(Class1380.class1380_0.method_4),
statisticsManager, null, null);
myPlayer.Location = Location_0.Id;
@@ -965,46 +1006,39 @@ private async Task WaitForPlayers()
{
Logger.LogInfo("Starting task to wait for other players.");
- MatchmakerAcceptPatches.GClass3163?.ChangeStatus($"Initializing Coop Game...");
+ if (MatchmakerAcceptPatches.GClass3182 != null)
+ {
+ MatchmakerAcceptPatches.GClass3182.ChangeStatus($"Initializing Coop Game...");
+ }
int numbersOfPlayersToWaitFor = 0;
- if (MatchmakerAcceptPatches.IsServer)
+ if (isServer)
{
- while (!Singleton.Instantiated && !Singleton.Instance.ServerReady)
- {
- await Task.Delay(100);
- }
-
FikaServer server = Singleton.Instance;
do
{
numbersOfPlayersToWaitFor = MatchmakerAcceptPatches.HostExpectedNumberOfPlayers - (server.NetServer.ConnectedPeersCount + 1);
- if (MatchmakerAcceptPatches.GClass3163 != null)
+ if (MatchmakerAcceptPatches.GClass3182 != null)
{
if (numbersOfPlayersToWaitFor > 0)
{
- MatchmakerAcceptPatches.GClass3163.ChangeStatus($"Waiting for {numbersOfPlayersToWaitFor} {(numbersOfPlayersToWaitFor > 1 ? "players" : "player")}");
+ MatchmakerAcceptPatches.GClass3182.ChangeStatus($"Waiting for {numbersOfPlayersToWaitFor} {(numbersOfPlayersToWaitFor > 1 ? "players" : "player")}");
}
else
{
- MatchmakerAcceptPatches.GClass3163.ChangeStatus($"All players joined, starting game...");
+ MatchmakerAcceptPatches.GClass3182.ChangeStatus($"All players joined, starting game...");
}
}
else
{
Logger.LogError("WaitForPlayers::GClass3163 was null!");
}
- await Task.Delay(1000);
+ await Task.Delay(100);
} while (numbersOfPlayersToWaitFor > 0 && !forceStart);
}
- else if (MatchmakerAcceptPatches.IsClient)
+ else
{
- while (!Singleton.Instantiated && !Singleton.Instance.ClientReady)
- {
- await Task.Delay(100);
- }
-
FikaClient client = Singleton.Instance;
while (client.NetClient == null)
@@ -1017,7 +1051,7 @@ private async Task WaitForPlayers()
while (client.ServerConnection == null && connectionAttempts < 5)
{
// Server retries 10 times with a 500ms interval, we give it 5 seconds to try
- MatchmakerAcceptPatches.GClass3163.ChangeStatus("Waiting for client to connect to server... If there is no notification it failed.");
+ MatchmakerAcceptPatches.GClass3182.ChangeStatus("Waiting for client to connect to server... If there is no notification it failed.");
connectionAttempts++;
await Task.Delay(1000);
@@ -1039,15 +1073,15 @@ private async Task WaitForPlayers()
do
{
numbersOfPlayersToWaitFor = MatchmakerAcceptPatches.HostExpectedNumberOfPlayers - (client.ConnectedClients + 1);
- if (MatchmakerAcceptPatches.GClass3163 != null)
+ if (MatchmakerAcceptPatches.GClass3182 != null)
{
if (numbersOfPlayersToWaitFor > 0)
{
- MatchmakerAcceptPatches.GClass3163.ChangeStatus($"Waiting for {numbersOfPlayersToWaitFor} {(numbersOfPlayersToWaitFor > 1 ? "players" : "player")}");
+ MatchmakerAcceptPatches.GClass3182.ChangeStatus($"Waiting for {numbersOfPlayersToWaitFor} {(numbersOfPlayersToWaitFor > 1 ? "players" : "player")}");
}
else
{
- MatchmakerAcceptPatches.GClass3163.ChangeStatus($"All players joined, starting game...");
+ MatchmakerAcceptPatches.GClass3182.ChangeStatus($"All players joined, starting game...");
}
}
else
@@ -1077,18 +1111,22 @@ private async Task SetStatus(LocalPlayer myPlayer, LobbyEntry.ELobbyStatus statu
///
///
///
- public override IEnumerator vmethod_4(float startDelay, BotControllerSettings controllerSettings, ISpawnSystem spawnSystem, Callback runCallback)
+ public override IEnumerator vmethod_4(BotControllerSettings controllerSettings, ISpawnSystem spawnSystem, Callback runCallback)
{
- if (MatchmakerAcceptPatches.IsClient)
+#if DEBUG
+ Logger.LogWarning("CoopGame::vmethod_4");
+#endif
+
+ if (!isServer)
{
controllerSettings.BotAmount = EBotAmount.NoBots;
}
- if (MatchmakerAcceptPatches.IsServer)
+ if (isServer)
{
- BotsPresets profileCreator = new(BackEndSession, wavesSpawnScenario_0.SpawnWaves, GClass579.BossSpawnWaves, nonWavesSpawnScenario_0.GClass1467_0, false);
+ BotsPresets profileCreator = new(BackEndSession, wavesSpawnScenario_0.SpawnWaves, GClass579.BossSpawnWaves, nonWavesSpawnScenario_0.GClass1477_0, false);
- GClass813 botCreator = new(this, profileCreator, CreateBot);
+ GClass814 botCreator = new(this, profileCreator, CreateBot);
BotZone[] botZones = LocationScene.GetAllObjects(false).ToArray();
bool enableWaves = controllerSettings.BotAmount == EBotAmount.Horde;
@@ -1110,7 +1148,7 @@ public override IEnumerator vmethod_4(float startDelay, BotControllerSettings co
_ => 0,
};
- if (MatchmakerAcceptPatches.IsClient)
+ if (!isServer)
{
numberOfBots = 0;
}
@@ -1118,34 +1156,37 @@ public override IEnumerator vmethod_4(float startDelay, BotControllerSettings co
botsController_0.SetSettings(numberOfBots, BackEndSession.BackEndConfig.BotPresets, BackEndSession.BackEndConfig.BotWeaponScatterings);
botsController_0.AddActivePLayer(PlayerOwner.Player);
- int limits = Location_0.Id.ToLower() switch
- {
- "factory4_day" => FikaPlugin.MaxBotsFactory.Value,
- "factory4_night" => FikaPlugin.MaxBotsFactory.Value,
- "bigmap" => FikaPlugin.MaxBotsCustoms.Value,
- "interchange" => FikaPlugin.MaxBotsInterchange.Value,
- "rezervbase" => FikaPlugin.MaxBotsReserve.Value,
- "woods" => FikaPlugin.MaxBotsWoods.Value,
- "shoreline" => FikaPlugin.MaxBotsShoreline.Value,
- "tarkovstreets" => FikaPlugin.MaxBotsStreets.Value,
- "sandbox" => FikaPlugin.MaxBotsGroundZero.Value,
- "laboratory" => FikaPlugin.MaxBotsLabs.Value,
- "lighthouse" => FikaPlugin.MaxBotsLighthouse.Value,
- _ => 0
- };
-
- if (limits > 0)
+ if (FikaPlugin.EnforcedSpawnLimits.Value)
{
- botsController_0.BotSpawner.SetMaxBots(limits);
+ int limits = Location_0.Id.ToLower() switch
+ {
+ "factory4_day" => FikaPlugin.MaxBotsFactory.Value,
+ "factory4_night" => FikaPlugin.MaxBotsFactory.Value,
+ "bigmap" => FikaPlugin.MaxBotsCustoms.Value,
+ "interchange" => FikaPlugin.MaxBotsInterchange.Value,
+ "rezervbase" => FikaPlugin.MaxBotsReserve.Value,
+ "woods" => FikaPlugin.MaxBotsWoods.Value,
+ "shoreline" => FikaPlugin.MaxBotsShoreline.Value,
+ "tarkovstreets" => FikaPlugin.MaxBotsStreets.Value,
+ "sandbox" => FikaPlugin.MaxBotsGroundZero.Value,
+ "laboratory" => FikaPlugin.MaxBotsLabs.Value,
+ "lighthouse" => FikaPlugin.MaxBotsLighthouse.Value,
+ _ => 0
+ };
+
+ if (limits > 0)
+ {
+ botsController_0.BotSpawner.SetMaxBots(limits);
+ }
}
- dynamicAI = gameObject.AddComponent();
+ DynamicAI = gameObject.AddComponent();
}
- else if (MatchmakerAcceptPatches.IsClient)
+ else
{
BotsPresets profileCreator = new(BackEndSession, [], [], [], false);
- GClass813 botCreator = new(this, profileCreator, CreateBot);
+ GClass814 botCreator = new(this, profileCreator, CreateBot);
BotZone[] botZones = LocationScene.GetAllObjects(false).ToArray();
// Setting this to an empty array stops the client from downloading bots
@@ -1161,27 +1202,31 @@ public override IEnumerator vmethod_4(float startDelay, BotControllerSettings co
BackendConfigSettingsClass instance = Singleton.Instance;
- bool isWinter = BackEndSession.IsWinter;
- Class420 winterEventController = new();
- Singleton.Instance.Class420_0 = winterEventController;
- winterEventController.Run(isWinter).HandleExceptions();
+ LocalGame.Class1387 seasonTaskHandler = new();
+ ESeason season = ginterface158_0.Season;
+ Class393 seasonHandler = new();
+ Singleton.Instance.GInterface26_0 = seasonHandler;
+ seasonTaskHandler.task = seasonHandler.Run(season);
+ yield return new WaitUntil(new Func(seasonTaskHandler.method_0));
- if (startDelay < 5)
+ int timeBeforeDeployLocal = Singleton.Instance.TimeBeforeDeployLocal;
+
+ if (timeBeforeDeployLocal < 5)
{
- startDelay = 5;
+ timeBeforeDeployLocal = 5;
NotificationManagerClass.DisplayWarningNotification("You have set the deploy timer too low, resetting to 5!");
}
- DeployScreen(startDelay);
+ yield return WaitForOtherPlayers();
- if (MatchmakerAcceptPatches.IsServer)
+ if (isServer)
{
while (Singleton.Instance.ReadyClients < MatchmakerAcceptPatches.HostExpectedNumberOfPlayers && !forceStart)
{
yield return new WaitForEndOfFrame();
}
}
- else if (MatchmakerAcceptPatches.IsClient)
+ else
{
while (Singleton.Instance.ReadyClients < MatchmakerAcceptPatches.HostExpectedNumberOfPlayers && !forceStart)
{
@@ -1189,37 +1234,47 @@ public override IEnumerator vmethod_4(float startDelay, BotControllerSettings co
}
}
- yield return new WaitForSeconds(startDelay);
-
- if (MatchmakerAcceptPatches.IsServer)
+ if (isServer)
{
if (Location_0.OldSpawn && wavesSpawnScenario_0.SpawnWaves != null && wavesSpawnScenario_0.SpawnWaves.Length != 0)
{
Logger.LogInfo("Running old spawn system. Waves: " + wavesSpawnScenario_0.SpawnWaves.Length);
- wavesSpawnScenario_0?.Run(EBotsSpawnMode.Anyway);
+ if (wavesSpawnScenario_0 != null)
+ {
+ wavesSpawnScenario_0.Run(EBotsSpawnMode.Anyway);
+ }
}
if (Location_0.NewSpawn)
{
Logger.LogInfo("Running new spawn system.");
- nonWavesSpawnScenario_0?.Run();
+ if (nonWavesSpawnScenario_0 != null)
+ {
+ nonWavesSpawnScenario_0.Run();
+ }
}
GClass579.Run(EBotsSpawnMode.Anyway);
FikaPlugin.DynamicAI.SettingChanged += DynamicAI_SettingChanged;
+ FikaPlugin.DynamicAIRate.SettingChanged += DynamicAIRate_SettingChanged;
}
else
{
- wavesSpawnScenario_0?.Stop();
- nonWavesSpawnScenario_0?.Stop();
- GClass579?.Stop();
+ if (wavesSpawnScenario_0 != null)
+ {
+ wavesSpawnScenario_0.Stop();
+ }
+ if (nonWavesSpawnScenario_0 != null)
+ {
+ nonWavesSpawnScenario_0.Stop();
+ }
+ if (GClass579 != null)
+ {
+ GClass579.Stop();
+ }
}
- yield return new WaitForEndOfFrame();
-
- CreateExfiltrationPointAndInitDeathHandler();
-
// Add FreeCamController to GameWorld GameObject
Singleton.Instance.gameObject.GetOrAddComponent();
Singleton.Instance.gameObject.GetOrAddComponent();
@@ -1232,16 +1287,25 @@ public override IEnumerator vmethod_4(float startDelay, BotControllerSettings co
Singleton.Instance.MineManager.OnExplosion += OnMineExplode;
}
- runCallback.Succeed();
+ Singleton.Instance.TimeBeforeDeployLocal = Math.Max(Singleton.Instance.TimeBeforeDeployLocal, 5);
+ yield return base.vmethod_4(controllerSettings, spawnSystem, runCallback);
yield break;
}
+ private void DynamicAIRate_SettingChanged(object sender, EventArgs e)
+ {
+ if (DynamicAI != null)
+ {
+ DynamicAI.RateChanged(FikaPlugin.DynamicAIRate.Value);
+ }
+ }
+
private void DynamicAI_SettingChanged(object sender, EventArgs e)
{
- if (dynamicAI != null)
+ if (DynamicAI != null)
{
- dynamicAI.SettingChanged(FikaPlugin.DynamicAI.Value);
+ DynamicAI.EnabledChange(FikaPlugin.DynamicAI.Value);
}
}
@@ -1254,14 +1318,14 @@ private void SetupBorderzones()
gameWorld.BorderZones[i].Id = i;
}
- if (MatchmakerAcceptPatches.IsServer)
+ if (isServer)
{
foreach (BorderZone borderZone in gameWorld.BorderZones)
{
borderZone.PlayerShotEvent += OnBorderZoneShot;
}
}
- else if (MatchmakerAcceptPatches.IsClient)
+ else
{
foreach (BorderZone borderZone in gameWorld.BorderZones)
{
@@ -1270,7 +1334,7 @@ private void SetupBorderzones()
}
}
- private void OnBorderZoneShot(GInterface94 player, BorderZone zone, float arg3, bool arg4)
+ private void OnBorderZoneShot(GInterface106 player, BorderZone zone, float arg3, bool arg4)
{
BorderZonePacket packet = new()
{
@@ -1291,29 +1355,35 @@ private void OnMineExplode(MineDirectional directional)
{
MinePositon = directional.transform.position
};
- if (MatchmakerAcceptPatches.IsClient)
+ if (!isServer)
{
Singleton.Instance.SendData(new NetDataWriter(), ref packet, LiteNetLib.DeliveryMethod.ReliableOrdered);
}
- else if (MatchmakerAcceptPatches.IsServer)
+ else
{
Singleton.Instance.SendDataToAll(new NetDataWriter(), ref packet, LiteNetLib.DeliveryMethod.ReliableOrdered);
}
}
- public void CreateExfiltrationPointAndInitDeathHandler()
+ public override void vmethod_5()
{
Logger.LogInfo("CreateExfiltrationPointAndInitDeathHandler");
- GameTimer.Start();
- gparam_0.vmethod_0();
+ GameTimer.Start(null, null);
gparam_0.Player.HealthController.DiedEvent += HealthController_DiedEvent;
+ gparam_0.vmethod_0();
+
+ SkillClass[] skills = Profile_0.Skills.Skills;
+ for (int i = 0; i < skills.Length; i++)
+ {
+ skills[i].SetPointsEarnedInSession(0f, false);
+ }
InfiltrationPoint = spawnPoint.Infiltration;
Profile_0.Info.EntryPoint = InfiltrationPoint;
Logger.LogDebug("SpawnPoint: " + spawnPoint.Id + ", InfiltrationPoint: " + InfiltrationPoint);
- if (MatchmakerAcceptPatches.IsClient)
+ if (!isServer)
{
CarExtraction carExtraction = FindObjectOfType();
if (carExtraction != null)
@@ -1322,10 +1392,10 @@ public void CreateExfiltrationPointAndInitDeathHandler()
}
}
- ExfiltrationControllerClass.Instance.InitAllExfiltrationPoints(Location_0.exits, MatchmakerAcceptPatches.IsClient, "");
+ ExfiltrationControllerClass.Instance.InitAllExfiltrationPoints(Location_0.exits, !isServer, "");
ExfiltrationPoint[] exfilPoints = ExfiltrationControllerClass.Instance.EligiblePoints(Profile_0);
- GameUi.TimerPanel.SetTime(GClass1296.UtcNow, Profile_0.Info.Side, GameTimer.SessionSeconds(), exfilPoints);
+ GameUi.TimerPanel.SetTime(GClass1304.UtcNow, Profile_0.Info.Side, GameTimer.SessionSeconds(), exfilPoints);
exfilManager = gameObject.AddComponent();
exfilManager.Run(exfilPoints);
@@ -1343,11 +1413,11 @@ public void CreateExfiltrationPointAndInitDeathHandler()
{
if (CoopHandler.TryGetCoopHandler(out CoopHandler coopHandler))
{
- if (MatchmakerAcceptPatches.IsServer)
+ if (isServer)
{
coopHandler.serverBTR = gameWorld.gameObject.AddComponent();
}
- else if (MatchmakerAcceptPatches.IsClient)
+ else
{
coopHandler.clientBTR = gameWorld.gameObject.AddComponent();
}
@@ -1360,7 +1430,7 @@ public void CreateExfiltrationPointAndInitDeathHandler()
}
}
- dateTime_0 = GClass1296.Now;
+ dateTime_0 = GClass1304.Now;
Status = GameStatus.Started;
ConsoleScreen.ApplyStartCommands();
}
@@ -1379,7 +1449,7 @@ public void ResetExfilPointsFromServer(ExfiltrationPoint[] points)
}
currentExfils.Clear();
- GameUi.TimerPanel.SetTime(GClass1296.UtcNow, Profile_0.Info.Side, GameTimer.SessionSeconds(), points);
+ GameUi.TimerPanel.SetTime(GClass1304.UtcNow, Profile_0.Info.Side, GameTimer.SessionSeconds(), points);
}
public List ExtractedPlayers { get; } = [];
@@ -1389,10 +1459,15 @@ public void ResetExfilPointsFromServer(ExfiltrationPoint[] points)
///
/// The local player to start the Coroutine on
///
- public void Extract(Player player, ExfiltrationPoint point)
+ public void Extract(CoopPlayer player, ExfiltrationPoint point)
{
PreloaderUI preloaderUI = Singleton.Instance;
+ if (MyExitStatus == ExitStatus.MissingInAction)
+ {
+ NotificationManagerClass.DisplayMessageNotification("You have gone missing in action...", iconType: EFT.Communications.ENotificationIconType.Alert, textColor: Color.red);
+ }
+
if (point != null)
{
point.Disable();
@@ -1416,19 +1491,19 @@ public void Extract(Player player, ExfiltrationPoint point)
GenericPacket genericPacket = new()
{
- NetId = ((CoopPlayer)player).NetId,
+ NetId = player.NetId,
PacketType = EPackageType.ClientExtract
};
try // This is to allow clients to extract if they lose connection
{
- if (MatchmakerAcceptPatches.IsClient)
+ if (!isServer)
{
- Singleton.Instance?.SendData(new NetDataWriter(), ref genericPacket, LiteNetLib.DeliveryMethod.ReliableOrdered);
+ Singleton.Instance.SendData(new NetDataWriter(), ref genericPacket, LiteNetLib.DeliveryMethod.ReliableOrdered);
}
- else if (MatchmakerAcceptPatches.IsServer)
+ else
{
- Singleton.Instance?.SendDataToAll(new NetDataWriter(), ref genericPacket, LiteNetLib.DeliveryMethod.ReliableOrdered);
+ Singleton.Instance.SendDataToAll(new NetDataWriter(), ref genericPacket, LiteNetLib.DeliveryMethod.ReliableOrdered);
ClearHostAI(player);
}
}
@@ -1439,7 +1514,7 @@ public void Extract(Player player, ExfiltrationPoint point)
CoopHandler coopHandler = CoopHandler.GetCoopHandler();
- CoopPlayer coopPlayer = (CoopPlayer)player;
+ CoopPlayer coopPlayer = player;
ExtractedPlayers.Add(coopPlayer.NetId);
coopHandler.ExtractedPlayers.Add(coopPlayer.NetId);
coopHandler.Players.Remove(coopPlayer.NetId);
@@ -1451,14 +1526,15 @@ public void Extract(Player player, ExfiltrationPoint point)
player.ActiveHealthController.DisableMetabolism();
player.ActiveHealthController.PauseAllEffects();
+ extractRoutine = StartCoroutine(ExtractRoutine(player));
+
// Prevents players from looting after extracting
- GClass3107.Instance.CloseAllScreensForced();
+ GClass3126.Instance.CloseAllScreensForced();
// Detroys session timer
- EndByTimerScenario endByTimerScenario = GetComponent();
- if (endByTimerScenario != null)
+ if (timeManager != null)
{
- Destroy(endByTimerScenario);
+ Destroy(timeManager);
}
if (GameUi.TimerPanel.enabled)
{
@@ -1469,24 +1545,48 @@ public void Extract(Player player, ExfiltrationPoint point)
if (FikaPlugin.AutoExtract.Value)
{
- if (MatchmakerAcceptPatches.IsClient)
+ if (!isServer)
{
Stop(coopHandler.MyPlayer.ProfileId, MyExitStatus, coopHandler.MyPlayer.ActiveHealthController.IsAlive ? MyExitLocation : null, 0);
}
- else if (MatchmakerAcceptPatches.IsServer && Singleton.Instance.NetServer.ConnectedPeersCount == 0)
+ else if (Singleton.Instance.NetServer.ConnectedPeersCount == 0)
{
Stop(coopHandler.MyPlayer.ProfileId, MyExitStatus, coopHandler.MyPlayer.ActiveHealthController.IsAlive ? MyExitLocation : null, 0);
}
}
}
+ ///
+ /// Used to make sure no stims or mods reset the DamageCoeff
+ ///
+ /// The to run the coroutine on
+ ///
+ private IEnumerator ExtractRoutine(CoopPlayer player)
+ {
+ while (true)
+ {
+ if (player != null && player.ActiveHealthController != null)
+ {
+ if (player.ActiveHealthController.DamageCoeff != 0)
+ {
+ player.ActiveHealthController.SetDamageCoeff(0);
+ }
+ }
+ else
+ {
+ yield break;
+ }
+ yield return new WaitForEndOfFrame();
+ }
+ }
+
public void ClearHostAI(Player player)
{
if (player != null)
{
if (botsController_0 != null)
{
- foreach (KeyValuePair kvp in botsController_0.Groups())
+ foreach (KeyValuePair kvp in botsController_0.Groups())
{
foreach (BotsGroup botsGroup in kvp.Value.GetGroups(true))
{
@@ -1506,10 +1606,6 @@ public void ClearHostAI(Player player)
}
}
- public ExitStatus MyExitStatus { get; set; } = ExitStatus.Survived;
- public string MyExitLocation { get; set; } = null;
- public ISpawnSystem SpawnSystem { get; set; }
-
private void HealthController_DiedEvent(EDamageType obj)
{
gparam_0.Player.HealthController.DiedEvent -= method_15;
@@ -1518,6 +1614,11 @@ private void HealthController_DiedEvent(EDamageType obj)
PlayerOwner.vmethod_1();
MyExitStatus = ExitStatus.Killed;
MyExitLocation = null;
+
+ if (FikaPlugin.Instance.ForceSaveOnDeath)
+ {
+ SavePlayer((CoopPlayer)gparam_0.Player, MyExitStatus, null, true);
+ }
}
public override void Stop(string profileId, ExitStatus exitStatus, string exitName, float delay = 0f)
@@ -1525,7 +1626,19 @@ public override void Stop(string profileId, ExitStatus exitStatus, string exitNa
Logger.LogInfo("CoopGame::Stop");
CoopPlayer myPlayer = (CoopPlayer)Singleton.Instance.MainPlayer;
- myPlayer.PacketSender?.DestroyThis();
+ myPlayer.PacketSender.DestroyThis();
+
+ if (myPlayer.Side != EPlayerSide.Savage)
+ {
+ if (myPlayer.Equipment.GetSlot(EquipmentSlot.Dogtag).ContainedItem != null)
+ {
+ GStruct415 result = InteractionsHandlerClass.Remove(myPlayer.Equipment.GetSlot(EquipmentSlot.Dogtag).ContainedItem, myPlayer.GClass2774_0, false, true);
+ if (result.Error != null)
+ {
+ FikaPlugin.Instance.FikaLogger.LogWarning("CoopGame::Stop: Error removing dog tag!");
+ }
+ }
+ }
if (!myPlayer.ActiveHealthController.IsAlive && exitStatus == ExitStatus.Survived)
{
@@ -1540,15 +1653,24 @@ public override void Stop(string profileId, ExitStatus exitStatus, string exitNa
}
}
- if (MatchmakerAcceptPatches.IsServer)
+ if (isServer)
{
botsController_0.Stop();
botsController_0.DestroyInfo(gparam_0.Player);
}
- GClass579?.Stop();
- nonWavesSpawnScenario_0?.Stop();
- wavesSpawnScenario_0?.Stop();
+ if (GClass579 != null)
+ {
+ GClass579.Stop();
+ }
+ if (nonWavesSpawnScenario_0 != null)
+ {
+ nonWavesSpawnScenario_0.Stop();
+ }
+ if (wavesSpawnScenario_0 != null)
+ {
+ wavesSpawnScenario_0.Stop();
+ }
try
{
@@ -1593,38 +1715,58 @@ public override void Stop(string profileId, ExitStatus exitStatus, string exitNa
Destroy(CoopHandler.CoopHandlerParent);
}
- Class1364 stopManager = new()
- {
- baseLocalGame_0 = this,
- exitStatus = exitStatus,
- exitName = exitName,
- delay = delay
- };
+ ExitManager stopManager = new(this, exitStatus, exitName, delay, myPlayer);
- EndByExitTrigerScenario endByExitTrigger = GetComponent();
- EndByTimerScenario endByTimerScenario = GetComponent();
GameUI gameUI = GameUI.Instance;
- if (endByTimerScenario != null)
- {
- if (Status == GameStatus.Starting || Status == GameStatus.Started)
- {
- endByTimerScenario.GameStatus_0 = GameStatus.SoftStopping;
- }
- }
-
exfilManager.Stop();
Status = GameStatus.Stopping;
GameTimer.TryStop();
- endByExitTrigger.Stop();
if (gameUI.TimerPanel.enabled)
{
gameUI.TimerPanel.Close();
}
- EnvironmentManager.Instance?.Stop();
- MonoBehaviourSingleton.Instance.StartBlackScreenShow(1f, 1f, new Action(stopManager.method_0));
- GClass549.Config.UseSpiritPlayer = false;
+ if (EnvironmentManager.Instance != null)
+ {
+ EnvironmentManager.Instance.Stop();
+ }
+ MonoBehaviourSingleton.Instance.StartBlackScreenShow(1f, 1f, new Action(stopManager.HandleExit));
+ GClass548.Config.UseSpiritPlayer = false;
+ }
+
+ private void SavePlayer(CoopPlayer player, ExitStatus exitStatus, string exitName, bool fromDeath)
+ {
+ if (hasSaved)
+ {
+ return;
+ }
+
+ if (fromDeath)
+ {
+ //Since we're bypassing saving on exiting, run this now.
+ player.Profile.EftStats.LastPlayerState = null;
+ player.StatisticsManager.EndStatisticsSession(exitStatus, PastTime);
+ player.CheckAndResetControllers(exitStatus, PastTime, Location_0.Id, exitName);
+ }
+
+ //Method taken directly from AKI, can be found in the aki-singleplayer assembly as OfflineSaveProfilePatch
+ Type converterClass = typeof(AbstractGame).Assembly.GetTypes().First(t => t.GetField("Converters", BindingFlags.Static | BindingFlags.Public) != null);
+
+ JsonConverter[] Converters = Traverse.Create(converterClass).Field("Converters").Value;
+
+ SaveProfileRequest SaveRequest = new()
+ {
+ Exit = exitStatus.ToString().ToLowerInvariant(),
+ Profile = player.Profile,
+ Health = HealthListener.Instance.CurrentHealth,
+ Insurance = InsuredItemManager.Instance.GetTrackedItems(),
+ IsPlayerScav = player.Side is EPlayerSide.Savage
+ };
+
+ RequestHandler.PutJson("/raid/profile/save", SaveRequest.ToJson(Converters.AddItem(new NotesJsonConverter()).ToArray()));
+
+ hasSaved = true;
}
private void StopFromError(string profileId, ExitStatus exitStatus)
@@ -1632,7 +1774,19 @@ private void StopFromError(string profileId, ExitStatus exitStatus)
Logger.LogInfo("CoopGame::StopFromError");
CoopPlayer myPlayer = (CoopPlayer)Singleton.Instance.MainPlayer;
- myPlayer.PacketSender?.DestroyThis();
+ myPlayer.PacketSender.DestroyThis();
+
+ if (myPlayer.Side != EPlayerSide.Savage)
+ {
+ if (myPlayer.Equipment.GetSlot(EquipmentSlot.Dogtag).ContainedItem != null)
+ {
+ GStruct415 result = InteractionsHandlerClass.Remove(myPlayer.Equipment.GetSlot(EquipmentSlot.Dogtag).ContainedItem, myPlayer.GClass2774_0, false, true);
+ if (result.Error != null)
+ {
+ FikaPlugin.Instance.FikaLogger.LogWarning("CoopGame::StopFromError: Error removing dog tag!");
+ }
+ }
+ }
string exitName = null;
float delay = 0f;
@@ -1667,11 +1821,18 @@ private void StopFromError(string profileId, ExitStatus exitStatus)
Destroy(CoopHandler.CoopHandlerParent);
}
- GClass579?.Stop();
-
- nonWavesSpawnScenario_0?.Stop();
-
- wavesSpawnScenario_0?.Stop();
+ if (GClass579 != null)
+ {
+ GClass579.Stop();
+ }
+ if (nonWavesSpawnScenario_0 != null)
+ {
+ nonWavesSpawnScenario_0.Stop();
+ }
+ if (wavesSpawnScenario_0 != null)
+ {
+ wavesSpawnScenario_0.Stop();
+ }
ErrorExitManager stopManager = new()
{
@@ -1681,31 +1842,37 @@ private void StopFromError(string profileId, ExitStatus exitStatus)
delay = delay
};
- EndByExitTrigerScenario endByExitTrigger = GetComponent();
- EndByTimerScenario endByTimerScenario = GetComponent();
GameUI gameUI = GameUI.Instance;
- if (endByTimerScenario != null)
+ if (exfilManager != null)
{
- if (Status == GameStatus.Starting || Status == GameStatus.Started)
- {
- endByTimerScenario.GameStatus_0 = GameStatus.SoftStopping;
- }
+ exfilManager.Stop();
}
- exfilManager?.Stop();
-
Status = GameStatus.Stopping;
- GameTimer?.TryStop();
- endByExitTrigger?.Stop();
+ if (GameTimer != null)
+ {
+ GameTimer.TryStop();
+ }
if (gameUI.TimerPanel.enabled)
{
gameUI.TimerPanel.Close();
}
- EnvironmentManager.Instance?.Stop();
+ if (EnvironmentManager.Instance != null)
+ {
+ EnvironmentManager.Instance.Stop();
+ }
MonoBehaviourSingleton.Instance.StartBlackScreenShow(1f, 1f, new Action(stopManager.ExitOverride));
- GClass549.Config.UseSpiritPlayer = false;
+ GClass548.Config.UseSpiritPlayer = false;
+ }
+
+ public void ToggleDebug(bool enabled)
+ {
+ if (fikaDebug != null)
+ {
+ fikaDebug.enabled = enabled;
+ }
}
public override void CleanUp()
@@ -1737,13 +1904,15 @@ public override void Dispose()
Singleton.Instance.MineManager.OnExplosion -= OnMineExplode;
}
- if (MatchmakerAcceptPatches.IsServer)
+ if (extractRoutine != null)
{
- CoopPlayer coopPlayer = (CoopPlayer)Singleton.Instance.MainPlayer;
- coopPlayer?.PacketSender.DestroyThis();
+ StopCoroutine(extractRoutine);
+ }
- Singleton.Instance?.NetServer.Stop();
- Singleton.TryRelease(Singleton.Instance);
+ if (isServer)
+ {
+ CoopPlayer coopPlayer = (CoopPlayer)Singleton.Instance.MainPlayer;
+ coopPlayer.PacketSender.DestroyThis();
FikaDynamicAI newDynamicAI = gameObject.GetComponent();
if (newDynamicAI != null)
@@ -1752,16 +1921,16 @@ public override void Dispose()
}
FikaPlugin.DynamicAI.SettingChanged -= DynamicAI_SettingChanged;
+ FikaPlugin.DynamicAIRate.SettingChanged -= DynamicAIRate_SettingChanged;
}
- else if (MatchmakerAcceptPatches.IsClient)
+ else
{
- Singleton.Instance?.NetClient.Stop();
- Singleton.TryRelease(Singleton.Instance);
-
// Resetting this array to null forces the game to re-allocate it if the client hosts the next session
typeof(BotsController).GetField("_allTypes", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Instance).SetValue(botsController_0, null);
}
+ NetManagerUtils.DestroyNetManager(isServer);
+
MatchmakerAcceptPatches.Nodes = null;
MatchmakerAcceptPatches.HostExpectedNumberOfPlayers = 1;
@@ -1784,26 +1953,67 @@ public override void Dispose()
base.Dispose();
}
- private GClass579 GClass579;
- private WavesSpawnScenario wavesSpawnScenario_0;
- private NonWavesSpawnScenario nonWavesSpawnScenario_0;
- private Func func_1;
+ private class ExitManager(CoopGame localGame, ExitStatus exitStatus, string exitName, float delay, CoopPlayer localPlayer)
+ {
+ private readonly CoopGame localGame = localGame;
+ private readonly ExitStatus exitStatus = exitStatus;
+ private readonly string exitName = exitName;
+ private readonly float delay = delay;
+ private readonly CoopPlayer localPlayer = localPlayer;
+ private Action EndAction;
+
+ public void HandleExit()
+ {
+ GClass3126 screenManager = GClass3126.Instance;
+ if (screenManager.CheckCurrentScreen(EEftScreenType.Reconnect))
+ {
+ screenManager.CloseAllScreensForced();
+ }
+ localGame.gparam_0.Player.OnGameSessionEnd(exitStatus, localGame.PastTime, localGame.Location_0.Id, exitName);
+ localGame.CleanUp();
+ localGame.Status = GameStatus.Stopped;
+ TimeSpan timeSpan = GClass1304.Now - localGame.dateTime_0;
+ localGame.ginterface158_0.OfflineRaidEnded(exitStatus, exitName, timeSpan.TotalSeconds).HandleExceptions();
+ MonoBehaviourSingleton.Instance.FadeOutVolumeAfterRaid();
+ StaticManager staticManager = StaticManager.Instance;
+ float num = delay;
+ Action action;
+ if ((action = EndAction) == null)
+ {
+ action = (EndAction = new Action(FireCallback));
+ }
+ staticManager.WaitSeconds(num, action);
+ }
- private class ErrorExitManager : Class1364
+ private void FireCallback()
+ {
+ Callback endCallback = Traverse.Create(localGame).Field("callback_0").GetValue>();
+
+ localGame.SavePlayer(localPlayer, exitStatus, exitName, false);
+
+ endCallback(new Result(exitStatus, GClass1304.Now - localGame.dateTime_0, new MetricsClass()));
+ UIEventSystem.Instance.Enable();
+ }
+ }
+
+ private class ErrorExitManager : Class1382
{
public void ExitOverride()
{
- GClass3107 instance = GClass3107.Instance;
+ GClass3126 instance = GClass3126.Instance;
if (instance != null && instance.CheckCurrentScreen(EEftScreenType.Reconnect))
{
instance.CloseAllScreensForced();
}
- baseLocalGame_0?.CleanUp();
- if (baseLocalGame_0 is not null)
+ if (baseLocalGame_0 != null)
{
+ baseLocalGame_0.CleanUp();
baseLocalGame_0.Status = GameStatus.Stopped;
}
- MonoBehaviourSingleton.Instance?.FadeOutVolumeAfterRaid();
+ if (MonoBehaviourSingleton.Instance != null)
+ {
+ MonoBehaviourSingleton.Instance.FadeOutVolumeAfterRaid();
+ }
MonoBehaviour instance2 = StaticManager.Instance;
float num = delay;
Action action;
@@ -1815,10 +2025,9 @@ public void ExitOverride()
}
}
-
public new void method_6(string backendUrl, string locationId, int variantId)
{
- Logger.LogInfo("CoopGame:method_6");
+ Logger.LogDebug("CoopGame::method_6");
return;
}
}
diff --git a/Fika.Core/Coop/GameMode/IMPTGame.cs b/Fika.Core/Coop/GameMode/IFikaGame.cs
similarity index 100%
rename from Fika.Core/Coop/GameMode/IMPTGame.cs
rename to Fika.Core/Coop/GameMode/IFikaGame.cs
diff --git a/Fika.Core/Coop/Matchmaker/EnvironmentUIRoot_Patch.cs b/Fika.Core/Coop/Matchmaker/EnvironmentUIRoot_Patch.cs
index cedf7b6c..db1816d4 100644
--- a/Fika.Core/Coop/Matchmaker/EnvironmentUIRoot_Patch.cs
+++ b/Fika.Core/Coop/Matchmaker/EnvironmentUIRoot_Patch.cs
@@ -1,5 +1,5 @@
-using Aki.Reflection.Patching;
-using EFT.UI;
+using EFT.UI;
+using SPT.Reflection.Patching;
using System.Reflection;
namespace Fika.Core.Coop.Matchmaker
diff --git a/Fika.Core/Coop/Matchmaker/MatchmakerAccept/MatchmakerAcceptPatches.cs b/Fika.Core/Coop/Matchmaker/MatchmakerAccept/MatchmakerAcceptPatches.cs
index fa521a98..bae39e6a 100644
--- a/Fika.Core/Coop/Matchmaker/MatchmakerAccept/MatchmakerAcceptPatches.cs
+++ b/Fika.Core/Coop/Matchmaker/MatchmakerAccept/MatchmakerAcceptPatches.cs
@@ -30,6 +30,8 @@ public static class MatchmakerAcceptPatches
public static MatchMakerGroupPreview MatchMakerGroupPreview { get; set; }
public static int HostExpectedNumberOfPlayers { get; set; } = 1;
public static WeatherClass[] Nodes { get; set; } = null;
+ public static string RemoteIp;
+ public static int RemotePort;
private static string groupId;
private static long timestamp;
#endregion
@@ -51,7 +53,7 @@ public static object MatchmakerScreenController
}
public static GameObject EnvironmentUIRoot { get; internal set; }
- public static MatchmakerTimeHasCome.GClass3163 GClass3163 { get; internal set; }
+ public static MatchmakerTimeHasCome.GClass3182 GClass3182 { get; internal set; }
#endregion
public static string GetGroupId()
@@ -74,7 +76,7 @@ public static void SetTimestamp(long ts)
timestamp = ts;
}
- public static bool JoinMatch(RaidSettings settings, string profileId, string serverId, out CreateMatch result, out string errorMessage)
+ public static bool JoinMatch(string profileId, string serverId, out CreateMatch result, out string errorMessage)
{
result = new CreateMatch();
errorMessage = $"No server matches the data provided or the server no longer exists";
diff --git a/Fika.Core/Coop/Matchmaker/MatchmakerAccept/MatchmakerAcceptScreen_Awake_Patch.cs b/Fika.Core/Coop/Matchmaker/MatchmakerAccept/MatchmakerAcceptScreen_Awake_Patch.cs
index d01f2324..1d8a37b3 100644
--- a/Fika.Core/Coop/Matchmaker/MatchmakerAccept/MatchmakerAcceptScreen_Awake_Patch.cs
+++ b/Fika.Core/Coop/Matchmaker/MatchmakerAccept/MatchmakerAcceptScreen_Awake_Patch.cs
@@ -1,7 +1,7 @@
-using Aki.Reflection.Patching;
-using Aki.Reflection.Utils;
-using EFT.UI.Matchmaker;
+using EFT.UI.Matchmaker;
using Newtonsoft.Json;
+using SPT.Reflection.Patching;
+using SPT.Reflection.Utils;
using System;
using System.Linq;
using System.Reflection;
diff --git a/Fika.Core/Coop/Matchmaker/MatchmakerAccept/MatchmakerAcceptScreen_Show_Patch.cs b/Fika.Core/Coop/Matchmaker/MatchmakerAccept/MatchmakerAcceptScreen_Show_Patch.cs
index 7e0ba5af..876bebcf 100644
--- a/Fika.Core/Coop/Matchmaker/MatchmakerAccept/MatchmakerAcceptScreen_Show_Patch.cs
+++ b/Fika.Core/Coop/Matchmaker/MatchmakerAccept/MatchmakerAcceptScreen_Show_Patch.cs
@@ -1,8 +1,8 @@
-using Aki.Reflection.Patching;
-using EFT;
+using EFT;
using EFT.UI;
using EFT.UI.Matchmaker;
using Fika.Core.UI.Custom;
+using SPT.Reflection.Patching;
using System.Linq;
using System.Reflection;
using UnityEngine;
@@ -12,12 +12,10 @@ namespace Fika.Core.Coop.Matchmaker
public class MatchmakerAcceptScreen_Show_Patch : ModulePatch
{
protected override MethodBase GetTargetMethod() => typeof(MatchMakerAcceptScreen).GetMethods(BindingFlags.Public | BindingFlags.Instance).First(x => x.Name == "Show" && x.GetParameters()[0].Name == "session");
-
private static GameObject MatchmakerObject { get; set; }
[PatchPrefix]
- private static void PreFix(ref ISession session, ref RaidSettings raidSettings, Profile ___profile_0, MatchMakerAcceptScreen __instance,
- DefaultUIButton ____acceptButton, DefaultUIButton ____backButton, MatchMakerPlayerPreview ____playerModelView)
+ private static void PreFix(ref RaidSettings raidSettings, DefaultUIButton ____acceptButton, DefaultUIButton ____backButton)
{
if (MatchmakerObject == null)
{
diff --git a/Fika.Core/Coop/ObservedClasses/CoopObservedStatisticsManager.cs b/Fika.Core/Coop/ObservedClasses/CoopObservedStatisticsManager.cs
index 951f304c..68d6dc5e 100644
--- a/Fika.Core/Coop/ObservedClasses/CoopObservedStatisticsManager.cs
+++ b/Fika.Core/Coop/ObservedClasses/CoopObservedStatisticsManager.cs
@@ -46,12 +46,12 @@ public void Init(Player player)
Player = player;
}
- public void OnEnemyDamage(DamageInfo damage, EBodyPart bodyPart, EPlayerSide playerSide, string role, string groupId, float fullHealth, bool isHeavyDamage, float distance, int hour, List targetEquipment, HealthEffects enemyEffects, List zoneIds)
+ public void OnEnemyDamage(DamageInfo damage, EBodyPart bodyPart, EPlayerSide playerSide, WildSpawnType role, string groupId, float fullHealth, bool isHeavyDamage, float distance, int hour, List targetEquipment, HealthEffects enemyEffects, List zoneIds)
{
// Do nothing
}
- public void OnEnemyKill(DamageInfo damage, EDamageType lethalDamageType, EBodyPart bodyPart, EPlayerSide playerSide, WildSpawnType role, string playerAccountId, string playerProfileId, string playerName, string groupId, int level, int killExp, float distance, int hour, List targetEquipment, HealthEffects enemyEffects, List zoneIds, bool isFriendly)
+ public void OnEnemyKill(DamageInfo damage, EDamageType lethalDamageType, EBodyPart bodyPart, EPlayerSide playerSide, WildSpawnType role, string playerAccountId, string playerProfileId, string playerName, string groupId, int level, int killExp, float distance, int hour, List targetEquipment, HealthEffects enemyEffects, List zoneIds, bool isFriendly, bool isAI)
{
// Do nothing
}
diff --git a/Fika.Core/Coop/ObservedClasses/HandsControllers/CoopObservedFirearmController.cs b/Fika.Core/Coop/ObservedClasses/HandsControllers/CoopObservedFirearmController.cs
index c3290abb..210dd508 100644
--- a/Fika.Core/Coop/ObservedClasses/HandsControllers/CoopObservedFirearmController.cs
+++ b/Fika.Core/Coop/ObservedClasses/HandsControllers/CoopObservedFirearmController.cs
@@ -5,6 +5,7 @@
using EFT.InventoryLogic;
using Fika.Core.Coop.Players;
using Fika.Core.Networking;
+using HarmonyLib;
using System;
using System.Collections;
using System.Collections.Generic;
@@ -12,9 +13,6 @@
using UnityEngine;
using static EFT.Player;
-// HandsControllerClass::method_10(GClass2249)
-// GClass2370::method_39(GClass2296)
-
namespace Fika.Core.Coop.ObservedClasses
{
public class CoopObservedFirearmController : FirearmController
@@ -28,6 +26,7 @@ public class CoopObservedFirearmController : FirearmController
private float aimMovementSpeed = 1f;
private bool hasFired = false;
private WeaponPrefab weaponPrefab;
+ private GClass1592 underBarrelManager;
public override bool IsAiming
{
get => base.IsAiming;
@@ -62,6 +61,10 @@ protected void Start()
_objectInHandsAnimator.SetAiming(false);
aimMovementSpeed = coopPlayer.Skills.GetWeaponInfo(Item).AimMovementSpeed;
weaponPrefab = ControllerGameObject.GetComponent();
+ if (UnderbarrelWeapon != null)
+ {
+ underBarrelManager = Traverse.Create(this).Field("gclass1592_0").GetValue();
+ }
}
public static CoopObservedFirearmController Create(CoopPlayer player, Weapon weapon)
@@ -127,7 +130,9 @@ public override void OnPlayerDead()
{
triggerPressed = false;
SetTriggerPressed(false);
- WeaponSoundPlayer.enabled = false;
+
+ needsReset = false;
+ WeaponSoundPlayer.OnBreakLoop();
coopPlayer.HandsAnimator.Animator.Update(Time.fixedDeltaTime);
ManualUpdate(Time.fixedDeltaTime);
@@ -136,10 +141,24 @@ public override void OnPlayerDead()
CurrentOperation.FastForward();
}
+ StartCoroutine(BreakFiringLoop());
+
base.OnPlayerDead();
}
- public override void SetScopeMode(GStruct164[] scopeStates)
+ private IEnumerator BreakFiringLoop()
+ {
+ Traverse isFiring = Traverse.Create(WeaponSoundPlayer).Field("_isFiring");
+ int attempts = 0;
+ while (isFiring.Value && attempts < 10)
+ {
+ yield return new WaitForEndOfFrame();
+ WeaponSoundPlayer.OnBreakLoop();
+ attempts++;
+ }
+ }
+
+ public override void SetScopeMode(GStruct165[] scopeStates)
{
_player.ProceduralWeaponAnimation.ObservedCalibration();
base.SetScopeMode(scopeStates);
@@ -215,7 +234,10 @@ public void HandleFirearmPacket(in WeaponPacket packet, InventoryControllerClass
}
else if (packet.ShotInfoPacket.ShotType == EShotType.DryFire)
{
+ FirearmsAnimator.SetFire(true);
DryShot();
+ hasFired = true;
+ lastFireTime = Time.time;
}
else if (packet.ShotInfoPacket.ShotType == EShotType.RegularShot)
{
@@ -234,7 +256,7 @@ public void HandleFirearmPacket(in WeaponPacket packet, InventoryControllerClass
triggerPressed = true;
}
- float pitchMult = method_55();
+ float pitchMult = method_57();
WeaponSoundPlayer.FireBullet(ammo, packet.ShotInfoPacket.ShotPosition, packet.ShotInfoPacket.ShotDirection,
pitchMult, Malfunction, false, IsBirstOf2Start);
@@ -254,6 +276,18 @@ public void HandleFirearmPacket(in WeaponPacket packet, InventoryControllerClass
FirearmsAnimator.SetFire(true);
+ if (packet.ShotInfoPacket.UnderbarrelShot)
+ {
+ if (UnderbarrelWeapon.Chamber.ContainedItem is BulletClass grenadeBullet && !grenadeBullet.IsUsed)
+ {
+ grenadeBullet.IsUsed = true;
+ UnderbarrelWeapon.Chamber.RemoveItem();
+ underBarrelManager?.DestroyPatronInWeapon();
+ }
+ FirearmsAnimator.SetFire(false);
+ return;
+ }
+
if (Weapon.HasChambers)
{
if (Weapon.ReloadMode is Weapon.EReloadMode.OnlyBarrel)
@@ -263,7 +297,7 @@ public void HandleFirearmPacket(in WeaponPacket packet, InventoryControllerClass
if (Weapon.Chambers[i].ContainedItem is BulletClass bClass && !bClass.IsUsed)
{
bClass.IsUsed = true;
- if (weaponPrefab != null && weaponPrefab.ObjectInHands is GClass1668 weaponEffectsManager)
+ if (weaponPrefab != null && weaponPrefab.ObjectInHands is GClass1678 weaponEffectsManager)
{
if (!bClass.AmmoTemplate.RemoveShellAfterFire)
{
@@ -285,7 +319,7 @@ public void HandleFirearmPacket(in WeaponPacket packet, InventoryControllerClass
else
{
Weapon.Chambers[0].RemoveItem(false);
- if (weaponPrefab != null && weaponPrefab.ObjectInHands is GClass1668 weaponEffectsManager)
+ if (weaponPrefab != null && weaponPrefab.ObjectInHands is GClass1678 weaponEffectsManager)
{
HandleShellEvent(weaponEffectsManager, packet, ammo, magazine);
}
@@ -293,7 +327,7 @@ public void HandleFirearmPacket(in WeaponPacket packet, InventoryControllerClass
}
// Remember to check if classes increment
- if (Weapon is GClass2696)
+ if (Weapon is GClass2708)
{
Weapon.CylinderHammerClosed = Weapon.FireMode.FireMode == Weapon.EFireMode.doubleaction;
@@ -326,7 +360,7 @@ public void HandleFirearmPacket(in WeaponPacket packet, InventoryControllerClass
{
if (Item.HasChambers)
{
- magazine.Cartridges.PopTo(inventoryController, new GClass2767(Item.Chambers[0]));
+ magazine.Cartridges.PopTo(inventoryController, new GClass2780(Item.Chambers[0]));
}
else
{
@@ -341,7 +375,7 @@ public void HandleFirearmPacket(in WeaponPacket packet, InventoryControllerClass
if (ammo.AmmoTemplate.IsLightAndSoundShot)
{
- method_56(packet.ShotInfoPacket.ShotPosition, packet.ShotInfoPacket.ShotDirection);
+ method_58(packet.ShotInfoPacket.ShotPosition, packet.ShotInfoPacket.ShotDirection);
LightAndSoundShot(packet.ShotInfoPacket.ShotPosition, packet.ShotInfoPacket.ShotDirection, ammo.AmmoTemplate);
}
}
@@ -384,7 +418,7 @@ public void HandleFirearmPacket(in WeaponPacket packet, InventoryControllerClass
if (packet.ChangeSightMode)
{
- SetScopeMode(packet.ScopeStatesPacket.GStruct164);
+ SetScopeMode(packet.ScopeStatesPacket.GStruct165);
}
if (packet.ToggleLauncher)
@@ -420,7 +454,7 @@ public void HandleFirearmPacket(in WeaponPacket packet, InventoryControllerClass
FikaPlugin.Instance.FikaLogger.LogError($"CoopObservedFirearmController::HandleFirearmPacket: There is no item {packet.ReloadMagPacket.MagId} in profile {coopPlayer.ProfileId}");
throw;
}
- GClass2769 gridItemAddress = null;
+ GClass2782 gridItemAddress = null;
if (packet.ReloadMagPacket.LocationDescription != null)
{
using MemoryStream memoryStream = new(packet.ReloadMagPacket.LocationDescription);
@@ -429,7 +463,7 @@ public void HandleFirearmPacket(in WeaponPacket packet, InventoryControllerClass
{
if (packet.ReloadMagPacket.LocationDescription.Length != 0)
{
- GClass1528 descriptor = binaryReader.ReadEFTGridItemAddressDescriptor();
+ GClass1538 descriptor = binaryReader.ReadEFTGridItemAddressDescriptor();
gridItemAddress = inventoryController.ToGridItemAddress(descriptor);
}
}
@@ -486,7 +520,7 @@ public void HandleFirearmPacket(in WeaponPacket packet, InventoryControllerClass
if (packet.ReloadWithAmmo.Status == FikaSerialization.ReloadWithAmmoPacket.EReloadWithAmmoStatus.StartReload)
{
List bullets = FindAmmoByIds(packet.ReloadWithAmmo.AmmoIds);
- GClass2495 ammoPack = new(bullets);
+ GClass2506 ammoPack = new(bullets);
if (!packet.HasCylinderMagPacket)
{
CurrentOperation.ReloadWithAmmo(ammoPack, null, null);
@@ -512,7 +546,7 @@ public void HandleFirearmPacket(in WeaponPacket packet, InventoryControllerClass
if (packet.ReloadWithAmmo.Status == FikaSerialization.ReloadWithAmmoPacket.EReloadWithAmmoStatus.StartReload)
{
List bullets = FindAmmoByIds(packet.ReloadWithAmmo.AmmoIds);
- GClass2495 ammoPack = new(bullets);
+ GClass2506 ammoPack = new(bullets);
ReloadCylinderMagazine(ammoPack, null);
}
}
@@ -525,7 +559,7 @@ public void HandleFirearmPacket(in WeaponPacket packet, InventoryControllerClass
}*/
- if (packet.HasRollCylinder && Weapon is GClass2696 rollWeapon)
+ if (packet.HasRollCylinder && Weapon is GClass2708 rollWeapon)
{
RollCylinder(packet.RollToZeroCamora);
}
@@ -535,7 +569,7 @@ public void HandleFirearmPacket(in WeaponPacket packet, InventoryControllerClass
if (packet.ReloadLauncher.Reload)
{
List ammo = FindAmmoByIds(packet.ReloadLauncher.AmmoIds);
- GClass2495 ammoPack = new(ammo);
+ GClass2506 ammoPack = new(ammo);
ReloadGrenadeLauncher(ammoPack, null);
}
}
@@ -546,9 +580,9 @@ public void HandleFirearmPacket(in WeaponPacket packet, InventoryControllerClass
{
List ammo = FindAmmoByIds(packet.ReloadBarrels.AmmoIds);
- GClass2495 ammoPack = new(ammo);
+ GClass2506 ammoPack = new(ammo);
- GClass2769 gridItemAddress = null;
+ GClass2782 gridItemAddress = null;
using MemoryStream memoryStream = new(packet.ReloadBarrels.LocationDescription);
using BinaryReader binaryReader = new(memoryStream);
@@ -556,7 +590,7 @@ public void HandleFirearmPacket(in WeaponPacket packet, InventoryControllerClass
{
if (packet.ReloadBarrels.LocationDescription.Length > 0)
{
- GClass1528 descriptor = binaryReader.ReadEFTGridItemAddressDescriptor();
+ GClass1538 descriptor = binaryReader.ReadEFTGridItemAddressDescriptor();
gridItemAddress = inventoryController.ToGridItemAddress(descriptor);
}
}
@@ -594,6 +628,16 @@ public void HandleFirearmPacket(in WeaponPacket packet, InventoryControllerClass
{
StartCoroutine(ObservedBoltAction(FirearmsAnimator, this, inventoryController));
}
+
+ if (packet.UnderbarrelSightingRangeUp)
+ {
+ UnderbarrelSightingRangeUp();
+ }
+
+ if (packet.UnderbarrelSightingRangeDown)
+ {
+ UnderbarrelSightingRangeDown();
+ }
}
private IEnumerator ObservedBoltAction(FirearmsAnimator animator, FirearmController controller, InventoryControllerClass inventoryController)
@@ -603,7 +647,7 @@ private IEnumerator ObservedBoltAction(FirearmsAnimator animator, FirearmControl
yield return new WaitForSeconds(0.75f);
- if (weaponPrefab != null && weaponPrefab.ObjectInHands is GClass1668 weaponEffectsManager)
+ if (weaponPrefab != null && weaponPrefab.ObjectInHands is GClass1678 weaponEffectsManager)
{
weaponEffectsManager.StartSpawnShell(coopPlayer.Velocity * 0.33f, 0);
}
@@ -612,14 +656,14 @@ private IEnumerator ObservedBoltAction(FirearmsAnimator animator, FirearmControl
if (controller.Item.GetCurrentMagazine() != null && magazine is not CylinderMagazineClass)
{
- magazine.Cartridges.PopTo(inventoryController, new GClass2767(controller.Item.Chambers[0]));
+ magazine.Cartridges.PopTo(inventoryController, new GClass2780(controller.Item.Chambers[0]));
}
animator.SetBoltActionReload(false);
animator.SetFire(false);
}
- private void HandleShellEvent(GClass1668 weaponEffectsManager, WeaponPacket packet, BulletClass ammo, MagazineClass magazine)
+ private void HandleShellEvent(GClass1678 weaponEffectsManager, WeaponPacket packet, BulletClass ammo, MagazineClass magazine)
{
weaponEffectsManager.DestroyPatronInWeapon(packet.ShotInfoPacket.ChamberIndex);
if (!ammo.AmmoTemplate.RemoveShellAfterFire)
@@ -637,7 +681,7 @@ private void HandleShellEvent(GClass1668 weaponEffectsManager, WeaponPacket pack
weaponEffectsManager.SetRoundIntoWeapon(ammo, 0);
}
- if (Weapon is GClass2696 || Weapon.ReloadMode == Weapon.EReloadMode.OnlyBarrel || Weapon.BoltAction)
+ if (Weapon is GClass2708 || Weapon.ReloadMode == Weapon.EReloadMode.OnlyBarrel || Weapon.BoltAction)
{
return;
}
diff --git a/Fika.Core/Coop/ObservedClasses/HandsControllers/CoopObservedGrenadeController.cs b/Fika.Core/Coop/ObservedClasses/HandsControllers/CoopObservedGrenadeController.cs
index c71583e5..77d1e117 100644
--- a/Fika.Core/Coop/ObservedClasses/HandsControllers/CoopObservedGrenadeController.cs
+++ b/Fika.Core/Coop/ObservedClasses/HandsControllers/CoopObservedGrenadeController.cs
@@ -51,10 +51,10 @@ public static CoopObservedGrenadeController Create(CoopPlayer player, GrenadeCla
};
}*/
- private void CreateGrenadeClass1()
+ /*private void CreateGrenadeClass1()
{
- }
+ }*/
public override bool CanChangeCompassState(bool newState)
{
diff --git a/Fika.Core/Coop/ObservedClasses/MovementStates/ObservedRunState.cs b/Fika.Core/Coop/ObservedClasses/MovementStates/ObservedRunState.cs
index c9bbc2f6..a0e31940 100644
--- a/Fika.Core/Coop/ObservedClasses/MovementStates/ObservedRunState.cs
+++ b/Fika.Core/Coop/ObservedClasses/MovementStates/ObservedRunState.cs
@@ -4,7 +4,7 @@
namespace Fika.Core.Coop.ObservedClasses.MovementStates
{
- internal class ObservedRunState : GClass1705
+ internal class ObservedRunState : GClass1715
{
public ObservedRunState(MovementContext movementContext) : base(movementContext)
{
diff --git a/Fika.Core/Coop/ObservedClasses/MovementStates/ObservedSprintState.cs b/Fika.Core/Coop/ObservedClasses/MovementStates/ObservedSprintState.cs
index 1b52dabf..6786566a 100644
--- a/Fika.Core/Coop/ObservedClasses/MovementStates/ObservedSprintState.cs
+++ b/Fika.Core/Coop/ObservedClasses/MovementStates/ObservedSprintState.cs
@@ -5,7 +5,7 @@
namespace Fika.Core.Coop.ObservedClasses.MovementStates
{
- internal class ObservedSprintState : GClass1705
+ internal class ObservedSprintState : GClass1715
{
public ObservedSprintState(MovementContext movementContext) : base(movementContext)
{
@@ -37,7 +37,7 @@ public override void ManualAnimatorMoveUpdate(float deltaTime)
/*MovementContext.ProcessSpeedLimits(deltaTime);*/
MovementContext.MovementDirection = Vector2.Lerp(MovementContext.MovementDirection, Direction, deltaTime * EFTHardSettings.Instance.DIRECTION_LERP_SPEED);
//MovementContext.ApplyRotation(Quaternion.AngleAxis(MovementContext.Yaw, Vector3.up));
- MovementContext.SetUpDiscreteDirection(GClass1657.ConvertToMovementDirection(Direction));
+ MovementContext.SetUpDiscreteDirection(GClass1667.ConvertToMovementDirection(Direction));
Direction = Vector2.zero;
MovementContext.SprintAcceleration(deltaTime);
UpdateRotationAndPosition(deltaTime);
diff --git a/Fika.Core/Coop/ObservedClasses/ObservedHealthController.cs b/Fika.Core/Coop/ObservedClasses/ObservedHealthController.cs
index a0379a58..4e4c1821 100644
--- a/Fika.Core/Coop/ObservedClasses/ObservedHealthController.cs
+++ b/Fika.Core/Coop/ObservedClasses/ObservedHealthController.cs
@@ -5,7 +5,7 @@
namespace Fika.Core.Coop.ObservedClasses
{
- public sealed class ObservedHealthController(byte[] serializedState, InventoryControllerClass inventory, SkillManager skills) : GClass2417(serializedState, inventory, skills)
+ public sealed class ObservedHealthController(byte[] serializedState, InventoryControllerClass inventory, SkillManager skills) : GClass2428(serializedState, inventory, skills)
{
public override bool ApplyItem(Item item, EBodyPart bodyPart, float? amount = null)
{
diff --git a/Fika.Core/Coop/PacketHandlers/BotPacketSender.cs b/Fika.Core/Coop/PacketHandlers/BotPacketSender.cs
index 02fc1b1e..4fa2c4dd 100644
--- a/Fika.Core/Coop/PacketHandlers/BotPacketSender.cs
+++ b/Fika.Core/Coop/PacketHandlers/BotPacketSender.cs
@@ -29,6 +29,11 @@ protected void Awake()
player = GetComponent();
}
+ public void Init()
+ {
+
+ }
+
protected void FixedUpdate()
{
if (!Enabled)
@@ -50,7 +55,7 @@ protected void FixedUpdate()
player.hasGround, player.CurrentSurface, player.MovementContext.SurfaceNormal);
Writer.Reset();
- Server?.SendDataToAll(Writer, ref playerStatePacket, DeliveryMethod.Unreliable);
+ Server.SendDataToAll(Writer, ref playerStatePacket, DeliveryMethod.Unreliable);
player.LastDirection = Vector2.zero; // Bots give a constant input for some odd reason, resetting on FixedUpdate should be ok from my testing and does not cause sliding for clients
}
@@ -65,8 +70,8 @@ protected void Update()
WeaponPacket firearmPacket = FirearmPackets.Dequeue();
firearmPacket.NetId = player.NetId;
- Writer?.Reset();
- Server?.SendDataToAll(Writer, ref firearmPacket, DeliveryMethod.ReliableOrdered);
+ Writer.Reset();
+ Server.SendDataToAll(Writer, ref firearmPacket, DeliveryMethod.ReliableOrdered);
}
}
int healthPackets = DamagePackets.Count;
@@ -77,8 +82,8 @@ protected void Update()
DamagePacket healthPacket = DamagePackets.Dequeue();
healthPacket.NetId = player.NetId;
- Writer?.Reset();
- Server?.SendDataToAll(Writer, ref healthPacket, DeliveryMethod.ReliableOrdered);
+ Writer.Reset();
+ Server.SendDataToAll(Writer, ref healthPacket, DeliveryMethod.ReliableOrdered);
}
}
int inventoryPackets = InventoryPackets.Count;
@@ -89,8 +94,8 @@ protected void Update()
InventoryPacket inventoryPacket = InventoryPackets.Dequeue();
inventoryPacket.NetId = player.NetId;
- Writer?.Reset();
- Server?.SendDataToAll(Writer, ref inventoryPacket, DeliveryMethod.ReliableOrdered);
+ Writer.Reset();
+ Server.SendDataToAll(Writer, ref inventoryPacket, DeliveryMethod.ReliableOrdered);
}
}
int commonPlayerPackets = CommonPlayerPackets.Count;
@@ -101,8 +106,8 @@ protected void Update()
CommonPlayerPacket commonPlayerPacket = CommonPlayerPackets.Dequeue();
commonPlayerPacket.NetId = player.NetId;
- Writer?.Reset();
- Server?.SendDataToAll(Writer, ref commonPlayerPacket, DeliveryMethod.ReliableOrdered);
+ Writer.Reset();
+ Server.SendDataToAll(Writer, ref commonPlayerPacket, DeliveryMethod.ReliableOrdered);
}
}
int healthSyncPackets = HealthSyncPackets.Count;
@@ -113,8 +118,8 @@ protected void Update()
HealthSyncPacket healthSyncPacket = HealthSyncPackets.Dequeue();
healthSyncPacket.NetId = player.NetId;
- Writer?.Reset();
- Server?.SendDataToAll(Writer, ref healthSyncPacket, DeliveryMethod.ReliableOrdered);
+ Writer.Reset();
+ Server.SendDataToAll(Writer, ref healthSyncPacket, DeliveryMethod.ReliableOrdered);
}
}
}
diff --git a/Fika.Core/Coop/PacketHandlers/ClientPacketSender.cs b/Fika.Core/Coop/PacketHandlers/ClientPacketSender.cs
index c545e3d6..f1ebb94b 100644
--- a/Fika.Core/Coop/PacketHandlers/ClientPacketSender.cs
+++ b/Fika.Core/Coop/PacketHandlers/ClientPacketSender.cs
@@ -33,7 +33,12 @@ protected void Awake()
{
player = GetComponent();
Client = Singleton.Instance;
+ enabled = false;
+ }
+ public void Init()
+ {
+ enabled = true;
StartCoroutine(SyncWorld());
StartCoroutine(SyncWeather());
}
@@ -53,7 +58,7 @@ protected void FixedUpdate()
player.hasGround, player.CurrentSurface, player.MovementContext.SurfaceNormal);
Writer.Reset();
- Client?.SendData(Writer, ref playerStatePacket, DeliveryMethod.Unreliable);
+ Client.SendData(Writer, ref playerStatePacket, DeliveryMethod.Unreliable);
if (player.MovementIdlingTime > 0.01f)
{
@@ -71,8 +76,8 @@ protected void Update()
WeaponPacket firearmPacket = FirearmPackets.Dequeue();
firearmPacket.NetId = player.NetId;
- Writer?.Reset();
- Client?.SendData(Writer, ref firearmPacket, DeliveryMethod.ReliableOrdered);
+ Writer.Reset();
+ Client.SendData(Writer, ref firearmPacket, DeliveryMethod.ReliableOrdered);
}
}
int healthPackets = DamagePackets.Count;
@@ -83,8 +88,8 @@ protected void Update()
DamagePacket healthPacket = DamagePackets.Dequeue();
healthPacket.NetId = player.NetId;
- Writer?.Reset();
- Client?.SendData(Writer, ref healthPacket, DeliveryMethod.ReliableOrdered);
+ Writer.Reset();
+ Client.SendData(Writer, ref healthPacket, DeliveryMethod.ReliableOrdered);
}
}
int inventoryPackets = InventoryPackets.Count;
@@ -95,8 +100,8 @@ protected void Update()
InventoryPacket inventoryPacket = InventoryPackets.Dequeue();
inventoryPacket.NetId = player.NetId;
- Writer?.Reset();
- Client?.SendData(Writer, ref inventoryPacket, DeliveryMethod.ReliableOrdered);
+ Writer.Reset();
+ Client.SendData(Writer, ref inventoryPacket, DeliveryMethod.ReliableOrdered);
}
}
int commonPlayerPackets = CommonPlayerPackets.Count;
@@ -107,8 +112,8 @@ protected void Update()
CommonPlayerPacket commonPlayerPacket = CommonPlayerPackets.Dequeue();
commonPlayerPacket.NetId = player.NetId;
- Writer?.Reset();
- Client?.SendData(Writer, ref commonPlayerPacket, DeliveryMethod.ReliableOrdered);
+ Writer.Reset();
+ Client.SendData(Writer, ref commonPlayerPacket, DeliveryMethod.ReliableOrdered);
}
}
int healthSyncPackets = HealthSyncPackets.Count;
@@ -119,8 +124,8 @@ protected void Update()
HealthSyncPacket healthSyncPacket = HealthSyncPackets.Dequeue();
healthSyncPacket.NetId = player.NetId;
- Writer?.Reset();
- Client?.SendData(Writer, ref healthSyncPacket, DeliveryMethod.ReliableOrdered);
+ Writer.Reset();
+ Client.SendData(Writer, ref healthSyncPacket, DeliveryMethod.ReliableOrdered);
}
}
if (FikaPlugin.UsePingSystem.Value
@@ -129,7 +134,7 @@ protected void Update()
&& Input.GetKey(FikaPlugin.PingButton.Value.MainKey)
&& FikaPlugin.PingButton.Value.Modifiers.All(Input.GetKey))
{
- player?.Ping();
+ player.Ping();
}
}
@@ -140,10 +145,6 @@ private IEnumerator SyncWorld()
yield return null;
}
- Writer?.Reset();
- SessionSettingsPacket settingsPacket = new(true);
- Client?.SendData(Writer, ref settingsPacket, DeliveryMethod.ReliableOrdered);
-
CoopGame coopGame = (CoopGame)Singleton.Instance;
if (coopGame == null)
@@ -158,13 +159,13 @@ private IEnumerator SyncWorld()
yield return new WaitForSeconds(10f);
- Writer?.Reset();
+ Writer.Reset();
GameTimerPacket gameTimerPacket = new(true);
- Client?.SendData(Writer, ref gameTimerPacket, DeliveryMethod.ReliableOrdered);
+ Client.SendData(Writer, ref gameTimerPacket, DeliveryMethod.ReliableOrdered);
- Writer?.Reset();
+ Writer.Reset();
ExfiltrationPacket exfilPacket = new(true);
- Client?.SendData(Writer, ref exfilPacket, DeliveryMethod.ReliableOrdered);
+ Client.SendData(Writer, ref exfilPacket, DeliveryMethod.ReliableOrdered);
}
private IEnumerator SyncWeather()
@@ -192,8 +193,8 @@ private IEnumerator SyncWeather()
HasData = false
};
- Writer?.Reset();
- Client?.SendData(Writer, ref packet, DeliveryMethod.ReliableOrdered);
+ Writer.Reset();
+ Client.SendData(Writer, ref packet, DeliveryMethod.ReliableOrdered);
}
public void DestroyThis()
diff --git a/Fika.Core/Coop/PacketHandlers/IPacketSender.cs b/Fika.Core/Coop/PacketHandlers/IPacketSender.cs
index bf832a3f..773f4aed 100644
--- a/Fika.Core/Coop/PacketHandlers/IPacketSender.cs
+++ b/Fika.Core/Coop/PacketHandlers/IPacketSender.cs
@@ -18,6 +18,7 @@ public interface IPacketSender
public Queue CommonPlayerPackets { get; set; }
public Queue HealthSyncPackets { get; set; }
+ public void Init();
public void DestroyThis();
}
}
diff --git a/Fika.Core/Coop/PacketHandlers/ObservedPacketSender.cs b/Fika.Core/Coop/PacketHandlers/ObservedPacketSender.cs
index ed74228d..9dbe68a8 100644
--- a/Fika.Core/Coop/PacketHandlers/ObservedPacketSender.cs
+++ b/Fika.Core/Coop/PacketHandlers/ObservedPacketSender.cs
@@ -39,6 +39,11 @@ protected void Awake()
}
}
+ public void Init()
+ {
+
+ }
+
protected void Update()
{
if (player == null || Writer == null)
diff --git a/Fika.Core/Coop/PacketHandlers/PacketReceiver.cs b/Fika.Core/Coop/PacketHandlers/PacketReceiver.cs
index 710bffff..25df953e 100644
--- a/Fika.Core/Coop/PacketHandlers/PacketReceiver.cs
+++ b/Fika.Core/Coop/PacketHandlers/PacketReceiver.cs
@@ -69,7 +69,7 @@ private void Update()
for (int i = 0; i < healthSyncPackets; i++)
{
HealthSyncPacket packet = HealthSyncPackets.Dequeue();
- if (packet.Packet.SyncType == GStruct346.ESyncType.IsAlive && !packet.Packet.Data.IsAlive.IsAlive)
+ if (packet.Packet.SyncType == GStruct347.ESyncType.IsAlive && !packet.Packet.Data.IsAlive.IsAlive)
{
observedPlayer.SetAggressor(packet.KillerId, packet.KillerWeaponId);
observedPlayer.SetInventory(packet.Equipment);
diff --git a/Fika.Core/Coop/PacketHandlers/ServerPacketSender.cs b/Fika.Core/Coop/PacketHandlers/ServerPacketSender.cs
index 99f40b1e..d79150f0 100644
--- a/Fika.Core/Coop/PacketHandlers/ServerPacketSender.cs
+++ b/Fika.Core/Coop/PacketHandlers/ServerPacketSender.cs
@@ -38,16 +38,18 @@ protected void Awake()
{
logger = BepInEx.Logging.Logger.CreateLogSource("ServerPacketSender");
player = GetComponent();
+ enabled = false;
}
- protected void Start()
+ public void Init()
{
+ enabled = true;
StartCoroutine(SendTrainTime());
}
protected void FixedUpdate()
{
- if (player == null || Writer == null)
+ if (player == null || Writer == null || Server == null)
{
return;
}
@@ -60,7 +62,7 @@ protected void FixedUpdate()
player.hasGround, player.CurrentSurface, player.MovementContext.SurfaceNormal);
Writer.Reset();
- Server?.SendDataToAll(Writer, ref playerStatePacket, DeliveryMethod.Unreliable);
+ Server.SendDataToAll(Writer, ref playerStatePacket, DeliveryMethod.Unreliable);
if (player.MovementIdlingTime > 0.01f)
{
@@ -78,8 +80,8 @@ protected void Update()
WeaponPacket firearmPacket = FirearmPackets.Dequeue();
firearmPacket.NetId = player.NetId;
- Writer?.Reset();
- Server?.SendDataToAll(Writer, ref firearmPacket, DeliveryMethod.ReliableOrdered);
+ Writer.Reset();
+ Server.SendDataToAll(Writer, ref firearmPacket, DeliveryMethod.ReliableOrdered);
}
}
int healthPackets = DamagePackets.Count;
@@ -90,8 +92,8 @@ protected void Update()
DamagePacket healthPacket = DamagePackets.Dequeue();
healthPacket.NetId = player.NetId;
- Writer?.Reset();
- Server?.SendDataToAll(Writer, ref healthPacket, DeliveryMethod.ReliableOrdered);
+ Writer.Reset();
+ Server.SendDataToAll(Writer, ref healthPacket, DeliveryMethod.ReliableOrdered);
}
}
int inventoryPackets = InventoryPackets.Count;
@@ -102,8 +104,8 @@ protected void Update()
InventoryPacket inventoryPacket = InventoryPackets.Dequeue();
inventoryPacket.NetId = player.NetId;
- Writer?.Reset();
- Server?.SendDataToAll(Writer, ref inventoryPacket, DeliveryMethod.ReliableOrdered);
+ Writer.Reset();
+ Server.SendDataToAll(Writer, ref inventoryPacket, DeliveryMethod.ReliableOrdered);
}
}
int commonPlayerPackets = CommonPlayerPackets.Count;
@@ -114,8 +116,8 @@ protected void Update()
CommonPlayerPacket commonPlayerPacket = CommonPlayerPackets.Dequeue();
commonPlayerPacket.NetId = player.NetId;
- Writer?.Reset();
- Server?.SendDataToAll(Writer, ref commonPlayerPacket, DeliveryMethod.ReliableOrdered);
+ Writer.Reset();
+ Server.SendDataToAll(Writer, ref commonPlayerPacket, DeliveryMethod.ReliableOrdered);
}
}
int healthSyncPackets = HealthSyncPackets.Count;
@@ -126,8 +128,8 @@ protected void Update()
HealthSyncPacket healthSyncPacket = HealthSyncPackets.Dequeue();
healthSyncPacket.NetId = player.NetId;
- Writer?.Reset();
- Server?.SendDataToAll(Writer, ref healthSyncPacket, DeliveryMethod.ReliableOrdered);
+ Writer.Reset();
+ Server.SendDataToAll(Writer, ref healthSyncPacket, DeliveryMethod.ReliableOrdered);
}
}
if (FikaPlugin.UsePingSystem.Value
@@ -136,7 +138,7 @@ protected void Update()
&& Input.GetKey(FikaPlugin.PingButton.Value.MainKey)
&& FikaPlugin.PingButton.Value.Modifiers.All(Input.GetKey))
{
- player?.Ping();
+ player.Ping();
}
}
@@ -178,8 +180,8 @@ private IEnumerator SendTrainTime()
DepartureTime = time
};
- Writer?.Reset();
- Server?.SendDataToAll(Writer, ref packet, DeliveryMethod.ReliableOrdered);
+ Writer.Reset();
+ Server.SendDataToAll(Writer, ref packet, DeliveryMethod.ReliableOrdered);
}
else
{
diff --git a/Fika.Core/Coop/Patches/AbstractGame/AbstractGame_InRaid_Patch.cs b/Fika.Core/Coop/Patches/AbstractGame/AbstractGame_InRaid_Patch.cs
index 43043ca0..354f9127 100644
--- a/Fika.Core/Coop/Patches/AbstractGame/AbstractGame_InRaid_Patch.cs
+++ b/Fika.Core/Coop/Patches/AbstractGame/AbstractGame_InRaid_Patch.cs
@@ -1,6 +1,6 @@
-using Aki.Reflection.Patching;
-using EFT;
+using EFT;
using Fika.Core.Coop.GameMode;
+using SPT.Reflection.Patching;
using System.Reflection;
namespace Fika.Core.Coop.Patches
@@ -16,7 +16,7 @@ protected override MethodBase GetTargetMethod()
}
[PatchPrefix]
- private static bool PreFix(AbstractGame __instance, bool __result)
+ private static bool PreFix(AbstractGame __instance, ref bool __result)
{
__result = __instance is CoopGame;
return false;
diff --git a/Fika.Core/Coop/Patches/BotCacher_Patch.cs b/Fika.Core/Coop/Patches/BotCacher_Patch.cs
index 815db9b1..90f9e925 100644
--- a/Fika.Core/Coop/Patches/BotCacher_Patch.cs
+++ b/Fika.Core/Coop/Patches/BotCacher_Patch.cs
@@ -1,6 +1,6 @@
-using Aki.Reflection.Patching;
-using EFT;
+using EFT;
using Fika.Core.Coop.Matchmaker;
+using SPT.Reflection.Patching;
using System;
using System.Reflection;
@@ -10,11 +10,11 @@ public class BotCacher_Patch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
- return typeof(GClass532).GetMethod(nameof(GClass532.LoadInternal), BindingFlags.Static | BindingFlags.Public);
+ return typeof(GClass531).GetMethod(nameof(GClass531.LoadInternal), BindingFlags.Static | BindingFlags.Public);
}
[PatchPrefix]
- private static bool PatchPrefix(out GClass531 core, ref bool __result)
+ private static bool PatchPrefix(out GClass530 core, ref bool __result)
{
if (FikaPlugin.Instance.BotDifficulties != null)
{
@@ -22,14 +22,14 @@ private static bool PatchPrefix(out GClass531 core, ref bool __result)
}
else
{
- string text = GClass532.LoadCoreByString();
+ string text = GClass531.LoadCoreByString();
if (text == null)
{
core = null;
__result = false;
return false;
}
- core = GClass531.Create(text);
+ core = GClass530.Create(text);
}
if (MatchmakerAcceptPatches.IsServer)
@@ -42,19 +42,19 @@ private static bool PatchPrefix(out GClass531 core, ref bool __result)
botSettingsComponents = FikaPlugin.Instance.BotDifficulties.GetComponent((BotDifficulty)difficulty, (WildSpawnType)type);
if (botSettingsComponents != null)
{
- if (!GClass532.AllSettings.ContainsKey((BotDifficulty)difficulty, (WildSpawnType)type))
+ if (!GClass531.AllSettings.ContainsKey((BotDifficulty)difficulty, (WildSpawnType)type))
{
- GClass532.AllSettings.Add((BotDifficulty)difficulty, (WildSpawnType)type, botSettingsComponents);
+ GClass531.AllSettings.Add((BotDifficulty)difficulty, (WildSpawnType)type, botSettingsComponents);
}
}
else
{
- botSettingsComponents = GClass532.smethod_1(GClass532.CheckOnExclude((BotDifficulty)difficulty, (WildSpawnType)type), (WildSpawnType)type, false);
+ botSettingsComponents = GClass531.smethod_1(GClass531.CheckOnExclude((BotDifficulty)difficulty, (WildSpawnType)type), (WildSpawnType)type, false);
if (botSettingsComponents != null)
{
- if (!GClass532.AllSettings.ContainsKey((BotDifficulty)difficulty, (WildSpawnType)type))
+ if (!GClass531.AllSettings.ContainsKey((BotDifficulty)difficulty, (WildSpawnType)type))
{
- GClass532.AllSettings.Add((BotDifficulty)difficulty, (WildSpawnType)type, botSettingsComponents);
+ GClass531.AllSettings.Add((BotDifficulty)difficulty, (WildSpawnType)type, botSettingsComponents);
}
}
else
diff --git a/Fika.Core/Coop/Patches/LocalGame/NonWaveSpawnScenario_Patch.cs b/Fika.Core/Coop/Patches/LocalGame/NonWaveSpawnScenario_Patch.cs
index 135572ac..56f382ad 100644
--- a/Fika.Core/Coop/Patches/LocalGame/NonWaveSpawnScenario_Patch.cs
+++ b/Fika.Core/Coop/Patches/LocalGame/NonWaveSpawnScenario_Patch.cs
@@ -1,6 +1,6 @@
-using Aki.Reflection.Patching;
-using EFT;
+using EFT;
using Fika.Core.Coop.Matchmaker;
+using SPT.Reflection.Patching;
using System.Reflection;
namespace Fika.Core.Coop.Patches.LocalGame
diff --git a/Fika.Core/Coop/Patches/LocalGame/TarkovApplication_LocalGameCreator_Patch.cs b/Fika.Core/Coop/Patches/LocalGame/TarkovApplication_LocalGameCreator_Patch.cs
index c84b2c7b..224cadaf 100644
--- a/Fika.Core/Coop/Patches/LocalGame/TarkovApplication_LocalGameCreator_Patch.cs
+++ b/Fika.Core/Coop/Patches/LocalGame/TarkovApplication_LocalGameCreator_Patch.cs
@@ -1,13 +1,16 @@
-using Aki.Reflection.Patching;
-using Comfort.Common;
+using Comfort.Common;
using EFT;
using EFT.InputSystem;
using EFT.UI;
using EFT.UI.Matchmaker;
using Fika.Core.Coop.GameMode;
using Fika.Core.Coop.Matchmaker;
+using Fika.Core.Coop.Utils;
using Fika.Core.Modding;
using Fika.Core.Modding.Events;
+using Fika.Core.Networking.Http;
+using Fika.Core.Networking.Http.Models;
+using SPT.Reflection.Patching;
using System;
using System.Linq;
using System.Reflection;
@@ -21,7 +24,7 @@ namespace Fika.Core.Coop.Patches.LocalGame
///
internal class TarkovApplication_LocalGameCreator_Patch : ModulePatch
{
- protected override MethodBase GetTargetMethod() => typeof(TarkovApplication).GetMethod(nameof(TarkovApplication.method_43));
+ protected override MethodBase GetTargetMethod() => typeof(TarkovApplication).GetMethod(nameof(TarkovApplication.method_47));
static ISession CurrentSession { get; set; }
@@ -31,7 +34,9 @@ public static bool Prefix(TarkovApplication __instance)
Logger.LogDebug("TarkovApplication_LocalGameCreator_Patch:Prefix");
if (MatchmakerAcceptPatches.IsSinglePlayer)
+ {
return true;
+ }
ISession session = __instance.GetClientBackEndSession();
if (session == null)
@@ -46,7 +51,7 @@ public static bool Prefix(TarkovApplication __instance)
}
[PatchPostfix]
- public static async Task Postfix(Task __result, TarkovApplication __instance, TimeAndWeatherSettings timeAndWeather, MatchmakerTimeHasCome.GClass3163 timeHasComeScreenController,
+ public static async Task Postfix(Task __result, TarkovApplication __instance, TimeAndWeatherSettings timeAndWeather, MatchmakerTimeHasCome.GClass3182 timeHasComeScreenController,
RaidSettings ____raidSettings, InputTree ____inputTree, GameDateTime ____localGameDateTime, float ____fixedDeltaTime, string ____backendUrl)
{
if (MatchmakerAcceptPatches.IsSinglePlayer)
@@ -73,24 +78,22 @@ public static async Task Postfix(Task __result, TarkovApplication __instance, Ti
LocationSettingsClass.Location location = ____raidSettings.SelectedLocation;
- MatchmakerAcceptPatches.GClass3163 = timeHasComeScreenController;
+ MatchmakerAcceptPatches.GClass3182 = timeHasComeScreenController;
if (Singleton.Instantiated)
{
Singleton.Instance.Deactivate();
}
- ISession session = CurrentSession;
+ NetManagerUtils.CreateNetManager(MatchmakerAcceptPatches.IsServer);
- /*Profile profile = session.Profile;
- Profile profileScav = session.ProfileOfPet;*/
+ ISession session = CurrentSession;
Profile profile = session.GetProfileBySide(____raidSettings.Side);
profile.Inventory.Stash = null;
profile.Inventory.QuestStashItems = null;
profile.Inventory.DiscardLimits = Singleton.Instance.GetDiscardLimits();
- //____raidSettings.RaidMode = ERaidMode.Online;
Logger.LogDebug("TarkovApplication_LocalGameCreator_Patch:Postfix: Attempt to set Raid Settings");
@@ -98,49 +101,54 @@ public static async Task Postfix(Task __result, TarkovApplication __instance, Ti
if (MatchmakerAcceptPatches.IsClient)
{
- timeHasComeScreenController.ChangeStatus("Joining Coop Game");
+ timeHasComeScreenController.ChangeStatus("Joining coop game...");
+
+ RaidSettingsRequest data = new();
+ RaidSettingsResponse raidSettingsResponse = await FikaRequestHandler.GetRaidSettings(data);
+
+ ____raidSettings.MetabolismDisabled = raidSettingsResponse.MetabolismDisabled;
+ ____raidSettings.PlayersSpawnPlace = (EPlayersSpawnPlace)Enum.Parse(typeof(EPlayersSpawnPlace), raidSettingsResponse.PlayersSpawnPlace);
}
else
{
- timeHasComeScreenController.ChangeStatus("Creating Coop Game");
+ timeHasComeScreenController.ChangeStatus("Creating coop game...");
}
StartHandler startHandler = new(__instance, session.Profile, session.ProfileOfPet, ____raidSettings.SelectedLocation, timeHasComeScreenController);
- CoopGame localGame = CoopGame.Create(____inputTree, profile, ____localGameDateTime,
- session.InsuranceCompany, MonoBehaviourSingleton.Instance,
- MonoBehaviourSingleton.Instance, MonoBehaviourSingleton.Instance,
- MonoBehaviourSingleton.Instance, ____raidSettings.SelectedLocation, timeAndWeather,
- ____raidSettings.WavesSettings, ____raidSettings.SelectedDateTime, new Callback(startHandler.HandleStart),
- ____fixedDeltaTime, EUpdateQueue.Update, session, TimeSpan.FromSeconds(60 * ____raidSettings.SelectedLocation.EscapeTimeLimit), ____raidSettings
- );
- Singleton.Create(localGame);
- FikaEventDispatcher.DispatchEvent(new AbstractGameCreatedEvent(localGame));
+ TimeSpan raidLimits = __instance.method_48(____raidSettings.SelectedLocation.EscapeTimeLimit);
+
+ CoopGame coopGame = CoopGame.Create(____inputTree, profile, ____localGameDateTime, session.InsuranceCompany, MonoBehaviourSingleton.Instance, MonoBehaviourSingleton.Instance,
+ ____raidSettings.SelectedLocation, timeAndWeather, ____raidSettings.WavesSettings, ____raidSettings.SelectedDateTime, new Callback(startHandler.HandleStop),
+ ____fixedDeltaTime, EUpdateQueue.Update, session, raidLimits, ____raidSettings);
+
+ Singleton.Create(coopGame);
+ FikaEventDispatcher.DispatchEvent(new AbstractGameCreatedEvent(coopGame));
if (MatchmakerAcceptPatches.IsClient)
{
- timeHasComeScreenController.ChangeStatus("Joined Coop Game");
+ coopGame.SetMatchmakerStatus("Coop game joined");
}
else
{
- timeHasComeScreenController.ChangeStatus("Created Coop Game");
+ coopGame.SetMatchmakerStatus("Coop game created");
}
- Task finishTask = localGame.InitPlayer(____raidSettings.BotSettings, ____backendUrl, null, new Callback(startHandler.HandleLoadComplete));
+ Task finishTask = coopGame.InitPlayer(____raidSettings.BotSettings, ____backendUrl, new Callback(startHandler.HandleLoadComplete));
__result = Task.WhenAll(finishTask);
}
- private class StartHandler(TarkovApplication tarkovApplication, Profile pmcProfile, Profile scavProfile, LocationSettingsClass.Location location, MatchmakerTimeHasCome.GClass3163 timeHasComeScreenController)
+ private class StartHandler(TarkovApplication tarkovApplication, Profile pmcProfile, Profile scavProfile, LocationSettingsClass.Location location, MatchmakerTimeHasCome.GClass3182 timeHasComeScreenController)
{
private readonly TarkovApplication tarkovApplication = tarkovApplication;
private readonly Profile pmcProfile = pmcProfile;
private readonly Profile scavProfile = scavProfile;
private readonly LocationSettingsClass.Location location = location;
- private readonly MatchmakerTimeHasCome.GClass3163 timeHasComeScreenController = timeHasComeScreenController;
+ private readonly MatchmakerTimeHasCome.GClass3182 timeHasComeScreenController = timeHasComeScreenController;
- public void HandleStart(Result result)
+ public void HandleStop(Result result)
{
- tarkovApplication.method_46(pmcProfile.Id, scavProfile, location, result, timeHasComeScreenController);
+ tarkovApplication.method_50(pmcProfile.Id, scavProfile, location, result, timeHasComeScreenController);
}
public void HandleLoadComplete(IResult error)
diff --git a/Fika.Core/Coop/Patches/LocalGame/WaveSpawnScenario_Patch.cs b/Fika.Core/Coop/Patches/LocalGame/WaveSpawnScenario_Patch.cs
index 32e27772..d46eccdf 100644
--- a/Fika.Core/Coop/Patches/LocalGame/WaveSpawnScenario_Patch.cs
+++ b/Fika.Core/Coop/Patches/LocalGame/WaveSpawnScenario_Patch.cs
@@ -1,6 +1,6 @@
-using Aki.Reflection.Patching;
-using EFT;
+using EFT;
using Fika.Core.Coop.Matchmaker;
+using SPT.Reflection.Patching;
using System.Reflection;
namespace Fika.Core.Coop.Patches.LocalGame
diff --git a/Fika.Core/Coop/Patches/Minefield/Minefield_method_2_Patch.cs b/Fika.Core/Coop/Patches/Minefield/Minefield_method_2_Patch.cs
index f774406f..d4f6ccc3 100644
--- a/Fika.Core/Coop/Patches/Minefield/Minefield_method_2_Patch.cs
+++ b/Fika.Core/Coop/Patches/Minefield/Minefield_method_2_Patch.cs
@@ -1,9 +1,9 @@
-using Aki.Reflection.Patching;
-using Comfort.Common;
+using Comfort.Common;
using EFT;
using EFT.Interactive;
using Fika.Core.Coop.Matchmaker;
using Fika.Core.Coop.Players;
+using SPT.Reflection.Patching;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -65,7 +65,7 @@ private static void DoReplicatedMineDamage(IPlayer player, float distance, bool
IEnumerable enumerable = isCollateral ? player.PlayerBones.BodyPartColliders.Where(new Func(minefield.method_4))
: player.PlayerBones.BodyPartColliders.Where(new Func(minefield.method_5));
- enumerable = enumerable.DistinctBy(new Func(Minefield.Class2286.class2286_0.method_0)).ToArray();
+ enumerable = enumerable.DistinctBy(new Func(Minefield.Class2312.class2312_0.method_0)).ToArray();
enumerable = enumerable.Randomize();
int num3 = ((isCollateral || first) ? UnityEngine.Random.Range(2, enumerable.Count()) : int.MaxValue);
@@ -74,7 +74,7 @@ private static void DoReplicatedMineDamage(IPlayer player, float distance, bool
foreach (BodyPartCollider bodyPartCollider in enumerable)
{
- coopPlayer.PacketSender?.DamagePackets?.Enqueue(new()
+ coopPlayer.PacketSender.DamagePackets.Enqueue(new()
{
DamageInfo = new()
{
diff --git a/Fika.Core/Coop/Players/CoopBot.cs b/Fika.Core/Coop/Players/CoopBot.cs
index e1d594de..a63e88fa 100644
--- a/Fika.Core/Coop/Players/CoopBot.cs
+++ b/Fika.Core/Coop/Players/CoopBot.cs
@@ -40,17 +40,20 @@ public static async Task CreateBot(int playerId, Vector3 position,
string layerName, string prefix, EPointOfView pointOfView, Profile profile, bool aiControl,
EUpdateQueue updateQueue, EUpdateMode armsUpdateMode, EUpdateMode bodyUpdateMode,
CharacterControllerSpawner.Mode characterControllerMode, Func getSensitivity,
- Func getAimingSensitivity, GInterface99 filter)
+ Func getAimingSensitivity, GInterface111 filter)
{
CoopBot player = null;
- player = Create(GClass1388.PLAYER_BUNDLE_NAME, playerId, position, updateQueue, armsUpdateMode,
+ player = Create(GClass1398.PLAYER_BUNDLE_NAME, playerId, position, updateQueue, armsUpdateMode,
bodyUpdateMode, characterControllerMode, getSensitivity, getAimingSensitivity, prefix, aiControl);
player.IsYourPlayer = false;
InventoryControllerClass inventoryController = new CoopBotInventoryController(player, profile, true);
+ player.PacketSender = player.gameObject.AddComponent();
+ player.PacketReceiver = player.gameObject.AddComponent();
+
await player.Init(rotation, layerName, pointOfView, profile, inventoryController,
new CoopBotHealthController(profile.Health, player, inventoryController, profile.Skills, aiControl),
new CoopObservedStatisticsManager(), null, null, filter,
@@ -74,7 +77,7 @@ public override void OnVaulting()
// Do nothing
}
- public override void OnSkillLevelChanged(GClass1766 skill)
+ public override void OnSkillLevelChanged(GClass1776 skill)
{
// Do nothing
}
@@ -98,7 +101,7 @@ public override void CreateMovementContext()
base.ApplyDamageInfo(damageInfo, bodyPartType, colliderType, absorbed);
}*/
- public override GClass1676 ApplyShot(DamageInfo damageInfo, EBodyPart bodyPartType, EBodyPartColliderType colliderType, EArmorPlateCollider armorPlateCollider, GStruct390 shotId)
+ public override GClass1686 ApplyShot(DamageInfo damageInfo, EBodyPart bodyPartType, EBodyPartColliderType colliderType, EArmorPlateCollider armorPlateCollider, GStruct390 shotId)
{
if (damageInfo.Player != null && damageInfo.Player.iPlayer is ObservedCoopPlayer)
{
@@ -118,7 +121,7 @@ public override GClass1676 ApplyShot(DamageInfo damageInfo, EBodyPart bodyPartTy
float damage = damageInfo.Damage;
List list = ProceedDamageThroughArmor(ref damageInfo, colliderType, armorPlateCollider, true);
MaterialType materialType = (flag ? MaterialType.HelmetRicochet : ((list == null || list.Count < 1) ? MaterialType.Body : list[0].Material));
- GClass1676 hitInfo = new()
+ GClass1686 hitInfo = new()
{
PoV = PointOfView,
Penetrated = (string.IsNullOrEmpty(damageInfo.BlockedBy) || string.IsNullOrEmpty(damageInfo.DeflectedBy)),
@@ -137,14 +140,6 @@ public override GClass1676 ApplyShot(DamageInfo damageInfo, EBodyPart bodyPartTy
protected override void Start()
{
- PacketSender = gameObject.AddComponent();
- PacketReceiver = gameObject.AddComponent();
-
- /*if (FikaPlugin.DynamicAI.Value)
- {
- dynamicAi = gameObject.AddComponent();
- }*/
-
if (FikaPlugin.DisableBotMetabolism.Value)
{
HealthController.DisableMetabolism();
@@ -185,23 +180,6 @@ public override void OnDead(EDamageType damageType)
SetupDogTag();
}
- /*DeathPacket packet = new(ProfileId)
- {
- RagdollPacket = new()
- {
- BodyPartColliderType = LastDamageInfo.BodyPartColliderType,
- Direction = LastDamageInfo.Direction,
- Point = LastDamageInfo.HitPoint,
- Force = _corpseAppliedForce,
- OverallVelocity = Velocity
- },
- HasInventory = true,
- Equipment = Inventory.Equipment
- };
-
- PacketSender?.Server?.SendDataToAll(new NetDataWriter(), ref packet, LiteNetLib.DeliveryMethod.ReliableOrdered);
- PacketSender?.Server?.NetServer?.TriggerUpdate();*/
-
if (FikaPlugin.ShowNotifications.Value)
{
if (IsBoss(Profile.Info.Settings.Role, out string name) && LastAggressor != null)
@@ -236,16 +214,23 @@ public override void OnDead(EDamageType damageType)
// This one is already handled by SPT, so we do not add directly to profile until they move it to client side
// They also do a flat value of 0.02 rather than 0.01 for 1 scav kill or 0.03 for >1
LastAggressor.Profile.EftStats.SessionCounters.AddDouble(0.02, [CounterTag.FenceStanding, EFenceStandingSource.ScavHelp]);
- //LastAggressor.Profile.FenceInfo.AddStanding(0.01, EFenceStandingSource.ScavHelp);
+ LastAggressor.Profile.FenceInfo.AddStanding(0.01, EFenceStandingSource.ScavHelp);
}
else if (Side == EPlayerSide.Savage)
{
- //LastAggressor.Profile.EftStats.SessionCounters.AddDouble(0.03, [CounterTag.FenceStanding, EFenceStandingSource.TraitorKill]);
+ LastAggressor.Profile.EftStats.SessionCounters.AddDouble(0.03, [CounterTag.FenceStanding, EFenceStandingSource.TraitorKill]);
LastAggressor.Profile.FenceInfo.AddStanding(0.03, EFenceStandingSource.TraitorKill);
}
}
}
}
+
+ CoopGame coopGame = (CoopGame)Singleton.Instance;
+ if (coopGame.Bots.ContainsKey(ProfileId))
+ {
+ coopGame.Bots.Remove(ProfileId);
+ }
+
base.OnDead(damageType);
}
@@ -253,7 +238,10 @@ private IEnumerator DestroyNetworkedComponents()
{
yield return new WaitForSeconds(2);
- PacketSender?.DestroyThis();
+ if (PacketSender != null)
+ {
+ PacketSender.DestroyThis();
+ }
}
public override void UpdateTick()
@@ -306,7 +294,7 @@ protected void OnDisable()
public override void OnDestroy()
{
#if DEBUG
- FikaPlugin.Instance.FikaLogger.LogInfo("Destroying " + ProfileId);
+ FikaPlugin.Instance.FikaLogger.LogInfo("Destroying " + ProfileId);
#endif
if (Singleton.Instantiated)
{
@@ -320,6 +308,11 @@ public override void OnDestroy()
BotNetId = NetId
};
server.SendDataToAll(new NetDataWriter(), ref packet, LiteNetLib.DeliveryMethod.ReliableOrdered);
+
+ if (!coopGame.Bots.Remove(ProfileId))
+ {
+ FikaPlugin.Instance.FikaLogger.LogWarning("Unable to remove " + ProfileId + " from CoopGame.Bots when Destroying");
+ }
}
}
if (CoopHandler.TryGetCoopHandler(out CoopHandler coopHandler))
@@ -359,7 +352,7 @@ internal void SendPacket()
return;
}
- coopBot.PacketSender?.CommonPlayerPackets?.Enqueue(new()
+ coopBot.PacketSender.CommonPlayerPackets.Enqueue(new()
{
HasProceedPacket = true,
ProceedPacket = new()
diff --git a/Fika.Core/Coop/Players/CoopPlayer.cs b/Fika.Core/Coop/Players/CoopPlayer.cs
index eb50eb76..1c974c3d 100644
--- a/Fika.Core/Coop/Players/CoopPlayer.cs
+++ b/Fika.Core/Coop/Players/CoopPlayer.cs
@@ -52,26 +52,39 @@ public static async Task Create(int playerId, Vector3 position, Qua
string layerName, string prefix, EPointOfView pointOfView, Profile profile, bool aiControl,
EUpdateQueue updateQueue, EUpdateMode armsUpdateMode, EUpdateMode bodyUpdateMode,
CharacterControllerSpawner.Mode characterControllerMode, Func getSensitivity,
- Func getAimingSensitivity, GInterface99 filter, int netId, IStatisticsManager statisticsManager)
+ Func getAimingSensitivity, GInterface111 filter, int netId, IStatisticsManager statisticsManager)
{
CoopPlayer player = null;
- player = Create(GClass1388.PLAYER_BUNDLE_NAME, playerId, position, updateQueue, armsUpdateMode,
+ player = Create(GClass1398.PLAYER_BUNDLE_NAME, playerId, position, updateQueue, armsUpdateMode,
bodyUpdateMode, characterControllerMode, getSensitivity, getAimingSensitivity, prefix, false);
player.IsYourPlayer = true;
player.NetId = netId;
- CoopClientInventoryController inventoryController = new(player, profile, true);
+ CoopClientInventoryController inventoryController = new(player, profile, false);
- GClass3206 questController = new(profile, inventoryController, null, true);
+ ISession session = Singleton>.Instance.GetClientBackEndSession();
+
+ GClass3223 questController = new(profile, inventoryController, session, true);
questController.Init();
questController.Run();
- AchievementControllerClass achievementsController = new(profile, inventoryController, null, true);
+ AchievementControllerClass achievementsController = new(profile, inventoryController, session, true);
achievementsController.Init();
achievementsController.Run();
+ if (MatchmakerAcceptPatches.IsServer)
+ {
+ player.PacketSender = player.gameObject.AddComponent();
+ }
+ else if (MatchmakerAcceptPatches.IsClient)
+ {
+ player.PacketSender = player.gameObject.AddComponent();
+ }
+
+ player.PacketReceiver = player.gameObject.AddComponent();
+
await player.Init(rotation, layerName, pointOfView, profile, inventoryController,
new CoopClientHealthController(profile.Health, player, inventoryController, profile.Skills, aiControl),
statisticsManager, questController, achievementsController, filter,
@@ -79,11 +92,11 @@ await player.Init(rotation, layerName, pointOfView, profile, inventoryController
foreach (MagazineClass magazineClass in player.Inventory.GetPlayerItems(EPlayerItems.NonQuestItems).OfType())
{
- player.GClass2761_0.StrictCheckMagazine(magazineClass, true, player.Profile.MagDrillsMastering, false, false);
+ player.GClass2774_0.StrictCheckMagazine(magazineClass, true, player.Profile.MagDrillsMastering, false, false);
}
player._handsController = EmptyHandsController.smethod_5(player);
- player._handsController.Spawn(1f, new Action(Class1500.class1500_0.method_0));
+ player._handsController.Spawn(1f, new Action(Class1522.class1522_0.method_0));
player.AIData = new AIData(null, player);
player.AggressorFound = false;
player._animators[0].enabled = true;
@@ -93,7 +106,7 @@ await player.Init(rotation, layerName, pointOfView, profile, inventoryController
return player;
}
- public override void OnSkillLevelChanged(GClass1766 skill)
+ public override void OnSkillLevelChanged(GClass1776 skill)
{
NotificationManagerClass.DisplayMessageNotification(string.Format("SkillLevelUpMessage".Localized(null),
skill.Id.ToString().Localized(null),
@@ -124,8 +137,8 @@ public override void BtrInteraction(BTRSide btr, byte placeId, EInteractionType
InteractPacket = btr.GetInteractWithBtrPacket(placeId, interaction)
};
- PacketSender?.Writer?.Reset();
- PacketSender?.Client?.SendData(PacketSender?.Writer, ref packet, LiteNetLib.DeliveryMethod.ReliableOrdered);
+ PacketSender.Writer.Reset();
+ PacketSender.Client.SendData(PacketSender.Writer, ref packet, LiteNetLib.DeliveryMethod.ReliableOrdered);
}
else if (MatchmakerAcceptPatches.IsServer)
{
@@ -142,8 +155,8 @@ public override void BtrInteraction(BTRSide btr, byte placeId, EInteractionType
InteractPacket = interactPacket
};
- PacketSender?.Writer?.Reset();
- PacketSender?.Server?.SendDataToAll(PacketSender?.Writer, ref packet, LiteNetLib.DeliveryMethod.ReliableOrdered);
+ PacketSender.Writer.Reset();
+ PacketSender.Server.SendDataToAll(PacketSender.Writer, ref packet, LiteNetLib.DeliveryMethod.ReliableOrdered);
}
}
}
@@ -158,7 +171,10 @@ public void ProcessInteractWithBTR(BTRInteractionPacket packet)
{
if (CoopHandler.TryGetCoopHandler(out CoopHandler coopHandler))
{
- coopHandler.clientBTR?.ClientInteraction(this, packet.InteractPacket);
+ if (coopHandler.clientBTR != null)
+ {
+ coopHandler.clientBTR.ClientInteraction(this, packet.InteractPacket);
+ }
}
}
}
@@ -198,7 +214,7 @@ public override void ApplyDamageInfo(DamageInfo damageInfo, EBodyPart bodyPartTy
base.ApplyDamageInfo(damageInfo, bodyPartType, colliderType, absorbed);
}
- public override GClass1676 ApplyShot(DamageInfo damageInfo, EBodyPart bodyPartType, EBodyPartColliderType colliderType, EArmorPlateCollider armorPlateCollider, GStruct390 shotId)
+ public override GClass1686 ApplyShot(DamageInfo damageInfo, EBodyPart bodyPartType, EBodyPartColliderType colliderType, EArmorPlateCollider armorPlateCollider, GStruct390 shotId)
{
if (damageInfo.DamageType is EDamageType.Sniper or EDamageType.Landmine)
{
@@ -213,10 +229,10 @@ public override GClass1676 ApplyShot(DamageInfo damageInfo, EBodyPart bodyPartTy
return null;
}
- public override void Proceed(bool withNetwork, Callback callback, bool scheduled = true)
+ public override void Proceed(bool withNetwork, Callback callback, bool scheduled = true)
{
base.Proceed(withNetwork, callback, scheduled);
- PacketSender?.CommonPlayerPackets?.Enqueue(new()
+ PacketSender.CommonPlayerPackets.Enqueue(new()
{
HasProceedPacket = true,
ProceedPacket = new()
@@ -227,7 +243,7 @@ public override void Proceed(bool withNetwork, Callback callback,
});
}
- public override void Proceed(FoodClass foodDrink, float amount, Callback callback, int animationVariant, bool scheduled = true)
+ public override void Proceed(FoodClass foodDrink, float amount, Callback callback, int animationVariant, bool scheduled = true)
{
FoodControllerHandler handler = new(this, foodDrink, amount, EBodyPart.Head, animationVariant);
@@ -237,7 +253,7 @@ public override void Proceed(FoodClass foodDrink, float amount, Callback callback, bool scheduled = true)
+ public override void Proceed(Item item, Callback callback, bool scheduled = true)
{
QuickUseItemControllerHandler handler = new(this, item);
@@ -257,7 +273,7 @@ public override void Proceed(KnifeComponent knife, Callback ca
handler.process.method_0(new(handler.HandleResult), callback, scheduled);
}
- public override void Proceed(KnifeComponent knife, Callback callback, bool scheduled = true)
+ public override void Proceed(KnifeComponent knife, Callback callback, bool scheduled = true)
{
QuickKnifeControllerHandler handler = new(this, knife);
@@ -267,7 +283,7 @@ public override void Proceed(KnifeComponent knife, Callback callb
handler.process.method_0(new(handler.HandleResult), callback, scheduled);
}
- public override void Proceed(MedsClass meds, EBodyPart bodyPart, Callback callback, int animationVariant, bool scheduled = true)
+ public override void Proceed(MedsClass meds, EBodyPart bodyPart, Callback callback, int animationVariant, bool scheduled = true)
{
MedsControllerHandler handler = new(this, meds, bodyPart, animationVariant);
@@ -312,7 +328,7 @@ public override void Proceed(Weapon weapon, Callback ca
handler.process.method_0(new(handler.HandleResult), callback, scheduled);
}
- public override void Proceed(Item item, Callback callback, bool scheduled = true)
+ public override void Proceed(Item item, Callback callback, bool scheduled = true)
{
// what is this
base.Proceed(item, callback, scheduled);
@@ -322,7 +338,7 @@ public override void DropCurrentController(Action callback, bool fastDrop, Item
{
base.DropCurrentController(callback, fastDrop, nextControllerItem);
- /*PacketSender?.CommonPlayerPackets?.Enqueue(new()
+ /*PacketSender.CommonPlayerPackets.Enqueue(new()
{
HasDrop = true,
DropPacket = new()
@@ -342,7 +358,7 @@ public override void SetInventoryOpened(bool opened)
}
base.SetInventoryOpened(opened);
- PacketSender?.CommonPlayerPackets?.Enqueue(new()
+ PacketSender.CommonPlayerPackets.Enqueue(new()
{
HasInventoryChanged = true,
SetInventoryOpen = opened
@@ -352,7 +368,7 @@ public override void SetInventoryOpened(bool opened)
public override void SetCompassState(bool value)
{
base.SetCompassState(value);
- PacketSender?.FirearmPackets?.Enqueue(new()
+ PacketSender.FirearmPackets.Enqueue(new()
{
HasCompassChange = true,
CompassState = value
@@ -371,17 +387,20 @@ public void ClientApplyShot(DamageInfo damageInfo, EBodyPart bodyPartType, EBody
public override void SendHeadlightsPacket(bool isSilent)
{
- GStruct163[] lightStates = _helmetLightControllers.Select(new Func(ClientPlayer.Class1430.class1430_0.method_0)).ToArray();
+ GStruct164[] lightStates = _helmetLightControllers.Select(new Func(ClientPlayer.Class1452.class1452_0.method_0)).ToArray();
- PacketSender?.CommonPlayerPackets?.Enqueue(new()
+ if (PacketSender != null)
{
- HasHeadLightsPacket = true,
- HeadLightsPacket = new()
+ PacketSender.CommonPlayerPackets.Enqueue(new()
{
- Amount = lightStates.Count(),
- LightStates = lightStates
- }
- });
+ HasHeadLightsPacket = true,
+ HeadLightsPacket = new()
+ {
+ Amount = lightStates.Count(),
+ LightStates = lightStates
+ }
+ });
+ }
}
public override void OnItemAddedOrRemoved(Item item, ItemAddress location, bool added)
@@ -395,7 +414,7 @@ public override void OnPhraseTold(EPhraseTrigger @event, TaggedClip clip, TagBan
if (ActiveHealthController.IsAlive)
{
- PacketSender?.CommonPlayerPackets?.Enqueue(new()
+ PacketSender.CommonPlayerPackets.Enqueue(new()
{
Phrase = @event,
PhraseIndex = clip.NetId
@@ -403,10 +422,10 @@ public override void OnPhraseTold(EPhraseTrigger @event, TaggedClip clip, TagBan
}
}
- public override void OperateStationaryWeapon(StationaryWeapon stationaryWeapon, GStruct169.EStationaryCommand command)
+ public override void OperateStationaryWeapon(StationaryWeapon stationaryWeapon, GStruct170.EStationaryCommand command)
{
base.OperateStationaryWeapon(stationaryWeapon, command);
- PacketSender?.CommonPlayerPackets?.Enqueue(new()
+ PacketSender.CommonPlayerPackets.Enqueue(new()
{
HasStationaryPacket = true,
StationaryPacket = new()
@@ -444,10 +463,10 @@ public override void vmethod_0(WorldInteractiveObject interactiveObject, Interac
InteractiveId = interactiveObject.Id,
InteractionType = interactionResult.InteractionType,
InteractionStage = EInteractionStage.Start,
- ItemId = (interactionResult is GClass2964 keyInteractionResult) ? keyInteractionResult.Key.Item.Id : string.Empty
+ ItemId = (interactionResult is GClass2981 keyInteractionResult) ? keyInteractionResult.Key.Item.Id : string.Empty
}
};
- PacketSender?.CommonPlayerPackets?.Enqueue(packet);
+ PacketSender.CommonPlayerPackets.Enqueue(packet);
}
// Execute
@@ -469,10 +488,10 @@ public override void vmethod_1(WorldInteractiveObject door, InteractionResult in
InteractiveId = door.Id,
InteractionType = interactionResult.InteractionType,
InteractionStage = EInteractionStage.Execute,
- ItemId = (interactionResult is GClass2964 keyInteractionResult) ? keyInteractionResult.Key.Item.Id : string.Empty
+ ItemId = (interactionResult is GClass2981 keyInteractionResult) ? keyInteractionResult.Key.Item.Id : string.Empty
}
};
- PacketSender?.CommonPlayerPackets?.Enqueue(packet);
+ PacketSender.CommonPlayerPackets.Enqueue(packet);
UpdateInteractionCast();
}
@@ -480,7 +499,7 @@ public override void vmethod_1(WorldInteractiveObject door, InteractionResult in
public override void vmethod_3(EGesture gesture)
{
base.vmethod_3(gesture);
- PacketSender?.FirearmPackets?.Enqueue(new()
+ PacketSender.FirearmPackets.Enqueue(new()
{
Gesture = gesture
});
@@ -491,7 +510,7 @@ public override void ApplyCorpseImpulse()
Corpse.Ragdoll.ApplyImpulse(LastDamageInfo.HitCollider, LastDamageInfo.Direction, LastDamageInfo.HitPoint, _corpseAppliedForce);
}
- public HealthSyncPacket SetupDeathPacket(GStruct346 packet)
+ public HealthSyncPacket SetupDeathPacket(GStruct347 packet)
{
float num = EFTHardSettings.Instance.HIT_FORCE;
num *= 0.3f + 0.7f * Mathf.InverseLerp(50f, 20f, LastDamageInfo.PenetrationPower);
@@ -530,7 +549,10 @@ private IEnumerator DestroyNetworkedComponents()
{
yield return new WaitForSeconds(2);
- PacketSender?.DestroyThis();
+ if (PacketSender != null)
+ {
+ PacketSender.DestroyThis();
+ }
}
public override void Move(Vector2 direction)
@@ -761,7 +783,7 @@ public void Ping()
Color pingColor = FikaPlugin.PingColor.Value;
pingColor = new(pingColor.r, pingColor.g, pingColor.b, 1);
// ref so that we can mutate it if we want to, ex: if I ping a switch I want it at the switch.gameObject.position + Vector3.up
- abstractPing?.Initialize(ref hitPoint, userData, pingColor);
+ abstractPing.Initialize(ref hitPoint, userData, pingColor);
GenericPacket genericPacket = new()
{
@@ -773,14 +795,14 @@ public void Ping()
Nickname = Profile.Nickname
};
- PacketSender?.Writer?.Reset();
+ PacketSender.Writer.Reset();
if (MatchmakerAcceptPatches.IsServer)
{
- PacketSender?.Server?.SendDataToAll(PacketSender.Writer, ref genericPacket, LiteNetLib.DeliveryMethod.ReliableOrdered);
+ PacketSender.Server.SendDataToAll(PacketSender.Writer, ref genericPacket, LiteNetLib.DeliveryMethod.ReliableOrdered);
}
else if (MatchmakerAcceptPatches.IsClient)
{
- PacketSender?.Client?.SendData(PacketSender.Writer, ref genericPacket, LiteNetLib.DeliveryMethod.ReliableOrdered);
+ PacketSender.Client.SendData(PacketSender.Writer, ref genericPacket, LiteNetLib.DeliveryMethod.ReliableOrdered);
}
if (FikaPlugin.PlayPingAnimation.Value)
@@ -821,22 +843,13 @@ public override void TryInteractionCallback(LootableContainer container)
protected virtual void Start()
{
- if (MatchmakerAcceptPatches.IsServer)
- {
- PacketSender = gameObject.AddComponent();
- }
- else if (MatchmakerAcceptPatches.IsClient)
- {
- PacketSender = gameObject.AddComponent();
- }
- PacketReceiver = gameObject.AddComponent();
Profile.Info.GroupId = "Fika";
if (Side != EPlayerSide.Savage)
{
if (Equipment.GetSlot(EquipmentSlot.Dogtag).ContainedItem != null)
{
- GStruct414 result = InteractionsHandlerClass.Remove(Equipment.GetSlot(EquipmentSlot.Dogtag).ContainedItem, _inventoryController, false, true);
+ GStruct415 result = InteractionsHandlerClass.Remove(Equipment.GetSlot(EquipmentSlot.Dogtag).ContainedItem, _inventoryController, false, true);
if (result.Error != null)
{
FikaPlugin.Instance.FikaLogger.LogWarning("CoopPlayer::Start: Error removing dog tag!");
@@ -934,7 +947,7 @@ public virtual void HandleCommonPacket(in CommonPlayerPacket packet)
{
if (this is ObservedCoopPlayer observedCoopPlayer)
{
- observedCoopPlayer?.HandleProceedPacket(packet.ProceedPacket);
+ observedCoopPlayer.HandleProceedPacket(packet.ProceedPacket);
}
}
@@ -968,7 +981,7 @@ public virtual void HandleCommonPacket(in CommonPlayerPacket packet)
if (packet.HasStationaryPacket)
{
StationaryWeapon stationaryWeapon = (packet.StationaryPacket.Command == StationaryPacket.EStationaryCommand.Occupy) ? Singleton.Instance.FindStationaryWeapon(packet.StationaryPacket.Id) : null;
- base.OperateStationaryWeapon(stationaryWeapon, (GStruct169.EStationaryCommand)packet.StationaryPacket.Command);
+ base.OperateStationaryWeapon(stationaryWeapon, (GStruct170.EStationaryCommand)packet.StationaryPacket.Command);
}
if (packet.Pickup)
@@ -1023,7 +1036,7 @@ public virtual void HandleInventoryPacket(in InventoryPacket packet)
using BinaryReader binaryReader = new(memoryStream);
try
{
- GStruct411 result = ToInventoryOperation(binaryReader.ReadPolymorph());
+ GStruct412 result = ToInventoryOperation(binaryReader.ReadPolymorph());
InventoryOperationHandler opHandler = new(result);
@@ -1031,9 +1044,9 @@ public virtual void HandleInventoryPacket(in InventoryPacket packet)
// TODO: Hacky workaround to fix errors due to each client generating new IDs. Might need to find a more 'elegant' solution later.
// Unknown what problems this might cause so far.
- if (result.Value is GClass2861 unloadOperation)
+ if (result.Value is GClass2874 unloadOperation)
{
- if (unloadOperation.InternalOperation is GClass2872 internalSplitOperation)
+ if (unloadOperation.InternalOperation is GClass2885 internalSplitOperation)
{
Item item = internalSplitOperation.To.Item;
if (item != null)
@@ -1055,7 +1068,7 @@ public virtual void HandleInventoryPacket(in InventoryPacket packet)
}
// TODO: Same as above.
- if (result.Value is GClass2872 splitOperation)
+ if (result.Value is GClass2885 splitOperation)
{
Item item = splitOperation.To.Item;
if (item != null)
@@ -1267,7 +1280,7 @@ public virtual void HandleDamagePacket(DamagePacket packet)
if (!string.IsNullOrEmpty(packet.DamageInfo.ProfileId))
{
- GInterface94 player = Singleton.Instance.GetAlivePlayerBridgeByProfileID(packet.DamageInfo.ProfileId);
+ GInterface106 player = Singleton.Instance.GetAlivePlayerBridgeByProfileID(packet.DamageInfo.ProfileId);
if (player != null)
{
@@ -1326,6 +1339,15 @@ public virtual void SetupDogTag()
}
}
+ public void CheckAndResetControllers(ExitStatus exitStatus, float pastTime, string locationId, string exitName)
+ {
+ _questController?.CheckExitConditionCounters(exitStatus, pastTime, locationId, exitName, HealthController.BodyPartEffects, TriggerZones);
+ _questController?.ResetCurrentNullableCounters();
+
+ _achievementsController?.CheckExitConditionCounters(exitStatus, pastTime, locationId, exitName, HealthController.BodyPartEffects, TriggerZones);
+ _achievementsController?.ResetCurrentNullableCounters();
+ }
+
public virtual void SetInventory(EquipmentClass equipmentClass)
{
// Do nothing
@@ -1339,7 +1361,10 @@ public override void OnDestroy()
public override void Dispose()
{
base.Dispose();
- PacketSender?.DestroyThis();
+ if (PacketSender != null)
+ {
+ PacketSender.DestroyThis();
+ }
}
public override void SendHandsInteractionStateChanged(bool value, int animationId)
@@ -1347,7 +1372,7 @@ public override void SendHandsInteractionStateChanged(bool value, int animationI
base.SendHandsInteractionStateChanged(value, animationId);
if (value)
{
- PacketSender?.CommonPlayerPackets?.Enqueue(new()
+ PacketSender.CommonPlayerPackets.Enqueue(new()
{
Pickup = value,
PickupAnimation = animationId
@@ -1357,7 +1382,7 @@ public override void SendHandsInteractionStateChanged(bool value, int animationI
public override void OnVaulting()
{
- PacketSender?.CommonPlayerPackets?.Enqueue(new()
+ PacketSender.CommonPlayerPackets.Enqueue(new()
{
HasVaultPacket = true,
VaultPacket = new()
@@ -1381,7 +1406,7 @@ public Item FindItem(string itemId)
return item;
}
- GStruct416- itemResult = FindItemById(itemId);
+ GStruct417
- itemResult = FindItemById(itemId);
if (itemResult.Error != null)
{
FikaPlugin.Instance.FikaLogger.LogError($"CoopPlayer::FindItem: Could not find item with id '{itemId}' in the world at all.");
@@ -1393,7 +1418,7 @@ public Item FindItem(string itemId)
private class KeyHandler(CoopPlayer player)
{
private readonly CoopPlayer player = player;
- public GStruct416 unlockResult;
+ public GStruct417 unlockResult;
internal void HandleKeyEvent()
{
@@ -1401,9 +1426,9 @@ internal void HandleKeyEvent()
}
}
- private class InventoryOperationHandler(GStruct411 opResult)
+ private class InventoryOperationHandler(GStruct412 opResult)
{
- public readonly GStruct411 opResult = opResult;
+ public readonly GStruct412 opResult = opResult;
internal void HandleResult(IResult result)
{
@@ -1421,7 +1446,7 @@ private class LootableContainerInteractionHandler(CoopPlayer player, LootableCon
public void Handle()
{
- player.PacketSender?.CommonPlayerPackets?.Enqueue(new()
+ player.PacketSender.CommonPlayerPackets.Enqueue(new()
{
HasContainerInteractionPacket = true,
ContainerInteractionPacket = new()
@@ -1459,7 +1484,7 @@ internal void SendPacket()
return;
}
- coopPlayer.PacketSender?.CommonPlayerPackets?.Enqueue(new()
+ coopPlayer.PacketSender.CommonPlayerPackets.Enqueue(new()
{
HasProceedPacket = true,
ProceedPacket = new()
@@ -1484,7 +1509,7 @@ private class QuickUseItemControllerHandler(CoopPlayer coopPlayer, Item item)
{
private readonly CoopPlayer coopPlayer = coopPlayer;
private readonly Item item = item;
- public Process process;
+ public Process process;
public Action confirmCallback;
internal QuickUseItemController ReturnController()
@@ -1494,7 +1519,7 @@ internal QuickUseItemController ReturnController()
internal void SendPacket()
{
- coopPlayer.PacketSender?.CommonPlayerPackets?.Enqueue(new()
+ coopPlayer.PacketSender.CommonPlayerPackets.Enqueue(new()
{
HasProceedPacket = true,
ProceedPacket = new()
@@ -1521,7 +1546,7 @@ private class MedsControllerHandler(CoopPlayer coopPlayer, MedsClass meds, EBody
private readonly MedsClass meds = meds;
private readonly EBodyPart bodyPart = bodyPart;
private readonly int animationVariant = animationVariant;
- public Process process;
+ public Process process;
public Action confirmCallback;
internal MedsController ReturnController()
@@ -1531,7 +1556,7 @@ internal MedsController ReturnController()
internal void SendPacket()
{
- coopPlayer.PacketSender?.CommonPlayerPackets?.Enqueue(new()
+ coopPlayer.PacketSender.CommonPlayerPackets.Enqueue(new()
{
HasProceedPacket = true,
ProceedPacket = new()
@@ -1561,7 +1586,7 @@ private class FoodControllerHandler(CoopPlayer coopPlayer, FoodClass foodDrink,
private readonly float amount = amount;
private readonly EBodyPart bodyPart = bodyPart;
private readonly int animationVariant = animationVariant;
- public Process process;
+ public Process process;
public Action confirmCallback;
internal MedsController ReturnController()
@@ -1571,7 +1596,7 @@ internal MedsController ReturnController()
internal void SendPacket()
{
- coopPlayer.PacketSender?.CommonPlayerPackets?.Enqueue(new()
+ coopPlayer.PacketSender.CommonPlayerPackets.Enqueue(new()
{
HasProceedPacket = true,
ProceedPacket = new()
@@ -1609,7 +1634,7 @@ internal CoopClientKnifeController ReturnController()
internal void SendPacket()
{
- coopPlayer.PacketSender?.CommonPlayerPackets?.Enqueue(new()
+ coopPlayer.PacketSender.CommonPlayerPackets.Enqueue(new()
{
HasProceedPacket = true,
ProceedPacket = new()
@@ -1634,7 +1659,7 @@ private class QuickKnifeControllerHandler(CoopPlayer coopPlayer, KnifeComponent
{
private readonly CoopPlayer coopPlayer = coopPlayer;
public readonly KnifeComponent knife = knife;
- public Process process;
+ public Process process;
public Action confirmCallback;
internal QuickKnifeKickController ReturnController()
@@ -1644,7 +1669,7 @@ internal QuickKnifeKickController ReturnController()
internal void SendPacket()
{
- coopPlayer.PacketSender?.CommonPlayerPackets?.Enqueue(new()
+ coopPlayer.PacketSender.CommonPlayerPackets.Enqueue(new()
{
HasProceedPacket = true,
ProceedPacket = new()
@@ -1679,7 +1704,7 @@ internal CoopClientGrenadeController ReturnController()
internal void SendPacket()
{
- coopPlayer.PacketSender?.CommonPlayerPackets?.Enqueue(new()
+ coopPlayer.PacketSender.CommonPlayerPackets.Enqueue(new()
{
HasProceedPacket = true,
ProceedPacket = new()
@@ -1714,7 +1739,7 @@ internal CoopClientQuickGrenadeController ReturnController()
internal void SendPacket()
{
- coopPlayer.PacketSender?.CommonPlayerPackets?.Enqueue(new()
+ coopPlayer.PacketSender.CommonPlayerPackets.Enqueue(new()
{
HasProceedPacket = true,
ProceedPacket = new()
diff --git a/Fika.Core/Coop/Players/ObservedCoopPlayer.cs b/Fika.Core/Coop/Players/ObservedCoopPlayer.cs
index a604f011..7dee376c 100644
--- a/Fika.Core/Coop/Players/ObservedCoopPlayer.cs
+++ b/Fika.Core/Coop/Players/ObservedCoopPlayer.cs
@@ -37,11 +37,12 @@ public class ObservedCoopPlayer : CoopPlayer
private readonly float interpolationRatio = 0.5f;
private float observedFixedTime = 0f;
private FikaHealthBar healthBar = null;
- public GClass2417 NetworkHealthController
+ private Coroutine waitForStartRoutine;
+ public GClass2428 NetworkHealthController
{
- get => HealthController as GClass2417;
+ get => HealthController as GClass2428;
}
- private readonly GClass2156 ObservedVaultingParameters = new();
+ private readonly GClass2167 ObservedVaultingParameters = new();
public override bool CanBeSnapped => false;
public override EPointOfView PointOfView { get => EPointOfView.ThirdPerson; }
public override AbstractHandsController HandsController
@@ -115,15 +116,15 @@ public override float SqrCameraDistance
}
#endregion
- public static async Task CreateObservedPlayer(int playerId, Vector3 position, Quaternion rotation,
+ public static async Task CreateObservedPlayer(int playerId, Vector3 position, Quaternion rotation,
string layerName, string prefix, EPointOfView pointOfView, Profile profile, bool aiControl,
EUpdateQueue updateQueue, EUpdateMode armsUpdateMode, EUpdateMode bodyUpdateMode,
CharacterControllerSpawner.Mode characterControllerMode, Func getSensitivity,
- Func getAimingSensitivity, GInterface99 filter)
+ Func getAimingSensitivity, GInterface111 filter)
{
ObservedCoopPlayer player = null;
- player = Create(GClass1388.PLAYER_BUNDLE_NAME, playerId, position, updateQueue,
+ player = Create(GClass1398.PLAYER_BUNDLE_NAME, playerId, position, updateQueue,
armsUpdateMode, bodyUpdateMode, characterControllerMode, getSensitivity, getAimingSensitivity, prefix,
aiControl);
@@ -164,12 +165,12 @@ public override bool CheckSurface()
public override void PlayGroundedSound(float fallHeight, float jumpHeight)
{
- (bool hit, BaseBallistic.ESurfaceSound surfaceSound) values = method_53();
- method_54(values.hit, values.surfaceSound);
+ (bool hit, BaseBallistic.ESurfaceSound surfaceSound) values = method_57();
+ method_58(values.hit, values.surfaceSound);
base.PlayGroundedSound(fallHeight, jumpHeight);
}
- public override void OnSkillLevelChanged(GClass1766 skill)
+ public override void OnSkillLevelChanged(GClass1776 skill)
{
//base.OnSkillLevelChanged(skill);
}
@@ -240,7 +241,7 @@ public override void ManageAggressor(DamageInfo damageInfo, EBodyPart bodyPart,
bool flag = damageInfo.DidBodyDamage / HealthController.GetBodyPartHealth(bodyPart, false).Maximum >= 0.6f && HealthController.FindExistingEffect(bodyPart) != null;
player.StatisticsManager.OnEnemyDamage(damageInfo, bodyPart,
- Profile.Info.Side, Profile.Info.Settings.Role.ToString(),
+ Profile.Info.Side, Profile.Info.Settings.Role,
Profile.Info.GroupId, HealthController.GetBodyPartHealth(EBodyPart.Common, false).Maximum,
flag, Vector3.Distance(player.Transform.position, Transform.position),
CurrentHour, Inventory.EquippedInSlotsTemplateIds,
@@ -261,7 +262,7 @@ public override void ApplyDamageInfo(DamageInfo damageInfo, EBodyPart bodyPartTy
{
if (damageInfo.DamageType == EDamageType.Landmine && MatchmakerAcceptPatches.IsServer)
{
- PacketSender?.DamagePackets?.Enqueue(new()
+ PacketSender.DamagePackets.Enqueue(new()
{
DamageInfo = new()
{
@@ -328,12 +329,12 @@ public override void ApplyDamageInfo(DamageInfo damageInfo, EBodyPart bodyPartTy
}
}*/
- public override GClass1676 ApplyShot(DamageInfo damageInfo, EBodyPart bodyPartType, EBodyPartColliderType colliderType, EArmorPlateCollider armorPlateCollider, GStruct390 shotId)
+ public override GClass1686 ApplyShot(DamageInfo damageInfo, EBodyPart bodyPartType, EBodyPartColliderType colliderType, EArmorPlateCollider armorPlateCollider, GStruct390 shotId)
{
if (damageInfo.DamageType == EDamageType.Sniper && MatchmakerAcceptPatches.IsServer)
{
ShotReactions(damageInfo, bodyPartType);
- PacketSender?.DamagePackets?.Enqueue(new()
+ PacketSender.DamagePackets.Enqueue(new()
{
DamageInfo = new()
{
@@ -379,7 +380,7 @@ public override GClass1676 ApplyShot(DamageInfo damageInfo, EBodyPart bodyPartTy
float damage = damageInfo.Damage;
List list = ProceedDamageThroughArmor(ref damageInfo, colliderType, armorPlateCollider, true);
MaterialType materialType = (flag ? MaterialType.HelmetRicochet : ((list == null || list.Count < 1) ? MaterialType.Body : list[0].Material));
- GClass1676 hitInfo = new()
+ GClass1686 hitInfo = new()
{
PoV = PointOfView,
Penetrated = (string.IsNullOrEmpty(damageInfo.BlockedBy) || string.IsNullOrEmpty(damageInfo.DeflectedBy)),
@@ -401,7 +402,7 @@ public override GClass1676 ApplyShot(DamageInfo damageInfo, EBodyPart bodyPartTy
colliderType = bodyPartCollider.BodyPartColliderType;
}
- PacketSender?.DamagePackets?.Enqueue(new()
+ PacketSender.DamagePackets.Enqueue(new()
{
DamageInfo = new()
{
@@ -439,7 +440,7 @@ public override GClass1676 ApplyShot(DamageInfo damageInfo, EBodyPart bodyPartTy
float damage = damageInfo.Damage;
List list = ProceedDamageThroughArmor(ref damageInfo, colliderType, armorPlateCollider, true);
MaterialType materialType = (flag ? MaterialType.HelmetRicochet : ((list == null || list.Count < 1) ? MaterialType.Body : list[0].Material));
- GClass1676 hitInfo = new()
+ GClass1686 hitInfo = new()
{
PoV = PointOfView,
Penetrated = (string.IsNullOrEmpty(damageInfo.BlockedBy) || string.IsNullOrEmpty(damageInfo.DeflectedBy)),
@@ -461,7 +462,7 @@ public override GClass1676 ApplyShot(DamageInfo damageInfo, EBodyPart bodyPartTy
colliderType = bodyPartCollider.BodyPartColliderType;
}
- PacketSender?.DamagePackets?.Enqueue(new()
+ PacketSender.DamagePackets.Enqueue(new()
{
DamageInfo = new()
{
@@ -501,7 +502,7 @@ public override void SetControllerInsteadRemovedOne(Item removingItem, Callback
{
RemoveHandsControllerHandler handler = new(this, callback);
_removeFromHandsCallback = callback;
- Proceed(false, new Callback(handler.Handle), false);
+ Proceed(false, new Callback(handler.Handle), false);
}
public override Corpse CreateCorpse()
@@ -527,7 +528,7 @@ public override void CreateMovementContext()
public override void OnHealthEffectAdded(IEffect effect)
{
// Remember to check if classes increment
- if (effect is GInterface245 && FractureSound != null && Singleton.Instantiated)
+ if (effect is GInterface269 && FractureSound != null && Singleton.Instantiated)
{
Singleton.Instance.PlayAtPoint(Position, FractureSound, CameraClass.Instance.Distance(Position),
BetterAudio.AudioSourceGroupType.Impacts, 15, 0.7f, EOcclusionTest.Fast, null, false);
@@ -570,7 +571,7 @@ public override void Proceed(Weapon weapon, Callback ca
.method_0(null, callback, scheduled);
}
- public override void Proceed(MedsClass meds, EBodyPart bodyPart, Callback callback, int animationVariant, bool scheduled = true)
+ public override void Proceed(MedsClass meds, EBodyPart bodyPart, Callback callback, int animationVariant, bool scheduled = true)
{
HandsControllerFactory factory = new(this)
{
@@ -579,11 +580,11 @@ public override void Proceed(MedsClass meds, EBodyPart bodyPart, Callback func = new(factory.CreateObservedMedsController);
- new Process(this, func, meds, false)
+ new Process(this, func, meds, false)
.method_0(null, callback, scheduled);
}
- public override void Proceed(FoodClass foodDrink, float amount, Callback callback, int animationVariant, bool scheduled = true)
+ public override void Proceed(FoodClass foodDrink, float amount, Callback callback, int animationVariant, bool scheduled = true)
{
HandsControllerFactory factory = new(this)
{
@@ -592,7 +593,7 @@ public override void Proceed(FoodClass foodDrink, float amount, Callback func = new(factory.CreateObservedMedsController);
- new Process(this, func, foodDrink, false)
+ new Process(this, func, foodDrink, false)
.method_0(null, callback, scheduled);
}
#endregion
@@ -602,7 +603,10 @@ public override void vmethod_3(EGesture gesture)
if (gesture == EGesture.Hello)
{
InteractionRaycast();
- InteractablePlayer?.ShowHelloNotification(Profile.Nickname);
+ if (InteractablePlayer != null)
+ {
+ InteractablePlayer.ShowHelloNotification(Profile.Nickname);
+ }
}
base.vmethod_3(gesture);
}
@@ -629,12 +633,12 @@ public override void DropCurrentController(Action callback, bool fastDrop, Item
public override void OnPhraseTold(EPhraseTrigger @event, TaggedClip clip, TagBank bank, PhraseSpeakerClass speaker)
{
- method_32(clip);
+ method_34(clip);
}
public PlayerStatePacket Interpolate(in PlayerStatePacket newState, in PlayerStatePacket lastState)
{
- method_54(newState.HasGround, newState.SurfaceSound);
+ method_58(newState.HasGround, newState.SurfaceSound);
Rotation = new Vector2(Mathf.LerpAngle(MovementContext.Rotation.x, newState.Rotation.x, interpolationRatio),
Mathf.Lerp(MovementContext.Rotation.y, newState.Rotation.y, interpolationRatio));
@@ -780,11 +784,11 @@ public override void OnDead(EDamageType damageType)
// This one is already handled by SPT, so we do not add directly to profile until they move it to client side
// They also do a flat value of 0.02 rather than 0.01 for 1 scav kill or 0.03 for >1
LastAggressor.Profile.EftStats.SessionCounters.AddDouble(0.02, [CounterTag.FenceStanding, EFenceStandingSource.ScavHelp]);
- //LastAggressor.Profile.FenceInfo.AddStanding(0.01, EFenceStandingSource.ScavHelp);
+ LastAggressor.Profile.FenceInfo.AddStanding(0.01, EFenceStandingSource.ScavHelp);
}
else if (Side == EPlayerSide.Savage)
{
- //LastAggressor.Profile.EftStats.SessionCounters.AddDouble(0.03, [CounterTag.FenceStanding, EFenceStandingSource.TraitorKill]);
+ LastAggressor.Profile.EftStats.SessionCounters.AddDouble(0.03, [CounterTag.FenceStanding, EFenceStandingSource.TraitorKill]);
LastAggressor.Profile.FenceInfo.AddStanding(0.03, EFenceStandingSource.TraitorKill);
}
}
@@ -824,9 +828,12 @@ public override void SetInventory(EquipmentClass equipmentClass)
{
Transform slotBone = PlayerBody.GetSlotBone(equipmentSlot);
Transform alternativeHolsterBone = PlayerBody.GetAlternativeHolsterBone(equipmentSlot);
- PlayerBody.GClass1860 gclass = new(PlayerBody, Inventory.Equipment.GetSlot(equipmentSlot), slotBone, equipmentSlot, Inventory.Equipment.GetSlot(EquipmentSlot.Backpack), alternativeHolsterBone);
- PlayerBody.GClass1860 gclass2 = PlayerBody.SlotViews.AddOrReplace(equipmentSlot, gclass);
- gclass2?.Dispose();
+ PlayerBody.GClass1872 gclass = new(PlayerBody, Inventory.Equipment.GetSlot(equipmentSlot), slotBone, equipmentSlot, Inventory.Equipment.GetSlot(EquipmentSlot.Backpack), alternativeHolsterBone);
+ PlayerBody.GClass1872 gclass2 = PlayerBody.SlotViews.AddOrReplace(equipmentSlot, gclass);
+ if (gclass2 != null)
+ {
+ gclass2.Dispose();
+ }
}
//PlayerBody.Init(PlayerBody.BodyCustomization, Inventory.Equipment, shouldSet ? itemInHands : null, LayerMask.NameToLayer("Player"), Side);
@@ -884,7 +891,7 @@ private IEnumerator DestroyNetworkedComponents()
}
}
- protected override async void Start()
+ public void InitObservedPlayer()
{
if (gameObject.name.StartsWith("Bot_"))
{
@@ -892,6 +899,7 @@ protected override async void Start()
}
PacketSender = gameObject.AddComponent();
+ Traverse playerTraverse = Traverse.Create(this);
if (IsObservedAI)
{
@@ -903,18 +911,20 @@ protected override async void Start()
PacketSender.Writer.Reset();
PacketSender.Client.SendData(PacketSender.Writer, ref genericPacket, LiteNetLib.DeliveryMethod.ReliableOrdered);
- IVaultingComponent vaultingComponent = Traverse.Create(this).Field("_vaultingComponent").GetValue();
+ IVaultingComponent vaultingComponent = playerTraverse.Field("_vaultingComponent").GetValue();
if (vaultingComponent != null)
{
UpdateEvent -= vaultingComponent.DoVaultingTick;
}
- Traverse.Create(this).Field("_vaultingComponent").SetValue(null);
- Traverse.Create(this).Field("_vaultingComponentDebug").SetValue(null);
- Traverse.Create(this).Field("_vaultingParameters").SetValue(null);
- Traverse.Create(this).Field("_vaultingGameplayRestrictions").SetValue(null);
- Traverse.Create(this).Field("_vaultAudioController").SetValue(null);
- Traverse.Create(this).Field("_sprintVaultAudioController").SetValue(null);
- Traverse.Create(this).Field("_climbAudioController").SetValue(null);
+
+
+ playerTraverse.Field("_vaultingComponent").SetValue(null);
+ playerTraverse.Field("_vaultingComponentDebug").SetValue(null);
+ playerTraverse.Field("_vaultingParameters").SetValue(null);
+ playerTraverse.Field("_vaultingGameplayRestrictions").SetValue(null);
+ playerTraverse.Field("_vaultAudioController").SetValue(null);
+ playerTraverse.Field("_sprintVaultAudioController").SetValue(null);
+ playerTraverse.Field("_climbAudioController").SetValue(null);
if (FikaPlugin.CullPlayers.Value)
{
@@ -928,17 +938,19 @@ protected override async void Start()
{
Profile.Info.GroupId = "Fika";
+ var asd = Side;
+
CoopGame coopGame = (CoopGame)Singleton.Instance;
- IVaultingComponent vaultingComponent = Traverse.Create(this).Field("_vaultingComponent").GetValue();
+ IVaultingComponent vaultingComponent = playerTraverse.Field("_vaultingComponent").GetValue();
if (vaultingComponent != null)
{
UpdateEvent -= vaultingComponent.DoVaultingTick;
}
- Traverse.Create(this).Field("_vaultingComponent").SetValue(null);
- Traverse.Create(this).Field("_vaultingComponentDebug").SetValue(null);
- Traverse.Create(this).Field("_vaultingParameters").SetValue(null);
- Traverse.Create(this).Field("_vaultingGameplayRestrictions").SetValue(null);
+ playerTraverse.Field("_vaultingComponent").SetValue(null);
+ playerTraverse.Field("_vaultingComponentDebug").SetValue(null);
+ playerTraverse.Field("_vaultingParameters").SetValue(null);
+ playerTraverse.Field("_vaultingGameplayRestrictions").SetValue(null);
InitVaultingAudioControllers(ObservedVaultingParameters);
@@ -948,16 +960,34 @@ protected override async void Start()
EFT.Communications.ENotificationDurationType.Default, EFT.Communications.ENotificationIconType.Friend);
}
- // Spawn these later to prevent errors
- while (coopGame.Status != GameStatus.Started)
- {
- await Task.Delay(TimeSpan.FromSeconds(1));
- }
+ waitForStartRoutine = StartCoroutine(CreateHealthBar());
+
+ RaycastCameraTransform = playerTraverse.Field("_playerLookRaycastTransform").GetValue();
+ }
+ }
- healthBar = gameObject.AddComponent();
+ private IEnumerator CreateHealthBar()
+ {
+ CoopGame coopGame = (CoopGame)Singleton.Instance;
- RaycastCameraTransform = Traverse.Create(this).Field("_playerLookRaycastTransform").GetValue();
+ if (coopGame == null)
+ {
+ yield break;
+ }
+
+ while (coopGame.Status != GameStatus.Started)
+ {
+ yield return null;
}
+
+ healthBar = gameObject.AddComponent();
+
+ yield break;
+ }
+
+ protected override void Start()
+ {
+ // Do nothing
}
public override void LateUpdate()
@@ -1010,7 +1040,7 @@ public override void LandingAdjustments(float d)
transform.localRotation = Quaternion.identity;
transform.localPosition = Vector3.zero;
method_29(transform.gameObject);
- compassInstantiated = true;
+ Traverse.Create(this).Field("_compassInstantiated").SetValue(true);
return;
}
}
@@ -1142,7 +1172,10 @@ public override void InitAudioController()
private void SetSoundRollOff()
{
- NestedStepSoundSource?.SetRolloff(60f * ProtagonistHearing);
+ if (NestedStepSoundSource != null)
+ {
+ NestedStepSoundSource.SetRolloff(60f * ProtagonistHearing);
+ }
}
public override bool UpdateGrenadeAnimatorDuePoV()
@@ -1252,7 +1285,7 @@ public void HandleProceedPacket(ProceedPacket packet)
#region handControllers
private void CreateHandsController(Func controllerFactory, Item item)
{
- CreateHandsControllerHandler handler = new((item != null) ? method_67(item) : null);
+ CreateHandsControllerHandler handler = new((item != null) ? method_71(item) : null);
handler.setInHandsOperation?.Confirm(true);
@@ -1418,7 +1451,7 @@ private class RemoveHandsControllerHandler(ObservedCoopPlayer coopPlayer, Callba
private readonly ObservedCoopPlayer coopPlayer = coopPlayer;
private readonly Callback callback = callback;
- public void Handle(Result result)
+ public void Handle(Result result)
{
if (coopPlayer._removeFromHandsCallback == callback)
{
@@ -1428,13 +1461,13 @@ public void Handle(Result result)
}
}
- private class CreateHandsControllerHandler(Class1059 setInHandsOperation)
+ private class CreateHandsControllerHandler(Class1079 setInHandsOperation)
{
- public readonly Class1059 setInHandsOperation = setInHandsOperation;
+ public readonly Class1079 setInHandsOperation = setInHandsOperation;
internal void DisposeHandler()
{
- Class1059 handler = setInHandsOperation;
+ Class1079 handler = setInHandsOperation;
if (handler == null)
return;
handler.Dispose();
diff --git a/Fika.Core/Coop/Utils/NetManagerUtils.cs b/Fika.Core/Coop/Utils/NetManagerUtils.cs
new file mode 100644
index 00000000..f3f700a7
--- /dev/null
+++ b/Fika.Core/Coop/Utils/NetManagerUtils.cs
@@ -0,0 +1,99 @@
+using BepInEx.Logging;
+using Comfort.Common;
+using Fika.Core.Coop.Players;
+using Fika.Core.Networking;
+using System.Threading.Tasks;
+using UnityEngine;
+
+namespace Fika.Core.Coop.Utils
+{
+ public static class NetManagerUtils
+ {
+ private static ManualLogSource logger = BepInEx.Logging.Logger.CreateLogSource("NetManagerUtils");
+ public static GameObject FikaGameObject;
+
+ public static void CreateNetManager(bool isServer)
+ {
+ if (FikaGameObject == null)
+ {
+ FikaGameObject = new GameObject("FikaGameObject");
+ Object.DontDestroyOnLoad(FikaGameObject);
+ logger.LogInfo("FikaGameObject has been created!");
+ }
+
+ if (isServer)
+ {
+ FikaServer server = FikaGameObject.AddComponent();
+ Singleton.Create(server);
+ logger.LogInfo("FikaServer has started!");
+ }
+ else
+ {
+ FikaClient client = FikaGameObject.AddComponent();
+ Singleton.Create(client);
+ logger.LogInfo("FikaClient has started!");
+ }
+ }
+
+ public static void DestroyNetManager(bool isServer)
+ {
+ if (FikaGameObject != null)
+ {
+ if (isServer)
+ {
+ Singleton.Instance.NetServer.Stop();
+ Singleton.TryRelease(Singleton.Instance);
+ logger.LogInfo("Destroyed FikaServer");
+ }
+ else
+ {
+ Singleton.Instance.NetClient.Stop();
+ Singleton.TryRelease(Singleton.Instance);
+ logger.LogInfo("Destroyed FikaClient");
+ }
+ }
+ }
+
+ public static Task InitNetManager(bool isServer)
+ {
+ if (FikaGameObject != null)
+ {
+ if (isServer)
+ {
+ FikaServer server = Singleton.Instance;
+ if (!server.Started)
+ {
+ return server.Init();
+ }
+ return Task.CompletedTask;
+ }
+ else
+ {
+ FikaClient client = Singleton.Instance;
+ if (!client.Started)
+ {
+ client.Init();
+ }
+ return Task.CompletedTask;
+ }
+ }
+
+ logger.LogError("InitNetManager: FikaGameObject was null!");
+ return Task.CompletedTask;
+ }
+
+ public static Task SetupGameVariables(bool isServer, CoopPlayer coopPlayer)
+ {
+ if (isServer)
+ {
+ Singleton.Instance.SetupGameVariables(coopPlayer);
+ }
+ else
+ {
+ Singleton.Instance.SetupGameVariables(coopPlayer);
+ }
+
+ return Task.CompletedTask;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Fika.Core/Coop/World/WeatherNode_Patch.cs b/Fika.Core/Coop/World/WeatherNode_Patch.cs
index 9a67d11c..f172f70e 100644
--- a/Fika.Core/Coop/World/WeatherNode_Patch.cs
+++ b/Fika.Core/Coop/World/WeatherNode_Patch.cs
@@ -1,15 +1,15 @@
// © 2024 Lacyway All Rights Reserved
-using Aki.Reflection.Patching;
using EFT.Weather;
using Fika.Core.Coop.Matchmaker;
+using SPT.Reflection.Patching;
using System.Reflection;
namespace Fika.Core.Coop.World
{
internal class WeatherNode_Patch : ModulePatch
{
- protected override MethodBase GetTargetMethod() => typeof(WeatherController).GetMethod(nameof(WeatherController.method_4));
+ protected override MethodBase GetTargetMethod() => typeof(WeatherController).GetMethod(nameof(WeatherController.method_0));
[PatchPostfix]
public static void Postfix(WeatherController __instance, WeatherClass[] nodes)
diff --git a/Fika.Core/EssentialPatches/FikaVersionLabel_Patch.cs b/Fika.Core/EssentialPatches/FikaVersionLabel_Patch.cs
index 1ad96296..9572c5a0 100644
--- a/Fika.Core/EssentialPatches/FikaVersionLabel_Patch.cs
+++ b/Fika.Core/EssentialPatches/FikaVersionLabel_Patch.cs
@@ -1,10 +1,10 @@
-using Aki.Common.Http;
-using Aki.Common.Utils;
-using Aki.Custom.Models;
-using Aki.Reflection.Patching;
-using Aki.Reflection.Utils;
-using EFT.UI;
+using EFT.UI;
using HarmonyLib;
+using SPT.Common.Http;
+using SPT.Common.Utils;
+using SPT.Custom.Models;
+using SPT.Reflection.Patching;
+using SPT.Reflection.Utils;
using System.Linq;
using System.Reflection;
@@ -33,8 +33,10 @@ internal static void PatchPostfix(string major, object __result)
string fikaVersion = Assembly.GetAssembly(typeof(FikaVersionLabel_Patch)).GetName().Version.ToString();
- Traverse.Create(MonoBehaviourSingleton.Instance).Field("_alphaVersionLabel").Property("LocalizationKey").SetValue("{0}");
- Traverse.Create(MonoBehaviourSingleton.Instance).Field("string_2").SetValue($"Fika {fikaVersion} |");
+ Traverse preloaderUiTraverse = Traverse.Create(MonoBehaviourSingleton.Instance);
+
+ preloaderUiTraverse.Field("_alphaVersionLabel").Property("LocalizationKey").SetValue("{0}");
+ preloaderUiTraverse.Field("string_2").SetValue($"Fika {fikaVersion} |");
Traverse.Create(__result).Field("Major").SetValue($"FIKA BETA {fikaVersion} | {_versionLabel}");
}
}
diff --git a/Fika.Core/Fika.Core.csproj b/Fika.Core/Fika.Core.csproj
index 7d7b9d12..f8f969e2 100644
--- a/Fika.Core/Fika.Core.csproj
+++ b/Fika.Core/Fika.Core.csproj
@@ -39,89 +39,32 @@
-
- ..\References\aki-custom.dll
- False
-
-
- ..\References\aki-singleplayer.dll
- False
-
-
- ..\References\Aki.Common.dll
- False
-
-
- ..\References\Aki.Reflection.dll
- False
-
-
- ..\References\AnimationSystem.Types.dll
- False
-
-
- ..\References\hollowed.dll
- False
-
-
- ..\References\bsg.componentace.compression.libs.zlib.dll
- False
-
-
- ..\References\bsg.console.core.dll
-
-
- ..\References\Comfort.dll
- False
-
-
- ..\References\Comfort.Unity.dll
- False
-
-
- ..\References\CommonExtensions.dll
- False
-
-
- ..\References\DissonanceVoip.dll
- False
-
-
- ..\References\ItemComponent.Types.dll
- false
-
-
- ..\References\Newtonsoft.Json.dll
- False
-
-
- ..\References\Sirenix.Serialization.dll
- False
-
-
- ..\References\Unity.Postprocessing.Runtime.dll
- False
-
-
- ..\References\Unity.TextMeshPro.dll
- False
-
-
- ..\References\UnityEngine.dll
- False
-
-
- ..\References\UnityEngine.CoreModule.dll
-
-
- ..\References\UnityEngine.UI.dll
- False
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
diff --git a/Fika.Core/FikaPlugin.cs b/Fika.Core/FikaPlugin.cs
index f7486fad..134a76e9 100644
--- a/Fika.Core/FikaPlugin.cs
+++ b/Fika.Core/FikaPlugin.cs
@@ -1,10 +1,4 @@
using Aki.Custom.Airdrops.Patches;
-using Aki.Custom.BTR.Patches;
-using Aki.Custom.Patches;
-using Aki.SinglePlayer.Patches.MainMenu;
-using Aki.SinglePlayer.Patches.Progression;
-using Aki.SinglePlayer.Patches.Quests;
-using Aki.SinglePlayer.Patches.RaidFix;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
@@ -27,6 +21,14 @@
using Fika.Core.UI.Models;
using Fika.Core.UI.Patches;
using Fika.Core.Utils;
+using SPT.Custom.Airdrops.Patches;
+using SPT.Custom.BTR.Patches;
+using SPT.Custom.Patches;
+using SPT.SinglePlayer.Patches.MainMenu;
+using SPT.SinglePlayer.Patches.Progression;
+using SPT.SinglePlayer.Patches.Quests;
+using SPT.SinglePlayer.Patches.RaidFix;
+using SPT.SinglePlayer.Patches.ScavMode;
using System;
using System.Collections;
using System.Collections.Generic;
@@ -44,12 +46,12 @@ namespace Fika.Core
/// Originally by: Paulov
/// Re-written by: Lacyway
///
- [BepInPlugin("com.fika.core", "Fika.Core", "0.9.89")]
+ [BepInPlugin("com.fika.core", "Fika.Core", "0.9.8906")]
[BepInProcess("EscapeFromTarkov.exe")]
- [BepInDependency("com.spt-aki.custom", BepInDependency.DependencyFlags.HardDependency)] // This is used so that we guarantee to load after aki-custom, that way we can disable its patches
- [BepInDependency("com.spt-aki.singleplayer", BepInDependency.DependencyFlags.HardDependency)] // This is used so that we guarantee to load after aki-singleplayer, that way we can disable its patches
- [BepInDependency("com.spt-aki.core", BepInDependency.DependencyFlags.HardDependency)] // This is used so that we guarantee to load after aki-custom, that way we can disable its patches
- [BepInDependency("com.spt-aki.debugging", BepInDependency.DependencyFlags.HardDependency)] // This is used so that we guarantee to load after aki-custom, that way we can disable its patches
+ [BepInDependency("com.SPT.custom", BepInDependency.DependencyFlags.HardDependency)] // This is used so that we guarantee to load after aki-custom, that way we can disable its patches
+ [BepInDependency("com.SPT.singleplayer", BepInDependency.DependencyFlags.HardDependency)] // This is used so that we guarantee to load after aki-singleplayer, that way we can disable its patches
+ [BepInDependency("com.SPT.core", BepInDependency.DependencyFlags.HardDependency)] // This is used so that we guarantee to load after aki-custom, that way we can disable its patches
+ [BepInDependency("com.SPT.debugging", BepInDependency.DependencyFlags.HardDependency)] // This is used so that we guarantee to load after aki-custom, that way we can disable its patches
public class FikaPlugin : BaseUnityPlugin
{
///
@@ -184,6 +186,8 @@ public class FikaPlugin : BaseUnityPlugin
public bool DynamicVExfils;
public bool AllowFreeCam;
public bool AllowItemSending;
+ public string[] BlacklistedItems;
+ public bool ForceSaveOnDeath;
#endregion
protected void Awake()
@@ -238,11 +242,6 @@ protected void Awake()
StartCoroutine(RunModHandler());
}
- private void Config_SettingChanged(object sender, SettingChangedEventArgs e)
- {
- throw new NotImplementedException();
- }
-
///
/// Coroutine to ensure all mods are loaded by waiting 5 seconds
///
@@ -250,7 +249,7 @@ private void Config_SettingChanged(object sender, SettingChangedEventArgs e)
private IEnumerator RunModHandler()
{
yield return new WaitForSeconds(5);
- ModHandler.Run();
+ ModHandler.VerifyMods();
}
private void GetClientConfig()
@@ -262,6 +261,8 @@ private void GetClientConfig()
DynamicVExfils = clientConfig.DynamicVExfils;
AllowFreeCam = clientConfig.AllowFreeCam;
AllowItemSending = clientConfig.AllowItemSending;
+ BlacklistedItems = clientConfig.BlacklistedItems;
+ ForceSaveOnDeath = clientConfig.ForceSaveOnDeath;
clientConfig.ToString();
}
@@ -360,25 +361,25 @@ private void SetupConfig()
DespawnMinimumDistance = Config.Bind("Performance | Max Bots", "Despawn Minimum Distance", 200.0f, new ConfigDescription("Don't despawn bots within this distance.", new AcceptableValueRange(50f, 3000f), new ConfigurationManagerAttributes() { Order = 12 }));
- MaxBotsFactory = Config.Bind("Performance | Max Bots", "Max Bots Factory", 0, new ConfigDescription("Max amount of bots that can be active at the same time on Factory. Useful if you have a weaker PC. Set to 0 to use vanilla limits.", new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 11 }));
+ MaxBotsFactory = Config.Bind("Performance | Max Bots", "Max Bots Factory", 0, new ConfigDescription("Max amount of bots that can be active at the same time on Factory. Useful if you have a weaker PC. Set to 0 to use vanilla limits. Cannot be changed during a raid.", new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 11 }));
- MaxBotsCustoms = Config.Bind("Performance | Max Bots", "Max Bots Customs", 0, new ConfigDescription("Max amount of bots that can be active at the same time on Customs. Useful if you have a weaker PC. Set to 0 to use vanilla limits.", new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 10 }));
+ MaxBotsCustoms = Config.Bind("Performance | Max Bots", "Max Bots Customs", 0, new ConfigDescription("Max amount of bots that can be active at the same time on Customs. Useful if you have a weaker PC. Set to 0 to use vanilla limits. Cannot be changed during a raid.", new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 10 }));
- MaxBotsInterchange = Config.Bind("Performance | Max Bots", "Max Bots Interchange", 0, new ConfigDescription("Max amount of bots that can be active at the same time on Interchange. Useful if you have a weaker PC. Set to 0 to use vanilla limits.", new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 8 }));
+ MaxBotsInterchange = Config.Bind("Performance | Max Bots", "Max Bots Interchange", 0, new ConfigDescription("Max amount of bots that can be active at the same time on Interchange. Useful if you have a weaker PC. Set to 0 to use vanilla limits. Cannot be changed during a raid.", new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 8 }));
- MaxBotsReserve = Config.Bind("Performance | Max Bots", "Max Bots Reserve", 0, new ConfigDescription("Max amount of bots that can be active at the same time on Reserve. Useful if you have a weaker PC. Set to 0 to use vanilla limits.", new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 7 }));
+ MaxBotsReserve = Config.Bind("Performance | Max Bots", "Max Bots Reserve", 0, new ConfigDescription("Max amount of bots that can be active at the same time on Reserve. Useful if you have a weaker PC. Set to 0 to use vanilla limits. Cannot be changed during a raid.", new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 7 }));
- MaxBotsWoods = Config.Bind("Performance | Max Bots", "Max Bots Woods", 0, new ConfigDescription("Max amount of bots that can be active at the same time on Woods. Useful if you have a weaker PC. Set to 0 to use vanilla limits.", new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 6 }));
+ MaxBotsWoods = Config.Bind("Performance | Max Bots", "Max Bots Woods", 0, new ConfigDescription("Max amount of bots that can be active at the same time on Woods. Useful if you have a weaker PC. Set to 0 to use vanilla limits. Cannot be changed during a raid.", new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 6 }));
- MaxBotsShoreline = Config.Bind("Performance | Max Bots", "Max Bots Shoreline", 0, new ConfigDescription("Max amount of bots that can be active at the same time on Shoreline. Useful if you have a weaker PC. Set to 0 to use vanilla limits.", new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 5 }));
+ MaxBotsShoreline = Config.Bind("Performance | Max Bots", "Max Bots Shoreline", 0, new ConfigDescription("Max amount of bots that can be active at the same time on Shoreline. Useful if you have a weaker PC. Set to 0 to use vanilla limits. Cannot be changed during a raid.", new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 5 }));
- MaxBotsStreets = Config.Bind("Performance | Max Bots", "Max Bots Streets", 0, new ConfigDescription("Max amount of bots that can be active at the same time on Streets of Tarkov. Useful if you have a weaker PC. Set to 0 to use vanilla limits.", new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 4 }));
+ MaxBotsStreets = Config.Bind("Performance | Max Bots", "Max Bots Streets", 0, new ConfigDescription("Max amount of bots that can be active at the same time on Streets of Tarkov. Useful if you have a weaker PC. Set to 0 to use vanilla limits. Cannot be changed during a raid.", new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 4 }));
- MaxBotsGroundZero = Config.Bind("Performance | Max Bots", "Max Bots Ground Zero", 0, new ConfigDescription("Max amount of bots that can be active at the same time on Ground Zero. Useful if you have a weaker PC. Set to 0 to use vanilla limits.", new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 3 }));
+ MaxBotsGroundZero = Config.Bind("Performance | Max Bots", "Max Bots Ground Zero", 0, new ConfigDescription("Max amount of bots that can be active at the same time on Ground Zero. Useful if you have a weaker PC. Set to 0 to use vanilla limits. Cannot be changed during a raid.", new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 3 }));
- MaxBotsLabs = Config.Bind("Performance | Max Bots", "Max Bots Labs", 0, new ConfigDescription("Max amount of bots that can be active at the same time on Labs. Useful if you have a weaker PC. Set to 0 to use vanilla limits.", new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 2 }));
+ MaxBotsLabs = Config.Bind("Performance | Max Bots", "Max Bots Labs", 0, new ConfigDescription("Max amount of bots that can be active at the same time on Labs. Useful if you have a weaker PC. Set to 0 to use vanilla limits. Cannot be changed during a raid.", new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 2 }));
- MaxBotsLighthouse = Config.Bind("Performance | Max Bots", "Max Bots Lighthouse", 0, new ConfigDescription("Max amount of bots that can be active at the same time on Lighthouse. Useful if you have a weaker PC. Set to 0 to use vanilla limits.", new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 1 }));
+ MaxBotsLighthouse = Config.Bind("Performance | Max Bots", "Max Bots Lighthouse", 0, new ConfigDescription("Max amount of bots that can be active at the same time on Lighthouse. Useful if you have a weaker PC. Set to 0 to use vanilla limits. Cannot be changed during a raid.", new AcceptableValueRange(0, 50), new ConfigurationManagerAttributes() { Order = 1 }));
// Network
@@ -461,6 +462,8 @@ private void DisableSPTPatches()
new AmmoUsedCounterPatch().Disable();
new ArmorDamageCounterPatch().Disable();
new DogtagPatch().Disable();
+ new OfflineSaveProfilePatch().Disable(); // We handle this with our own exit manager
+ new ScavRepAdjustmentPatch().Disable();
new BTRInteractionPatch().Disable();
new BTRExtractPassengersPatch().Disable();
diff --git a/Fika.Core/Models/BotDifficulties.cs b/Fika.Core/Models/BotDifficulties.cs
index 24edd6fe..a74d37af 100644
--- a/Fika.Core/Models/BotDifficulties.cs
+++ b/Fika.Core/Models/BotDifficulties.cs
@@ -1,6 +1,6 @@
-using Aki.Common.Http;
-using EFT;
+using EFT;
using Newtonsoft.Json;
+using SPT.Common.Http;
using System.Collections.Generic;
namespace Fika.Core.Models
@@ -8,12 +8,12 @@ namespace Fika.Core.Models
public class BotDifficulties : Dictionary
{
[JsonIgnore]
- private GClass531 CoreSettings;
+ private GClass530 CoreSettings;
public BotDifficulties()
{
string coreString = RequestHandler.GetJson("/singleplayer/settings/bot/difficulty/core/core");
- CoreSettings = JsonConvert.DeserializeObject(coreString);
+ CoreSettings = JsonConvert.DeserializeObject(coreString);
}
public BotSettingsComponents GetComponent(BotDifficulty botDifficulty, WildSpawnType role)
@@ -31,7 +31,7 @@ public BotSettingsComponents GetComponent(BotDifficulty botDifficulty, WildSpawn
return null;
}
- public GClass531 GetCoreSettings()
+ public GClass530 GetCoreSettings()
{
FikaPlugin.Instance.FikaLogger.LogInfo("Retrieving Core settings");
if (CoreSettings != null)
diff --git a/Fika.Core/Models/ClientConfigModel.cs b/Fika.Core/Models/ClientConfigModel.cs
index bcabfec6..100e0bc1 100644
--- a/Fika.Core/Models/ClientConfigModel.cs
+++ b/Fika.Core/Models/ClientConfigModel.cs
@@ -21,13 +21,21 @@ public struct ClientConfigModel
[DataMember(Name = "allowItemSending")]
public bool AllowItemSending;
- public ClientConfigModel(bool useBTR, bool friendlyFire, bool dynamicVExfils, bool allowFreeCam, bool allowItemSending)
+ [DataMember(Name = "blacklistedItems")]
+ public string[] BlacklistedItems;
+
+ [DataMember(Name = "forceSaveOnDeath")]
+ public bool ForceSaveOnDeath;
+
+ public ClientConfigModel(bool useBTR, bool friendlyFire, bool dynamicVExfils, bool allowFreeCam, bool allowItemSending, string[] blacklistedItems, bool forceSaveOnDeath)
{
UseBTR = useBTR;
FriendlyFire = friendlyFire;
DynamicVExfils = dynamicVExfils;
AllowFreeCam = allowFreeCam;
AllowItemSending = allowItemSending;
+ BlacklistedItems = blacklistedItems;
+ ForceSaveOnDeath = forceSaveOnDeath;
}
public new void ToString()
diff --git a/Fika.Core/Networking/FikaClient.cs b/Fika.Core/Networking/FikaClient.cs
index d27e79b5..dd21643c 100644
--- a/Fika.Core/Networking/FikaClient.cs
+++ b/Fika.Core/Networking/FikaClient.cs
@@ -11,11 +11,10 @@
using EFT.Weather;
using Fika.Core.Coop.Components;
using Fika.Core.Coop.GameMode;
+using Fika.Core.Coop.Matchmaker;
using Fika.Core.Coop.Players;
using Fika.Core.Modding;
using Fika.Core.Modding.Events;
-using Fika.Core.Networking.Http;
-using Fika.Core.Networking.Http.Models;
using Fika.Core.Networking.Packets.GameWorld;
using Fika.Core.Networking.Packets.Player;
using HarmonyLib;
@@ -34,9 +33,9 @@ public class FikaClient : MonoBehaviour, INetEventListener
{
private NetManager _netClient;
public NetDataWriter DataWriter = new();
- public CoopPlayer MyPlayer => (CoopPlayer)Singleton.Instance.MainPlayer;
- public Dictionary Players => CoopHandler.Players;
- private CoopHandler CoopHandler { get; set; }
+ public CoopPlayer MyPlayer;
+ public Dictionary Players => coopHandler.Players;
+ private CoopHandler coopHandler;
public NetPacketProcessor packetProcessor = new();
public int Ping = 0;
public int ConnectedClients = 0;
@@ -49,13 +48,23 @@ public NetManager NetClient
}
}
public NetPeer ServerConnection { get; private set; }
- public string IP { get; private set; }
- public int Port { get; private set; }
+ /*public string IP { get; private set; }
+ public int Port { get; private set; }*/
public bool SpawnPointsReceived { get; private set; } = false;
private readonly ManualLogSource clientLogger = BepInEx.Logging.Logger.CreateLogSource("Fika.Client");
- public bool ClientReady = false;
+ public bool Started
+ {
+ get
+ {
+ if (_netClient == null)
+ {
+ return false;
+ }
+ return _netClient.IsRunning;
+ }
+ }
- protected void Start()
+ public void Init()
{
packetProcessor.SubscribeNetSerializable(OnPlayerStatePacketReceived);
packetProcessor.SubscribeNetSerializable(OnGameTimerPacketReceived);
@@ -80,7 +89,6 @@ protected void Start()
packetProcessor.SubscribeNetSerializable(OnAssignNetIdPacketReceived);
packetProcessor.SubscribeNetSerializable(OnSyncNetIdPacketReceived);
packetProcessor.SubscribeNetSerializable(OnOperationCallbackPacketReceived);
- packetProcessor.SubscribeNetSerializable(OnSessionSettingsPacketReceived);
_netClient = new NetManager(this)
{
@@ -95,36 +103,31 @@ protected void Start()
_netClient.Start();
- GetHostRequest body = new(CoopHandler.GetServerId());
+ /*GetHostRequest body = new(MatchmakerAcceptPatches.GetGroupId());
GetHostResponse result = FikaRequestHandler.GetHost(body);
IP = result.Ip;
- Port = result.Port;
+ Port = result.Port;*/
+
+ string ip = MatchmakerAcceptPatches.RemoteIp;
+ int port = MatchmakerAcceptPatches.RemotePort;
- if (string.IsNullOrEmpty(IP))
+ if (string.IsNullOrEmpty(ip))
{
Singleton.Instance.ShowErrorScreen("Network Error", "Unable to connect to the raid server. IP and/or Port was empty when requesting data!");
}
else
{
- ServerConnection = _netClient.Connect(IP, Port, "fika.core");
+ ServerConnection = _netClient.Connect(ip, port, "fika.core");
};
- Singleton.Create(this);
FikaEventDispatcher.DispatchEvent(new FikaClientCreatedEvent(this));
- ClientReady = true;
}
- private void OnSessionSettingsPacketReceived(SessionSettingsPacket packet)
+ public void SetupGameVariables(CoopPlayer coopPlayer)
{
- if (!packet.IsRequest)
- {
- if (packet.MetabolismDisabled)
- {
- Singleton.Instance.MainPlayer.HealthController.DisableMetabolism();
- NotificationManagerClass.DisplayMessageNotification("Metabolism disabled", iconType: EFT.Communications.ENotificationIconType.Alert);
- }
- }
+ coopHandler = CoopHandler.CoopHandlerParent.GetComponent();
+ MyPlayer = coopPlayer;
}
private void OnOperationCallbackPacketReceived(OperationCallbackPacket packet)
@@ -155,7 +158,7 @@ private void OnSyncNetIdPacketReceived(SyncNetIdPacket packet)
{
FikaPlugin.Instance.FikaLogger.LogError($"OnSyncNetIdPacketReceived: Could not find NetId {packet.NetId} in player list!");
string allPlayers = "";
- foreach (KeyValuePair kvp in CoopHandler.Players)
+ foreach (KeyValuePair kvp in coopHandler.Players)
{
string toAdd = $"Key: {kvp.Key}, Nickname: {kvp.Value.Profile.Nickname}, NetId: {kvp.Value.NetId}";
allPlayers = string.Join(", ", allPlayers + toAdd);
@@ -193,7 +196,7 @@ private void OnSendCharacterPacketReceived(SendCharacterPacket packet)
{
if (packet.PlayerInfo.Profile.ProfileId != MyPlayer.ProfileId)
{
- CoopHandler.QueueProfile(packet.PlayerInfo.Profile, packet.Position, packet.netId, packet.IsAlive, packet.IsAI);
+ coopHandler.QueueProfile(packet.PlayerInfo.Profile, packet.Position, packet.netId, packet.IsAlive, packet.IsAI);
}
}
@@ -213,7 +216,7 @@ private void OnBorderZonePacketReceived(BorderZonePacket packet)
{
if (player.ProfileId == packet.ProfileId)
{
- GInterface94 playerBridge = Singleton.Instance.GetAlivePlayerBridgeByProfileID(player.ProfileId);
+ GInterface106 playerBridge = Singleton.Instance.GetAlivePlayerBridgeByProfileID(player.ProfileId);
borderZone.ProcessIncomingPacket(playerBridge, true);
}
}
@@ -227,7 +230,7 @@ private void OnMinePacketReceived(MinePacket packet)
{
if (Singleton.Instance.MineManager != null)
{
- NetworkGame.Class1381 mineSeeker = new()
+ NetworkGame.Class1403 mineSeeker = new()
{
minePosition = packet.MinePositon
};
@@ -258,7 +261,10 @@ private void OnBTRInteractionPacketReceived(BTRInteractionPacket packet)
private void OnBTRPacketReceived(BTRPacket packet)
{
- CoopHandler.clientBTR?.btrPackets.Enqueue(packet);
+ if (coopHandler.clientBTR != null)
+ {
+ coopHandler.clientBTR.btrPackets.Enqueue(packet);
+ }
}
private void OnWeatherPacketReceived(WeatherPacket packet)
@@ -267,7 +273,7 @@ private void OnWeatherPacketReceived(WeatherPacket packet)
{
if (WeatherController.Instance != null)
{
- WeatherController.Instance.method_4(packet.WeatherClasses);
+ WeatherController.Instance.method_0(packet.WeatherClasses);
}
else
{
@@ -369,13 +375,13 @@ private void OnGenericPacketReceived(GenericPacket packet)
{
case EPackageType.ClientExtract:
{
- if (CoopHandler.Players.TryGetValue(packet.NetId, out CoopPlayer playerToApply))
+ if (coopHandler.Players.TryGetValue(packet.NetId, out CoopPlayer playerToApply))
{
- CoopHandler.Players.Remove(packet.NetId);
- if (!CoopHandler.ExtractedPlayers.Contains(packet.NetId))
+ coopHandler.Players.Remove(packet.NetId);
+ if (!coopHandler.ExtractedPlayers.Contains(packet.NetId))
{
- CoopHandler.ExtractedPlayers.Add(packet.NetId);
- CoopGame coopGame = (CoopGame)CoopHandler.LocalGameInstance;
+ coopHandler.ExtractedPlayers.Add(packet.NetId);
+ CoopGame coopGame = (CoopGame)coopHandler.LocalGameInstance;
coopGame.ExtractedPlayers.Add(packet.NetId);
coopGame.ClearHostAI(playerToApply);
@@ -436,15 +442,22 @@ private void OnGenericPacketReceived(GenericPacket packet)
break;
case EPackageType.TraderServiceNotification:
{
- CoopHandler.clientBTR?.DisplayNetworkNotification(packet.TraderServiceType);
+ if (coopHandler.clientBTR)
+ {
+ coopHandler.clientBTR.DisplayNetworkNotification(packet.TraderServiceType);
+ }
}
break;
case EPackageType.DisposeBot:
{
- if (CoopHandler.Players.TryGetValue(packet.BotNetId, out CoopPlayer botToDispose))
+ if (coopHandler.Players.TryGetValue(packet.BotNetId, out CoopPlayer botToDispose))
{
+ if (!botToDispose.gameObject.activeSelf)
+ {
+ botToDispose.gameObject.SetActive(true);
+ }
- if (CoopHandler.Players.Remove(packet.BotNetId))
+ if (coopHandler.Players.Remove(packet.BotNetId))
{
botToDispose.Dispose();
AssetPoolObject.ReturnToPool(botToDispose.gameObject, true);
@@ -471,12 +484,12 @@ private void OnGenericPacketReceived(GenericPacket packet)
break;
case EPackageType.EnableBot:
{
- if (CoopHandler.Players.TryGetValue(packet.BotNetId, out CoopPlayer botToEnable))
+ if (coopHandler.Players.TryGetValue(packet.BotNetId, out CoopPlayer botToEnable))
{
if (!botToEnable.gameObject.activeSelf)
{
#if DEBUG
- clientLogger.LogWarning("Enabling " + packet.BotNetId);
+ clientLogger.LogWarning("Enabling " + packet.BotNetId);
#endif
botToEnable.gameObject.SetActive(true);
}
@@ -489,12 +502,12 @@ private void OnGenericPacketReceived(GenericPacket packet)
break;
case EPackageType.DisableBot:
{
- if (CoopHandler.Players.TryGetValue(packet.BotNetId, out CoopPlayer botToEnable))
+ if (coopHandler.Players.TryGetValue(packet.BotNetId, out CoopPlayer botToEnable))
{
if (botToEnable.gameObject.activeSelf)
{
#if DEBUG
- clientLogger.LogWarning("Disabling " + packet.BotNetId);
+ clientLogger.LogWarning("Disabling " + packet.BotNetId);
#endif
botToEnable.gameObject.SetActive(false);
}
@@ -512,7 +525,7 @@ private void OnHealthSyncPacketReceived(HealthSyncPacket packet)
{
if (Players.TryGetValue(packet.NetId, out CoopPlayer playerToApply))
{
- playerToApply?.PacketReceiver?.HealthSyncPackets?.Enqueue(packet);
+ playerToApply.PacketReceiver?.HealthSyncPackets?.Enqueue(packet);
}
}
@@ -579,7 +592,7 @@ private void OnAllCharacterRequestPacketReceived(AllCharacterRequestPacket packe
clientLogger.LogInfo($"Received CharacterRequest! ProfileID: {packet.PlayerInfo.Profile.ProfileId}, Nickname: {packet.PlayerInfo.Profile.Nickname}");
if (packet.ProfileId != MyPlayer.ProfileId)
{
- CoopHandler.QueueProfile(packet.PlayerInfo.Profile, packet.Position, packet.NetId, packet.IsAlive, packet.IsAI);
+ coopHandler.QueueProfile(packet.PlayerInfo.Profile, packet.Position, packet.NetId, packet.IsAlive, packet.IsAI);
}
}
else if (packet.IsRequest)
@@ -606,7 +619,7 @@ private void OnCommonPlayerPacketReceived(CommonPlayerPacket packet)
{
if (Players.TryGetValue(packet.NetId, out CoopPlayer playerToApply))
{
- playerToApply?.PacketReceiver?.CommonPlayerPackets?.Enqueue(packet);
+ playerToApply.PacketReceiver?.CommonPlayerPackets?.Enqueue(packet);
}
}
@@ -614,7 +627,7 @@ private void OnInventoryPacketReceived(InventoryPacket packet)
{
if (Players.TryGetValue(packet.NetId, out CoopPlayer playerToApply))
{
- playerToApply?.PacketReceiver?.InventoryPackets?.Enqueue(packet);
+ playerToApply.PacketReceiver?.InventoryPackets?.Enqueue(packet);
}
}
@@ -622,7 +635,7 @@ private void OnDamagePacketReceived(DamagePacket packet)
{
if (Players.TryGetValue(packet.NetId, out CoopPlayer playerToApply))
{
- playerToApply?.PacketReceiver?.DamagePackets?.Enqueue(packet);
+ playerToApply.PacketReceiver?.DamagePackets?.Enqueue(packet);
}
}
@@ -630,7 +643,7 @@ private void OnFirearmPacketReceived(WeaponPacket packet)
{
if (Players.TryGetValue(packet.NetId, out CoopPlayer playerToApply))
{
- playerToApply?.PacketReceiver?.FirearmPackets?.Enqueue(packet);
+ playerToApply.PacketReceiver?.FirearmPackets?.Enqueue(packet);
}
}
@@ -671,19 +684,14 @@ private void OnPlayerStatePacketReceived(PlayerStatePacket packet)
}
}
- protected void Awake()
- {
- CoopHandler = CoopHandler.CoopHandlerParent.GetComponent();
- }
-
protected void Update()
{
- _netClient.PollEvents();
+ _netClient?.PollEvents();
- if (_netClient.FirstPeer == null)
+ /*if (_netClient.FirstPeer == null)
{
_netClient.SendBroadcast([1], Port);
- }
+ }*/
}
protected void OnDestroy()
diff --git a/Fika.Core/Networking/FikaPingingClient.cs b/Fika.Core/Networking/FikaPingingClient.cs
index ef77fa1a..8dc5a14e 100644
--- a/Fika.Core/Networking/FikaPingingClient.cs
+++ b/Fika.Core/Networking/FikaPingingClient.cs
@@ -1,4 +1,5 @@
using BepInEx.Logging;
+using Fika.Core.Coop.Matchmaker;
using Fika.Core.Networking.Http;
using Fika.Core.Networking.Http.Models;
using LiteNetLib;
@@ -14,6 +15,7 @@ internal class FikaPingingClient(string serverId) : INetEventListener
private readonly ManualLogSource _logger = Logger.CreateLogSource("Fika.PingingClient");
private readonly string serverId = serverId;
private IPEndPoint remoteEndPoint;
+ private IPEndPoint localEndPoint;
public bool Received = false;
public bool Init()
@@ -26,7 +28,12 @@ public bool Init()
GetHostRequest body = new(serverId);
GetHostResponse result = FikaRequestHandler.GetHost(body);
- string ip = result.Ip;
+ string ip = result.Ips[0];
+ string localIp = null;
+ if (result.Ips.Length > 1)
+ {
+ localIp = result.Ips[1];
+ }
int port = result.Port;
if (string.IsNullOrEmpty(ip))
@@ -42,23 +49,31 @@ public bool Init()
}
remoteEndPoint = new(IPAddress.Parse(ip), port);
+ if (!string.IsNullOrEmpty(localIp))
+ {
+ localEndPoint = new(IPAddress.Parse(localIp), port);
+ }
NetClient.Start();
return true;
}
- public bool PingEndPoint()
+ public void PingEndPoint()
{
if (Received)
{
- return true;
+ return;
}
NetDataWriter writer = new();
writer.Put("fika.hello");
- return NetClient.SendUnconnectedMessage(writer, remoteEndPoint);
+ NetClient.SendUnconnectedMessage(writer, remoteEndPoint);
+ if (localEndPoint != null)
+ {
+ NetClient.SendUnconnectedMessage(writer, localEndPoint);
+ }
}
public void OnConnectionRequest(ConnectionRequest request)
@@ -94,6 +109,8 @@ public void OnNetworkReceiveUnconnected(IPEndPoint remoteEndPoint, NetPacketRead
if (result == "fika.hello")
{
Received = true;
+ MatchmakerAcceptPatches.RemoteIp = remoteEndPoint.Address.ToString();
+ MatchmakerAcceptPatches.RemotePort = remoteEndPoint.Port;
}
else
{
diff --git a/Fika.Core/Networking/FikaSerialization.cs b/Fika.Core/Networking/FikaSerialization.cs
index 846c70dc..c88770eb 100644
--- a/Fika.Core/Networking/FikaSerialization.cs
+++ b/Fika.Core/Networking/FikaSerialization.cs
@@ -17,14 +17,14 @@ public class FikaSerialization
/*public class AddressUtils
{
- public static void SerializeGridItemAddressDescriptor(NetDataWriter writer, GClass1528 gridItemAddressDescriptor)
+ public static void SerializeGridItemAddressDescriptor(NetDataWriter writer, GClass1538 gridItemAddressDescriptor)
{
SerializeLocationInGrid(writer, gridItemAddressDescriptor.LocationInGrid);
}
- public static GClass1528 DeserializeGridItemAddressDescriptor(NetDataReader reader)
+ public static GClass1538 DeserializeGridItemAddressDescriptor(NetDataReader reader)
{
- return new GClass1528()
+ return new GClass1538()
{
LocationInGrid = DeserializeLocationInGrid(reader),
Container = DeserializeContainerDescriptor(reader)
@@ -227,13 +227,13 @@ public static void SerializeInventory(NetDataWriter writer, Inventory inventory)
{
GClass1489 inventoryDescriptor = new GClass1489()
{
- Equipment = GClass1524.SerializeItem(inventory.Equipment),
- Stash = GClass1524.SerializeItem(inventory.Stash),
- QuestRaidItems = GClass1524.SerializeItem(inventory.QuestRaidItems),
- QuestStashItems = GClass1524.SerializeItem(inventory.QuestStashItems),
- SortingTable = GClass1524.SerializeItem(inventory.SortingTable),
- FastAccess = GClass1524.SerializeFastAccess(inventory.FastAccess),
- DiscardLimits = GClass1524.SerializeDiscardLimits(inventory.DiscardLimits)
+ Equipment = GClass1534.SerializeItem(inventory.Equipment),
+ Stash = GClass1534.SerializeItem(inventory.Stash),
+ QuestRaidItems = GClass1534.SerializeItem(inventory.QuestRaidItems),
+ QuestStashItems = GClass1534.SerializeItem(inventory.QuestStashItems),
+ SortingTable = GClass1534.SerializeItem(inventory.SortingTable),
+ FastAccess = GClass1534.SerializeFastAccess(inventory.FastAccess),
+ DiscardLimits = GClass1534.SerializeDiscardLimits(inventory.DiscardLimits)
};
GClass1081 polyWriter = new();
polyWriter.WriteEFTInventoryDescriptor(inventoryDescriptor);
@@ -244,7 +244,7 @@ public static Inventory DeserializeInventory(byte[] inventoryBytes)
{
using MemoryStream memoryStream = new(inventoryBytes);
BinaryReader polyReader = new(memoryStream);
- Inventory inventory = GClass1524.DeserializeInventory(Singleton.Instance, polyReader.ReadEFTInventoryDescriptor());
+ Inventory inventory = GClass1534.DeserializeInventory(Singleton.Instance, polyReader.ReadEFTInventoryDescriptor());
return inventory;
}
}*/
@@ -273,14 +273,14 @@ public static PlayerInfoPacket Deserialize(NetDataReader reader)
public struct LightStatesPacket
{
public int Amount;
- public GStruct163[] LightStates;
+ public GStruct164[] LightStates;
public static LightStatesPacket Deserialize(NetDataReader reader)
{
LightStatesPacket packet = new();
packet.Amount = reader.GetInt();
if (packet.Amount > 0)
{
- packet.LightStates = new GStruct163[packet.Amount];
+ packet.LightStates = new GStruct164[packet.Amount];
for (int i = 0; i < packet.Amount; i++)
{
packet.LightStates[i] = new()
@@ -312,14 +312,14 @@ public static void Serialize(NetDataWriter writer, LightStatesPacket packet)
public struct HeadLightsPacket
{
public int Amount;
- public GStruct163[] LightStates;
+ public GStruct164[] LightStates;
public static HeadLightsPacket Deserialize(NetDataReader reader)
{
HeadLightsPacket packet = new();
packet.Amount = reader.GetInt();
if (packet.Amount > 0)
{
- packet.LightStates = new GStruct163[packet.Amount];
+ packet.LightStates = new GStruct164[packet.Amount];
for (int i = 0; i < packet.Amount; i++)
{
packet.LightStates[i] = new()
@@ -351,17 +351,17 @@ public static void Serialize(NetDataWriter writer, HeadLightsPacket packet)
public struct ScopeStatesPacket
{
public int Amount;
- public GStruct164[] GStruct164;
+ public GStruct165[] GStruct165;
public static ScopeStatesPacket Deserialize(NetDataReader reader)
{
ScopeStatesPacket packet = new();
packet.Amount = reader.GetInt();
if (packet.Amount > 0)
{
- packet.GStruct164 = new GStruct164[packet.Amount];
+ packet.GStruct165 = new GStruct165[packet.Amount];
for (int i = 0; i < packet.Amount; i++)
{
- packet.GStruct164[i] = new()
+ packet.GStruct165[i] = new()
{
Id = reader.GetString(),
ScopeMode = reader.GetInt(),
@@ -380,10 +380,10 @@ public static void Serialize(NetDataWriter writer, ScopeStatesPacket packet)
{
for (int i = 0; i < packet.Amount; i++)
{
- writer.Put(packet.GStruct164[i].Id);
- writer.Put(packet.GStruct164[i].ScopeMode);
- writer.Put(packet.GStruct164[i].ScopeIndexInsideSight);
- writer.Put(packet.GStruct164[i].ScopeCalibrationIndex);
+ writer.Put(packet.GStruct165[i].Id);
+ writer.Put(packet.GStruct165[i].ScopeMode);
+ writer.Put(packet.GStruct165[i].ScopeIndexInsideSight);
+ writer.Put(packet.GStruct165[i].ScopeCalibrationIndex);
}
}
}
@@ -892,7 +892,6 @@ public static void Serialize(NetDataWriter writer, KnifePacket packet)
public struct ShotInfoPacket()
{
- public bool IsPrimaryActive = true;
public EShotType ShotType = EShotType.Unknown;
public int AmmoAfterShot = 0;
public Vector3 ShotPosition = Vector3.zero;
@@ -910,7 +909,6 @@ public static ShotInfoPacket Deserialize(NetDataReader reader)
{
ShotInfoPacket packet = new()
{
- IsPrimaryActive = reader.GetBool(),
ShotType = (EShotType)reader.GetInt(),
AmmoAfterShot = reader.GetInt(),
ShotPosition = reader.GetVector3(),
@@ -929,7 +927,6 @@ public static ShotInfoPacket Deserialize(NetDataReader reader)
}
public static void Serialize(NetDataWriter writer, ShotInfoPacket packet)
{
- writer.Put(packet.IsPrimaryActive);
writer.Put((int)packet.ShotType);
writer.Put(packet.AmmoAfterShot);
writer.Put(packet.ShotPosition);
@@ -1119,8 +1116,8 @@ public static BTRDataPacket Deserialize(NetDataReader reader)
LeftSideState = reader.GetByte(),
RouteState = reader.GetByte(),
State = reader.GetByte(),
- gunsBlockRotation = reader.GetQuaternion(),
- turretRotation = reader.GetQuaternion(),
+ gunsBlockRotation = reader.GetFloat(),
+ turretRotation = reader.GetFloat(),
rotation = reader.GetQuaternion()
};
}
diff --git a/Fika.Core/Networking/FikaSerializationExtensions.cs b/Fika.Core/Networking/FikaSerializationExtensions.cs
index 2a3ce5b6..cfc0b2a7 100644
--- a/Fika.Core/Networking/FikaSerializationExtensions.cs
+++ b/Fika.Core/Networking/FikaSerializationExtensions.cs
@@ -107,11 +107,11 @@ public static Color GetColor(this NetDataReader reader)
}
///
- /// Serializes a (Physical) struct
+ /// Serializes a (Physical) struct
///
///
///
- public static void Put(this NetDataWriter writer, GStruct35 physical)
+ public static void Put(this NetDataWriter writer, GStruct36 physical)
{
writer.Put(physical.StaminaExhausted);
writer.Put(physical.OxygenExhausted);
@@ -119,13 +119,13 @@ public static void Put(this NetDataWriter writer, GStruct35 physical)
}
///
- /// Deserializes a (Physical) struct
+ /// Deserializes a (Physical) struct
///
///
- /// A (Physical)
- public static GStruct35 GetPhysical(this NetDataReader reader)
+ /// A (Physical)
+ public static GStruct36 GetPhysical(this NetDataReader reader)
{
- return new GStruct35() { StaminaExhausted = reader.GetBool(), OxygenExhausted = reader.GetBool(), HandsExhausted = reader.GetBool() };
+ return new GStruct36() { StaminaExhausted = reader.GetBool(), OxygenExhausted = reader.GetBool(), HandsExhausted = reader.GetBool() };
}
///
@@ -188,7 +188,7 @@ public static void PutAirdropItem(this NetDataWriter writer, Item item)
{
using MemoryStream memoryStream = new();
using BinaryWriter binaryWriter = new(memoryStream);
- binaryWriter.Write(GClass1524.SerializeItem(item));
+ binaryWriter.Write(GClass1534.SerializeItem(item));
writer.PutByteArray(memoryStream.ToArray());
}
@@ -202,12 +202,12 @@ public static Item GetAirdropItem(this NetDataReader reader)
using MemoryStream memoryStream = new(reader.GetByteArray());
using BinaryReader binaryReader = new(memoryStream);
- Item item = GClass1524.DeserializeItem(Singleton.Instance, [], binaryReader.ReadEFTItemDescriptor());
+ Item item = GClass1534.DeserializeItem(Singleton.Instance, [], binaryReader.ReadEFTItemDescriptor());
ContainerCollection[] containerCollections = [item as ContainerCollection];
ResourceKey[] resourceKeys = containerCollections.GetAllItemsFromCollections()
- .Concat(containerCollections.Where(new Func- (AirdropSynchronizableObject.Class1802.class1802_0.method_2)))
- .SelectMany(new Func
- >(AirdropSynchronizableObject.Class1802.class1802_0.method_3))
+ .Concat(containerCollections.Where(new Func
- (AirdropSynchronizableObject.Class1828.class1828_0.method_2)))
+ .SelectMany(new Func
- >(AirdropSynchronizableObject.Class1828.class1828_0.method_3))
.ToArray();
Singleton.Instance.LoadBundlesAndCreatePools(PoolManager.PoolsCategory.Raid, PoolManager.AssemblyType.Online, resourceKeys, JobPriority.Immediate, null, default);
@@ -223,7 +223,7 @@ public static void PutItem(this NetDataWriter writer, Item item)
{
using MemoryStream memoryStream = new();
using BinaryWriter binaryWriter = new(memoryStream);
- binaryWriter.Write(GClass1524.SerializeItem(item));
+ binaryWriter.Write(GClass1534.SerializeItem(item));
writer.PutByteArray(memoryStream.ToArray());
}
@@ -237,7 +237,7 @@ public static Item GetItem(this NetDataReader reader)
using MemoryStream memoryStream = new(reader.GetByteArray());
using BinaryReader binaryReader = new(memoryStream);
- return GClass1524.DeserializeItem(Singleton.Instance, [], binaryReader.ReadEFTItemDescriptor());
+ return GClass1534.DeserializeItem(Singleton.Instance, [], binaryReader.ReadEFTItemDescriptor());
}
}
}
diff --git a/Fika.Core/Networking/FikaServer.cs b/Fika.Core/Networking/FikaServer.cs
index b6a25dd2..2d410a11 100644
--- a/Fika.Core/Networking/FikaServer.cs
+++ b/Fika.Core/Networking/FikaServer.cs
@@ -38,12 +38,12 @@ public class FikaServer : MonoBehaviour, INetEventListener, INetLogger
private NetManager _netServer;
public NetPacketProcessor packetProcessor = new();
private readonly NetDataWriter _dataWriter = new();
- public CoopPlayer MyPlayer => (CoopPlayer)Singleton.Instance.MainPlayer;
- public Dictionary Players => CoopHandler.Players;
+ public CoopPlayer MyPlayer;
+ public Dictionary Players => coopHandler.Players;
public List PlayersMissing = [];
public string MyExternalIP { get; private set; } = NetUtils.GetLocalIp(LocalAddrType.IPv4);
private int Port => FikaPlugin.UDPPort.Value;
- private CoopHandler CoopHandler { get; set; }
+ private CoopHandler coopHandler;
public int ReadyClients = 0;
public NetManager NetServer
{
@@ -55,10 +55,20 @@ public NetManager NetServer
public DateTime timeSinceLastPeerDisconnected = DateTime.Now.AddDays(1);
public bool hasHadPeer = false;
private readonly ManualLogSource serverLogger = BepInEx.Logging.Logger.CreateLogSource("Fika.Server");
- public bool ServerReady = false;
private int _currentNetId;
+ public bool Started
+ {
+ get
+ {
+ if (_netServer == null)
+ {
+ return false;
+ }
+ return _netServer.IsRunning;
+ }
+ }
- public async void Start()
+ public async Task Init()
{
// Start at 1 to avoid having 0 and making us think it's working when it's not
_currentNetId = 1;
@@ -83,7 +93,6 @@ public async void Start()
packetProcessor.SubscribeNetSerializable(OnMinePacketReceived);
packetProcessor.SubscribeNetSerializable(OnBorderZonePacketReceived);
packetProcessor.SubscribeNetSerializable(OnSendCharacterPacketReceived);
- packetProcessor.SubscribeNetSerializable(OnSessionSettingsPacketReceived);
_netServer = new NetManager(this)
{
@@ -101,24 +110,21 @@ public async void Start()
{
bool upnpFailed = false;
- await Task.Run(async () =>
+ try
{
- try
- {
- NatDiscoverer discoverer = new();
- CancellationTokenSource cts = new(10000);
- NatDevice device = await discoverer.DiscoverDeviceAsync(PortMapper.Upnp, cts);
- IPAddress extIp = await device.GetExternalIPAsync();
- MyExternalIP = extIp.MapToIPv4().ToString();
+ NatDiscoverer discoverer = new();
+ CancellationTokenSource cts = new(10000);
+ NatDevice device = await discoverer.DiscoverDeviceAsync(PortMapper.Upnp, cts);
+ IPAddress extIp = await device.GetExternalIPAsync();
+ MyExternalIP = extIp.MapToIPv4().ToString();
- await device.CreatePortMapAsync(new Mapping(Protocol.Udp, Port, Port, 300, "Fika UDP"));
- }
- catch (Exception ex)
- {
- serverLogger.LogError($"Error when attempting to map UPnP. Make sure the selected port is not already open! Error message: {ex.Message}");
- upnpFailed = true;
- }
- });
+ await device.CreatePortMapAsync(new Mapping(Protocol.Udp, Port, Port, 300, "Fika UDP"));
+ }
+ catch (Exception ex)
+ {
+ serverLogger.LogError($"Error when attempting to map UPnP. Make sure the selected port is not already open! Error message: {ex.Message}");
+ upnpFailed = true;
+ }
if (upnpFailed)
{
@@ -157,29 +163,27 @@ await Task.Run(async () =>
NotificationManagerClass.DisplayMessageNotification($"Server started on port {_netServer.LocalPort}.",
EFT.Communications.ENotificationDurationType.Default, EFT.Communications.ENotificationIconType.EntryPoint);
- SetHostRequest body = new(MyExternalIP, Port);
- FikaRequestHandler.UpdateSetHost(body);
+ string[] Ips = [];
- Singleton.Create(this);
- FikaEventDispatcher.DispatchEvent(new FikaServerCreatedEvent(this));
- ServerReady = true;
- }
-
- private void OnSessionSettingsPacketReceived(SessionSettingsPacket packet, NetPeer peer)
- {
- if (packet.IsRequest)
+ foreach (string ip in FikaPlugin.Instance.LocalIPs)
{
- CoopGame coopGame = (CoopGame)Singleton.Instance;
- if (coopGame != null)
+ if (ip.StartsWith("192.168")) // need to add more cases here later, for now only check normal range...
{
- SessionSettingsPacket returnPacket = new(false)
- {
- MetabolismDisabled = coopGame.RaidSettings.MetabolismDisabled
- };
-
- SendDataToPeer(peer, new(), ref returnPacket, DeliveryMethod.ReliableUnordered);
+ Ips = [MyExternalIP, ip];
}
}
+
+ if (Ips.Length < 1)
+ {
+ Ips = [MyExternalIP, ""];
+ NotificationManagerClass.DisplayMessageNotification("Could not find a valid local IP!",
+ iconType: EFT.Communications.ENotificationIconType.Alert);
+ }
+
+ SetHostRequest body = new(Ips, Port);
+ FikaRequestHandler.UpdateSetHost(body);
+
+ FikaEventDispatcher.DispatchEvent(new FikaServerCreatedEvent(this));
}
public int PopNetId()
@@ -190,13 +194,19 @@ public int PopNetId()
return netId;
}
+ public void SetupGameVariables(CoopPlayer coopPlayer)
+ {
+ coopHandler = CoopHandler.CoopHandlerParent.GetComponent();
+ MyPlayer = coopPlayer;
+ }
+
private void OnSendCharacterPacketReceived(SendCharacterPacket packet, NetPeer peer)
{
int netId = PopNetId();
packet.netId = netId;
if (packet.PlayerInfo.Profile.ProfileId != MyPlayer.ProfileId)
{
- CoopHandler.QueueProfile(packet.PlayerInfo.Profile, packet.Position, packet.netId, packet.IsAlive, packet.IsAI);
+ coopHandler.QueueProfile(packet.PlayerInfo.Profile, packet.Position, packet.netId, packet.IsAlive, packet.IsAI);
}
_dataWriter.Reset();
@@ -221,7 +231,7 @@ private void OnMinePacketReceived(MinePacket packet, NetPeer peer)
{
if (Singleton.Instance.MineManager != null)
{
- NetworkGame.Class1381 mineSeeker = new()
+ NetworkGame.Class1403 mineSeeker = new()
{
minePosition = packet.MinePositon
};
@@ -247,18 +257,21 @@ private void OnDeathPacketReceived(DeathPacket packet, NetPeer peer)
private void OnBTRServicePacketReceived(BTRServicePacket packet, NetPeer peer)
{
- CoopHandler.serverBTR?.NetworkBtrTraderServicePurchased(packet);
+ if (coopHandler.serverBTR != null)
+ {
+ coopHandler.serverBTR.NetworkBtrTraderServicePurchased(packet);
+ }
}
private void OnBTRInteractionPacketReceived(BTRInteractionPacket packet, NetPeer peer)
{
- if (CoopHandler.serverBTR != null)
+ if (coopHandler.serverBTR != null)
{
if (Players.TryGetValue(packet.NetId, out CoopPlayer player))
{
- if (CoopHandler.serverBTR.CanPlayerEnter(player))
+ if (coopHandler.serverBTR.CanPlayerEnter(player))
{
- CoopHandler.serverBTR.HostObservedInteraction(player, packet.InteractPacket);
+ coopHandler.serverBTR.HostObservedInteraction(player, packet.InteractPacket);
_dataWriter.Reset();
SendDataToAll(_dataWriter, ref packet, DeliveryMethod.ReliableOrdered);
@@ -344,13 +357,13 @@ private void OnGenericPacketReceived(GenericPacket packet, NetPeer peer)
{
if (packet.PacketType == EPackageType.ClientExtract)
{
- if (CoopHandler.Players.TryGetValue(packet.NetId, out CoopPlayer playerToApply))
+ if (coopHandler.Players.TryGetValue(packet.NetId, out CoopPlayer playerToApply))
{
- CoopHandler.Players.Remove(packet.NetId);
- if (!CoopHandler.ExtractedPlayers.Contains(packet.NetId))
+ coopHandler.Players.Remove(packet.NetId);
+ if (!coopHandler.ExtractedPlayers.Contains(packet.NetId))
{
- CoopHandler.ExtractedPlayers.Add(packet.NetId);
- CoopGame coopGame = (CoopGame)CoopHandler.LocalGameInstance;
+ coopHandler.ExtractedPlayers.Add(packet.NetId);
+ CoopGame coopGame = (CoopGame)coopHandler.LocalGameInstance;
coopGame.ExtractedPlayers.Add(packet.NetId);
coopGame.ClearHostAI(playerToApply);
@@ -407,7 +420,7 @@ private void OnHealthSyncPacketReceived(HealthSyncPacket packet, NetPeer peer)
{
if (Players.TryGetValue(packet.NetId, out CoopPlayer playerToApply))
{
- playerToApply?.PacketReceiver?.HealthSyncPackets?.Enqueue(packet);
+ playerToApply.PacketReceiver?.HealthSyncPackets?.Enqueue(packet);
}
_dataWriter.Reset();
@@ -433,10 +446,9 @@ private void OnInformationPacketReceived(InformationPacket packet, NetPeer peer)
private void OnAllCharacterRequestPacketReceived(AllCharacterRequestPacket packet, NetPeer peer)
{
- // This method needs to be refined. For some reason the ping-pong has to be run twice for it to work on the host?
if (packet.IsRequest)
{
- foreach (CoopPlayer player in CoopHandler.Players.Values)
+ foreach (CoopPlayer player in coopHandler.Players.Values)
{
if (player.ProfileId == packet.ProfileId)
{
@@ -464,7 +476,7 @@ private void OnAllCharacterRequestPacketReceived(AllCharacterRequestPacket packe
SendDataToPeer(peer, _dataWriter, ref requestPacket, DeliveryMethod.ReliableOrdered);
}
}
- if (!Players.ContainsKey(packet.NetId) && !PlayersMissing.Contains(packet.ProfileId) && !CoopHandler.ExtractedPlayers.Contains(packet.NetId))
+ if (!Players.ContainsKey(packet.NetId) && !PlayersMissing.Contains(packet.ProfileId) && !coopHandler.ExtractedPlayers.Contains(packet.NetId))
{
PlayersMissing.Add(packet.ProfileId);
serverLogger.LogInfo($"Requesting missing player from server.");
@@ -477,7 +489,7 @@ private void OnAllCharacterRequestPacketReceived(AllCharacterRequestPacket packe
serverLogger.LogInfo($"Received CharacterRequest from client: ProfileID: {packet.PlayerInfo.Profile.ProfileId}, Nickname: {packet.PlayerInfo.Profile.Nickname}");
if (packet.ProfileId != MyPlayer.ProfileId)
{
- CoopHandler.QueueProfile(packet.PlayerInfo.Profile, new Vector3(packet.Position.x, packet.Position.y + 0.5f, packet.Position.y), packet.NetId, packet.IsAlive);
+ coopHandler.QueueProfile(packet.PlayerInfo.Profile, new Vector3(packet.Position.x, packet.Position.y + 0.5f, packet.Position.y), packet.NetId, packet.IsAlive);
PlayersMissing.Remove(packet.ProfileId);
}
}
@@ -487,7 +499,7 @@ private void OnCommonPlayerPacketReceived(CommonPlayerPacket packet, NetPeer pee
{
if (Players.TryGetValue(packet.NetId, out CoopPlayer playerToApply))
{
- playerToApply?.PacketReceiver?.CommonPlayerPackets?.Enqueue(packet);
+ playerToApply.PacketReceiver?.CommonPlayerPackets?.Enqueue(packet);
}
_dataWriter.Reset();
@@ -502,7 +514,7 @@ private void OnInventoryPacketReceived(InventoryPacket packet, NetPeer peer)
using BinaryReader binaryReader = new(memoryStream);
try
{
- GStruct411 result = playerToApply.ToInventoryOperation(binaryReader.ReadPolymorph());
+ GStruct412 result = playerToApply.ToInventoryOperation(binaryReader.ReadPolymorph());
InventoryOperationHandler opHandler = new()
{
@@ -520,9 +532,9 @@ private void OnInventoryPacketReceived(InventoryPacket packet, NetPeer peer)
// TODO: Hacky workaround to fix errors due to each client generating new IDs. Might need to find a more 'elegant' solution later.
// Unknown what problems this might cause so far.
- if (result.Value is GClass2861 unloadOperation)
+ if (result.Value is GClass2874 unloadOperation)
{
- if (unloadOperation.InternalOperation is GClass2872 internalSplitOperation)
+ if (unloadOperation.InternalOperation is GClass2885 internalSplitOperation)
{
Item item = internalSplitOperation.To.Item;
if (item != null)
@@ -544,7 +556,7 @@ private void OnInventoryPacketReceived(InventoryPacket packet, NetPeer peer)
}
// TODO: Same as above.
- if (result.Value is GClass2872 splitOperation)
+ if (result.Value is GClass2885 splitOperation)
{
Item item = splitOperation.To.Item;
if (item != null)
@@ -589,7 +601,7 @@ private void OnDamagePacketReceived(DamagePacket packet, NetPeer peer)
{
if (Players.TryGetValue(packet.NetId, out CoopPlayer playerToApply))
{
- playerToApply?.PacketReceiver?.DamagePackets?.Enqueue(packet);
+ playerToApply.PacketReceiver?.DamagePackets?.Enqueue(packet);
}
_dataWriter.Reset();
@@ -600,7 +612,7 @@ private void OnFirearmPacketReceived(WeaponPacket packet, NetPeer peer)
{
if (Players.TryGetValue(packet.NetId, out CoopPlayer playerToApply))
{
- playerToApply?.PacketReceiver?.FirearmPackets?.Enqueue(packet);
+ playerToApply.PacketReceiver?.FirearmPackets?.Enqueue(packet);
}
_dataWriter.Reset();
@@ -636,17 +648,12 @@ private void OnPlayerStatePacketReceived(PlayerStatePacket packet, NetPeer peer)
SendDataToAll(_dataWriter, ref packet, DeliveryMethod.ReliableOrdered, peer);
}
- protected void Awake()
- {
- CoopHandler = CoopHandler.CoopHandlerParent.GetComponent();
- }
-
- void Update()
+ protected void Update()
{
- _netServer.PollEvents();
+ _netServer?.PollEvents();
}
- void OnDestroy()
+ protected void OnDestroy()
{
NetDebug.Logger = null;
_netServer?.Stop();
@@ -754,7 +761,7 @@ public void OnNetworkReceive(NetPeer peer, NetPacketReader reader, byte channelN
private class InventoryOperationHandler
{
- public GStruct411 opResult;
+ public GStruct412 opResult;
public uint operationId;
public int netId;
public NetPeer peer;
@@ -782,7 +789,7 @@ internal void HandleResult(IResult result)
using MemoryStream memoryStream = new();
using BinaryWriter binaryWriter = new(memoryStream);
- binaryWriter.WritePolymorph(GClass1632.FromInventoryOperation(opResult.Value, false));
+ binaryWriter.WritePolymorph(GClass1642.FromInventoryOperation(opResult.Value, false));
byte[] opBytes = memoryStream.ToArray();
packet.ItemControllerExecutePacket = new()
{
diff --git a/Fika.Core/Networking/Fuyu.Platform.Common/Http/FuyuClient.cs b/Fika.Core/Networking/Fuyu.Platform.Common/Http/FuyuClient.cs
index 88515aa6..b466531c 100644
--- a/Fika.Core/Networking/Fuyu.Platform.Common/Http/FuyuClient.cs
+++ b/Fika.Core/Networking/Fuyu.Platform.Common/Http/FuyuClient.cs
@@ -2,7 +2,7 @@
- Using Aki zlib (de-)compression
*/
-using Aki.Common.Utils;
+using SPT.Common.Utils;
using System;
using System.IO;
using System.Net.Http;
diff --git a/Fika.Core/Networking/Http/FikaHttpHandler.cs b/Fika.Core/Networking/Http/FikaHttpHandler.cs
index 232b7db0..8065063d 100644
--- a/Fika.Core/Networking/Http/FikaHttpHandler.cs
+++ b/Fika.Core/Networking/Http/FikaHttpHandler.cs
@@ -1,10 +1,10 @@
-using Aki.Common.Http;
using EFT;
using Fika.Core.Models;
using Fika.Core.Networking.Http.Models;
using Fika.Core.UI.Models;
using Fuyu.Platform.Common.Http;
using Newtonsoft.Json;
+using SPT.Common.Http;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
@@ -135,5 +135,10 @@ public static Dictionary AvailableReceivers(AvailableReceiversRe
{
return PostJson>("/fika/senditem/availablereceivers", data);
}
+
+ public static async Task GetRaidSettings(RaidSettingsRequest data)
+ {
+ return await PostJsonAsync("/fika/raid/getsettings", data);
+ }
}
}
\ No newline at end of file
diff --git a/Fika.Core/Networking/Models/GetHostResponse.cs b/Fika.Core/Networking/Models/GetHostResponse.cs
index 11f82482..1297c88f 100644
--- a/Fika.Core/Networking/Models/GetHostResponse.cs
+++ b/Fika.Core/Networking/Models/GetHostResponse.cs
@@ -5,15 +5,15 @@ namespace Fika.Core.Networking.Http.Models
[DataContract]
public struct GetHostResponse
{
- [DataMember(Name = "ip")]
- public string Ip;
+ [DataMember(Name = "ips")]
+ public string[] Ips;
[DataMember(Name = "port")]
public int Port;
- public GetHostResponse(string ip, int port)
+ public GetHostResponse(string[] ips, int port)
{
- Ip = ip;
+ Ips = ips;
Port = port;
}
}
diff --git a/Fika.Core/Networking/Models/ModValidationResponse.cs b/Fika.Core/Networking/Models/ModValidationResponse.cs
new file mode 100644
index 00000000..f5fba64c
--- /dev/null
+++ b/Fika.Core/Networking/Models/ModValidationResponse.cs
@@ -0,0 +1,17 @@
+using System.Runtime.Serialization;
+
+namespace Fika.Core.Networking.Http.Models
+{
+ [DataContract]
+ public struct ModValidationResponse
+ {
+ [DataMember(Name = "forbidden")]
+ public string[] Forbidden;
+
+ [DataMember(Name = "missingRequired")]
+ public string[] MissingRequired;
+
+ [DataMember(Name = "hashMismatch")]
+ public string[] HashMismatch;
+ }
+}
\ No newline at end of file
diff --git a/Fika.Core/Networking/Models/RaidSettingsRequest.cs b/Fika.Core/Networking/Models/RaidSettingsRequest.cs
new file mode 100644
index 00000000..b6df6a28
--- /dev/null
+++ b/Fika.Core/Networking/Models/RaidSettingsRequest.cs
@@ -0,0 +1,17 @@
+using Fika.Core.Coop.Components;
+using System.Runtime.Serialization;
+
+namespace Fika.Core.Networking.Http.Models
+{
+ [DataContract]
+ public struct RaidSettingsRequest
+ {
+ [DataMember(Name = "serverId")]
+ public string ServerId;
+
+ public RaidSettingsRequest()
+ {
+ ServerId = CoopHandler.GetServerId();
+ }
+ }
+}
\ No newline at end of file
diff --git a/Fika.Core/Networking/Models/RaidSettingsResponse.cs b/Fika.Core/Networking/Models/RaidSettingsResponse.cs
new file mode 100644
index 00000000..bb627ba5
--- /dev/null
+++ b/Fika.Core/Networking/Models/RaidSettingsResponse.cs
@@ -0,0 +1,13 @@
+using System.Runtime.Serialization;
+
+namespace Fika.Core.Networking.Http.Models
+{
+ [DataContract]
+ public struct RaidSettingsResponse(bool metabolismDisabled, string playersSpawnPlace)
+ {
+ [DataMember(Name = "metabolismDisabled")]
+ public bool MetabolismDisabled = metabolismDisabled;
+ [DataMember(Name = "playersSpawnPlace")]
+ public string PlayersSpawnPlace = playersSpawnPlace;
+ }
+}
\ No newline at end of file
diff --git a/Fika.Core/Networking/Models/SetHostRequest.cs b/Fika.Core/Networking/Models/SetHostRequest.cs
index aa539a09..57b9203b 100644
--- a/Fika.Core/Networking/Models/SetHostRequest.cs
+++ b/Fika.Core/Networking/Models/SetHostRequest.cs
@@ -9,16 +9,16 @@ public struct SetHostRequest
[DataMember(Name = "serverId")]
public string ServerId;
- [DataMember(Name = "ip")]
- public string Ip;
+ [DataMember(Name = "ips")]
+ public string[] Ips;
[DataMember(Name = "port")]
public int Port;
- public SetHostRequest(string ip, int port)
+ public SetHostRequest(string[] ips, int port)
{
ServerId = CoopHandler.GetServerId();
- Ip = ip;
+ Ips = ips;
Port = port;
}
}
diff --git a/Fika.Core/Networking/Open.Nat/Utils/Extensions.cs b/Fika.Core/Networking/Open.Nat/Utils/Extensions.cs
index 032f957c..a5c2a795 100644
--- a/Fika.Core/Networking/Open.Nat/Utils/Extensions.cs
+++ b/Fika.Core/Networking/Open.Nat/Utils/Extensions.cs
@@ -149,7 +149,7 @@ public static Task TimeoutAfter(this Task task, TimeS
public static async Task TimeoutAfter(this Task task, TimeSpan timeout)
{
#if DEBUG
- return await task;
+ return await task;
#endif
var timeoutCancellationTokenSource = new CancellationTokenSource();
diff --git a/Fika.Core/Networking/Packets/Backend/SessionSettingsPacket.cs b/Fika.Core/Networking/Packets/Backend/SessionSettingsPacket.cs
deleted file mode 100644
index d71661c5..00000000
--- a/Fika.Core/Networking/Packets/Backend/SessionSettingsPacket.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-using LiteNetLib.Utils;
-
-namespace Fika.Core.Networking
-{
- public struct SessionSettingsPacket(bool isRequest) : INetSerializable
- {
- public bool IsRequest = isRequest;
- public bool MetabolismDisabled;
-
- public void Deserialize(NetDataReader reader)
- {
- IsRequest = reader.GetBool();
- if (!IsRequest)
- {
- MetabolismDisabled = reader.GetBool();
- }
- }
-
- public void Serialize(NetDataWriter writer)
- {
- writer.Put(IsRequest);
- if (!IsRequest)
- {
- writer.Put(MetabolismDisabled);
- }
- }
- }
-}
diff --git a/Fika.Core/Networking/Packets/FirearmController/WeaponPacket.cs b/Fika.Core/Networking/Packets/FirearmController/WeaponPacket.cs
index ede93653..7a841088 100644
--- a/Fika.Core/Networking/Packets/FirearmController/WeaponPacket.cs
+++ b/Fika.Core/Networking/Packets/FirearmController/WeaponPacket.cs
@@ -54,6 +54,8 @@ public struct WeaponPacket(int netId) : INetSerializable
public bool ReloadBoltAction = false;
public bool HasRollCylinder = false;
public bool RollToZeroCamora = false;
+ public bool UnderbarrelSightingRangeUp = false;
+ public bool UnderbarrelSightingRangeDown = false;
public void Deserialize(NetDataReader reader)
{
@@ -123,6 +125,8 @@ public void Deserialize(NetDataReader reader)
HasRollCylinder = reader.GetBool();
if (HasRollCylinder)
RollToZeroCamora = reader.GetBool();
+ UnderbarrelSightingRangeUp = reader.GetBool();
+ UnderbarrelSightingRangeDown = reader.GetBool();
}
public void Serialize(NetDataWriter writer)
@@ -189,6 +193,8 @@ public void Serialize(NetDataWriter writer)
writer.Put(HasRollCylinder);
if (HasRollCylinder)
writer.Put(RollToZeroCamora);
+ writer.Put(UnderbarrelSightingRangeUp);
+ writer.Put(UnderbarrelSightingRangeDown);
}
}
}
diff --git a/Fika.Core/Networking/Packets/GameWorld/AirdropPacket.cs b/Fika.Core/Networking/Packets/GameWorld/AirdropPacket.cs
index 268ed6cd..554b7e68 100644
--- a/Fika.Core/Networking/Packets/GameWorld/AirdropPacket.cs
+++ b/Fika.Core/Networking/Packets/GameWorld/AirdropPacket.cs
@@ -1,8 +1,8 @@
// © 2024 Lacyway All Rights Reserved
-using Aki.Custom.Airdrops.Models;
using ComponentAce.Compression.Libs.zlib;
using LiteNetLib.Utils;
+using SPT.Custom.Airdrops.Models;
using UnityEngine;
namespace Fika.Core.Networking
diff --git a/Fika.Core/Networking/Packets/Player/HealthSyncPacket.cs b/Fika.Core/Networking/Packets/Player/HealthSyncPacket.cs
index c17ac483..28177c14 100644
--- a/Fika.Core/Networking/Packets/Player/HealthSyncPacket.cs
+++ b/Fika.Core/Networking/Packets/Player/HealthSyncPacket.cs
@@ -7,7 +7,7 @@ namespace Fika.Core.Networking
public struct HealthSyncPacket(int netId) : INetSerializable
{
public int NetId = netId;
- public GStruct346 Packet;
+ public GStruct347 Packet;
public string KillerId;
public string KillerWeaponId;
public RagdollPacket RagdollPacket;
@@ -16,13 +16,13 @@ public struct HealthSyncPacket(int netId) : INetSerializable
public void Deserialize(NetDataReader reader)
{
NetId = reader.GetInt();
- GStruct346 packet = new()
+ GStruct347 packet = new()
{
- SyncType = (GStruct346.ESyncType)reader.GetInt()
+ SyncType = (GStruct347.ESyncType)reader.GetInt()
};
switch (packet.SyncType)
{
- case GStruct346.ESyncType.AddEffect:
+ case GStruct347.ESyncType.AddEffect:
{
packet.Data.AddEffect = new()
{
@@ -34,11 +34,11 @@ public void Deserialize(NetDataReader reader)
WorkTime = reader.GetFloat(),
ResidueTime = reader.GetFloat(),
Strength = reader.GetFloat(),
- ExtraDataType = (GStruct346.GStruct347.EExtraDataType)reader.GetInt()
+ ExtraDataType = (GStruct347.GStruct348.EExtraDataType)reader.GetInt()
};
switch (packet.Data.AddEffect.ExtraDataType)
{
- case GStruct346.GStruct347.EExtraDataType.MedEffect:
+ case GStruct347.GStruct348.EExtraDataType.MedEffect:
{
packet.Data.AddEffect.ExtraData = new()
{
@@ -50,7 +50,7 @@ public void Deserialize(NetDataReader reader)
};
}
break;
- case GStruct346.GStruct347.EExtraDataType.Stimulator:
+ case GStruct347.GStruct348.EExtraDataType.Stimulator:
{
packet.Data.AddEffect.ExtraData = new()
{
@@ -64,7 +64,7 @@ public void Deserialize(NetDataReader reader)
}
break;
}
- case GStruct346.ESyncType.RemoveEffect:
+ case GStruct347.ESyncType.RemoveEffect:
{
packet.Data.RemoveEffect = new()
{
@@ -72,7 +72,7 @@ public void Deserialize(NetDataReader reader)
};
break;
}
- case GStruct346.ESyncType.EffectNextState:
+ case GStruct347.ESyncType.EffectNextState:
{
packet.Data.EffectNextState = new()
{
@@ -81,7 +81,7 @@ public void Deserialize(NetDataReader reader)
};
break;
}
- case GStruct346.ESyncType.EffectStateTime:
+ case GStruct347.ESyncType.EffectStateTime:
{
packet.Data.EffectStateTime = new()
{
@@ -90,7 +90,7 @@ public void Deserialize(NetDataReader reader)
};
break;
}
- case GStruct346.ESyncType.EffectStrength:
+ case GStruct347.ESyncType.EffectStrength:
{
packet.Data.EffectStrength = new()
{
@@ -99,7 +99,7 @@ public void Deserialize(NetDataReader reader)
};
break;
}
- case GStruct346.ESyncType.EffectMedResource:
+ case GStruct347.ESyncType.EffectMedResource:
{
packet.Data.EffectMedResource = new()
{
@@ -108,7 +108,7 @@ public void Deserialize(NetDataReader reader)
};
break;
}
- case GStruct346.ESyncType.EffectStimulatorBuff:
+ case GStruct347.ESyncType.EffectStimulatorBuff:
{
packet.Data.EffectStimulatorBuff = new()
{
@@ -125,7 +125,7 @@ public void Deserialize(NetDataReader reader)
}
break;
}
- case GStruct346.ESyncType.IsAlive:
+ case GStruct347.ESyncType.IsAlive:
{
packet.Data.IsAlive = new()
{
@@ -142,7 +142,7 @@ public void Deserialize(NetDataReader reader)
}
break;
}
- case GStruct346.ESyncType.BodyHealth:
+ case GStruct347.ESyncType.BodyHealth:
{
packet.Data.BodyHealth = new()
{
@@ -151,7 +151,7 @@ public void Deserialize(NetDataReader reader)
};
break;
}
- case GStruct346.ESyncType.Energy:
+ case GStruct347.ESyncType.Energy:
{
packet.Data.Energy = new()
{
@@ -159,7 +159,7 @@ public void Deserialize(NetDataReader reader)
};
break;
}
- case GStruct346.ESyncType.Hydration:
+ case GStruct347.ESyncType.Hydration:
{
packet.Data.Hydration = new()
{
@@ -167,7 +167,7 @@ public void Deserialize(NetDataReader reader)
};
break;
}
- case GStruct346.ESyncType.Temperature:
+ case GStruct347.ESyncType.Temperature:
{
packet.Data.Temperature = new()
{
@@ -175,7 +175,7 @@ public void Deserialize(NetDataReader reader)
};
break;
}
- case GStruct346.ESyncType.DamageCoeff:
+ case GStruct347.ESyncType.DamageCoeff:
{
packet.Data.DamageCoeff = new()
{
@@ -183,7 +183,7 @@ public void Deserialize(NetDataReader reader)
};
break;
}
- case GStruct346.ESyncType.ApplyDamage:
+ case GStruct347.ESyncType.ApplyDamage:
{
packet.Data.ApplyDamage = new()
{
@@ -193,7 +193,7 @@ public void Deserialize(NetDataReader reader)
};
break;
}
- case GStruct346.ESyncType.DestroyedBodyPart:
+ case GStruct347.ESyncType.DestroyedBodyPart:
{
packet.Data.DestroyedBodyPart = new()
{
@@ -208,7 +208,7 @@ public void Deserialize(NetDataReader reader)
packet.Data.DestroyedBodyPart.HealthMaximum = reader.GetFloat();
break;
}
- case GStruct346.ESyncType.HealthRates:
+ case GStruct347.ESyncType.HealthRates:
{
packet.Data.HealthRates = new()
{
@@ -221,7 +221,7 @@ public void Deserialize(NetDataReader reader)
};
break;
}
- case GStruct346.ESyncType.HealerDone:
+ case GStruct347.ESyncType.HealerDone:
{
packet.Data.HealerDone = new()
{
@@ -229,7 +229,7 @@ public void Deserialize(NetDataReader reader)
};
break;
}
- case GStruct346.ESyncType.BurnEyes:
+ case GStruct347.ESyncType.BurnEyes:
{
packet.Data.BurnEyes = new()
{
@@ -239,7 +239,7 @@ public void Deserialize(NetDataReader reader)
};
break;
}
- case GStruct346.ESyncType.Poison:
+ case GStruct347.ESyncType.Poison:
{
packet.Data.Poison = new()
{
@@ -247,7 +247,7 @@ public void Deserialize(NetDataReader reader)
};
break;
}
- case GStruct346.ESyncType.StaminaCoeff:
+ case GStruct347.ESyncType.StaminaCoeff:
{
packet.Data.StaminaCoeff = new()
{
@@ -263,11 +263,11 @@ public void Deserialize(NetDataReader reader)
public void Serialize(NetDataWriter writer)
{
writer.Put(NetId);
- GStruct346.GStruct365 packet = Packet.Data;
+ GStruct347.GStruct366 packet = Packet.Data;
writer.Put((int)Packet.SyncType);
switch (Packet.SyncType)
{
- case GStruct346.ESyncType.AddEffect:
+ case GStruct347.ESyncType.AddEffect:
{
writer.Put(packet.AddEffect.EffectId);
writer.Put(packet.AddEffect.Type);
@@ -280,15 +280,15 @@ public void Serialize(NetDataWriter writer)
writer.Put((int)packet.AddEffect.ExtraDataType);
switch (packet.AddEffect.ExtraDataType)
{
- case GStruct346.GStruct347.EExtraDataType.None:
+ case GStruct347.GStruct348.EExtraDataType.None:
break;
- case GStruct346.GStruct347.EExtraDataType.MedEffect:
+ case GStruct347.GStruct348.EExtraDataType.MedEffect:
{
writer.Put(packet.AddEffect.ExtraData.MedEffect.ItemId);
writer.Put(packet.AddEffect.ExtraData.MedEffect.Amount);
break;
}
- case GStruct346.GStruct347.EExtraDataType.Stimulator:
+ case GStruct347.GStruct348.EExtraDataType.Stimulator:
{
writer.Put(packet.AddEffect.ExtraData.Stimulator.BuffsName);
break;
@@ -296,36 +296,36 @@ public void Serialize(NetDataWriter writer)
}
break;
}
- case GStruct346.ESyncType.RemoveEffect:
+ case GStruct347.ESyncType.RemoveEffect:
{
writer.Put(packet.RemoveEffect.EffectId);
break;
}
- case GStruct346.ESyncType.EffectNextState:
+ case GStruct347.ESyncType.EffectNextState:
{
writer.Put(packet.EffectNextState.EffectId);
writer.Put(packet.EffectNextState.StateTime);
break;
}
- case GStruct346.ESyncType.EffectStateTime:
+ case GStruct347.ESyncType.EffectStateTime:
{
writer.Put(packet.EffectStateTime.EffectId);
writer.Put(packet.EffectStateTime.RemainingStateTime);
break;
}
- case GStruct346.ESyncType.EffectStrength:
+ case GStruct347.ESyncType.EffectStrength:
{
writer.Put(packet.EffectStrength.EffectId);
writer.Put(packet.EffectStrength.Strength);
break;
}
- case GStruct346.ESyncType.EffectMedResource:
+ case GStruct347.ESyncType.EffectMedResource:
{
writer.Put(packet.EffectMedResource.EffectId);
writer.Put(packet.EffectMedResource.Resource);
break;
}
- case GStruct346.ESyncType.EffectStimulatorBuff:
+ case GStruct347.ESyncType.EffectStimulatorBuff:
{
writer.Put(packet.EffectStimulatorBuff.EffectId);
writer.Put(packet.EffectStimulatorBuff.BuffIndex);
@@ -339,7 +339,7 @@ public void Serialize(NetDataWriter writer)
}
break;
}
- case GStruct346.ESyncType.IsAlive:
+ case GStruct347.ESyncType.IsAlive:
{
writer.Put(packet.IsAlive.IsAlive);
if (!packet.IsAlive.IsAlive)
@@ -353,40 +353,40 @@ public void Serialize(NetDataWriter writer)
}
break;
}
- case GStruct346.ESyncType.BodyHealth:
+ case GStruct347.ESyncType.BodyHealth:
{
writer.Put((int)packet.BodyHealth.BodyPart);
writer.Put(packet.BodyHealth.Value);
break;
}
- case GStruct346.ESyncType.Energy:
+ case GStruct347.ESyncType.Energy:
{
writer.Put(packet.Energy.Value);
break;
}
- case GStruct346.ESyncType.Hydration:
+ case GStruct347.ESyncType.Hydration:
{
writer.Put(packet.Hydration.Value);
break;
}
- case GStruct346.ESyncType.Temperature:
+ case GStruct347.ESyncType.Temperature:
{
writer.Put(packet.Temperature.Value);
break;
}
- case GStruct346.ESyncType.DamageCoeff:
+ case GStruct347.ESyncType.DamageCoeff:
{
writer.Put(packet.DamageCoeff.DamageCoeff);
break;
}
- case GStruct346.ESyncType.ApplyDamage:
+ case GStruct347.ESyncType.ApplyDamage:
{
writer.Put((int)packet.ApplyDamage.BodyPart);
writer.Put(packet.ApplyDamage.Damage);
writer.Put((int)packet.ApplyDamage.DamageType);
break;
}
- case GStruct346.ESyncType.DestroyedBodyPart:
+ case GStruct347.ESyncType.DestroyedBodyPart:
{
writer.Put((int)packet.DestroyedBodyPart.BodyPart);
writer.Put(packet.DestroyedBodyPart.IsDestroyed);
@@ -398,7 +398,7 @@ public void Serialize(NetDataWriter writer)
writer.Put(packet.DestroyedBodyPart.HealthMaximum);
break;
}
- case GStruct346.ESyncType.HealthRates:
+ case GStruct347.ESyncType.HealthRates:
{
writer.Put(packet.HealthRates.HealRate);
writer.Put(packet.HealthRates.DamageRate);
@@ -408,24 +408,24 @@ public void Serialize(NetDataWriter writer)
writer.Put(packet.HealthRates.Temperature);
break;
}
- case GStruct346.ESyncType.HealerDone:
+ case GStruct347.ESyncType.HealerDone:
{
writer.Put(packet.HealerDone.EffectId);
break;
}
- case GStruct346.ESyncType.BurnEyes:
+ case GStruct347.ESyncType.BurnEyes:
{
writer.Put(packet.BurnEyes.Position);
writer.Put(packet.BurnEyes.DistanceStrength);
writer.Put(packet.BurnEyes.NormalTime);
break;
}
- case GStruct346.ESyncType.Poison:
+ case GStruct347.ESyncType.Poison:
{
writer.Put(packet.Poison.Value);
break;
}
- case GStruct346.ESyncType.StaminaCoeff:
+ case GStruct347.ESyncType.StaminaCoeff:
{
writer.Put(packet.StaminaCoeff.StaminaCoeff);
break;
diff --git a/Fika.Core/Networking/Packets/Player/PlayerStatePacket.cs b/Fika.Core/Networking/Packets/Player/PlayerStatePacket.cs
index cf9ff22b..c81ee152 100644
--- a/Fika.Core/Networking/Packets/Player/PlayerStatePacket.cs
+++ b/Fika.Core/Networking/Packets/Player/PlayerStatePacket.cs
@@ -6,7 +6,7 @@ namespace Fika.Core.Networking
{
public struct PlayerStatePacket(int netId, Vector3 position, Vector2 rotation, Vector2 headRotation, Vector2 movementDirection,
EPlayerState state, float tilt, int step, int animatorStateIndex, float characterMovementSpeed,
- bool isProne, float poseLevel, bool isSprinting, GClass681.GStruct35 stamina, int blindfire,
+ bool isProne, float poseLevel, bool isSprinting, GClass681.GStruct36 stamina, int blindfire,
float weaponOverlap, bool leftStanceDisabled, bool isGrounded, bool hasGround, ESurfaceSound surfaceSound, Vector3 surfaceNormal) : INetSerializable
{
public int NetId = netId;
@@ -22,7 +22,7 @@ public struct PlayerStatePacket(int netId, Vector3 position, Vector2 rotation, V
public bool IsProne = isProne;
public float PoseLevel = poseLevel;
public bool IsSprinting = isSprinting;
- public GClass681.GStruct35 Stamina = stamina;
+ public GClass681.GStruct36 Stamina = stamina;
public int Blindfire = blindfire;
public float WeaponOverlap = weaponOverlap;
public bool LeftStanceDisabled = leftStanceDisabled;
diff --git a/Fika.Core/UI/Custom/MatchMakerUI.cs b/Fika.Core/UI/Custom/MatchMakerUI.cs
index 90e4efe0..78dd350e 100644
--- a/Fika.Core/UI/Custom/MatchMakerUI.cs
+++ b/Fika.Core/UI/Custom/MatchMakerUI.cs
@@ -17,6 +17,8 @@ public class MatchMakerUI : MonoBehaviour
[SerializeField]
public Button StartButton;
[SerializeField]
+ public Button CloseButton;
+ [SerializeField]
public TextMeshProUGUI PlayerAmountText;
public void SetServerNumberText(string text)
diff --git a/Fika.Core/UI/Custom/MatchMakerUIScript.cs b/Fika.Core/UI/Custom/MatchMakerUIScript.cs
index 67e837d9..2edb0d50 100644
--- a/Fika.Core/UI/Custom/MatchMakerUIScript.cs
+++ b/Fika.Core/UI/Custom/MatchMakerUIScript.cs
@@ -34,14 +34,14 @@ internal class MatchMakerUIScript : MonoBehaviour
private float _lastRefreshed;
- private void Start()
+ protected void Start()
{
CreateMatchMakerUI();
StartCoroutine(ServerQuery());
}
- void Update()
+ protected void Update()
{
if (Input.GetKeyDown(KeyCode.Escape))
{
@@ -64,11 +64,13 @@ private void DestroyThis()
Destroy(this);
}
- private void OnDestroy()
+ protected void OnDestroy()
{
StopQuery = true;
if (NewBackButton != null)
+ {
Destroy(NewBackButton);
+ }
}
private void CreateMatchMakerUI()
@@ -102,6 +104,15 @@ private void CreateMatchMakerUI()
}
});
+ fikaMatchMakerUi.CloseButton.onClick.AddListener(() =>
+ {
+ Singleton.Instance.PlayUISound(EUISoundType.ButtonClick);
+ if (fikaMatchMakerUi.PlayerAmountSelection.active)
+ {
+ fikaMatchMakerUi.PlayerAmountSelection.SetActive(false);
+ }
+ });
+
fikaMatchMakerUi.StartButton.onClick.AddListener(() =>
{
Singleton.Instance.PlayUISound(EUISoundType.ButtonClick);
@@ -124,10 +135,9 @@ private void CreateMatchMakerUI()
if (!IPAddress.TryParse(ip, out _))
{
- Singleton.Instance.ShowCriticalErrorScreen(
- "ERROR FORCING IP",
- $"'{ip}' is not a valid IP address to connect to! Check your 'Force IP' setting.",
- ErrorScreen.EButtonType.OkButton, 10f, null, null);
+ Singleton.Instance.ShowCriticalErrorScreen("ERROR FORCING IP",
+ $"'{ip}' is not a valid IP address to connect to! Check your 'Force IP' setting.",
+ ErrorScreen.EButtonType.OkButton, 10f, null, null);
return;
}
}
@@ -135,10 +145,9 @@ private void CreateMatchMakerUI()
{
if (!IPAddress.TryParse(FikaPlugin.ForceBindIP.Value, out _))
{
- Singleton.Instance.ShowCriticalErrorScreen(
- "ERROR BINDING",
- $"'{FikaPlugin.ForceBindIP.Value}' is not a valid IP address to bind to! Check your 'Force Bind IP' setting.",
- ErrorScreen.EButtonType.OkButton, 10f, null, null);
+ Singleton.Instance.ShowCriticalErrorScreen("ERROR BINDING",
+ $"'{FikaPlugin.ForceBindIP.Value}' is not a valid IP address to bind to! Check your 'Force Bind IP' setting.",
+ ErrorScreen.EButtonType.OkButton, 10f, null, null);
return;
}
}
@@ -165,11 +174,22 @@ private void CreateMatchMakerUI()
Traverse.Create(newButtonComponent).Field("OnClick").SetValue(newEvent);
if (!NewBackButton.active)
+ {
NewBackButton.SetActive(true);
+ }
BackButton.gameObject.SetActive(false);
}
+ private void AutoRefresh()
+ {
+ Matches = FikaRequestHandler.LocationRaids(RaidSettings);
+
+ _lastRefreshed = Time.time;
+
+ RefreshUI();
+ }
+
private void ManualRefresh()
{
Singleton.Instance.PlayUISound(EUISoundType.ButtonClick);
@@ -232,7 +252,7 @@ private IEnumerator JoinMatch(string profileId, string serverId, Button button)
pingingClient.NetClient?.Stop();
pingingClient = null;
- if (MatchmakerAcceptPatches.JoinMatch(RaidSettings, profileId, serverId, out CreateMatch result, out string errorMessage))
+ if (MatchmakerAcceptPatches.JoinMatch(profileId, serverId, out CreateMatch result, out string errorMessage))
{
MatchmakerAcceptPatches.SetGroupId(result.ServerId);
MatchmakerAcceptPatches.SetTimestamp(result.Timestamp);
@@ -442,7 +462,7 @@ public IEnumerator ServerQuery()
{
while (!StopQuery)
{
- ManualRefresh();
+ AutoRefresh();
while (Time.time < _lastRefreshed + FikaPlugin.AutoRefreshRate.Value)
{
diff --git a/Fika.Core/UI/FikaUIUtils.cs b/Fika.Core/UI/FikaUIUtils.cs
index 957870d9..ab1ea6d7 100644
--- a/Fika.Core/UI/FikaUIUtils.cs
+++ b/Fika.Core/UI/FikaUIUtils.cs
@@ -1,12 +1,17 @@
// © 2024 Lacyway All Rights Reserved
+using Diz.Utils;
+using EFT.InputSystem;
using EFT.UI;
+using HarmonyLib;
+using System;
+using System.Reflection;
using TMPro;
using UnityEngine;
namespace Fika.Core.UI
{
- internal class FikaUIUtils
+ internal static class FikaUIUtils
{
public static TextMeshProUGUI CreateOverlayText(string overlayText)
{
@@ -15,13 +20,13 @@ public static TextMeshProUGUI CreateOverlayText(string overlayText)
if (labelObj != null)
{
- Object.Destroy(labelObj);
+ UnityEngine.Object.Destroy(labelObj);
}
ClientWatermark watermarkText = obj.GetComponent();
if (watermarkText != null)
{
- Object.Destroy(watermarkText);
+ UnityEngine.Object.Destroy(watermarkText);
}
obj.active = true;
@@ -33,5 +38,96 @@ public static TextMeshProUGUI CreateOverlayText(string overlayText)
return text;
}
+
+ public static GClass3102 ShowFikaMessage(this PreloaderUI preloaderUI, string header, string message,
+ ErrorScreen.EButtonType buttonType, float waitingTime, Action acceptCallback, Action endTimeCallback)
+ {
+ Traverse preloaderUiTraverse = Traverse.Create(preloaderUI);
+
+ PreloaderUI.Class2590 messageHandler = new()
+ {
+ preloaderUI_0 = preloaderUI,
+ acceptCallback = acceptCallback,
+ endTimeCallback = endTimeCallback
+ };
+
+ if (!AsyncWorker.CheckIsMainThread())
+ {
+ FikaPlugin.Instance.FikaLogger.LogError("You are trying to show error screen from non-main thread!");
+ return new GClass3102();
+ }
+
+ ErrorScreen errorScreenTemplate = preloaderUiTraverse.Field("_criticalErrorScreenTemplate").GetValue();
+ EmptyInputNode errorScreenContainer = preloaderUiTraverse.Field("_criticalErrorScreenContainer").GetValue();
+
+ messageHandler.errorScreen = UnityEngine.Object.Instantiate(errorScreenTemplate, errorScreenContainer.transform, false);
+ errorScreenContainer.AddChildNode(messageHandler.errorScreen);
+ return messageHandler.errorScreen.ShowFikaMessage(header, message, new Action(messageHandler.method_1), waitingTime, new Action(messageHandler.method_2), buttonType, true);
+ }
+
+ public static GClass3104 ShowFikaMessage(this ErrorScreen errorScreen, string title, string message,
+ Action closeManuallyCallback = null, float waitingTime = 0f, Action timeOutCallback = null,
+ ErrorScreen.EButtonType buttonType = ErrorScreen.EButtonType.OkButton, bool removeHtml = true)
+ {
+ Traverse errorScreenTraverse = Traverse.Create(errorScreen);
+
+ ErrorScreen.Class2378 errorScreenHandler = new()
+ {
+ errorScreen_0 = errorScreen
+ };
+ if (!MonoBehaviourSingleton.Instance.CanShowErrorScreen)
+ {
+ return new GClass3104();
+ }
+ if (removeHtml)
+ {
+ message = ErrorScreen.smethod_0(message);
+ }
+ ItemUiContext.Instance.CloseAllWindows();
+
+ Action action_1 = timeOutCallback ?? closeManuallyCallback;
+ errorScreenTraverse.Field("action_1").SetValue(action_1);
+ MethodBase baseShow = typeof(ErrorScreen).BaseType.GetMethod("Show");
+
+ errorScreenHandler.context = (GClass3104)baseShow.Invoke(errorScreen, [closeManuallyCallback]);
+ errorScreenHandler.context.OnAccept += errorScreen.method_3;
+ errorScreenHandler.context.OnDecline += errorScreen.method_4;
+ errorScreenHandler.context.OnCloseSilent += errorScreen.method_4;
+
+ GClass767 ui = Traverse.Create(errorScreen).Field("UI").GetValue();
+
+ ui.AddDisposable(new Action(errorScreenHandler.method_0));
+ string text = buttonType switch
+ {
+ ErrorScreen.EButtonType.OkButton => "I UNDERSTAND",
+ ErrorScreen.EButtonType.CancelButton => "CANCEL",
+ ErrorScreen.EButtonType.QuitButton => "I DECLINE",
+ _ => throw new ArgumentOutOfRangeException()
+ };
+
+ DefaultUIButton exitButton = errorScreenTraverse.Field("_exitButton").GetValue();
+
+ exitButton.SetHeaderText(text, exitButton.HeaderSize);
+ errorScreen.RectTransform.anchoredPosition = Vector2.zero;
+
+ errorScreen.Caption.SetText(string.IsNullOrEmpty(title) ? "ERROR" : title);
+
+ string string_1 = message.SubstringIfNecessary(500);
+ errorScreenTraverse.Field("string_1").SetValue(string_1);
+
+ TextMeshProUGUI errorDescription = Traverse.Create(errorScreen).Field("_errorDescription").GetValue();
+ errorDescription.text = string_1;
+
+ Coroutine coroutine_0 = errorScreenTraverse.Field("coroutine_0").GetValue();
+ if (coroutine_0 != null)
+ {
+ errorScreen.StopCoroutine(coroutine_0);
+ }
+ if (waitingTime > 0f)
+ {
+ errorScreenTraverse.Field("coroutine_0").SetValue(errorScreen.StartCoroutine(errorScreen.method_2(GClass1304.Now.AddSeconds((double)waitingTime))));
+ }
+ return errorScreenHandler.context;
+ }
}
}
diff --git a/Fika.Core/UI/Patches/DisableInsuranceReadyButton_Patch.cs b/Fika.Core/UI/Patches/DisableInsuranceReadyButton_Patch.cs
index a2ce9500..3e26628c 100644
--- a/Fika.Core/UI/Patches/DisableInsuranceReadyButton_Patch.cs
+++ b/Fika.Core/UI/Patches/DisableInsuranceReadyButton_Patch.cs
@@ -1,7 +1,7 @@
// © 2024 Lacyway All Rights Reserved
-using Aki.Reflection.Patching;
using EFT.UI;
+using SPT.Reflection.Patching;
using System.Reflection;
using UnityEngine;
diff --git a/Fika.Core/UI/Patches/DisableMatchSettingsReadyButton_Patch.cs b/Fika.Core/UI/Patches/DisableMatchSettingsReadyButton_Patch.cs
index a10a62f2..3bf4be04 100644
--- a/Fika.Core/UI/Patches/DisableMatchSettingsReadyButton_Patch.cs
+++ b/Fika.Core/UI/Patches/DisableMatchSettingsReadyButton_Patch.cs
@@ -1,8 +1,8 @@
// © 2024 Lacyway All Rights Reserved
-using Aki.Reflection.Patching;
using EFT.UI;
using EFT.UI.Matchmaker;
+using SPT.Reflection.Patching;
using System.Reflection;
using UnityEngine;
diff --git a/Fika.Core/UI/Patches/DisableReadyButton_Patch.cs b/Fika.Core/UI/Patches/DisableReadyButton_Patch.cs
index a0f2d4cd..b2adb8c3 100644
--- a/Fika.Core/UI/Patches/DisableReadyButton_Patch.cs
+++ b/Fika.Core/UI/Patches/DisableReadyButton_Patch.cs
@@ -1,8 +1,8 @@
// © 2024 Lacyway All Rights Reserved
-using Aki.Reflection.Patching;
using EFT.UI;
using EFT.UI.Matchmaker;
+using SPT.Reflection.Patching;
using System.Reflection;
using UnityEngine;
diff --git a/Fika.Core/UI/Patches/InventoryScroll_Patch.cs b/Fika.Core/UI/Patches/InventoryScroll_Patch.cs
index ff319aeb..2998303e 100644
--- a/Fika.Core/UI/Patches/InventoryScroll_Patch.cs
+++ b/Fika.Core/UI/Patches/InventoryScroll_Patch.cs
@@ -1,5 +1,5 @@
-using Aki.Reflection.Patching;
-using EFT.UI;
+using EFT.UI;
+using SPT.Reflection.Patching;
using System.Reflection;
using UnityEngine.UI;
diff --git a/Fika.Core/UI/Patches/ItemContext_Patch.cs b/Fika.Core/UI/Patches/ItemContext_Patch.cs
index 2af2a52d..e62d5076 100644
--- a/Fika.Core/UI/Patches/ItemContext_Patch.cs
+++ b/Fika.Core/UI/Patches/ItemContext_Patch.cs
@@ -1,5 +1,4 @@
-using Aki.Reflection.Patching;
-using Comfort.Common;
+using Comfort.Common;
using EFT;
using EFT.InventoryLogic;
using EFT.UI;
@@ -7,6 +6,7 @@
using Fika.Core.Networking.Http;
using Fika.Core.UI.Models;
using HarmonyLib;
+using SPT.Reflection.Patching;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
@@ -27,12 +27,12 @@ protected override MethodBase GetTargetMethod()
[PatchPrefix]
private static void Prefix(ItemInfoInteractionsAbstractClass contextInteractions, Item item)
{
- if (contextInteractions is not GClass3021 gclass)
+ if (contextInteractions is not GClass3038 gclass)
{
return;
}
- ItemContextAbstractClass itemContext = Traverse.Create(contextInteractions).Field("gclass2813_0").Value;
+ ItemContextAbstractClass itemContext = Traverse.Create(contextInteractions).Field("gclass2826_0").Value;
if (itemContext.ViewType == EItemViewType.Inventory)
{
if (Singleton.Instantiated && Singleton.Instance is not HideoutGameWorld)
@@ -40,6 +40,14 @@ private static void Prefix(ItemInfoInteractionsAbstractClass co
return;
}
+ // Save as variable in case we need to add more checks later...
+ MenuUI menuUI = Singleton.Instance;
+
+ if (menuUI.HideoutAreaTransferItemsScreen.isActiveAndEnabled)
+ {
+ return;
+ }
+
IEnumerable
- parentItems = item.GetAllParentItems();
if (parentItems.Any(x => x is EquipmentClass))
{
@@ -49,17 +57,26 @@ private static void Prefix(ItemInfoInteractionsAbstractClass co
Dictionary