From 19fd62e92a0eea1ba532c78867c04878652469de Mon Sep 17 00:00:00 2001 From: Ezekiel Warren Date: Fri, 21 Jun 2024 08:09:25 -0700 Subject: [PATCH] chore: wip --- ecsact/entt/detail/apply_pending.hh | 3 +- .../association/association.cc | 32 +++++++++++-------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/ecsact/entt/detail/apply_pending.hh b/ecsact/entt/detail/apply_pending.hh index 2c2ec92..2262e6c 100644 --- a/ecsact/entt/detail/apply_pending.hh +++ b/ecsact/entt/detail/apply_pending.hh @@ -1,6 +1,7 @@ #pragma once #include +#include "ecsact/entt/registry.hh" #include "ecsact/entt/wrapper/core.hh" #include "ecsact/entt/detail/internal_markers.hh" @@ -10,7 +11,7 @@ template auto apply_pending_add(ecsact::entt::registry_t& registry) -> void { if constexpr(std::is_empty_v) { registry.view>().each([&](auto entity) { - C& comp = registry.emplace(entity); + registry.emplace(entity); // lifecycle_on_add(registry, entity, comp); }); } else { diff --git a/rt_entt_codegen/core/system_provider/association/association.cc b/rt_entt_codegen/core/system_provider/association/association.cc index eab28bf..406587c 100644 --- a/rt_entt_codegen/core/system_provider/association/association.cc +++ b/rt_entt_codegen/core/system_provider/association/association.cc @@ -65,22 +65,16 @@ auto provider::association::context_function_header( ); } +static auto push_back_unique(auto& vec, const auto& element) -> void { + if(std::ranges::find(vec, element) == std::end(vec)) { + vec.push_back(element); + } +} + auto provider::association::after_make_view_or_group( codegen_plugin_context& ctx, const common_vars& names ) -> void { - auto assoc_ids = ecsact::meta::system_assoc_ids(sys_like_id); - for(auto assoc_id : assoc_ids) { - auto assoc_caps = - ecsact::meta::system_assoc_capabilities(sys_like_id, assoc_id); - auto assoc_system_details = - ecsact_entt_system_details::from_capabilities(assoc_caps); - auto make_view_opts = util::make_view_options(assoc_system_details); - make_view_opts.view_var_name = assoc_view_names.at(assoc_id); - make_view_opts.registry_var_name = names.registry_var_name; - - util::make_view(ctx, make_view_opts); - } } auto provider::association::context_function_other( @@ -107,11 +101,24 @@ auto provider::association::entity_iteration( make_view_opts.registry_var_name = names.registry_var_name; for(auto compo_id : assoc_composites.at(assoc_id)) { + // TODO: At the time of writing this is safe. It's very possible we + // allow actions to be referenecd in association fields in the near + // future and at that point this must be addressed. + auto comp_like_id = static_cast(compo_id); + if(!assoc_system_details.get_comps.contains(comp_like_id)) { + auto comp_cpp_ident = cpp_identifier(decl_full_name(comp_like_id)); + push_back_unique( + make_view_opts.additional_components, + comp_cpp_ident + ); + } } util::make_view(ctx, make_view_opts); } + print_other_contexts(ctx, names); + for(auto&& [assoc_id, compo_ids] : assoc_composites) { for(auto compo_id : compo_ids) { auto field_ids = assoc_fields.at(compo_id); @@ -177,7 +184,6 @@ auto provider::association::pre_entity_iteration( codegen_plugin_context& ctx, const common_vars& names ) -> void { - print_other_contexts(ctx, names); } auto provider::association::pre_exec_system_impl(