From c81a7821034eba4bb7cdc1d68bade212b1aaff4d Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 22 Nov 2023 04:29:30 +0100 Subject: add wall passability --- serialize/wall-atlas.cpp | 6 ++++++ src/wall-atlas.hpp | 2 ++ test/json/wall-atlas-02_groups.json | 1 + test/wall-atlas.cpp | 1 + 4 files changed, 10 insertions(+) diff --git a/serialize/wall-atlas.cpp b/serialize/wall-atlas.cpp index e3d8f0a9..6d711d6b 100644 --- a/serialize/wall-atlas.cpp +++ b/serialize/wall-atlas.cpp @@ -4,6 +4,7 @@ #include "corrade-string.hpp" #include "compat/exception.hpp" #include "loader/loader.hpp" +#include "pass-mode.hpp" #include #include #include @@ -113,6 +114,9 @@ Direction read_direction_metadata(const json& jroot, Direction_ dir) val.top.pixel_size = val.top.pixel_size.flipped(); + if (jdir.contains("pass-mode")) + val.passability = jdir["pass-mode"]; + return val; } @@ -180,6 +184,8 @@ void write_group_metadata(json& jgroup, const Group& val) void write_direction_metadata(json& jdir, const Direction& dir) { + jdir["pass-mode"] = dir.passability; + for (auto [s_, memfn, tag] : Direction::groups) { std::string_view s = {s_.data(), s_.size()}; diff --git a/src/wall-atlas.hpp b/src/wall-atlas.hpp index d7ae5a46..6a0abf15 100644 --- a/src/wall-atlas.hpp +++ b/src/wall-atlas.hpp @@ -1,6 +1,7 @@ #pragma once #include "compat/defs.hpp" #include "src/rotation.hpp" +#include "src/pass-mode.hpp" #include #include #include @@ -49,6 +50,7 @@ struct Direction Group wall, overlay, side, top; Group corner_L, corner_R; + pass_mode passability = pass_mode::blocked; static constexpr inline member_tuple groups[] = { { "wall"_s, &Direction::wall, Tag::wall }, diff --git a/test/json/wall-atlas-02_groups.json b/test/json/wall-atlas-02_groups.json index 58ec0194..e3ff3fb3 100644 --- a/test/json/wall-atlas-02_groups.json +++ b/test/json/wall-atlas-02_groups.json @@ -20,6 +20,7 @@ "n": { }, "w": { + "pass-mode": "shoot-through", "wall": { "default-tint": false, "offset": 0, diff --git a/test/wall-atlas.cpp b/test/wall-atlas.cpp index 84b79094..7cd922ae 100644 --- a/test/wall-atlas.cpp +++ b/test/wall-atlas.cpp @@ -74,6 +74,7 @@ void test_read_groups(StringView filename) fm_assert(read_direction_metadata(jroot, Direction_::S).is_empty()); const auto dir = read_direction_metadata(jroot, Direction_::W); + fm_assert(dir.passability == pass_mode::shoot_through); fm_assert(dir.wall.pixel_size == Vector2ui{} ); fm_assert(dir.wall.default_tint == false ); fm_assert(dir.wall.mirrored == group_defaults.mirrored ); -- cgit v1.2.3