1
0

plugin.cpp 875 B

1234567891011121314151617181920212223242526272829303132
  1. #include <cr.h>
  2. #include <entt/core/type_info.hpp>
  3. #include <entt/entity/registry.hpp>
  4. #include "types.h"
  5. template<typename Type>
  6. struct entt::type_index<Type> {};
  7. CR_EXPORT int cr_main(cr_plugin *ctx, cr_op operation) {
  8. switch (operation) {
  9. case CR_STEP:
  10. [ctx]() {
  11. auto &registry = *static_cast<entt::registry *>(ctx->userdata);
  12. const auto view = registry.view<position>();
  13. registry.assign(view.begin(), view.end(), velocity{1., 1.});
  14. registry.view<position, velocity>().each([](auto &pos, auto &vel) {
  15. pos.x += static_cast<int>(16 * vel.dx);
  16. pos.y += static_cast<int>(16 * vel.dy);
  17. });
  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. }