a_module.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #include <entt/entity/registry.hpp>
  2. #include <entt/signal/dispatcher.hpp>
  3. #include <entt/signal/emitter.hpp>
  4. #include "types.h"
  5. #ifndef LIB_EXPORT
  6. #if defined _WIN32 || defined __CYGWIN__
  7. #define LIB_EXPORT __declspec(dllexport)
  8. #elif defined __GNUC__
  9. #define LIB_EXPORT __attribute__((visibility("default")))
  10. #else
  11. #define LIB_EXPORT
  12. #endif
  13. #endif
  14. LIB_EXPORT typename entt::component a_module_int_type() {
  15. entt::registry registry;
  16. (void)registry.type<double>();
  17. (void)registry.type<float>();
  18. return registry.type<int>();
  19. }
  20. LIB_EXPORT typename entt::component a_module_char_type() {
  21. entt::registry registry;
  22. (void)registry.type<double>();
  23. (void)registry.type<float>();
  24. return registry.type<char>();
  25. }
  26. LIB_EXPORT void update_position(int delta, entt::registry &registry) {
  27. registry.view<position, velocity>().each([delta](auto &pos, auto &vel) {
  28. pos.x += delta * vel.dx;
  29. pos.y += delta * vel.dy;
  30. });
  31. }
  32. LIB_EXPORT void trigger_another_event(entt::dispatcher &dispatcher) {
  33. dispatcher.trigger<another_event>();
  34. }
  35. LIB_EXPORT void emit_another_event(test_emitter &emitter) {
  36. emitter.publish<another_event>();
  37. }