Cytopia  0.3
A city building simulation game
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
tileData.hxx
Go to the documentation of this file.
1 #ifndef TILEDATA_HXX_
2 #define TILEDATA_HXX_
3 
4 #include <string>
5 #include <vector>
6 #include "enums.hxx"
7 
9 #define TD_PRICE_MIN 0
10 #define TD_PRICE_MAX 100000
11 #define TD_UPKEEP_MIN -10000
12 #define TD_UPKEEP_MAX 10000
13 #define TD_POWER_MIN -100
14 #define TD_POWER_MAX 1000
15 #define TD_WATER_MIN -100
16 #define TD_WATER_MAX 1000
17 #define TD_EDUCATION_MIN -100
18 #define TD_EDUCATION_MAX 100
19 #define TD_POLLUTION_MIN -100
20 #define TD_POLLUTION_MAX 100
21 #define TD_CRIME_MIN -100
22 #define TD_CRIME_MAX 100
23 #define TD_HABITANTS_MIN 0
24 #define TD_HABITANTS_MAX 10000
25 #define TD_FIREDANGER_MIN -100
26 #define TD_FIREDANGER_MAX 100
27 #define TD_HAPPINESS_MIN -100
28 #define TD_HAPPINESS_MAX 100
29 #define TD_TITLE_MAX_CHARS 100
30 #define TD_DESCRIPTION_MAX_CHARS 100
31 #define TD_BIOME_MAX_CHARS 100
32 #define TD_AUTHOR_MAX_CHARS 100
33 #define TD_ID_MAX_CHARS 100
34 #define TD_CATEGORY_MAX_CHARS 40
35 #define TD_SUBCATEGORY_MAX_CHARS 40
36 #define TD_REQUIREDTILES_MIN 1
37 #define TD_REQUIREDTILES_MAX 20
38 
39 BETTER_ENUM(TileType, int,
40  DEFAULT,
41  FLORA,
42  TERRAIN,
43  WATER,
44  BLUEPRINT,
45  AUTOTILE,
46  ZONE,
47  ROAD,
48  POWERLINE,
49  GROUNDDECORATION,
50  UNDERGROUND,
51  RCI
52 )
53 
54 //
55 BETTER_ENUM(ZoneType, int, RESIDENTIAL, INDUSTRIAL, COMMERCIAL, AGRICULTURAL)
56 
57 BETTER_ENUM(ZoneDensity, int,
58  LOW,
60  HIGH
61 )
62 
63 BETTER_ENUM(Style, int,
64  ALL,
65  ASIAN,
66  EUROPEAN,
67  US
68 )
69 
71 struct TileSetData
72 {
73  std::string fileName;
74  int count =
75  1;
76  int clippingWidth = 0;
77  int clippingHeight = 0;
78  int offset =
79  0;
80  bool pickRandomTile = false;
81  int rotations =
82  1;
83 };
84 
86 struct TileSize
87 {
88  unsigned int width;
89  unsigned int height;
90 
91  TileSize() : width(1), height(1){};
92  TileSize(unsigned int width, unsigned int height) : width(width), height(height){};
93  TileSize(const TileSize &other) : width(other.width), height(other.height){};
94 
95  TileSize &operator=(const TileSize &other)
96  {
97  width = other.width;
98  height = other.height;
99  return *this;
100  };
101 
102  bool operator==(const TileSize &other) const
103  {
104  if (width == other.width && height == other.height)
105  return true;
106  return false;
107  };
108 
109  const bool operator<(const TileSize &other)
110  {
111  if (width < other.width)
112  return true;
113  else if (width == other.width && height == other.height)
114  return true;
115 
116  return false;
117  };
118 
119  size_t operator()(const TileSize &TileSizeToHash) const noexcept
120  {
121  size_t hash = TileSizeToHash.width + 10 * TileSizeToHash.height;
122  return hash;
123  };
124 };
125 
126 namespace std
127 {
128 template <> struct hash<TileSize>
129 {
130  std::size_t operator()(const TileSize &p) const noexcept { return p(p); }
131 };
132 } // namespace std
133 
135 struct TileData
136 {
143  uint8_t buildingsize;
144  std::vector<std::string>
146  std::vector<std::string> tags;
147 
148  TileSetData tiles;
150  TileSetData shoreTiles;
151  TileSetData slopeTiles;
154  int price = 0;
155  int upkeepCost = 0;
156  int power = 0;
157  int water = 0;
158 
159  std::vector<std::string>
161  bool placeOnGround = true;
162  bool placeOnWater = false;
164  int pollutionLevel = 0;
165  int crimeLevel = 0;
166  int fireHazardLevel = 0;
167  int inhabitants = 0;
168  int happiness = 0;
169  int educationLevel = 0;
170  std::vector<ZoneType> zoneTypes;
171  std::vector<Style> style;
172  std::vector<ZoneDensity> zoneDensity;
174 };
175 
176 #endif
TileData::title
std::string title
The item's title. It's shown ingame and in the editor's tree-view.
Definition: tileData.hxx:152
TileSize::height
unsigned int height
Definition: tileData.hxx:89
TileData::water
int water
water production / consumption if negative
Definition: tileData.hxx:157
TileData::placeOnWater
bool placeOnWater
whether or not this building is placeable on water
Definition: tileData.hxx:162
WATER
@ WATER
6- Water tiles
Definition: enums.hxx:17
TileData::tileType
TileType tileType
Definition: tileData.hxx:149
DEFAULT
@ DEFAULT
Definition: TileManager.hxx:18
MEDIUM
MEDIUM
Medium density.
Definition: tileData.hxx:59
TileData::placeOnGround
bool placeOnGround
whether or not this building is placeable on ground
Definition: tileData.hxx:161
TileSize::operator==
bool operator==(const TileSize &other) const
Definition: tileData.hxx:102
TileData::category
std::string category
The category this item resides in. Categories are used for the building menu in-game and for sorting ...
Definition: tileData.hxx:140
TileData::crimeLevel
int crimeLevel
Crime this building produces or prevents (police station)
Definition: tileData.hxx:165
TileSize
How many tiles are occupied by a building.
Definition: tileData.hxx:86
enums.hxx
TileData::groundDecoration
std::vector< std::string > groundDecoration
tileID of the item that should be drawn on ground below sprite instead of terrain(grass,...
Definition: tileData.hxx:160
TileData::biomes
std::vector< std::string > biomes
Restrict this building to spawn only in the given biomes. Must correspond to a biome defined in resou...
Definition: tileData.hxx:145
TileData::buildingsize
uint8_t buildingsize
the size that the building occupies in tiles.
Definition: tileData.hxx:143
TileData::happiness
int happiness
The effect on happiness around this building.
Definition: tileData.hxx:168
TileData::description
std::string description
Description of the item that is shown in its details.
Definition: tileData.hxx:153
TileData::tiles
TileSetData tiles
Tile Spritesheet information.
Definition: tileData.hxx:148
TileData::pollutionLevel
int pollutionLevel
Pollution this building produces or prevents.
Definition: tileData.hxx:164
BETTER_ENUM
BETTER_ENUM(TileType, int, DEFAULT, FLORA, TERRAIN, WATER, BLUEPRINT, AUTOTILE, ZONE, ROAD, POWERLINE, GROUNDDECORATION, UNDERGROUND, RCI) BETTER_ENUM(ZoneDensity
ZONE
@ ZONE
4- Optional layer, zones(Industrial/Residential/Commercial).
Definition: enums.hxx:15
BLUEPRINT
@ BLUEPRINT
1- Optional layer - Map Blueprint
Definition: enums.hxx:12
TileSize::operator()
size_t operator()(const TileSize &TileSizeToHash) const noexcept
Definition: tileData.hxx:119
TileData::inhabitants
int inhabitants
How many residents / workers this building can hold. Also how much jobs it provides.
Definition: tileData.hxx:167
TileData::style
std::vector< Style > style
Restrict this building to certain Art Styles.
Definition: tileData.hxx:171
TileData::power
int power
power production / consumption if negative
Definition: tileData.hxx:156
std::hash< TileSize >::operator()
std::size_t operator()(const TileSize &p) const noexcept
Definition: tileData.hxx:130
TileSize::operator<
const bool operator<(const TileSize &other)
Definition: tileData.hxx:109
TileData::id
std::string id
The ID of this item. Must be unique and can be referenced in the code.
Definition: tileData.hxx:137
TileData::price
int price
building cost
Definition: tileData.hxx:154
TileSize::operator=
TileSize & operator=(const TileSize &other)
Definition: tileData.hxx:95
TileData::isOverPlacable
bool isOverPlacable
Determines if other tiles can be placed over this one tile.
Definition: tileData.hxx:163
TileData::RequiredTiles
TileSize RequiredTiles
How many tiles this building uses.
Definition: tileData.hxx:173
FLORA
@ FLORA
10- Trees and other flora/Fauna tiles
Definition: enums.hxx:21
TileData::zoneTypes
std::vector< ZoneType > zoneTypes
Restrict this building to a zone type.
Definition: tileData.hxx:170
TileSize::TileSize
TileSize(const TileSize &other)
Definition: tileData.hxx:93
TileData::slopeTiles
TileSetData slopeTiles
Slope Tile Spritesheet information.
Definition: tileData.hxx:151
TERRAIN
@ TERRAIN
3- Terrain tiles, decorations, ... - must always be a "full" tile
Definition: enums.hxx:14
TileData::upkeepCost
int upkeepCost
monthly cost
Definition: tileData.hxx:155
TileData::tags
std::vector< std::string > tags
Tags to filter buildings in the gui.
Definition: tileData.hxx:146
ROAD
@ ROAD
5- Optional layer, roads.
Definition: enums.hxx:16
TileData::zoneDensity
std::vector< ZoneDensity > zoneDensity
Restrict this building to a certain zone density. See enum ZoneDensity.
Definition: tileData.hxx:172
std
Definition: Point.hxx:83
TileSize::TileSize
TileSize()
Definition: tileData.hxx:91
TileData::fireHazardLevel
int fireHazardLevel
Fire Danger this building produces or prevents.
Definition: tileData.hxx:166
TileData::educationLevel
int educationLevel
How much education this building provides (educational building) / requires (job)
Definition: tileData.hxx:169
TileSize::TileSize
TileSize(unsigned int width, unsigned int height)
Definition: tileData.hxx:92
TileData::subCategory
std::string subCategory
subcategories are used for the building menu in-game and for sorting the items in the editors tree vi...
Definition: tileData.hxx:142
string
std::string string
Definition: AudioConfig.hxx:14
UNDERGROUND
@ UNDERGROUND
2- Optional layer - Pipes, Subway-pipes and so onn
Definition: enums.hxx:13
TileData
Holds all releavted information to this specific tile.
Definition: tileData.hxx:135
TileData::author
std::string author
The author of this item.
Definition: tileData.hxx:138
TileSize::width
unsigned int width
Definition: tileData.hxx:88
TileData::shoreTiles
TileSetData shoreTiles
Shore Tile Spritesheet information.
Definition: tileData.hxx:150
LOW
LOW
Low density.
Definition: tileData.hxx:58