diff --git a/KerbalVR_Mod/KerbalVR/Addon.cs b/KerbalVR_Mod/KerbalVR/Addon.cs index c339f2dc..035b94ad 100644 --- a/KerbalVR_Mod/KerbalVR/Addon.cs +++ b/KerbalVR_Mod/KerbalVR/Addon.cs @@ -30,9 +30,9 @@ public void Awake() XRSettings.enabled = false; SteamVR.enabled = false; SteamVR_Behaviour.instance.enabled = false; - } - ApplyPatches(); + ApplyPatches(); + } GameEvents.onLevelWasLoaded.Add(OnLevelWasLoaded); GameEvents.onGameSceneLoadRequested.Add(OnGameSceneLoadRequested); diff --git a/KerbalVR_Mod/KerbalVR/CameraUtils.cs b/KerbalVR_Mod/KerbalVR/CameraUtils.cs index 8256fa4a..8361fdd8 100644 --- a/KerbalVR_Mod/KerbalVR/CameraUtils.cs +++ b/KerbalVR_Mod/KerbalVR/CameraUtils.cs @@ -89,30 +89,27 @@ static IEnumerable Transpiler(IEnumerable inst public static void PatchAll(Harmony harmony) { - if (Core.IsVrEnabled) - { - Utils.Log("Patching Camera FOV"); + Utils.Log("Patching Camera FOV"); - MethodInfo transpiler = AccessTools.Method(typeof(CameraFOVPatch), nameof(CameraFOVPatch.Transpiler)); - (Type, string)[] targets = - { - (typeof(FXCamera), nameof(FXCamera.LateUpdate)), - (typeof(FXDepthCamera), nameof(FXDepthCamera.LateUpdate)), - (typeof(InternalCamera), nameof(InternalCamera.SetFOV)), - (typeof(InternalCamera), nameof(InternalCamera.UpdateState)), - (typeof(FlightCamera), nameof(FlightCamera.SetFoV)), - (typeof(ScaledCamera), nameof(ScaledCamera.SetFoV)), - (typeof(GalaxyCameraControl), nameof(GalaxyCameraControl.SetFoV)), - (typeof(InternalSpaceOverlay), nameof(InternalSpaceOverlay.LateUpdate)), - (typeof(IVACamera), nameof(IVACamera.UpdateState)), - (typeof(VehiclePhysics.CameraFree), nameof(VehiclePhysics.CameraFree.Update)), - (typeof(VehiclePhysics.CameraLookAt), nameof(VehiclePhysics.CameraLookAt.Update)), - }; - - foreach ((Type type, string method) in targets) - { - harmony.Patch(AccessTools.Method(type, method), transpiler: new HarmonyMethod(transpiler)); - } + MethodInfo transpiler = AccessTools.Method(typeof(CameraFOVPatch), nameof(CameraFOVPatch.Transpiler)); + (Type, string)[] targets = + { + (typeof(FXCamera), nameof(FXCamera.LateUpdate)), + (typeof(FXDepthCamera), nameof(FXDepthCamera.LateUpdate)), + (typeof(InternalCamera), nameof(InternalCamera.SetFOV)), + (typeof(InternalCamera), nameof(InternalCamera.UpdateState)), + (typeof(FlightCamera), nameof(FlightCamera.SetFoV)), + (typeof(ScaledCamera), nameof(ScaledCamera.SetFoV)), + (typeof(GalaxyCameraControl), nameof(GalaxyCameraControl.SetFoV)), + (typeof(InternalSpaceOverlay), nameof(InternalSpaceOverlay.LateUpdate)), + (typeof(IVACamera), nameof(IVACamera.UpdateState)), + (typeof(VehiclePhysics.CameraFree), nameof(VehiclePhysics.CameraFree.Update)), + (typeof(VehiclePhysics.CameraLookAt), nameof(VehiclePhysics.CameraLookAt.Update)), + }; + + foreach ((Type type, string method) in targets) + { + harmony.Patch(AccessTools.Method(type, method), transpiler: new HarmonyMethod(transpiler)); } } }