another_module.cpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #include <entt/entity/registry.hpp>
  2. #include <entt/meta/factory.hpp>
  3. #include <entt/signal/dispatcher.hpp>
  4. #include <entt/signal/emitter.hpp>
  5. #include "types.h"
  6. #ifndef LIB_EXPORT
  7. #if defined _WIN32 || defined __CYGWIN__
  8. #define LIB_EXPORT __declspec(dllexport)
  9. #elif defined __GNUC__
  10. #define LIB_EXPORT __attribute__((visibility("default")))
  11. #else
  12. #define LIB_EXPORT
  13. #endif
  14. #endif
  15. LIB_EXPORT typename entt::component another_module_int_type() {
  16. entt::registry registry;
  17. (void)registry.type<char>();
  18. (void)registry.type<double>();
  19. (void)registry.type<const int>();
  20. (void)registry.type<const char>();
  21. (void)registry.type<float>();
  22. return registry.type<int>();
  23. }
  24. LIB_EXPORT typename entt::component another_module_char_type() {
  25. entt::registry registry;
  26. (void)registry.type<int>();
  27. (void)registry.type<float>();
  28. (void)registry.type<const char>();
  29. (void)registry.type<const int>();
  30. (void)registry.type<double>();
  31. return registry.type<char>();
  32. }
  33. LIB_EXPORT void assign_velocity(int vel, entt::registry &registry) {
  34. for(auto entity: registry.view<position>()) {
  35. registry.assign<velocity>(entity, vel, vel);
  36. }
  37. }
  38. LIB_EXPORT void trigger_an_event(int payload, entt::dispatcher &dispatcher) {
  39. dispatcher.trigger<an_event>(payload);
  40. }
  41. LIB_EXPORT void emit_an_event(int payload, test_emitter &emitter) {
  42. emitter.publish<an_event>(payload);
  43. }
  44. LIB_EXPORT void another_module_bind_ctx(entt::meta_ctx context) {
  45. entt::meta_ctx::bind(context);
  46. }
  47. LIB_EXPORT void another_module_meta_init() {
  48. entt::meta<int>().type().data<0>("0"_hs);
  49. }
  50. LIB_EXPORT void another_module_meta_deinit() {
  51. entt::meta<int>().reset();
  52. }