Pyrogenesis  trunk
World.h
Go to the documentation of this file.
1 /* Copyright (C) 2021 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 /**
19  * File : World.h
20  * Project : engine
21  * Description : Contains the CWorld Class which contains all the entities and represents them at a specific moment in time.
22  *
23  **/
24 #ifndef INCLUDED_WORLD
25 #define INCLUDED_WORLD
26 
27 #include "ps/CStrForward.h"
28 #include "ps/Errors.h"
29 
30 #ifndef ERROR_GROUP_GAME_DEFINED
31 #define ERROR_GROUP_GAME_DEFINED
32 ERROR_GROUP(Game);
33 #endif
34 ERROR_SUBGROUP(Game, World);
35 ERROR_TYPE(Game_World, MapLoadFailed);
36 
37 class CGame;
38 class CUnitManager;
39 class CTerrain;
40 class CMapReader;
41 class ScriptContext;
42 
43 /**
44  * CWorld is a general data class containing whatever is needed to accurately represent the world.
45  * This includes the map, entities, influence maps, tiles, heightmap, etc.
46  **/
47 class CWorld
48 {
50  /**
51  * pointer to the CGame object representing the game.
52  **/
54 
55  /**
56  * pointer to the CTerrain object representing the height map.
57  **/
59 
60  /**
61  * pointer to the CUnitManager that holds all the units in the world.
62  **/
64 
66 
67 public:
68  CWorld(CGame *pGame);
69  ~CWorld();
70 
71  /*
72  Initialize the World - load the map and all objects
73  */
74  void RegisterInit(const CStrW& mapFile, const ScriptContext& cx, JS::HandleValue settings, int playerID);
75 
76  /*
77  Initialize the World - generate and load the random map
78  */
79  void RegisterInitRMS(const CStrW& scriptFile, const ScriptContext& cx, JS::HandleValue settings, int playerID);
80 
81  /**
82  * Explicitly delete m_MapReader once the map has finished loading.
83  **/
84  int DeleteMapReader();
85 
86  /**
87  * Get the pointer to the terrain object.
88  *
89  * @return CTerrain * the value of m_Terrain.
90  **/
91  inline CTerrain *GetTerrain()
92  { return m_Terrain; }
93 
94  /**
95  * Get a reference to the unit manager object.
96  *
97  * @return CUnitManager & dereferenced m_UnitManager.
98  **/
100  { return *m_UnitManager; }
101 };
102 
103 // rationale: see definition.
104 class CLightEnv;
105 extern CLightEnv g_LightEnv;
106 
107 #endif
The container that holds the rules, resources and attributes of the game.
Definition: Game.h:42
CLightEnv g_LightEnv
Global light settings.
Definition: World.cpp:44
CUnitManager & GetUnitManager()
Get a reference to the unit manager object.
Definition: World.h:99
Definition: Terrain.h:51
ERROR_TYPE(Game_World, MapLoadFailed)
ERROR_GROUP(Game)
Abstraction around a SpiderMonkey JSContext.
Definition: ScriptContext.h:40
~CWorld()
Destructor.
Definition: World.cpp:117
ERROR_SUBGROUP(Game, World)
CTerrain * GetTerrain()
Get the pointer to the terrain object.
Definition: World.h:91
Definition: MapReader.h:45
CWorld is a general data class containing whatever is needed to accurately represent the world...
Definition: World.h:47
void RegisterInit(const CStrW &mapFile, const ScriptContext &cx, JS::HandleValue settings, int playerID)
Initializes the game world with the attributes provided.
Definition: World.cpp:63
Definition: UnitManager.h:35
int DeleteMapReader()
Explicitly delete m_MapReader once the map has finished loading.
Definition: World.cpp:107
CMapReader * m_MapReader
Definition: World.h:65
void RegisterInitRMS(const CStrW &scriptFile, const ScriptContext &cx, JS::HandleValue settings, int playerID)
Definition: World.cpp:92
CWorld(CGame *pGame)
Constructor.
Definition: World.cpp:52
Class CLightEnv: description of a lighting environment - contains all the necessary parameters for re...
Definition: LightEnv.h:36
CTerrain * m_Terrain
pointer to the CTerrain object representing the height map.
Definition: World.h:58
NONCOPYABLE(CWorld)
CUnitManager * m_UnitManager
pointer to the CUnitManager that holds all the units in the world.
Definition: World.h:63
CGame * m_pGame
pointer to the CGame object representing the game.
Definition: World.h:53