Line data Source code
1 : /* Copyright (C) 2026 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 "lib/debug.h" 22 : #include "simulation2/system/Entity.h" 23 : 24 : class CComponentManager; 25 : class CUnitManager; 26 : class CTerrain; 27 : namespace Script { class Interface; } 28 : 29 : /** 30 : * Contains pointers to various 'global' objects that are needed by the simulation code, 31 : * to allow easy access without using real (evil) global variables. 32 : */ 33 : class CSimContext 34 : { 35 : public: 36 : CSimContext(CTerrain* terrain = nullptr, CUnitManager* unitManager = nullptr); 37 : ~CSimContext(); 38 : 39 : CComponentManager& GetComponentManager() const; 40 : void SetComponentManager(CComponentManager* man); 41 : 42 : bool HasUnitManager() const; 43 : CUnitManager& GetUnitManager() const; 44 : 45 : CTerrain& GetTerrain() const; 46 : 47 : Script::Interface& GetScriptInterface() const; 48 : 49 67 : void SetSystemEntity(CEntityHandle ent) { m_SystemEntity = ent; } 50 150148 : CEntityHandle GetSystemEntity() const { ASSERT(m_SystemEntity.GetId() == SYSTEM_ENTITY); return m_SystemEntity; } 51 : 52 : /** 53 : * Returns the player ID that the current display is being rendered for. 54 : * Currently relies on g_Game being initialised (evil globals...) 55 : */ 56 : int GetCurrentDisplayedPlayer() const; 57 : 58 : private: 59 : CComponentManager* m_ComponentManager{nullptr}; 60 : CUnitManager* m_UnitManager; 61 : CTerrain* m_Terrain; 62 : 63 : CEntityHandle m_SystemEntity; 64 : }; 65 : 66 : #endif // INCLUDED_SIMCONTEXT