Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
SimContext.h
Go to the documentation of this file.
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"
23
25class CUnitManager;
26class CTerrain;
27namespace 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 */
34{
35public:
36 CSimContext(CTerrain* terrain = nullptr, CUnitManager* unitManager = nullptr);
38
41
42 bool HasUnitManager() const;
44
45 CTerrain& GetTerrain() const;
46
48
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
58private:
62
64};
65
66#endif // INCLUDED_SIMCONTEXT
Definition: ComponentManager.h:46
Object wrapping an entity_id_t, with a SEntityComponentCache to support fast QueryInterface() / CmpPt...
Definition: Entity.h:80
entity_id_t GetId() const
Definition: Entity.h:88
Contains pointers to various 'global' objects that are needed by the simulation code,...
Definition: SimContext.h:34
~CSimContext()
Definition: SimContext.cpp:33
void SetComponentManager(CComponentManager *man)
Definition: SimContext.cpp:59
CTerrain & GetTerrain() const
Definition: SimContext.cpp:53
CEntityHandle m_SystemEntity
Definition: SimContext.h:63
CTerrain * m_Terrain
Definition: SimContext.h:61
CSimContext(CTerrain *terrain=nullptr, CUnitManager *unitManager=nullptr)
Definition: SimContext.cpp:27
void SetSystemEntity(CEntityHandle ent)
Definition: SimContext.h:49
CComponentManager & GetComponentManager() const
Definition: SimContext.cpp:37
CUnitManager & GetUnitManager() const
Definition: SimContext.cpp:47
bool HasUnitManager() const
Definition: SimContext.cpp:42
CComponentManager * m_ComponentManager
Definition: SimContext.h:59
CUnitManager * m_UnitManager
Definition: SimContext.h:60
CEntityHandle GetSystemEntity() const
Definition: SimContext.h:50
Script::Interface & GetScriptInterface() const
Definition: SimContext.cpp:65
int GetCurrentDisplayedPlayer() const
Returns the player ID that the current display is being rendered for.
Definition: SimContext.cpp:70
Definition: Terrain.h:52
Definition: UnitManager.h:39
Definition: Interface.h:93
#define ASSERT(expr)
same as ENSURE in debug mode, does nothing in release mode.
Definition: debug.h:250
Abstraction around a SpiderMonkey JSContext.
Definition: DapInterface.h:32
const entity_id_t SYSTEM_ENTITY
Entity ID for singleton 'system' components.
Definition: Entity.h:43