Skip to content

Commit 9e7f73e

Browse files
committed
Lock out camera mode controls when unbuckled from freeiva
1 parent 213babc commit 9e7f73e

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

ProbeControlRoom/ProbeControlRoom.cs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -569,19 +569,33 @@ public void stopIVA()
569569
toolbarControl.SetTexture(IconDeactivate, disabledTexture);
570570
}
571571

572+
bool KerbalIsUnbuckled(Kerbal kerbal)
573+
{
574+
if (kerbal == null) return false;
575+
576+
if (kerbal.transform.parent == kerbal.protoCrewMember.seat.seatTransform) return false;
577+
578+
return true;
579+
}
580+
581+
// FreeIva changes its buckled states inside Update, so we need to use the state from the end of the previous frame
582+
bool kerbalWasUnbuckled;
583+
572584
/// <summary>
573585
/// Check for invalid PCR states and controls inputs for acivation/deactivation
574586
/// </summary>
575587
public void LateUpdate()
576588
{
577589
if (isActive)
578590
{
591+
bool canChangeCameras = !MapView.MapIsEnabled && !kerbalWasUnbuckled;
592+
579593
if (CameraManager.Instance.currentCameraMode == CameraManager.CameraMode.Flight)
580594
{
581595
stopIVA();
582596
}
583597
//Check for imput to stop IVA
584-
else if (!MapView.MapIsEnabled && GameSettings.CAMERA_MODE.GetKeyDown(false))
598+
else if (canChangeCameras && GameSettings.CAMERA_MODE.GetKeyDown(false))
585599
{
586600
ProbeControlRoomUtils.Logger.message("LateUpdate() - CAMERA_MODE.key seen, stopIVA()");
587601
if (ProbeControlRoomSettings.Instance.ForcePCROnly)
@@ -590,12 +604,12 @@ public void LateUpdate()
590604
}
591605
else
592606
{
593-
// TODO: this triggers when trying to "return to seat" in FreeIva - how to avoid?
607+
594608
stopIVA();
595609
}
596610
}
597611
// Cycle to the next kerbal
598-
else if (!MapView.MapIsEnabled && GameSettings.CAMERA_NEXT.GetKeyDown(false))
612+
else if (canChangeCameras && GameSettings.CAMERA_NEXT.GetKeyDown(false))
599613
{
600614
// the normal IVA kerbal cycling code uses the crew on the vessel, but the kerbals in the PCR are not in the vessel!
601615
int currentIndex = aPart.internalModel.seats.FindIndex(seat => seat.kerbalRef == CameraManager.Instance.IVACameraActiveKerbal);
@@ -619,6 +633,8 @@ public void LateUpdate()
619633
}
620634
}
621635
}
636+
637+
kerbalWasUnbuckled = KerbalIsUnbuckled(CameraManager.Instance.IVACameraActiveKerbal);
622638
}
623639

624640
/// <summary>

0 commit comments

Comments
 (0)