/** * HeadMachine 시동 * @param initState 작동시 초기화 할 상태 */ public void Begin(IState initState) { currentState = initState; prevState = initState; if (currentState != null) { currentState.OnEnter(); } }
/** * HeadMachine 상태 변경 * @param nextState 변경할 상태 */ public void SetState(IState nextState) { if (currentState == nextState) { return; } prevState = currentState; if (currentState != null) { currentState.OnExit(); } currentState = nextState; currentState.OnEnter(); }