src/necsus/runtime/query

Types

AnyQuery[Comps] = Query[Comps] | FullQuery[Comps]
FullQuery[Comps] = distinct RawQuery[Comps]
Allows systems to query for entities with specific components. Where Comps is a tuple of the components to fetch in this query. Provides access to the EntityId
Not[Comps] = distinct int8
A query flag that indicates a component should be excluded from a query. Where Comps is the single component that should be excluded.
Query[Comps] = distinct RawQuery[Comps]
Allows systems to query for entities with specific components. Where Comps is a tuple of the components to fetch in this query. Does not provide access to the entity ID
QueryItem[Comps] = tuple[entityId: EntityId, components: Comps]
An individual value yielded by a query. Where Comps is a tuple of the components to fetch in this query
QueryNext[Comps] = proc (appStatePtr: pointer; state: var uint;
                         iter: var BlockIter; eid: var EntityId; slot: var Comps): bool {.
    ...gcsafe, raises: [], nimcall.}
RawQuery[Comps] = ref object
Allows systems to query for entities with specific components. Where Comps is a tuple of the components to fetch in this query.

Procs

proc asFullQuery[Comps](rawQuery: RawQuery[Comps]): FullQuery[Comps]
proc asQuery[Comps](rawQuery: RawQuery[Comps]): Query[Comps]
proc len[Comps: tuple](query: AnyQuery[Comps]): uint {....gcsafe, raises: [].}
Returns the number of entities in this query
proc newQuery[Comps: tuple](appState: pointer; getLen: QueryGetLen;
                            getNext: QueryNext[Comps]): RawQuery[Comps]
proc single[Comps: tuple](query: AnyQuery[Comps]): Option[Comps]
Returns a single element from a query

Iterators

iterator items[Comps: tuple](query: AnyQuery[Comps]): Comps
Iterates through the entities in a query
iterator pairs[Comps: tuple](query: FullQuery[Comps]): QueryItem[Comps]
Iterates through the entities in a query