[Gameplay] Reduce loom cost
[0ad.git] / source / graphics / UnitManager.h
blobeed884aebe7fb7b93cfcbf30b594c92a38689767
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/>.
19 * Container that owns all units
22 #ifndef INCLUDED_UNITMANAGER
23 #define INCLUDED_UNITMANAGER
25 #include "ps/CStrForward.h"
26 #include "simulation2/system/Entity.h"
28 #include <vector>
29 #include <set>
31 class CUnit;
32 class CObjectManager;
34 ///////////////////////////////////////////////////////////////////////////////
35 // CUnitManager: simple container class holding all units within the world
36 class CUnitManager
38 public:
39 // constructor, destructor
40 CUnitManager();
41 ~CUnitManager();
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();
52 // creates a new unit and adds it to the world
53 CUnit* CreateUnit(const CStrW& actorName, const entity_id_t id, const uint32_t seed);
55 // return the units
56 const std::vector<CUnit*>& GetUnits() const { return m_Units; }
58 void SetObjectManager(CObjectManager& objectManager) { m_ObjectManager = &objectManager; }
60 /**
61 * Mark a specific region of the terrain as dirty.
62 * Coordinates are in terrain tiles, lower inclusive, upper exclusive.
64 void MakeTerrainDirty(ssize_t i0, ssize_t j0, ssize_t i1, ssize_t j1, int dirtyFlags);
66 private:
67 // list of all known units
68 std::vector<CUnit*> m_Units;
69 // graphical object manager; may be NULL if not set up
70 CObjectManager* m_ObjectManager;
73 #endif // INCLUDED_UNITMANAGER