Pyrogenesis trunk
UnitManager.h
Go to the documentation of this file.
1/* Copyright (C) 2023 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 * Container that owns all units
20 */
21
22#ifndef INCLUDED_UNITMANAGER
23#define INCLUDED_UNITMANAGER
24
25#include "ps/CStrForward.h"
27
28#include <memory>
29#include <set>
30#include <vector>
31
32class CUnit;
33class CObjectManager;
34
35///////////////////////////////////////////////////////////////////////////////
36// CUnitManager: simple container class holding all units within the world
38{
39public:
40 // constructor, destructor
43
44 // add given unit to world
45 CUnit* AddUnit(std::unique_ptr<CUnit> unit);
46 // remove given unit from world and delete it
47 void DeleteUnit(CUnit* unit);
48
49 // creates a new unit and adds it to the world
50 CUnit* CreateUnit(const CStrW& actorName, const entity_id_t id, const uint32_t seed);
51
52 void SetObjectManager(CObjectManager& objectManager) { m_ObjectManager = &objectManager; }
53
54 /**
55 * Mark a specific region of the terrain as dirty.
56 * Coordinates are in terrain tiles, lower inclusive, upper exclusive.
57 */
58 void MakeTerrainDirty(ssize_t i0, ssize_t j0, ssize_t i1, ssize_t j1, int dirtyFlags);
59
60private:
61 // list of all known units
62 std::vector<std::unique_ptr<CUnit>> m_Units;
63 // graphical object manager; may be NULL if not set up
65};
66
67#endif // INCLUDED_UNITMANAGER
Definition: ObjectManager.h:42
Definition: UnitManager.h:38
CUnitManager()
Definition: UnitManager.cpp:32
void DeleteUnit(CUnit *unit)
Definition: UnitManager.cpp:52
CObjectManager * m_ObjectManager
Definition: UnitManager.h:64
CUnit * CreateUnit(const CStrW &actorName, const entity_id_t id, const uint32_t seed)
Definition: UnitManager.cpp:65
CUnit * AddUnit(std::unique_ptr< CUnit > unit)
Definition: UnitManager.cpp:44
std::vector< std::unique_ptr< CUnit > > m_Units
Definition: UnitManager.h:62
void MakeTerrainDirty(ssize_t i0, ssize_t j0, ssize_t i1, ssize_t j1, int dirtyFlags)
Mark a specific region of the terrain as dirty.
Definition: UnitManager.cpp:77
void SetObjectManager(CObjectManager &objectManager)
Definition: UnitManager.h:52
Definition: Unit.h:38
u32 entity_id_t
Entity ID type.
Definition: Entity.h:29
unsigned int uint32_t
Definition: wposix_types.h:53
intptr_t ssize_t
Definition: wposix_types.h:82