using System;
using UnityEngine;

public abstract class AbstractState : MonoBehaviour
{
    [SerializeField]
    private AbstractTransition transition = null; 

    protected StateMachine StateMachine { get; private set; }
    public void Init(StateMachine stateMachine)
    {
        StateMachine = stateMachine;
    }

    public void EnterState()
    {
        if (transition == null) {
            gameObject.SetActive(true);
        } else {
            transition.EnterTransition();
        }
        OnEnterState();
    }

    public void ExitState()
    {
        if (transition == null) {
            gameObject.SetActive(false);
        } else {
            transition.ExitTransition();
        }
        OnExitState();
    }

    protected virtual void OnEnterState()
    {
    }

    protected virtual void OnExitState()
    {
    }
}
