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); }
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); }
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); }
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); } } } }