1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
void StateManager::changeState(StateID nextStateID)
{
	// UNFOCUS THE CURRENT STATE //
	if (currentState())
	{
		currentState()->onUnFocus();

		// DESTROY THE STATE IF IT WANTS IT //
		if(currentState()->isDestroyedOnUnFocus()) {
			destroyCurrentState();
		}
	}


	if (m_GameStates[nextStateID]) {
		// SWITCH TO NEXT STATE //
		setCurrentState(nextStateID);
	
	}
	else
	{
		// CREATE NEW STATE //
		switch (nextStateID)
		{
		case MainMenuStateID:
			m_GameStates[MainMenuStateID] = new MainMenuState;

			break;

		case GameStateID:
                        m_GameStates[MainMenuStateID] = new GameStates;

			break;

		};

		setCurrentState(nextStateID);
	}
	

	// FOCUS NEXT STATE //
	currentState()->onFocus();
	
}