Rehti MMORPG  1.0.0
Rehti MMORPG is a free and open source MMORPG game.
Map Class Reference

Static class representing the map of the game world. Map contains information about which tiles are accessible and which are not. It also contains information about the height of the tiles. It does not contain any information about the entities in the world. For that refer to GameWorld. More...

#include <Map.hpp>

Collaboration diagram for Map:
Collaboration graph

Static Public Member Functions

static void loadMap ()
 Loads the map information from generated assets. Currently loads the access map and height map information. More...
 
static std::vector< std::pair< int, int > > findPath (Coordinates start, Coordinates end)
 Finds a path from start to end. More...
 
static std::vector< std::pair< int, int > > findPathToRange (Coordinates start, Coordinates end, int range)
 Finds a path to some locations range. Can be used, for example, if the attack target is not in range, we can find a path to a location that is in range. More...
 
static std::optional< int > getHeight (int x, int y)
 Gives the height for the given (x, y) coordinates. More...
 
static const std::vector< std::vector< uint8_t > > & getAccessMap ()
 Get the access map. More...
 
static Coordinates getRandomCoordinates (const SpawnCoordinateBounds &coordinateBounds)
 Gets a random coordinate within the given bounds. More...
 
static Coordinates getRandomNeighbour (Coordinates coordinates, const SpawnCoordinateBounds &coordinateBounds)
 Gets a random neighbour of the given coordinates. More...
 

Static Private Attributes

static std::vector< std::vector< uint8_t > > accessMapM = {}
 
static std::vector< std::vector< int > > heightMapM = {}
 

Detailed Description

Static class representing the map of the game world. Map contains information about which tiles are accessible and which are not. It also contains information about the height of the tiles. It does not contain any information about the entities in the world. For that refer to GameWorld.

Member Function Documentation

◆ findPath()

std::vector< std::pair< int, int > > Map::findPath ( Coordinates  start,
Coordinates  end 
)
static

Finds a path from start to end.

Parameters
startStarting coordinates
endEnding coordinates
Returns
Vector of coordinates (x,y) that form the path. Empty vector if no path found.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ findPathToRange()

std::vector< std::pair< int, int > > Map::findPathToRange ( Coordinates  start,
Coordinates  end,
int  range 
)
static

Finds a path to some locations range. Can be used, for example, if the attack target is not in range, we can find a path to a location that is in range.

Parameters
startStarting coordinates
endEnding coordinates
rangeRange in tiles
Returns
Vector of coordinates (x,y) that form the path. Empty vector if no path found.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getAccessMap()

const std::vector< std::vector< uint8_t > > & Map::getAccessMap ( )
static

Get the access map.

Returns
access map
Here is the caller graph for this function:

◆ getHeight()

std::optional< int > Map::getHeight ( int  x,
int  y 
)
static

Gives the height for the given (x, y) coordinates.

Parameters
xX-coordinate
yY-coordinate
Returns
Height of the given coordinates wrapped in optional.
Here is the caller graph for this function:

◆ getRandomCoordinates()

Coordinates Map::getRandomCoordinates ( const SpawnCoordinateBounds coordinateBounds)
static

Gets a random coordinate within the given bounds.

Parameters
coordinateBounds
Returns
Coordinates
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getRandomNeighbour()

Coordinates Map::getRandomNeighbour ( Coordinates  coordinates,
const SpawnCoordinateBounds coordinateBounds 
)
static

Gets a random neighbour of the given coordinates.

Parameters
coordinates
coordinateBoundsBounds for the coordinates
Returns
Coordinates (Returns the given coordinates if no neighbours found/accessible)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ loadMap()

void Map::loadMap ( )
static

Loads the map information from generated assets. Currently loads the access map and height map information.

Note
Call this before using any other methods of this class.
Returns
Nothing
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ accessMapM

std::vector<std::vector<uint8_t> > Map::accessMapM = {}
inlinestaticprivate

◆ heightMapM

std::vector<std::vector<int> > Map::heightMapM = {}
inlinestaticprivate

The documentation for this class was generated from the following files: