Struct as_group

Synopsis

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

template<typename Entity>
struct as_group

Description

Converts a registry to a group.

Template Parameters

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

Methods

as_groupConstructs a converter for a given registry.
operator basic_group< entity_type, Exclude, Get, Owned... >Conversion function from a registry to a group.

Source

Lines 70-97 in src/entt/entity/helper.hpp.

template<typename Entity>
struct as_group {
    /*! @brief Underlying entity identifier. */
    using entity_type = std::remove_const_t<Entity>;
    /*! @brief Type of registry to convert. */
    using registry_type = constness_as_t<basic_registry<entity_type>, Entity>;

    /**
     * @brief Constructs a converter for a given registry.
     * @param source A valid reference to a registry.
     */
    as_group(registry_type &source) ENTT_NOEXCEPT: reg{source} {}

    /**
     * @brief Conversion function from a registry to a group.
     * @tparam Exclude Types of components used to filter the group.
     * @tparam Get Types of components observed by the group.
     * @tparam Owned Types of components owned by the group.
     * @return A newly created group.
     */
    template<typename Exclude, typename Get, typename... Owned>
    operator basic_group<entity_type, Exclude, Get, Owned...>() const {
        return reg.template group<Owned...>(Get{}, Exclude{});
    }

private:
    registry_type &reg;
};





Add Discussion

Log in to comment