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