Function children

Synopsis

#include <include/flecs/addons/cpp/entity_view.hpp>

template <typename Func>
void children(Func &&func) const

Description

Iterate children for entity. The function parameter must match the following signature: void(*)(flecs::entity target)

Parameters

func - The function invoked for each child.

Mentioned in

Source

Lines 147-169 in include/flecs/addons/cpp/entity_view.hpp.

template <typename Func>
void children(Func&& func) const {
    flecs::world world(m_world);
    ecs_term_t terms[2];
    ecs_filter_t f = ECS_FILTER_INIT;
    f.terms = terms;
    f.term_count = 2;
    ecs_filter_desc_t desc = {};
    desc.terms[0].id = ecs_pair(flecs::ChildOf, m_id);
    desc.terms[1].id = flecs::Prefab;
    desc.terms[1].oper = EcsOptional;
    desc.storage = &f;
    ecs_filter_init(m_world, &desc);
    ecs_iter_t it = ecs_filter_iter(m_world, &f);
    while (ecs_filter_next(&it)) {
        _::each_invoker<Func>(FLECS_MOV(func)).invoke(&it);
    }
    ecs_filter_fini(&f);
}