Pyrogenesis  trunk
World.h
Go to the documentation of this file.
1 /* Copyright (C) 2013 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/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 CTerritoryManager;
40 class CTerrain;
41 class CStrW;
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  /**
65  * pointer to the CTerritoryManager that holds territory matrix for the world.
66  **/
67  CTerritoryManager *m_TerritoryManager;
68 
69 public:
70  CWorld(CGame *pGame);
71  ~CWorld();
72 
73  /*
74  Initialize the World - load the map and all objects
75  */
76  void RegisterInit(const CStrW& mapFile, JSRuntime* rt, JS::HandleValue settings, int playerID);
77 
78  /*
79  Initialize the World - generate and load the random map
80  */
81  void RegisterInitRMS(const CStrW& scriptFile, JSRuntime* rt, JS::HandleValue settings, int playerID);
82 
83  /**
84  * Get the pointer to the terrain object.
85  *
86  * @return CTerrain * the value of m_Terrain.
87  **/
88  inline CTerrain *GetTerrain()
89  { return m_Terrain; }
90 
91  /**
92  * Get a reference to the unit manager object.
93  *
94  * @return CUnitManager & dereferenced m_UnitManager.
95  **/
97  { return *m_UnitManager; }
98  /**
99  * Get the pointer to the territory manager object.
100  *
101  * @return CTerritoryManager * the value of m_TerritoryManager.
102  **/
103  inline CTerritoryManager *GetTerritoryManager()
104  { return m_TerritoryManager; }
105 };
106 
107 // rationale: see definition.
108 class CLightEnv;
109 extern CLightEnv g_LightEnv;
110 
111 #endif
The container that holds the rules, resources and attributes of the game.
Definition: Game.h:40
CLightEnv g_LightEnv
File : World.cpp Project : engine Description : Contains the CWorld Class implementation.
Definition: World.cpp:49
void RegisterInitRMS(const CStrW &scriptFile, JSRuntime *rt, JS::HandleValue settings, int playerID)
Definition: World.cpp:98
CUnitManager & GetUnitManager()
Get a reference to the unit manager object.
Definition: World.h:96
CTerritoryManager * GetTerritoryManager()
Get the pointer to the territory manager object.
Definition: World.h:103
Definition: Terrain.h:51
ERROR_TYPE(Game_World, MapLoadFailed)
ERROR_GROUP(Game)
~CWorld()
Destructor.
Definition: World.cpp:120
ERROR_SUBGROUP(Game, World)
CTerrain * GetTerrain()
Get the pointer to the terrain object.
Definition: World.h:88
CWorld is a general data class containing whatever is needed to accurately represent the world...
Definition: World.h:47
Definition: UnitManager.h:36
CWorld(CGame *pGame)
Constructor.
Definition: World.cpp:57
Class CLightEnv: description of a lighting environment - contains all the necessary parameters for re...
Definition: LightEnv.h:36
CTerritoryManager * m_TerritoryManager
pointer to the CTerritoryManager that holds territory matrix for the world.
Definition: World.h:67
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
void RegisterInit(const CStrW &mapFile, JSRuntime *rt, JS::HandleValue settings, int playerID)
Initializes the game world with the attributes provided.
Definition: World.cpp:68
CGame * m_pGame
pointer to the CGame object representing the game.
Definition: World.h:53