Skip to content

Commit

Permalink
Replicate explosion armor damage
Browse files Browse the repository at this point in the history
  • Loading branch information
Lacyway committed Sep 27, 2024
1 parent af5e08e commit c331d1b
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 0 deletions.
29 changes: 29 additions & 0 deletions Fika.Core/Coop/Players/CoopBot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,35 @@ public override ShotInfoClass ApplyShot(DamageInfo damageInfo, EBodyPart bodyPar
return hitInfo;
}

public override void ApplyExplosionDamageToArmor(Dictionary<GStruct209, float> armorDamage, DamageInfo damageInfo)
{
_preAllocatedArmorComponents.Clear();
Inventory.GetPutOnArmorsNonAlloc(_preAllocatedArmorComponents);
List<ArmorComponent> armorComponents = [];
foreach (ArmorComponent armorComponent in _preAllocatedArmorComponents)
{
float num = 0f;
foreach (KeyValuePair<GStruct209, float> keyValuePair in armorDamage)
{
if (armorComponent.ShotMatches(keyValuePair.Key.BodyPartColliderType, keyValuePair.Key.ArmorPlateCollider))
{
num += keyValuePair.Value;
armorComponents.Add(armorComponent);
}
}
if (num > 0f)
{
num = armorComponent.ApplyExplosionDurabilityDamage(num, damageInfo, _preAllocatedArmorComponents);
method_95(num, armorComponent);
}
}

if (armorComponents.Count > 0)
{
QueueArmorDamagePackets([.. armorComponents]);
}
}

public override void Proceed(Weapon weapon, Callback<IFirearmHandsController> callback, bool scheduled = true)
{
BotFirearmControllerHandler handler = new(this, weapon);
Expand Down
32 changes: 32 additions & 0 deletions Fika.Core/Coop/Players/CoopPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1310,6 +1310,38 @@ public virtual void HandleWeaponPacket(in WeaponPacket packet)
}
}

public override void ApplyExplosionDamageToArmor(Dictionary<GStruct209, float> armorDamage, DamageInfo damageInfo)
{
if (IsYourPlayer)
{
_preAllocatedArmorComponents.Clear();
Inventory.GetPutOnArmorsNonAlloc(_preAllocatedArmorComponents);
List<ArmorComponent> armorComponents = [];
foreach (ArmorComponent armorComponent in _preAllocatedArmorComponents)
{
float num = 0f;
foreach (KeyValuePair<GStruct209, float> keyValuePair in armorDamage)
{
if (armorComponent.ShotMatches(keyValuePair.Key.BodyPartColliderType, keyValuePair.Key.ArmorPlateCollider))
{
num += keyValuePair.Value;
armorComponents.Add(armorComponent);
}
}
if (num > 0f)
{
num = armorComponent.ApplyExplosionDurabilityDamage(num, damageInfo, _preAllocatedArmorComponents);
method_95(num, armorComponent);
}
}

if (armorComponents.Count > 0)
{
QueueArmorDamagePackets([.. armorComponents]);
}
}
}

public void QueueArmorDamagePackets(ArmorComponent[] armorComponents)
{
int amount = armorComponents.Length;
Expand Down
32 changes: 32 additions & 0 deletions Fika.Core/Coop/Players/ObservedCoopPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,38 @@ public override ShotInfoClass ApplyShot(DamageInfo damageInfo, EBodyPart bodyPar
return hitInfo;
}

public override void ApplyExplosionDamageToArmor(Dictionary<GStruct209, float> armorDamage, DamageInfo damageInfo)
{
if (isServer)
{
_preAllocatedArmorComponents.Clear();
Inventory.GetPutOnArmorsNonAlloc(_preAllocatedArmorComponents);
List<ArmorComponent> armorComponents = [];
foreach (ArmorComponent armorComponent in _preAllocatedArmorComponents)
{
float num = 0f;
foreach (KeyValuePair<GStruct209, float> keyValuePair in armorDamage)
{
if (armorComponent.ShotMatches(keyValuePair.Key.BodyPartColliderType, keyValuePair.Key.ArmorPlateCollider))
{
num += keyValuePair.Value;
armorComponents.Add(armorComponent);
}
}
if (num > 0f)
{
num = armorComponent.ApplyExplosionDurabilityDamage(num, damageInfo, _preAllocatedArmorComponents);
method_95(num, armorComponent);
}
}

if (armorComponents.Count > 0)
{
QueueArmorDamagePackets([.. armorComponents]);
}
}
}

public ShotInfoClass ApplyClientShot(DamageInfo damageInfo, EBodyPart bodyPartType, EBodyPartColliderType colliderType, EArmorPlateCollider armorPlateCollider, GStruct400 shotId)
{
ShotReactions(damageInfo, bodyPartType);
Expand Down

0 comments on commit c331d1b

Please sign in to comment.