コード例 #1
0
        private GUIStyle getGeeAccumStyle(KeepFitCrewMember crew, Period period, GeeLoadingAccumulator accum)
        {
            GameConfig gameConfig = scenarioModule.GetGameConfig();

            GUIStyle style = new GUIStyle(GUI.skin.label);

            style.normal.textColor = Color.green;
            style.wordWrap         = false;

            GeeToleranceConfig tolerance = gameConfig.GetGeeTolerance(period);

            if (tolerance == null)
            {
                return(style);
            }

            float geeWarn  = GeeLoadingCalculator.GetFitnessModifiedGeeTolerance(tolerance.warn, crew, gameConfig);
            float geeFatal = GeeLoadingCalculator.GetFitnessModifiedGeeTolerance(tolerance.fatal, crew, gameConfig);

            float gee = accum.GetLastGeeMeanPerSecond();

            if (gee > geeFatal)
            {
                style.normal.textColor = Color.red;
            }
            else
            {
                if (gee > geeWarn)
                {
                    style.normal.textColor = Color.yellow;
                }
            }

            return(style);
        }
コード例 #2
0
        private GeeLoadingOutCome handleGeeLoadingUpdate(KeepFitCrewMember crewMember,
                                                         float geeLoading,
                                                         float elapsedSeconds,
                                                         GeeLoadingAccumulator accum,
                                                         GeeToleranceConfig tolerance,
                                                         float healthGeeToleranceModifier)
        {
            float meanG;

            if (accum.AccumulateGeeLoading(geeLoading, elapsedSeconds, out meanG))
            {
                float geeWarn  = GeeLoadingCalculator.GetFitnessModifiedGeeTolerance(tolerance.warn, crewMember, gameConfig);
                float geeFatal = GeeLoadingCalculator.GetFitnessModifiedGeeTolerance(tolerance.fatal, crewMember, gameConfig);

                if (meanG > geeFatal)
                {
                    return(GeeLoadingOutCome.GeeFatal);
                }
                else if (meanG > geeWarn)
                {
                    return(GeeLoadingOutCome.GeeWarn);
                }
            }

            return(GeeLoadingOutCome.Ok);
        }
コード例 #3
0
        public float?getFitnessGeeToleranceModifier(string kerbalName)
        {
            if (gameConfig == null)
            {
                return(null);
            }
            KeepFitCrewMember crewMember = getCrewMember(kerbalName);

            return(crewMember != null ? (float?)GeeLoadingCalculator.GetFitnessModifiedGeeTolerance((float)1.0, crewMember, gameConfig) :  null);
        }
コード例 #4
0
        protected void DrawCrew(int windowHandle, ICollection <KeepFitCrewMember> crew, bool showGeeLoadings, bool showAllCrewExpanded)
        {
            GameConfig gameConfig = scenarioModule.GetGameConfig();

            GUILayout.Space(4);
            foreach (KeepFitCrewMember crewMember in crew)
            {
                bool expanded;
                if (showAllCrewExpanded)
                {
                    expanded = true;
                }
                else
                {
                    expandedCrew.TryGetValue(crewMember.Name, out expanded);
                }

                // first line - crewmember name
                GUILayout.BeginHorizontal();
                GUILayout.Label(crewMember.Name + "(" + (crewMember.loaded ? "loaded" : "generated") + ")", uiResources.styleCrewName);
                DrawExperienceTrait(crewMember);
                DrawActivityLevel(crewMember.activityLevel);
                GUILayout.FlexibleSpace();
                if (!showAllCrewExpanded && DrawChevron(expanded))
                {
                    expanded = !expanded;
                    if (expanded)
                    {
                        expandedCrew[crewMember.Name] = true;
                    }
                    else
                    {
                        expandedCrew.Remove(crewMember.Name);
                    }
                }
                GUILayout.EndHorizontal();
                GUILayout.Space(4);

                if (!expanded)
                {
                    continue;
                }

                // second line - fitness current / max
                DrawBar2("Fit", "Current / max Fitness level", (float)crewMember.fitnessLevel, (float)gameConfig.maxFitnessLevel);
                GUILayout.Space(2);

                if (!showGeeLoadings)
                {
                    continue;
                }

                //// 3rd to <n>th line - Gee(inst) current / max
                foreach (Period period in Enum.GetValues(typeof(Period)))
                {
                    GeeToleranceConfig    tolerance = gameConfig.GetGeeTolerance(period);
                    GeeLoadingAccumulator accum;
                    crewMember.geeAccums.TryGetValue(period, out accum);

                    if (accum != null && tolerance != null)
                    {
                        float geeWarn  = GeeLoadingCalculator.GetFitnessModifiedGeeTolerance(tolerance.warn, crewMember, gameConfig);
                        float geeFatal = GeeLoadingCalculator.GetFitnessModifiedGeeTolerance(tolerance.fatal, crewMember, gameConfig);

                        string label   = "G(" + period.ToString().Substring(0, 1) + ")";
                        string tooltip = "Gee(" + period + ") Current / Max - Orange warn, Red fatal";
                        float  level   = accum.GetLastGeeMeanPerSecond();
                        float  max     = geeFatal;//(level < geeFatal ? geeFatal : geeFatal + 20);
                        DrawBar3(label, tooltip, level, geeWarn, geeFatal, max);
                        GUILayout.Space(1);
                    }
                }
            }
        }
