Deep RTS
Tile.h
Go to the documentation of this file.
1//
2// Created by Per-Arne on 24.02.2017.
3//
4
5#pragma once
6
7#include <string>
8#include "Tile.h"
9#include "util/Position.h"
10#include "Constants.h"
11
12
13class Unit;
14class Tilemap;
15
16
21class Tile{
22private:
23
30 Tilemap &tilemap;
31
33 bool harvestable;
34
36 bool walkable;
37
39 float walkModifier;
40
42 int occupantID = -1;
43
45 int resources;
46
48 std::string name;
49
51 int typeId;
52
54 bool depleted;
55
62 const bool newHarvestable;
63
65 const bool newWalkable;
66
68 const float newWalkModifier;
69
71 const int newTypeId;
72
74 const int newResources;
75
77 const std::string newName;
78
85 const bool depletedHarvestable;
86
88 const bool depletedWalkable;
89
91 const float depletedWalkModifier;
92
94 const int depletedTypeId;
95
97 const int depletedResources;
98
100 const std::string depletedName;
101
102
103public:
106 [[nodiscard]] float getWalkModifier() const;
107
109 const int id;
110
112 const int x;
113
115 const int y;
116
118 const int width;
119
121 const int height;
122
124 const float lumberYield;
125
127 const float goldYield;
128
130 const float stoneYield;
131
154 Tile(
155 Tilemap &tilemap,
156 int id,
157 int x,
158 int y,
159 int w,
160 int h,
161 const std::string& newName,
162 int newTypeId,
163 bool newHarvestable,
164 bool newWalkable,
165 float newWalkModifier,
166 int newResources,
167 const std::string& depletedName,
168 int depletedTypeId,
169 bool depletedHarvestable,
170 bool depletedWalkable,
171 float depletedWalkmMdifier,
172 int depletedResources,
173 float lumberYield,
174 float goldYield,
175 float stoneYield
176 );
177
178
184
185
188 [[nodiscard]] Position getPosition() const;
189
193 bool isAttackable(Unit & unit);
194
197 [[nodiscard]] bool isWalkable()const;
198
201 [[nodiscard]] bool isHarvestable()const;
202
205 [[nodiscard]] bool isBuildable()const;
206
210 int distance(Tile &sourceTile) const;
211
214 Unit* getOccupant();
215
218 [[nodiscard]] int getOccupantID() const;
219
222 [[nodiscard]] bool hasOccupant() const;
223
226 [[nodiscard]] int getResources() const;
227
230 [[nodiscard]] bool isDepleted() const;
231
234 [[nodiscard]] int getTypeId() const;
235
238 [[nodiscard]] Tilemap &getTilemap() const;
239
242 [[nodiscard]] const std::string &getName() const;
243
246 [[maybe_unused]] [[nodiscard]] int getDepleteTile() const;
247
250 void triggerOnTileChange();
251
257
260 void setOccupant(Unit *unit);
261
264 void setOccupantID(int unitID);
265
267 void setDepleted();
268
271 void setResources(uint16_t resource_count);
272
275 void takeResource(uint8_t n);
276
282
284 void reset();
285
286
287
288
289
290
291
292
293};
294
295
296
Definition: Tile.h:21
const int height
The height of the tile (usually 1)
Definition: Tile.h:121
Tile(Tilemap &tilemap, int id, int x, int y, int w, int h, const std::string &newName, int newTypeId, bool newHarvestable, bool newWalkable, float newWalkModifier, int newResources, const std::string &depletedName, int depletedTypeId, bool depletedHarvestable, bool depletedWalkable, float depletedWalkmMdifier, int depletedResources, float lumberYield, float goldYield, float stoneYield)
Definition: Tile.cpp:8
int getTypeId() const
Definition: Tile.cpp:230
Position getPosition() const
Definition: Tile.cpp:222
float getWalkModifier() const
Definition: Tile.cpp:246
const int id
The TileID.
Definition: Tile.h:109
bool isWalkable() const
Definition: Tile.cpp:131
void setOccupant(Unit *unit)
Definition: Tile.cpp:139
bool isDepleted() const
Definition: Tile.cpp:226
void setResources(uint16_t resource_count)
Definition: Tile.cpp:213
bool isBuildable() const
Definition: Tile.cpp:161
void setDepleted()
Sets the tile to deplted.
Definition: Tile.cpp:193
const int y
THe y position of the tile.
Definition: Tile.h:115
Unit * getOccupant()
Definition: Tile.cpp:107
void triggerOnTileChange()
Definition: Tile.cpp:209
Tilemap & getTilemap() const
Definition: Tile.cpp:234
const int x
The x position of the tile.
Definition: Tile.h:112
bool hasOccupant() const
Definition: Tile.cpp:101
bool isHarvestable() const
Definition: Tile.cpp:135
const float goldYield
The number of hgold the tile yields on harvesting.
Definition: Tile.h:127
const int width
The width of the tile (usually 1)
Definition: Tile.h:118
void takeResource(uint8_t n)
Definition: Tile.cpp:218
void reset()
Reset tile.
Definition: Tile.cpp:170
const float stoneYield
The number of stone the tile yields on harvesting.
Definition: Tile.h:130
int getDepleteTile() const
Definition: Tile.cpp:242
int distance(Tile &sourceTile) const
Definition: Tile.cpp:166
int getOccupantID() const
Definition: Tile.cpp:155
int getResources() const
Definition: Tile.cpp:117
bool isAttackable(Unit &unit)
Definition: Tile.cpp:122
const float lumberYield
The number of lumber the tile yields on harvesting.
Definition: Tile.h:124
const std::string & getName() const
Definition: Tile.cpp:238
void setOccupantID(int unitID)
Definition: Tile.cpp:149
Definition: Tilemap.h:16
Definition: Unit.h:25
Definition: Position.h:8