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

Function reset

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

* 重置系统状态 * * 当系统从场景中移除时调用,重置初始化状态以便重新添加时能正确初始化。 * * 注意:此方法由 Scene.removeEntityProcessor 调用,在 unregister(触发dispose)之后调用。 * dispose 已经调用了 onDestroy 并设置了 _destroyed 标志,所以这里不需要重置该标志。 * 重置 _destroyed 会违反服务容器的语义(dispose 后不应重用)。

()

Source from the content-addressed store, hash-verified

497 * 重置 _destroyed 会违反服务容器的语义(dispose 后不应重用)。
498 */
499 public reset(): void {
500 // 如果系统已经被销毁,不需要再次调用destroy
501 if (this._destroyed) {
502 return;
503 }
504
505 this.scene = null;
506 this._initialized = false;
507 this._entityCache.clearAll();
508
509 // 清理实体ID映射缓存
510 this._entityIdMap = null;
511 this._entityIdMapVersion = -1;
512
513 // 清理所有事件监听器并调用销毁回调
514 this.destroy();
515 }
516
517 /**
518 * 查询匹配的实体

Callers

nothing calls this directly

Calls 2

destroyMethod · 0.65
clearAllMethod · 0.45

Tested by

no test coverage detected