diff --git a/TestFlightCore/TestFlightCore/TestFlightCore.cs b/TestFlightCore/TestFlightCore/TestFlightCore.cs index 47926d7..1f5ce81 100644 --- a/TestFlightCore/TestFlightCore/TestFlightCore.cs +++ b/TestFlightCore/TestFlightCore/TestFlightCore.cs @@ -770,10 +770,19 @@ private void OnEngineActiveChange(ModuleEngines data) OnFlightStart(); } + private void OnVesselSituationChange(GameEvents.HostedFromToAction ev) + { + if (ev.from == Vessel.Situations.PRELAUNCH && ev.host == FlightGlobals.ActiveVessel) + { + OnFlightStart(); + } + } + private void OnFlightStart() { GameEvents.onStageActivate.Remove(OnStageActivate); GameEvents.onEngineActiveChange.Remove(OnEngineActiveChange); + GameEvents.onVesselSituationChange.Remove(OnVesselSituationChange); firstStaged = true; missionStartTime = Planetarium.GetUniversalTime(); } @@ -856,10 +865,17 @@ public override void Start() GameEvents.onCrewTransferred.Add(OnCrewChange); _OnCrewChange(); firstStaged = vessel.situation != Vessel.Situations.PRELAUNCH; - if (vessel.situation == Vessel.Situations.PRELAUNCH) + + if (!firstStaged && part.isEngine()) + { + firstStaged = part.FindModulesImplementing().Find(e => e.staged) != null; + } + + if (!firstStaged) { GameEvents.onStageActivate.Add(OnStageActivate); GameEvents.onEngineActiveChange.Add(OnEngineActiveChange); + GameEvents.onVesselSituationChange.Add(OnVesselSituationChange); } else missionStartTime = Planetarium.GetUniversalTime(); @@ -872,6 +888,7 @@ public override void OnDestroy() GameEvents.onCrewTransferred.Remove(OnCrewChange); GameEvents.onStageActivate.Remove(OnStageActivate); GameEvents.onEngineActiveChange.Remove(OnEngineActiveChange); + GameEvents.onVesselSituationChange.Remove(OnVesselSituationChange); } public override void OnAwake()