* @zh 销毁实体 * @en Destroy entity * * @zh 移除所有组件并标记为已销毁。层级关系的清理由 HierarchySystem 处理。 * @en Removes all components and marks as destroyed. Hierarchy cleanup is handled by HierarchySystem.
()
| 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 比较实体优先级 |
nothing calls this directly
no test coverage detected