refactor: improve tic tac toe with region entity
This commit is contained in:
+7
-3
@@ -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){
|
||||
|
||||
Reference in New Issue
Block a user