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); }
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); }
internal override void DrawWindow(int id) { base.DrawWindow(id); GameConfig config = scenarioModule.GetGameConfig(); GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); GUILayout.Label("KeepFit v" + Statics.GetDllVersion(this) + " : " + (config.enabled ? "Enabled" : "Disabled")); GUILayout.FlexibleSpace(); if (GUILayout.Button((config.enabled ? "Disable" : "Enable"), GUILayout.Width(80))) { config.enabled = !config.enabled; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Choose a Skin"); GUILayout.FlexibleSpace(); if (GUILayout.Button(new GUIContent("KSP Style", "Sets the style to be the default KSPStyle"))) { SkinsLibrary.SetCurrent(SkinsLibrary.DefSkinType.KSP); } if (GUILayout.Button(new GUIContent("Unity Style", "Sets the style to be the default Unity Style"))) { SkinsLibrary.SetCurrent(SkinsLibrary.DefSkinType.Unity); } GUILayout.EndHorizontal(); config.wimpMode = GUILayout.Toggle(config.wimpMode, "WimpMode: ", GUILayout.Width(80)); config.useBestPartOnVessel = GUILayout.Toggle(config.useBestPartOnVessel, "Use Best Overall Part On Vessel: ", GUILayout.Width(80)); if (scenarioModule.GetCLS() != null) { config.applyCLSLimitsIfAvailable = GUILayout.Toggle(config.applyCLSLimitsIfAvailable, "Apply CLS limits: ", GUILayout.Width(80)); } showFloatEditor("Min Gee For Exercising when Landed", ref wipMinimumLandedGeeForExcercising, ref config.minimumLandedGeeForExcercising, ref config, true); showFloatEditor("Initial fitness level", ref wipInitialFitnessLevel, ref config.initialFitnessLevel, ref config, true); showFloatEditor("Min fitness level", ref wipMinFitnessLevel, ref config.minFitnessLevel, ref config, true); showFloatEditor("Max fitness level", ref wipMaxFitnessLevel, ref config.maxFitnessLevel, ref config, true); foreach (Period period in Enum.GetValues(typeof(Period))) { GeeToleranceConfig geeToleranceConfig = config.GetGeeTolerance(period); WipValuePair wipValuePair = wipGeeTolerances[period]; showFloatPairEditor("Tolerance (" + period + ")", "Warn", "Fatal", ref wipValuePair, ref geeToleranceConfig.warn, ref geeToleranceConfig.fatal, ref config); } GUILayout.EndVertical(); }
private bool tryHandleWithGEffectsMod(KeepFitCrewMember crewMember, float geeLoading, float elapsedSeconds, GeeLoadingAccumulator accum, GeeToleranceConfig tolerance, float healthGeeToleranceModifier) { if (!gEffectsAPI.isInitialized()) { return(false); } double?downwardG = gEffectsAPI.getDownwardG(crewMember.Name); double?forwardG = gEffectsAPI.getForwardG(crewMember.Name); if ((downwardG == null) || (forwardG == null)) { return(false); } //The plain (medical) sum of longitudal and lateral G loads is used for G. Also the regular vector module Math.Sqrt(Math.Pow(downwardG, 2) + Math.Pow(upwardG, 2)) may be used. handleGeeLoadingUpdate(crewMember, Math.Abs((float)downwardG) + Math.Abs((float)forwardG), elapsedSeconds, accum, tolerance, healthGeeToleranceModifier); //The outcome is ignored for not displaying warning messages because G-Effects mod has enough visual warnings itself return(true); }
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; }
private bool tryHandleWithGEffectsMod(KeepFitCrewMember crewMember, float geeLoading, float elapsedSeconds, GeeLoadingAccumulator accum, GeeToleranceConfig tolerance, float healthGeeToleranceModifier) { if (! gEffectsAPI.isInitialized()) { return false; } double? downwardG = gEffectsAPI.getDownwardG(crewMember.Name); double? forwardG = gEffectsAPI.getForwardG(crewMember.Name); if ((downwardG == null) || (forwardG == null)) { return false; } //The plain (medical) sum of longitudal and lateral G loads is used for G. Also the regular vector module Math.Sqrt(Math.Pow(downwardG, 2) + Math.Pow(upwardG, 2)) may be used. handleGeeLoadingUpdate(crewMember, Math.Abs((float)downwardG) + Math.Abs((float)forwardG), elapsedSeconds, accum, tolerance, healthGeeToleranceModifier); //The outcome is ignored for not displaying warning messages because G-Effects mod has enough visual warnings itself return true; }
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); } } } }
public GeeToleranceConfigAndPeriod(Period period, GeeToleranceConfig config) { this.period = period; this.tolerance = config; }