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

Method addEntity

packages/core/src/ECS/Core/QuerySystem.ts:106–124  ·  view source on GitHub ↗

* 添加单个实体到查询系统 * * 将新实体添加到查询系统中,并自动更新相关索引。 * 为了提高批量添加性能,可以延迟缓存清理。 * * @param entity 要添加的实体 * @param deferCacheClear 是否延迟缓存清理(用于批量操作)

(entity: Entity, deferCacheClear: boolean = false)

Source from the content-addressed store, hash-verified

104 * @param deferCacheClear 是否延迟缓存清理(用于批量操作)
105 */
106 public addEntity(entity: Entity, deferCacheClear: boolean = false): void {
107 if (!this._entities.includes(entity)) {
108 this._entities.push(entity);
109 this.addEntityToIndexes(entity);
110
111 this._archetypeSystem.addEntity(entity);
112
113 // 通知响应式查询
114 this.notifyReactiveQueriesEntityAdded(entity);
115
116 // 只有在非延迟模式下才立即清理缓存
117 if (!deferCacheClear) {
118 this.clearQueryCache();
119 }
120
121 // 更新版本号
122 this._version++;
123 }
124 }
125
126 /**
127 * 批量添加实体

Callers 1

updateEntityMethod · 0.95

Calls 5

addEntityToIndexesMethod · 0.95
clearQueryCacheMethod · 0.95
pushMethod · 0.65
addEntityMethod · 0.65

Tested by

no test coverage detected