2026-04-04 13:08:28 +08:00
|
|
|
import type { GameHost } from 'boardgame-core';
|
2026-04-12 17:29:02 +08:00
|
|
|
import { ReactiveScene } from './ReactiveScene';
|
2026-04-04 13:08:28 +08:00
|
|
|
|
|
|
|
|
export interface GameHostSceneOptions<TState extends Record<string, unknown>> {
|
|
|
|
|
gameHost: GameHost<TState>;
|
2026-04-12 16:26:52 +08:00
|
|
|
[key: string]: unknown;
|
2026-04-04 13:08:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export abstract class GameHostScene<TState extends Record<string, unknown>>
|
2026-04-12 16:26:52 +08:00
|
|
|
extends ReactiveScene<GameHostSceneOptions<TState>>
|
2026-04-04 13:08:28 +08:00
|
|
|
{
|
2026-04-04 16:34:17 +08:00
|
|
|
public get gameHost(): GameHost<TState> {
|
2026-04-12 16:26:52 +08:00
|
|
|
return this.initData.gameHost as GameHost<TState>;
|
2026-04-04 16:34:17 +08:00
|
|
|
}
|
2026-04-12 16:26:52 +08:00
|
|
|
|
2026-04-06 13:59:00 +08:00
|
|
|
public get state(): TState {
|
|
|
|
|
return this.gameHost?.state.value;
|
|
|
|
|
}
|
2026-04-04 23:10:32 +08:00
|
|
|
|
2026-04-04 15:40:18 +08:00
|
|
|
addInterruption(promise: Promise<void>){
|
|
|
|
|
this.gameHost?.addInterruption(promise);
|
|
|
|
|
}
|
2026-04-04 23:10:32 +08:00
|
|
|
|
2026-04-04 15:43:50 +08:00
|
|
|
addTweenInterruption(tween: Phaser.Tweens.Tween){
|
|
|
|
|
this.addInterruption(new Promise(
|
|
|
|
|
resolve => tween.once('complete', resolve)
|
|
|
|
|
));
|
|
|
|
|
}
|
2026-04-04 13:08:28 +08:00
|
|
|
}
|