42 lines
1.4 KiB
TypeScript
42 lines
1.4 KiB
TypeScript
/**
|
||
* Standalone 模式启动器
|
||
*/
|
||
|
||
import { Component } from 'cc';
|
||
import { PinballManager, PinballMode } from '../../PinballManager';
|
||
import { BaseBooter } from '../BaseBooter';
|
||
import { PinballBootConfig } from '../BootTypes';
|
||
|
||
export class StandaloneBooter extends BaseBooter {
|
||
|
||
async boot(hostComponent: Component, config: PinballBootConfig): Promise<PinballManager> {
|
||
this.log('[StandaloneBooter] 正在启动 Standalone 模式...', config.debugMode);
|
||
|
||
// 创建或获取 PinballManager 组件
|
||
let pinballManager = hostComponent.getComponent(PinballManager);
|
||
if (!pinballManager) {
|
||
pinballManager = hostComponent.addComponent(PinballManager);
|
||
}
|
||
|
||
// 应用配置
|
||
this.applyConfiguration(pinballManager, config);
|
||
|
||
// 设置默认模式
|
||
pinballManager.defaultMode = PinballMode.STANDALONE;
|
||
|
||
// 启动 PinballManager(在配置应用后)
|
||
const startSuccess = await pinballManager.Start();
|
||
if (!startSuccess) {
|
||
throw new Error('PinballManager 启动失败');
|
||
}
|
||
|
||
// 启动 Standalone 模式
|
||
const success = await pinballManager.startGame(PinballMode.STANDALONE);
|
||
if (!success) {
|
||
throw new Error('Standalone 模式启动失败');
|
||
}
|
||
|
||
this.log('[StandaloneBooter] Standalone 模式启动完成', config.debugMode);
|
||
return pinballManager;
|
||
}
|
||
} |