public void ChangeState(State <T> newState) { if (stateCurrent != null) { stateCurrent.Exit(); } stateCurrent = newState; stateCurrent.Enter(); }
public void SetState <TState>() where TState : State { if (_stateAlreadySet) { return; } stateEvent?.Raise(currentState.Exit()); currentState = GetState <TState>(); stateEvent?.Raise(currentState.Enter()); _stateAlreadySet = true; }