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