plugin.cpp 900 B

1234567891011121314151617181920212223242526272829303132
  1. #include <common/boxed_type.h>
  2. #include <common/empty.h>
  3. #include <cr.h>
  4. #include <entt/entity/registry.hpp>
  5. CR_EXPORT int cr_main(cr_plugin *ctx, cr_op operation) {
  6. constexpr auto count = 3;
  7. switch(operation) {
  8. case CR_STEP: {
  9. // forces things to break
  10. auto &registry = *static_cast<entt::registry *>(ctx->userdata);
  11. // forces the creation of the pool for the empty type
  12. static_cast<void>(registry.storage<test::empty>());
  13. const auto view = registry.view<test::boxed_int>();
  14. registry.insert(view.begin(), view.end(), test::empty{});
  15. registry.view<test::boxed_int, test::empty>().each([cnt = count](test::boxed_int &elem) {
  16. elem.value += cnt;
  17. });
  18. } break;
  19. case CR_CLOSE:
  20. case CR_LOAD:
  21. case CR_UNLOAD:
  22. // nothing to do here, this is only a test.
  23. break;
  24. }
  25. return 0;
  26. }