From cd246c76e86a50e94cf58eaebcc0dcac1a3c1cd4 Mon Sep 17 00:00:00 2001 From: Xjph Date: Mon, 15 Nov 2021 11:19:57 -0330 Subject: [PATCH] Implement close binary check --- ObservatoryExplorer/DefaultCriteria.cs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/ObservatoryExplorer/DefaultCriteria.cs b/ObservatoryExplorer/DefaultCriteria.cs index 2f6e483..145d0ce 100644 --- a/ObservatoryExplorer/DefaultCriteria.cs +++ b/ObservatoryExplorer/DefaultCriteria.cs @@ -125,6 +125,27 @@ namespace Observatory.Explorer results.Add("Fast Orbit", $"Orbital Period: {Math.Abs(scan.OrbitalPeriod / 3600):N1} hours"); } + // Close binary pair + if ((settings.CloseBinary || settings.CollidingBinary) && scan.Parent?[0].ParentType == ParentType.Null && scan.Radius / scan.SemiMajorAxis > 0.4) + { + var binaryPartner = scanHistory[scan.SystemAddress].Where(priorScan => priorScan.Value.Parent?[0].Body == scan.Parent?[0].Body && scan.BodyID != priorScan.Key); + + if (binaryPartner.Count() == 1) + { + if (binaryPartner.First().Value.Radius / binaryPartner.First().Value.SemiMajorAxis > 0.4) + { + if (settings.CollidingBinary && binaryPartner.First().Value.Radius + scan.Radius >= binaryPartner.First().Value.SemiMajorAxis * (1 - binaryPartner.First().Value.Eccentricity) + scan.SemiMajorAxis * (1 - scan.Eccentricity)) + { + results.Add(("COLLIDING binary", $"Orbit: {Math.Truncate((double)scan.SemiMajorAxis / 1000):N0}km, Radius: {Math.Truncate((double)scan.Radius / 1000):N0}km, Partner: {binaryPartner.First().Value.BodyName}")); + } + else if (settings.CloseBinary) + { + results.Add(("Close binary relative to body size", $"Orbit: {Math.Truncate((double)scan.SemiMajorAxis / 1000):N0}km, Radius: {Math.Truncate((double)scan.Radius / 1000):N0}km, Partner: {binaryPartner.First().Value.BodyName}")); + } + } + } + } + if (settings.GoodFSDBody && scan.Landable) { List boostMaterials = new()