#ifndef MAP_H_D95D6D47 #define MAP_H_D95D6D47 #include #include #include #include #include "vector.h" #include "step_type.h" #include "sprite.h" struct Tile { unsigned int id = 0; bool flipHorizontal = false; bool flipVertical = false; bool blocked = false; StepType step = StepType::none; CharacterMedium medium = CharacterMedium::Normal; }; struct Prototype { std::string name; vec2i pos; vec2i collisionOffset {-7, -8}; vec2i collisionSize {14, 8}; std::string animationFilename; std::string animName; Direction dir = Direction::down; std::string interactionScript; std::string bumpPlayerScript; std::string backgroundScript; bool shadow = false; bool wander = false; int movementSpeed = -1; std::string enclosureZone; bool masked = false; MirrorType mirrorType = MirrorType::None; int mirrorAxis = 0; std::string spriteToMirror; bool floating = false; }; struct Trigger { std::string name; vec2i pos; vec2i size; std::string script; }; struct Zone { vec2i ul; vec2i dr; }; class Map { public: explicit Map(std::string_view name); const std::string& getName() const { return name_; } const vec2i& getMapSize() const { return mapSize_; } const vec2i& getTileSize() const { return tileSize_; } const std::vector>& getUpperLayers() const { return upperLayers_; } const std::vector>& getLowerLayers() const { return lowerLayers_; } const std::string& getTilesetFilename() const { return tilesetFilename_; } int getTilesetColumns() const { return tilesetColumns_; } bool isBlocked(int x, int y) const; StepType getStepType(int x, int y) const; CharacterMedium getMedium(int x, int y) const; const std::vector& getPrototypes() const { return prototypes_; } const vec2i& getWarpPoint(std::string_view name) const { return warpPoints_.find(name)->second; } const std::vector& getTriggers() const { return triggers_; } const Zone& getZone(const std::string& name) const { return zones_.at(name); } bool hasMusic() const { return !music_.empty(); } const std::string& getMusic() const { return music_; } const std::string& getMaskZone() const { return maskZone_; } bool hasExitArea() const { return hasExitArea_; } private: std::string name_; vec2i mapSize_; vec2i tileSize_; std::vector> upperLayers_; std::vector> lowerLayers_; std::string tilesetFilename_; int tilesetColumns_; std::vector prototypes_; std::map> warpPoints_; std::vector triggers_; std::map zones_; std::string music_; std::string maskZone_; bool hasExitArea_ = false; }; #endif /* end of include guard: MAP_H_D95D6D47 */