Skip to content

Commit

Permalink
Fix #101: hide hatch tubes in IVA overlay mode
Browse files Browse the repository at this point in the history
  • Loading branch information
JonnyOThan committed Oct 26, 2024
1 parent 287c0c3 commit b50ca6a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
4 changes: 3 additions & 1 deletion FreeIva/InternalModules/Hatches/Hatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,9 @@ void SetTubeScale()
tubeScale = Vector3.Dot(toTarget, tubeAxis);
}

tubeTransform.gameObject.SetActive(tubeScale > 0);
bool tubeShouldBeActive = tubeScale > 0 && CameraManager.Instance.currentCameraMode == CameraManager.CameraMode.IVA;

tubeTransform.gameObject.SetActive(tubeShouldBeActive);

if (tubeScale > 0)
{
Expand Down
17 changes: 17 additions & 0 deletions FreeIva/InternalModules/InternalModuleFreeIva.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,23 @@ public static void RefreshInternals()
}
}

public static void HideAllTubes()
{
foreach (var ivaModule in perModelCache.Values)
{
if (ivaModule.isActiveAndEnabled)
{
foreach (var hatch in ivaModule.Hatches)
{
if (hatch.tubeTransform != null)
{
hatch.tubeTransform.gameObject.SetActive(false);
}
}
}
}
}

#endregion

[KSPField]
Expand Down
1 change: 1 addition & 0 deletions FreeIva/KerbalIvaAddon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ public void OnCameraChange(CameraManager.CameraMode cameraMode)
else if (cameraMode != CameraManager.CameraMode.IVA && _previousCameraMode == CameraManager.CameraMode.IVA)
{
InternalModuleFreeIva.RefreshDepthMasks();
InternalModuleFreeIva.HideAllTubes();

InputLockManager.RemoveControlLock("FreeIVA");

Expand Down

0 comments on commit b50ca6a

Please sign in to comment.