Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Lacyway committed Jun 14, 2024
1 parent 3918b29 commit 2a33dc6
Show file tree
Hide file tree
Showing 22 changed files with 66 additions and 65 deletions.
2 changes: 1 addition & 1 deletion Fika.Core/Coop/BTR/FikaBTRManager_Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion Fika.Core/Coop/BTR/FikaBTRManager_Host.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 0 additions & 1 deletion Fika.Core/Coop/BotClasses/CoopBotInventoryController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

using Comfort.Common;
using EFT;
using EFT.InventoryLogic;
using Fika.Core.Coop.Players;
using Fika.Core.Networking;
using JetBrains.Annotations;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
14 changes: 7 additions & 7 deletions Fika.Core/Coop/Components/CoopHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,29 +202,29 @@ 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<FikaServer>.Instance.NetServer.ConnectedPeersCount > 0) && quitState != EQuitState.NONE)
// A host needs to wait for the team to extract or die!
if ((Singleton<FikaServer>.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<FikaServer>.Instance.NetServer.ConnectedPeersCount == 0
&& Singleton<FikaServer>.Instance.timeSinceLastPeerDisconnected > DateTime.Now.AddSeconds(-5)
&& Singleton<FikaServer>.Instance.hasHadPeer)
&& Singleton<FikaServer>.Instance.timeSinceLastPeerDisconnected > DateTime.Now.AddSeconds(-5)
&& Singleton<FikaServer>.Instance.hasHadPeer)
{
NotificationManagerClass.DisplayWarningNotification($"HOSTING: Please wait at least 5 seconds after the last peer disconnected before quitting.");
requestQuitGame = false;
return;
}
else
{
coopGame.Stop(Singleton<GameWorld>.Instance.MainPlayer.ProfileId, coopGame.MyExitStatus, MyPlayer.ActiveHealthController.IsAlive ? coopGame.MyExitLocation : null, 0);
coopGame.Stop(Singleton<GameWorld>.Instance.MainPlayer.ProfileId, coopGame.MyExitStatus, MyPlayer.ActiveHealthController.IsAlive ? coopGame.MyExitLocation : null, 0);
}
}
else
{
coopGame.Stop(Singleton<GameWorld>.Instance.MainPlayer.ProfileId, coopGame.MyExitStatus, MyPlayer.ActiveHealthController.IsAlive ? coopGame.MyExitLocation : null, 0);
coopGame.Stop(Singleton<GameWorld>.Instance.MainPlayer.ProfileId, coopGame.MyExitStatus, MyPlayer.ActiveHealthController.IsAlive ? coopGame.MyExitLocation : null, 0);
}
return;
}
Expand Down Expand Up @@ -307,7 +307,7 @@ private async void SpawnPlayer(SpawnObject spawnObject)
}
}

int playerId = Players.Count + Singleton<GameWorld>.Instance.RegisteredPlayers.Count + 1;
int playerId = Players.Count + Singleton<GameWorld>.Instance.RegisteredPlayers.Count + 1;

IEnumerable<ResourceKey> allPrefabPaths = spawnObject.Profile.GetAllPrefabPaths();
if (allPrefabPaths.Count() == 0)
Expand Down
8 changes: 4 additions & 4 deletions Fika.Core/Coop/Custom/FikaHealthBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ protected void Awake()
{
currentPlayer = GetComponent<ObservedCoopPlayer>();
mainPlayer = (CoopPlayer)Singleton<GameWorld>.Instance.MainPlayer;
CreateHealthBar();
CreateHealthBar();
}

protected void Update()
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions Fika.Core/Coop/FreeCamera/FreeCamera.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}
}

Expand Down
2 changes: 1 addition & 1 deletion Fika.Core/Coop/FreeCamera/FreeCameraController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
20 changes: 10 additions & 10 deletions Fika.Core/Coop/GameMode/CoopGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1467,16 +1467,16 @@ public void Extract(CoopPlayer player, ExfiltrationPoint point)
PreloaderUI preloaderUI = Singleton<PreloaderUI>.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<BackendConfigSettingsClass>.Instance.Experience.MatchEnd;
if (player.Profile.EftStats.SessionCounters.GetAllInt([CounterTag.Exp]) < matchEndConfig.SurvivedExpRequirement || PastTime < matchEndConfig.SurvivedTimeRequirement)
{
MyExitStatus = ExitStatus.Runner;
}
BackendConfigSettingsClass.GClass1361.GClass1367 matchEndConfig = Singleton<BackendConfigSettingsClass>.Instance.Experience.MatchEnd;
if (player.Profile.EftStats.SessionCounters.GetAllInt([CounterTag.Exp]) < matchEndConfig.SurvivedExpRequirement || PastTime < matchEndConfig.SurvivedTimeRequirement)
{
MyExitStatus = ExitStatus.Runner;
}

if (point != null)
{
Expand Down Expand Up @@ -1638,7 +1638,7 @@ private IEnumerator SaveOnDeathRoutine()
{
yield return null;
}
}
}

public override void Stop(string profileId, ExitStatus exitStatus, string exitName, float delay = 0f)
{
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Fika.Core/Coop/PacketHandlers/BotPacketSender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void Init()

public void SendQuestPacket(ref QuestConditionPacket packet)
{

}

public void SendQuestItemPacket(ref QuestItemPacket packet)
Expand Down
1 change: 0 additions & 1 deletion Fika.Core/Coop/PacketHandlers/PacketReceiver.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private static void DoReplicatedMineDamage(IPlayer player, float distance, bool
enumerable = enumerable.DistinctBy(new Func<BodyPartCollider, EBodyPart>(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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions Fika.Core/Coop/Players/CoopBot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ public override GClass1688 ApplyShot(DamageInfo damageInfo, EBodyPart bodyPartTy
bool flag = !string.IsNullOrEmpty(damageInfo.DeflectedBy);
float damage = damageInfo.Damage;
List<ArmorComponent> 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;
Expand Down
2 changes: 1 addition & 1 deletion Fika.Core/Coop/Players/CoopPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
17 changes: 11 additions & 6 deletions Fika.Core/Coop/Players/ObservedCoopPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -380,11 +379,11 @@ public override GClass1688 ApplyShot(DamageInfo damageInfo, EBodyPart bodyPartTy
bool flag = !string.IsNullOrEmpty(damageInfo.DeflectedBy);
float damage = damageInfo.Damage;
List<ArmorComponent> 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;
Expand Down Expand Up @@ -440,11 +439,11 @@ public override GClass1688 ApplyShot(DamageInfo damageInfo, EBodyPart bodyPartTy
bool flag = !string.IsNullOrEmpty(damageInfo.DeflectedBy);
float damage = damageInfo.Damage;
List<ArmorComponent> 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;
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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)
Expand All @@ -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);
Expand Down
Loading

0 comments on commit 2a33dc6

Please sign in to comment.