plugin.cpp 945 B

1234567891011121314151617181920212223242526272829303132333435
  1. #include <cr.h>
  2. #include <entt/core/type_info.hpp>
  3. #include <entt/signal/dispatcher.hpp>
  4. #include "type_context.h"
  5. #include "types.h"
  6. inline static type_context *context;
  7. template<typename Type>
  8. struct entt::type_seq<Type> {
  9. [[nodiscard]] static id_type value() ENTT_NOEXCEPT {
  10. static const entt::id_type value = context->value(entt::type_hash<Type>::value());
  11. return value;
  12. }
  13. };
  14. CR_EXPORT int cr_main(cr_plugin *ctx, cr_op operation) {
  15. switch (operation) {
  16. case CR_STEP:
  17. if(!context) {
  18. context = static_cast<type_context *>(ctx->userdata);
  19. } else {
  20. static_cast<entt::dispatcher *>(ctx->userdata)->trigger<event>();
  21. static_cast<entt::dispatcher *>(ctx->userdata)->trigger<message>(42);
  22. }
  23. break;
  24. case CR_CLOSE:
  25. case CR_LOAD:
  26. case CR_UNLOAD:
  27. // nothing to do here, this is only a test.
  28. break;
  29. }
  30. return 0;
  31. }