a_module.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 a_module_int_type() {
  16. entt::registry registry;
  17. (void)registry.type<double>();
  18. (void)registry.type<float>();
  19. return registry.type<int>();
  20. }
  21. LIB_EXPORT typename entt::component a_module_char_type() {
  22. entt::registry registry;
  23. (void)registry.type<double>();
  24. (void)registry.type<float>();
  25. return registry.type<char>();
  26. }
  27. LIB_EXPORT void update_position(int delta, entt::registry &registry) {
  28. registry.view<position, velocity>().each([delta](auto &pos, auto &vel) {
  29. pos.x += delta * vel.dx;
  30. pos.y += delta * vel.dy;
  31. });
  32. }
  33. LIB_EXPORT void trigger_another_event(entt::dispatcher &dispatcher) {
  34. dispatcher.trigger<another_event>();
  35. }
  36. LIB_EXPORT void emit_another_event(test_emitter &emitter) {
  37. emitter.publish<another_event>();
  38. }
  39. LIB_EXPORT void a_module_bind_ctx(entt::meta_ctx context) {
  40. entt::meta_ctx::bind(context);
  41. }
  42. LIB_EXPORT void a_module_meta_init() {
  43. entt::meta<char>().type().data<'c'>("c"_hs);
  44. }
  45. LIB_EXPORT void a_module_meta_deinit() {
  46. entt::meta().reset();
  47. }