public virtual List <Tile> GetEmptyTiles ( GenerationConstraints constraints = null, bool canBeNextToDoors = true, bool nodeIndexMustMatch = false//allows skipping childIsland tiles ) { var tt = new TimeTracker(); var emptyTiles = new List <Tile>(); if (!created) { return(emptyTiles); } DoGridAction((int col, int row) => { if (IsTileEmpty(tiles[row, col])// != null && tiles[row, col].IsEmpty //null can be outside the walls ) { var tile = tiles[row, col]; if (!nodeIndexMustMatch || tile.DungeonNodeIndex == NodeIndex) { var pt = new Point(col, row); if (constraints == null || (constraints.IsInside(pt))) { emptyTiles.Add(tile); } } } }); //if (constraints != null && constraints.Tiles != null) //{ // emptyTiles = emptyTiles.Where(i => constraints.Tiles.Contains(i)).ToList(); //} if (!canBeNextToDoors) { emptyTiles = emptyTiles.Where(i => !GetNeighborTiles(i).Any(j => j is Dungeons.Tiles.Door)).ToList(); } //Log("GetEmptyTiles time: "+tt.TotalSeconds, false); return(emptyTiles); }
public Tile GetRandomEmptyTile(GenerationConstraints constraints = null, bool canBeNextToDoors = true, int?nodeIndex = null) { var emptyTiles = GetEmptyTiles(constraints, canBeNextToDoors); return(GetRandomEmptyTile(emptyTiles, nodeIndex)); }