private BooleanValue HasImpact() { if (Available()) { return(shared.Vessel == FlightGlobals.ActiveVessel && TRWrapper.ImpactVector().HasValue); } throw new KOSUnavailableAddonException("HASIMPACT", "Trajectories"); }
private Vector PlannedVector() { if (shared.Vessel != FlightGlobals.ActiveVessel) { throw new KOSException("You may only call addons:TR:plannedVect from the active vessel. Always check addons:tr:hasImpact"); } if (Available()) { Vector3 vect = TRWrapper.PlannedDirection(); return(new Vector(vect.x, vect.y, vect.z)); } throw new KOSUnavailableAddonException("PLANNEDDIRECTION", "Trajectories"); }
private void SetTarget(GeoCoordinates target) { if (shared.Vessel != FlightGlobals.ActiveVessel) { throw new KOSException("You may only call addons:TR:SetTarget from the active vessel."); } if (Available()) { TRWrapper.SetTarget(target.Latitude, target.Longitude, target.GetTerrainAltitude()); return; } throw new KOSUnavailableAddonException("SETTARGET", "Trajectories"); }
private void ResetDescentProfile(ScalarValue aoa) { if (shared.Vessel != FlightGlobals.ActiveVessel) { throw new KOSException("You may only call addons:tr:RESETDESCENTPROFILE from the active vessel."); } if (Available()) { TRWrapper.ResetDescentProfile(aoa * Mathf.Deg2Rad); return; } throw new KOSUnavailableAddonException("RESETDESCENTPROFILE", "Trajectories"); }
private void ClearTarget() { if (shared.Vessel != FlightGlobals.ActiveVessel) { throw new KOSException("You may only call addons:tr:CLEARTARGET from the active vessel."); } if (Available()) { TRWrapper.ClearTarget(); return; } throw new KOSUnavailableAddonException("CLEARTARGET", "Trajectories"); }
// v2.0.0 HasTarget suffix. private BooleanValue HasTarget() { if (shared.Vessel != FlightGlobals.ActiveVessel) { throw new KOSException("You may only call addons:TR:HasTarget from the active vessel."); } if (Available()) { bool?result = TRWrapper.HasTarget(); if (result != null) { return(result); } throw new KOSException("HasTarget is not available. It was added in Trajectories v2.0.0. and your version might be older." + " Check addons:tr:IsVerTwo or addons:tr:GetVersion"); } throw new KOSUnavailableAddonException("HASTARGET", "Trajectories"); }
private Vector CorrectedVector() { if (shared.Vessel != FlightGlobals.ActiveVessel) { throw new KOSException("You may only call addons:TR:CorrectedVect from the active vessel and must also have a trajectories target set." + " Always check addons:tr:HasImpact and addons:tr:HasTarget"); } if (Available()) { Vector3?vect = TRWrapper.CorrectedDirection(); if (vect != null) { Vector3 vector = (Vector3)vect; return(new Vector(vector.x, vector.y, vector.z)); } throw new KOSException("Corrected Vector is not available. Remember to check addons:tr:HasImpact and addons:tr:HasTarget"); } throw new KOSUnavailableAddonException("CORRECTEDDIRECTION", "Trajectories"); }
// v2.2.0 and above suffixes. private ScalarValue TimeTillImpact() { if (shared.Vessel != FlightGlobals.ActiveVessel) { throw new KOSException("You may only call addons:TR:TimeTillImpact from the active vessel."); } if (Available()) { double?result = TRWrapper.GetTimeTillImpact(); if (result != null) { return(result); } throw new KOSException("TimeTillImpact is not available. Remember to check addons:tr:HasImpact." + " Also TimeTillImpact was added in Trajectories v2.2.0. and your version might be older." + " Check addons:tr:IsVerTwoTwo or addons:tr:GetVersion"); } throw new KOSUnavailableAddonException("TIMETILLIMPACT", "Trajectories"); }
private Vector PlannedVector() { if (shared.Vessel != FlightGlobals.ActiveVessel) { throw new KOSException("You may only call addons:tr:PLANNEDVECT from the active vessel and must also have a trajectories target set." + " Always check addons:tr:HASIMPACT and addons:tr:HASTARGET"); } if (Available()) { Vector3?vect = TRWrapper.PlannedDirection(); if (vect != null) { Vector3 vector = (Vector3)vect; return(new Vector(vector.x, vector.y, vector.z)); } throw new KOSException("PLANNEDVECT is not available. Remember to check addons:tr:HASIMPACT and addons:tr:HASTARGET"); } throw new KOSUnavailableAddonException("PLANNEDVECT", "Trajectories"); }
// Older suffixes. private GeoCoordinates ImpactPos() { if (shared.Vessel != FlightGlobals.ActiveVessel) { throw new KOSException("You may only call addons:TR:ImpactPos from the active vessel. Always check addons:tr:HasImpact"); } if (Available()) { CelestialBody body = shared.Vessel.orbit.referenceBody; Vector3? impactVect = TRWrapper.ImpactVector(); if (impactVect != null) { var worldImpactPos = (Vector3d)impactVect + body.position; var lat = body.GetLatitude(worldImpactPos); var lng = Utils.DegreeFix(body.GetLongitude(worldImpactPos), -180); return(new GeoCoordinates(shared, lat, lng)); } throw new KOSException("Impact position is not available. Remember to check addons:tr:HasImpact"); } throw new KOSUnavailableAddonException("IMPACTPOS", "Trajectories"); }
// v2.4.0 and above suffixes. private GeoCoordinates GetTarget() { if (shared.Vessel != FlightGlobals.ActiveVessel) { throw new KOSException("You may only call addons:tr:GETTARGET from the active vessel and must also have a trajectories target set." + " Always check addons:tr:HASTARGET"); } if (Available()) { Vector3d?result = TRWrapper.GetTarget(); if (result != null) { return(new GeoCoordinates(shared, result.Value.x, result.Value.y)); } throw new KOSException("GETTARGET is not available or no target is set. Remember to check addons:tr:HASTARGET." + " Also GETTARGET was added in Trajectories v2.4.0. and your version might be older." + " Check addons:tr:ISVERTWOFOUR or addons:tr:GETVERSION"); } throw new KOSUnavailableAddonException("GETTARGET", "Trajectories"); }
public override BooleanValue Available() { return(TRWrapper.Wrapped()); }
public override BooleanValue Available() => TRWrapper.Wrapped();