[DesktopVRSwitch] Add TryCatch to patches to appease Kafe.

This commit is contained in:
NotAKidoS 2023-06-20 18:35:05 -05:00
parent 900c6646af
commit 730a085850

View file

@ -17,9 +17,17 @@ class CheckVRPatches
[HarmonyPostfix] [HarmonyPostfix]
[HarmonyPatch(typeof(CheckVR), nameof(CheckVR.Start))] [HarmonyPatch(typeof(CheckVR), nameof(CheckVR.Start))]
static void Postfix_CheckVR_Start(ref CheckVR __instance) static void Postfix_CheckVR_Start(ref CheckVR __instance)
{
try
{ {
__instance.gameObject.AddComponent<VRModeSwitchManager>(); __instance.gameObject.AddComponent<VRModeSwitchManager>();
} }
catch (Exception e)
{
DesktopVRSwitch.Logger.Error($"Error during the patched method {nameof(Postfix_CheckVR_Start)}");
DesktopVRSwitch.Logger.Error(e);
}
}
} }
class IKSystemPatches class IKSystemPatches
@ -27,13 +35,23 @@ class IKSystemPatches
[HarmonyPostfix] //lazy fix so i dont need to wait few frames [HarmonyPostfix] //lazy fix so i dont need to wait few frames
[HarmonyPatch(typeof(TrackingPoint), nameof(TrackingPoint.Initialize))] [HarmonyPatch(typeof(TrackingPoint), nameof(TrackingPoint.Initialize))]
static void Postfix_TrackingPoint_Initialize(ref TrackingPoint __instance) static void Postfix_TrackingPoint_Initialize(ref TrackingPoint __instance)
{
try
{ {
__instance.referenceTransform.localScale = Vector3.one; __instance.referenceTransform.localScale = Vector3.one;
} }
catch (Exception e)
{
DesktopVRSwitch.Logger.Error($"Error during the patched method {nameof(Postfix_TrackingPoint_Initialize)}");
DesktopVRSwitch.Logger.Error(e);
}
}
[HarmonyPostfix] //lazy fix so device indecies can change properly [HarmonyPostfix] //lazy fix so device indecies can change properly
[HarmonyPatch(typeof(SteamVRTrackingModule), nameof(SteamVRTrackingModule.ModuleDestroy))] [HarmonyPatch(typeof(SteamVRTrackingModule), nameof(SteamVRTrackingModule.ModuleDestroy))]
static void Postfix_SteamVRTrackingModule_ModuleDestroy(ref SteamVRTrackingModule __instance) static void Postfix_SteamVRTrackingModule_ModuleDestroy(ref SteamVRTrackingModule __instance)
{
try
{ {
for (int i = 0; i < __instance.TrackingPoints.Count; i++) for (int i = 0; i < __instance.TrackingPoints.Count; i++)
{ {
@ -41,6 +59,12 @@ class IKSystemPatches
} }
__instance.TrackingPoints.Clear(); __instance.TrackingPoints.Clear();
} }
catch (Exception e)
{
DesktopVRSwitch.Logger.Error($"Error during the patched method {nameof(Postfix_SteamVRTrackingModule_ModuleDestroy)}");
DesktopVRSwitch.Logger.Error(e);
}
}
} }
class CVRWorldPatches class CVRWorldPatches
@ -49,9 +73,17 @@ class CVRWorldPatches
[HarmonyPatch(typeof(CVRWorld), nameof(CVRWorld.SetDefaultCamValues))] [HarmonyPatch(typeof(CVRWorld), nameof(CVRWorld.SetDefaultCamValues))]
[HarmonyPatch(typeof(CVRWorld), nameof(CVRWorld.CopyRefCamValues))] [HarmonyPatch(typeof(CVRWorld), nameof(CVRWorld.CopyRefCamValues))]
static void Postfix_CVRWorld_HandleCamValues() static void Postfix_CVRWorld_HandleCamValues()
{
try
{ {
ReferenceCameraPatch.OnWorldLoad(); ReferenceCameraPatch.OnWorldLoad();
} }
catch (Exception e)
{
DesktopVRSwitch.Logger.Error($"Error during the patched method {nameof(Postfix_CVRWorld_HandleCamValues)}");
DesktopVRSwitch.Logger.Error(e);
}
}
} }
class CameraFacingObjectPatches class CameraFacingObjectPatches
@ -59,9 +91,17 @@ class CameraFacingObjectPatches
[HarmonyPostfix] [HarmonyPostfix]
[HarmonyPatch(typeof(CameraFacingObject), nameof(CameraFacingObject.Start))] [HarmonyPatch(typeof(CameraFacingObject), nameof(CameraFacingObject.Start))]
static void Postfix_CameraFacingObject_Start(ref CameraFacingObject __instance) static void Postfix_CameraFacingObject_Start(ref CameraFacingObject __instance)
{
try
{ {
__instance.gameObject.AddComponent<CameraFacingObjectTracker>(); __instance.gameObject.AddComponent<CameraFacingObjectTracker>();
} }
catch (Exception e)
{
DesktopVRSwitch.Logger.Error($"Error during the patched method {nameof(Postfix_CameraFacingObject_Start)}");
DesktopVRSwitch.Logger.Error(e);
}
}
} }
class CVRPickupObjectPatches class CVRPickupObjectPatches
@ -69,6 +109,8 @@ class CVRPickupObjectPatches
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(CVRPickupObject), nameof(CVRPickupObject.Start))] [HarmonyPatch(typeof(CVRPickupObject), nameof(CVRPickupObject.Start))]
static void Prefix_CVRPickupObject_Start(ref CVRPickupObject __instance) static void Prefix_CVRPickupObject_Start(ref CVRPickupObject __instance)
{
try
{ {
if (__instance.gripType == CVRPickupObject.GripType.Free) if (__instance.gripType == CVRPickupObject.GripType.Free)
return; return;
@ -82,6 +124,12 @@ class CVRPickupObjectPatches
tracker._storedGripOrigin = (!MetaPort.Instance.isUsingVr ? vrOrigin : desktopOrigin); tracker._storedGripOrigin = (!MetaPort.Instance.isUsingVr ? vrOrigin : desktopOrigin);
} }
} }
catch (Exception e)
{
DesktopVRSwitch.Logger.Error($"Error during the patched method {nameof(Prefix_CVRPickupObject_Start)}");
DesktopVRSwitch.Logger.Error(e);
}
}
} }
class CohtmlUISystemPatches class CohtmlUISystemPatches