1 /* Copyright (C) 2023 Wildfire Games.
2 * This file is part of 0 A.D.
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.
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.
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/>.
21 * Description : Contains the CWorld Class which contains all the entities and represents them at a specific moment in time.
24 #ifndef INCLUDED_WORLD
25 #define INCLUDED_WORLD
27 #include "ps/CStrForward.h"
28 #include "ps/Errors.h"
32 #ifndef ERROR_GROUP_GAME_DEFINED
33 #define ERROR_GROUP_GAME_DEFINED
36 ERROR_SUBGROUP(Game
, World
);
37 ERROR_TYPE(Game_World
, MapLoadFailed
);
46 * CWorld is a general data class containing whatever is needed to accurately represent the world.
47 * This includes the map, entities, influence maps, tiles, heightmap, etc.
56 Initialize the World - load the map and all objects
58 void RegisterInit(const CStrW
& mapFile
, const ScriptContext
& cx
, JS::HandleValue settings
, int playerID
);
61 Initialize the World - generate and load the random map
63 void RegisterInitRMS(const CStrW
& scriptFile
, const ScriptContext
& cx
, JS::HandleValue settings
, int playerID
);
66 * Explicitly delete m_MapReader once the map has finished loading.
68 int DeleteMapReader();
71 * Get a reference to the terrain object.
73 * @return CTerrain& dereferenced m_Terrain.
75 CTerrain
& GetTerrain()
81 * Get a reference to the unit manager object.
83 * @return CUnitManager& dereferenced m_UnitManager.
85 CUnitManager
& GetUnitManager()
87 return *m_UnitManager
;
92 * Reference to the CGame object representing the game.
97 * The CTerrain object represents the height map.
99 const std::unique_ptr
<CTerrain
> m_Terrain
;
102 * The CUnitManager that holds all the units in the world.
104 const std::unique_ptr
<CUnitManager
> m_UnitManager
;
107 * The map reader gets deleted just after the map is read.
109 std::unique_ptr
<CMapReader
> m_MapReader
;
112 // rationale: see definition.
114 extern CLightEnv g_LightEnv
;