fix: update according to boardgame-core
This commit is contained in:
@@ -5,11 +5,11 @@ import type { MutableSignal, IGameContext, CommandResult } from 'boardgame-core'
|
||||
type DisposeFn = () => void;
|
||||
|
||||
export interface ReactiveSceneOptions<TState extends Record<string, unknown>> {
|
||||
state: MutableSignal<TState>;
|
||||
commands: IGameContext<TState>['commands'];
|
||||
gameContext: IGameContext<TState>;
|
||||
}
|
||||
|
||||
export abstract class ReactiveScene<TState extends Record<string, unknown>> extends Phaser.Scene {
|
||||
protected gameContext!: IGameContext<TState>;
|
||||
protected state!: MutableSignal<TState>;
|
||||
protected commands!: IGameContext<TState>['commands'];
|
||||
private effects: DisposeFn[] = [];
|
||||
@@ -18,6 +18,12 @@ export abstract class ReactiveScene<TState extends Record<string, unknown>> exte
|
||||
super(key);
|
||||
}
|
||||
|
||||
init(data: ReactiveSceneOptions<TState>): void {
|
||||
this.gameContext = data.gameContext;
|
||||
this.state = data.gameContext.state;
|
||||
this.commands = data.gameContext.commands;
|
||||
}
|
||||
|
||||
protected watch(fn: () => void): DisposeFn {
|
||||
const e = effect(fn);
|
||||
this.effects.push(e);
|
||||
|
||||
Reference in New Issue
Block a user