#pragma once #include "pass-mode.hpp" #include "tile-defs.hpp" #include "rotation.hpp" #include "object.hpp" #include #include #include #include #include namespace floormat { template struct [[maybe_unused]] overloaded : Ts... { using Ts::operator()...; }; template overloaded(Ts...) -> overloaded; class chunk; class anim_atlas; class world; enum class scenery_type : unsigned char { none, generic, door, }; struct generic_scenery_proto { unsigned char active : 1 = false; unsigned char interactive : 1 = false; bool operator==(const generic_scenery_proto& p) const; enum scenery_type scenery_type() const; }; struct door_scenery_proto { unsigned char active : 1 = false; unsigned char interactive : 1 = true; unsigned char closing : 1 = false; bool operator==(const door_scenery_proto& p) const; enum scenery_type scenery_type() const; }; using scenery_proto_variants = std::variant; struct scenery_proto : object_proto { scenery_proto_variants subtype; scenery_proto() noexcept; scenery_proto(const scenery_proto&) noexcept; ~scenery_proto() noexcept override; scenery_proto& operator=(const scenery_proto&) noexcept; bool operator==(const object_proto& proto) const override; explicit operator bool() const; enum scenery_type scenery_type() const; }; struct scenery; struct generic_scenery { unsigned char active : 1 = false; unsigned char interactive : 1 = false; void update(scenery& sc, size_t i, Ns dt); Vector2 ordinal_offset(const scenery& sc, Vector2b offset) const; bool can_activate(const scenery& sc, size_t i) const; bool activate(scenery& sc, size_t i); enum scenery_type scenery_type() const; explicit operator generic_scenery_proto() const; generic_scenery(object_id id, class chunk& c, const generic_scenery_proto& p); }; struct door_scenery { unsigned char closing : 1 = false; unsigned char active : 1 = false; unsigned char interactive : 1 = false; void update(scenery& sc, size_t i, Ns dt); Vector2 ordinal_offset(const scenery& sc, Vector2b offset) const; bool can_activate(const scenery& sc, size_t i) const; bool activate(scenery& sc, size_t i); enum scenery_type scenery_type() const; explicit operator door_scenery_proto() const; door_scenery(object_id id, class chunk& c, const door_scenery_proto& p); }; using scenery_variants = std::variant; struct scenery final : object { scenery_variants subtype; void update(size_t i, Ns dt) override; Vector2 ordinal_offset(Vector2b offset) const override; float depth_offset() const override; bool can_activate(size_t i) const override; bool activate(size_t i) override; object_type type() const noexcept override; explicit operator scenery_proto() const; enum scenery_type scenery_type() const; static scenery_variants subtype_from_proto(object_id id, class chunk& c, const scenery_proto_variants& variants); static scenery_variants subtype_from_scenery_type(object_id id, class chunk& c, enum scenery_type type); private: friend class world; scenery(object_id id, class chunk& c, const scenery_proto& proto); }; template<> struct object_type_ : std::integral_constant {}; template<> struct object_type_ : std::integral_constant {}; } // namespace floormat