동현

State

public abstract class State<T> where T : class
{
    // 해당 상태를 시작할 때 1회 호출
    public abstract void Enter(T entity);

    // 해당 상태를 업데이트할 때 매 프레임 호출
    public abstract void Execute(T entity);

    // 해당 상태를 종료할 때 1회 호출
    public abstract void Exit(T entity);
}

// 어떤 Entity()가 어떤 상태에 들어가라

StateMachine

    private T ownerEntity;          // StateMachine 소유주
    private State<T> curState;
    private State<T> previousState; // 이전 상태
    private State<T> globalState;   // 전역 상태
    public void Setup(T owner, State<T> entryState)
    {
        ownerEntity = owner;
        curState = null;
        previousState = null;
        globalState = null;

        ChangeState(entryState);
    }