Home > @esengine/ecs-framework-monorepo > QuerySystem > queryAll
QuerySystem.queryAll() method
查询包含所有指定组件的实体
返回同时包含所有指定组件类型的实体列表。 系统会自动选择最高效的查询策略,包括索引查找和缓存机制。
Signature:
typescript
queryAll(...componentTypes: ComponentType[]): QueryResult;
Parameters
Parameter | Type | Description |
---|---|---|
componentTypes | 要查询的组件类型列表 |
Returns:
QueryResult
查询结果,包含匹配的实体和性能信息
Example
typescript
// 查询同时具有位置和速度组件的实体
const result = querySystem.queryAll(PositionComponent, VelocityComponent);
logger.info(`找到 ${result.count} 个移动实体`);