Pyrogenesis  trunk
SimContext.h
Go to the documentation of this file.
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  */
33 {
34 public:
35  CSimContext();
36  ~CSimContext();
37 
40 
41  bool HasUnitManager() const;
43 
44  CTerrain& GetTerrain() const;
45 
47 
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:
61 
63 
64  friend class CSimulation2Impl;
65 };
66 
67 #endif // INCLUDED_SIMCONTEXT
CTerrain & GetTerrain() const
Definition: SimContext.cpp:51
CSimContext()
Definition: SimContext.cpp:26
CUnitManager & GetUnitManager() const
Definition: SimContext.cpp:45
CComponentManager & GetComponentManager() const
Definition: SimContext.cpp:35
CComponentManager * m_ComponentManager
Definition: SimContext.h:58
CTerrain * m_Terrain
Definition: SimContext.h:60
int GetCurrentDisplayedPlayer() const
Returns the player ID that the current display is being rendered for.
Definition: SimContext.cpp:68
Object wrapping an entity_id_t, with a SEntityComponentCache to support fast QueryInterface() / CmpPt...
Definition: Entity.h:79
~CSimContext()
Definition: SimContext.cpp:31
Definition: Terrain.h:51
#define ASSERT(expr)
same as ENSURE in debug mode, does nothing in release mode.
Definition: debug.h:318
Contains pointers to various &#39;global&#39; objects that are needed by the simulation code, to allow easy access without using real (evil) global variables.
Definition: SimContext.h:32
const entity_id_t SYSTEM_ENTITY
Entity ID for singleton &#39;system&#39; components.
Definition: Entity.h:43
ScriptInterface & GetScriptInterface() const
Definition: SimContext.cpp:63
Definition: Simulation2.cpp:54
Definition: ComponentManager.h:39
Definition: UnitManager.h:35
CEntityHandle GetSystemEntity() const
Definition: SimContext.h:49
CEntityHandle m_SystemEntity
Definition: SimContext.h:62
bool HasUnitManager() const
Definition: SimContext.cpp:40
void SetSystemEntity(CEntityHandle ent)
Definition: SimContext.h:48
entity_id_t GetId() const
Definition: Entity.h:88
Abstraction around a SpiderMonkey JS::Realm.
Definition: ScriptInterface.h:71
void SetComponentManager(CComponentManager *man)
Definition: SimContext.cpp:57
CUnitManager * m_UnitManager
Definition: SimContext.h:59