public FiniteStateMachine(ExplicitState initialState) { initialState.StateMachine = this; InitialState = CurrentState = initialState; OnEnterState(); EnterState?.Invoke(); CurrentState.OnEnter(); }
public void Transition(ExplicitState toState) { if (CurrentState == toState) { return; } if (toState == null) { throw new ArgumentNullException("toState"); } OnExitState(); ExitState?.Invoke(); CurrentState.OnExit(); CurrentState = toState; OnEnterState(); EnterState?.Invoke(); CurrentState.OnEnter(); }