 |
Cytopia
0.3
A city building simulation game
|
Go to the documentation of this file.
2 #include "../engine/basics/PointFunctions.hxx"
3 #include "../services/Randomizer.hxx"
4 #include "../engine/TileManager.hxx"
12 mainZone.
xmin = std::min(mainZone.
xmin, toBeMerged.
xmin);
13 mainZone.
xmax = std::max(mainZone.
xmax, toBeMerged.
xmax);
14 mainZone.
ymin = std::min(mainZone.
ymin, toBeMerged.
ymin);
15 mainZone.
ymax = std::max(mainZone.
ymax, toBeMerged.
ymax);
19 :
MapGrid{zoneNode}, m_zoneType(zoneNode.zoneType), m_zoneDensity(zoneNode.zoneDensity),
20 xmin(std::max(0, zoneNode.coordinate.x - 1)), xmax(std::min(
Settings::instance().mapSize, zoneNode.coordinate.x + 1)),
21 ymin(std::max(0, zoneNode.coordinate.y - 1)), ymax(std::min(
Settings::instance().mapSize, zoneNode.coordinate.y + 1))
24 m_isVacant = checkVacancy();
29 constexpr
int amountOfBuildingsToSpawn = 5;
34 int buildingsSpawned = 0;
39 if (buildingsSpawned >= amountOfBuildingsToSpawn)
69 for (
int distance = 1; distance <= possibleSize.
width || distance <= possibleSize.
height; distance++)
74 bool increaseX =
true;
75 bool increaseY =
true;
77 for (
auto coord : xDirection)
85 for (
auto coord : yDirection)
146 node->occupied =
false;
150 node->occupied =
true;
void removeZoneNode(Point coordinate)
Remove a zoneNode on a given coordinate from this zoneArea.
void mergeZoneAreas(ZoneArea &mainZone, ZoneArea &toBeMerged)
bool checkVacancy() const
internal function to check for vacancy
How many tiles are occupied by a building.
static std::vector< Point > getArea(const Point &isoCoordinatesStart, const Point &isoCoordinatesEnd)
Gets all nodes in a rectangular area between start and end point.
bool isMemberOf(Point coordinate) const
If this coordinate is part of the grid.
std::optional< std::string > getRandomTileIDForZoneWithRandomSize(ZoneType zone, ZoneDensity zoneDensity, TileSize maxTileSize={1, 1})
Pick a single random tileID for a zone with a random tilesize within the supplied max Size.
void spawnBuildings()
Spawn buildings on nodes in this area if all demands are fulfilled.
std::vector< T > m_gridNodes
void setVacancy(Point coordinate, bool vacancy)
Set vacancy for this tile.
ZoneDensity m_zoneDensity
static Settings & instance(void)
Get an instance of the singleton.
bool setTileID(const std::string &tileID, Point coordinate)
Set the Tile ID Of Node object.
ZoneArea(ZoneNode zoneNode)
void addNode(ZoneNode zoneNode) override
Add a zoneNode to this zoneArea.
TileSize getMaximumTileSize(Point originPoint)
Returns the possible size of buildings that can be placed on this coordinate in a zone.