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

Method initializeWith

packages/core/src/ECS/Core/ReactiveQuery.ts:343–360  ·  view source on GitHub ↗

* 批量初始化查询结果 * * @param entities 初始实体列表

(entities: readonly Entity[])

Source from the content-addressed store, hash-verified

341 * @param entities 初始实体列表
342 */
343 public initializeWith(entities: readonly Entity[]): void {
344 // 清空现有结果
345 this._entities.length = 0;
346 this._entityIdSet.clear();
347 this._snapshot = null; // 使快照失效 | Invalidate snapshot
348
349 // 筛选匹配的实体
350 for (const entity of entities) {
351 if (this.matches(entity)) {
352 this._entities.push(entity);
353 this._entityIdSet.add(entity.id);
354 }
355 }
356
357 if (this._config.debug) {
358 logger.debug(`ReactiveQuery ${this._id}: 初始化 ${this._entities.length} 个实体`);
359 }
360 }
361
362 /**
363 * 添加到批量变化缓存

Callers 2

createReactiveQueryMethod · 0.95

Calls 5

matchesMethod · 0.95
clearMethod · 0.65
pushMethod · 0.65
addMethod · 0.45
debugMethod · 0.45

Tested by

no test coverage detected