Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/game/StarWorldStructure.hpp
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2023-06-20 14:33:09 +1000
committerKae <80987908+Novaenia@users.noreply.github.com>2023-06-20 14:33:09 +1000
commit6352e8e3196f78388b6c771073f9e03eaa612673 (patch)
treee23772f79a7fbc41bc9108951e9e136857484bf4 /source/game/StarWorldStructure.hpp
parent6741a057e5639280d85d0f88ba26f000baa58f61 (diff)
everything everywhere
all at once
Diffstat (limited to 'source/game/StarWorldStructure.hpp')
-rw-r--r--source/game/StarWorldStructure.hpp96
1 files changed, 96 insertions, 0 deletions
diff --git a/source/game/StarWorldStructure.hpp b/source/game/StarWorldStructure.hpp
new file mode 100644
index 0000000..343ab20
--- /dev/null
+++ b/source/game/StarWorldStructure.hpp
@@ -0,0 +1,96 @@
+#ifndef STAR_WORLD_STRUCTURE_HPP
+#define STAR_WORLD_STRUCTURE_HPP
+
+#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<Overlay> const& backgroundOverlays() const;
+ List<Overlay> const& foregroundOverlays() const;
+
+ List<Block> const& backgroundBlocks() const;
+ List<Block> const& foregroundBlocks() const;
+
+ List<Object> const& objects() const;
+
+ List<Vec2I> 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<Overlay> m_backgroundOverlays;
+ List<Overlay> m_foregroundOverlays;
+
+ List<Block> m_backgroundBlocks;
+ List<Block> m_foregroundBlocks;
+
+ List<Object> m_objects;
+ StringMap<List<Vec2I>> m_flaggedBlocks;
+};
+
+}
+
+#endif