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

Function initialize

packages/core/src/ECS/Systems/EntitySystem.ts:436–460  ·  view source on GitHub ↗

* 系统初始化(框架调用) * * 在系统创建时调用。框架内部使用,用户不应直接调用。

()

Source from the content-addressed store, hash-verified

434 * 在系统创建时调用。框架内部使用,用户不应直接调用。
435 */
436 public initialize(): void {
437 // 防止重复初始化 | Prevent re-initialization
438 if (this._initialized) {
439 return;
440 }
441
442 this._initialized = true;
443
444 // 框架内部初始化:触发一次实体查询,以便正确跟踪现有实体
445 // Framework initialization: query entities once to track existing entities
446 if (this.scene) {
447 // 清理缓存确保初始化时重新查询 | Clear cache to ensure fresh query
448 this._entityCache.invalidate();
449 const entities = this.queryEntities();
450
451 // 初始化时对已存在的匹配实体触发 onAdded
452 // Trigger onAdded for existing matching entities during initialization
453 for (const entity of entities) {
454 this.onAdded(entity);
455 }
456 }
457
458 // 调用用户可重写的初始化方法 | Call user-overridable initialization method
459 this.onInitialize();
460 }
461
462 /**
463 * 系统初始化回调

Callers

nothing calls this directly

Calls 4

onInitializeMethod · 0.65
invalidateMethod · 0.45
queryEntitiesMethod · 0.45
onAddedMethod · 0.45

Tested by

no test coverage detected