![]() |
Peoplemon
0.1.0
Peoplemon 3 game source documentation
|
The primary map class that represents a usable map in the game. More...
#include <Map.hpp>
Public Member Functions | |
Map () | |
Creates an empty Map. More... | |
virtual | ~Map () |
Destroy the Map. More... | |
bool | loadDev (std::istream &input) |
Loads the map from the given file. Will try to determine if the extension or path need to be added in order to support how map names used to be entered. Loads the json format. More... | |
bool | loadProd (bl::serial::binary::InputStream &input) |
Loads the map from the given file. Will try to determine if the extension or path need to be added in order to support how map names used to be entered. Loads the binary format. More... | |
bool | save (const std::string &file) |
Saves the map to the given file. The path should be relative to the maps directory and include the .map extension. More... | |
bool | saveBundle (bl::serial::binary::OutputStream &output, bl::resource::bundle::FileHandlerContext &ctx) const |
Saves the data from this object to the given bundle and registers dependency files. More... | |
bool | enter (system::Systems &systems, std::uint16_t spawnId, const std::string &prevMap, const bl::tmap::Position &prevPlayerPos) |
Initializes runtime data structures and spawns entities into the game. Also runs the on-load script. More... | |
void | exit (system::Systems &systems, const std::string &newMap) |
Removes spawned entities and runs the on-unload script. More... | |
void | setupCamera (system::Systems &systems) |
Configures the game camera for the player in the map. More... | |
const std::string & | name () const |
Returns the name of the map. More... | |
Weather & | weatherSystem () |
Returns a reference to the weather system in this map. More... | |
LightingSystem & | lightingSystem () |
Returns a reference to the lighting system in this map. More... | |
const sf::Vector2i & | sizeTiles () const |
Returns the size of the map in tiles. More... | |
sf::Vector2f | sizePixels () const |
Returns the size of the map in pixels. More... | |
std::uint8_t | levelCount () const |
Returns the number of levels in the map. More... | |
void | update (float dt) |
Updates internal logic over the elapsed time. More... | |
bool | contains (const bl::tmap::Position &position) const |
Returns whether or not the map contains the given position. More... | |
bl::tmap::Position | adjacentTile (const bl::tmap::Position &pos, bl::tmap::Direction dir) const |
Returns the adjacent position to the given position when moving in the given direction. Does not take into account collisions. More... | |
bool | movePossible (const bl::tmap::Position &position, bl::tmap::Direction dir) const |
Returns whether or not a particular movement is possible. Does not take into account entities blocking the way. More... | |
bool | isLedgeHop (const bl::tmap::Position &position, bl::tmap::Direction dir) const |
Test whether the given movement will be a ledge hop or not. More... | |
virtual void | observe (const event::EntityMoved &moveEvent) override |
Event listener for moving entities. Used to trigger map events. More... | |
bool | interact (bl::ecs::Entity interactor, const bl::tmap::Position &interactPos) |
Lets entities interact with the map itself. This is called by the Interaction system. More... | |
const CatchRegion * | getCatchRegion (const bl::tmap::Position &position) const |
Returns the catch region at the given position if the position is on a catch tile. More... | |
bool | canFlyFromHere () const |
Returns whether or not the player can fly from this map. More... | |
const bl::tmap::Position * | getSpawnPosition (unsigned int spawnId) const |
Returns the position of the given player spawn, or nullptr if not found. More... | |
const std::string & | getLocationName (const bl::tmap::Position &pos) const |
Returns the name of the town or route at the given position. More... | |
float | getDepthForPosition (unsigned int level, unsigned int y, int layer=-1) const |
Computes the depth to use at the given y position, taking into account the map size, layer count, and layer types. More... | |
float | getMinDepth () const |
Returns the maximum depth possible for this map. Maximum is always 0.f. Minimum is negative, so 'higher' positions will have lower depths than deeper positions. More... | |
bl::rc::SceneRef | getScene () |
Returns the scene for this map. More... | |
bl::rc::lgt::Scene2DLighting & | getSceneLighting () |
Returns the scene lighting for this map. Only valid after enter() is called. More... | |
void | setupEntityPosition (bl::ecs::Entity entity) |
Performs the final setup of the position components for the given entity. Must already have a bl::tmap::Position and bl::com::Transform2D component. More... | |
Static Public Member Functions | |
static std::string | getMapFile (const std::string &partialFile) |
Returns the full path to the map file from the given partial file. Accounts for missing extension. More... | |
static const std::vector< Town > & | FlyMapTowns () |
Returns the set of towns that can be flown to. More... | |
Protected Member Functions | |
void | clear () |
void | finishLoad () |
void | triggerAnimation (const bl::tmap::Position &position) |
Town * | getTown (const glm::i32vec2 &pos) |
void | enterTown (Town *town) |
void | prepareRender () |
void | cleanupRender () |
void | setupLevel (unsigned int level) |
void | setupLayer (unsigned int level, unsigned int layer) |
void | setupTile (unsigned int level, unsigned int layer, const sf::Vector2u &pos) |
Static Protected Member Functions | |
static void | loadFlymapTowns () |
Protected Attributes | |
std::string | nameField |
std::string | loadScriptField |
std::string | unloadScriptField |
std::string | playlistField |
Weather::Type | weatherField |
std::vector< LayerSet > | levels |
std::string | tilesetField |
std::unordered_map< std::uint16_t, Spawn > | spawns |
std::vector< CharacterSpawn > | characterField |
std::vector< Item > | itemsField |
std::vector< Event > | eventsField |
LightingSystem | lighting |
std::vector< CatchRegion > | catchRegionsField |
bl::ctr::Vector2D< LevelTransition > | transitionField |
std::vector< Town > | towns |
bl::ctr::Vector2D< std::uint8_t > | townTiles |
system::Systems * | systems |
Town | defaultTown |
Town * | currentTown |
sf::Vector2i | size |
bl::resource::Ref< Tileset > | tileset |
Weather | weather |
std::unique_ptr< bl::script::Script > | onEnterScript |
std::unique_ptr< bl::script::Script > | onExitScript |
bl::ctr::Grid< const Event * > | eventRegions |
bool | isWorldMap |
bl::audio::AudioSystem::Handle | playlistHandle |
bool | activated |
bl::rc::SceneRef | scene |
std::list< RenderLevel > | renderLevels |
Static Protected Attributes | |
static std::vector< Town > | flymapTowns |
Friends | |
struct | bl::serial::SerializableObject< Map > |
The primary map class that represents a usable map in the game.
bl::tmap::Position core::map::Map::adjacentTile | ( | const bl::tmap::Position & | pos, |
bl::tmap::Direction | dir | ||
) | const |
Returns the adjacent position to the given position when moving in the given direction. Does not take into account collisions.
pos | The position that is being moved from |
dir | The direction that the movement is going |
bool core::map::Map::canFlyFromHere | ( | ) | const |
bool core::map::Map::contains | ( | const bl::tmap::Position & | position | ) | const |
bool core::map::Map::enter | ( | system::Systems & | systems, |
std::uint16_t | spawnId, | ||
const std::string & | prevMap, | ||
const bl::tmap::Position & | prevPlayerPos | ||
) |
Initializes runtime data structures and spawns entities into the game. Also runs the on-load script.
systems | The primary game systems |
spawnId | The spawn to place the player at |
prevMap | The name of the map coming from |
prevPlayerPos | Used to spawn the player when coming back from a map or loading save |
void core::map::Map::exit | ( | system::Systems & | systems, |
const std::string & | newMap | ||
) |
|
static |
const CatchRegion * core::map::Map::getCatchRegion | ( | const bl::tmap::Position & | position | ) | const |
float core::map::Map::getDepthForPosition | ( | unsigned int | level, |
unsigned int | y, | ||
int | layer = -1 |
||
) | const |
Computes the depth to use at the given y position, taking into account the map size, layer count, and layer types.
level | The level of the position to compute the depth for |
y | The y coordinate of the position to compute the depth for |
layer | The index of the layer to compute the depth for. -1 is for entities |
const std::string & core::map::Map::getLocationName | ( | const bl::tmap::Position & | pos | ) | const |
|
static |
float core::map::Map::getMinDepth | ( | ) | const |
|
inline |
|
inline |
const bl::tmap::Position * core::map::Map::getSpawnPosition | ( | unsigned int | spawnId | ) | const |
|
protected |
bool core::map::Map::interact | ( | bl::ecs::Entity | interactor, |
const bl::tmap::Position & | interactPos | ||
) |
bool core::map::Map::isLedgeHop | ( | const bl::tmap::Position & | position, |
bl::tmap::Direction | dir | ||
) | const |
std::uint8_t core::map::Map::levelCount | ( | ) | const |
LightingSystem & core::map::Map::lightingSystem | ( | ) |
bool core::map::Map::loadDev | ( | std::istream & | input | ) |
Loads the map from the given file. Will try to determine if the extension or path need to be added in order to support how map names used to be entered. Loads the json format.
input | Stream to load the map from |
bool core::map::Map::loadProd | ( | bl::serial::binary::InputStream & | input | ) |
Loads the map from the given file. Will try to determine if the extension or path need to be added in order to support how map names used to be entered. Loads the binary format.
input | Stream to load the map from |
bool core::map::Map::movePossible | ( | const bl::tmap::Position & | position, |
bl::tmap::Direction | dir | ||
) | const |
const std::string & core::map::Map::name | ( | ) | const |
|
overridevirtual |
bool core::map::Map::save | ( | const std::string & | file | ) |
bool core::map::Map::saveBundle | ( | bl::serial::binary::OutputStream & | output, |
bl::resource::bundle::FileHandlerContext & | ctx | ||
) | const |
void core::map::Map::setupCamera | ( | system::Systems & | systems | ) |
void core::map::Map::setupEntityPosition | ( | bl::ecs::Entity | entity | ) |
|
protected |
|
protected |
|
protected |
sf::Vector2f core::map::Map::sizePixels | ( | ) | const |
const sf::Vector2i & core::map::Map::sizeTiles | ( | ) | const |
|
protected |
void core::map::Map::update | ( | float | dt | ) |
Weather & core::map::Map::weatherSystem | ( | ) |
|
protected |
|
protected |
|
protected |
|
staticprotected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |