import { Runner } from '../../utils'; import type { ComponentConstructor } from '../ComponentInterface'; import type { Entity } from '../Entity'; import type { Scene } from '../Scene'; import { ID32 } from './ID32'; export declare type NotQueryComponent = { operator: string; component: ComponentConstructor; }; export declare type OrQueryComponent = { operator: string; components: ComponentConstructor[]; }; export declare type QueryComponent = ComponentConstructor | NotQueryComponent | OrQueryComponent; export declare type QueryKey = { name: string; componentID: ID32; notComponentID: ID32; orComponentIDs: ID32[]; }; export declare enum QueryEvents { MODIFIED = "modified", ADDED = "added", REMOVED = "removed" } export declare class Query { /** entities that belong in the query */ readonly entities: Entity[]; /** whether or not the query is reactive */ reactive: boolean; /** a key used to identify the query */ key: string; /** name of the query */ name: string; readonly runners: { added: Runner<"addedToQuery">; removed: Runner<"removedFromQuery">; modified: Runner<"modifiedQuery">; }; protected readonly componentID: ID32; protected readonly notComponentID: ID32; protected readonly orComponentIDs: ID32[]; constructor(world: Scene, key: QueryKey, name: string); /** * Gets the first entity in the query. */ get first(): Entity; /** * Loops through all entities in the query backwards * @param callbackfn - callback on interaction */ forEach(callbackfn: (value: T, index: number, array: T[]) => void): void; /** * Add entity to this query * @param entity - entity to be added */ addEntity(entity: Entity): void; /** * Remove entity from this query * @param entity - entity to be removed */ removeEntity(entity: Entity): void; /** * checks if an entity exists in this query * @param entity - entity to be checked */ hasEntity(entity: Entity): boolean; /** * Checks if an entity id matches the query id. * @param entityId - id of the entity to check */ match(entityId: ID32): boolean; } //# sourceMappingURL=Query.d.ts.map