public static OptimizedLocation GetOptimizedCircleLocation(List <Vector2> champPositions, float width, float range, // ReSharper disable once InconsistentNaming int useMECMax = 9) { var result = new Vector2(); var champsHit = 0; var startPos = ObjectManager.Player.ServerPosition.To2D(); range = range * range; if (champPositions.Count == 0) { return(new OptimizedLocation(result, champsHit)); } if (champPositions.Count <= useMECMax) { var subGroups = GetCombinations(champPositions); foreach (var subGroup in subGroups) { if (subGroup.Count > 0) { var circle = MEC.GetMec(subGroup); if (circle.Radius <= width && circle.Center.Distance(startPos, true) <= range) { champsHit = subGroup.Count; return(new OptimizedLocation(circle.Center, champsHit)); } } } } else { foreach (var pos in champPositions) { if (pos.Distance(startPos, true) <= range) { var count = champPositions.Count(pos2 => pos.Distance(pos2, true) <= width * width); if (count >= champsHit) { result = pos; champsHit = count; } } } } return(new OptimizedLocation(result, champsHit)); }