void Start()
        {
            if (!CompatibilityChecker.IsAllCompatible())
            {
                this.enabled = false;
                return;
            }

            _vessel                = GetComponent <Vessel>();
            _vesselAero            = GetComponent <FARVesselAero>();
            _physicsCalcs          = new PhysicsCalcs(_vessel, _vesselAero);
            _flightStatusGUI       = new FlightStatusGUI();
            _stabilityAugmentation = new StabilityAugmentation(_vessel);
            _flightDataGUI         = new FlightDataGUI();
            _aeroVizGUI            = new AeroVisualizationGUI();

            settingsWindow = new GUIDropDown <int>(new string[4] {
                "Flt Data", "Stab Aug", "Air Spd", "Aero Viz"
            }, new int[4] {
                0, 1, 2, 3
            }, 0);
            //boxStyle.padding = new RectOffset(4, 4, 4, 4);

            if (vesselFlightGUI.ContainsKey(_vessel))
            {
                vesselFlightGUI[_vessel] = this;
            }
            else
            {
                vesselFlightGUI.Add(_vessel, this);
            }

            this.enabled = true;

            if (FARDebugValues.useBlizzyToolbar)
            {
                GenerateBlizzyToolbarButton();
            }
            else
            {
                OnGUIAppLauncherReady();
            }

            activeFlightGUICount++;

            if (_vessel == FlightGlobals.ActiveVessel || FlightGlobals.ActiveVessel == null)
            {
                LoadConfigs();
            }

            GameEvents.onShowUI.Add(ShowUI);
            GameEvents.onHideUI.Add(HideUI);
        }
Ejemplo n.º 2
0
        protected override void OnStart()
        {
            base.OnStart();

            if (!CompatibilityChecker.IsAllCompatible())
            {
                enabled = false;
                return;
            }

            showGUI = savedShowGUI;
            //since we're sharing the button, we need these shenanigans now
            if (FARDebugAndSettings.FARDebugButtonStock && HighLogic.LoadedSceneIsFlight)
            {
                if (showGUI)
                {
                    FARDebugAndSettings.FARDebugButtonStock.SetTrue(false);
                }
                else
                {
                    FARDebugAndSettings.FARDebugButtonStock.SetFalse(false);
                }
            }


            _vessel                = GetComponent <Vessel>();
            _vesselAero            = GetComponent <FARVesselAero>();
            _physicsCalcs          = new PhysicsCalcs(_vessel, _vesselAero);
            _flightStatusGUI       = new FlightStatusGUI();
            _stabilityAugmentation = new StabilityAugmentation(_vessel);
            _flightDataGUI         = new FlightDataGUI();
            AeroVizGUI             = new AeroVisualizationGUI();

            settingsWindow = new GUIDropDown <int>(new[]
            {
                Localizer.Format("FARFlightGUIWindowSelect0"),
                Localizer.Format("FARFlightGUIWindowSelect1"),
                Localizer.Format("FARFlightGUIWindowSelect2"),
                Localizer.Format("FARFlightGUIWindowSelect3")
            },
                                                   new[] { 0, 1, 2, 3 });

            if (vesselFlightGUI.ContainsKey(_vessel))
            {
                vesselFlightGUI[_vessel] = this;
            }
            else
            {
                vesselFlightGUI.Add(_vessel, this);
            }

            enabled = true;

            if (FARDebugValues.useBlizzyToolbar)
            {
                GenerateBlizzyToolbarButton();
            }

            activeFlightGUICount++;

            if (_vessel == FlightGlobals.ActiveVessel || FlightGlobals.ActiveVessel == null)
            {
                LoadConfigs();
            }

            GameEvents.onShowUI.Add(ShowUI);
            GameEvents.onHideUI.Add(HideUI);
        }
        void Start()
        {
            if (!CompatibilityChecker.IsAllCompatible())
            {
                this.enabled = false;
                return;
            }

            _vessel = GetComponent<Vessel>();
            _vesselAero = GetComponent<FARVesselAero>();
            _physicsCalcs = new PhysicsCalcs(_vessel, _vesselAero);
            _flightStatusGUI = new FlightStatusGUI();
            _stabilityAugmentation = new StabilityAugmentation(_vessel);
            _flightDataGUI = new FlightDataGUI();
            _aeroVizGUI = new AeroVisualizationGUI();

            settingsWindow = new GUIDropDown<int>(new string[4]{"Flt Data","Stab Aug", "Air Spd","Aero Viz"}, new int[4]{0,1,2,3}, 0);
            //boxStyle.padding = new RectOffset(4, 4, 4, 4);

            if (vesselFlightGUI.ContainsKey(_vessel))
                vesselFlightGUI[_vessel] = this;
            else
                vesselFlightGUI.Add(_vessel, this);

            this.enabled = true;

            if (FARDebugValues.useBlizzyToolbar)
            {
                GenerateBlizzyToolbarButton();
            }
            else
                OnGUIAppLauncherReady();

            activeFlightGUICount++;

            if(_vessel == FlightGlobals.ActiveVessel)
                LoadConfigs();

            GameEvents.onShowUI.Add(ShowUI);
            GameEvents.onHideUI.Add(HideUI);
        }
        //Returns the tinted color if active; else it returns an alpha 0 color
        private Color AeroVisualizationTintingCalculation(AeroVisualizationGUI aeroVizGUI)
        {
            // Disable tinting for low dynamic pressure to prevent flicker
            if (vessel.dynamicPressurekPa <= 0.00001)
                return new Color(0, 0, 0, 0);

            // Stall tinting overrides Cl / Cd tinting
            if (legacyWingModel != null && aeroVizGUI.TintForStall)
                return new Color((float)((legacyWingModel.GetStall() * 100.0) / aeroVizGUI.FullySaturatedStall), 0f, 0f, 0.5f);

            if (!aeroVizGUI.TintForCl && !aeroVizGUI.TintForCd)
                return new Color(0, 0, 0, 0);

            double visualizationCl = 0, visualizationCd = 0;

            if (projectedArea.totalArea > 0.0)
            {
                Vector3 worldVelNorm = partTransform.localToWorldMatrix.MultiplyVector(partLocalVelNorm);
                Vector3 worldDragArrow = Vector3.Dot(totalWorldSpaceAeroForce, worldVelNorm) * worldVelNorm;
                Vector3 worldLiftArrow = totalWorldSpaceAeroForce - worldDragArrow;

                double invAndDynPresArea = legacyWingModel != null ? legacyWingModel.S : projectedArea.totalArea;
                invAndDynPresArea *= vessel.dynamicPressurekPa;
                invAndDynPresArea = 1 / invAndDynPresArea;
                visualizationCl = worldLiftArrow.magnitude * invAndDynPresArea;
                visualizationCd = worldDragArrow.magnitude * invAndDynPresArea;
            }

            double fullSatCl = 0, satCl = 0, fullSatCd = 0, satCd = 0;

            if (legacyWingModel != null)
            {
                fullSatCl = aeroVizGUI.FullySaturatedCl;
                fullSatCd = aeroVizGUI.FullySaturatedCd;
            }
            else
            {
                fullSatCl = aeroVizGUI.FullySaturatedClBody;
                fullSatCd = aeroVizGUI.FullySaturatedCdBody;
            }

            if (aeroVizGUI.TintForCl)
                satCl = Math.Abs(visualizationCl / fullSatCl);
            if (aeroVizGUI.TintForCd)
                satCd = Math.Abs(visualizationCd / fullSatCd);

            return new Color((float)satCd, 0.5f * (float)(satCl + satCd), (float)satCl, 0.5f);
        }