EasyEcs
API reference

QueryFilter

Extra query constraints: components that must be present without being read (QueryFilter.With) or must be absent (QueryFilter.Without).

public readonly struct QueryFilter

Extra query constraints: components that must be present without being read (QueryFilter.With) or must be absent (QueryFilter.Without). Build once and keep it (e.g. in a static readonly field):

static readonly QueryFilter Alive = QueryFilter.Create().Without<Dead>();

Methods

Changed

public QueryFilter Changed<T>(ulong since) where T : struct, IComponent, ITrackChanges;

Require T and only rows whose T was written at or after change tick since: a World.ChangeTick read earlier ([Changed<T>] methods select the rows written since their system last ran on their own). A filter has one tick: its Changed and Removed filters must name the same one.

Exceptions

  • ArgumentException: An earlier Changed or Removed filter named another tick.

Complexity (API table): O(1); a pass skips tables, 4,096-row blocks and 64-row words written before since

Create

public static QueryFilter Create();

A filter that matches every entity with the queried components: the start of a chain (Create().Without<Dead>()). O(1).

Complexity (API table): O(1)

InGroup

public QueryFilter InGroup<T>(int group) where T : struct, IComponent, IGroup;

Require T with group group: only the tables of that group are walked (World.GroupBy; in a world that does not group by T, every table holds group 0). One group per filter.

Complexity (API table): O(1); a pass walks only that group's tables

Removed

public QueryFilter Removed<T>(ulong since) where T : struct, IComponent, ITrackChanges;

Only entities that lost T at or after change tick since and have not got it back ([Removed<T>] methods select the removals since their system last ran on their own). Removing a component keeps the entity's row, so the removal is a row like any other: its presence bit is clear and its change tick says when. Destroyed entities have no row and are not visited. A filter has one tick: its Changed and Removed filters must name the same one.

Exceptions

  • ArgumentException: An earlier Changed or Removed filter named another tick.

Complexity (API table): as Changed

Since

public QueryFilter Since(ulong since);

The same filter with its QueryFilter.Changed and QueryFilter.Removed filters moved to tick since, without rebuilding it: a filter kept in a field, used again after each update.

Complexity (API table): O(1)

With

public QueryFilter With<T>() where T : struct, IComponent;

Require T to be present (not passed to the query callback).

WithAny

public QueryFilter WithAny<T>() where T : struct, IComponent;

Require at least one of the components named by WithAny calls: WithAny<Burning>().WithAny<Poisoned>() matches entities with Burning, Poisoned or both.

Without

public QueryFilter Without<T>() where T : struct, IComponent;

Require T to be absent.

Edit on GitHub

Last updated on

How is this guide?

On this page