Struct QueryBuilder
- Namespace
- KeenEyes
- Assembly
- KeenEyes.Core.dll
Fluent builder for constructing queries.
public readonly struct QueryBuilder : IQueryBuilder, IEnumerable<Entity>, IEnumerable
- Implements
-
IQueryBuilderIEnumerable<Entity>
- Inherited Members
- Extension Methods
Properties
Description
Gets the query description.
public QueryDescription Description { get; }
Property Value
World
Gets the world this query operates on.
public World World { get; }
Property Value
Methods
Count()
Counts the number of entities matching this query.
public int Count()
Returns
- int
The number of entities matching the query.
Remarks
This method is optimized to avoid LINQ overhead and is safe to use in hot paths. When no string tag filters are applied, it sums archetype counts directly (O(archetypes)). When string tag filters are present, it must iterate entities (O(entities)).
GetEnumerator()
Gets an enumerator for iterating over matching entities.
public QueryEnumerator GetEnumerator()
Returns
WithTag(string)
Requires the entity to have this string tag.
public QueryBuilder WithTag(string tag)
Parameters
tagstringThe string tag that must be present.
Returns
Exceptions
- ArgumentNullException
Thrown when
tagis null.- ArgumentException
Thrown when
tagis empty or whitespace.
With<TWith>()
Requires the entity to have this component (filter only, not accessed).
public QueryBuilder With<TWith>() where TWith : struct, IComponent
Returns
Type Parameters
TWith
WithoutTag(string)
Excludes entities that have this string tag.
public QueryBuilder WithoutTag(string tag)
Parameters
tagstringThe string tag that must NOT be present.
Returns
Exceptions
- ArgumentNullException
Thrown when
tagis null.- ArgumentException
Thrown when
tagis empty or whitespace.
Without<TWithout>()
Excludes entities that have this component.
public QueryBuilder Without<TWithout>() where TWithout : struct, IComponent
Returns
Type Parameters
TWithout