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

Method destroyEntities

packages/core/src/ECS/Scene.ts:821–844  ·  view source on GitHub ↗

* 批量销毁实体

(entities: Entity[])

Source from the content-addressed store, hash-verified

819 * 批量销毁实体
820 */
821 public destroyEntities(entities: Entity[]): void {
822 if (entities.length === 0) return;
823
824 for (const entity of entities) {
825 entity.setDestroyedState(true);
826 }
827
828 for (const entity of entities) {
829 entity.removeAllComponents();
830 }
831
832 for (const entity of entities) {
833 this.entities.remove(entity);
834 this.querySystem.removeEntity(entity);
835
836 if (isValidHandle(entity.handle)) {
837 this._handleToEntity.delete(entity.handle);
838 this.handleManager.destroy(entity.handle);
839 }
840 }
841
842 this.querySystem.clearCache();
843 this.clearSystemEntityCaches();
844 }
845
846 /**
847 * 从场景中删除所有实体

Callers 5

processMethod · 0.80
onDestroyMethod · 0.80
Scene.test.tsFile · 0.80
removeEntityMethod · 0.80
clearEntitiesMethod · 0.80

Calls 9

isValidHandleFunction · 0.90
setDestroyedStateMethod · 0.80
removeMethod · 0.65
removeEntityMethod · 0.65
deleteMethod · 0.65
destroyMethod · 0.65
clearCacheMethod · 0.65
removeAllComponentsMethod · 0.45

Tested by

no test coverage detected