refactor: expose addInterruption
This commit is contained in:
@@ -4,6 +4,7 @@ import { GameHostScene } from 'boardgame-phaser';
|
||||
import { spawnEffect, type Spawner } from 'boardgame-phaser';
|
||||
import type { ReadonlySignal } from '@preact/signals-core';
|
||||
import {commands} from "@/game/boop";
|
||||
import {MutableSignal} from "boardgame-core";
|
||||
|
||||
const BOARD_SIZE = 6;
|
||||
const CELL_SIZE = 80;
|
||||
@@ -38,7 +39,7 @@ export class GameScene extends GameHostScene<BoopState> {
|
||||
this.drawGrid();
|
||||
this.createSupplyUI();
|
||||
|
||||
this.disposables.add(spawnEffect(new BoopPartSpawner(this, this.gameHost.state)));
|
||||
this.disposables.add(spawnEffect(new BoopPartSpawner(this, this.gameHost.state as MutableSignal<BoopState>)));
|
||||
|
||||
this.watch(() => {
|
||||
const winner = this.state.winner;
|
||||
@@ -393,10 +394,10 @@ export class GameScene extends GameHostScene<BoopState> {
|
||||
}
|
||||
|
||||
class BoopPartSpawner implements Spawner<BoopPart, Phaser.GameObjects.Container> {
|
||||
constructor(public readonly scene: GameScene, public readonly state: ReadonlySignal<BoopState>) {}
|
||||
constructor(public readonly scene: GameHostScene<BoopState>) {}
|
||||
|
||||
*getData() {
|
||||
for (const part of Object.values(this.state.value.pieces)) {
|
||||
for (const part of Object.values(this.scene.state.pieces)) {
|
||||
yield part;
|
||||
}
|
||||
}
|
||||
@@ -452,6 +453,7 @@ class BoopPartSpawner implements Spawner<BoopPart, Phaser.GameObjects.Container>
|
||||
duration: 200,
|
||||
ease: 'Back.easeOut',
|
||||
});
|
||||
this.state.addInterruption(new Promise(resolve => setTimeout(resolve, 200)));
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user