Pyrogenesis  trunk
UnitManager.h
Go to the documentation of this file.
1 /* Copyright (C) 2022 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"
26 
27 #include <vector>
28 #include <set>
29 
30 class CUnit;
31 class CObjectManager;
32 
33 ///////////////////////////////////////////////////////////////////////////////
34 // CUnitManager: simple container class holding all units within the world
36 {
37 public:
38  // constructor, destructor
39  CUnitManager();
40  ~CUnitManager();
41 
42  // add given unit to world
43  void AddUnit(CUnit* unit);
44  // remove given unit from world, but don't delete it
45  void RemoveUnit(CUnit* unit);
46  // remove given unit from world and delete it
47  void DeleteUnit(CUnit* unit);
48  // remove and delete all units
49  void DeleteAll();
50 
51  // creates a new unit and adds it to the world
52  CUnit* CreateUnit(const CStrW& actorName, uint32_t seed);
53 
54  // return the units
55  const std::vector<CUnit*>& GetUnits() const { return m_Units; }
56 
57  void SetObjectManager(CObjectManager& objectManager) { m_ObjectManager = &objectManager; }
58 
59  /**
60  * Mark a specific region of the terrain as dirty.
61  * Coordinates are in terrain tiles, lower inclusive, upper exclusive.
62  */
63  void MakeTerrainDirty(ssize_t i0, ssize_t j0, ssize_t i1, ssize_t j1, int dirtyFlags);
64 
65 private:
66  // list of all known units
67  std::vector<CUnit*> m_Units;
68  // graphical object manager; may be NULL if not set up
70 };
71 
72 #endif
const std::vector< CUnit * > & GetUnits() const
Definition: UnitManager.h:55
CUnitManager()
Definition: UnitManager.cpp:38
void DeleteUnit(CUnit *unit)
Definition: UnitManager.cpp:72
CObjectManager * m_ObjectManager
Definition: UnitManager.h:69
Definition: ObjectManager.h:41
void SetObjectManager(CObjectManager &objectManager)
Definition: UnitManager.h:57
void RemoveUnit(CUnit *unit)
Definition: UnitManager.cpp:60
Definition: Unit.h:36
std::vector< CUnit * > m_Units
Definition: UnitManager.h:67
void AddUnit(CUnit *unit)
Definition: UnitManager.cpp:53
~CUnitManager()
Definition: UnitManager.cpp:45
Definition: UnitManager.h:35
void DeleteAll()
Definition: UnitManager.cpp:80
intptr_t ssize_t
Definition: wposix_types.h:82
CUnit * CreateUnit(const CStrW &actorName, uint32_t seed)
Definition: UnitManager.cpp:90
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:101
unsigned int uint32_t
Definition: wposix_types.h:53