BlueGit

timfa questward

Show door (per-tile block) previews in the world editor hover.

Atlas rebuild alone skipped perTileBlock sprites; apply preview in #drawTile and refresh those tiles on set/clear.

timfa Tim Falken · pushed by timfa

Authored 2026-09-02 · 2 months ago

Hash
91a49842a6d9d6447aacab82ca47527f38e92ee7
Parent
8c53edf3
1 file changed +9 −2
client/src/render/worldView.js +9 −2
@@ -2183,7 +2183,10 @@ export class WorldView
2183 2183 const prevKey = `${Math.floor(previous.tileX / CHUNK_SIZE)},${Math.floor(previous.tileY / CHUNK_SIZE)}`;
2184 2184 if (prevKey !== `${chunkX},${chunkY}`)
2185 2185 { this.#scheduleChunkRebuild(this.chunks.get(prevKey)); }
2186 // Per-tile blocks (doors, campfires, …) are not in the atlas — refresh sprites.
2187 this.#drawTile(previous.tileX, previous.tileY);
2186 2188 }
2189 this.#drawTile(tileX, tileY);
2187 2190 }
2188 2191
2189 2192 clearTilePreview ()
@@ -2194,6 +2197,7 @@ export class WorldView
2194 2197 this.preview = null;
2195 2198 const snapshot = this.chunks.get(`${Math.floor(previous.tileX / CHUNK_SIZE)},${Math.floor(previous.tileY / CHUNK_SIZE)}`);
2196 2199 this.#scheduleChunkRebuild(snapshot);
2200 this.#drawTile(previous.tileX, previous.tileY);
2197 2201 }
2198 2202
2199 2203 #lerpMs (gait)
@@ -3655,16 +3659,19 @@ export class WorldView
3655 3659 objects.waterEdges = null;
3656 3660 }
3657 3661
3662 let blockSource = snapshot.blocks[index];
3663 if (this.preview && this.preview.tileX === tileX && this.preview.tileY === tileY && this.preview.block !== undefined)
3664 { blockSource = this.preview.block; }
3658 3665 const tileBlock = tileBlockSpriteEntry(
3659 3666 this.catalog,
3660 3667 this.game.images,
3661 snapshot.blocks[index],
3668 blockSource,
3662 3669 this.worldSeason
3663 3670 );
3664 3671 if (tileBlock)
3665 3672 {
3666 3673 const pivot = tilePivot(tileX, tileY, this.tileSize());
3667 const blockEntry = normalizeBlock(snapshot.blocks[index]);
3674 const blockEntry = normalizeBlock(blockSource);
3668 3675 const blockDef = blockDefinition(blockEntry?.typeId);
3669 3676 const blockSort = blockDef?.door
3670 3677 ? doorSortSubOrder(blockEntry?.state, SORT_ENTITY)
@@ -2183,7 +2183,10 @@ export class WorldView
2183 const prevKey = `${Math.floor(previous.tileX / CHUNK_SIZE)},${Math.floor(previous.tileY / CHUNK_SIZE)}`;
2183 const prevKey = `${Math.floor(previous.tileX / CHUNK_SIZE)},${Math.floor(previous.tileY / CHUNK_SIZE)}`;
2184 if (prevKey !== `${chunkX},${chunkY}`)
2184 if (prevKey !== `${chunkX},${chunkY}`)
2185 { this.#scheduleChunkRebuild(this.chunks.get(prevKey)); }
2185 { this.#scheduleChunkRebuild(this.chunks.get(prevKey)); }
2186 // Per-tile blocks (doors, campfires, …) are not in the atlas — refresh sprites.
2187 this.#drawTile(previous.tileX, previous.tileY);
2186 }
2188 }
2189 this.#drawTile(tileX, tileY);
2187 }
2190 }
2188
2191
2189 clearTilePreview ()
2192 clearTilePreview ()
@@ -2194,6 +2197,7 @@ export class WorldView
2194 this.preview = null;
2197 this.preview = null;
2195 const snapshot = this.chunks.get(`${Math.floor(previous.tileX / CHUNK_SIZE)},${Math.floor(previous.tileY / CHUNK_SIZE)}`);
2198 const snapshot = this.chunks.get(`${Math.floor(previous.tileX / CHUNK_SIZE)},${Math.floor(previous.tileY / CHUNK_SIZE)}`);
2196 this.#scheduleChunkRebuild(snapshot);
2199 this.#scheduleChunkRebuild(snapshot);
2200 this.#drawTile(previous.tileX, previous.tileY);
2197 }
2201 }
2198
2202
2199 #lerpMs (gait)
2203 #lerpMs (gait)
@@ -3655,16 +3659,19 @@ export class WorldView
3655 objects.waterEdges = null;
3659 objects.waterEdges = null;
3656 }
3660 }
3657
3661
3662 let blockSource = snapshot.blocks[index];
3663 if (this.preview && this.preview.tileX === tileX && this.preview.tileY === tileY && this.preview.block !== undefined)
3664 { blockSource = this.preview.block; }
3658 const tileBlock = tileBlockSpriteEntry(
3665 const tileBlock = tileBlockSpriteEntry(
3659 this.catalog,
3666 this.catalog,
3660 this.game.images,
3667 this.game.images,
3661 snapshot.blocks[index],
3668 blockSource,
3662 this.worldSeason
3669 this.worldSeason
3663 );
3670 );
3664 if (tileBlock)
3671 if (tileBlock)
3665 {
3672 {
3666 const pivot = tilePivot(tileX, tileY, this.tileSize());
3673 const pivot = tilePivot(tileX, tileY, this.tileSize());
3667 const blockEntry = normalizeBlock(snapshot.blocks[index]);
3674 const blockEntry = normalizeBlock(blockSource);
3668 const blockDef = blockDefinition(blockEntry?.typeId);
3675 const blockDef = blockDefinition(blockEntry?.typeId);
3669 const blockSort = blockDef?.door
3676 const blockSort = blockDef?.door
3670 ? doorSortSubOrder(blockEntry?.state, SORT_ENTITY)
3677 ? doorSortSubOrder(blockEntry?.state, SORT_ENTITY)