Ejemplo n.º 1
0
 private BooleanValue HasImpact()
 {
     if (Available())
     {
         return(shared.Vessel == FlightGlobals.ActiveVessel && TRWrapper.ImpactVector().HasValue);
     }
     throw new KOSUnavailableAddonException("HASIMPACT", "Trajectories");
 }
Ejemplo n.º 2
0
 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");
 }
Ejemplo n.º 3
0
 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");
 }
Ejemplo n.º 4
0
 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");
 }
Ejemplo n.º 5
0
 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");
 }
Ejemplo n.º 6
0
 // 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");
 }
Ejemplo n.º 7
0
 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");
 }
Ejemplo n.º 8
0
 // 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");
 }
Ejemplo n.º 9
0
 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");
 }
Ejemplo n.º 10
0
 // 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");
 }
Ejemplo n.º 11
0
        // 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");
        }
Ejemplo n.º 12
0
 public override BooleanValue Available()
 {
     return(TRWrapper.Wrapped());
 }
Ejemplo n.º 13
0
 public override BooleanValue Available() => TRWrapper.Wrapped();