vecs
Fast, flexible ecs in C++ with ergonomic API
|
Represents a query for components within the ECS world. More...
#include <vecs.h>
Classes | |
class | Iterator |
Iterator for iterating over entities matching the query. More... | |
struct | Record |
A container for a single record and its components, as a result of a query. More... | |
struct | Single |
A container for a single entity and its components, as a result of a query. More... | |
Public Types | |
template<typename T > | |
using | QueryTypeTraits = _traits::query::QueryTypeTraits<T> |
template<typename T > | |
using | ComponentStorageType = typename QueryTypeTraits<T>::StorageType |
using | QueryComponents |
Public Member Functions | |
Query (World *world) | |
Constructs a Query to search for entities with specified components. | |
Iterator | begin () |
Returns an iterator to the beginning of the query results. | |
Iterator | end () |
Returns an iterator to the end of the query results. | |
Record | get (Entity entity) |
Retrieves the components of an entity matching the query. | |
Record | get_single () |
Retrieves the components of a single entity matching the query. | |
Static Public Member Functions | |
static ComponentMask | compute_mask () |
Represents a query for components within the ECS world.
This class provides an interface for querying entities that match a set of components. It allows iteration over matching entities and provides methods to retrieve individual results.
Components | The types of components to be queried. |
using vecs::Query< Components >::QueryComponents |
|
inline |
Constructs a Query
to search for entities with specified components.
world | Pointer to the ECS world containing the entities and components. |
|
inline |
Returns an iterator to the beginning of the query results.
|
inline |
Returns an iterator to the end of the query results.
|
inline |
Retrieves the components of an entity matching the query.
entity | The entity to retrieve the components for. |
Record
containing the entity's components, or an invalid Record
if the entity does not match the query.Example usage:
|
inline |
Retrieves the components of a single entity matching the query.
This method is intended to be used with queries that are expected to match exactly one entity. If the query does not match exactly one entity, an invalid Record
is returned.
Record
containing the matched component, or an invalid Record
if no components or multiple components match the query.Example usage: