File tree Expand file tree Collapse file tree 6 files changed +55
-0
lines changed Expand file tree Collapse file tree 6 files changed +55
-0
lines changed Original file line number Diff line number Diff line change @@ -373,4 +373,21 @@ inline auto clear_component(ecsact_registry_id registry_id) -> void {
373
373
reg.clear <ecsact::entt::component_removed<C>>();
374
374
}
375
375
376
+ template <typename C>
377
+ inline auto init_registry_with_component (ecsact_registry_id registry_id
378
+ ) -> void {
379
+ using namespace ecsact ::entt;
380
+
381
+ auto & reg = ecsact::entt::get_registry (registry_id);
382
+
383
+ reg.template storage <C>();
384
+ reg.template storage <component_added<C>>();
385
+ reg.template storage <component_changed<C>>();
386
+ reg.template storage <component_removed<C>>();
387
+
388
+ if constexpr (!std::is_empty_v<C>) {
389
+ reg.storage <detail::beforechange_storage<C>>();
390
+ }
391
+ }
392
+
376
393
} // namespace ecsact::entt::wrapper::core
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ cc_library(
13
13
_CORE_CODEGEN_METHODS = {
14
14
"execute_systems" : [],
15
15
"create_registry" : [],
16
+ "init_registry_storage" : [],
16
17
"events" : [],
17
18
"print_sys_exec" : [
18
19
"//rt_entt_codegen/shared:comps_with_caps" ,
Original file line number Diff line number Diff line change @@ -21,6 +21,11 @@ auto print_create_registry( //
21
21
const ecsact_entt_details& details
22
22
) -> void;
23
23
24
+ auto print_init_registry_storage ( //
25
+ ecsact::codegen_plugin_context& ctx,
26
+ const ecsact::rt_entt_codegen::ecsact_entt_details& details
27
+ ) -> void;
28
+
24
29
auto print_execute_system_like_template_specializations ( //
25
30
codegen_plugin_context& ctx,
26
31
const ecsact_entt_details& details
Original file line number Diff line number Diff line change @@ -27,5 +27,7 @@ auto ecsact::rt_entt_codegen::core::print_create_registry( //
27
27
}
28
28
}
29
29
30
+ ctx.write (" ecsact_init_registry_storage(registry_id);\n " );
31
+
30
32
ctx.write (" \n return registry_id;" );
31
33
}
Original file line number Diff line number Diff line change
1
+ #include " core.hh"
2
+
3
+ #include " ecsact/lang-support/lang-cc.hh"
4
+ #include " rt_entt_codegen/shared/util.hh"
5
+
6
+ auto ecsact::rt_entt_codegen::core::print_init_registry_storage (
7
+ ecsact::codegen_plugin_context& ctx,
8
+ const ecsact::rt_entt_codegen::ecsact_entt_details& details
9
+ ) -> void {
10
+ using ecsact::cc_lang_support::cpp_identifier;
11
+ using ecsact::meta::decl_full_name;
12
+ using ecsact::rt_entt_codegen::util::method_printer;
13
+
14
+ auto printer = //
15
+ method_printer{ctx, " ecsact_init_registry_storage" }
16
+ .parameter (" ecsact_registry_id" , " registry_id" )
17
+ .return_type (" void" );
18
+
19
+ for (auto comp_id : details.all_components ) {
20
+ auto cpp_comp_name = cpp_identifier (decl_full_name (comp_id));
21
+
22
+ ctx.write (
23
+ " ecsact::entt::wrapper::core::init_registry_with_component<" ,
24
+ cpp_comp_name,
25
+ " >(registry_id)"
26
+ );
27
+ ctx.write (" ;\n " );
28
+ }
29
+ }
Original file line number Diff line number Diff line change @@ -204,6 +204,7 @@ void ecsact_codegen_plugin(
204
204
205
205
core::print_check_error_template_specializations (ctx, details);
206
206
core::print_execute_system_like_template_specializations (ctx, details);
207
+ core::print_init_registry_storage (ctx, details);
207
208
core::print_create_registry (ctx, details);
208
209
core::print_trigger_ecsact_events_minimal (ctx, details);
209
210
core::print_trigger_ecsact_events_all (ctx, details);
You can’t perform that action at this time.
0 commit comments