* 查询包含所有指定组件的实体 * * 返回同时包含所有指定组件类型的实体列表。 * 内部使用响应式查询作为智能缓存,自动跟踪实体变化,性能更优。 * * @param componentTypes 要查询的组件类型列表 * @returns 查询结果,包含匹配的实体和性能信息 * * @example * ```typescript * // 查询同时具有位置和速度组件的实体 * const result = querySystem.queryAll(PositionComponen
(...componentTypes: ComponentType[])
| 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 | * 查询包含任意指定组件的实体 |
no test coverage detected