diff --git a/ecsact/entt/registry_util.hh b/ecsact/entt/registry_util.hh index 8213c5b..629b104 100644 --- a/ecsact/entt/registry_util.hh +++ b/ecsact/entt/registry_util.hh @@ -33,4 +33,6 @@ inline auto create_registry() return {registry_id, std::ref(registry)}; } +auto ecsact_init_registry_storage(::entt::registry& registry) -> void; + } // namespace ecsact::entt diff --git a/ecsact/entt/wrapper/core.hh b/ecsact/entt/wrapper/core.hh index 9c53cf3..3879dc1 100644 --- a/ecsact/entt/wrapper/core.hh +++ b/ecsact/entt/wrapper/core.hh @@ -6,6 +6,7 @@ #include "ecsact/entt/detail/internal_markers.hh" #include "ecsact/entt/event_markers.hh" #include "entt/entity/registry.hpp" +#include "entt/entt.hpp" #include "ecsact/entt/registry_util.hh" #include "ecsact/entt/error_check.hh" #include "ecsact/entt/detail/execution_events_collector.hh" @@ -452,11 +453,9 @@ inline auto clear_notify_component(ecsact_registry_id registry_id) -> void { } template -inline auto prepare_component(ecsact_registry_id registry_id) -> void { +inline auto prepare_component(::entt::registry& reg) -> void { using namespace ecsact::entt; - auto& reg = ecsact::entt::get_registry(registry_id); - reg.template storage(); reg.template storage>(); reg.template storage>(); @@ -467,17 +466,17 @@ inline auto prepare_component(ecsact_registry_id registry_id) -> void { if constexpr(!std::is_empty_v) { reg.template storage>(); reg.template storage>(); + reg.template storage>(); } } template -inline auto prepare_system(ecsact_registry_id registry_id) -> void { +inline auto prepare_system(::entt::registry& registry) -> void { using namespace ecsact::entt::detail; - auto& reg = ecsact::entt::get_registry(registry_id); - reg.template storage>(); - reg.template storage>(); - reg.template storage>(); + registry.template storage>(); + registry.template storage>(); + registry.template storage>(); } template diff --git a/rt_entt_codegen/core/create_registry.cc b/rt_entt_codegen/core/create_registry.cc index 41f79ec..973617e 100644 --- a/rt_entt_codegen/core/create_registry.cc +++ b/rt_entt_codegen/core/create_registry.cc @@ -16,6 +16,8 @@ auto ecsact::rt_entt_codegen::core::print_create_registry( // .return_type("ecsact_registry_id"); ctx.write("auto&& [registry_id, reg] = ecsact::entt::create_registry();\n\n"); - ctx.write("ecsact_init_registry_storage(registry_id);\n"); + + ctx.write("auto& entt_reg = ecsact::entt::get_registry(registry_id);\n\n"); + ctx.write("ecsact::entt::ecsact_init_registry_storage(entt_reg);\n"); ctx.write("\nreturn registry_id;"); } diff --git a/rt_entt_codegen/core/init_registry_storage.cc b/rt_entt_codegen/core/init_registry_storage.cc index 6cc7365..b0dda9a 100644 --- a/rt_entt_codegen/core/init_registry_storage.cc +++ b/rt_entt_codegen/core/init_registry_storage.cc @@ -12,15 +12,19 @@ auto ecsact::rt_entt_codegen::core::print_init_registry_storage( using ecsact::rt_entt_codegen::util::method_printer; auto printer = // - method_printer{ctx, "ecsact_init_registry_storage"} - .parameter("ecsact_registry_id", "registry_id") + method_printer{ctx, "ecsact::entt::ecsact_init_registry_storage"} + .parameter("::entt::registry&", "registry") .return_type("void"); + ctx.write( + "registry.template storage();\n\n" + ); + for(auto comp_id : details.all_components) { auto cpp_comp_name = cpp_identifier(decl_full_name(comp_id)); ctx.write(std::format( - "ecsact::entt::wrapper::core::prepare_component<{}>(registry_id);\n", + "ecsact::entt::wrapper::core::prepare_component<{}>(registry);\n", cpp_comp_name )); } @@ -29,7 +33,7 @@ auto ecsact::rt_entt_codegen::core::print_init_registry_storage( auto cpp_sys_name = cpp_identifier(decl_full_name(system_id)); ctx.write(std::format( - "ecsact::entt::wrapper::core::prepare_system<{}>(registry_id);\n", + "ecsact::entt::wrapper::core::prepare_system<{}>(registry);\n", cpp_sys_name )); }