private void SwitchCarState(CarState newState) { if (newState == null) { return; } if (carState != null) { carState.OnEnd(); } carState = newState; carState.OnBegin(this); }