private void OnReadyToChangeState(AIState state) { _currentState.OnReadyToChangeState -= OnReadyToChangeState; AIState nextState = state; if (_queuedAIStates.Count > 0) { nextState = _queuedAIStates.Dequeue(); } _currentState?.Exit(nextState); _currentState = nextState; _currentState.OnReadyToChangeState += OnReadyToChangeState; _currentState?.Enter(); }
public virtual void Enter() { // if already active, no need to re-enter if (Active) { return; } _character.AnimationController?.UpdateAnimationState(_animationData); if (_parentState != null) { _parentState.Enter(); _parentState.OnReadyToChangeState += FireReadyToChangeState; } Active = true; }
// Start is called before the first frame update void Start() { _currentState.OnReadyToChangeState += OnReadyToChangeState; _currentState?.Enter(); }