public Dictionary<Vector2, Tile> Expand(List<Vector2> selection, int distance)
{
var ret = new Dictionary<Vector2, Tile>();
if (distance <= 0) return ret;
for (int i = 1; i <= distance; i++)
{
foreach (var pos in selection)
{
//TODO: optimization for bigger distances would be to remove the 'inner' tiles from the selection
//so they aren't rechecked every iteration
var neighbors = GetNeighbors(pos);
var untouchedNeighbors = neighbors.Where(x => !selection.Contains(x.Key));
foreach (var neighbor in untouchedNeighbors)
{
if (ret.ContainsKey(neighbor.Key)) continue;
ret.Add(neighbor.Key, neighbor.Value);
}
}
selection.ForEach(s => ret.Add(s, mapModel.tiles[s]));
selection = ret.Keys.ToList();
}
return ret;
}