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); }
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(); } }
protected void Dispatch(int key, ITransitionParameter transitionParameter) { StateMachine.Dispatch(key, transitionParameter); }
public virtual void Enter(ITransitionParameter transitionParameter) { }