Skip to content
This repository was archived by the owner on Jan 9, 2025. It is now read-only.

Commit

Permalink
Prevent rings from triggering some planet based notifications.
Browse files Browse the repository at this point in the history
  • Loading branch information
Xjph committed Jun 20, 2019
1 parent 8fc3b21 commit 22126a7
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions EDDisco/ScanReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,21 @@ class ScanReader
private readonly ScanEvent scanEvent;
private readonly Dictionary<(string, long), ScanEvent> scanHistory;
private readonly string currentSystem;
private readonly bool isRing;
public List<(string,string,string)> Interest { get; private set; }

public ScanReader (ScanEvent scanEvent, Dictionary<(string,long),ScanEvent> scanHistory, string currentSystem)
{
this.scanEvent = scanEvent;
this.scanHistory = scanHistory;
this.currentSystem = currentSystem;
isRing = scanEvent.BodyName.Contains(" Ring");
Interest = new List<(string,string,string)>();
}

public bool IsInteresting()
{
bool interesting = DefaultInterest() | CustomInterest();
bool interesting = DefaultInterest() || CustomInterest();
if (Interest.Count() == 0)
{
Interest.Add((scanEvent.BodyName, "Uninteresting", string.Empty));
Expand Down Expand Up @@ -53,8 +55,7 @@ private bool DefaultInterest()

//Parent relative checks
if ((scanEvent.Parent?[0].Item1 == "Planet" || scanEvent.Parent?[0].Item1 == "Star") &&
!scanEvent.BodyName.Contains(" Ring") &&
scanHistory.ContainsKey((currentSystem, scanEvent.Parent[0].Item2)))
!isRing && scanHistory.ContainsKey((currentSystem, scanEvent.Parent[0].Item2)))
{
ScanEvent parent = scanHistory[(currentSystem, scanEvent.Parent[0].Item2)];

Expand Down Expand Up @@ -99,19 +100,19 @@ private bool DefaultInterest()
}

// Tiny object
if (scanEvent.StarType == null && scanEvent.Radius < 300000)
if (scanEvent.StarType == null && scanEvent.Radius < 300000 && !isRing)
{
Interest.Add((scanEvent.BodyName, "Small Body", $"Radius: {Math.Truncate((double)scanEvent.Radius / 1000)}km"));
}

// Fast rotation
if (scanEvent.RotationPeriod != null && !scanEvent.TidalLock.GetValueOrDefault(true) && Math.Abs((double)scanEvent.RotationPeriod) < 28800)
if (scanEvent.RotationPeriod != null && !scanEvent.TidalLock.GetValueOrDefault(true) && Math.Abs((double)scanEvent.RotationPeriod) < 28800 && !isRing)
{
Interest.Add((scanEvent.BodyName, "Non-locked body with fast rotation", $"Rotational period: {Math.Abs(Math.Round((decimal)scanEvent.RotationPeriod / 3600, 1))} hours"));
}

// Fast orbit
if (scanEvent.OrbitalPeriod != null && Math.Abs((double)scanEvent.OrbitalPeriod) < 28800)
if (scanEvent.OrbitalPeriod != null && Math.Abs((double)scanEvent.OrbitalPeriod) < 28800 && !isRing)
{
Interest.Add((scanEvent.BodyName, "Fast orbit", $"Orbital Period: {Math.Abs(Math.Round((decimal)scanEvent.OrbitalPeriod / 3600, 1))} hours"));
}
Expand Down

0 comments on commit 22126a7

Please sign in to comment.