diff --git a/src/client/graphics/layers/NukeTrajectoryPreviewLayer.ts b/src/client/graphics/layers/NukeTrajectoryPreviewLayer.ts index f7f9dbe64..ffe63ba23 100644 --- a/src/client/graphics/layers/NukeTrajectoryPreviewLayer.ts +++ b/src/client/graphics/layers/NukeTrajectoryPreviewLayer.ts @@ -264,7 +264,7 @@ export class NukeTrajectoryPreviewLayer implements Layer { } } - // Shared helper to resolve the current target tile, preferring a locked ghost tile when present + // resolve the current target tile, preferring a locked ghost tile when present private getTargetTile(): TileRef | null { if (this.uiState.lockedGhostTile) { return this.uiState.lockedGhostTile; diff --git a/src/client/graphics/layers/StructureIconsLayer.ts b/src/client/graphics/layers/StructureIconsLayer.ts index 26acb0698..7deeba45b 100644 --- a/src/client/graphics/layers/StructureIconsLayer.ts +++ b/src/client/graphics/layers/StructureIconsLayer.ts @@ -558,24 +558,22 @@ export class StructureIconsLayer implements Layer { this.removeGhostStructure(); } - private getTileFromContextMenuEvent(e: ContextMenuEvent): TileRef | null { + private getTileFromScreenCoords(x: number, y: number): TileRef | null { const rect = this.transformHandler.boundingRect(); if (!rect) return null; - const x = e.x - rect.left; - const y = e.y - rect.top; - const tile = this.transformHandler.screenToWorldCoordinates(x, y); + const localX = x - rect.left; + const localY = y - rect.top; + const tile = this.transformHandler.screenToWorldCoordinates(localX, localY); if (!this.game.isValidCoord(tile.x, tile.y)) return null; return this.game.ref(tile.x, tile.y); } + private getTileFromContextMenuEvent(e: ContextMenuEvent): TileRef | null { + return this.getTileFromScreenCoords(e.x, e.y); + } + private getTileFromMouseEvent(e: MouseUpEvent): TileRef | null { - const rect = this.transformHandler.boundingRect(); - if (!rect) return null; - const x = e.x - rect.left; - const y = e.y - rect.top; - const tile = this.transformHandler.screenToWorldCoordinates(x, y); - if (!this.game.isValidCoord(tile.x, tile.y)) return null; - return this.game.ref(tile.x, tile.y); + return this.getTileFromScreenCoords(e.x, e.y); } private resolveTargetTileFromEvent(e: MouseUpEvent): TileRef | null {