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

Method addEntity

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

* 在场景的实体列表中添加一个实体 * @param entity 要添加的实体 * @param deferCacheClear 是否延迟缓存清理(用于批量操作)

(entity: Entity, deferCacheClear: boolean = false)

Source from the content-addressed store, hash-verified

771 * @param deferCacheClear 是否延迟缓存清理(用于批量操作)
772 */
773 public addEntity(entity: Entity, deferCacheClear: boolean = false) {
774 this.entities.add(entity);
775 entity.scene = this;
776
777 this.querySystem.addEntity(entity, deferCacheClear);
778
779 if (!deferCacheClear) {
780 this.clearSystemEntityCaches();
781 }
782
783 this.eventSystem.emitSync('entity:added', { entity, scene: this });
784
785 return entity;
786 }
787
788 /**
789 * 批量创建实体(高性能版本)

Callers 1

createEntityMethod · 0.95

Calls 4

addEntityMethod · 0.65
addMethod · 0.45
emitSyncMethod · 0.45

Tested by

no test coverage detected