Empty a deleted tile's cells on every tilemap (#268)

Deleting a tile left the cells painted with it in the tilemaps. They
drew nothing, blocked nothing and did not show in the delete dialog,
but still read as a tile for "Tile at" and stopped a fill.

- DeleteAssetCommand empties the cells of a deleted tile on every
  layer of every tilemap in the same step. Undo puts the tile and its
  cells back together.
- The delete dialog counts them, for example "3 cell(s) on 1
  tilemap(s) are painted with it and become empty." (cellsPainted).
- presentTile treats a cell naming a missing tile as empty. "Tile at"
  (World.tileAt) and floodFill use it, so cells already in existing
  files read and fill as empty. There is no migration.
- The brush, the rectangle and the fill check the tile in hand. A
  tile deleted after it was picked no longer paints new invisible
  cells, the editor says "Choose a tile to paint with." instead.
- Unchanged on purpose: the picker still reports such a cell as
  naming a tile that no longer exists, and erasing removes it.

Tests:
- ./check.sh: 195 files, 2823 tests, CHECK EXIT 0 (+6).
- GM_STEPS=39,40: ALL PASSED, 100 checks (4 new in 40t).
- Full e2e sum is now 1590 (1586 confirmed by CI on round 8, plus 4).
- Counter-checks, all fail as expected: 5 in unit tests (delete
  without emptying, undo without cells, fill and "Tile at" without
  presentTile, wrong map count) and 3 in the browser (dialog without
  count, delete without emptying, brush without the check).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
adminandClaude Opus 5.5 committed 2026-09-29 19:00:22 +02:00
1 parent 14972d057f
commit 9b5eeaab57
11 files changed
+310 -38

No files matched your search

+7 -3
View File
@@ -8,7 +8,7 @@ import { bakeInstances, materializeInstance, objectRef, resolveObjects } from '.
import { groupNamed, treeOrder } from '../core/model/hierarchy';
import { liveTileAt, withTile } from '../core/model/liveTilemap';
import { referenceCandidates } from '../core/model/objectRefs';
import type { Cell } from '../core/model/tilemap';
import { type Cell, presentTile } from '../core/model/tilemap';
import { descendantsBelow } from '../core/model/walk';
import { findAsset, findAssetOf, findScene, type Project } from '../core/model/Project';
import { createSceneObject, objectName, type SceneObject } from '../core/model/SceneObject';
@@ -189,10 +189,14 @@ export class World {
return this.tilemapAssetOf(entity) !== undefined;
}
/** The tile in a cell of a placed tilemap as the run left it (see `model/liveTilemap.ts`). */
/**
* The tile in a cell of a placed tilemap as the run left it (see `model/liveTilemap.ts`), `''` for
* a cell naming a tile the project does not have, as it is drawn.
*/
tileAt(entity: Entity, layer: string, cell: Cell): string | null {
const asset = this.tilemapAssetOf(entity);
return asset ? liveTileAt(asset, entity.tileEdits, entity.props, layer, cell) : null;
const tile = asset ? liveTileAt(asset, entity.tileEdits, entity.props, layer, cell) : null;
return tile === null ? null : presentTile(this.project, tile);
}
/** Sets a cell of this one placement for the rest of the run; `''` empties it. */