public void ChangeSurfVelocity() { active = false; //DaMichel: Avoid conflict between multiple vessels in physics range. We only want to show the speed of the active vessel. if (FlightGlobals.ActiveVessel != _vessel) { return; } //DaMichel: Keep our fingers off of this also if there is no atmosphere (staticPressure <= 0) if (FlightUIController.speedDisplayMode != FlightUIController.SpeedDisplayModes.Surface || _vessel.atmDensity <= 0) { return; } double unitConversion = 1; string unitString = "m/s"; string caption; if (unitMode == SurfaceVelUnit.KNOTS) { unitConversion = 1.943844492440604768413343347219; unitString = "knots"; } else if (unitMode == SurfaceVelUnit.KM_H) { unitConversion = 3.6; unitString = "km/h"; } else if (unitMode == SurfaceVelUnit.MPH) { unitConversion = 2.236936; unitString = "mph"; } if (velMode == SurfaceVelMode.TAS) { caption = "Surface"; velString = (_vessel.srfSpeed * unitConversion).ToString("F1") + unitString; } else { if (velMode == SurfaceVelMode.IAS) { caption = "IAS"; double densityRatio = (FARAeroUtil.GetCurrentDensity(_vessel.mainBody, _vessel.altitude, false) / 1.225); double pressureRatio = FARAeroUtil.StagnationPressureCalc(_vessel.mach); velString = (_vessel.srfSpeed * Math.Sqrt(densityRatio) * pressureRatio * unitConversion).ToString("F1") + unitString; } else if (velMode == SurfaceVelMode.EAS) { caption = "EAS"; double densityRatio = (FARAeroUtil.GetCurrentDensity(_vessel.mainBody, _vessel.altitude, false) / 1.225); velString = (_vessel.srfSpeed * Math.Sqrt(densityRatio) * unitConversion).ToString("F1") + unitString; } else// if (velMode == SurfaceVelMode.MACH) { caption = "Mach"; velString = _vessel.mach.ToString("F3"); } } active = true; FlightUIController UI = FlightUIController.fetch; if (UI.spdCaption == null || UI.speed == null) { return; } UI.spdCaption.text = caption; UI.speed.text = velString; }