Files
shooter-demo/client-cocos/assets/scripts/Modules/Pinball/Boot/Mode/StandaloneBooter.ts
2025-11-28 18:10:10 +08:00

42 lines
1.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 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;
}
}