peds are killed with a separate function ; ragdoll is detached only when peds are killed, not destroyed

This commit is contained in:
in0finite 2021-01-05 05:18:47 +01:00
parent acae61657d
commit 17f6aaeeda
4 changed files with 24 additions and 7 deletions

View file

@ -207,11 +207,6 @@ namespace SanAndreasUnity.Behaviours
void OnDisable ()
{
s_allPeds.Remove (this);
if (this.PlayerModel != null)
{
this.PlayerModel.DetachRagdoll(this.KillingDamageInfo);
}
}

View file

@ -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);
}
}
}

View file

@ -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

View file

@ -164,7 +164,7 @@ namespace SanAndreasUnity.UI {
{
foreach (var p in Ped.AllPeds)
{
Destroy (p.gameObject);
p.Kill();
}
}