Rehti MMORPG  1.0.0
Rehti MMORPG is a free and open source MMORPG game.
Map.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <cstdint>
4 #include <iostream>
5 #include <optional>
6 #include <vector>
7 
8 #include "Coordinates.hpp"
9 #include "RehtiReader.hpp"
10 
16 class Map
17 {
18 public:
24  static void loadMap();
25 
32  static std::vector<std::pair<int, int>> findPath(Coordinates start, Coordinates end);
33 
41  static std::vector<std::pair<int, int>> findPathToRange(Coordinates start, Coordinates end, int range);
42 
49  static std::optional<int> getHeight(int x, int y);
50 
56  static const std::vector<std::vector<uint8_t>>& getAccessMap();
57 
64  static Coordinates getRandomCoordinates(const SpawnCoordinateBounds& coordinateBounds);
65 
73  static Coordinates getRandomNeighbour(Coordinates coordinates, const SpawnCoordinateBounds& coordinateBounds);
74 
75 private:
76  inline static std::vector<std::vector<uint8_t>> accessMapM = {};
77  inline static std::vector<std::vector<int>> heightMapM = {};
78 };
Static class representing the map of the game world. Map contains information about which tiles are a...
Definition: Map.hpp:17
static void loadMap()
Loads the map information from generated assets. Currently loads the access map and height map inform...
Definition: Map.cpp:6
static const std::vector< std::vector< uint8_t > > & getAccessMap()
Get the access map.
Definition: Map.cpp:60
static std::optional< int > getHeight(int x, int y)
Gives the height for the given (x, y) coordinates.
Definition: Map.cpp:50
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,...
Definition: Map.cpp:18
static std::vector< std::pair< int, int > > findPath(Coordinates start, Coordinates end)
Finds a path from start to end.
Definition: Map.cpp:13
static std::vector< std::vector< uint8_t > > accessMapM
Definition: Map.hpp:76
static Coordinates getRandomCoordinates(const SpawnCoordinateBounds &coordinateBounds)
Gets a random coordinate within the given bounds.
Definition: Map.cpp:65
static std::vector< std::vector< int > > heightMapM
Definition: Map.hpp:77
static Coordinates getRandomNeighbour(Coordinates coordinates, const SpawnCoordinateBounds &coordinateBounds)
Gets a random neighbour of the given coordinates.
Definition: Map.cpp:104
Struct for coordinates.
Definition: Coordinates.hpp:7
Contains the spawn coordinate bounds for a character.
Definition: CharacterReader.hpp:10