 |
Cytopia
0.3
A city building simulation game
|
Class that holds map nodes.
More...
#include <MapNode.hxx>
Class that holds map nodes.
Each tile is represented by the map nodes class.
Definition at line 30 of file MapNode.hxx.
◆ MapNode() [1/2]
◆ MapNode() [2/2]
◆ ~MapNode()
◆ changeHeight()
bool MapNode::changeHeight |
( |
const bool |
higher | ) |
|
Change Height.
Increases or decrease the height of the node and its sprite. This function should not be called directly, but only from where the neighboring nodes slopes are determined.
- Parameters
-
higher | pass true in case that height should be increased or false in case that height should be decreased. |
- Returns
- true in case that height is changed, otherwise false.
Definition at line 26 of file MapNode.cxx.
28 constexpr
int minHeight = 0;
31 if ((higher && (height <
maxHeight)) || (!higher && (height > minHeight)))
33 higher ? ++height : --height;
◆ demolishLayer()
void MapNode::demolishLayer |
( |
const Layer & |
layer | ) |
|
demolish specific layer of a Node.
- Parameters
-
layer | what layer should be demolished. |
Definition at line 454 of file MapNode.cxx.
◆ demolishNode()
void MapNode::demolishNode |
( |
const Layer & |
layer = Layer::NONE | ) |
|
Demolish a node.
Removes all tiles on a node. This effects all layers where something to demolish is placed (BUILDINGS, GROUND_DECORATION, UNDERGROUND) per default, but can be restricted to a single Layer.
- Parameters
-
layer | restrict demolish to a single layer |
- See also
- MapNode::demolishNode
Definition at line 465 of file MapNode.cxx.
468 std::vector<Layer> layersToDemolish;
479 for (
auto &layer : layersToDemolish)
488 m_mapNodeData[layer].tileData->tileType != +TileType::GROUNDDECORATION))
◆ getActiveMapNodeData()
const MapNodeData & MapNode::getActiveMapNodeData |
( |
| ) |
const |
◆ getCoordinates()
const Point& MapNode::getCoordinates |
( |
| ) |
const |
|
inline |
get iso coordinates of this node
- Returns
- a pointer to the node's iso coordinates
Definition at line 59 of file MapNode.hxx.
◆ getElevationBitmask()
unsigned char MapNode::getElevationBitmask |
( |
| ) |
const |
|
inline |
◆ getMapNodeData()
const std::vector<MapNodeData>& MapNode::getMapNodeData |
( |
| ) |
const |
|
inline |
◆ getMapNodeDataForLayer()
◆ getOrigCornerPoint()
const Point& MapNode::getOrigCornerPoint |
( |
Layer |
layer | ) |
const |
|
inline |
Get the Origin Corner Point of a multitile building.
- Parameters
-
layer | the layer that should be checked |
- Returns
- const Point&
Definition at line 136 of file MapNode.hxx.
◆ getSprite()
Sprite* MapNode::getSprite |
( |
| ) |
const |
|
inline |
◆ getTileData()
◆ getTileID()
get TileID of specific layer inside NodeData.
- Parameters
-
layer | what layer should be checked on. |
Definition at line 89 of file MapNode.hxx.
◆ getTopMostActiveLayer()
Layer MapNode::getTopMostActiveLayer |
( |
| ) |
const |
return topmost active layer.
check layers in order of significance for the topmost active layer that has an active tile on that layer
- Returns
- Layer enum of the topmost active layer
Definition at line 105 of file MapNode.cxx.
◆ isConductive()
const bool MapNode::isConductive |
( |
| ) |
const |
check the conductivity of the node
- Returns
- true if the node conducts electricity/power, false if not
Definition at line 502 of file MapNode.cxx.
◆ isLayerOccupied()
bool MapNode::isLayerOccupied |
( |
const Layer & |
layer | ) |
const |
|
inline |
◆ isOriginNode()
If this is the origin node of a multitile building.
- Parameters
-
layer | the layer that should be checked, defaults to the BUILDINGS layer |
- Returns
- wheter or not this is the origin node of a multitile building
Definition at line 144 of file MapNode.hxx.
◆ isPlacableOnSlope()
bool MapNode::isPlacableOnSlope |
( |
const std::string & |
tileID | ) |
const |
check if tileID placeable on slope tile.
- Parameters
-
tileID | the tileID which need to be checked whether allowing placement on slope or not. |
Definition at line 124 of file MapNode.cxx.
138 if (clipRectX >=
static_cast<int>(tileData->
slopeTiles.count) * tileData->
slopeTiles.clippingWidth &&
◆ isPlacementAllowed()
bool MapNode::isPlacementAllowed |
( |
const std::string & |
newTileID | ) |
const |
Definition at line 147 of file MapNode.cxx.
166 [
this](
const Layer &_layer) { return this->isLayerOccupied(_layer); }))
226 if (!tileData->placeOnGround)
◆ isSlopeNode()
bool MapNode::isSlopeNode |
( |
void |
| ) |
const |
check if current Node Terrain is Slope Terrain.
Definition at line 430 of file MapNode.cxx.
◆ render()
void MapNode::render |
( |
| ) |
const |
◆ setAutotileBitMask()
void MapNode::setAutotileBitMask |
( |
std::vector< unsigned char > && |
bitMask | ) |
|
|
inline |
Set autotile bit mask.
- Parameters
-
Definition at line 165 of file MapNode.hxx.
◆ setBitmask()
void MapNode::setBitmask |
( |
unsigned char |
elevationBitmask, |
|
|
std::vector< uint8_t > |
tileTypeBitmask |
|
) |
| |
◆ setCoordinates()
void MapNode::setCoordinates |
( |
const Point & |
newIsoCoordinates | ) |
|
sets the iso coordinates of this node
- Parameters
-
newIsoCoordinates | the new iso coordinates for the node |
Definition at line 432 of file MapNode.cxx.
◆ setElevationBitMask()
void MapNode::setElevationBitMask |
( |
const unsigned char |
bitMask | ) |
|
|
inline |
Set elevation bit mask.
- Parameters
-
Definition at line 160 of file MapNode.hxx.
◆ setMapNodeData()
void MapNode::setMapNodeData |
( |
std::vector< MapNodeData > && |
mapNodeData | ) |
|
Overwrite m_mapData with the one loaded from a savegame. This function to be used only by loadGame.
Definition at line 440 of file MapNode.cxx.
◆ setNodeTransparency()
void MapNode::setNodeTransparency |
( |
const float |
transparencyFactor, |
|
|
const Layer & |
layer |
|
) |
| const |
Sets a node to be Transparent.
- Parameters
-
transparencyFactor | (0-1.0) - The percentage of node transparency. 1 -> invisible, 0 -> opaque. |
layer | what layer in Sprite should it's transparency altered. |
Definition at line 117 of file MapNode.cxx.
120 unsigned char alpha = (1 - transparencyFactor) * 255;
121 m_sprite->setSpriteTranparencyFactor(layer, alpha);
◆ setTileID()
void MapNode::setTileID |
( |
const std::string & |
tileType, |
|
|
const Point & |
origPoint |
|
) |
| |
set tileIndex to a rand between 1 and count, this will be the displayed image of the entire tileset if this tile has ordered frames, like roads then pickRandomTile must be set to 0.
must be reset to 0 otherwise overwritting tiles would keep the old tile's tileIndex which creates problems if it's supposed to be 0
Definition at line 50 of file MapNode.cxx.
53 if (tileData && !tileID.empty())
◆ setZIndex()
void MapNode::setZIndex |
( |
int |
zIndex | ) |
|
|
inline |
Update the Z-Index of this mapNode.
- Parameters
-
Definition at line 183 of file MapNode.hxx.
◆ updateTexture()
void MapNode::updateTexture |
( |
const Layer & |
layer = Layer::NONE | ) |
|
Update texture.
- Parameters
-
Definition at line 253 of file MapNode.cxx.
255 SDL_Rect clipRect{0, 0, 0, 0};
258 std::vector<Layer> layersToGoOver;
262 layersToGoOver.push_back(layer);
269 for (
auto currentLayer : layersToGoOver)
273 size_t spriteCount = 1;
298 if (
m_mapNodeData[currentLayer].tileData->slopeTiles.fileName.empty())
320 if (
m_mapNodeData[currentLayer].tileData->tileType == +TileType::POWERLINE &&
322 [
this](
const Layer &_layer) { return this->m_mapNodeData[_layer].tileData; }))
365 static_cast<Layer>(currentLayer));
367 static_cast<Layer>(currentLayer));
370 spriteCount =
m_mapNodeData[currentLayer].tileData->tiles.count;
387 static_cast<Layer>(currentLayer));
389 static_cast<Layer>(currentLayer));
392 spriteCount =
m_mapNodeData[currentLayer].tileData->shoreTiles.count;
395 if (
m_mapNodeData[currentLayer].tileData->slopeTiles.fileName.empty())
400 clipRect.x =
m_mapNodeData[currentLayer].tileData->slopeTiles.clippingWidth *
402 spriteCount =
m_mapNodeData[currentLayer].tileData->slopeTiles.count;
407 static_cast<Layer>(currentLayer));
409 static_cast<Layer>(currentLayer));
425 m_sprite->spriteCount = spriteCount;
◆ m_autotileBitmask
std::vector<unsigned char> MapNode::m_autotileBitmask |
|
private |
◆ m_autotileOrientation
◆ m_clippingWidth
int MapNode::m_clippingWidth = 0 |
|
private |
◆ m_elevationBitmask
unsigned char MapNode::m_elevationBitmask = 0 |
|
private |
◆ m_elevationOrientation
◆ m_isoCoordinates
Point MapNode::m_isoCoordinates |
|
private |
◆ m_mapNodeData
◆ m_previousTileID
◆ m_sprite
std::unique_ptr<Sprite> MapNode::m_sprite |
|
private |
◆ maxHeight
const int MapNode::maxHeight = 32 |
|
static |
Maximum height of the node.
Definition at line 186 of file MapNode.hxx.
The documentation for this class was generated from the following files:
@ DE_ZONE
Remove only zones.
bool placeOnWater
whether or not this building is placeable on water
TileOrientation calculateTileOrientation(unsigned char bitMaskElevation)
Calculates the TileOrientation for elevated tiles to pick the correct Sprite.
const MapNodeData & getMapNodeDataForLayer(Layer layer) const
const Point & getCoordinates() const
get iso coordinates of this node
std::string category
The category this item resides in. Categories are used for the building menu in-game and for sorting ...
@ POWERLINES
9- Powerlines
Layer getTopMostActiveLayer() const
return topmost active layer.
@ NONE
0- this must be FIRST !!!
static const int maxHeight
Maximum height of the node.
size_t calculateSlopeOrientation(unsigned char bitMaskElevation)
Calculates the slope orientation for elevated tiles to pick the correct slope Sprite.
@ GROUND_DECORATION
Remove only ground decoration.
const TileData * getTileData(Layer layer) const
std::vector< TileOrientation > m_autotileOrientation
unsigned char m_elevationBitmask
std::unique_ptr< Sprite > m_sprite
void demolishLayer(const Layer &layer)
demolish specific layer of a Node.
void updateTexture(const Layer &layer=Layer::NONE)
Update texture.
TileSetData tiles
Tile Spritesheet information.
@ ZONE
4- Optional layer, zones(Industrial/Residential/Commercial).
@ BLUEPRINT
1- Optional layer - Map Blueprint
@ BUILDINGS
8- Buildings, Streets and everything that goes on the terrain
Layer getTileLayer(const std::string &tileID) const
Get the Layer that is associated with a tileID. The Tile will be placed on this layer.
size_t m_elevationOrientation
SDL_Texture * getTexture(const std::string &tileID) const
Get the Texture for the tileID.
bool rectangularRoads
place rectangular road tiles instead of diagonal tiles
DemolishMode demolishMode
bool isOverPlacable
Determines if other tiles can be placed over this one tile.
std::vector< MapNodeData > m_mapNodeData
@ FLORA
10- Trees and other flora/Fauna tiles
TileData * getTileData(const std::string &id) noexcept
Get the TileData struct for this tileID and all information associated with it.
@ DEFAULT
Demolish everything, but not.
static bool isLayerActive(unsigned int layer)
Check if given Layer is being drawn.
TileSetData slopeTiles
Slope Tile Spritesheet information.
@ TERRAIN
3- Terrain tiles, decorations, ... - must always be a "full" tile
void setNodeTransparency(const float transparencyFactor, const Layer &layer) const
Sets a node to be Transparent.
static Layer layersInActiveOrder[]
This is a ordered list of all relevant layers from the most active to the least active.
int height
The height level.
@ ROAD
5- Optional layer, roads.
const std::string & getTileID(Layer layer) const
get TileID of specific layer inside NodeData.
std::vector< unsigned char > m_autotileBitmask
const static std::vector< Layer > layersPowerlinesCanCross
std::string m_previousTileID
static Layer allLayersOrdered[]
This is a ordered list of all relevant layers we need to interact with.
@ GROUND_DECORATION
13- Decoration to place beneath buildings. Like concrete or grass
static TileManager & instance(void)
Get an instance of the singleton.
@ LAYERS_COUNT
this must be LAST !!!
bool isPlacableOnSlope(const std::string &tileID) const
check if tileID placeable on slope tile.
@ UNDERGROUND
2- Optional layer - Pipes, Subway-pipes and so onn
bool isLayerOccupied(const Layer &layer) const
@ TILE_DEFAULT_ORIENTATION
Holds all releavted information to this specific tile.
void setTileID(const std::string &tileType, const Point &origPoint)