Cytopia  0.3
A city building simulation game
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ZoneArea.hxx
Go to the documentation of this file.
1 #ifndef ZONE_AREA_HXX_
2 #define ZONE_AREA_HXX_
3 
4 #include "../engine/basics/Point.hxx"
5 #include "../engine/basics/tileData.hxx"
6 #include "../engine/GameObjects/MapGrid.hxx"
7 
8 struct ZoneNode
9 {
11  ZoneType zoneType;
12  ZoneDensity zoneDensity;
13  bool occupied = false;
14 };
15 
16 class ZoneArea;
17 void mergeZoneAreas(ZoneArea &mainZone, ZoneArea &toBeMerged);
18 
19 class ZoneArea : public MapGrid<ZoneNode>
20 {
21 public:
22  ZoneArea(ZoneNode zoneNode);
23 
29  void addNode(ZoneNode zoneNode) override;
30 
36  void removeZoneNode(Point coordinate);
37 
43  void setPowerSupply(bool hasPower) { m_hasPower = hasPower; };
44 
50  bool hasPowerSupply() { return m_hasPower; };
51 
57  void setWaterSupply(bool hasWater) { m_hasWater = hasWater; };
58 
64  bool hasWaterSupply() { return m_hasWater; };
65 
71  ZoneType getZone() const { return m_zoneType; };
72 
78  ZoneDensity getZoneDensity() { return m_zoneDensity; };
79 
85  bool isVacant() const { return m_isVacant; };
86 
90  void spawnBuildings();
91 
98  bool isWithinBoundaries(Point coordinate) const
99  {
100  return (xmin <= coordinate.x) && (xmax >= coordinate.x) && (ymin <= coordinate.y) && (ymax >= coordinate.y);
101  }
102 
109  void setVacancy(Point coordinate, bool vacancy);
110 
111 private:
112  ZoneType m_zoneType;
113  ZoneDensity m_zoneDensity;
114 
115  bool m_hasPower = false;
116  bool m_hasWater = false;
117  bool m_isVacant = false;
118  int xmin, xmax, ymin, ymax;
119 
121  bool checkVacancy() const;
122 
123  friend void mergeZoneAreas(ZoneArea &mainZone, ZoneArea &toBeMerged);
124 
131  TileSize getMaximumTileSize(Point originPoint);
132 };
133 
134 #endif
ZoneArea::removeZoneNode
void removeZoneNode(Point coordinate)
Remove a zoneNode on a given coordinate from this zoneArea.
Definition: ZoneArea.cxx:131
ZoneArea::isVacant
bool isVacant() const
If this area has unoccupied nodes left.
Definition: ZoneArea.hxx:85
ZoneArea
Definition: ZoneArea.hxx:19
ZoneArea::checkVacancy
bool checkVacancy() const
internal function to check for vacancy
Definition: ZoneArea.cxx:59
ZoneArea::isWithinBoundaries
bool isWithinBoundaries(Point coordinate) const
Check if a given point is within the boundaries of this zone area.
Definition: ZoneArea.hxx:98
TileSize
How many tiles are occupied by a building.
Definition: tileData.hxx:86
ZoneArea::hasPowerSupply
bool hasPowerSupply()
Get the Power supply for this Area.
Definition: ZoneArea.hxx:50
ZoneNode::zoneType
ZoneType zoneType
Definition: ZoneArea.hxx:11
Point::y
int y
The y coordinate.
Definition: Point.hxx:20
ZoneArea::ymin
int ymin
Definition: ZoneArea.hxx:118
Point::x
int x
The x coordinate.
Definition: Point.hxx:14
ZoneArea::ymax
int ymax
Definition: ZoneArea.hxx:118
ZoneArea::xmax
int xmax
Definition: ZoneArea.hxx:118
ZoneArea::mergeZoneAreas
friend void mergeZoneAreas(ZoneArea &mainZone, ZoneArea &toBeMerged)
Definition: ZoneArea.cxx:7
ZoneArea::xmin
int xmin
Definition: ZoneArea.hxx:118
ZoneArea::spawnBuildings
void spawnBuildings()
Spawn buildings on nodes in this area if all demands are fulfilled.
Definition: ZoneArea.cxx:27
Point::INVALID
static constexpr Point INVALID()
Definition: Point.hxx:35
ZoneArea::getZoneDensity
ZoneDensity getZoneDensity()
Get the zone density for this Area.
Definition: ZoneArea.hxx:78
ZoneNode::occupied
bool occupied
Definition: ZoneArea.hxx:13
ZoneNode::zoneDensity
ZoneDensity zoneDensity
Definition: ZoneArea.hxx:12
ZoneNode::coordinate
Point coordinate
Definition: ZoneArea.hxx:10
ZoneArea::m_zoneType
ZoneType m_zoneType
Definition: ZoneArea.hxx:112
ZoneArea::getZone
ZoneType getZone() const
Get the zone for this Area.
Definition: ZoneArea.hxx:71
ZoneNode
Definition: ZoneArea.hxx:8
mergeZoneAreas
void mergeZoneAreas(ZoneArea &mainZone, ZoneArea &toBeMerged)
Definition: ZoneArea.cxx:7
ZoneArea::setVacancy
void setVacancy(Point coordinate, bool vacancy)
Set vacancy for this tile.
Definition: ZoneArea.cxx:139
ZoneArea::m_zoneDensity
ZoneDensity m_zoneDensity
Definition: ZoneArea.hxx:113
Point
Definition: Point.hxx:7
ZoneArea::m_isVacant
bool m_isVacant
Definition: ZoneArea.hxx:117
ZoneArea::setPowerSupply
void setPowerSupply(bool hasPower)
Set the power supply for this Area.
Definition: ZoneArea.hxx:43
ZoneArea::m_hasPower
bool m_hasPower
Definition: ZoneArea.hxx:115
ZoneArea::m_hasWater
bool m_hasWater
Definition: ZoneArea.hxx:116
ZoneArea::ZoneArea
ZoneArea(ZoneNode zoneNode)
Definition: ZoneArea.cxx:18
ZoneArea::setWaterSupply
void setWaterSupply(bool hasWater)
Set the water supply for this Area.
Definition: ZoneArea.hxx:57
ZoneArea::hasWaterSupply
bool hasWaterSupply()
Get the water supply for this Area.
Definition: ZoneArea.hxx:64
ZoneArea::addNode
void addNode(ZoneNode zoneNode) override
Add a zoneNode to this zoneArea.
Definition: ZoneArea.cxx:106
MapGrid
Definition: MapGrid.hxx:7
ZoneArea::getMaximumTileSize
TileSize getMaximumTileSize(Point originPoint)
Returns the possible size of buildings that can be placed on this coordinate in a zone.
Definition: ZoneArea.cxx:65