private Tile InnerApply(TileGridLayer tileLayer, int x, int y) { TileCoord[] coordSet = NeighborCoordSet(x, y); List <int> neighbors = new List <int>(); for (int i = 0; i < coordSet.Length; i++) { if (ContainsMemberTile(tileLayer.TilesAt(coordSet[i]))) { neighbors.Add(i + 1); } } List <LocatedTile> targetStack = new List <LocatedTile>(); foreach (LocatedTile tile in tileLayer.TilesAt(new TileCoord(x, y))) { targetStack.Add(tile); } foreach (LocatedTile tile in targetStack) { if (IsMemberTile(tile)) { tileLayer.RemoveTile(x, y, tile.Tile); } } int index = _brushClass.ApplyRules(neighbors); Tile newTile = null; if (index >= 0 && index < _tiles.Count && _tiles[index].Tile != null) { newTile = _tiles[index].Tile; } if (newTile != null) { tileLayer.AddTile(x, y, newTile); } return(newTile); }
public override void ApplyBrush(TileGridLayer tileLayer, int x, int y) { List <LocatedTile> updatedTiles = new List <LocatedTile>(); updatedTiles.Add(new LocatedTile(InnerApply(tileLayer, x, y), x, y)); // Update valid neighboring tiles foreach (TileCoord coord in NeighborCoordSet(x, y)) { if (ContainsMemberTile(tileLayer.TilesAt(coord))) { updatedTiles.Add(new LocatedTile(InnerApply(tileLayer, coord.X, coord.Y), coord.X, coord.Y)); } } }
private Tile InnerApply(TileGridLayer tileLayer, int x, int y) { TileCoord[] coordSet = NeighborCoordSet(x, y); List<int> neighbors = new List<int>(); for (int i = 0; i < coordSet.Length; i++) { if (ContainsMemberTile(tileLayer.TilesAt(coordSet[i]))) neighbors.Add(i + 1); } List<LocatedTile> targetStack = new List<LocatedTile>(); foreach (LocatedTile tile in tileLayer.TilesAt(new TileCoord(x, y))) targetStack.Add(tile); foreach (LocatedTile tile in targetStack) { if (IsMemberTile(tile)) tileLayer.RemoveTile(x, y, tile.Tile); } int index = _brushClass.ApplyRules(neighbors); Tile newTile = null; if (index >= 0 && index < _tiles.Count && _tiles[index].Tile != null) newTile = _tiles[index].Tile; if (newTile != null) tileLayer.AddTile(x, y, newTile); return newTile; }
public override void ApplyBrush(TileGridLayer tileLayer, int x, int y) { List<LocatedTile> updatedTiles = new List<LocatedTile>(); updatedTiles.Add(new LocatedTile(InnerApply(tileLayer, x, y), x, y)); // Update valid neighboring tiles foreach (TileCoord coord in NeighborCoordSet(x, y)) { if (ContainsMemberTile(tileLayer.TilesAt(coord))) updatedTiles.Add(new LocatedTile(InnerApply(tileLayer, coord.X, coord.Y), coord.X, coord.Y)); } }