| 51 | * ``` |
| 52 | */ |
| 53 | export class SceneManager implements IService { |
| 54 | /** |
| 55 | * 内部默认World |
| 56 | */ |
| 57 | private _defaultWorld: World; |
| 58 | |
| 59 | /** |
| 60 | * 待切换的下一个场景(延迟切换用) |
| 61 | */ |
| 62 | private _nextScene: IScene | null = null; |
| 63 | |
| 64 | /** |
| 65 | * ECS流式API |
| 66 | */ |
| 67 | private _ecsAPI: ECSFluentAPI | null = null; |
| 68 | |
| 69 | /** |
| 70 | * 日志器 |
| 71 | */ |
| 72 | private _logger = createLogger('SceneManager'); |
| 73 | |
| 74 | /** |
| 75 | * 场景切换回调函数 |
| 76 | */ |
| 77 | private _onSceneChangedCallback?: () => void; |
| 78 | |
| 79 | /** |
| 80 | * 性能监控器(从 Core 注入) |
| 81 | */ |
| 82 | private _performanceMonitor: PerformanceMonitor | null = null; |
| 83 | |
| 84 | /** |
| 85 | * 待迁移的持久化实体 |
| 86 | * |
| 87 | * Pending persistent entities for migration. |
| 88 | */ |
| 89 | private _pendingPersistentEntities: Entity[] = []; |
| 90 | |
| 91 | /** |
| 92 | * 默认场景ID |
| 93 | */ |
| 94 | private static readonly DEFAULT_SCENE_ID = '__main__'; |
| 95 | |
| 96 | constructor(performanceMonitor?: PerformanceMonitor) { |
| 97 | this._defaultWorld = new World({ name: '__default__' }); |
| 98 | this._defaultWorld.start(); |
| 99 | this._performanceMonitor = performanceMonitor || null; |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * 设置场景切换回调 |
| 104 | * |
| 105 | * @param callback 场景切换时的回调函数 |
| 106 | * @internal |
| 107 | */ |
| 108 | public setSceneChangedCallback(callback: () => void): void { |
| 109 | this._onSceneChangedCallback = callback; |
| 110 | } |
nothing calls this directly
no test coverage detected