Example #1
0
        public double TotalDeltaVAtmosphere()
        {
            MechJebModuleStageStats stats = core.GetComputerModule <MechJebModuleStageStats>();

            stats.RequestUpdate(this);
            return(stats.atmoStats.Sum(s => s.deltaV));
        }
        public float TotalDeltaVVaccum()
        {
            MechJebModuleStageStats stats = core.GetComputerModule <MechJebModuleStageStats>();

            stats.RequestUpdate(this);
            return(stats.vacStats.Sum(s => s.deltaV));
        }
Example #3
0
        public string TotalDeltaVAtmosphereAndVac()
        {
            MechJebModuleStageStats stats = core.GetComputerModule <MechJebModuleStageStats>();

            stats.RequestUpdate(this);

            double atmDv = stats.atmoStats.Sum(s => s.deltaV);
            double vacDv = stats.vacStats.Sum(s => s.deltaV);

            return(String.Format("{0:F0}, {1:F0}", atmDv, vacDv));
        }
Example #4
0
        public string StageDeltaVAtmosphereAndVac()
        {
            MechJebModuleStageStats stats = core.GetComputerModule <MechJebModuleStageStats>();

            stats.RequestUpdate(this);

            double atmDv = (stats.atmoStats.Length == 0) ? 0 : stats.atmoStats[stats.atmoStats.Length - 1].deltaV;
            double vacDv = (stats.vacStats.Length == 0) ? 0 : stats.vacStats[stats.vacStats.Length - 1].deltaV;

            return(String.Format("{0:F0}, {1:F0}", atmDv, vacDv));
        }
Example #5
0
        public double StageDeltaVAtmosphere()
        {
            MechJebModuleStageStats stats = core.GetComputerModule <MechJebModuleStageStats>();

            stats.RequestUpdate(this);

            if (stats.atmoStats.Length == 0)
            {
                return(0);
            }

            return(stats.atmoStats[stats.atmoStats.Length - 1].deltaV);
        }
        public float StageDeltaVVacuum()
        {
            MechJebModuleStageStats stats = core.GetComputerModule <MechJebModuleStageStats>();

            stats.RequestUpdate(this);

            if (stats.vacStats.Length == 0)
            {
                return(0);
            }

            return(stats.vacStats[stats.vacStats.Length - 1].deltaV);
        }
Example #7
0
        public float StageTimeLeftFullThrottle()
        {
            MechJebModuleStageStats stats = core.GetComputerModule <MechJebModuleStageStats>();

            stats.RequestUpdate(this);

            if (stats.vacStats.Length == 0 || stats.atmoStats.Length == 0)
            {
                return(0);
            }

            float vacTimeLeft  = (float)stats.vacStats[stats.vacStats.Length - 1].time;
            float atmoTimeLeft = (float)stats.atmoStats[stats.atmoStats.Length - 1].time;
            float timeLeft     = Mathf.Lerp(vacTimeLeft, atmoTimeLeft, Mathf.Clamp01((float)FlightGlobals.getStaticPressure()));

            return(timeLeft);
        }
