* @zh 加载并初始化插件 * @en Load and initialize plugins
()
| 519 | * @en Load and initialize plugins |
| 520 | */ |
| 521 | private async _initializePlugins(): Promise<void> { |
| 522 | const hasPlugins = runtimePluginManager.getPlugins().length > 0; |
| 523 | |
| 524 | if (!hasPlugins) { |
| 525 | const configs = convertToPluginLoadConfigs(this._projectConfig, BUILTIN_PLUGIN_PACKAGES); |
| 526 | const loader = new PluginLoader({ plugins: configs }); |
| 527 | |
| 528 | await loader.loadAll(); |
| 529 | |
| 530 | const loaded = loader.getLoaded(); |
| 531 | const failed = loader.getFailed(); |
| 532 | |
| 533 | if (loaded.length > 0) { |
| 534 | console.log(`[GameRuntime] Loaded: ${loaded.map(p => p.packageId).join(', ')}`); |
| 535 | } |
| 536 | if (failed.length > 0) { |
| 537 | for (const p of failed) { |
| 538 | console.warn(`[GameRuntime] Failed: ${p.packageId} - ${p.error}`); |
| 539 | } |
| 540 | } |
| 541 | } |
| 542 | |
| 543 | await runtimePluginManager.initializeRuntime(Core.services); |
| 544 | } |
| 545 | |
| 546 | /** |
| 547 | * @zh 设置游戏逻辑系统启用状态 |
no test coverage detected