AutoAsparagus.ASPFuelLine.nearestNeighborWithoutFuelLine C# (CSharp) Method

nearestNeighborWithoutFuelLine() private static method

private static nearestNeighborWithoutFuelLine ( Part tank, string partName, List brothers ) : Part
tank Part
partName string
brothers List
return Part
        private static Part nearestNeighborWithoutFuelLine(Part tank, string partName, List<Part> brothers)
        {
            // Check through symmetry partners, find closest tank that doesn't have a fuel line already
            float closestDistance = 9999f;
            Part closestPart = null;
            foreach (Part p in brothers) {
                if (!hasFuelLine (p, partName)) {
                    float distance = distanceBetweenParts (tank, p);
                    if (distance < closestDistance) {
                        closestDistance = distance;
                        closestPart = p;
                    }
                }
            }
            return closestPart;
        }