refactor: improve tic tac toe with region entity

This commit is contained in:
2026-04-02 16:52:58 +08:00
parent b1a6619ae3
commit 06c801e6ae
3 changed files with 13 additions and 15 deletions
+7 -3
View File
@@ -1,4 +1,4 @@
import {computed, ReadonlySignal, SignalOptions} from "@preact/signals-core";
import {batch, computed, ReadonlySignal, SignalOptions} from "@preact/signals-core";
import {Entity} from "@/utils/entity";
import {Part} from "./part";
import {RNG} from "@/utils/rng";
@@ -33,7 +33,9 @@ export class RegionEntity extends Entity<Region> {
}
export function applyAlign(region: Entity<Region>) {
region.produce(applyAlignCore);
batch(() => {
region.produce(applyAlignCore);
});
}
function applyAlignCore(region: Region) {
@@ -91,7 +93,9 @@ function applyAlignCore(region: Region) {
}
export function shuffle(region: Entity<Region>, rng: RNG) {
region.produce(region => shuffleCore(region, rng));
batch(() => {
region.produce(region => shuffleCore(region, rng));
});
}
function shuffleCore(region: Region, rng: RNG){