 |
Cytopia
0.3
A city building simulation game
|
#include <ZoneManager.hxx>
Definition at line 8 of file ZoneManager.hxx.
◆ ZoneManager()
ZoneManager::ZoneManager |
( |
| ) |
|
◆ addZoneNodeToArea()
void ZoneManager::addZoneNodeToArea |
( |
ZoneNode & |
zoneNode, |
|
|
std::vector< ZoneArea > & |
zoneAreas |
|
) |
| |
|
private |
Adds a zoneNode to a given area.
- Parameters
-
zoneNode | node to add |
zoneAreas | all zoneAreas |
Definition at line 124 of file ZoneManager.cxx.
128 if (zoneNeighbour.empty())
131 zoneAreas.emplace_back(zoneNode);
133 else if (zoneNeighbour.size() == 1)
136 zoneAreas[zoneNeighbour[0]].addNode(zoneNode);
141 ZoneArea &mergedZone = zoneAreas[zoneNeighbour[0]];
144 for (
int idx = 1; idx < zoneNeighbour.size(); ++idx)
149 for (
int idx = zoneNeighbour.size() - 1; idx > 0; --idx)
151 zoneAreas.erase(zoneAreas.begin() + zoneNeighbour[idx]);
◆ getAdjacentZoneAreas()
std::vector< int > ZoneManager::getAdjacentZoneAreas |
( |
const ZoneNode & |
zoneNode, |
|
|
std::vector< ZoneArea > & |
zoneAreas |
|
) |
| |
|
private |
get a list of neighboring zoneareas for a zoneNode
- Parameters
-
zoneNode | the zoneNode we need neighboring areas for |
zoneAreas | a vector of areas that apply |
- Returns
- a list of neighboring zoneareas for a zoneNode
Definition at line 106 of file ZoneManager.cxx.
108 std::vector<int> neighborZones;
111 for (
auto &zoneArea : zoneAreas)
113 if (zoneArea.getZone() == zoneNode.
zoneType && (zoneArea.getZoneDensity() == zoneNode.
zoneDensity) &&
116 neighborZones.push_back(i);
121 return neighborZones;
◆ rebuildZoneArea()
rebuild a certain zone area
- Parameters
-
zoneArea | the area to rebuild |
- Returns
- rebuilt zone area
Definition at line 156 of file ZoneManager.cxx.
158 std::vector<ZoneArea> newZoneAreas;
◆ removeZoneNode()
void ZoneManager::removeZoneNode |
( |
Point |
coordinate | ) |
|
|
private |
Removes a zonenode.
- Parameters
-
coordinate | coordinate of the zone to remove |
Definition at line 168 of file ZoneManager.cxx.
172 if (zoneIt->isMemberOf(coordinate))
174 zoneIt->removeZoneNode(coordinate);
176 if (zoneIt->size() == 0)
183 assert(zoneAreas.size() > 0);
186 if (zoneAreas.size() > 1)
◆ reset()
void ZoneManager::reset |
( |
| ) |
|
◆ spawnBuildings()
void ZoneManager::spawnBuildings |
( |
| ) |
|
|
private |
Spawn Buildings on the gathered tileMap.
Definition at line 83 of file ZoneManager.cxx.
88 if (zoneArea.isVacant() && zoneArea.hasPowerSupply())
92 for (
auto node : zoneArea)
101 zoneArea.spawnBuildings();
◆ update()
void ZoneManager::update |
( |
| ) |
|
|
private |
Process previously cached nodes to update.
Definition at line 26 of file ZoneManager.cxx.
35 if (zoneArea.isMemberOf(nodeToVacate))
37 zoneArea.setVacancy(nodeToVacate,
true);
52 if (zoneArea.isMemberOf(nodeToOccupy))
54 zoneArea.setVacancy(nodeToOccupy,
false);
◆ updatePlacedNodes()
void ZoneManager::updatePlacedNodes |
( |
const MapNode & |
mapNode | ) |
|
|
private |
◆ updatePower()
void ZoneManager::updatePower |
( |
const std::vector< PowerGrid > & |
powerGrid | ) |
|
|
private |
Definition at line 198 of file ZoneManager.cxx.
200 for (
const auto &grid : powerGrid)
204 if (
bool isGridConnected =
206 std::find_if(area.begin(), area.end(), [grid](
const ZoneNode &node) { return grid.isNeighbor(node.coordinate); });
209 if (grid.getPowerLevel() > 0)
211 area.setPowerSupply(
true);
215 area.setPowerSupply(
false);
◆ updateRemovedNodes()
void ZoneManager::updateRemovedNodes |
( |
const MapNode * |
mapNode | ) |
|
|
private |
◆ m_nodesToAdd
std::vector<ZoneNode> ZoneManager::m_nodesToAdd |
|
private |
◆ m_nodesToOccupy
std::vector<Point> ZoneManager::m_nodesToOccupy |
|
private |
◆ m_nodesToRemove
std::vector<Point> ZoneManager::m_nodesToRemove |
|
private |
◆ m_nodesToVacate
std::vector<Point> ZoneManager::m_nodesToVacate |
|
private |
◆ m_zoneAreas
std::vector<ZoneArea> ZoneManager::m_zoneAreas |
|
private |
The documentation for this class was generated from the following files:
void updatePlacedNodes(const MapNode &mapNode)
@ DE_ZONE
Remove only zones.
std::vector< ZoneArea > m_zoneAreas
void spawnBuildings()
Spawn Buildings on the gathered tileMap.
void updatePower(const std::vector< PowerGrid > &powerGrid)
std::vector< Point > m_nodesToVacate
All zoneAreas.
void mergeZoneAreas(ZoneArea &mainZone, ZoneArea &toBeMerged)
void removeZoneNode(Point coordinate)
Removes a zonenode.
const Point & getCoordinates() const
get iso coordinates of this node
void update()
Process previously cached nodes to update.
const TileData * getTileData(Layer layer) const
@ ZONE
4- Optional layer, zones(Industrial/Residential/Commercial).
@ BUILDINGS
8- Buildings, Streets and everything that goes on the terrain
void addZoneNodeToArea(ZoneNode &zoneNode, std::vector< ZoneArea > &zoneAreas)
Adds a zoneNode to a given area.
std::vector< Point > m_nodesToRemove
All zoneAreas.
void updateRemovedNodes(const MapNode *mapNode)
std::vector< ZoneType > zoneTypes
Restrict this building to a zone type.
@ DEFAULT
Demolish everything, but not.
std::vector< ZoneNode > m_nodesToAdd
All zoneAreas.
std::vector< ZoneArea > rebuildZoneArea(ZoneArea &zoneArea)
rebuild a certain zone area
std::function< R(Args...)> slot(instance &object, R(Class::*method)(Args...))
This function creates a std::function by binding object to the member function pointer method.
std::vector< ZoneDensity > zoneDensity
Restrict this building to a certain zone density. See enum ZoneDensity.
static SignalMediator & instance(void)
Get an instance of the singleton.
std::vector< int > getAdjacentZoneAreas(const ZoneNode &zoneNode, std::vector< ZoneArea > &zoneAreas)
get a list of neighboring zoneareas for a zoneNode
GameClock::ClockTaskHndl addRealTimeClockTask(ClockCbk cbk, DelayType delay, PeriodType period=TimePointZero)
Add new real time clock task.
void addNode(ZoneNode zoneNode) override
Add a zoneNode to this zoneArea.
std::vector< Point > m_nodesToOccupy
All zoneAreas.