#define CR_HOST #include #include #include #include "proxy.h" #include "types.h" proxy::proxy(entt::registry &ref) : registry{&ref} {} void proxy::for_each(void(*cb)(position &, velocity &)) { registry->view().each(cb); } void proxy::assign(velocity vel) { for(auto entity: registry->view()) { registry->assign(entity, vel); } } TEST(Lib, Registry) { entt::registry registry; proxy handler{registry}; for(auto i = 0; i < 3; ++i) { const auto entity = registry.create(); registry.assign(entity, i, i); } cr_plugin ctx; ctx.userdata = &handler; cr_plugin_load(ctx, PLUGIN); cr_plugin_update(ctx); ASSERT_EQ(registry.size(), registry.size()); registry.view().each([](auto entity, auto &position) { ASSERT_EQ(position.x, entt::to_integral(entity) + 16); ASSERT_EQ(position.y, entt::to_integral(entity) + 16); }); cr_plugin_close(ctx); }