using System.Collections.Generic; using SanAndreasUnity.Utilities; using UnityEngine; namespace SanAndreasUnity.Behaviours.Peds { public class DeadBody : MonoBehaviour { private static List _deadBodies = new List(); public static IEnumerable DeadBodies => _deadBodies; public static int NumDeadBodies => _deadBodies.Count; public PushableByDamage PushableByDamage { get; private set; } private void Awake() { this.PushableByDamage = this.GetComponentOrThrow(); this.PushableByDamage.forceMultiplier = PedManager.Instance.ragdollDamageForceWhenDetached; } private void OnEnable() { _deadBodies.Add(this); } private void OnDisable() { _deadBodies.Remove(this); } public static DeadBody Create(Transform ragdollTransform, Ped ped) { NetStatus.ThrowIfNotOnServer(); GameObject ragdollGameObject = Object.Instantiate(PedManager.Instance.ragdollPrefab); DeadBody deadBody = ragdollGameObject.GetComponentOrThrow(); Object.Destroy(ragdollGameObject, PedManager.Instance.ragdollLifetime * Random.Range(0.85f, 1.15f)); ragdollGameObject.name = "dead body " + ped.name; ragdollTransform.SetParent(ragdollGameObject.transform); NetManager.Spawn(ragdollGameObject); return deadBody; } } }