public void Clear() { if (isOutput && !empty) { foreach (Connection c in OtherConnections.ToList()) c.Clear(); } else if (!empty) { point = null; OtherConnection.OtherConnections.Remove(this); OtherConnection.empty = OtherConnection.OtherConnections.Count == 0; } empty = true; }
public static CablePoint NearestPoint(List<CablePoint> points, float maxDist, float x, float y) { float best = float.PositiveInfinity; CablePoint bestPoint = null; foreach (CablePoint point in points) { float dist = (point.x - x) * (point.x - x) + (point.y - y) * (point.y - y); if (dist < best && dist < maxDist * maxDist) { best = dist; bestPoint = point; } } return bestPoint; }