import {DisposableBag, IDisposable} from "@/utils/disposable"; import type {GameHost} from "../../../../../boardgame-core/src"; import {effect} from "@preact/signals"; export abstract class GameHostScene> extends Phaser.Scene implements IDisposable{ protected disposables = new DisposableBag(); protected gameHost!: GameHost; init(data: { gameHost: GameHost }): void { this.gameHost = data.gameHost; } create(){ this.events.on('shutdown', this.dispose, this); } dispose() { this.disposables.dispose(); } public get state(): T { return this.gameHost.state.value; } protected watch(fn: () => void | (()=>void)){ this.disposables.add(effect(fn)); } }