summaryrefslogtreecommitdiffhomepage
path: root/src/scenery.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/scenery.hpp')
-rw-r--r--src/scenery.hpp36
1 files changed, 34 insertions, 2 deletions
diff --git a/src/scenery.hpp b/src/scenery.hpp
index cc8cc159..fadf4da8 100644
--- a/src/scenery.hpp
+++ b/src/scenery.hpp
@@ -8,23 +8,55 @@ struct anim_atlas;
enum class rotation : std::uint8_t {
N, NE, E, SE, S, SW, W, NW,
- COUNT,
+};
+
+constexpr inline rotation rotation_COUNT = rotation{8};
+
+enum class scenery_type : std::uint8_t {
+ none, generic, door,
};
struct scenery final
{
+ struct none_tag_t final {};
+ struct generic_tag_t final {};
+ struct door_tag_t final {};
+
static constexpr auto NO_FRAME = (std::uint16_t)-1;
+ static constexpr inline auto none = none_tag_t{};
+ static constexpr inline auto generic = generic_tag_t{};
+ static constexpr inline auto door = door_tag_t{};
using frame_t = std::uint16_t;
+ float delta = 0;
frame_t frame = NO_FRAME;
- rotation r = rotation::N;
+ rotation r : 3 = rotation::N;
+ std::uint8_t passable : 1 = false;
+ std::uint8_t active : 1 = false;
+ scenery_type type : 3 = scenery_type::none;
+
+ scenery() noexcept;
+ scenery(none_tag_t) noexcept;
+ scenery(generic_tag_t, rotation r, const anim_atlas& atlas, frame_t frame = 0);
+ 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 activate(const anim_atlas& atlas);
+ void update(float dt, const anim_atlas& anim);
};
struct scenery_proto final {
std::shared_ptr<anim_atlas> atlas;
scenery frame;
+ scenery_proto() noexcept;
+ explicit scenery_proto(scenery::none_tag_t) noexcept;
+ scenery_proto(const std::shared_ptr<anim_atlas>& atlas, const scenery& frame);
+ scenery_proto(scenery::generic_tag_t, rotation r, const std::shared_ptr<anim_atlas>& atlas, scenery::frame_t frame = 0);
+ scenery_proto(scenery::door_tag_t, rotation r, const std::shared_ptr<anim_atlas>& atlas, bool is_open = false);
+ scenery_proto& operator=(const scenery_proto&) noexcept;
+
operator bool() const noexcept;
};