From 2a33dc67641bbe83511b9f09e4d11e5f7a9d54f6 Mon Sep 17 00:00:00 2001 From: Lacyway <20912169+Lacyway@users.noreply.github.com> Date: Fri, 14 Jun 2024 12:53:22 +0200 Subject: [PATCH] Cleanup --- Fika.Core/Coop/BTR/FikaBTRManager_Client.cs | 2 +- Fika.Core/Coop/BTR/FikaBTRManager_Host.cs | 2 +- .../BotClasses/CoopBotInventoryController.cs | 1 - .../CoopClientInventoryController.cs | 2 +- Fika.Core/Coop/Components/CoopHandler.cs | 14 ++++++------- Fika.Core/Coop/Custom/FikaHealthBar.cs | 8 ++++---- Fika.Core/Coop/FreeCamera/FreeCamera.cs | 16 +++++++-------- .../Coop/FreeCamera/FreeCameraController.cs | 2 +- Fika.Core/Coop/GameMode/CoopGame.cs | 20 +++++++++---------- .../CoopObservedFirearmController.cs | 2 +- .../Coop/PacketHandlers/BotPacketSender.cs | 2 +- .../Coop/PacketHandlers/PacketReceiver.cs | 1 - .../Minefield/Minefield_method_2_Patch.cs | 2 +- .../BotTemplateLimitPatch_Override.cs | 2 +- Fika.Core/Coop/Players/CoopBot.cs | 4 ++-- Fika.Core/Coop/Players/CoopPlayer.cs | 2 +- Fika.Core/Coop/Players/ObservedCoopPlayer.cs | 17 ++++++++++------ Fika.Core/Networking/FikaClient.cs | 12 +++++------ Fika.Core/Networking/FikaServer.cs | 10 +++++----- .../UI/Patches/FikaVersionLabel_Patch.cs | 4 +--- Fika.Core/UI/Patches/ItemContext_Patch.cs | 2 +- Fika.Core/Utils/WorldToScreen.cs | 4 ++-- 22 files changed, 66 insertions(+), 65 deletions(-) diff --git a/Fika.Core/Coop/BTR/FikaBTRManager_Client.cs b/Fika.Core/Coop/BTR/FikaBTRManager_Client.cs index 6498bb9f..e0d60de1 100644 --- a/Fika.Core/Coop/BTR/FikaBTRManager_Client.cs +++ b/Fika.Core/Coop/BTR/FikaBTRManager_Client.cs @@ -115,7 +115,7 @@ public void OnPlayerInteractDoor(Player player, PlayerInteractPacket interactPac // Find `BTRControllerClass.method_9(PathDestination currentDestinationPoint, bool lastRoutePoint)` private bool IsUpdateTaxiPriceMethod(MethodInfo method) { - return (method.GetParameters().Length == 2 && method.GetParameters()[0].ParameterType == typeof(PathDestination)); + return method.GetParameters().Length == 2 && method.GetParameters()[0].ParameterType == typeof(PathDestination); } private void Update() diff --git a/Fika.Core/Coop/BTR/FikaBTRManager_Host.cs b/Fika.Core/Coop/BTR/FikaBTRManager_Host.cs index 5baeabce..e1c6a32e 100644 --- a/Fika.Core/Coop/BTR/FikaBTRManager_Host.cs +++ b/Fika.Core/Coop/BTR/FikaBTRManager_Host.cs @@ -226,7 +226,7 @@ public void OnPlayerInteractDoor(Player player, PlayerInteractPacket interactPac // Find `BTRControllerClass.method_9(PathDestination currentDestinationPoint, bool lastRoutePoint)` private bool IsUpdateTaxiPriceMethod(MethodInfo method) { - return (method.GetParameters().Length == 2 && method.GetParameters()[0].ParameterType == typeof(PathDestination)); + return method.GetParameters().Length == 2 && method.GetParameters()[0].ParameterType == typeof(PathDestination); } private void Update() diff --git a/Fika.Core/Coop/BotClasses/CoopBotInventoryController.cs b/Fika.Core/Coop/BotClasses/CoopBotInventoryController.cs index 315af5d2..8afa6310 100644 --- a/Fika.Core/Coop/BotClasses/CoopBotInventoryController.cs +++ b/Fika.Core/Coop/BotClasses/CoopBotInventoryController.cs @@ -2,7 +2,6 @@ using Comfort.Common; using EFT; -using EFT.InventoryLogic; using Fika.Core.Coop.Players; using Fika.Core.Networking; using JetBrains.Annotations; diff --git a/Fika.Core/Coop/ClientClasses/CoopClientInventoryController.cs b/Fika.Core/Coop/ClientClasses/CoopClientInventoryController.cs index 6e37e59e..99e3eb6e 100644 --- a/Fika.Core/Coop/ClientClasses/CoopClientInventoryController.cs +++ b/Fika.Core/Coop/ClientClasses/CoopClientInventoryController.cs @@ -16,7 +16,7 @@ namespace Fika.Core.Coop.ClientClasses public sealed class CoopClientInventoryController(Player player, Profile profile, bool examined) : Player.PlayerOwnerInventoryController(player, profile, examined) { public override bool HasDiscardLimits => false; - + ManualLogSource BepInLogger { get; set; } = BepInEx.Logging.Logger.CreateLogSource(nameof(CoopClientInventoryController)); diff --git a/Fika.Core/Coop/Components/CoopHandler.cs b/Fika.Core/Coop/Components/CoopHandler.cs index 61be0a34..c34d8e62 100644 --- a/Fika.Core/Coop/Components/CoopHandler.cs +++ b/Fika.Core/Coop/Components/CoopHandler.cs @@ -202,16 +202,16 @@ void ProcessQuitting() // If you are the server / host if (MatchmakerAcceptPatches.IsServer) { - // A host needs to wait for the team to extract or die! - if ((Singleton.Instance.NetServer.ConnectedPeersCount > 0) && quitState != EQuitState.NONE) + // A host needs to wait for the team to extract or die! + if ((Singleton.Instance.NetServer.ConnectedPeersCount > 0) && quitState != EQuitState.NONE) { NotificationManagerClass.DisplayWarningNotification("HOSTING: You cannot exit the game until all clients have disconnected."); requestQuitGame = false; return; } else if (Singleton.Instance.NetServer.ConnectedPeersCount == 0 - && Singleton.Instance.timeSinceLastPeerDisconnected > DateTime.Now.AddSeconds(-5) - && Singleton.Instance.hasHadPeer) + && Singleton.Instance.timeSinceLastPeerDisconnected > DateTime.Now.AddSeconds(-5) + && Singleton.Instance.hasHadPeer) { NotificationManagerClass.DisplayWarningNotification($"HOSTING: Please wait at least 5 seconds after the last peer disconnected before quitting."); requestQuitGame = false; @@ -219,12 +219,12 @@ void ProcessQuitting() } else { - coopGame.Stop(Singleton.Instance.MainPlayer.ProfileId, coopGame.MyExitStatus, MyPlayer.ActiveHealthController.IsAlive ? coopGame.MyExitLocation : null, 0); + coopGame.Stop(Singleton.Instance.MainPlayer.ProfileId, coopGame.MyExitStatus, MyPlayer.ActiveHealthController.IsAlive ? coopGame.MyExitLocation : null, 0); } } else { - coopGame.Stop(Singleton.Instance.MainPlayer.ProfileId, coopGame.MyExitStatus, MyPlayer.ActiveHealthController.IsAlive ? coopGame.MyExitLocation : null, 0); + coopGame.Stop(Singleton.Instance.MainPlayer.ProfileId, coopGame.MyExitStatus, MyPlayer.ActiveHealthController.IsAlive ? coopGame.MyExitLocation : null, 0); } return; } @@ -307,7 +307,7 @@ private async void SpawnPlayer(SpawnObject spawnObject) } } - int playerId = Players.Count + Singleton.Instance.RegisteredPlayers.Count + 1; + int playerId = Players.Count + Singleton.Instance.RegisteredPlayers.Count + 1; IEnumerable allPrefabPaths = spawnObject.Profile.GetAllPrefabPaths(); if (allPrefabPaths.Count() == 0) diff --git a/Fika.Core/Coop/Custom/FikaHealthBar.cs b/Fika.Core/Coop/Custom/FikaHealthBar.cs index 84381e68..6612a4ed 100644 --- a/Fika.Core/Coop/Custom/FikaHealthBar.cs +++ b/Fika.Core/Coop/Custom/FikaHealthBar.cs @@ -28,7 +28,7 @@ protected void Awake() { currentPlayer = GetComponent(); mainPlayer = (CoopPlayer)Singleton.Instance.MainPlayer; - CreateHealthBar(); + CreateHealthBar(); } protected void Update() @@ -114,12 +114,12 @@ private void UpdateScreenSpacePosition() float alpha = 1f; float halfMaxDistanceToShow = maxDistanceToShow / 2; - float lerpValue = Mathf.Clamp01((sqrDistance - halfMaxDistanceToShow) / (halfMaxDistanceToShow)); + float lerpValue = Mathf.Clamp01((sqrDistance - halfMaxDistanceToShow) / halfMaxDistanceToShow); alpha = Mathf.LerpUnclamped(alpha, 0, lerpValue); float namePlateScaleMult = Mathf.LerpUnclamped(1f, 0.5f, lerpValue); namePlateScaleMult = Mathf.Clamp(namePlateScaleMult * FikaPlugin.NamePlateScale.Value, FikaPlugin.MinimumNamePlateScale.Value * FikaPlugin.NamePlateScale.Value, FikaPlugin.NamePlateScale.Value); - playerPlate.ScalarObjectScreen.transform.localScale = (Vector3.one / processedDistance) * namePlateScaleMult; + playerPlate.ScalarObjectScreen.transform.localScale = Vector3.one / processedDistance * namePlateScaleMult; alpha *= opacityMultiplier; alpha *= distFromCenterMultiplier; @@ -232,7 +232,7 @@ private void UpdateHealth() playerPlate.healthNumberBackgroundScreen.gameObject.SetActive(true); playerPlate.healthBarBackgroundScreen.gameObject.SetActive(false); } - int healthNumberPercentage = (int)Math.Round((currentHealth / maxHealth) * 100); + int healthNumberPercentage = (int)Math.Round(currentHealth / maxHealth * 100); playerPlate.SetHealthNumberText($"{healthNumberPercentage}%"); } else diff --git a/Fika.Core/Coop/FreeCamera/FreeCamera.cs b/Fika.Core/Coop/FreeCamera/FreeCamera.cs index a46d854b..8d429572 100644 --- a/Fika.Core/Coop/FreeCamera/FreeCamera.cs +++ b/Fika.Core/Coop/FreeCamera/FreeCamera.cs @@ -273,22 +273,22 @@ protected void Update() if (Input.GetKey(leftKey) || Input.GetKey(KeyCode.LeftArrow)) { - transform.position += (-transform.right * (movementSpeed * Time.deltaTime)); + transform.position += -transform.right * (movementSpeed * Time.deltaTime); } if (Input.GetKey(rightKey) || Input.GetKey(KeyCode.RightArrow)) { - transform.position += (transform.right * (movementSpeed * Time.deltaTime)); + transform.position += transform.right * (movementSpeed * Time.deltaTime); } if (Input.GetKey(forwardKey) || Input.GetKey(KeyCode.UpArrow)) { - transform.position += (transform.forward * (movementSpeed * Time.deltaTime)); + transform.position += transform.forward * (movementSpeed * Time.deltaTime); } if (Input.GetKey(backKey) || Input.GetKey(KeyCode.DownArrow)) { - transform.position += (-transform.forward * (movementSpeed * Time.deltaTime)); + transform.position += -transform.forward * (movementSpeed * Time.deltaTime); } // Teleportation @@ -311,22 +311,22 @@ protected void Update() { if (Input.GetKey(relUpKey)) { - transform.position += (transform.up * (movementSpeed * Time.deltaTime)); + transform.position += transform.up * (movementSpeed * Time.deltaTime); } if (Input.GetKey(relDownKey)) { - transform.position += (-transform.up * (movementSpeed * Time.deltaTime)); + transform.position += -transform.up * (movementSpeed * Time.deltaTime); } if (Input.GetKey(upKey) || Input.GetKey(KeyCode.PageUp)) { - transform.position += (Vector3.up * (movementSpeed * Time.deltaTime)); + transform.position += Vector3.up * (movementSpeed * Time.deltaTime); } if (Input.GetKey(downKey) || Input.GetKey(KeyCode.PageDown)) { - transform.position += (-Vector3.up * (movementSpeed * Time.deltaTime)); + transform.position += -Vector3.up * (movementSpeed * Time.deltaTime); } } diff --git a/Fika.Core/Coop/FreeCamera/FreeCameraController.cs b/Fika.Core/Coop/FreeCamera/FreeCameraController.cs index 18ce9a35..71e8ee27 100644 --- a/Fika.Core/Coop/FreeCamera/FreeCameraController.cs +++ b/Fika.Core/Coop/FreeCamera/FreeCameraController.cs @@ -146,7 +146,7 @@ protected void Update() if (quitState == CoopHandler.EQuitState.YouHaveExtracted && !extracted) { CoopGame coopGame = coopHandler.LocalGameInstance; - if (coopGame.ExtractedPlayers.Contains((_player).NetId)) + if (coopGame.ExtractedPlayers.Contains(_player.NetId)) { extracted = true; ShowExtractMessage(); diff --git a/Fika.Core/Coop/GameMode/CoopGame.cs b/Fika.Core/Coop/GameMode/CoopGame.cs index 5644eb99..70907d11 100644 --- a/Fika.Core/Coop/GameMode/CoopGame.cs +++ b/Fika.Core/Coop/GameMode/CoopGame.cs @@ -1467,16 +1467,16 @@ public void Extract(CoopPlayer player, ExfiltrationPoint point) PreloaderUI preloaderUI = Singleton.Instance; - if (MyExitStatus == ExitStatus.MissingInAction) + if (MyExitStatus == ExitStatus.MissingInAction) { NotificationManagerClass.DisplayMessageNotification("You have gone missing in action...", iconType: EFT.Communications.ENotificationIconType.Alert, textColor: Color.red); } - BackendConfigSettingsClass.GClass1361.GClass1367 matchEndConfig = Singleton.Instance.Experience.MatchEnd; - if (player.Profile.EftStats.SessionCounters.GetAllInt([CounterTag.Exp]) < matchEndConfig.SurvivedExpRequirement || PastTime < matchEndConfig.SurvivedTimeRequirement) - { - MyExitStatus = ExitStatus.Runner; - } + BackendConfigSettingsClass.GClass1361.GClass1367 matchEndConfig = Singleton.Instance.Experience.MatchEnd; + if (player.Profile.EftStats.SessionCounters.GetAllInt([CounterTag.Exp]) < matchEndConfig.SurvivedExpRequirement || PastTime < matchEndConfig.SurvivedTimeRequirement) + { + MyExitStatus = ExitStatus.Runner; + } if (point != null) { @@ -1638,7 +1638,7 @@ private IEnumerator SaveOnDeathRoutine() { yield return null; } - } + } public override void Stop(string profileId, ExitStatus exitStatus, string exitName, float delay = 0f) { @@ -2002,7 +2002,7 @@ public void HandleExit() StaticManager staticManager = StaticManager.Instance; float num = delay; EndAction = new Action(FireCallback); - staticManager.WaitSeconds(num, EndAction); + staticManager.WaitSeconds(num, EndAction); } private void FireCallback() @@ -2036,8 +2036,8 @@ public void ExitOverride() } MonoBehaviour instance2 = StaticManager.Instance; float num = delay; - action_0 = new Action(method_1); - instance2.WaitSeconds(num, action_0); + action_0 = new Action(method_1); + instance2.WaitSeconds(num, action_0); } } diff --git a/Fika.Core/Coop/ObservedClasses/HandsControllers/CoopObservedFirearmController.cs b/Fika.Core/Coop/ObservedClasses/HandsControllers/CoopObservedFirearmController.cs index 19229cd0..d0429f70 100644 --- a/Fika.Core/Coop/ObservedClasses/HandsControllers/CoopObservedFirearmController.cs +++ b/Fika.Core/Coop/ObservedClasses/HandsControllers/CoopObservedFirearmController.cs @@ -42,7 +42,7 @@ public override bool IsAiming } _isAiming = value; - _player.Skills.FastAimTimer.Target = (value ? 0f : 2f); + _player.Skills.FastAimTimer.Target = value ? 0f : 2f; _player.MovementContext.SetAimingSlowdown(IsAiming, 0.33f + aimMovementSpeed); _player.Physical.Aim((!_isAiming || !(_player.MovementContext.StationaryWeapon == null)) ? 0f : ErgonomicWeight); coopPlayer.ProceduralWeaponAnimation.IsAiming = _isAiming; diff --git a/Fika.Core/Coop/PacketHandlers/BotPacketSender.cs b/Fika.Core/Coop/PacketHandlers/BotPacketSender.cs index 69589bb2..48dc98c8 100644 --- a/Fika.Core/Coop/PacketHandlers/BotPacketSender.cs +++ b/Fika.Core/Coop/PacketHandlers/BotPacketSender.cs @@ -37,7 +37,7 @@ public void Init() public void SendQuestPacket(ref QuestConditionPacket packet) { - + } public void SendQuestItemPacket(ref QuestItemPacket packet) diff --git a/Fika.Core/Coop/PacketHandlers/PacketReceiver.cs b/Fika.Core/Coop/PacketHandlers/PacketReceiver.cs index 18293c8e..732929eb 100644 --- a/Fika.Core/Coop/PacketHandlers/PacketReceiver.cs +++ b/Fika.Core/Coop/PacketHandlers/PacketReceiver.cs @@ -1,7 +1,6 @@ // © 2024 Lacyway All Rights Reserved using Comfort.Common; -using EFT.UI; using Fika.Core.Coop.Matchmaker; using Fika.Core.Coop.Players; using Fika.Core.Networking; 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 cc2097a1..61fa23a3 100644 --- a/Fika.Core/Coop/Patches/Minefield/Minefield_method_2_Patch.cs +++ b/Fika.Core/Coop/Patches/Minefield/Minefield_method_2_Patch.cs @@ -68,7 +68,7 @@ private static void DoReplicatedMineDamage(IPlayer player, float distance, bool enumerable = enumerable.DistinctBy(new Func(Minefield.Class2316.class2316_0.method_0)).ToArray(); enumerable = enumerable.Randomize(); - int num3 = ((isCollateral || first) ? UnityEngine.Random.Range(2, enumerable.Count()) : int.MaxValue); + int num3 = (isCollateral || first) ? UnityEngine.Random.Range(2, enumerable.Count()) : int.MaxValue; float num4 = (isCollateral || first) ? firstExplosionDamage : secondExplosionDamage; int num5 = 0; diff --git a/Fika.Core/Coop/Patches/Overrides/BotTemplateLimitPatch_Override.cs b/Fika.Core/Coop/Patches/Overrides/BotTemplateLimitPatch_Override.cs index 33c9f490..03e59169 100644 --- a/Fika.Core/Coop/Patches/Overrides/BotTemplateLimitPatch_Override.cs +++ b/Fika.Core/Coop/Patches/Overrides/BotTemplateLimitPatch_Override.cs @@ -35,7 +35,7 @@ So we change Limit of each group. foreach (WaveInfo wave in __result) { var json = RequestHandler.GetJson($"/singleplayer/settings/bot/limit/{wave.Role}"); - wave.Limit = (string.IsNullOrWhiteSpace(json)) + wave.Limit = string.IsNullOrWhiteSpace(json) ? 30 : Convert.ToInt32(json); } diff --git a/Fika.Core/Coop/Players/CoopBot.cs b/Fika.Core/Coop/Players/CoopBot.cs index d7934a5a..0fd05256 100644 --- a/Fika.Core/Coop/Players/CoopBot.cs +++ b/Fika.Core/Coop/Players/CoopBot.cs @@ -121,11 +121,11 @@ public override GClass1688 ApplyShot(DamageInfo damageInfo, EBodyPart bodyPartTy bool flag = !string.IsNullOrEmpty(damageInfo.DeflectedBy); 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)); + MaterialType materialType = flag ? MaterialType.HelmetRicochet : ((list == null || list.Count < 1) ? MaterialType.Body : list[0].Material); GClass1688 hitInfo = new() { PoV = PointOfView, - Penetrated = (string.IsNullOrEmpty(damageInfo.BlockedBy) || string.IsNullOrEmpty(damageInfo.DeflectedBy)), + Penetrated = string.IsNullOrEmpty(damageInfo.BlockedBy) || string.IsNullOrEmpty(damageInfo.DeflectedBy), Material = materialType }; float num = damage - damageInfo.Damage; diff --git a/Fika.Core/Coop/Players/CoopPlayer.cs b/Fika.Core/Coop/Players/CoopPlayer.cs index c4f373d4..49368038 100644 --- a/Fika.Core/Coop/Players/CoopPlayer.cs +++ b/Fika.Core/Coop/Players/CoopPlayer.cs @@ -1269,7 +1269,7 @@ public virtual void HandleWeaponPacket(in WeaponPacket packet) } } - public virtual void HandleDamagePacket(DamagePacket packet) + public virtual void HandleDamagePacket(ref DamagePacket packet) { DamageInfo damageInfo = new() { diff --git a/Fika.Core/Coop/Players/ObservedCoopPlayer.cs b/Fika.Core/Coop/Players/ObservedCoopPlayer.cs index affb5345..ad53658e 100644 --- a/Fika.Core/Coop/Players/ObservedCoopPlayer.cs +++ b/Fika.Core/Coop/Players/ObservedCoopPlayer.cs @@ -19,7 +19,6 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Linq; using System.Threading.Tasks; using UnityEngine; using static Fika.Core.Networking.FikaSerialization; @@ -380,11 +379,11 @@ public override GClass1688 ApplyShot(DamageInfo damageInfo, EBodyPart bodyPartTy bool flag = !string.IsNullOrEmpty(damageInfo.DeflectedBy); 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)); + MaterialType materialType = flag ? MaterialType.HelmetRicochet : ((list == null || list.Count < 1) ? MaterialType.Body : list[0].Material); GClass1688 hitInfo = new() { PoV = PointOfView, - Penetrated = (string.IsNullOrEmpty(damageInfo.BlockedBy) || string.IsNullOrEmpty(damageInfo.DeflectedBy)), + Penetrated = string.IsNullOrEmpty(damageInfo.BlockedBy) || string.IsNullOrEmpty(damageInfo.DeflectedBy), Material = materialType }; float num = damage - damageInfo.Damage; @@ -440,11 +439,11 @@ public override GClass1688 ApplyShot(DamageInfo damageInfo, EBodyPart bodyPartTy bool flag = !string.IsNullOrEmpty(damageInfo.DeflectedBy); 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)); + MaterialType materialType = flag ? MaterialType.HelmetRicochet : ((list == null || list.Count < 1) ? MaterialType.Body : list[0].Material); GClass1688 hitInfo = new() { PoV = PointOfView, - Penetrated = (string.IsNullOrEmpty(damageInfo.BlockedBy) || string.IsNullOrEmpty(damageInfo.DeflectedBy)), + Penetrated = string.IsNullOrEmpty(damageInfo.BlockedBy) || string.IsNullOrEmpty(damageInfo.DeflectedBy), Material = materialType }; float num = damage - damageInfo.Damage; @@ -810,7 +809,7 @@ public override void OnBeenKilledByAggressor(IPlayer aggressor, DamageInfo damag // Only handle if it was ourselves as otherwise it's irrelevant if (LastAggressor.IsYourPlayer) { - base.OnBeenKilledByAggressor(aggressor, damageInfo, bodyPart, lethalDamageType); + base.OnBeenKilledByAggressor(aggressor, damageInfo, bodyPart, lethalDamageType); } } @@ -1241,6 +1240,11 @@ public override void SendHandsInteractionStateChanged(bool value, int animationI } } + public override void HandleDamagePacket(ref DamagePacket packet) + { + // Do nothing + } + public void HandleProceedPacket(ProceedPacket packet) { switch (packet.ProceedType) @@ -1250,6 +1254,7 @@ public void HandleProceedPacket(ProceedPacket packet) CreateEmptyHandsController(); break; } + case EProceedType.FoodClass: case EProceedType.MedsClass: { CreateMedsController(packet.ItemId, packet.BodyPart, packet.Amount, packet.AnimationVariant); diff --git a/Fika.Core/Networking/FikaClient.cs b/Fika.Core/Networking/FikaClient.cs index 0985a9a9..39c7f15b 100644 --- a/Fika.Core/Networking/FikaClient.cs +++ b/Fika.Core/Networking/FikaClient.cs @@ -141,7 +141,7 @@ private void OnQuestConditionPacketReceived(QuestConditionPacket packet) if (MyPlayer.GClass3227_0 is CoopSharedQuestController sharedQuestController) { sharedQuestController.ReceiveQuestPacket(ref packet); - } + } } } @@ -549,7 +549,7 @@ private void OnHealthSyncPacketReceived(HealthSyncPacket packet) { if (Players.TryGetValue(packet.NetId, out CoopPlayer playerToApply)) { - playerToApply.PacketReceiver?.HealthSyncPackets?.Enqueue(packet); + playerToApply.PacketReceiver.HealthSyncPackets?.Enqueue(packet); } } @@ -635,7 +635,7 @@ private void OnCommonPlayerPacketReceived(CommonPlayerPacket packet) { if (Players.TryGetValue(packet.NetId, out CoopPlayer playerToApply)) { - playerToApply.PacketReceiver?.CommonPlayerPackets?.Enqueue(packet); + playerToApply.PacketReceiver.CommonPlayerPackets?.Enqueue(packet); } } @@ -643,7 +643,7 @@ private void OnInventoryPacketReceived(InventoryPacket packet) { if (Players.TryGetValue(packet.NetId, out CoopPlayer playerToApply)) { - playerToApply.PacketReceiver?.InventoryPackets?.Enqueue(packet); + playerToApply.PacketReceiver.InventoryPackets?.Enqueue(packet); } } @@ -651,7 +651,7 @@ private void OnDamagePacketReceived(DamagePacket packet) { if (Players.TryGetValue(packet.NetId, out CoopPlayer playerToApply)) { - playerToApply.PacketReceiver?.DamagePackets?.Enqueue(packet); + playerToApply.PacketReceiver.DamagePackets?.Enqueue(packet); } } @@ -659,7 +659,7 @@ private void OnFirearmPacketReceived(WeaponPacket packet) { if (Players.TryGetValue(packet.NetId, out CoopPlayer playerToApply)) { - playerToApply.PacketReceiver?.FirearmPackets?.Enqueue(packet); + playerToApply.PacketReceiver.FirearmPackets?.Enqueue(packet); } } diff --git a/Fika.Core/Networking/FikaServer.cs b/Fika.Core/Networking/FikaServer.cs index fc663951..5d8aab9d 100644 --- a/Fika.Core/Networking/FikaServer.cs +++ b/Fika.Core/Networking/FikaServer.cs @@ -215,7 +215,7 @@ private void OnQuestConditionPacketReceived(QuestConditionPacket packet, NetPeer if (MyPlayer.GClass3227_0 is CoopSharedQuestController sharedQuestController) { sharedQuestController.ReceiveQuestPacket(ref packet); - } + } } } @@ -456,7 +456,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(); @@ -532,7 +532,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(); @@ -634,7 +634,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(); @@ -645,7 +645,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(); diff --git a/Fika.Core/UI/Patches/FikaVersionLabel_Patch.cs b/Fika.Core/UI/Patches/FikaVersionLabel_Patch.cs index 629898fe..ed4cda89 100644 --- a/Fika.Core/UI/Patches/FikaVersionLabel_Patch.cs +++ b/Fika.Core/UI/Patches/FikaVersionLabel_Patch.cs @@ -4,8 +4,6 @@ using SPT.Common.Utils; using SPT.Custom.Models; using SPT.Reflection.Patching; -using SPT.Reflection.Utils; -using System.Linq; using System.Reflection; namespace Fika.Core.EssentialPatches @@ -31,7 +29,7 @@ internal static void PatchPostfix(string major, object __result) { string json = RequestHandler.GetJson("/singleplayer/settings/version"); versionLabel = Json.Deserialize(json).Version; - Logger.LogInfo($"Server version: {versionLabel}"); + Logger.LogInfo($"Server version: {versionLabel}"); } string fikaVersion = Assembly.GetAssembly(typeof(FikaVersionLabel_Patch)).GetName().Version.ToString(); diff --git a/Fika.Core/UI/Patches/ItemContext_Patch.cs b/Fika.Core/UI/Patches/ItemContext_Patch.cs index 818184d2..cf167124 100644 --- a/Fika.Core/UI/Patches/ItemContext_Patch.cs +++ b/Fika.Core/UI/Patches/ItemContext_Patch.cs @@ -151,4 +151,4 @@ private static void Prefix(ItemInfoInteractionsAbstractClass co } } } -} +} \ No newline at end of file diff --git a/Fika.Core/Utils/WorldToScreen.cs b/Fika.Core/Utils/WorldToScreen.cs index b93f212d..a16307f8 100644 --- a/Fika.Core/Utils/WorldToScreen.cs +++ b/Fika.Core/Utils/WorldToScreen.cs @@ -33,8 +33,8 @@ public static bool GetScreenPoint(Vector3 worldPosition, CoopPlayer mainPlayer, Vector3 opticCenterScreenPosition = GetOpticCenterScreenPosition(weaponAnimation, worldCamera); Vector3 opticCenterScreenOffset = opticCenterScreenPosition - (new Vector3(Screen.width, Screen.height, 0f) / 2); - float opticScale = (Screen.height / opticCamera.scaledPixelHeight); - Vector3 opticCameraOffset = new Vector3((worldCamera.pixelWidth / 2 - opticCamera.pixelWidth / 2), (worldCamera.pixelHeight / 2 - opticCamera.pixelHeight / 2), 0); + float opticScale = Screen.height / opticCamera.scaledPixelHeight; + Vector3 opticCameraOffset = new Vector3(worldCamera.pixelWidth / 2 - opticCamera.pixelWidth / 2, worldCamera.pixelHeight / 2 - opticCamera.pixelHeight / 2, 0); Vector3 opticScreenPoint = (opticCamera.WorldToScreenPoint(worldPosition) + opticCameraOffset) * opticScale; if (opticScreenPoint.z > 0f)