Function has

Synopsis

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

template <typename... Component>
bool has(const entity_type entity) const

Description

Checks if an entity has all the given components.

Warning
Attempting to use an invalid entity results in undefined behavior.
Template Parameters

Component - Components for which to perform the check.

Parameters

entity - A valid entity identifier.

Return
True if the entity has all the components, false otherwise.

Source

Lines 778-782 in src/entt/entity/registry.hpp.

template<typename... Component>
[[nodiscard]] bool has(const entity_type entity) const {
    ENTT_ASSERT(valid(entity));
    return (assure<Component>().contains(entity) && ...);
}





Add Discussion

Log in to comment