using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;

public class AnimetorEventer : MonoBehaviour
{
    [System.Serializable]
    public class EventInfo
    {
        public string eventTag;
        public UnityEvent eventCall;
        public bool isEnable = true;
        public bool isMany = true;
    }

    public Animator ani;
    public List<EventInfo> eventList = new List<EventInfo>();


    private void Awake()
    {
        ani = GetComponent<Animator>();
    }
    public void eventCall(string eventTag)
    {
#if UNITY_EDITOR
        if (Application.isPlaying == false)
        {
            return;
        }
#endif
        EventInfo eventInfo = eventList.Find(x => x.eventTag.Equals(eventTag) && x.isEnable);
        if (eventInfo != null)
        {
            eventInfo.isEnable = eventInfo.isMany;
            eventInfo.eventCall?.Invoke();
        }
    }
    public void triggerCall(string trigger)
    {
        ani.SetTrigger(trigger);
    }
}
