Function to_entity

Synopsis

#include <src/entt/entity/helper.hpp>

template <typename Entity, typename Component>
Entity to_entity(const basic_registry< Entity > &reg, const Component &component)

Description

Returns the entity associated with a given component.

Template Parameters:

Entity - A valid entity type (see entt_traits for more details).

Component - Type of component.

Parameters:

reg - A registry that contains the given entity and its components.

component - A valid component instance.

Return
The entity associated with the given component.

Mentioned in

Source

Lines 140-143 in src/entt/entity/helper.hpp.

template<typename Entity, typename Component>
Entity to_entity(const basic_registry<Entity> &reg, const Component &component) {
    return *(reg.template data<Component>() + (&component - reg.template raw<Component>()));
}





Add Discussion

Log in to comment