[RCCVirtualSteeringWheel] Fixed error spam when sitting in a CVRSeat with lockControls, but no RCC component in parent

This commit is contained in:
NotAKidoS 2025-04-03 04:11:40 -05:00
parent 138c9a9856
commit 018112d6b9

View file

@ -1,4 +1,5 @@
using ABI_RC.Systems.InputManagement;
using ABI_RC.Core.InteractionSystem;
using ABI_RC.Systems.InputManagement;
using ABI_RC.Systems.Movement;
using HarmonyLib;
using NAK.RCCVirtualSteeringWheel.Util;
@ -39,12 +40,20 @@ internal static class CVRInputManager_Patches
[HarmonyPatch(typeof(CVRInputManager), nameof(CVRInputManager.UpdateInput))]
private static void Postfix_CVRInputManager_UpdateInput(ref CVRInputManager __instance)
{
// Steering input is clamped in RCC component
if (BetterBetterCharacterController.Instance.IsSittingOnControlSeat()
&& SteeringWheelRoot.TryGetWheelInput(
BetterBetterCharacterController.Instance._lastCvrSeat._carController, out float steeringValue))
{
BetterBetterCharacterController characterController = BetterBetterCharacterController.Instance;
if (!characterController._isSitting)
return; // Must be sitting
CVRSeat cvrSeat = characterController._lastCvrSeat;
if (!cvrSeat
|| !cvrSeat.lockControls)
return; // Must be a driver seat
RCC_CarControllerV3 carController = characterController._lastCvrSeat._carController;
if (!carController)
return; // Specific to RCC
if (SteeringWheelRoot.TryGetWheelInput(carController, out float steeringValue))
__instance.steering = steeringValue;
}
}
}