another_module.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 another_module_int_type() {
  15. entt::registry registry;
  16. (void)registry.type<char>();
  17. (void)registry.type<double>();
  18. (void)registry.type<const int>();
  19. (void)registry.type<const char>();
  20. (void)registry.type<float>();
  21. return registry.type<int>();
  22. }
  23. LIB_EXPORT typename entt::component another_module_char_type() {
  24. entt::registry registry;
  25. (void)registry.type<int>();
  26. (void)registry.type<float>();
  27. (void)registry.type<const char>();
  28. (void)registry.type<const int>();
  29. (void)registry.type<double>();
  30. return registry.type<char>();
  31. }
  32. LIB_EXPORT void assign_velocity(int vel, entt::registry &registry) {
  33. for(auto entity: registry.view<position>()) {
  34. registry.assign<velocity>(entity, vel, vel);
  35. }
  36. }
  37. LIB_EXPORT void trigger_an_event(int payload, entt::dispatcher &dispatcher) {
  38. dispatcher.trigger<an_event>(payload);
  39. }
  40. LIB_EXPORT void emit_an_event(int payload, test_emitter &emitter) {
  41. emitter.publish<an_event>(payload);
  42. }