mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2024-11-14 16:27:19 +00:00
ped damage handling is done by State classes
This commit is contained in:
parent
9734b6f515
commit
e5c6144706
3 changed files with 23 additions and 16 deletions
|
@ -96,21 +96,7 @@ namespace SanAndreasUnity.Behaviours
|
|||
if (this.Health <= 0)
|
||||
return;
|
||||
|
||||
DamageInfo damageInfo = this.Damageable.LastDamageInfo;
|
||||
|
||||
float amount = damageInfo.raycastHitTransform != null
|
||||
? this.PlayerModel.GetAmountOfDamageForBone(damageInfo.raycastHitTransform, damageInfo.amount)
|
||||
: damageInfo.amount;
|
||||
|
||||
this.Health -= amount;
|
||||
|
||||
if (this.Health <= 0)
|
||||
{
|
||||
Object.Destroy(this.gameObject);
|
||||
}
|
||||
|
||||
// notify clients
|
||||
this.SendDamagedEventToClients(damageInfo, amount);
|
||||
this.CurrentState.OnDamaged(this.Damageable.LastDamageInfo);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -308,6 +308,24 @@ namespace SanAndreasUnity.Behaviours.Peds.States
|
|||
weapon.PlayFireSound();
|
||||
}
|
||||
|
||||
}
|
||||
public virtual void OnDamaged(DamageInfo damageInfo)
|
||||
{
|
||||
float amount = damageInfo.raycastHitTransform != null
|
||||
? m_model.GetAmountOfDamageForBone(damageInfo.raycastHitTransform, damageInfo.amount)
|
||||
: damageInfo.amount;
|
||||
|
||||
m_ped.Health -= amount;
|
||||
|
||||
if (m_ped.Health <= 0)
|
||||
{
|
||||
Object.Destroy(m_ped.gameObject);
|
||||
}
|
||||
|
||||
// notify clients
|
||||
m_ped.SendDamagedEventToClients(damageInfo, amount);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
using SanAndreasUnity.Utilities;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SanAndreasUnity.Behaviours.Peds.States
|
||||
|
@ -31,6 +32,8 @@ namespace SanAndreasUnity.Behaviours.Peds.States
|
|||
|
||||
void OnWeaponFiredFromServer(Weapon weapon, Vector3 firePos);
|
||||
|
||||
void OnDamaged(DamageInfo damageInfo);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue