private List <DistrictCell> GenerateDistrictCells(VoronoiDiagram voronoi)
{
//Create a district cell from the voronoi cells
var districtCells = new List <DistrictCell>();
foreach (var cell in voronoi.GetCellsInBounds())
{
//ignore cells that are not valid
if (cell.Edges.Count < 2)
{
continue;
}
districtCells.Add(DistrictCell.FromCell(cell, _citySettings.DistrictSettings[0].Type));
}
//tag random cells based on the settings for each district
foreach (var setting in _citySettings.DistrictSettings)
{
for (int i = 0; i < setting.Frequency; ++i)
{
//Get a random start cell from the voronoi
var startCell = districtCells.GetRandomValue();
//size is a ratio of the width and length of the plane
var size = setting.Size * ((voronoi.Bounds.Right + voronoi.Bounds.Bottom) / 8);
//tag cell
districtCells.TagCells(startCell, size, setting.Type);
}
}
return(districtCells);
}