Skip to content

Commit

Permalink
ensure fill clones tile data
Browse files Browse the repository at this point in the history
  • Loading branch information
colegarien committed Aug 16, 2024
1 parent 1c8be02 commit 970ada6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Ozzyria.Gryp/Models/Data/Layer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ public void PaintArea(TileBoundary? region, Tile tileData, int originX, int orig
var fillDown = GetTileData(toFillX, toFillY + 1)?.Equal(toFillTile) ?? false;
var fillUp = GetTileData(toFillX, toFillY - 1)?.Equal(toFillTile) ?? false;

PushTile(tileData, toFillX, toFillY);
PushTile(tileData.Clone(), toFillX, toFillY);
toFill.RemoveAt(0);

if (fillRight)
Expand Down
7 changes: 7 additions & 0 deletions Ozzyria.Gryp/Models/Data/Tile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ internal class Tile
{
public List<string> DrawableIds { get; set; } = new List<string>();

public Tile Clone()
{
Tile tile = new Tile();
tile.DrawableIds.AddRange(DrawableIds);
return tile;
}

public bool Equal(Tile other)
{
if(DrawableIds.Count <= 0 && other.DrawableIds.Count <= 0) return true;
Expand Down

0 comments on commit 970ada6

Please sign in to comment.