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