mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2024-11-26 22:10:17 +00:00
peds are killed with a separate function ; ragdoll is detached only when peds are killed, not destroyed
This commit is contained in:
parent
acae61657d
commit
17f6aaeeda
4 changed files with 24 additions and 7 deletions
|
@ -207,11 +207,6 @@ namespace SanAndreasUnity.Behaviours
|
|||
void OnDisable ()
|
||||
{
|
||||
s_allPeds.Remove (this);
|
||||
|
||||
if (this.PlayerModel != null)
|
||||
{
|
||||
this.PlayerModel.DetachRagdoll(this.KillingDamageInfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@ namespace SanAndreasUnity.Behaviours
|
|||
/// </summary>
|
||||
public DamageInfo KillingDamageInfo { get; set; }
|
||||
|
||||
private bool m_alreadyKilled = false;
|
||||
|
||||
|
||||
|
||||
void AwakeForDamage ()
|
||||
|
@ -130,6 +132,26 @@ namespace SanAndreasUnity.Behaviours
|
|||
msg.Text = damageAmount.ToString();
|
||||
}
|
||||
|
||||
public void Kill()
|
||||
{
|
||||
F.RunExceptionSafe(this.KillInternal);
|
||||
}
|
||||
|
||||
void KillInternal()
|
||||
{
|
||||
if (m_alreadyKilled)
|
||||
return;
|
||||
|
||||
m_alreadyKilled = true;
|
||||
|
||||
if (this.PlayerModel != null)
|
||||
{
|
||||
this.PlayerModel.DetachRagdoll(this.KillingDamageInfo);
|
||||
}
|
||||
|
||||
Object.Destroy(this.gameObject);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -319,7 +319,7 @@ namespace SanAndreasUnity.Behaviours.Peds.States
|
|||
if (m_ped.Health <= 0)
|
||||
{
|
||||
m_ped.KillingDamageInfo = damageInfo;
|
||||
Object.Destroy(m_ped.gameObject);
|
||||
m_ped.Kill();
|
||||
}
|
||||
|
||||
// notify clients
|
||||
|
|
|
@ -164,7 +164,7 @@ namespace SanAndreasUnity.UI {
|
|||
{
|
||||
foreach (var p in Ped.AllPeds)
|
||||
{
|
||||
Destroy (p.gameObject);
|
||||
p.Kill();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue