Skip to content

Commit

Permalink
Fix #368: make sure boarding from EVA works consistently
Browse files Browse the repository at this point in the history
-previously we only hooked up the FSM modifications on GoEVA, which means kerbals that were already on EVA don't  get handled
  • Loading branch information
JonnyOThan committed Mar 1, 2024
1 parent 1d37dd7 commit bb6a1f7
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions FreeIva/FreeIva.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,17 @@ public static InternalModuleFreeIva CurrentInternalModuleFreeIva
get; private set;
}

void Awake()
{
Paused = false;
GameEvents.onGamePause.Add(OnPause);
GameEvents.onGameUnpause.Add(OnUnPause);
GameEvents.onVesselWasModified.Add(OnVesselWasModified);
GameEvents.onSameVesselDock.Add(OnSameVesselDockingChange);
GameEvents.onSameVesselUndock.Add(OnSameVesselDockingChange);
GameEvents.onVesselChange.Add(OnVesselChange);
}

public void Start()
{
GuiUtils.DrawGui =
Expand All @@ -78,14 +89,6 @@ public void Start()
false;
#endif

Paused = false;
GameEvents.onGamePause.Add(OnPause);
GameEvents.onGameUnpause.Add(OnUnPause);
GameEvents.onVesselWasModified.Add(OnVesselWasModified);
GameEvents.onSameVesselDock.Add(OnSameVesselDockingChange);
GameEvents.onSameVesselUndock.Add(OnSameVesselDockingChange);
GameEvents.onCrewOnEva.Add(OnCrewOnEva);

Settings.LoadSettings();
SetRenderQueues(FlightGlobals.ActiveVessel.rootPart);

Expand All @@ -98,12 +101,14 @@ public void Start()
ivaSun.ivaLight.shadows = LightShadows.Hard;
}

private void OnCrewOnEva(GameEvents.FromToAction<Part, Part> data)
private void OnVesselChange(Vessel vessel)
{
StartCoroutine(ModifyEvaFsm(data.to));
if (vessel.evaController != null)
{
StartCoroutine(ModifyEvaFsm(vessel.evaController));
}
}


internal static Part FindPartWithEmptySeat(Part sourcePart)
{
if (sourcePart.protoModuleCrew.Count < sourcePart.CrewCapacity)
Expand Down Expand Up @@ -232,10 +237,8 @@ public static void BoardPartFromAirlock(KerbalEVA kerbalEva, bool checkInventory
}
}

private IEnumerator ModifyEvaFsm(Part kerbalPart)
private IEnumerator ModifyEvaFsm(KerbalEVA kerbalEva)
{
var kerbalEva = kerbalPart.GetModule<KerbalEVA>();

while (!kerbalEva.Ready)
{
yield return null;
Expand Down Expand Up @@ -282,7 +285,7 @@ public void OnDestroy()
GameEvents.onVesselWasModified.Remove(OnVesselWasModified);
GameEvents.onSameVesselDock.Remove(OnSameVesselDockingChange);
GameEvents.onSameVesselUndock.Remove(OnSameVesselDockingChange);
GameEvents.onCrewOnEva.Remove(OnCrewOnEva);
GameEvents.onVesselChange.Remove(OnVesselChange);
InputLockManager.RemoveControlLock("FreeIVA");
}

Expand Down

0 comments on commit bb6a1f7

Please sign in to comment.