从 tslib 导入辅助函数
This commit is contained in:
@@ -78,6 +78,7 @@
|
||||
"directory": "packages/core"
|
||||
},
|
||||
"dependencies": {
|
||||
"msgpack-lite": "^0.1.26"
|
||||
"msgpack-lite": "^0.1.26",
|
||||
"tslib": "^2.8.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +52,13 @@ module.exports = [
|
||||
})
|
||||
],
|
||||
external,
|
||||
onwarn(warning, warn) {
|
||||
// 忽略 msgpack-lite 的循环依赖警告
|
||||
if (warning.code === 'CIRCULAR_DEPENDENCY' && warning.ids && warning.ids.some(id => id.includes('msgpack-lite'))) {
|
||||
return;
|
||||
}
|
||||
warn(warning);
|
||||
},
|
||||
treeshake: {
|
||||
moduleSideEffects: false,
|
||||
propertyReadSideEffects: false,
|
||||
@@ -78,6 +85,12 @@ module.exports = [
|
||||
})
|
||||
],
|
||||
external,
|
||||
onwarn(warning, warn) {
|
||||
if (warning.code === 'CIRCULAR_DEPENDENCY' && warning.ids && warning.ids.some(id => id.includes('msgpack-lite'))) {
|
||||
return;
|
||||
}
|
||||
warn(warning);
|
||||
},
|
||||
treeshake: {
|
||||
moduleSideEffects: false
|
||||
}
|
||||
@@ -103,6 +116,12 @@ module.exports = [
|
||||
})
|
||||
],
|
||||
external: [],
|
||||
onwarn(warning, warn) {
|
||||
if (warning.code === 'CIRCULAR_DEPENDENCY' && warning.ids && warning.ids.some(id => id.includes('msgpack-lite'))) {
|
||||
return;
|
||||
}
|
||||
warn(warning);
|
||||
},
|
||||
treeshake: {
|
||||
moduleSideEffects: false
|
||||
}
|
||||
@@ -157,6 +176,12 @@ module.exports = [
|
||||
})
|
||||
],
|
||||
external: [],
|
||||
onwarn(warning, warn) {
|
||||
if (warning.code === 'CIRCULAR_DEPENDENCY' && warning.ids && warning.ids.some(id => id.includes('msgpack-lite'))) {
|
||||
return;
|
||||
}
|
||||
warn(warning);
|
||||
},
|
||||
treeshake: {
|
||||
moduleSideEffects: false
|
||||
}
|
||||
|
||||
@@ -173,6 +173,13 @@ export class Core {
|
||||
this._sceneManager = new SceneManager();
|
||||
this._serviceContainer.registerInstance(SceneManager, this._sceneManager);
|
||||
|
||||
// 设置场景切换回调,通知调试管理器
|
||||
this._sceneManager.setSceneChangedCallback(() => {
|
||||
if (this._debugManager) {
|
||||
this._debugManager.onSceneChanged();
|
||||
}
|
||||
});
|
||||
|
||||
// 初始化插件管理器
|
||||
this._pluginManager = new PluginManager();
|
||||
this._pluginManager.initialize(this, this._serviceContainer);
|
||||
|
||||
@@ -14,7 +14,6 @@ import { SceneSerializer, SceneSerializationOptions, SceneDeserializationOptions
|
||||
import { IncrementalSerializer, IncrementalSnapshot, IncrementalSerializationOptions } from './Serialization/IncrementalSerializer';
|
||||
import { ComponentPoolManager } from './Core/ComponentPool';
|
||||
import { PerformanceMonitor } from '../Utils/PerformanceMonitor';
|
||||
import { Core } from '../Core';
|
||||
import { ServiceContainer, type ServiceType } from '../Core/ServiceContainer';
|
||||
import { createInstance, isInjectable } from '../Core/DI';
|
||||
import { isUpdatable, getUpdatableMetadata } from '../Core/DI/Decorators';
|
||||
@@ -183,11 +182,9 @@ export class Scene implements IScene {
|
||||
this._services = new ServiceContainer();
|
||||
this.logger = createLogger('Scene');
|
||||
|
||||
if (config?.performanceMonitor) {
|
||||
this._performanceMonitor = config.performanceMonitor;
|
||||
} else {
|
||||
this._performanceMonitor = Core.services.resolve(PerformanceMonitor);
|
||||
}
|
||||
// 从配置获取 PerformanceMonitor,如果未提供则创建一个新实例
|
||||
// Scene 应该是独立的,不依赖于 Core,通过构造函数参数明确依赖关系
|
||||
this._performanceMonitor = config?.performanceMonitor || new PerformanceMonitor();
|
||||
|
||||
if (config?.name) {
|
||||
this.name = config.name;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { IScene } from './IScene';
|
||||
import { ECSFluentAPI, createECSAPI } from './Core/FluentAPI';
|
||||
import { Time } from '../Utils/Time';
|
||||
import { Core } from '../Core';
|
||||
import { createLogger } from '../Utils/Logger';
|
||||
import type { IService } from '../Core/ServiceContainer';
|
||||
|
||||
@@ -68,6 +67,21 @@ export class SceneManager implements IService {
|
||||
*/
|
||||
private _logger = createLogger('SceneManager');
|
||||
|
||||
/**
|
||||
* 场景切换回调函数
|
||||
*/
|
||||
private _onSceneChangedCallback?: () => void;
|
||||
|
||||
/**
|
||||
* 设置场景切换回调
|
||||
*
|
||||
* @param callback 场景切换时的回调函数
|
||||
* @internal
|
||||
*/
|
||||
public setSceneChangedCallback(callback: () => void): void {
|
||||
this._onSceneChangedCallback = callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置当前场景(立即切换)
|
||||
*
|
||||
@@ -104,10 +118,9 @@ export class SceneManager implements IService {
|
||||
// 触发场景切换回调
|
||||
Time.sceneChanged();
|
||||
|
||||
// 通知调试管理器
|
||||
const coreInstance = Core.Instance;
|
||||
if (coreInstance && coreInstance._debugManager) {
|
||||
coreInstance._debugManager.onSceneChanged();
|
||||
// 通知调试管理器(通过回调)
|
||||
if (this._onSceneChangedCallback) {
|
||||
this._onSceneChangedCallback();
|
||||
}
|
||||
|
||||
this._logger.info(`Scene changed to: ${scene.name}`);
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
"noUncheckedIndexedAccess": false,
|
||||
"experimentalDecorators": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"importHelpers": false,
|
||||
"importHelpers": true,
|
||||
"downlevelIteration": true,
|
||||
"isolatedModules": false,
|
||||
"allowJs": true,
|
||||
|
||||
Reference in New Issue
Block a user