Skip to content

Commit

Permalink
Fix height offset bug, adjust height offset calculation to allow repl…
Browse files Browse the repository at this point in the history
…acing back cliffs
  • Loading branch information
Rampastring committed Jan 17, 2024
1 parent bc26f31 commit 47e807c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
17 changes: 13 additions & 4 deletions src/TSMapEditor/Mutations/Classes/PlaceTerrainTileMutation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,23 @@ public override void Perform()
if (image.TmpImage == null)
continue;

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

var mapTile = MutationTarget.Map.GetTile(cx, cy);

if (mapTile != null)
{
if (originLevel < 0 || mapTile.Level < originLevel)
originLevel = mapTile.Level;
var existingTile = Map.TheaterInstance.GetTile(mapTile.TileIndex).GetSubTile(mapTile.SubTileIndex);

int cellLevel = mapTile.Level;

// Allow replacing back cliffs
if (existingTile.TmpImage.Height == image.TmpImage.Height)
cellLevel -= existingTile.TmpImage.Height;

if (originLevel < 0 || cellLevel < originLevel)
originLevel = cellLevel;
}
}

Expand Down
17 changes: 13 additions & 4 deletions src/TSMapEditor/UI/CursorActions/PlaceTerrainCursorAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,23 @@ private void DoActionForCells(Point2D cellCoords, Action<MapTile> action)
if (image.TmpImage == null)
continue;

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

var mapTile = MutationTarget.Map.GetTile(cx, cy);

if (mapTile != null)
{
if (originLevel < 0 || mapTile.Level < originLevel)
originLevel = mapTile.Level;
var existingTile = Map.TheaterInstance.GetTile(mapTile.TileIndex).GetSubTile(mapTile.SubTileIndex);

int cellLevel = mapTile.Level;

// Allow replacing back cliffs
if (existingTile.TmpImage.Height == image.TmpImage.Height)
cellLevel -= existingTile.TmpImage.Height;

if (originLevel < 0 || cellLevel < originLevel)
originLevel = cellLevel;
}
}

Expand Down

0 comments on commit 47e807c

Please sign in to comment.