private void AddIsland(IMap map, int totalLength, int width) { if (map.Polygons.Any(p => p.IsInside && p.DistanceFromEdge >= width)) { Queue<Polygon> queue = new Queue<Polygon>(); var direction = Geometry.GetRandomUnitVector(); Polygon current; do { current = map.GetRandomPolygon(); } while (!(current.IsInside && current.DistanceFromEdge >= width)); CreateSkeleton(width, direction, current, totalLength, queue, m_Random.Next(2) == 0); while (queue.Count > 0) { current = queue.Dequeue(); if (current.DistanceFromSkeleton < width) { foreach (var polygon in current.Polygons) { if (polygon.IsInside && !polygon.InSkeleton && polygon.DistanceFromEdge > 0) { polygon.InSkeleton = true; polygon.IsLand = true; polygon.DistanceFromSkeleton = current.DistanceFromSkeleton + 1; queue.Enqueue(polygon); } } } } } foreach (var polygon in map.Polygons) { polygon.InSkeleton = false; } }