MCPcopy Create free account
hub / github.com/esengine/esengine / queryAll

Method queryAll

packages/core/src/ECS/Core/QuerySystem.ts:346–365  ·  view source on GitHub ↗

* 查询包含所有指定组件的实体 * * 返回同时包含所有指定组件类型的实体列表。 * 内部使用响应式查询作为智能缓存,自动跟踪实体变化,性能更优。 * * @param componentTypes 要查询的组件类型列表 * @returns 查询结果,包含匹配的实体和性能信息 * * @example * ```typescript * // 查询同时具有位置和速度组件的实体 * const result = querySystem.queryAll(PositionComponen

(...componentTypes: ComponentType[])

Source from the content-addressed store, hash-verified

344 * ```
345 */
346 public queryAll(...componentTypes: ComponentType[]): QueryResult {
347 const startTime = performance.now();
348 this._queryStats.totalQueries++;
349
350 // 使用内部响应式查询作为智能缓存
351 const reactiveQuery = this.getOrCreateReactiveQuery(QueryConditionType.ALL, componentTypes);
352
353 // 从响应式查询获取结果(永远是最新的)
354 const entities = reactiveQuery.getEntities();
355
356 // 统计为缓存命中(响应式查询本质上是永不过期的智能缓存)
357 this._queryStats.cacheHits++;
358
359 return {
360 entities,
361 count: entities.length,
362 executionTime: performance.now() - startTime,
363 fromCache: true
364 };
365 }
366
367 /**
368 * 查询包含任意指定组件的实体

Callers 7

queryChangedSinceMethod · 0.95
executeMethod · 0.45
findMethod · 0.45
findFirstMethod · 0.45
_refreshCacheMethod · 0.45

Calls 3

nowMethod · 0.80
getEntitiesMethod · 0.65

Tested by

no test coverage detected