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

Method _rebuildComponentCache

packages/core/src/ECS/Entity.ts:281–307  ·  view source on GitHub ↗

* @zh 从存储重建组件缓存 * @en Rebuild component cache from storage

()

Source from the content-addressed store, hash-verified

279 * @en Rebuild component cache from storage
280 */
281 private _rebuildComponentCache(): void {
282 const components: Component[] = [];
283
284 if (!this.scene?.componentStorageManager) {
285 this._componentCache = components;
286 return;
287 }
288
289 const mask = this._componentMask;
290 const registry = this.scene.componentRegistry;
291 const maxBitIndex = registry.getRegisteredCount();
292
293 for (let bitIndex = 0; bitIndex < maxBitIndex; bitIndex++) {
294 if (BitMask64Utils.getBit(mask, bitIndex)) {
295 const componentType = registry.getTypeByBitIndex(bitIndex);
296 if (componentType) {
297 const component = this.scene.componentStorageManager.getComponent(this.id, componentType);
298
299 if (component) {
300 components.push(component);
301 }
302 }
303 }
304 }
305
306 this._componentCache = components;
307 }
308
309 /**
310 * 获取活跃状态

Callers 1

componentsMethod · 0.95

Calls 5

getRegisteredCountMethod · 0.80
getBitMethod · 0.80
getTypeByBitIndexMethod · 0.80
pushMethod · 0.65
getComponentMethod · 0.45

Tested by

no test coverage detected