Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop returning null if no next patch #2009

Merged
merged 1 commit into from
May 10, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/kOS/Suffixed/OrbitInfo.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using kOS.Safe.Encapsulation;
using kOS.Safe.Encapsulation.Suffixes;
using System;
using kOS.Safe.Exceptions;
using kOS.Serialization;
using kOS.Safe.Serialization;
using kOS.Safe;
using System;

namespace kOS.Suffixed
{
Expand Down Expand Up @@ -98,14 +97,18 @@ public OrbitableVelocity GetVelocityAtUT( TimeSpan timeStamp )
surfVel = new Vector( orbVel.X, orbVel.Y, orbVel.Z );
return new OrbitableVelocity( orbVel, surfVel );
}

/// <summary>
/// Return the next OrbitInfo after this one (i.e. transitional encounter)
/// </summary>
/// <returns>an OrbitInfo, or a null if there isn't any.</returns>
private OrbitInfo GetNextPatch()
{
return ! GetHasNextPatch() ? null : new OrbitInfo(orbit.nextPatch,Shared);
if (GetHasNextPatch())
{
return new OrbitInfo(orbit.nextPatch, Shared);
}
throw new KOSSituationallyInvalidException("Cannot get next patch when no additional patches exist. Try checking the HASNEXTPATCH suffix.");
}

/// <summary>
Expand All @@ -118,7 +121,7 @@ private ScalarValue GetNextPatchETA()
{
return orbit.EndUT - Planetarium.GetUniversalTime();
}
throw new Safe.Exceptions.KOSSituationallyInvalidException("Cannot get eta to next patch when no additional patches exist. Try checking the HASNEXTPATCH suffix.");
throw new KOSSituationallyInvalidException("Cannot get eta to next patch when no additional patches exist. Try checking the HASNEXTPATCH suffix.");
}

/// <summary>
Expand Down