コード例 #1
0
 private BooleanValue HasImpact()
 {
     if (Available())
     {
         return(shared.Vessel == FlightGlobals.ActiveVessel && TRWrapper.ImpactVector().HasValue);
     }
     throw new KOSUnavailableAddonException("HASIMPACT", "Trajectories");
 }
コード例 #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");
 }
コード例 #3
0
ファイル: Addon.cs プロジェクト: stephengeorgewest/KOS-1
 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");
 }
コード例 #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");
 }
コード例 #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");
 }
コード例 #6
0
ファイル: Addon.cs プロジェクト: stephengeorgewest/KOS-1
 // 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");
 }
コード例 #7
0
ファイル: Addon.cs プロジェクト: stephengeorgewest/KOS-1
 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");
 }
コード例 #8
0
ファイル: Addon.cs プロジェクト: stephengeorgewest/KOS-1
 // 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");
 }
コード例 #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");
 }
コード例 #10
0
ファイル: Addon.cs プロジェクト: stephengeorgewest/KOS-1
 // 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");
 }
コード例 #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");
        }
コード例 #12
0
 public override BooleanValue Available()
 {
     return(TRWrapper.Wrapped());
 }
コード例 #13
0
 public override BooleanValue Available() => TRWrapper.Wrapped();