import type { GameHost } from 'boardgame-core'; import { ReactiveScene } from './ReactiveScene'; export interface GameHostSceneOptions> { gameHost: GameHost; [key: string]: unknown; } export abstract class GameHostScene> extends ReactiveScene> { public get gameHost(): GameHost { const gameHost = this.initData.gameHost as GameHost; if (!gameHost) { throw new Error( `GameHostScene (${this.scene.key}): gameHost 未提供。` + `确保在 PhaserScene 组件的 data 属性中传入 gameHost。` ); } return gameHost; } public get state(): TState { return this.gameHost?.state.value; } addInterruption(promise: Promise){ this.gameHost?.addInterruption(promise); } addTweenInterruption(tween: Phaser.Tweens.Tween){ this.addInterruption(new Promise( resolve => tween.once('complete', resolve) )); } }