コード例 #5
0
        public void FixedUpdate()
        {
            // too spammy
            //this.Log_DebugOnly("FixedUpdate", ".");

            if (gameConfig == null)
            {
                // too spammy
                //this.Log_DebugOnly("FixedUpdate", "No gameConfig - bailing");
                return;
            }

            if (HighLogic.LoadedSceneIsEditor)
            {
                // too spammy
                this.Log_DebugOnly("FixedUpdate", "Not in flight scene - bailing");
                return;
            }

            if (lastGeeLoadingUpdateUT == -1)
            {
                this.Log_DebugOnly("FixedUpdate", "No lastGeeLoadingUpdateUT - skipping this update");

                // don't do anything this time
                this.lastGeeLoadingUpdateUT = Planetarium.GetUniversalTime();
                return;
            }

            double currentUT      = Planetarium.GetUniversalTime();
            float  elapsedSeconds = (float)(currentUT - lastGeeLoadingUpdateUT);

            lastGeeLoadingUpdateUT = currentUT;

            // too spammy
            //this.Log_DebugOnly("FixedUpdate", "[{0}] seconds since last fixed update", elapsedSeconds);

            // just check gee loading on active vessel for now
            Vessel vessel = FlightGlobals.ActiveVessel;

            if (vessel == null)
            {
                this.Log_DebugOnly("FixedUpdate", "No active vessel");
                return;
            }

            // too spammy
            //this.Log_DebugOnly("FixedUpdate", "Checking gee loading for active vessel[{0}]", vessel.GetName());

            float  geeLoading;
            string invalidReason;
            bool   valid = GeeLoadingCalculator.GetGeeLoading(vessel, out geeLoading, out invalidReason);

            if (!valid)
            {
                this.Log_DebugOnly("FixedUpdate", "Gee loading for active vessel[{0}] is not valid currently because[{1}]", vessel.GetName(), invalidReason);
            }
            else
            {
                // too spammy
                //this.Log_DebugOnly("FixedUpdate", "Gee loading for active vessel[{0}] is[{1}] letting the crew know", vessel.GetName(), geeLoading);

                foreach (ProtoCrewMember crewMember in vessel.GetVesselCrew())
                {
                    try
                    {
                        // too spammy
                        //this.Log_DebugOnly("FixedUpdate", "Gee loading for active vessel[{0}] is[{1}] letting [{2}] know", vessel.GetName(), geeLoading, crewMember.name);

                        KeepFitCrewMember keepFitCrewMember = gameConfig.roster.crew[crewMember.name];

                        handleGeeLoadingUpdates(keepFitCrewMember, geeLoading, elapsedSeconds);
                    }
                    catch (KeyNotFoundException)
                    {
                        // ignore, we'll pick them up later
                        this.Log_Release("KeepFitGeeEffectsController:FixedUpdate", "Gee loading for active vessel[{0}] is[{1}] crewmember [{2}] not in the keepfit roster yet", vessel.GetName(), geeLoading, crewMember.name);
                    }
                }
            }
        }
