using UnityEngine;

namespace ScrambleKit.FX
{
    [System.Serializable]
    public class FXTrigger
    {
        public Transform SpawnPrefab;
        public string AnimState;
        public string SoundName;
        public float HitStop;
        public float CameraShake;

        public void Trigger(Transform owner)
        {
            if (HitStop != 0)
                HitStopFX.HitStop(HitStop);

            if(CameraShake != 0)
            {
                CameraFX.Shake(CameraShake);
            }

            if (SpawnPrefab)
            {
                Transform t = GameObject.Instantiate(SpawnPrefab);
                t.position = owner.position;
            }

            if (AnimState != "")
            {
                Animator anim = owner.GetComponent<Animator>();
                if (anim != null)
                    anim.Play(AnimState);
            }

            if(SoundName != "")
            {
                SoundFX.PlaySound(SoundName);
            }
        }

    }
}