 |
Cytopia
0.3
A city building simulation game
|
Go to the documentation of this file.
2 #include "../services/GameClock.hxx"
56 std::vector<int> neighborGrids;
59 for (
auto &powerGrid : powerGrids)
61 if (powerGrid.isNeighbor(powerNode.
coordinate))
63 neighborGrids.push_back(i);
75 if (gridNeighbour.empty())
77 powerGrids.emplace_back(powerNode);
79 else if (gridNeighbour.size() == 1)
81 powerGrids[gridNeighbour[0]].addNode(powerNode);
85 PowerGrid &mergedGrid = powerGrids[gridNeighbour[0]];
88 for (
int idx = 1; idx < gridNeighbour.size(); ++idx)
93 for (
int idx = gridNeighbour.size() - 1; idx > 0; --idx)
95 powerGrids.erase(powerGrids.begin() + gridNeighbour[idx]);
104 if (gridIt->isMemberOf(coordinate))
106 gridIt->removeNode(coordinate);
108 if (gridIt->size() == 0)
115 assert(powerGrids.size() > 0);
118 if (powerGrids.size() > 1)
132 std::vector<PowerGrid> newPowerGrids;
139 return newPowerGrids;
148 int powerLevelOfTile = 0;
179 powerGrid.updatePowerLevel();
188 if (mapNode.isConductive())
195 PowerNode powerNode = {mapNode.getCoordinates(), power};
std::vector< int > getAdjacentPowerGrids(const PowerNode &powerNode, std::vector< PowerGrid > &powerGrids)
virtual void addNode(T node)
Add a T node to this gridnode.
std::vector< PowerGrid > rebuildZoneArea(PowerGrid &powerGrid)
const Point & getCoordinates() const
get iso coordinates of this node
void updatePowerLevels()
Updates all PowerGrid's power levels.
const bool isConductive() const
check the conductivity of the node
void addPowerNodeToGrid(PowerNode &powerNode, std::vector< PowerGrid > &powerGrids)
const TileData * getTileData(Layer layer) const
void updatePlacedNodes(const MapNode &mapNode)
Class that holds map nodes.
@ BUILDINGS
8- Buildings, Streets and everything that goes on the terrain
int power
power production / consumption if negative
std::vector< Point > m_nodesToRemove
@ DEFAULT
Demolish everything, but not.
std::vector< PowerNode > m_nodesToAdd
void mergePowerGrids(PowerGrid &mainGrid, PowerGrid &toBeMerged)
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.
void updateRemovedNodes(const MapNode *mapNode)
static SignalMediator & instance(void)
Get an instance of the singleton.
GameClock::ClockTaskHndl addRealTimeClockTask(ClockCbk cbk, DelayType delay, PeriodType period=TimePointZero)
Add new real time clock task.
std::vector< PowerGrid > m_powerGrids
void removePowerNode(Point coordinate)