summaryrefslogtreecommitdiffhomepage
path: root/entity
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-02-23 17:22:32 +0100
committerStanislaw Halik <sthalik@misaki.pl>2023-02-23 17:22:32 +0100
commitecacc4e197eb8da6c311dad6e37330bcbbfef86e (patch)
tree4e9d6f70b93d2e53aa948eac6cd0aceff11f1fc5 /entity
parent25e36ab269096f11ebb2a1c9f6cc3ab93f830b44 (diff)
wip
Diffstat (limited to 'entity')
-rw-r--r--entity/accessor.hpp6
-rw-r--r--entity/chunk.cpp35
-rw-r--r--entity/types.hpp24
3 files changed, 3 insertions, 62 deletions
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<typename FieldType>
- [[nodiscard]] constexpr bool check_field_name() const noexcept;
+ [[nodiscard]] constexpr bool check_field_type() const noexcept;
template<typename Obj>
constexpr void do_asserts() const;
@@ -114,10 +114,10 @@ constexpr bool erased_accessor::check_name() const noexcept
}
template<typename FieldType>
-constexpr bool erased_accessor::check_field_name() const noexcept
+constexpr bool erased_accessor::check_field_type() const noexcept
{
constexpr auto name = name_of<FieldType>;
- return field_name == name;
+ return field_type == name;
}
template<typename Obj, typename FieldType>
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<scenery_ref> {
- static constexpr auto accessors()
- {
- using entity = Entity<scenery_ref>;
- using frame_t = scenery::frame_t;
- constexpr auto tuple = std::make_tuple(
- entity::type<scenery::frame_t>::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<frame_t>{0, !x.atlas ? frame_t(0) : frame_t(x.atlas->info().nframes)}; }
- },
- entity::type<Vector2b>::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<bool>::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<erased_field_type> struct type_of_erased_field;
-template<typename T> struct erased_field_type_v_ : std::integral_constant<erased_field_type, erased_field_type::DYNAMIC> {};
-
-#define FM_ERASED_FIELD_TYPE(TYPE, ENUM) \
- template<> struct erased_field_type_v_<TYPE> : std::integral_constant<erased_field_type, erased_field_type::ENUM> {}; \
- template<> struct type_of_erased_field<erased_field_type::ENUM> { 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