Entities · class

QueryCursor

Explained in Entities.

class QueryCursor implements Iterator<Entity>, Iterable<Entity>
import { QueryCursor } from '@driftengine/entities';

Constructor

new

constructor(host: CursorHost)
ParameterTypeDescription
hostCursorHost

Methods

open

open(a: ComponentType, b?: ComponentType, c?: ComponentType, d?: ComponentType): this

Configure and take ownership.

ParameterTypeDescription
aComponentType
b?ComponentType
c?ComponentType
d?ComponentType
More

Four component types rather than a rest parameter, because ...types allocates an array on every call — once per system per frame, which is exactly the hot path this file exists for. Four covers every query in the corpus; a fifth is .with(), which is one more call and no array either.

with

with(type: ComponentType): this

Require a component without yielding anything about it.

ParameterTypeDescription
typeComponentType

without

without(type: ComponentType): this

Exclude everything that has this component.

ParameterTypeDescription
typeComponentType

next

next(): IteratorResult<Entity>

return

return(): IteratorResult<Entity>

Called by for…of when a loop breaks, which is what stops an abandoned cursor leaking.

Signatures

[Symbol.iterator](): Iterator<Entity>

[Symbol.iterator](): Iterator<Entity>