コード例 #1
0
 public FiniteStateMachine(ExplicitState initialState)
 {
     initialState.StateMachine = this;
     InitialState = CurrentState = initialState;
     OnEnterState();
     EnterState?.Invoke();
     CurrentState.OnEnter();
 }
コード例 #2
0
        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();
        }