Example #1
0
        public bool Dispatch(int key, ITransitionParameter transitionParameter = null)
        {
            if (_states.TryGetValue(key, out var next))
            {
                _nextState           = next;
                CurrentStateKey      = key;
                _transitionParameter = transitionParameter;
                return(true);
            }

            return(false);
        }
Example #2
0
        public void Update()
        {
            if (_nextState == _currentState)
            {
                _nextState           = null;
                _transitionParameter = null;
                return;
            }

            if (_nextState != null)
            {
                _currentState?.Exit();
                _currentState = _nextState;
                _currentState.Enter(_transitionParameter);
                _nextState           = null;
                _transitionParameter = null;
            }

            if (_currentState != null)
            {
                _currentState.Update();
                _currentState.TransitionIfNeeded();
            }
        }
Example #3
0
 protected void Dispatch(int key, ITransitionParameter transitionParameter)
 {
     StateMachine.Dispatch(key, transitionParameter);
 }
Example #4
0
 public virtual void Enter(ITransitionParameter transitionParameter)
 {
 }