 |
Cytopia
0.3
A city building simulation game
|
Go to the documentation of this file.
5 #include "../map/MapLayers.hxx"
10 : m_isoCoordinates(
std::move(isoCoordinates)), m_sprite{std::make_unique<Sprite>(
m_isoCoordinates)},
15 setTileID(terrainID, isoCoordinates);
18 setTileID(tileID, isoCoordinates);
21 setTileID(
"terrain_blueprint", isoCoordinates);
28 constexpr
int minHeight = 0;
31 if ((higher && (height <
maxHeight)) || (!higher && (height > minHeight)))
33 higher ? ++height : --height;
53 if (tileData && !tileID.empty())
120 unsigned char alpha = (1 - transparencyFactor) * 255;
121 m_sprite->setSpriteTranparencyFactor(layer, alpha);
138 if (clipRectX >=
static_cast<int>(tileData->
slopeTiles.count) * tileData->
slopeTiles.clippingWidth &&
166 [
this](
const Layer &_layer) { return this->isLayerOccupied(_layer); }))
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;
468 std::vector<Layer> layersToDemolish;
479 for (
auto &layer : layersToDemolish)
488 m_mapNodeData[layer].tileData->tileType != +TileType::GROUNDDECORATION))
@ 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.
bool placeOnGround
whether or not this building is placeable on ground
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 !!!
const bool isConductive() const
check the conductivity of the node
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.
bool isPlacementAllowed(const std::string &newTileID) const
@ 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.
void demolishNode(const Layer &layer=Layer::NONE)
Demolish a node.
void render() const
Render MapNode.
TileSetData tiles
Tile Spritesheet information.
bool isSlopeNode(void) const
check if current Node Terrain is Slope Terrain.
@ 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 changeHeight(const bool higher)
Change Height.
MapNode(Point isoCoordinates, const std::string &terrainID, const std::string &newTileID="")
void setMapNodeData(std::vector< MapNodeData > &&mapNodeData)
Overwrite m_mapData with the one loaded from a savegame. This function to be used only by loadGame.
bool isPlacableOnSlope(const std::string &tileID) const
check if tileID placeable on slope tile.
void setBitmask(unsigned char elevationBitmask, std::vector< uint8_t > tileTypeBitmask)
@ UNDERGROUND
2- Optional layer - Pipes, Subway-pipes and so onn
const MapNodeData & getActiveMapNodeData() const
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)
void setCoordinates(const Point &newIsoCoordinates)
sets the iso coordinates of this node