public void PaintPit(RectInt cell, bool paintWalls) { BoundsInt floorCheck = cell.ToBoundsInt(); floorCheck.size += new Vector3Int(2, 2, 0); floorCheck.position -= new Vector3Int(1, 1, 0); TileBase[] floorTiles = _floors.GetTilesBlock(floorCheck); if (floorTiles.Any(x => x == null)) { return; } Vector3Int pos = new Vector3Int(cell.xMin, cell.yMin, 0); Vector3Int size = new Vector3Int(cell.width, cell.height, 1); TileBase[] tiles = new TileBase[size.x * size.y]; for (int i = 0; i < size.x * size.y; i++) { tiles[i] = _pitContainer.FloorTiles.GetRandom(); //FloorTiles[0]; } _pits.SetTilesBlock(new BoundsInt(pos, size), tiles); if (paintWalls) { for (int i = 0; i < size.x * size.y; i++) { tiles[i] = null; int x = i % size.x + pos.x; int y = i / size.x + pos.y; if (x == pos.x && y == pos.y) { tiles[i] = _pitContainer.BottomLeft; } else if (x == pos.x && y == cell.yMax - 1) { tiles[i] = _pitContainer.TopLeft; } else if (x == cell.xMax - 1 && y == pos.y) { tiles[i] = _pitContainer.BottomRight; } else if (x == cell.xMax - 1 && y == cell.yMax - 1) { tiles[i] = _pitContainer.TopRight; } else if (y == cell.yMax - 1) { tiles[i] = _pitContainer.TopMiddle; } else if (y == pos.y) { tiles[i] = _pitContainer.BottomMiddle; } else if (x == cell.xMax - 1) { tiles[i] = _pitContainer.MiddleRight; } else if (x == pos.x) { tiles[i] = _pitContainer.MiddleLeft; } } _pits.SetTilesBlock(new BoundsInt(pos, size), tiles); } }