#pragma once #include "StarJson.hpp" #include "StarRect.hpp" #include "StarGameTypes.hpp" namespace Star { STAR_EXCEPTION(WorldStructureException, StarException); STAR_CLASS(WorldStructure); class WorldStructure { public: struct Overlay { Vec2F min; String image; bool fullbright; }; struct Block { Vec2I position; MaterialId materialId; // If the material here should not be removed on upgrade, this flag will be // set to true. bool residual; }; struct Object { Vec2I position; String name; Direction direction; Json parameters; // If an object is not designed to be removed on upgrade, this flag will be // set to true. bool residual; }; WorldStructure(); WorldStructure(String const& configPath); WorldStructure(Json const& store); Json configValue(String const& name) const; List const& backgroundOverlays() const; List const& foregroundOverlays() const; List const& backgroundBlocks() const; List const& foregroundBlocks() const; List const& objects() const; List flaggedBlocks(String const& flag) const; RectI region() const; Vec2I anchorPosition() const; void setAnchorPosition(Vec2I const& anchorPosition); void translate(Vec2I const& distance); Json store() const; private: struct BlockKey { bool anchor; bool foregroundBlock; MaterialId foregroundMat; bool foregroundResidual; bool backgroundBlock; MaterialId backgroundMat; bool backgroundResidual; String object; Direction objectDirection; Json objectParameters; bool objectResidual; StringList flags; }; RectI m_region; Vec2I m_anchorPosition; Json m_config; List m_backgroundOverlays; List m_foregroundOverlays; List m_backgroundBlocks; List m_foregroundBlocks; List m_objects; StringMap> m_flaggedBlocks; }; }