a_module.cpp 1.0 KB

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