00001 // ///////////////////////////////////////////////////////////////////////////// 00002 // 00003 // Name: GameManager.h 00004 // Author: Michael Bartsch (ZCCdark203) 00005 // 00006 // Desc : Declaration of the GameManager class. 00007 // 00008 // License: Copyright (C) 2009 Michael Bartsch and Contributors 00009 // 00010 // This program is free software: you can redistribute it 00011 // and/or modify it under the terms of the zlib/libpng License. 00012 // See main.cpp for conditions of distribution and use. 00013 // 00014 // ///////////////////////////////////////////////////////////////////////////// 00015 00016 #ifndef __GAMEMANAGER_H__ 00017 #define __GAMEMANAGER_H__ 00018 00019 // Include files 00020 #include "../dependencies.h" 00021 00022 #include "DataStore.h" 00023 #include "EntityManager.h" 00024 #include "EventManager.h" 00025 #include "../sound/SoundManager.h" 00026 #include "../scripting/ScriptManager.h" 00027 #include "../components/components.h" 00028 00029 #include "GameState.h" 00030 00031 // Forward declarations 00032 class GameState; 00033 class ScriptManager; 00034 00035 00036 // GameManager class 00040 class GameManager 00041 { 00042 public: 00043 00044 // Initialisation, deinitialisation and control... 00046 GameManager(); 00048 ~GameManager(); 00049 00051 static GameManager* Instance(); 00053 static GameManager& Reference(); 00054 00056 void init(); 00058 void update(); 00060 void clear(); 00061 00062 // AngelScript binding 00065 static GameManager* refFactory(); 00068 void refAdd(); 00071 void refRelease(); 00072 00073 // Public methods 00076 void changeState(GameState *state); 00079 void changeState(asIScriptObject *object); 00082 void pushState(GameState *state); 00085 void pushState(asIScriptObject *object); 00087 void popState(); 00088 00091 IrrlichtDevice* getDevice(); 00094 IVideoDriver* getDriver(); 00097 ISceneManager* getSceneManager(); 00100 IGUIEnvironment* getGUIEnvironment(); 00101 00103 DataStore* getDataStore(); 00105 EntityManager* getEntityManager(); 00107 EventManager* getEventManager(); 00109 ScriptManager* getScriptManager(); 00111 SoundManager* getSoundManager(); 00112 00114 bool getIsRunning() const; 00115 00117 void setIsRunning(bool value); 00118 00119 00120 private: 00121 00122 // GameManager singleton 00123 static GameManager *pInstance; 00124 00125 // Normal members 00126 vector<GameState*> mGameStates; 00127 00128 IrrlichtDevice *pDevice; 00129 IVideoDriver *pDriver; 00130 ISceneManager *pSceneManager; 00131 IGUIEnvironment *pGUIEnvironment; 00132 00133 DataStore *pDataStore; 00134 EntityManager *pEntityManager; 00135 EventManager *pEventManager; 00136 ScriptManager *pScriptManager; 00137 SoundManager *pSoundManager; 00138 00139 u32 mLastTime; 00140 }; 00141 00142 00143 // GameManager Angelscript binding. 00145 extern void bindGameManager(asIScriptEngine *engine); 00146 00147 #endif