QueryComponentManagable<T extends App<T> , E extends IsComponentManagable<T, E> , Q extends QueryComponentManagable<T, E, Q> > class
abstract
Base class for the Query-like DSL, a fluent, chainable query language for filtering entities or components.
The Query-like language
Capitalized methods (e.g. With, Except, Where, Or, Not) are the vocabulary of an embedded query language. They are named in PascalCase to distinguish them from ordinary Dart methods and to read naturally in a chain:
query
.With<Position>()
.With<Velocity>()
.Except<Frozen>()
.DoForEach((e) => ...);
The query is lazily evaluated: nothing is resolved until a terminal operation such as First, DoForEach, Collect, etc. is called.
Groups and boolean logic
Internally a query is a list of QueryGroups. Within a group, all filters are ANDed. Or starts a new group; results across groups are ORed (entity passes if any group passes). Not starts a new negated group (entity passes if it would fail all filters in that group).
// entities that have Burning OR have Wet
query.With<Burning>().Or().With<Wet>().Collect();
// entities that are NOT frozen
query.Not().With<Frozen>().Collect();
Type parameters
- Inheritance
- Mixed-in types
-
- Self<
Q> - IsClonable<
T, Q, Cloner< T> > - HasAppAccess<
T>
- Self<
- Implementers
Constructors
- QueryComponentManagable(T app)
Properties
- app → T
-
final
- backend → UnhingedBackend
-
Shorthand for App.backend.
no setterinherited
- Count → int
-
Query-likeReturns the number of matching elements.no setter -
draw
→ Drawers<
T> -
Shorthand for App.draw.
no setterinherited
- Exists → bool
-
Query-likeAlias for IsNotEmpty.trueif at least one element matches.no setter - First → E
-
Query-likeReturns the first matching element. Throws if none exist.no setter - FirstOrNull → E?
-
Query-likeReturns the first matching element, ornullif the result set is empty.no setter - hashCode → int
-
The hash code for this object.
no setterinherited
- id → int
-
Per-type unique identifier, auto-assigned in the constructor.
no setterinherited
-
input
→ InputSystem<
T> -
Shorthand for App.input.
no setterinherited
- isClonable → bool
-
Check this before calling clone:
if (obj.isClonable) obj.clone();no setterinherited - isClone ↔ bool
-
Whether this object is a clone of another.
getter/setter pairinherited
- isCloned ↔ bool
-
Whether this object has been cloned at least once.
getter/setter pairinherited
- isCloning ↔ bool
-
Whether this object is currently mid-clone.
getter/setter pairinherited
- IsEmpty → bool
-
Query-liketrueif no elements match.no setter - IsNotEmpty → bool
-
Query-liketrueif at least one element matches.no setter - isOriginal → bool
-
Whether this object is an original (not a clone).
no setterinherited
- Last → E
-
Query-likeReturns the last matching element. Throws if none exist.no setter - LastOrNull → E?
-
Query-likeReturns the last matching element, ornullif the result set is empty.no setter - name ↔ String
-
Human-readable name, defaults to
<runtimeType>_<id>.getter/setter pairinherited - namedId → String
-
Per-type unique String identifier, auto-assigned in the constructor.
Defaults to
<runtimeType>_<id>.no setterinherited -
parent
↔ ECSBase<
T> ? -
The parent object in the ECS tree, if any.
getter/setter pairinherited
-
queryableList
→ Iterable<
E> -
The default pool of elements to query when no explicit From source is
provided. Implemented by concrete subclasses.
no setter
-
renderer
→ Renderer<
T> -
Shorthand for App.renderer.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
scene
→ Scene<
T> -
Shorthand for App.currentScene.
no setterinherited
- sceneBounds → Bounds
-
no setterinherited
- sceneHeight → double
-
no setterinherited
- sceneSize → Vector2D
-
no setterinherited
- sceneWidth → double
-
no setterinherited
- screenHeight → double
-
Shorthand for App's height.
no setterinherited
- screenSize → Vector2D
-
Shorthand for App.screenSize.
no setterinherited
- screenWidth → double
-
Shorthand for App's width.
no setterinherited
- self → Q
-
This object cast to
T.no setterinherited -
time
→ AppTime<
T> -
Shorthand for App.time.
no setterinherited
Methods
-
And(
[Q? other]) → Q -
Query-likeMerges all groups fromotherinto this query (AND at the group level). -
callback(
void callback()) → void -
inherited
-
clone<
X extends E> ([Cloner< T> ? cloner]) → X -
Produces a clone of this object.
inherited
-
cloneInto<
X extends E> (X target, [Cloner< T> ? cloner]) → X -
inherited
-
Collect<
A extends E> () → Iterable< A> -
Query-likeReturns all matching elements as a lazy Iterable. -
createClone(
Q newInstance, [Cloner< T> ? cloner]) → Q -
Override to customize how state is copied into
newInstance.inherited -
createInstance(
) → Q -
Override to provide a fresh uninitialized instance of this type.
inherited
-
DoAll<
A extends E> (void fn(Iterable< A> entities)) → void -
Query-likePasses the full result Iterable tofn. -
DoFirst<
A extends E> (void fn(A entity)) → void -
Query-likeCallsfnwith the first matching element. Does nothing if the result set is empty. -
DoFirstWith<
C extends Comp< (T> >void fn(E entity, C c)) → void -
Query-likeCallsfnwith the first matching element and itsCcomponent. Does nothing if the result set is empty. -
DoFirstWith2<
A extends Comp< (T> , B extends Comp<T> >void fn(E entity, A a, B b)) → void -
Query-likeCallsfnwith the first matching element and itsAandBcomponents. Does nothing if the result set is empty. -
DoFirstWith3<
A extends Comp< (T> , B extends Comp<T> , C extends Comp<T> >void fn(E entity, A a, B b, C c)) → void -
Query-likeCallsfnwith the first matching element and itsA,B, andCcomponents. Does nothing if the result set is empty. -
DoForEach<
A extends E> (void fn(A entity)) → void -
Query-likeCallsfnonce for each matching element. -
DoForEachWith<
C extends Comp< (T> >void fn(E entity, C a)) → void -
Query-likeFor each element that hasC, callsfnwith the element and itsCinstance. Implicitly adds a With<C>filter. -
DoForEachWith2<
A extends Comp< (T> , B extends Comp<T> >void fn(E entity, A a, B b)) → void -
Query-likeFor each element that has bothAandB, callsfnwith the element and both component instances. Implicitly adds a With2<A, B>filter. -
DoForEachWith3<
A extends Comp< (T> , B extends Comp<T> , C extends Comp<T> >void fn(E entity, A a, B b, C c)) → void -
Query-likeFor each element that hasA,B, andC, callsfnwith the element and all three component instances. Implicitly adds a With3<A, B, C>filter. -
DoLast<
A extends E> (void fn(A entity)) → void -
Query-likeCallsfnwith the last matching element. Does nothing if the result set is empty. -
DoLastWith<
C extends Comp< (T> >void fn(E entity, C c)) → void -
Query-likeCallsfnwith the last matching element and itsCcomponent. Does nothing if the result set is empty. -
DoLastWith2<
A extends Comp< (T> , B extends Comp<T> >void fn(E entity, A a, B b)) → void -
Query-likeCallsfnwith the last matching element and itsAandBcomponents. Does nothing if the result set is empty. -
DoLastWith3<
A extends Comp< (T> , B extends Comp<T> , C extends Comp<T> >void fn(E entity, A a, B b, C c)) → void -
Query-likeCallsfnwith the last matching element and itsA,B, andCcomponents. Does nothing if the result set is empty. -
Except<
C extends Comp< (T> >) → Q -
Query-likeExcludes elements that have componentC. -
Except2<
A extends Comp< (T> , B extends Comp<T> >) → Q -
Query-likeExcludes elements that have eitherAorB. -
Except3<
A extends Comp< (T> , B extends Comp<T> , C extends Comp<T> >) → Q -
Query-likeExcludes elements that have any ofA,B, orC. -
FirstAs<
X extends E> () → X -
Query-likeReturns the first element of typeX, skipping any non-matching elements. Throws a StateError if no element of typeXexists. -
FirstAsOrNull<
X extends E> () → X? -
Query-likeReturns the first element of typeX, skipping any non-matching elements, ornullif none exists. -
From(
List< E> entities) → Q -
Query-likeRestricts the query to a specific list ofentitiesinstead of the default queryableList. -
getAncestors(
) → Iterable< ECSBase< T> > -
Returns every ancestor of this component, from immediate parent up to the root.
inherited
-
getClones(
) → Iterable< Q> -
Returns all clones produced from this object.
inherited
-
getDepth(
) → int -
Returns the depth/level in the hierarchy.
inherited
-
getParentAs<
P extends ECSBase< (T> >) → P? -
Returns parent cast to
P, ornullif the cast would fail.inherited -
getPath(
) → List< ECSBase< T> > -
Returns the path from the root down to this one, inclusive.
inherited
-
hasParentOf<
P extends ECSBase< (T> >) → bool -
Whether parent is of type
P.inherited -
IndexOf(
E e) → int -
Query-likeReturns the index ofein the resolved result list, or-1if not found. -
LastAs<
X extends E> () → X -
Query-likeReturns the last element of typeX, skipping any non-matching elements. Throws a StateError if no element of typeXexists. -
LastAsOrNull<
X extends E> () → X? -
Query-likeReturns the last element of typeX, skipping any non-matching elements, ornullif none exists. -
listenOnAfterClone(
void fn(Q copy, [Cloner< T> ? cloner])) → Q -
Registers
fnas an after-clone listener.inherited -
listenOnBeforeClone(
bool fn(Q copy, [Cloner< T> ? cloner])) → Q -
Registers
fnas a before-clone listener.inherited -
listenOnClone(
void fn(Q copy, [Cloner< T> ? cloner])) → Q -
Registers
fnas a clone listener.inherited -
Map<
X> (X toElement(E e)) → Iterable< X> -
Query-likeProjects matching elements usingtoElement. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
Not(
) → Q -
Query-likeOpens a new negated filter group. -
On<
C extends E> () → Q -
Query-likeKeeps only elements whose runtime type isC. -
onAfterClone(
Q copy, [Cloner< T> ? cloner]) → void -
Override to react after cloning has completed.
inherited
-
onBeforeClone(
Q copy, [Cloner< T> ? cloner]) → bool -
Override to cancel cloning from within the class.
inherited
-
onClone(
Q copy, [Cloner< T> ? cloner]) → void -
Override to react when cloning is about to complete.
inherited
-
onCloned(
Q original) → void -
Called on the copy after cloning completes, with a reference to
original.inherited -
onSelf(
void fn(Q original)) → Q -
Calls
fnwith self and returns self, for fluent chaining.inherited -
Or(
[Q? other]) → Q -
Query-likeOpens a new filter group (OR semantics between groups). -
run(
Task< T> task) → void -
inherited
-
task(
Task< T> task) → void -
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
uniqKey(
String key) → String -
Returns a key namespaced to this object's namedId.
inherited
-
whenClone(
Q fn(Q newInstance, [Cloner< T> ? cloner])) → Q -
Registers
fnas the clone factory, replacing the default clone behavior.inherited -
whenCloned(
Q fn(Q self, Q copy)) → Q -
Registers
fnto run after the clone is produced.inherited -
whenCreateInstance(
Q fn(Q self)) → Q -
Registers
fnas the instance factory used during cloning.inherited -
Where(
bool fn(E entity)) → Q -
Query-likeKeeps only elements for whichfnreturnstrue. -
WhereType<
X> () → Q -
Query-likeKeeps only elements matching given typeX. -
With<
C extends Comp< (T> >) → Q -
Query-likeKeeps only elements that have componentCattached. -
With2<
A extends Comp< (T> , B extends Comp<T> >) → Q -
Query-likeKeeps only elements that have both componentsAandB. -
With2Where<
A extends Comp< (T> , B extends Comp<T> >bool fn(E entity, A a, B b)) → Q -
Query-likeKeeps only elements that have bothAandBand for whichfnreturnstrue. -
With3<
A extends Comp< (T> , B extends Comp<T> , C extends Comp<T> >) → Q -
Query-likeKeeps only elements that have all three componentsA,B, andC. -
With3Where<
A extends Comp< (T> , B extends Comp<T> , C extends Comp<T> >bool fn(E entity, A a, B b, C c)) → Q -
Query-likeKeeps only elements that have all three ofA,B, andCand for whichfnreturnstrue. -
WithAny<
A extends Comp< (T> , B extends Comp<T> >) → Q -
Query-likeKeeps only elements that have at least one ofAorB. -
WithWhere<
C extends Comp< (T> >bool fn(E entity, C c)) → Q -
Query-likeKeeps only elements that haveCand for whichfnreturnstruegiven the entity and itsCinstance.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited