public static void Update() { Vessel vessel = FlightGlobals.ActiveVessel; if (vessel == null) { return; } if (destinationAirfield == null) { return; } distanceToAirfield = NavUtils.DistanceToAirfield(vessel, destinationAirfield); bearingToAirfield = NavUtils.InitialBearingToAirfield(vessel, destinationAirfield); // do this not to often and not in an airfield if (landingRunway == null || distanceToAirfield > 2000 || !InBeam) { landingRunway = destinationAirfield.GetLandingRunwayForBearing(bearingToAirfield); ILS = landingRunway.HasILS; } if (landingRunway != null) { // Bearing to runway bearingToRunway = NavUtils.InitialBearingToRunway(vessel, landingRunway); if (bearingToRunway < 0) { bearingToRunway = 360 - bearingToRunway; } // // distance to runway distanceToRunway = NavUtils.DistanceToRunway(vessel, landingRunway); // // glide slope horizontalGlideslopeDeviation = NavUtils.HorizontalGlideSlopeDeviation(bearingToRunway, landingRunway); verticalGlideslopeDeviation = NavUtils.VerticalGlideSlopeDeviation(vessel, landingRunway); // // check if we are inside the ILS cone bool insideHorizontalBeam = NavUtils.InsideCone(bearingToRunway, landingRunway.To, landingRunway.ILSCone); bool insideVerticalBeam = NavUtils.InsideCone(verticalGlideslopeDeviation, 0.0, landingRunway.ILSCone); InBeam = insideHorizontalBeam && insideVerticalBeam && distanceToRunway <= landingRunway.ILSRange; } else { bearingToRunway = 0.0; distanceToRunway = double.MaxValue; InBeam = false; horizontalGlideslopeDeviation = double.MaxValue; verticalGlideslopeDeviation = double.MaxValue; } }