using UnityEngine;

namespace ScrambleKit.Hits
{
    public class Corpse : MonoBehaviour
    {
        public bool DropAtRoot = true;

        public Transform CorpsePrefab;
        public bool CopyOwnersScaleRotation = false;
        
        void Dying()
        {
            if (CorpsePrefab == null)
                return;

            Transform corpse = Instantiate(CorpsePrefab);

            Transform toCopy = (DropAtRoot) ? transform.root : transform;

            corpse.position = toCopy.position;

            if (CopyOwnersScaleRotation)
            {
                corpse.localScale = toCopy.localScale;
                corpse.localEulerAngles = toCopy.eulerAngles;
            }
        }
    }

}