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

Method removeEntity

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

* 从查询系统移除实体 * * 从查询系统中移除指定实体,并清理相关索引。 * * @param entity 要移除的实体

(entity: Entity)

Source from the content-addressed store, hash-verified

193 * @param entity 要移除的实体
194 */
195 public removeEntity(entity: Entity): void {
196 const index = this._entities.indexOf(entity);
197 if (index !== -1) {
198 const componentTypes: ComponentType[] = [];
199 for (const component of entity.components) {
200 componentTypes.push(component.constructor as ComponentType);
201 }
202
203 this._entities.splice(index, 1);
204 this.removeEntityFromIndexes(entity);
205
206 this._archetypeSystem.removeEntity(entity);
207
208 if (componentTypes.length > 0) {
209 this.notifyReactiveQueriesEntityRemoved(entity, componentTypes);
210 } else {
211 this.notifyReactiveQueriesEntityRemovedFallback(entity);
212 }
213
214 this.clearQueryCache();
215
216 this._version++;
217 }
218 }
219
220 /**
221 * 更新实体在查询系统中的索引

Callers

nothing calls this directly

Calls 6

clearQueryCacheMethod · 0.95
pushMethod · 0.65
removeEntityMethod · 0.65

Tested by

no test coverage detected