public void FixedUpdate() { LoadDelayedModules(); CheckControlledVessel(); //make sure our onFlyByWire callback is registered with the right vessel if (this != vessel.GetMasterMechJeb() || (HighLogic.LoadedSceneIsFlight && !vessel.isActiveVessel)) { wasMasterAndFocus = false; } if (this != vessel.GetMasterMechJeb()) { return; } if (!wasMasterAndFocus && (HighLogic.LoadedSceneIsEditor || vessel.isActiveVessel)) { if (HighLogic.LoadedSceneIsFlight && (lastFocus != null) && lastFocus.loaded && (lastFocus.GetMasterMechJeb() != null)) { print("Focus changed! Forcing " + lastFocus.vesselName + " to save"); lastFocus.GetMasterMechJeb().OnSave(null); } OnLoad(null); // Force Global reload wasMasterAndFocus = true; lastFocus = vessel; } if (modulesUpdated) { computerModules.Sort(); modulesUpdated = false; } if (vessel == null) { return; //don't run ComputerModules' OnFixedUpdate in editor } vesselState.Update(vessel); foreach (ComputerModule module in computerModules) { try { if (module.enabled) { module.OnFixedUpdate(); } } catch (Exception e) { Debug.LogError("MechJeb module " + module.GetType().Name + " threw an exception in OnFixedUpdate: " + e); } } }
public void FixedUpdate() { if (!FlightGlobals.ready) { return; } LoadDelayedModules(); CheckControlledVessel(); //make sure our onFlyByWire callback is registered with the right vessel if (this != vessel.GetMasterMechJeb() || (HighLogic.LoadedSceneIsFlight && !vessel.isActiveVessel)) { wasMasterAndFocus = false; } if (this != vessel.GetMasterMechJeb()) { return; } Profiler.BeginSample("MechJebCore.FixedUpdate"); if (!wasMasterAndFocus && (HighLogic.LoadedSceneIsEditor || vessel.isActiveVessel)) { if (HighLogic.LoadedSceneIsFlight && (lastFocus != null) && lastFocus.loaded && (lastFocus.GetMasterMechJeb() != null)) { print("Focus changed! Forcing " + lastFocus.vesselName + " to save"); lastFocus.GetMasterMechJeb().OnSave(null); } // Clear the modules cache ClearModulesCache(); OnLoad(null); // Force Global reload wasMasterAndFocus = true; lastFocus = vessel; } if (vessel == null) { Profiler.EndSample(); return; //don't run ComputerModules' OnFixedUpdate in editor } Profiler.BeginSample("vesselState"); ready = vesselState.Update(vessel); Profiler.EndSample(); foreach (ComputerModule module in GetComputerModules <ComputerModule>()) { Profiler.BeginSample(module.profilerName); try { if (module.enabled) { module.OnFixedUpdate(); } } catch (Exception e) { Debug.LogError("MechJeb module " + module.GetType().Name + " threw an exception in OnFixedUpdate: " + e); } Profiler.EndSample(); } Profiler.EndSample(); }