private void ActivateState(StateId state) { if (ActiveState != null) { if (ActiveState.Id == state) { return; } ActiveState.Deactivate(); } ActiveState = _registeredStates[state]; ActiveState.Activate(); OnStateChanged(state); }