|
baba-is-auto
C++17 Baba Is You simulator
|
#include <Map.hpp>
Public Member Functions | |
| Map ()=default | |
| Default constructor. | |
| Map (std::size_t width, std::size_t height) | |
| void | Reset () |
| Resets map data. | |
| std::size_t | GetWidth () const |
| std::size_t | GetHeight () const |
| void | Load (std::string_view filename) |
| void | AddObject (std::size_t x, std::size_t y, ObjectType type) |
| void | AddObject (std::size_t x, std::size_t y, ObjectType type, Direction direction) |
| void | RemoveObject (std::size_t x, std::size_t y, ObjectType type) |
| bool | RemoveObject (ObjectID id) |
| bool | MoveObject (ObjectID id, std::size_t x, std::size_t y) |
| std::optional< Position > | GetPosition (ObjectID id) const |
| ObjectInstance * | GetInstance (ObjectID id) |
| const ObjectInstance * | GetInstance (ObjectID id) const |
| bool | SetDirection (ObjectID id, Direction direction) |
| std::optional< Direction > | GetDirection (ObjectID id) const |
| Object & | At (std::size_t x, std::size_t y) |
| const Object & | At (std::size_t x, std::size_t y) const |
| std::vector< Position > | GetPositions (ObjectType type) const |
Friends | |
| class | Game |
Map class.
This class represents map. A map is a board of the game.
|
default |
Default constructor.
| baba_is_auto::Map::Map | ( | std::size_t | width, |
| std::size_t | height | ||
| ) |
Constructs map with given width and height.
| width | The size of the width. |
| height | The size of the height. |
| void baba_is_auto::Map::AddObject | ( | std::size_t | x, |
| std::size_t | y, | ||
| ObjectType | type | ||
| ) |
Adds an object to the map.
| x | The x position. |
| y | The y position. |
| type | An object type to add to the map. |
| void baba_is_auto::Map::AddObject | ( | std::size_t | x, |
| std::size_t | y, | ||
| ObjectType | type, | ||
| Direction | direction | ||
| ) |
Adds an object with an initial facing direction.
| x | The x position. |
| y | The y position. |
| type | An object type to add to the map. |
| direction | An initial facing direction of the object. |
| Object & baba_is_auto::Map::At | ( | std::size_t | x, |
| std::size_t | y | ||
| ) |
Gets a writable object reference from the map.
| x | The x position. |
| y | The y position. |
| const Object & baba_is_auto::Map::At | ( | std::size_t | x, |
| std::size_t | y | ||
| ) | const |
Gets an object from the map.
| x | The x position. |
| y | The y position. |
Gets an object's facing direction.
| id | The stable ID of the object. |
| std::size_t baba_is_auto::Map::GetHeight | ( | ) | const |
Gets the height of the map.
| ObjectInstance * baba_is_auto::Map::GetInstance | ( | ObjectID | id | ) |
Gets an object by stable ID.
| id | The stable ID of the object. |
| const ObjectInstance * baba_is_auto::Map::GetInstance | ( | ObjectID | id | ) | const |
Gets an object by stable ID.
| id | The stable ID of the object. |
Gets an object's current position.
| id | The stable ID of the object. |
| std::vector< Position > baba_is_auto::Map::GetPositions | ( | ObjectType | type | ) | const |
Gets a list of icon positions.
| type | An object type to get a list of positions. |
| std::size_t baba_is_auto::Map::GetWidth | ( | ) | const |
Gets the width of the map.
| void baba_is_auto::Map::Load | ( | std::string_view | filename | ) |
Loads the data of the map.
| filename | The file name to load. |
| std::runtime_error | If the map data is invalid. |
| bool baba_is_auto::Map::MoveObject | ( | ObjectID | id, |
| std::size_t | x, | ||
| std::size_t | y | ||
| ) |
Moves an object by stable ID, preserving its state.
| id | The stable ID of the object to move. |
| x | The new x position. |
| y | The new y position. |
| bool baba_is_auto::Map::RemoveObject | ( | ObjectID | id | ) |
Removes an object by stable ID.
| id | The stable ID of the object to remove. |
| void baba_is_auto::Map::RemoveObject | ( | std::size_t | x, |
| std::size_t | y, | ||
| ObjectType | type | ||
| ) |
Removes an object from the map.
| x | The x position. |
| y | The y position. |
| type | An object type to remove from the map. |
| void baba_is_auto::Map::Reset | ( | ) |
Resets map data.
Updates an object's facing direction.
| id | The stable ID of the object. |
| direction | The new facing direction of the object. |
|
friend |