Skip to content

Commit 47e807c

Browse files
committed
Fix height offset bug, adjust height offset calculation to allow replacing back cliffs
1 parent bc26f31 commit 47e807c

2 files changed

Lines changed: 26 additions & 8 deletions

File tree

src/TSMapEditor/Mutations/Classes/PlaceTerrainTileMutation.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,23 @@ public override void Perform()
7171
if (image.TmpImage == null)
7272
continue;
7373

74-
int cx = targetCellCoords.X + (tile.Width) + i % tile.Width;
75-
int cy = targetCellCoords.Y + (tile.Height) + i / tile.Width;
74+
int cx = targetCellCoords.X + i % tile.Width;
75+
int cy = targetCellCoords.Y + i / tile.Width;
7676

7777
var mapTile = MutationTarget.Map.GetTile(cx, cy);
78+
7879
if (mapTile != null)
7980
{
80-
if (originLevel < 0 || mapTile.Level < originLevel)
81-
originLevel = mapTile.Level;
81+
var existingTile = Map.TheaterInstance.GetTile(mapTile.TileIndex).GetSubTile(mapTile.SubTileIndex);
82+
83+
int cellLevel = mapTile.Level;
84+
85+
// Allow replacing back cliffs
86+
if (existingTile.TmpImage.Height == image.TmpImage.Height)
87+
cellLevel -= existingTile.TmpImage.Height;
88+
89+
if (originLevel < 0 || cellLevel < originLevel)
90+
originLevel = cellLevel;
8291
}
8392
}
8493

src/TSMapEditor/UI/CursorActions/PlaceTerrainCursorAction.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,23 @@ private void DoActionForCells(Point2D cellCoords, Action<MapTile> action)
6767
if (image.TmpImage == null)
6868
continue;
6969

70-
int cx = adjustedCellCoords.X + Tile.Width + i % Tile.Width;
71-
int cy = adjustedCellCoords.Y + Tile.Height + i / Tile.Width;
70+
int cx = adjustedCellCoords.X + i % Tile.Width;
71+
int cy = adjustedCellCoords.Y + i / Tile.Width;
7272

7373
var mapTile = MutationTarget.Map.GetTile(cx, cy);
74+
7475
if (mapTile != null)
7576
{
76-
if (originLevel < 0 || mapTile.Level < originLevel)
77-
originLevel = mapTile.Level;
77+
var existingTile = Map.TheaterInstance.GetTile(mapTile.TileIndex).GetSubTile(mapTile.SubTileIndex);
78+
79+
int cellLevel = mapTile.Level;
80+
81+
// Allow replacing back cliffs
82+
if (existingTile.TmpImage.Height == image.TmpImage.Height)
83+
cellLevel -= existingTile.TmpImage.Height;
84+
85+
if (originLevel < 0 || cellLevel < originLevel)
86+
originLevel = cellLevel;
7887
}
7988
}
8089

0 commit comments

Comments
 (0)