Fix Y-based depth sorting for world objects #32
@@ -589,7 +589,7 @@ export class VillagerSystem {
|
|||||||
// Silhouette: same texture, white fill, fixed high depth so it shows through
|
// Silhouette: same texture, white fill, fixed high depth so it shows through
|
||||||
// trees and buildings. Visibility is toggled per frame by isOccluded().
|
// trees and buildings. Visibility is toggled per frame by isOccluded().
|
||||||
const outlineSprite = this.scene.add.image(v.x, v.y, 'villager')
|
const outlineSprite = this.scene.add.image(v.x, v.y, 'villager')
|
||||||
.setScale(1.1)
|
.setScale(1.15)
|
||||||
.setTintFill(0xaaddff)
|
.setTintFill(0xaaddff)
|
||||||
.setAlpha(0.85)
|
.setAlpha(0.85)
|
||||||
.setDepth(900)
|
.setDepth(900)
|
||||||
@@ -648,19 +648,22 @@ export class VillagerSystem {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if a world object (tree, rock, or building) with a higher tileY
|
* Returns true if a world object (tree, rock, or building) with a higher tileY
|
||||||
* than the Nisse exists on the same column, meaning the Nisse is visually
|
* exists in the vicinity of the Nisse and would visually occlude them.
|
||||||
* behind that object. Checks 1–3 tiles below to account for tall tree canopies.
|
* Checks a 3-column × 4-row window below the Nisse's tile to account for
|
||||||
|
* wide tree canopies that extend above and to the sides of the trunk tile.
|
||||||
* @param tileX - Nisse's current tile column
|
* @param tileX - Nisse's current tile column
|
||||||
* @param tileY - Nisse's current tile row
|
* @param tileY - Nisse's current tile row
|
||||||
*/
|
*/
|
||||||
private isOccluded(tileX: number, tileY: number): boolean {
|
private isOccluded(tileX: number, tileY: number): boolean {
|
||||||
const state = stateManager.getState()
|
const state = stateManager.getState()
|
||||||
for (let dy = 1; dy <= 3; dy++) {
|
const buildings = Object.values(state.world.buildings)
|
||||||
const checkY = tileY + dy
|
for (let dx = -1; dx <= 1; dx++) {
|
||||||
if (this.worldSystem.hasResourceAt(tileX, checkY)) return true
|
for (let dy = 1; dy <= 4; dy++) {
|
||||||
if (Object.values(state.world.buildings).some(
|
const cx = tileX + dx
|
||||||
b => b.tileX === tileX && b.tileY === checkY && b.kind !== 'stockpile_zone'
|
const cy = tileY + dy
|
||||||
)) return true
|
if (this.worldSystem.hasResourceAt(cx, cy)) return true
|
||||||
|
if (buildings.some(b => b.tileX === cx && b.tileY === cy && b.kind !== 'stockpile_zone')) return true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user