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

Method destroy

packages/core/src/ECS/Entity.ts:797–820  ·  view source on GitHub ↗

* @zh 销毁实体 * @en Destroy entity * * @zh 移除所有组件并标记为已销毁。层级关系的清理由 HierarchySystem 处理。 * @en Removes all components and marks as destroyed. Hierarchy cleanup is handled by HierarchySystem.

()

Source from the content-addressed store, hash-verified

795 * @en Removes all components and marks as destroyed. Hierarchy cleanup is handled by HierarchySystem.
796 */
797 public destroy(): void {
798 if (this._isDestroyed) {
799 return;
800 }
801
802 this._isDestroyed = true;
803
804 if (this.scene && this.scene.referenceTracker) {
805 this.scene.referenceTracker.clearReferencesTo(this.id);
806 this.scene.referenceTracker.unregisterEntityScene(this.id);
807 }
808
809 this.removeAllComponents();
810
811 if (this.scene) {
812 if (this.scene.querySystem) {
813 this.scene.querySystem.removeEntity(this);
814 }
815
816 if (this.scene.entities) {
817 this.scene.entities.remove(this);
818 }
819 }
820 }
821
822 /**
823 * @zh 比较实体优先级

Callers

nothing calls this directly

Calls 5

removeAllComponentsMethod · 0.95
clearReferencesToMethod · 0.80
unregisterEntitySceneMethod · 0.80
removeEntityMethod · 0.65
removeMethod · 0.65

Tested by

no test coverage detected