plugin.cpp 946 B

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