using Sirenix.OdinInspector;
using UnityEditor.Animations;
using UnityEngine;

namespace VOID.Generic.Objects.Door
{
    [System.Serializable]
    public class DoorObjectAnimator : ObjectComponent<DoorObject>
    {
        #region Initialize

        protected override void SelfInitialize()
        {
            _animator = parent.GetComponent<Animator>();
            _animator.runtimeAnimatorController = Object.Instantiate(animatorController);
        }

        #endregion

        private static readonly int TriggerOpen = Animator.StringToHash("TRIGGER_OPEN");
        private static readonly int TriggerClose = Animator.StringToHash("TRIGGER_CLOSE");
        
        private Animator _animator;

        [SerializeField, Required] private AnimatorController animatorController;

        public void PlayOpen()
        {
            _animator.SetTrigger(TriggerOpen);
        }

        public void PlayClose()
        {
            _animator.SetTrigger(TriggerClose);
        }
    }
}
