|
4 | 4 | #include "ecsact/lang-support/lang-cc.hh"
|
5 | 5 | #include "rt_entt_codegen/shared/util.hh"
|
6 | 6 | #include "ecsact/cpp_codegen_plugin_util.hh"
|
| 7 | +#include "rt_entt_codegen/shared/system_variant.hh" |
7 | 8 |
|
8 | 9 | constexpr auto METHOD_BODY_TOP = R"(
|
9 | 10 | auto& registry = ecsact::entt::get_registry(registry_id);
|
@@ -77,66 +78,28 @@ auto ecsact::rt_entt_codegen::core::print_execute_systems( //
|
77 | 78 | });
|
78 | 79 | });
|
79 | 80 |
|
| 81 | + std::vector<system_like_id_variant> system_like_variants; |
| 82 | + |
| 83 | + for(const auto sys_like_id : details.top_execution_order) { |
| 84 | + if(details.is_system(sys_like_id)) { |
| 85 | + system_like_variants.push_back(static_cast<ecsact_system_id>(sys_like_id) |
| 86 | + ); |
| 87 | + } else if(details.is_action(sys_like_id)) { |
| 88 | + system_like_variants.push_back(static_cast<ecsact_action_id>(sys_like_id) |
| 89 | + ); |
| 90 | + } |
| 91 | + } |
| 92 | + |
80 | 93 | auto parallel_system_cluster =
|
81 | 94 | ecsact::rt_entt_codegen::parallel::get_parallel_execution_cluster(
|
82 | 95 | ctx,
|
83 |
| - details, |
84 |
| - details.top_execution_order |
| 96 | + system_like_variants |
85 | 97 | );
|
86 | 98 |
|
87 |
| - for(const auto& systems_to_parallel : parallel_system_cluster) { |
88 |
| - if(systems_to_parallel.size() == 1) { |
89 |
| - auto sync_sys_id = systems_to_parallel[0]; |
90 |
| - |
91 |
| - auto sync_sys_name = |
92 |
| - cpp_identifier(ecsact::meta::decl_full_name(sync_sys_id)); |
93 |
| - |
94 |
| - if(details.is_action(sync_sys_id)) { |
95 |
| - ctx.write(std::format( |
96 |
| - "ecsact::entt::execute_actions<{}>(registry, {}, " |
97 |
| - "actions_map);\n", |
98 |
| - sync_sys_name, |
99 |
| - "nullptr" |
100 |
| - )); |
101 |
| - } |
102 |
| - if(details.is_system(sync_sys_id)) { |
103 |
| - ctx.write(std::format( |
104 |
| - "ecsact::entt::execute_system<{}>(registry, {}, " |
105 |
| - "actions_map);\n", |
106 |
| - sync_sys_name, |
107 |
| - "nullptr" |
108 |
| - )); |
109 |
| - } |
110 |
| - continue; |
111 |
| - } |
112 |
| - |
113 |
| - ctx.write("execute_parallel_cluster(registry, nullptr, "); |
114 |
| - ctx.write(std::format( |
115 |
| - "std::array<exec_entry_t, {}> {{\n", |
116 |
| - systems_to_parallel.size() |
117 |
| - )); |
118 |
| - for(const auto system_like_id : systems_to_parallel) { |
119 |
| - auto cpp_decl_name = |
120 |
| - cpp_identifier(ecsact::meta::decl_full_name(system_like_id)); |
121 |
| - |
122 |
| - if(details.is_action(system_like_id)) { |
123 |
| - ctx.write( |
124 |
| - "\texec_entry_t{&ecsact::entt::execute_actions<", |
125 |
| - cpp_decl_name, |
126 |
| - ">, actions_map},\n" |
127 |
| - ); |
128 |
| - } else if(details.is_system(system_like_id)) { |
129 |
| - ctx.write( |
130 |
| - "\texec_entry_t{&ecsact::entt::execute_system<", |
131 |
| - cpp_decl_name, |
132 |
| - ">, actions_map},\n" |
133 |
| - ); |
134 |
| - } else { |
135 |
| - ctx.write("// ??? unhandled ??? ", cpp_decl_name, "\n"); |
136 |
| - } |
137 |
| - } |
138 |
| - ctx.write("});\n"); |
139 |
| - } |
| 99 | + ecsact::rt_entt_codegen::parallel::print_parallel_execution_cluster( |
| 100 | + ctx, |
| 101 | + parallel_system_cluster |
| 102 | + ); |
140 | 103 |
|
141 | 104 | ctx.write("\nupdate_all_beforechange_storage(registry_id);\n");
|
142 | 105 | ctx.write("cleanup_system_notifies(registry_id);\n");
|
|
0 commit comments