* @zh 从存储重建组件缓存 * @en Rebuild component cache from storage
()
| 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 | * 获取活跃状态 |
no test coverage detected