private void OnReadyToChangeState(IAIState nextState) { _currentState.OnReadyToTransition -= OnReadyToChangeState; _currentState?.TryExit(nextState); _currentState = nextState; _currentState.OnReadyToTransition += OnReadyToChangeState; _currentState?.TryEnter(); }
public virtual void TryExit(IAIState nextState) { // is this state on the next state's path? if (nextState.IsStateOnPath(this)) { // if so, no need to exit this state return; } if (_parentState != null) { _parentState.TryExit(nextState); } OnExit(); }