* @zh 创建场景实例 * @en Create scene instance * * @param config - @zh 场景配置 @en Scene configuration
(config?: ISceneConfig)
| 380 | * @param config - @zh 场景配置 @en Scene configuration |
| 381 | */ |
| 382 | constructor(config?: ISceneConfig) { |
| 383 | this.entities = new EntityList(this); |
| 384 | this.identifierPool = new IdentifierPool(); |
| 385 | this.componentStorageManager = new ComponentStorageManager(); |
| 386 | |
| 387 | this.componentRegistry = new ComponentRegistry(); |
| 388 | |
| 389 | if (config?.inheritGlobalRegistry !== false) { |
| 390 | this.componentRegistry.cloneFrom(GlobalComponentRegistry); |
| 391 | } |
| 392 | |
| 393 | this.querySystem = new QuerySystem(); |
| 394 | this.eventSystem = new TypeSafeEventSystem(); |
| 395 | this.referenceTracker = new ReferenceTracker(); |
| 396 | this.handleManager = new EntityHandleManager(); |
| 397 | this._services = new ServiceContainer(); |
| 398 | this._logger = createLogger('Scene'); |
| 399 | this._maxErrorCount = config?.maxSystemErrorCount ?? 10; |
| 400 | |
| 401 | if (config?.name) { |
| 402 | this.name = config.name; |
| 403 | } |
| 404 | } |
| 405 | |
| 406 | /** |
| 407 | * 获取性能监控器 |
nothing calls this directly
no test coverage detected