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

Method updateAll

packages/core/src/ECS/WorldManager.ts:199–225  ·  view source on GitHub ↗

* 更新所有活跃的World * * 应该在每帧的游戏循环中调用。 * 会自动更新所有活跃World的全局系统和场景。 * * @example * ```typescript * function gameLoop(deltaTime: number) { * Core.update(deltaTime); // 更新全局服务 * worldManager.updateAll(); // 更新所有World * } * ```

()

Source from the content-addressed store, hash-verified

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

Callers 3

updateInternalMethod · 0.45

Calls 5

cleanupMethod · 0.95
valuesMethod · 0.45
updateGlobalSystemsMethod · 0.45
updateScenesMethod · 0.45
debugMethod · 0.45

Tested by

no test coverage detected