diff options
| author | Stanislaw Halik <sthalik@misaki.pl> | 2022-12-02 14:44:32 +0100 |
|---|---|---|
| committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-12-02 14:46:59 +0100 |
| commit | 889d2c0c0933cf2fd9e068b1d2b79eb936b29b58 (patch) | |
| tree | cfc5f5b6e417c28482734645a69e0d49388fa5b3 /src/scenery.cpp | |
| parent | 8dbf450e34121358992e48212ae22cb7f5fc92f9 (diff) | |
src, serialize: work on pass mode
1. add one more value to the enum
2. serialize it properly in binary
3. serialize it as string in json
Diffstat (limited to 'src/scenery.cpp')
| -rw-r--r-- | src/scenery.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/scenery.cpp b/src/scenery.cpp index 4056f49f..28884ad8 100644 --- a/src/scenery.cpp +++ b/src/scenery.cpp @@ -29,11 +29,11 @@ scenery_ref::operator scenery_proto() const noexcept { return { atlas, frame }; scenery_ref::operator bool() const noexcept { return atlas != nullptr; } scenery::scenery() noexcept : scenery{none_tag_t{}} {} -scenery::scenery(none_tag_t) noexcept : passable{true} {} +scenery::scenery(none_tag_t) noexcept {} scenery::scenery(generic_tag_t, const anim_atlas& atlas, rotation r, frame_t frame, - bool passable, bool blocks_view, bool active, bool interactive) : + pass_mode pass, bool active, bool interactive) : frame{frame}, r{r}, type{scenery_type::generic}, - passable{passable}, blocks_view{blocks_view}, active{active}, + passability{pass}, active{active}, interactive{interactive} { fm_assert(r < rotation_COUNT); @@ -43,7 +43,8 @@ scenery::scenery(generic_tag_t, const anim_atlas& atlas, rotation r, frame_t fra scenery::scenery(door_tag_t, const anim_atlas& atlas, rotation r, bool is_open) : frame{frame_t(is_open ? 0 : atlas.group(r).frames.size()-1)}, r{r}, type{scenery_type::door}, - passable{is_open}, blocks_view{!is_open}, interactive{true} + passability{is_open ? pass_mode::pass : pass_mode::blocked}, + interactive{true} { fm_assert(r < rotation_COUNT); fm_assert(atlas.group(r).frames.size() >= 2); @@ -78,8 +79,12 @@ void scenery::update(float dt, const anim_atlas& anim) const std::int8_t dir = closing ? 1 : -1; const int fr = frame + dir*n; active = fr > 0 && fr < nframes-1; - passable = fr <= 0; - blocks_view = !passable; + if (fr <= 0) + passability = pass_mode::pass; + else if (fr >= nframes-1) + passability = pass_mode::blocked; + else + passability = pass_mode::see_through; frame = (frame_t)std::clamp(fr, 0, nframes-1); if (!active) delta = closing = 0; |
