#pragma once #include #include #include #include "dinkyecs.hpp" #define ENROLL_COMPONENT(COMPONENT, ...) \ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(COMPONENT, __VA_ARGS__); \ template <> struct NameOf { \ static constexpr const char *name = #COMPONENT; \ }; namespace components { using namespace nlohmann; template struct NameOf; using ReflFuncSignature = std::function; using ComponentMap = std::unordered_map; template void enroll(ComponentMap &m) { m[NameOf::name] = [](DinkyECS::World& world, DinkyECS::Entity ent, nlohmann::json &j) { COMPONENT c; from_json(j, c); world.set(ent, c); }; } void configure_entity(const ComponentMap& component_map, DinkyECS::World& world, DinkyECS::Entity ent, json& data); }