Skip to content

Commit

Permalink
chore: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
zaucy committed Jun 21, 2024
1 parent 8e2f6b5 commit 19fd62e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
3 changes: 2 additions & 1 deletion ecsact/entt/detail/apply_pending.hh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <entt/entt.hpp>
#include "ecsact/entt/registry.hh"
#include "ecsact/entt/wrapper/core.hh"
#include "ecsact/entt/detail/internal_markers.hh"

Expand All @@ -10,7 +11,7 @@ template<typename C>
auto apply_pending_add(ecsact::entt::registry_t& registry) -> void {
if constexpr(std::is_empty_v<C>) {
registry.view<pending_add<C>>().each([&](auto entity) {
C& comp = registry.emplace<C>(entity);
registry.emplace<C>(entity);
// lifecycle_on_add<C>(registry, entity, comp);
});
} else {
Expand Down
32 changes: 19 additions & 13 deletions rt_entt_codegen/core/system_provider/association/association.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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<ecsact_component_like_id>(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);
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 19fd62e

Please sign in to comment.