/// <summary> /// Exits the current state and returns the Type of it. /// </summary> /// <returns></returns> private Type ExitCurrentState(bool addToHistory) { if (_currentState == null) { return(null); } else { _currentState.Exit(); // Record it in the history if (addToHistory) { AddStateToHistory(_currentState); } var stateType = _currentState.StateType; _currentState = null; return(stateType); } }