Skip to content

Commit bc0fac6

Browse files
authored
chore: ecsact to entt reg prepare (#159)
1 parent 6835f18 commit bc0fac6

File tree

4 files changed

+20
-13
lines changed

4 files changed

+20
-13
lines changed

ecsact/entt/registry_util.hh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,6 @@ inline auto create_registry()
3333
return {registry_id, std::ref(registry)};
3434
}
3535

36+
auto ecsact_init_registry_storage(::entt::registry& registry) -> void;
37+
3638
} // namespace ecsact::entt

ecsact/entt/wrapper/core.hh

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "ecsact/entt/detail/internal_markers.hh"
77
#include "ecsact/entt/event_markers.hh"
88
#include "entt/entity/registry.hpp"
9+
#include "entt/entt.hpp"
910
#include "ecsact/entt/registry_util.hh"
1011
#include "ecsact/entt/error_check.hh"
1112
#include "ecsact/entt/detail/execution_events_collector.hh"
@@ -452,11 +453,9 @@ inline auto clear_notify_component(ecsact_registry_id registry_id) -> void {
452453
}
453454

454455
template<typename C>
455-
inline auto prepare_component(ecsact_registry_id registry_id) -> void {
456+
inline auto prepare_component(::entt::registry& reg) -> void {
456457
using namespace ecsact::entt;
457458

458-
auto& reg = ecsact::entt::get_registry(registry_id);
459-
460459
reg.template storage<C>();
461460
reg.template storage<component_added<C>>();
462461
reg.template storage<component_removed<C>>();
@@ -467,17 +466,17 @@ inline auto prepare_component(ecsact_registry_id registry_id) -> void {
467466
if constexpr(!std::is_empty_v<C>) {
468467
reg.template storage<detail::exec_beforechange_storage<C>>();
469468
reg.template storage<detail::exec_itr_beforechange_storage<C>>();
469+
reg.template storage<detail::run_on_stream<C>>();
470470
}
471471
}
472472

473473
template<typename S>
474-
inline auto prepare_system(ecsact_registry_id registry_id) -> void {
474+
inline auto prepare_system(::entt::registry& registry) -> void {
475475
using namespace ecsact::entt::detail;
476-
auto& reg = ecsact::entt::get_registry(registry_id);
477476

478-
reg.template storage<system_sorted<S>>();
479-
reg.template storage<pending_lazy_execution<S>>();
480-
reg.template storage<run_system<S>>();
477+
registry.template storage<system_sorted<S>>();
478+
registry.template storage<pending_lazy_execution<S>>();
479+
registry.template storage<run_system<S>>();
481480
}
482481

483482
template<typename C, typename V>

rt_entt_codegen/core/create_registry.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ auto ecsact::rt_entt_codegen::core::print_create_registry( //
1616
.return_type("ecsact_registry_id");
1717

1818
ctx.write("auto&& [registry_id, reg] = ecsact::entt::create_registry();\n\n");
19-
ctx.write("ecsact_init_registry_storage(registry_id);\n");
19+
20+
ctx.write("auto& entt_reg = ecsact::entt::get_registry(registry_id);\n\n");
21+
ctx.write("ecsact::entt::ecsact_init_registry_storage(entt_reg);\n");
2022
ctx.write("\nreturn registry_id;");
2123
}

rt_entt_codegen/core/init_registry_storage.cc

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,19 @@ auto ecsact::rt_entt_codegen::core::print_init_registry_storage(
1212
using ecsact::rt_entt_codegen::util::method_printer;
1313

1414
auto printer = //
15-
method_printer{ctx, "ecsact_init_registry_storage"}
16-
.parameter("ecsact_registry_id", "registry_id")
15+
method_printer{ctx, "ecsact::entt::ecsact_init_registry_storage"}
16+
.parameter("::entt::registry&", "registry")
1717
.return_type("void");
1818

19+
ctx.write(
20+
"registry.template storage<ecsact::entt::detail::destroyed_entity>();\n\n"
21+
);
22+
1923
for(auto comp_id : details.all_components) {
2024
auto cpp_comp_name = cpp_identifier(decl_full_name(comp_id));
2125

2226
ctx.write(std::format(
23-
"ecsact::entt::wrapper::core::prepare_component<{}>(registry_id);\n",
27+
"ecsact::entt::wrapper::core::prepare_component<{}>(registry);\n",
2428
cpp_comp_name
2529
));
2630
}
@@ -29,7 +33,7 @@ auto ecsact::rt_entt_codegen::core::print_init_registry_storage(
2933
auto cpp_sys_name = cpp_identifier(decl_full_name(system_id));
3034

3135
ctx.write(std::format(
32-
"ecsact::entt::wrapper::core::prepare_system<{}>(registry_id);\n",
36+
"ecsact::entt::wrapper::core::prepare_system<{}>(registry);\n",
3337
cpp_sys_name
3438
));
3539
}

0 commit comments

Comments
 (0)