public void ChangeState(MachineBehaviourState <T> targetState) { if (targetState == null) { throw new System.Exception("Can't find target state."); } targetState.owner = CurrentState.owner; PreState = CurrentState; CurrentState.Exit(); CurrentState = targetState; CurrentState.Enter(); }
public StateMachine(T owner, MachineBehaviourState <T> firstState, MachineBehaviourState <T> globalState = null) { if (globalState != null) { GlobalState = globalState; GlobalState.owner = owner; GlobalState.Enter(); } CurrentState = firstState; CurrentState.owner = owner; CurrentState.Enter(); }