refactor: clean up
This commit is contained in:
@@ -1,26 +0,0 @@
|
||||
import {DisposableBag, IDisposable} from "@/utils/disposable";
|
||||
import type {GameHost} from "../../../../../boardgame-core/src";
|
||||
import {effect} from "@preact/signals";
|
||||
|
||||
export abstract class GameHostScene<T extends Record<string,unknown>> extends Phaser.Scene implements IDisposable{
|
||||
protected disposables = new DisposableBag();
|
||||
|
||||
protected gameHost!: GameHost<T>;
|
||||
|
||||
init(data: { gameHost: GameHost<T> }): 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));
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
import Phaser from 'phaser';
|
||||
import type {TicTacToeState, TicTacToePart} from '@/game/tic-tac-toe';
|
||||
import {ReadonlySignal} from "@preact/signals";
|
||||
import {GameHostScene} from "@/scenes/GameHostScene";
|
||||
import {spawnEffect, Spawner} from "@/utils/spawner";
|
||||
import { GameHostScene } from 'boardgame-phaser';
|
||||
import { spawnEffect, type Spawner } from 'boardgame-phaser';
|
||||
import type { ReadonlySignal } from '@preact/signals-core';
|
||||
import {commands} from "@/game/tic-tac-toe";
|
||||
|
||||
const CELL_SIZE = 120;
|
||||
|
||||
Reference in New Issue
Block a user