Unravel Engine C++ Reference
Loading...
Searching...
No Matches
ecs_utils.h
Go to the documentation of this file.
1#pragma once
3#include <functional>
4
5namespace unravel
6{
7
14template<typename ComponentType>
15void 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
40 }
41}
42
43} // namespace unravel
Component that handles transformations (position, rotation, scale, etc.) in the ACE framework.
std::vector< render_pass_node > 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