summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-11-27 15:28:05 +0100
committerStanislaw Halik <sthalik@misaki.pl>2022-11-27 15:28:05 +0100
commitd2fcaad5425acb4a50138e793e3dcecc6600e4d3 (patch)
tree76fd32dd74a661d0ef30b65bba5d56d4f8b55881 /src
parentc145f1f806b49c1edd4b53aeeb7865c506d67949 (diff)
wip scenery list
Diffstat (limited to 'src')
-rw-r--r--src/scenery.cpp21
-rw-r--r--src/scenery.hpp15
2 files changed, 19 insertions, 17 deletions
diff --git a/src/scenery.cpp b/src/scenery.cpp
index eb90b598..03adc39e 100644
--- a/src/scenery.cpp
+++ b/src/scenery.cpp
@@ -12,7 +12,7 @@ scenery_proto::scenery_proto(const std::shared_ptr<anim_atlas>& atlas, const sce
{}
scenery_proto::scenery_proto(scenery::generic_tag_t, rotation r, const std::shared_ptr<anim_atlas>& atlas, bool passable, scenery::frame_t frame) :
- atlas{atlas}, frame{scenery::generic, r, *atlas, passable, frame}
+ atlas{atlas}, frame{scenery::generic, r, *atlas, frame, passable}
{}
scenery_proto::scenery_proto(scenery::door_tag_t, rotation r, const std::shared_ptr<anim_atlas>& atlas, bool is_open) :
@@ -39,19 +39,19 @@ 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(generic_tag_t, rotation r, const anim_atlas& atlas, bool passable, frame_t frame) :
- frame{frame}, r{r}, passable{passable}, type{scenery_type::generic}
+scenery::scenery(generic_tag_t, rotation r, const anim_atlas& atlas, frame_t frame,
+ bool passable, bool blocks_view, bool animated, bool active) :
+ frame{frame}, r{r}, passable{passable},
+ blocks_view{blocks_view}, active{active}, animated{animated},
+ type{scenery_type::generic}
{
fm_assert(frame < atlas.group(r).frames.size());
}
scenery::scenery(door_tag_t, rotation r, const anim_atlas& atlas, bool is_open) :
frame{frame_t(is_open ? 0 : atlas.group(r).frames.size()-1)},
- r{r}, passable{is_open}, type{scenery_type::door}
-{}
-
-scenery::scenery(float dt, frame_t frame, rotation r, bool passable, scenery_type type) :
- delta{dt}, frame{frame}, r{r}, passable{passable}, type{type}
+ r{r},
+ passable{is_open}, blocks_view{!is_open}, type{scenery_type::door}
{}
bool scenery::can_activate() const noexcept
@@ -63,10 +63,10 @@ bool scenery::can_activate() const noexcept
{
default:
return false;
- case scenery_type::door:
- return !active;
case scenery_type::object:
return true;
+ case scenery_type::door:
+ return !active;
}
#endif
}
@@ -96,6 +96,7 @@ void scenery::update(float dt, const anim_atlas& anim)
const int fr = frame + dir*n;
active = fr > 0 && fr < nframes-1;
passable = fr <= 0;
+ blocks_view = !passable;
frame = (frame_t)std::clamp(fr, 0, nframes-1);
if (!active)
delta = 0;
diff --git a/src/scenery.hpp b/src/scenery.hpp
index aabf7315..c1e2b5ea 100644
--- a/src/scenery.hpp
+++ b/src/scenery.hpp
@@ -31,17 +31,18 @@ struct scenery final
float delta = 0;
frame_t frame = NO_FRAME;
- rotation r : 3 = rotation::N;
- std::uint8_t passable : 1 = false;
- std::uint8_t active : 1 = false;
- std::uint8_t closing : 1 = true;
- scenery_type type : 2 = scenery_type::none;
+ rotation r : 3 = rotation::N;
+ std::uint8_t passable : 1 = false;
+ std::uint8_t blocks_view : 1 = false; // todo
+ std::uint8_t active : 1 = false;
+ std::uint8_t closing : 1 = false;
+ std::uint8_t animated : 1 = false; // todo
+ scenery_type type : 3 = scenery_type::none;
scenery() noexcept;
scenery(none_tag_t) noexcept;
- scenery(generic_tag_t, rotation r, const anim_atlas& atlas, bool passable = false, frame_t frame = 0);
+ scenery(generic_tag_t, rotation r, const anim_atlas& atlas, frame_t frame = 0, bool passable = false, bool blocks_view = false, bool animated = false, bool active = false);
scenery(door_tag_t, rotation r, const anim_atlas& atlas, bool is_open = false);
- scenery(float dt, frame_t frame, rotation r, bool passable, scenery_type type);
bool can_activate() const noexcept;
bool activate(const anim_atlas& atlas);