Unravel Engine C++ Reference
Loading...
Searching...
No Matches
ecs_utils.h
Go to the documentation of this file.
1
#pragma once
2
#include "
components/transform_component.h
"
3
#include <functional>
4
5
namespace
unravel
6
{
7
14
template
<
typename
ComponentType>
15
void
for_each_component_in_children
(entt::handle parent, std::function<
void
(ComponentType&)> callback)
16
{
17
if
(!parent.valid())
18
{
19
return
;
20
}
21
22
// Check if parent has transform_component to get children
23
if
(!parent.all_of<
transform_component
>())
24
{
25
return
;
26
}
27
28
const
auto
&
children
= parent.get<
transform_component
>().get_children();
29
for
(
const
auto
& child :
children
)
30
{
31
// Check if child has the component
32
if
(child.all_of<ComponentType>())
33
{
34
auto
& component = child.get<ComponentType>();
35
callback(component);
36
}
37
38
// Recurse into children
39
for_each_component_in_children<ComponentType>
(child, callback);
40
}
41
}
42
43
}
// namespace unravel
unravel::transform_component
Component that handles transformations (position, rotation, scale, etc.) in the ACE framework.
Definition
transform_component.h:56
children
std::vector< render_pass_node > children
Definition
gpu_frame_stats_widgets.cpp:65
unravel
Definition
crash.cpp:21
unravel::for_each_component_in_children
void for_each_component_in_children(entt::handle parent, std::function< void(ComponentType &)> callback)
Iterates through all children (recursively) and calls the callback for each entity that has the speci...
Definition
ecs_utils.h:15
transform_component.h
engine
engine
ecs
ecs_utils.h
Generated by
1.12.0