plugin.cpp 981 B

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