Example #8
0
        public void AllStageStats()
        {
            // Unity throws an exception if we change our layout between the Layout event and
            // the Repaint event, so only get new data right before the Layout event.
            MechJebModuleStageStats stats = core.GetComputerModule <MechJebModuleStageStats>();

            KerbalEngineer.VesselSimulator.Stage[] vacStats  = stats.vacStats;
            KerbalEngineer.VesselSimulator.Stage[] atmoStats = stats.atmoStats;
            if (Event.current.type == EventType.Layout)
            {
                stats.RequestUpdate(this);
            }

            int numStages = atmoStats.Length;
            var stages    = Enumerable.Range(0, numStages);

            GUILayout.BeginVertical();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Stage stats", GUILayout.ExpandWidth(true));

            if (HighLogic.LoadedSceneIsEditor)
            {
                // We're in the VAB/SPH
                TWRbody          = GuiUtils.ComboBox.Box(TWRbody, FlightGlobals.Bodies.ConvertAll(b => b.GetName()).ToArray(), this);
                stats.editorBody = FlightGlobals.Bodies[TWRbody];
            }

            if (GUILayout.Button("All stats", GUILayout.ExpandWidth(false)))
            {
                // NK detect necessity of atmo initial TWR
                //bool hasMFE = parts.Any(p => p.IsMFE());

                if (showInitialMass)
                {
                    showInitialTWR = showAtmoInitialTWR = showVacDeltaV = showVacTime = showAtmoDeltaV = showAtmoTime = true;
                    //showAtmoInitialTWR = hasMFE; // NK
                    showInitialMass = showFinalMass = showMaxTWR = false;
                }
                else
                {
                    showInitialMass = showInitialTWR = showAtmoInitialTWR = showMaxTWR = showVacDeltaV = showVacTime = showAtmoDeltaV = showAtmoTime = true;
                    //showAtmoInitialTWR = hasMFE; // NK
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            DrawStageStatsColumn("Stage", stages.Select(s => s.ToString()));
            if (showInitialMass)
            {
                showInitialMass = !DrawStageStatsColumn("Start mass", stages.Select(s => vacStats[s].totalMass.ToString("F1") + " t"));
            }
            if (showFinalMass)
            {
                showFinalMass = !DrawStageStatsColumn("End mass", stages.Select(s => (vacStats[s].totalMass - vacStats[s].resourceMass).ToString("F1") + " t"));
            }
            if (showInitialTWR)
            {
                showInitialTWR = !DrawStageStatsColumn("TWR", stages.Select(s => vacStats[s].thrustToWeight.ToString("F2")));
            }
            if (showAtmoInitialTWR)
            {
                showAtmoInitialTWR = !DrawStageStatsColumn("SLT", stages.Select(s => atmoStats[s].thrustToWeight.ToString("F2")));                     // NK
            }
            if (showMaxTWR)
            {
                showMaxTWR = !DrawStageStatsColumn("Max TWR", stages.Select(s => vacStats[s].maxThrustToWeight.ToString("F2")));
            }
            if (showAtmoDeltaV)
            {
                showAtmoDeltaV = !DrawStageStatsColumn("Atmo ΔV", stages.Select(s => atmoStats[s].deltaV.ToString("F0") + " m/s"));
            }
            //if (showAtmoTime) showAtmoTime = !DrawStageStatsColumn("Atmo time", stages.Select(s => GuiUtils.TimeToDHMS(atmoStats[s].time)));
            if (showVacDeltaV)
            {
                showVacDeltaV = !DrawStageStatsColumn("Vac ΔV", stages.Select(s => vacStats[s].deltaV.ToString("F0") + " m/s"));
            }
            if (showVacTime)
            {
                showVacTime = !DrawStageStatsColumn("Time", stages.Select(s => GuiUtils.TimeToDHMS(vacStats[s].time)));
            }
            GUILayout.EndHorizontal();

            GUILayout.EndVertical();
        }
        public void AllStageStats()
        {
            MechJebModuleStageStats stats = core.GetComputerModule <MechJebModuleStageStats>();

            stats.RequestUpdate(this);

            int numStages = stats.atmoStats.Length;
            var stages    = Enumerable.Range(0, numStages);

            GUILayout.BeginVertical();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Stage stats", GUILayout.ExpandWidth(true));
            if (GUILayout.Button("All stats", GUILayout.ExpandWidth(false)))
            {
                if (showInitialMass)
                {
                    showInitialTWR  = showVacDeltaV = showVacTime = showAtmoDeltaV = showAtmoTime = true;
                    showInitialMass = showFinalMass = showMaxTWR = false;
                }
                else
                {
                    showInitialMass = showInitialTWR = showMaxTWR = showVacDeltaV = showVacTime = showAtmoDeltaV = showAtmoTime = true;
                }
            }
            GUILayout.EndHorizontal();

            double geeASL = (HighLogic.LoadedSceneIsEditor ? 1 : mainBody.GeeASL);

            GUILayout.BeginHorizontal();
            DrawStageStatsColumn("Stage", stages.Select(s => s.ToString()));
            if (showInitialMass)
            {
                showInitialMass = !DrawStageStatsColumn("Start mass", stages.Select(s => stats.vacStats[s].startMass.ToString("F1") + " t"));
            }
            if (showFinalMass)
            {
                showFinalMass = !DrawStageStatsColumn("End mass", stages.Select(s => stats.vacStats[s].endMass.ToString("F1") + " t"));
            }
            if (showInitialTWR)
            {
                showInitialTWR = !DrawStageStatsColumn("TWR", stages.Select(s => stats.vacStats[s].StartTWR(geeASL).ToString("F2")));
            }
            if (showMaxTWR)
            {
                showMaxTWR = !DrawStageStatsColumn("Max TWR", stages.Select(s => stats.vacStats[s].MaxTWR(geeASL).ToString("F2")));
            }
            if (showAtmoDeltaV)
            {
                showAtmoDeltaV = !DrawStageStatsColumn("Atmo ΔV", stages.Select(s => stats.atmoStats[s].deltaV.ToString("F0") + " m/s"));
            }
            if (showAtmoTime)
            {
                showAtmoTime = !DrawStageStatsColumn("Atmo time", stages.Select(s => GuiUtils.TimeToDHMS(stats.atmoStats[s].deltaTime)));
            }
            if (showVacDeltaV)
            {
                showVacDeltaV = !DrawStageStatsColumn("Vac ΔV", stages.Select(s => stats.vacStats[s].deltaV.ToString("F0") + " m/s"));
            }
            if (showVacTime)
            {
                showVacTime = !DrawStageStatsColumn("Vac time", stages.Select(s => GuiUtils.TimeToDHMS(stats.vacStats[s].deltaTime)));
            }
            GUILayout.EndHorizontal();

            GUILayout.EndVertical();
        }
Example #10
0
        public void AllStageStats()
        {
            // Unity throws an exception if we change our layout between the Layout event and
            // the Repaint event, so only get new data right before the Layout event.
            if (Event.current.type == EventType.Layout)
            {
                MechJebModuleStageStats stats = core.GetComputerModule <MechJebModuleStageStats>();
                vacStats  = stats.vacStats;
                atmoStats = stats.atmoStats;
                stats.RequestUpdate(this);
            }

            int numStages = atmoStats.Length;
            var stages    = Enumerable.Range(0, numStages);

            GUILayout.BeginVertical();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Stage stats", GUILayout.ExpandWidth(true));

            double geeASL;

            if (HighLogic.LoadedSceneIsEditor)
            {
                // We're in the VAB/SPH
                TWRbody = (int)GuiUtils.ArrowSelector(TWRbody, FlightGlobals.Bodies.Count, FlightGlobals.Bodies[(int)TWRbody].GetName());
                geeASL  = FlightGlobals.Bodies[TWRbody].GeeASL;
            }
            else
            {
                // We're in flight
                geeASL = mainBody.GeeASL;
            }

            if (GUILayout.Button("All stats", GUILayout.ExpandWidth(false)))
            {
                // NK detect necessity of atmo initial TWR
                bool hasMFE = false;
                if (HighLogic.LoadedSceneIsEditor)
                {
                    foreach (Part p in parts)
                    {
                        if (p.Modules.Contains("ModuleEngineConfigs") || p.Modules.Contains("ModuleHybridEngine") || p.Modules.Contains("ModuleHybridEngines"))
                        {
                            hasMFE = true;
                            break;
                        }
                    }
                }
                else
                {
                    hasMFE = vesselState.hasMFE;
                }

                if (showInitialMass)
                {
                    showInitialTWR     = showVacDeltaV = showVacTime = showAtmoDeltaV = showAtmoTime = true;
                    showAtmoInitialTWR = hasMFE; // NK
                    showInitialMass    = showFinalMass = showMaxTWR = false;
                }
                else
                {
                    showInitialMass    = showInitialTWR = showMaxTWR = showVacDeltaV = showVacTime = showAtmoDeltaV = showAtmoTime = true;
                    showAtmoInitialTWR = hasMFE; // NK
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            DrawStageStatsColumn("Stage", stages.Select(s => s.ToString()));
            if (showInitialMass)
            {
                showInitialMass = !DrawStageStatsColumn("Start mass", stages.Select(s => vacStats[s].startMass.ToString("F1") + " t"));
            }
            if (showFinalMass)
            {
                showFinalMass = !DrawStageStatsColumn("End mass", stages.Select(s => vacStats[s].endMass.ToString("F1") + " t"));
            }
            if (showInitialTWR)
            {
                showInitialTWR = !DrawStageStatsColumn("TWR", stages.Select(s => vacStats[s].StartTWR(geeASL).ToString("F2")));
            }
            if (showAtmoInitialTWR)
            {
                showAtmoInitialTWR = !DrawStageStatsColumn("SLT", stages.Select(s => atmoStats[s].StartTWR(geeASL).ToString("F2")));                     // NK
            }
            if (showMaxTWR)
            {
                showMaxTWR = !DrawStageStatsColumn("Max TWR", stages.Select(s => vacStats[s].MaxTWR(geeASL).ToString("F2")));
            }
            if (showAtmoDeltaV)
            {
                showAtmoDeltaV = !DrawStageStatsColumn("Atmo ΔV", stages.Select(s => atmoStats[s].deltaV.ToString("F0") + " m/s"));
            }
            if (showAtmoTime)
            {
                showAtmoTime = !DrawStageStatsColumn("Atmo time", stages.Select(s => GuiUtils.TimeToDHMS(atmoStats[s].deltaTime)));
            }
            if (showVacDeltaV)
            {
                showVacDeltaV = !DrawStageStatsColumn("Vac ΔV", stages.Select(s => vacStats[s].deltaV.ToString("F0") + " m/s"));
            }
            if (showVacTime)
            {
                showVacTime = !DrawStageStatsColumn("Vac time", stages.Select(s => GuiUtils.TimeToDHMS(vacStats[s].deltaTime)));
            }
            GUILayout.EndHorizontal();

            GUILayout.EndVertical();
        }