* 更新所有活跃的World * * 应该在每帧的游戏循环中调用。 * 会自动更新所有活跃World的全局系统和场景。 * * @example * ```typescript * function gameLoop(deltaTime: number) { * Core.update(deltaTime); // 更新全局服务 * worldManager.updateAll(); // 更新所有World * } * ```
()
| 197 | * ``` |
| 198 | */ |
| 199 | public updateAll(): void { |
| 200 | if (!this._isRunning) return; |
| 201 | |
| 202 | for (const world of this._worlds.values()) { |
| 203 | if (world.isActive) { |
| 204 | // 更新World的全局System |
| 205 | world.updateGlobalSystems(); |
| 206 | |
| 207 | // 更新World中的所有Scene |
| 208 | world.updateScenes(); |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | // 基于帧的自动清理 |
| 213 | if (this._config.autoCleanup) { |
| 214 | this._framesSinceCleanup++; |
| 215 | |
| 216 | if (this._framesSinceCleanup >= this._config.cleanupFrameInterval) { |
| 217 | this.cleanup(); |
| 218 | this._framesSinceCleanup = 0; // 重置计数器 |
| 219 | |
| 220 | if (this._config.debug) { |
| 221 | logger.debug(`执行定期清理World (间隔: ${this._config.cleanupFrameInterval} 帧)`); |
| 222 | } |
| 223 | } |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | /** |
| 228 | * 获取所有激活的World |
no test coverage detected