1 /* Copyright (C) 2016 Wildfire Games. 2 * This file is part of 0 A.D. 3 * 4 * 0 A.D. is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * 0 A.D. is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 #ifndef INCLUDED_SIMCONTEXT 19 #define INCLUDED_SIMCONTEXT 20 21 #include "Entity.h" 22 23 class CComponentManager; 24 class CUnitManager; 25 class CTerrain; 26 class ScriptInterface; 27 28 /** 29 * Contains pointers to various 'global' objects that are needed by the simulation code, 30 * to allow easy access without using real (evil) global variables. 31 */ 32 class CSimContext 33 { 34 public: 35 CSimContext(); 36 ~CSimContext(); 37 38 CComponentManager& GetComponentManager() const; 39 void SetComponentManager(CComponentManager* man); 40 41 bool HasUnitManager() const; 42 CUnitManager& GetUnitManager() const; 43 44 CTerrain& GetTerrain() const; 45 46 ScriptInterface& GetScriptInterface() const; 47 SetSystemEntity(CEntityHandle ent)48 void SetSystemEntity(CEntityHandle ent) { m_SystemEntity = ent; } GetSystemEntity()49 CEntityHandle GetSystemEntity() const { ASSERT(m_SystemEntity.GetId() == SYSTEM_ENTITY); return m_SystemEntity; } 50 51 /** 52 * Returns the player ID that the current display is being rendered for. 53 * Currently relies on g_Game being initialised (evil globals...) 54 */ 55 int GetCurrentDisplayedPlayer() const; 56 57 private: 58 CComponentManager* m_ComponentManager; 59 CUnitManager* m_UnitManager; 60 CTerrain* m_Terrain; 61 62 CEntityHandle m_SystemEntity; 63 64 friend class CSimulation2Impl; 65 }; 66 67 #endif // INCLUDED_SIMCONTEXT 68