summaryrefslogtreecommitdiffhomepage
path: root/src/scenery.hpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-03-01 11:48:59 +0100
committerStanislaw Halik <sthalik@misaki.pl>2023-03-01 11:48:59 +0100
commit078c376b6255fb6fd24362b27862819444327265 (patch)
tree2c160075a1cd171a034fd475e82f5af5209291cf /src/scenery.hpp
parent51398dfed2c6615aada518d85bf2d6d04f307063 (diff)
src: make scenery aware of its chunk
Diffstat (limited to 'src/scenery.hpp')
-rw-r--r--src/scenery.hpp24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/scenery.hpp b/src/scenery.hpp
index 9e58f612..5fe2f043 100644
--- a/src/scenery.hpp
+++ b/src/scenery.hpp
@@ -10,6 +10,7 @@
namespace floormat {
+struct chunk;
struct anim_atlas;
enum class scenery_type : std::uint8_t {
@@ -82,15 +83,30 @@ struct scenery_proto final
};
struct scenery_ref final {
- std::shared_ptr<anim_atlas>& atlas;
- scenery& frame;
-
- scenery_ref(std::shared_ptr<anim_atlas>& atlas, scenery& frame) noexcept;
+ scenery_ref(struct chunk& c, std::size_t i) noexcept;
scenery_ref(const scenery_ref&) noexcept;
scenery_ref(scenery_ref&&) noexcept;
scenery_ref& operator=(const scenery_proto& proto) noexcept;
+
operator scenery_proto() const noexcept;
operator bool() const noexcept;
+
+ struct chunk& chunk() noexcept;
+ std::uint8_t index() const noexcept;
+
+ template<std::size_t N> std::tuple_element_t<N, scenery_ref>& get() & { if constexpr(N == 0) return atlas; else return frame; }
+ template<std::size_t N> std::tuple_element_t<N, scenery_ref>& get() && { if constexpr(N == 0) return atlas; else return frame; }
+
+ std::shared_ptr<anim_atlas>& atlas;
+ scenery& frame;
+
+private:
+ struct chunk* c;
+ std::uint8_t idx;
};
} // namespace floormat
+
+template<> struct std::tuple_size<floormat::scenery_ref> final : std::integral_constant<std::size_t, 2> {};
+template<> struct std::tuple_element<0, floormat::scenery_ref> final { using type = std::shared_ptr<floormat::anim_atlas>; };
+template<> struct std::tuple_element<1, floormat::scenery_ref> final { using type = floormat::scenery; };