public void changeState(BaseGameState state, Transition out, Transition in) { if (state == null) { throw new IllegalArgumentException("State must not be null!"); } if (isTransitioning()) { if (leaving != null) { completeLeave(); } if (entering != null) { completeEnter(); } } leaving = out; entering = in; nextState = state; currentState.onLeave(nextState); nextState.onEnter(currentState); if (leaving == null) { completeLeave(); } }