From 3ca872ed3ae80259be822cd15cd6eedbd087d090 Mon Sep 17 00:00:00 2001 From: Lacyway <20912169+Lacyway@users.noreply.github.com> Date: Sat, 14 Dec 2024 15:19:52 +0100 Subject: [PATCH 1/4] Update - Pass as ref - Don't stop trigger when waiting for callback --- .../CoopClientInventoryController.cs | 44 +------------------ .../CoopClientFirearmController.cs | 4 +- Fika.Core/Coop/Players/CoopPlayer.cs | 2 +- Fika.Core/Networking/FikaClient.cs | 2 +- 4 files changed, 5 insertions(+), 47 deletions(-) diff --git a/Fika.Core/Coop/ClientClasses/CoopClientInventoryController.cs b/Fika.Core/Coop/ClientClasses/CoopClientInventoryController.cs index f734a1b4..820480e1 100644 --- a/Fika.Core/Coop/ClientClasses/CoopClientInventoryController.cs +++ b/Fika.Core/Coop/ClientClasses/CoopClientInventoryController.cs @@ -45,16 +45,6 @@ public override IPlayerSearchController PlayerSearchController } } - /*public override void RollBack() - { - base.RollBack(); - ResyncInventoryIdPacket packet = new(coopPlayer.NetId) - { - MongoId = mongoID_0 - }; - coopPlayer.PacketSender.SendPacket(ref packet, false); - }*/ - public override void GetTraderServicesDataFromServer(string traderId) { if (FikaBackendUtils.IsClient) @@ -263,7 +253,7 @@ private void HandleFinalResult(IResult result) InventoryController.logger.LogError($"{InventoryController.ID} - Operation critical failure - status mismatch: {Operation.Id} server status: {serverStatus} client status: {localStatus} - {Operation}"); } } - Callback?.Invoke(OperationResult); + Callback(OperationResult); } } @@ -272,37 +262,5 @@ public readonly struct ServerOperationStatus(EOperationStatus status, string err public readonly EOperationStatus Status = status; public readonly string Error = error; } - - /*private class ClientInventoryCallbackManager - { - public Result result; - public ClientInventoryOperationHandler clientOperationManager; - - public void HandleResult(IResult executeResult) - { - if (!executeResult.Succeed && (executeResult.Error is not "skipped skippable" or "skipped _completed")) - { - FikaPlugin.Instance.FikaLogger.LogError($"{clientOperationManager.inventoryController.ID} - Client operation critical failure: {clientOperationManager.inventoryController.ID} - {clientOperationManager.operation}\r\nError: {executeResult.Error}"); - } - - clientOperationManager.localOperationStatus = EOperationStatus.Succeeded; - - if (clientOperationManager.localOperationStatus == clientOperationManager.serverOperationStatus) - { - clientOperationManager.operation.Dispose(); - clientOperationManager.callback.Invoke(result); - return; - } - - if (clientOperationManager.serverOperationStatus != null) - { - if (clientOperationManager.serverOperationStatus == EOperationStatus.Failed) - { - clientOperationManager.operation.Dispose(); - clientOperationManager.callback.Invoke(result); - } - } - } - }*/ } } \ No newline at end of file diff --git a/Fika.Core/Coop/ClientClasses/HandsControllers/CoopClientFirearmController.cs b/Fika.Core/Coop/ClientClasses/HandsControllers/CoopClientFirearmController.cs index 58346310..83608723 100644 --- a/Fika.Core/Coop/ClientClasses/HandsControllers/CoopClientFirearmController.cs +++ b/Fika.Core/Coop/ClientClasses/HandsControllers/CoopClientFirearmController.cs @@ -67,7 +67,7 @@ public override bool CanStartReload() return base.CanStartReload(); } - public override bool CanPressTrigger() + /*public override bool CanPressTrigger() { if (isClient) { @@ -75,7 +75,7 @@ public override bool CanPressTrigger() } return base.CanPressTrigger(); - } + }*/ public Player.BaseAnimationOperation Weapon1() { diff --git a/Fika.Core/Coop/Players/CoopPlayer.cs b/Fika.Core/Coop/Players/CoopPlayer.cs index ba366b95..7bff9d94 100644 --- a/Fika.Core/Coop/Players/CoopPlayer.cs +++ b/Fika.Core/Coop/Players/CoopPlayer.cs @@ -1208,7 +1208,7 @@ public override void UnpauseAllEffectsOnPlayer() ActiveHealthController.UnpauseAllEffects(); } - public void HandleCallbackFromServer(OperationCallbackPacket operationCallbackPacket) + public void HandleCallbackFromServer(ref OperationCallbackPacket operationCallbackPacket) { if (OperationCallbacks.TryGetValue(operationCallbackPacket.CallbackId, out Action callback)) { diff --git a/Fika.Core/Networking/FikaClient.cs b/Fika.Core/Networking/FikaClient.cs index 9b585076..405ac5e0 100644 --- a/Fika.Core/Networking/FikaClient.cs +++ b/Fika.Core/Networking/FikaClient.cs @@ -797,7 +797,7 @@ private void OnOperationCallbackPacketReceived(OperationCallbackPacket packet) { if (coopHandler.Players.TryGetValue(packet.NetId, out CoopPlayer player) && player.IsYourPlayer) { - player.HandleCallbackFromServer(packet); + player.HandleCallbackFromServer(ref packet); } } From 19def90a35e05d7d88d4e3076724db3b6b53d226 Mon Sep 17 00:00:00 2001 From: Lacyway <20912169+Lacyway@users.noreply.github.com> Date: Sat, 14 Dec 2024 15:23:23 +0100 Subject: [PATCH 2/4] Change from ref --- Fika.Core/Coop/Players/CoopPlayer.cs | 2 +- Fika.Core/Networking/FikaClient.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Fika.Core/Coop/Players/CoopPlayer.cs b/Fika.Core/Coop/Players/CoopPlayer.cs index 7bff9d94..ba366b95 100644 --- a/Fika.Core/Coop/Players/CoopPlayer.cs +++ b/Fika.Core/Coop/Players/CoopPlayer.cs @@ -1208,7 +1208,7 @@ public override void UnpauseAllEffectsOnPlayer() ActiveHealthController.UnpauseAllEffects(); } - public void HandleCallbackFromServer(ref OperationCallbackPacket operationCallbackPacket) + public void HandleCallbackFromServer(OperationCallbackPacket operationCallbackPacket) { if (OperationCallbacks.TryGetValue(operationCallbackPacket.CallbackId, out Action callback)) { diff --git a/Fika.Core/Networking/FikaClient.cs b/Fika.Core/Networking/FikaClient.cs index 405ac5e0..9b585076 100644 --- a/Fika.Core/Networking/FikaClient.cs +++ b/Fika.Core/Networking/FikaClient.cs @@ -797,7 +797,7 @@ private void OnOperationCallbackPacketReceived(OperationCallbackPacket packet) { if (coopHandler.Players.TryGetValue(packet.NetId, out CoopPlayer player) && player.IsYourPlayer) { - player.HandleCallbackFromServer(ref packet); + player.HandleCallbackFromServer(packet); } } From 1d539ec6d69add9f207e9adc8a5e1f54357a8a58 Mon Sep 17 00:00:00 2001 From: Lacyway <20912169+Lacyway@users.noreply.github.com> Date: Sat, 14 Dec 2024 19:08:55 +0100 Subject: [PATCH 3/4] Add null check --- Fika.Core/Coop/ClientClasses/CoopClientInventoryController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Fika.Core/Coop/ClientClasses/CoopClientInventoryController.cs b/Fika.Core/Coop/ClientClasses/CoopClientInventoryController.cs index 820480e1..d2c7a663 100644 --- a/Fika.Core/Coop/ClientClasses/CoopClientInventoryController.cs +++ b/Fika.Core/Coop/ClientClasses/CoopClientInventoryController.cs @@ -253,7 +253,7 @@ private void HandleFinalResult(IResult result) InventoryController.logger.LogError($"{InventoryController.ID} - Operation critical failure - status mismatch: {Operation.Id} server status: {serverStatus} client status: {localStatus} - {Operation}"); } } - Callback(OperationResult); + Callback?.Invoke(OperationResult); } } From 90a36db8a25ec6f0dc8696ce0eaa5f0e552249a1 Mon Sep 17 00:00:00 2001 From: Lacyway <20912169+Lacyway@users.noreply.github.com> Date: Sat, 14 Dec 2024 20:27:18 +0100 Subject: [PATCH 4/4] Remove unused class --- .../Coop/BotClasses/BotMovementContext.cs | 29 ------------------- Fika.Core/Coop/Players/CoopBot.cs | 6 ---- 2 files changed, 35 deletions(-) delete mode 100644 Fika.Core/Coop/BotClasses/BotMovementContext.cs diff --git a/Fika.Core/Coop/BotClasses/BotMovementContext.cs b/Fika.Core/Coop/BotClasses/BotMovementContext.cs deleted file mode 100644 index 5799adeb..00000000 --- a/Fika.Core/Coop/BotClasses/BotMovementContext.cs +++ /dev/null @@ -1,29 +0,0 @@ -using EFT; -using Fika.Core.Coop.Players; -using System; -using UnityEngine; - -namespace Fika.Core.Coop.BotClasses -{ - public sealed class BotMovementContext : MovementContext - { - private CoopBot Bot; - - public override void ApplyGravity(ref Vector3 motion, float deltaTime, bool stickToGround) - { - if (Bot.AIData.BotOwner.BotState == EBotState.NonActive) - { - return; - } - - base.ApplyGravity(ref motion, deltaTime, stickToGround); - } - - public new static BotMovementContext Create(Player player, Func animatorGetter, Func characterControllerGetter, LayerMask groundMask) - { - BotMovementContext movementContext = Create(player, animatorGetter, characterControllerGetter, groundMask); - movementContext.Bot = (CoopBot)player; - return movementContext; - } - } -} diff --git a/Fika.Core/Coop/Players/CoopBot.cs b/Fika.Core/Coop/Players/CoopBot.cs index acabc5c4..373bcc1b 100644 --- a/Fika.Core/Coop/Players/CoopBot.cs +++ b/Fika.Core/Coop/Players/CoopBot.cs @@ -121,12 +121,6 @@ public override void ConnectSkillManager() // Do nothing } - public override void CreateMovementContext() - { - LayerMask movement_MASK = EFTHardSettings.Instance.MOVEMENT_MASK; - MovementContext = BotMovementContext.Create(this, GetBodyAnimatorCommon, GetCharacterControllerCommon, movement_MASK); - } - public override void OnBeenKilledByAggressor(IPlayer aggressor, DamageInfoStruct damageInfo, EBodyPart bodyPart, EDamageType lethalDamageType) { base.OnBeenKilledByAggressor(aggressor, damageInfo, bodyPart, lethalDamageType);