/// <summary>
        /// Transition into the specified state.
        /// </summary>
        /// <param name="id">StateId of the new state.</param>
        public void EnterState(StateId id)
        {
            EngineState state = _gameStates[id];

            if (state == null)
            {
                throw new InvalidOperationException("Attempting to switch to state id '" + id + "' which has a null state instance!");
            }
            if (_currentState != null)
            {
                _currentState.OnExit();
            }
            _currentState = state;
            _currentState.OnEnter();
        }