|
Cytopia
0.3
A city building simulation game
|
#include <MapFunctions.hxx>
Inheritance diagram for MapFunctions:
Collaboration diagram for MapFunctions:Public Member Functions | |
| MapFunctions () | |
| Map * | getMap () |
| void | changeHeight (const Point &isoCoordinates, const bool elevate) |
| Change map node height. More... | |
| bool | updateHeight (Point coordinate, const bool elevate) |
| Change map node height. More... | |
| void | levelHeight (const Point &startCoordinate, const std::vector< Point > levelArea) |
| level area of map nodes. More... | |
| MapNode & | getMapNode (Point isoCoords) |
| Get pointer to a single mapNode at specific iso coordinates. More... | |
| const std::vector< MapNode > & | getMapNodes () |
| Get all mapnodes as a vector. More... | |
| std::vector< NeighborNode > | getNeighborNodes (const Point &isoCoordinates, const bool includeCentralNode) |
| Get all neighbor nodes from provided map node. More... | |
| unsigned char | getElevatedNeighborBitmask (Point centerCoordinates) |
| Get elevated bit mask of the map node. More... | |
| bool | isPlacementOnNodeAllowed (const Point &isoCoordinates, const std::string &tileID) const |
| check if Tile is occupied More... | |
| bool | isPlacementOnAreaAllowed (const std::vector< Point > &targetCoordinates, const std::string &tileID) const |
| check if Tile can be placed in an area More... | |
| bool | setTileID (const std::string &tileID, Point coordinate) |
| Set the Tile ID Of Node object. More... | |
| bool | setTileID (const std::string &tileID, const std::vector< Point > &coordinates) |
| Set the Tile ID Of multiple Node objects. More... | |
| void | demolishNode (const std::vector< Point > &isoCoordinates, bool updateNeighboringTiles=false, Layer layer=Layer::NONE) |
| Demolish a node. More... | |
| Point | getNodeOrigCornerPoint (const Point &isoCoordinates, Layer layer=Layer::NONE) |
| Get original corner point of given point within building borders. More... | |
| void | getNodeInformation (const Point &isoCoordinates) const |
| Debug MapNodeData to Console. More... | |
| void | highlightNode (const Point &isoCoordinates, const SpriteRGBColor &rgbColor) |
| Sets a node to be highlighted. More... | |
| void | unHighlightNode (const Point &isoCoordinates) |
| Sets a node to be unhighlighred. More... | |
| Point | findNodeInMap (const SDL_Point &screenCoordinates, const Layer &layer=Layer::NONE) |
| Returns the node at given screen coordinates. More... | |
| std::string | getTileID (const Point &isoCoordinates, Layer layer) |
| get Tile ID of specific layer of specific iso coordinates More... | |
| void | refreshVisibleMap () |
| Refresh the visible part of the map. More... | |
| void | newMap (bool generateTerrain=true) |
| Creates a new map object with terrain gen. More... | |
| void | loadMapFromFile (const std::string &fileName) |
| Load Map from file. More... | |
Private Member Functions | |
| void | updateNodeNeighbors (const std::vector< Point > &nodes) |
| Update the nodes and all affected node with the change. More... | |
| void | updateAllNodes () |
| Update all mapNodes. More... | |
| bool | isClickWithinTile (const SDL_Point &screenCoordinates, Point isoCoordinate, const Layer &layer) const |
| Check if a click is within a non transparent part of a sprite. More... | |
| void | saveMapToFile (const std::string &fileName) |
| Save Map to file. More... | |
| std::vector< uint8_t > | calculateAutotileBitmask (Point coordinate) |
| Get a bitmask that represents same-tile neighbors. More... | |
Private Attributes | |
| Map * | m_map |
Additional Inherited Members | |
Static Public Member Functions inherited from Singleton< MapFunctions > | |
| static MapFunctions & | instance (void) |
| Get an instance of the singleton. More... | |
Protected Member Functions inherited from Singleton< MapFunctions > | |
| Singleton () noexcept=default | |
| ~Singleton () noexcept=default | |
Definition at line 12 of file MapFunctions.hxx.
| MapFunctions::MapFunctions | ( | ) |
Definition at line 16 of file MapFunctions.cxx.
Here is the call graph for this function:
|
private |
Get a bitmask that represents same-tile neighbors.
Checks all neighboring tiles and returns the elevated neighbors in a bitmask: [ BR BL TR TL R L B T ] [ 0 0 0 0 0 0 0 0 ]
| coordinate | Point on the map to calculate bitmask for. |
Definition at line 336 of file MapFunctions.cxx.
Here is the call graph for this function:
Here is the caller graph for this function:| void MapFunctions::changeHeight | ( | const Point & | isoCoordinates, |
| const bool | elevate | ||
| ) |
Change map node height.
| isoCoordinates | the Point on the map node to change height. |
| elevate | if set to true make node higher, otherwise lower. |
Definition at line 36 of file MapFunctions.cxx.
Here is the call graph for this function:
Here is the caller graph for this function:| void MapFunctions::demolishNode | ( | const std::vector< Point > & | isoCoordinates, |
| bool | updateNeighboringTiles = false, |
||
| Layer | layer = Layer::NONE |
||
| ) |
Demolish a node.
This function gathers all tiles that should be demolished and invokes the node's demolish function. When a building bigger than 1x1 is selected, all its coordinates are added to the demolishing points.
| isoCoordinates | all coordinates that should be demolished |
| updateNeighboringTiles | whether the adjacent tiles should be updated. (only relevant for autotiling) |
| layer | restrict demolish to a single layer |
Definition at line 465 of file MapFunctions.cxx.
Here is the call graph for this function:
Here is the caller graph for this function:| Point MapFunctions::findNodeInMap | ( | const SDL_Point & | screenCoordinates, |
| const Layer & | layer = Layer::NONE |
||
| ) |
Returns the node at given screen coordinates.
| screenCoordinates |
Definition at line 558 of file MapFunctions.cxx.
Here is the call graph for this function:
Here is the caller graph for this function:| unsigned char MapFunctions::getElevatedNeighborBitmask | ( | Point | centerCoordinates | ) |
Get elevated bit mask of the map node.
| centerCoordinates | Point on the map node to calculate elevated bit mask. |
Definition at line 310 of file MapFunctions.cxx.
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Get pointer to a single mapNode at specific iso coordinates.
| isoCoords | The node to retrieve. |
Definition at line 40 of file MapFunctions.hxx.
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Get all mapnodes as a vector.
Definition at line 48 of file MapFunctions.hxx.
| std::vector< NeighborNode > MapFunctions::getNeighborNodes | ( | const Point & | isoCoordinates, |
| const bool | includeCentralNode | ||
| ) |
Get all neighbor nodes from provided map node.
| isoCoordinates | iso coordinates. |
| includeCentralNode | if set to true include the central node in the result. |
Definition at line 253 of file MapFunctions.cxx.
Here is the call graph for this function:
Here is the caller graph for this function:| void MapFunctions::getNodeInformation | ( | const Point & | isoCoordinates | ) | const |
Debug MapNodeData to Console.
Used as Tile-Inspector until we implement a GUI variant
| isoCoordinates | Tile to inspect |
Definition at line 518 of file MapFunctions.cxx.
Here is the call graph for this function:
Here is the caller graph for this function:| Point MapFunctions::getNodeOrigCornerPoint | ( | const Point & | isoCoordinates, |
| Layer | layer = Layer::NONE |
||
| ) |
Get original corner point of given point within building borders.
| isoCoordinates | Point to get corner point of |
| layer |
Definition at line 326 of file MapFunctions.cxx.
Here is the call graph for this function:
Here is the caller graph for this function:| std::string MapFunctions::getTileID | ( | const Point & | isoCoordinates, |
| Layer | layer | ||
| ) |
get Tile ID of specific layer of specific iso coordinates
| isoCoordinates | Tile to inspect |
| layer | layer to check. |
Definition at line 545 of file MapFunctions.cxx.
Here is the call graph for this function:
Here is the caller graph for this function:| void MapFunctions::highlightNode | ( | const Point & | isoCoordinates, |
| const SpriteRGBColor & | rgbColor | ||
| ) |
Sets a node to be highlighted.
This sets a node to be highlighted. The highlighting is done during rendering
| isoCoordinates | which node should be highlit. |
| rgbColor | The SpriteRGBColor that should be used for highlighting |
Definition at line 535 of file MapFunctions.cxx.
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Check if a click is within a non transparent part of a sprite.
| screenCoordinates | click coordinates on the scrren |
| isoCoordinate | isocoordinates of the mapnode to check |
| layer | layer to check |
Definition at line 608 of file MapFunctions.cxx.
Here is the call graph for this function:
Here is the caller graph for this function:| bool MapFunctions::isPlacementOnAreaAllowed | ( | const std::vector< Point > & | targetCoordinates, |
| const std::string & | tileID | ||
| ) | const |
check if Tile can be placed in an area
| targetCoordinates | Tile array to inspect |
| tileID | tileID which should be checked |
Definition at line 270 of file MapFunctions.cxx.
Here is the call graph for this function:
Here is the caller graph for this function:| bool MapFunctions::isPlacementOnNodeAllowed | ( | const Point & | isoCoordinates, |
| const std::string & | tileID | ||
| ) | const |
check if Tile is occupied
| isoCoordinates | Tile to inspect |
| tileID | tileID which should be checked |
Definition at line 265 of file MapFunctions.cxx.
Here is the call graph for this function:
Here is the caller graph for this function:| void MapFunctions::levelHeight | ( | const Point & | startCoordinate, |
| const std::vector< Point > | levelArea | ||
| ) |
level area of map nodes.
| startcoordinate | the starting point whose height is used for levelling |
| levelArea | the area that is to be leveled. |
Definition at line 63 of file MapFunctions.cxx.
Here is the call graph for this function:
Here is the caller graph for this function:| void MapFunctions::loadMapFromFile | ( | const std::string & | fileName | ) |
Load Map from file.
Deserializes the Map class from a json file, creates a new Map and updates m_map.
| fileName | The file the map is stored in |
| ConfigurationError | when loading savegame file results in an error |
| CytopiaError | when savegame version is not compatible with current version of Cytopia |
Definition at line 684 of file MapFunctions.cxx.
Here is the call graph for this function:
Here is the caller graph for this function:| void MapFunctions::newMap | ( | bool | generateTerrain = true | ) |
Creates a new map object with terrain gen.
| generateTerrain | flat map or procedural |
Definition at line 671 of file MapFunctions.cxx.
Here is the call graph for this function:
Here is the caller graph for this function:| void MapFunctions::refreshVisibleMap | ( | ) |
Refresh the visible part of the map.
Definition at line 764 of file MapFunctions.cxx.
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Save Map to file.
Serializes the Map class to json and writes the data to a file.
| fileName | The file the map should be written to |
Definition at line 745 of file MapFunctions.cxx.
Here is the call graph for this function:
Here is the caller graph for this function:| bool MapFunctions::setTileID | ( | const std::string & | tileID, |
| const std::vector< Point > & | coordinates | ||
| ) |
Set the Tile ID Of multiple Node objects.
Also invokes all necessary texture updates (auto-tiling, slopes, ...)
| tileID | the new tileID to set |
| coordinates | a vector of Points where the tileIDs which should be set |
Definition at line 455 of file MapFunctions.cxx.
Here is the call graph for this function:| bool MapFunctions::setTileID | ( | const std::string & | tileID, |
| Point | coordinate | ||
| ) |
Set the Tile ID Of Node object.
Also invokes all necessary texture updates (auto-tiling, slopes, ...)
| tileID | the new tileID to set |
| coordinate | Point where the tileID which should be set |
Definition at line 378 of file MapFunctions.cxx.
Here is the call graph for this function:
Here is the caller graph for this function:| void MapFunctions::unHighlightNode | ( | const Point & | isoCoordinates | ) |
Sets a node to be unhighlighred.
This sets a node to be unhighlighted, which is done during rendering
| isoCoordinates | which node should be unhighlit. |
Definition at line 550 of file MapFunctions.cxx.
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Update all mapNodes.
Updates all mapNode and its adjacent tiles regarding height information, draws slopes for adjacent tiles and sets tiling for mapNode sprite if applicable
Definition at line 244 of file MapFunctions.cxx.
Here is the call graph for this function:
Here is the caller graph for this function:| bool MapFunctions::updateHeight | ( | Point | coordinate, |
| const bool | elevate | ||
| ) |
Change map node height.
| coordinate | the Point on the map node to change height |
| elevate | if set to true make node higher, otherwise lower. |
Definition at line 18 of file MapFunctions.cxx.
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Update the nodes and all affected node with the change.
| nodes | vector of coordinates to be updated. |
Definition at line 134 of file MapFunctions.cxx.
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Definition at line 168 of file MapFunctions.hxx.