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

Method constructor

packages/core/src/Core.ts:131–174  ·  view source on GitHub ↗

* @zh 创建核心实例 * @en Create core instance * * @param config - @zh Core配置对象 @en Core configuration object

(config: ICoreConfig = {})

Source from the content-addressed store, hash-verified

129 * @param config - @zh Core配置对象 @en Core configuration object
130 */
131 private constructor(config: ICoreConfig = {}) {
132 Core._instance = this;
133 this._config = { debug: true, ...config };
134 this._serviceContainer = new ServiceContainer();
135
136 this._timerManager = new TimerManager();
137 this._serviceContainer.registerInstance(TimerManager, this._timerManager);
138
139 this._performanceMonitor = new PerformanceMonitor();
140 this._serviceContainer.registerInstance(PerformanceMonitor, this._performanceMonitor);
141 if (this._config.debug) {
142 this._performanceMonitor.enable();
143 }
144
145 this._poolManager = new PoolManager();
146 this._serviceContainer.registerInstance(PoolManager, this._poolManager);
147
148 this._sceneManager = new SceneManager(this._performanceMonitor);
149 this._serviceContainer.registerInstance(SceneManager, this._sceneManager);
150 this._sceneManager.setSceneChangedCallback(() => this._debugManager?.onSceneChanged());
151
152 this._worldManager = new WorldManager({ debug: !!this._config.debug, ...this._config.worldManagerConfig });
153 this._serviceContainer.registerInstance(WorldManager, this._worldManager);
154
155 this._pluginManager = new PluginManager();
156 this._pluginManager.initialize(this, this._serviceContainer);
157 this._serviceContainer.registerInstance(PluginManager, this._pluginManager);
158
159 this._pluginServiceRegistry = new PluginServiceRegistry();
160 this._serviceContainer.registerInstance(PluginServiceRegistry, this._pluginServiceRegistry);
161
162 this.debug = this._config.debug ?? true;
163
164 if (this._config.debugConfig?.enabled) {
165 const configService = new DebugConfigService();
166 configService.setConfig(this._config.debugConfig);
167 this._serviceContainer.registerInstance(DebugConfigService, configService);
168 this._serviceContainer.registerSingleton(DebugManager, (c) => createInstance(DebugManager, c));
169 this._debugManager = this._serviceContainer.resolve(DebugManager);
170 this._debugManager.onInitialize();
171 }
172
173 this.initialize();
174 }
175
176 /**
177 * @zh 获取核心实例

Callers

nothing calls this directly

Calls 11

setConfigMethod · 0.95
initializeMethod · 0.95
createInstanceFunction · 0.90
initializeMethod · 0.65
resolveMethod · 0.65
onInitializeMethod · 0.65
registerInstanceMethod · 0.45
enableMethod · 0.45
onSceneChangedMethod · 0.45
registerSingletonMethod · 0.45

Tested by

no test coverage detected