From ecacc4e197eb8da6c311dad6e37330bcbbfef86e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 23 Feb 2023 17:22:32 +0100 Subject: wip --- entity/accessor.hpp | 6 +++--- entity/chunk.cpp | 35 ----------------------------------- entity/types.hpp | 24 ------------------------ 3 files changed, 3 insertions(+), 62 deletions(-) delete mode 100644 entity/chunk.cpp (limited to 'entity') diff --git a/entity/accessor.hpp b/entity/accessor.hpp index 84c599c2..cc777e5d 100644 --- a/entity/accessor.hpp +++ b/entity/accessor.hpp @@ -69,7 +69,7 @@ struct erased_accessor final { [[nodiscard]] constexpr bool check_name() const noexcept; template - [[nodiscard]] constexpr bool check_field_name() const noexcept; + [[nodiscard]] constexpr bool check_field_type() const noexcept; template constexpr void do_asserts() const; @@ -114,10 +114,10 @@ constexpr bool erased_accessor::check_name() const noexcept } template -constexpr bool erased_accessor::check_field_name() const noexcept +constexpr bool erased_accessor::check_field_type() const noexcept { constexpr auto name = name_of; - return field_name == name; + return field_type == name; } template diff --git a/entity/chunk.cpp b/entity/chunk.cpp deleted file mode 100644 index f7b9aadc..00000000 --- a/entity/chunk.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "entity/metadata.hpp" -#include "entity/accessor.hpp" -#include "src/scenery.hpp" -#include "src/anim-atlas.hpp" -#include "src/tile-defs.hpp" - -namespace floormat::entities { - -template<> struct entity_accessors { - static constexpr auto accessors() - { - using entity = Entity; - using frame_t = scenery::frame_t; - constexpr auto tuple = std::make_tuple( - entity::type::field{"frame"_s, - [](const scenery_ref& x) { return x.frame.frame; }, - [](scenery_ref& x, frame_t value) { x.frame.frame = value; }, - [](const scenery_ref& x) { return constraints::range{0, !x.atlas ? frame_t(0) : frame_t(x.atlas->info().nframes)}; } - }, - entity::type::field{"offset"_s, - [](const scenery_ref& x) { return x.frame.offset; }, - [](scenery_ref& x, Vector2b value) { x.frame.offset = value; }, - constantly(constraints::range{Vector2b(iTILE_SIZE2/-2), Vector2b(iTILE_SIZE2/2)}) - }, - // todo pass_mode enum - entity::type::field{"interactive"_s, - [](const scenery_ref& x) { return x.frame.interactive; }, - [](scenery_ref& x, bool value) { x.frame.interactive = value; } - } - ); - return tuple; - } -}; - -} // namespace floormat::entities diff --git a/entity/types.hpp b/entity/types.hpp index 2987f2e8..d2cf5542 100644 --- a/entity/types.hpp +++ b/entity/types.hpp @@ -4,30 +4,6 @@ namespace floormat::entities { -enum class erased_field_type : unsigned { - none, - string, - u8, u16, u32, u64, s8, s16, s32, s64, - user_type_start, - MAX = (1u << 31) - 1u, - DYNAMIC = (std::uint32_t)-1, -}; -template struct type_of_erased_field; -template struct erased_field_type_v_ : std::integral_constant {}; - -#define FM_ERASED_FIELD_TYPE(TYPE, ENUM) \ - template<> struct erased_field_type_v_ : std::integral_constant {}; \ - template<> struct type_of_erased_field { using type = TYPE; } -FM_ERASED_FIELD_TYPE(std::uint8_t, u8); -FM_ERASED_FIELD_TYPE(std::uint16_t, u16); -FM_ERASED_FIELD_TYPE(std::uint32_t, u32); -FM_ERASED_FIELD_TYPE(std::uint64_t, u64); -FM_ERASED_FIELD_TYPE(std::int8_t, s8); -FM_ERASED_FIELD_TYPE(std::int16_t, s16); -FM_ERASED_FIELD_TYPE(std::int32_t, s32); -FM_ERASED_FIELD_TYPE(std::int64_t, s64); -FM_ERASED_FIELD_TYPE(StringView, string); -#undef FM_ERASED_FIELD_TYPE } // namespace floormat::entities -- cgit v1.2.3