🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
891 B

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