Skip to content

Commit

Permalink
Fix #401: make sure hatches close when they become disconnected via u…
Browse files Browse the repository at this point in the history
…ndocking or decoupling
  • Loading branch information
JonnyOThan committed Oct 26, 2024
1 parent a7506b6 commit 02d76a0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 26 deletions.
16 changes: 6 additions & 10 deletions FreeIva/FreeIva.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void Awake()
Paused = false;
GameEvents.onGamePause.Add(OnPause);
GameEvents.onGameUnpause.Add(OnUnPause);
GameEvents.onVesselWasModified.Add(OnVesselWasModified);
GameEvents.onVesselPartCountChanged.Add(OnVesselPartCountChanged);
GameEvents.onSameVesselDock.Add(OnSameVesselDockingChange);
GameEvents.onSameVesselUndock.Add(OnSameVesselDockingChange);
GameEvents.onVesselChange.Add(OnVesselChange);
Expand Down Expand Up @@ -210,28 +210,24 @@ public void OnUnPause()
Paused = false;
}

private void OnVesselWasModified(Vessel vessel)
private void OnVesselPartCountChanged(Vessel vessel)
{
if (CameraManager.Instance.currentCameraMode == CameraManager.CameraMode.IVA)
{
m_internalVisibilityDirty = true;
}
m_internalVisibilityDirty = true;
}

private void OnSameVesselDockingChange(GameEvents.FromToAction<ModuleDockingNode, ModuleDockingNode> data)
{
OnVesselWasModified(data.to.vessel);
if (data.from.vessel != data.to.vessel)
if (CameraManager.Instance.currentCameraMode == CameraManager.CameraMode.IVA)
{
OnVesselWasModified(data.from.vessel);
m_internalVisibilityDirty = true;
}
}

public void OnDestroy()
{
GameEvents.onGamePause.Remove(OnPause);
GameEvents.onGameUnpause.Remove(OnUnPause);
GameEvents.onVesselWasModified.Remove(OnVesselWasModified);
GameEvents.onVesselPartCountChanged.Remove(OnVesselPartCountChanged);
GameEvents.onSameVesselDock.Remove(OnSameVesselDockingChange);
GameEvents.onSameVesselUndock.Remove(OnSameVesselDockingChange);
GameEvents.onVesselChange.Remove(OnVesselChange);
Expand Down
19 changes: 3 additions & 16 deletions FreeIva/InternalModules/Hatches/Hatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,9 @@ void SetAnimationState(State newState)
{
case State.Closed:
animState.normalizedTime = 0;
m_animationComponent.Stop();
animState.speed = 0;
animState.enabled = true;
//m_animationComponent.Stop(); // this seems to prevent it from actually moving
m_animationCoroutine = null;
break;

Expand Down Expand Up @@ -1065,21 +1067,6 @@ private IEnumerator GoEVA_Coroutine()
}
}

public static void InitialiseAllHatchesClosed()
{
foreach (Part p in FlightGlobals.ActiveVessel.Parts)
{
InternalModuleFreeIva mfi = InternalModuleFreeIva.GetForModel(p.internalModel);
if (mfi != null)
{
foreach (var hatch in mfi.Hatches)
{
hatch.SetOpened(false);
}
}
}
}

static InternalProp CreateProp(string propName, InternalProp atProp)
{
return CreateProp(propName, atProp, Vector3.zero, Quaternion.identity, Vector3.one);
Expand Down

0 comments on commit 02d76a0

Please sign in to comment.