docs: sync updated boardgame-core

This commit is contained in:
2026-04-03 17:45:56 +08:00
parent 4d4889f825
commit cbee709a27
2 changed files with 51 additions and 36 deletions
+3 -7
View File
@@ -39,11 +39,10 @@ export function bindRegion<TState, TMeta>(
container: Phaser.GameObjects.Container,
): { cleanup: () => void; objects: Map<string, Phaser.GameObjects.GameObject> } {
const objects = new Map<string, Phaser.GameObjects.GameObject>();
const effects: DisposeFn[] = [];
const offset = options.offset ?? { x: 0, y: 0 };
function syncParts() {
const dispose = effect(function(this: { dispose: () => void }) {
const parts = partsGetter(state.value);
const currentIds = new Set(region.childIds);
for (const [id, obj] of objects) {
@@ -73,14 +72,11 @@ export function bindRegion<TState, TMeta>(
}
}
}
}
const e = effect(syncParts);
effects.push(e);
});
return {
cleanup: () => {
for (const e of effects) e();
dispose();
for (const [, obj] of objects) obj.destroy();
objects.clear();
},