コード例 #6
0
        public void FixedUpdate()
        {
            // too spammy
            //this.Log_DebugOnly("FixedUpdate", ".");

            if (gameConfig == null)
            {
                // too spammy
                //this.Log_DebugOnly("FixedUpdate", "No gameConfig - bailing");
                return;
            }

            if (HighLogic.LoadedSceneIsEditor)
            {
                // too spammy
                this.Log_DebugOnly("FixedUpdate", "Not in flight scene - bailing");
                return;
            }

            // just check gee loading on active vessel for now
            Vessel vessel = FlightGlobals.ActiveVessel;

            if (vessel == null)
            {
                this.Log_DebugOnly("FixedUpdate", "No active vessel");
                return;
            }

            if (lastGeeLoadingUpdateUT == -1)
            {
                this.Log_DebugOnly("FixedUpdate", "No lastGeeLoadingUpdateUT - skipping this update");

                if (vessel.situation == Vessel.Situations.LANDED || vessel.situation == Vessel.Situations.SPLASHED || vessel.situation == Vessel.Situations.PRELAUNCH)
                {
                    gStart = (float)vessel.mainBody.GeeASL;
                }
                else
                {
                    gStart = 0;
                }

                gHistory              = Enumerable.Repeat(gStart, 300).ToList();
                gLoads[Period.Inst]   = gStart;
                gLoads[Period.Short]  = gStart;
                gLoads[Period.Medium] = gStart;
                gLoads[Period.Long]   = gStart;

                // don't do anything this time
                this.lastGeeLoadingUpdateUT = Planetarium.GetUniversalTime();
                return;
            }



            // too spammy
            //this.Log_DebugOnly("FixedUpdate", "[{0}] seconds since last fixed update", elapsedSeconds);

            // too spammy
            //this.Log_DebugOnly("FixedUpdate", "Checking gee loading for active vessel[{0}]", vessel.GetName());

            float  geeLoading;
            string invalidReason;
            bool   valid = GeeLoadingCalculator.GetGeeLoading(vessel, out geeLoading, out invalidReason);

            if (!valid)
            {
                this.Log_DebugOnly("FixedUpdate", "Gee loading for active vessel[{0}] is not valid currently because[{1}]", vessel.GetName(), invalidReason);
            }
            else
            {
                // too spammy
                //this.Log_DebugOnly("FixedUpdate", "Gee loading for active vessel[{0}] is[{1}] letting the crew know", vessel.GetName(), geeLoading);


                double currentUT = Planetarium.GetUniversalTime();

                float elapsedSeconds = (float)(currentUT - lastGeeLoadingUpdateUT);

                if (elapsedSeconds >= 1)
                {
                    lastGeeLoadingUpdateUT = currentUT;

                    gHistory.RemoveAt(299);
                    gHistory.Insert(0, geeLoading);

                    gLoads[Period.Inst]   = geeLoading;
                    gLoads[Period.Short]  = gHistory.GetRange(0, 5).Average();
                    gLoads[Period.Medium] = gHistory.GetRange(0, 60).Average();
                    gLoads[Period.Long]   = gHistory.Average();
                }



                foreach (ProtoCrewMember crewMember in vessel.GetVesselCrew())
                {
                    try
                    {
                        // too spammy
                        //this.Log_DebugOnly("FixedUpdate", "Gee loading for active vessel[{0}] is[{1}] letting [{2}] know", vessel.GetName(), geeLoading, crewMember.name);

                        KeepFitCrewMember keepFitCrewMember = gameConfig.roster.crew[crewMember.name];

                        handleGeeLoadingUpdates(keepFitCrewMember, gLoads);
                    }
                    catch (KeyNotFoundException)
                    {
                        // ignore, we'll pick them up later
                        this.Log_Release("KeepFitGeeEffectsController:FixedUpdate", "Gee loading for active vessel[{0}] is[{1}] crewmember [{2}] not in the keepfit roster yet", vessel.GetName(), geeLoading, crewMember.name);
                    }
                }
            }
        }