using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Logging; using DarkMachine.UI; using HarmonyLib; using HarmonyLib.Tools; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.InputSystem.LowLevel; using UnityEngine.InputSystem.Users; using UnityEngine.InputSystem.Utilities; using UnityEngine.InputSystem.XR; using UnityEngine.Rendering; using UnityEngine.Rendering.PostProcessing; using UnityEngine.SceneManagement; using UnityEngine.UI; using UnityEngine.XR; using UnityEngine.XR.OpenXR; using UnityEngine.XR.OpenXR.Features; using UnityEngine.XR.OpenXR.Features.Interactions; using WhiteKnuckleVRMod; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETFramework,Version=v4.7", FrameworkDisplayName = ".NET Framework 4.7")] [assembly: AssemblyCompany("WhiteKnuckleVRMod")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+aa74a6885563e9de6cca3c77dadeb9c55cb92ca0")] [assembly: AssemblyProduct("WhiteKnuckleVRMod")] [assembly: AssemblyTitle("WhiteKnuckleVRMod")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } public static class CanvasManager { private const float WORLD_SPACE_SCALE = 0.0013f; public const float DEFAULT_UI_DISTANCE = 1.8f; private const float UI_X_OFFSET = 0f; private const float UI_Y_OFFSET = 0f; private static void DisableCanvasScaler(Canvas canvas, ManualLogSource logger) { CanvasScaler component = ((Component)canvas).GetComponent(); if ((Object)(object)component != (Object)null && ((Behaviour)component).enabled) { ((Behaviour)component).enabled = false; if (VRLog.VerboseEnabled) { logger.LogInfo((object)("Disabled CanvasScaler on '" + ((Object)canvas).name + "' so it stops overwriting localScale.")); } } } public static void CanvasToWorldSpace(Canvas canvas, Transform playerRoot, Camera vrCamera, ManualLogSource logger, float scale = 0.0013f, float distance = 1.8f) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Invalid comparison between Unknown and I4 //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)canvas == (Object)null) { logger.LogError((object)"Attempted to convert a null Canvas."); return; } if ((int)canvas.renderMode == 2) { logger.LogWarning((object)("Canvas '" + ((Object)canvas).name + "' is already in WorldSpace. Skipping conversion.")); return; } if (VRLog.VerboseEnabled) { logger.LogInfo((object)("Converting Canvas: " + ((Object)canvas).name + " to WorldSpace.")); } DisableCanvasScaler(canvas, logger); ((Component)canvas).transform.SetParent(playerRoot, false); canvas.renderMode = (RenderMode)2; canvas.worldCamera = vrCamera; VRCanvasOverlaySentinel.Attach(((Component)canvas).gameObject); ((Component)canvas).transform.localRotation = Quaternion.identity; ((Component)canvas).transform.localPosition = new Vector3(0f, 0f, distance); ((Component)canvas).transform.localScale = new Vector3(scale, scale, scale); canvas.planeDistance = distance; if (VRLog.VerboseEnabled) { logger.LogInfo((object)$"Canvas '{((Object)canvas).name}' converted. Positioned {distance}m in front of player."); } } private static void ConvertNestedCanvasInPlace(Canvas canvas, Camera vrCamera, ManualLogSource logger) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 if ((int)canvas.renderMode != 2) { DisableCanvasScaler(canvas, logger); canvas.renderMode = (RenderMode)2; canvas.worldCamera = vrCamera; VRCanvasOverlaySentinel.Attach(((Component)canvas).gameObject); if (VRLog.VerboseEnabled) { logger.LogInfo((object)("Converted nested Canvas '" + ((Object)canvas).name + "' to WorldSpace in place (no reparent).")); } } } public static void ConvertCanvasHierarchyToWorldSpace(Canvas rootCanvas, Transform playerRoot, Camera vrCamera, ManualLogSource logger, float scale = 0.0013f, float distance = 1.8f) { if ((Object)(object)rootCanvas == (Object)null) { logger.LogError((object)"Attempted to convert a null root Canvas hierarchy."); return; } CanvasToWorldSpace(rootCanvas, playerRoot, vrCamera, logger, scale, distance); Canvas[] componentsInChildren = ((Component)rootCanvas).GetComponentsInChildren(true); Canvas[] array = componentsInChildren; foreach (Canvas val in array) { if (!((Object)(object)val == (Object)(object)rootCanvas)) { ConvertNestedCanvasInPlace(val, vrCamera, logger); } } } } namespace WhiteKnuckleVRMod { internal static class BepInExConfigGuard { private const string SettingKey = "HideManagerGameObject"; public static void EnsureManagerObjectHidden(ManualLogSource logger) { string text = Path.Combine(Paths.ConfigPath, "BepInEx.cfg"); try { if (!File.Exists(text)) { logger.LogWarning((object)(text + " not found, cannot verify HideManagerGameObject.")); return; } string[] array = File.ReadAllLines(text); int num = FindSettingLine(array); if (num < 0) { logger.LogWarning((object)"HideManagerGameObject not present in BepInEx.cfg. If the VR mod never starts, add 'HideManagerGameObject = true' under [Chainloader] and relaunch."); } else if (!ReadsTrue(array[num])) { array[num] = "HideManagerGameObject = true"; File.WriteAllLines(text, array); logger.LogWarning((object)"================================================================"); logger.LogWarning((object)"White Knuckle destroys the BepInEx manager object unless HideManagerGameObject"); logger.LogWarning((object)"is enabled, which stops every plugin including this one from starting."); logger.LogWarning((object)"HideManagerGameObject has been set to true in BepInEx/config/BepInEx.cfg."); logger.LogWarning((object)"RESTART THE GAME to finish loading the VR mod."); logger.LogWarning((object)"================================================================"); } } catch (Exception arg) { logger.LogError((object)string.Format("Failed to verify {0} in {1}: {2}", "HideManagerGameObject", text, arg)); } } private static int FindSettingLine(string[] lines) { for (int i = 0; i < lines.Length; i++) { string text = lines[i].TrimStart(); if (!text.StartsWith("#") && text.StartsWith("HideManagerGameObject", StringComparison.OrdinalIgnoreCase)) { int num = text.IndexOf('='); if (num >= 0 && text.Substring(0, num).Trim().Equals("HideManagerGameObject", StringComparison.OrdinalIgnoreCase)) { return i; } } } return -1; } private static bool ReadsTrue(string line) { int num = line.IndexOf('='); if (num >= 0) { return line.Substring(num + 1).Trim().Equals("true", StringComparison.OrdinalIgnoreCase); } return false; } } internal static class VRPluginInfo { public const string PLUGIN_GUID = "com.whiteknucklevr.vrmod"; public const string PLUGIN_NAME = "White Knuckle VR Mod"; public const string PLUGIN_VERSION = "1.1.3"; } internal static class VRPluginConstants { public const float MENU_PLAYER_HEIGHT = 0.45f; public const float MOUSE_SENSITIVITY = 0.05f; public const float SNAP_TURN_DEADZONE = 0.5f; } public class MathUtils { public static Quaternion ExtractComponentVector(Quaternion rotation, Vector3 components) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) float num = default(float); Vector3 val = default(Vector3); ((Quaternion)(ref rotation)).ToAngleAxis(ref num, ref val); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(val.x * components.x, val.y * components.y, val.z * components.z); if (Mathf.Abs(val2.x) < 1E-06f && Mathf.Abs(val2.y) < 1E-06f && Mathf.Abs(val2.z) < 1E-06f) { return Quaternion.identity; } ((Vector3)(ref val2)).Normalize(); return Quaternion.AngleAxis(num, val2); } public static float RotationAroundAxis(Quaternion rotation, Vector3 axis) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) float num = default(float); Vector3 val = default(Vector3); ((Quaternion)(ref rotation)).ToAngleAxis(ref num, ref val); if (num > 180f) { num -= 360f; } float num2 = Vector3.Dot(val, axis); if (Mathf.Abs(num2) < 1E-06f) { return 0f; } return num * num2; } } public static class Scenes { public static readonly string Intro = "Intro"; public static readonly string MainMenu = "Main-Menu"; public static readonly string GameMain = "Game-Main"; public static readonly string Playground = "Playground"; } [BepInPlugin("com.whiteknucklevr.vrmod", "White Knuckle VR Mod", "1.1.3")] public class VRRenderingPipeline : BaseUnityPlugin { private class ENT_Player_Patch { private static Vector3 positionBeforeMovementThisTick = Vector3.zero; private static VRCameraSpoof propGrabSpoof; private static VRCameraSpoof hangSpoof; [HarmonyPrefix] [HarmonyPatch(typeof(ENT_Player), "MouseLook")] private static bool MouseLook_Patch(ENT_Player __instance) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) if (!__instance.IsMoveLocked() || !__instance.IsInputLocked()) { __instance.InterpolateCamera(); } if (__instance.IsLocked()) { return false; } if (vrInitialized) { Quaternion canonicalHeadRotation = CanonicalHeadRotation; float num = MathUtils.RotationAroundAxis(canonicalHeadRotation, Vector3.up); AlignLocomotionYawToSpawnOnce(__instance, num); float num2 = num + locomotionYaw; ((Component)__instance).transform.rotation = Quaternion.AngleAxis(num2, Vector3.up); __instance.camTransform.localRotation = VRLookOffset.PitchRotationFor(canonicalHeadRotation) * MathUtils.ExtractComponentVector(canonicalHeadRotation, new Vector3(1f, 0f, 1f)); __instance.camY = num2; __instance.cameraPosition = __instance.camTransform.position; __instance.cameraRotation = __instance.camTransform.rotation; } return false; } [HarmonyPrefix] [HarmonyPatch(typeof(ENT_Player), "FixedUpdate")] private static void FixedUpdate_RefreshInput_Prefix() { if (vrInitialized && MotionControlsActive) { VRHandInput.Advance(); } } [HarmonyPostfix] [HarmonyPatch(typeof(ENT_Player), "FixedUpdate")] private static void FixedUpdate_Patch(ENT_Player __instance) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (vrInitialized) { RecordFixedPlayerPosition(((Component)__instance).transform.position); } } [HarmonyPostfix] [HarmonyPatch(typeof(ENT_Player), "LateUpdate")] private static void LateUpdate_OwnCrouch_Postfix(ENT_Player __instance) { if (vrInitialized && MotionControlsActive && Settings.physicalCrouchEnabled && !((Object)(object)CL_GameManager.gMan == (Object)null) && !CL_GameManager.gMan.isPaused) { __instance.crouchPressed = VRPhysicalCrouch.Crouched; } } [HarmonyPrefix] [HarmonyPatch(typeof(ENT_Player), "Movement")] private static void Movement_Prefix(ENT_Player __instance) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) ApplyHeadsetPositionalMovement(__instance); positionBeforeMovementThisTick = ((Component)__instance).transform.position; if (MotionControlsActive) { VRClimbControl.Apply(__instance); } } [HarmonyPostfix] [HarmonyPatch(typeof(ENT_Player), "Movement")] private static void Movement_Postfix(ENT_Player __instance) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Component)__instance).transform.position - positionBeforeMovementThisTick; val.y = 0f; RecordStickSpeed(((Vector3)(ref val)).magnitude / Time.fixedDeltaTime); } [HarmonyPrefix] [HarmonyPatch(typeof(ENT_Player), "GrabPropUpdate")] private static void GrabPropUpdate_Prefix(ENT_Player __instance, int hand) { if (MotionControlsActive) { propGrabSpoof = VRPropGrab.AimHeldProp(__instance, hand); } } [HarmonyFinalizer] [HarmonyPatch(typeof(ENT_Player), "GrabPropUpdate")] private static void GrabPropUpdate_Finalizer() { propGrabSpoof.Dispose(); propGrabSpoof = default(VRCameraSpoof); } [HarmonyPrefix] [HarmonyPatch(typeof(ENT_Player), "Hang")] private static void Hang_Prefix(ENT_Player __instance) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) if (MotionControlsActive && !((Object)(object)__instance.cam == (Object)null) && __instance.IsHanging() && !VRClimbControl.JoystickClimbActive) { Vector3 forward = ((Component)__instance).transform.forward; Vector3 lastClimbIntentDirection = VRClimbControl.LastClimbIntentDirection; Vector3 intentDirection = ((((Vector3)(ref lastClimbIntentDirection)).sqrMagnitude > 0.0001f) ? ((Vector3)(ref lastClimbIntentDirection)).normalized : forward); intentDirection = VRClimbControl.ProjectIntentOffSurface(__instance, intentDirection, forward); Vector3 upHint = ((Mathf.Abs(intentDirection.y) > 0.99f) ? forward : Vector3.up); hangSpoof = VRCameraSpoof.FaceDirection(intentDirection, upHint); } } [HarmonyFinalizer] [HarmonyPatch(typeof(ENT_Player), "Hang")] private static void Hang_Finalizer() { hangSpoof.Dispose(); } [HarmonyPrefix] [HarmonyPatch(typeof(ENT_Player), "InteractCheck")] private static void InteractCheck_Prefix(int hand) { if (MotionControlsActive) { VRBackpack.BeginBagAim(hand); } } [HarmonyFinalizer] [HarmonyPatch(typeof(ENT_Player), "InteractCheck")] private static void InteractCheck_Finalizer() { VRBackpack.EndBagAim(); } [HarmonyPrefix] [HarmonyPatch(typeof(ENT_Player), "HandAnimation")] private static void HandAnimation_Prefix(Hand curhand, out string? __state) { __state = null; if (!MotionControlsActive || curhand == null || !ENT_Player_Hand_Patch.GripIsSecondInput()) { return; } int id = curhand.id; if (id >= 0 && id < VRHandInput.Hands.Length) { VRHand vRHand = VRHandInput.ForHandId(id); bool flag = vRHand.Grip.Pressed || vRHand.Grip.Down; bool flag2 = vRHand.Trigger.Pressed || vRHand.Trigger.Down; if (!(!flag2 || flag) && !string.IsNullOrEmpty(curhand.fireButton)) { __state = curhand.fireButton; curhand.fireButton = VRHandButtons.GrabName(id); } } } [HarmonyFinalizer] [HarmonyPatch(typeof(ENT_Player), "HandAnimation")] private static void HandAnimation_Finalizer(Hand curhand, string? __state) { if (__state != null && curhand != null) { curhand.fireButton = __state; } } } private class CL_Prop_Patch { [HarmonyPostfix] [HarmonyPatch(typeof(CL_Prop), "Interact")] private static void Interact_Postfix(InteractionInfo info) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) if (MotionControlsActive && info != null && info.hand != null) { VRPropGrab.RecordGrabDistance(info.hand.id, info.interactionPoint); } } [HarmonyPostfix] [HarmonyPatch(typeof(CL_Prop), "StopInteract")] private static void StopInteract_Postfix(Hand hand) { if (hand != null) { VRPropGrab.ClearGrabDistance(hand.id); } } } private class CL_HoldLever_Patch { private static VRCameraSpoof updateSpoof; private static VRCameraSpoof lateUpdateSpoof; private static VRCameraSpoof interactSpoof; [HarmonyPrefix] [HarmonyPatch(typeof(CL_HoldLever), "Update")] private static void Update_Prefix(CL_HoldLever __instance) { updateSpoof = VRPropGrab.AimLever(__instance); } [HarmonyFinalizer] [HarmonyPatch(typeof(CL_HoldLever), "Update")] private static void Update_Finalizer() { updateSpoof.Dispose(); updateSpoof = default(VRCameraSpoof); } [HarmonyPrefix] [HarmonyPatch(typeof(CL_HoldLever), "LateUpdate")] private static void LateUpdate_Prefix(CL_HoldLever __instance) { lateUpdateSpoof = VRPropGrab.AimLever(__instance); } [HarmonyFinalizer] [HarmonyPatch(typeof(CL_HoldLever), "LateUpdate")] private static void LateUpdate_Finalizer() { lateUpdateSpoof.Dispose(); lateUpdateSpoof = default(VRCameraSpoof); } [HarmonyPrefix] [HarmonyPatch(typeof(CL_HoldLever), "Interact", new Type[] { typeof(InteractionInfo) })] private static void Interact_Prefix(InteractionInfo info) { if (MotionControlsActive && info != null && info.hand != null) { interactSpoof = VRAimRay.AimFromHandId(info.hand.id); } } [HarmonyFinalizer] [HarmonyPatch(typeof(CL_HoldLever), "Interact", new Type[] { typeof(InteractionInfo) })] private static void Interact_Finalizer() { interactSpoof.Dispose(); interactSpoof = default(VRCameraSpoof); } } private class M_Level_Patch { [HarmonyPostfix] [HarmonyPatch(typeof(M_Level), "OnSpawn")] private static void OnSpawn_Postfix(M_Level __instance) { VRSoftDepth.CompensateHierarchy(((Component)__instance).transform); } } private class CL_Handhold_Patch { [HarmonyPostfix] [HarmonyPatch(typeof(CL_Handhold), "LateUpdate")] private static void LateUpdate_Postfix(CL_Handhold __instance) { if (vrInitialized && VRShimmer.HandholdShimmerEnabled && !((Object)(object)__instance.handholdRenderer == (Object)null)) { VRShimmer.ApplyWorldSpaceWave(__instance.handholdRenderer); } } [HarmonyPostfix] [HarmonyPatch(typeof(CL_Handhold), "Interact")] private static void Interact_Postfix(CL_Handhold __instance, InteractionInfo info) { if (vrInitialized && Settings.verboseLogging) { int num = ((info.hand != null) ? info.hand.id : (-1)); } } [HarmonyPostfix] [HarmonyPatch(typeof(CL_Handhold), "StopInteract")] private static void StopInteract_Postfix(CL_Handhold __instance, Hand dropHand) { if (vrInitialized) { _ = Settings.verboseLogging; } } } private class UT_CameraTakeover_Patch { [HarmonyPostfix] [HarmonyPatch(typeof(UT_CameraTakeover), "TakeoverCamera")] private static void TakeoverCamera_Postfix(UT_CameraTakeover __instance) { VRTerminalView.BeginTakeover(__instance); } [HarmonyPostfix] [HarmonyPatch(typeof(UT_CameraTakeover), "EndTakeover")] private static void EndTakeover_Postfix(UT_CameraTakeover __instance) { VRTerminalView.EndTakeover(__instance); } } private class InputManager_Patch { [HarmonyPostfix] [HarmonyPatch(typeof(InputManager), "UpdateInputs")] private static void UpdateInputs_Postfix() { if (MotionControlsActive) { VRPhysicalCrouch.WriteCrouchInput(); VRHandSwapGesture.WriteSwapInput(); } } } private class Inventory_Patch { private static VRCameraSpoof lookAwaySpoof; [HarmonyPrefix] [HarmonyPatch(typeof(Inventory), "TryPocketItemInHand")] private static void TryPocketItemInHand_Prefix(Inventory __instance, int handID) { if (vrInitialized && Settings.verboseLogging && __instance.pockets != null && handID < __instance.pockets.Count) { Pocket val = __instance.pockets[handID]; if (val != null && val.pouch != null) { Item val2 = ((val.targetHandID < __instance.itemHands.Length) ? __instance.itemHands[val.targetHandID].currentItem : null); } } } [HarmonyPostfix] [HarmonyPatch(typeof(Inventory), "CalculateEncumberance")] private static void CalculateEncumberance_Postfix(Inventory __instance) { _ = vrInitialized; } [HarmonyPrefix] [HarmonyPatch(typeof(Inventory), "Update")] private static void Update_Prefix(Inventory __instance) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) if (vrInitialized) { if (MotionControlsActive) { VRBackpack.BeginInventoryButtonOverride(); } if (MotionControlsActive) { VRPocketDrop.BeginPocketButtonOverride(); } if (__instance.showingInventory && !((Object)(object)__instance.inventory == (Object)null)) { lookAwaySpoof = VRCameraSpoof.FaceDirection(__instance.inventory.forward, Vector3.up); } } } [HarmonyFinalizer] [HarmonyPatch(typeof(Inventory), "Update")] private static void Update_Finalizer() { lookAwaySpoof.Dispose(); if (MotionControlsActive) { VRBackpack.EndInventoryButtonOverride(); } if (MotionControlsActive) { VRPocketDrop.EndPocketButtonOverride(); } } [HarmonyPostfix] [HarmonyPatch(typeof(Inventory), "Update")] private static void Update_Postfix() { if (vrInitialized) { VRBackpack.PlaceBag(); } } } private class HandItem_Aim_Patch { private static readonly VRCameraSpoof[] spoofStack = new VRCameraSpoof[8]; private static int spoofDepth; private static void Push(HandItem handItem) { if (!MotionControlsActive) { spoofDepth++; return; } if (spoofDepth < 0 || spoofDepth >= spoofStack.Length) { spoofDepth++; return; } spoofStack[spoofDepth] = VRAimRay.AimFromHand(handItem); spoofDepth++; } private static void Pop() { spoofDepth--; if (spoofDepth < 0 || spoofDepth >= spoofStack.Length) { if (spoofDepth < 0) { spoofDepth = 0; } } else { spoofStack[spoofDepth].Dispose(); spoofStack[spoofDepth] = default(VRCameraSpoof); } } [HarmonyPrefix] [HarmonyPatch(typeof(HandItem_Shoot), "Shoot")] private static void Shoot_Prefix(HandItem_Shoot __instance) { Push((HandItem)(object)__instance); } [HarmonyFinalizer] [HarmonyPatch(typeof(HandItem_Shoot), "Shoot")] private static void Shoot_Finalizer() { Pop(); } [HarmonyPrefix] [HarmonyPatch(typeof(HandItem_Melee), "HitCast")] private static void HitCast_Prefix(HandItem_Melee __instance) { Push((HandItem)(object)__instance); } [HarmonyFinalizer] [HarmonyPatch(typeof(HandItem_Melee), "HitCast")] private static void HitCast_Finalizer() { Pop(); } [HarmonyPrefix] [HarmonyPatch(typeof(HandItem_Melee), "Hit")] private static void Hit_Prefix(HandItem_Melee __instance) { Push((HandItem)(object)__instance); } [HarmonyFinalizer] [HarmonyPatch(typeof(HandItem_Melee), "Hit")] private static void Hit_Finalizer() { Pop(); } [HarmonyPrefix] [HarmonyPatch(typeof(HandItem_Piton), "PitonHit")] private static void PitonHit_Prefix(HandItem_Piton __instance) { Push((HandItem)(object)__instance); } [HarmonyFinalizer] [HarmonyPatch(typeof(HandItem_Piton), "PitonHit")] private static void PitonHit_Finalizer() { Pop(); } [HarmonyPrefix] [HarmonyPatch(typeof(HandItem_Piton), "PitonRaycast")] private static void PitonRaycast_Prefix(HandItem_Piton __instance) { Push((HandItem)(object)__instance); } [HarmonyFinalizer] [HarmonyPatch(typeof(HandItem_Piton), "PitonRaycast")] private static void PitonRaycast_Finalizer() { Pop(); } [HarmonyPrefix] [HarmonyPatch(typeof(HandItem_BlinkEye), "LateUpdate")] private static void BlinkEyeLateUpdate_Prefix(HandItem_BlinkEye __instance) { Push((HandItem)(object)__instance); } [HarmonyFinalizer] [HarmonyPatch(typeof(HandItem_BlinkEye), "LateUpdate")] private static void BlinkEyeLateUpdate_Finalizer() { Pop(); } [HarmonyPostfix] [HarmonyPatch(typeof(HandItem_BlinkEye), "LateUpdate")] private static void BlinkEyeLateUpdate_Postfix(HandItem_BlinkEye __instance) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) if (((HandItem)__instance).used && MotionControlsActive && !((Object)(object)__instance.blinkHoldEffect == (Object)null)) { ((Component)__instance.blinkHoldEffect).transform.localPosition = Vector3.zero; ((Component)__instance.blinkHoldEffect).transform.localRotation = Quaternion.identity; } } [HarmonyPrefix] [HarmonyPatch(typeof(HandItem_Melee_Rapier), "OnChargeAttack")] private static void RapierOnChargeAttack_Prefix(HandItem_Melee_Rapier __instance) { Push((HandItem)(object)__instance); } [HarmonyFinalizer] [HarmonyPatch(typeof(HandItem_Melee_Rapier), "OnChargeAttack")] private static void RapierOnChargeAttack_Finalizer() { Pop(); } [HarmonyPrefix] [HarmonyPatch(typeof(HandItem_Melee_Rapier), "PogoCheck")] private static void RapierPogoCheck_Prefix(HandItem_Melee_Rapier __instance) { Push((HandItem)(object)__instance); } [HarmonyFinalizer] [HarmonyPatch(typeof(HandItem_Melee_Rapier), "PogoCheck")] private static void RapierPogoCheck_Finalizer() { Pop(); } [HarmonyPrefix] [HarmonyPatch(typeof(HandItem_GrapplingHook), "Grapple")] private static void GrapplingHookGrapple_Prefix(HandItem_GrapplingHook __instance) { Push((HandItem)(object)__instance); } [HarmonyFinalizer] [HarmonyPatch(typeof(HandItem_GrapplingHook), "Grapple")] private static void GrapplingHookGrapple_Finalizer() { Pop(); } } private class ViewSway_Patch { [HarmonyPostfix] [HarmonyPatch(typeof(ViewSway), "Update")] private static void Update_Postfix(ViewSway __instance, Hand ___hand) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) if (MotionControlsActive && ___hand != null && !HandItem_LateUpdate_Patch.IsNested(((Component)__instance).transform) && VRAimRay.TryGetHandRay(___hand.id, out var _, out var direction)) { ((Component)__instance).transform.rotation = Quaternion.LookRotation(direction, VRHandInput.Hands[___hand.id].Up); } } } private class Inventory_ShowInventory_Patch { [HarmonyPostfix] [HarmonyPatch(typeof(Inventory), "ShowInventory")] private static void ShowInventory_Postfix(Inventory __instance) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) Bag_Handler bagHandler = __instance.bagHandler; if ((Object)(object)bagHandler == (Object)null || bagHandler.extraPouches == null) { return; } foreach (Bag_Pouch extraPouch in bagHandler.extraPouches) { if (!((Object)(object)extraPouch == (Object)null)) { ((Component)extraPouch).transform.localRotation = Quaternion.identity; } } } } private class SubmitSlider_Patch { [HarmonyPostfix] [HarmonyPatch(typeof(SubmitSlider), "OnSubmit")] private static void OnSubmit_Postfix(SubmitSlider __instance) { VRMenuSelection.ToggleSliderEngagement(__instance); } [HarmonyPostfix] [HarmonyPatch(typeof(SubmitSlider), "OnDeselect")] private static void OnDeselect_Postfix(SubmitSlider __instance) { VRMenuSelection.ReleaseSliderEngagement(__instance); } } private class CosmeticInfoPanel_Patch { [HarmonyPostfix] [HarmonyPatch(typeof(UI_CosmeticInfoPanel), "Open")] private static void Open_Postfix(UI_CosmeticInfoPanel __instance) { ForceMenuCanvasGroupVisible(__instance.parentGroup); VRMenuSelection.SelectFirstInteractable(((Component)__instance).gameObject); } [HarmonyPostfix] [HarmonyPatch(typeof(UI_CosmeticInfoPanel), "Close")] private static void Close_Postfix(UI_CosmeticInfoPanel __instance) { ReleaseMenuCanvasGroupVisible(__instance.parentGroup); VRMenuSelection.ClearSliderEngagement(); } } private class Item_Object_Flashlight_Patch { [HarmonyPostfix] [HarmonyPatch(typeof(Item_Object_Flashlight), "Execute")] private static void Execute_Postfix(Item_Object_Flashlight __instance, Inventory inv) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) if (vrInitialized) { Camera vrCamera = VrCamera; if (!((Object)(object)vrCamera == (Object)null) && !((Object)(object)__instance.lamp == (Object)null) && ((Item_Object)__instance).itemData.InInventory() && !((Object)(object)((Item_Object)__instance).itemData.GetHandItem() != (Object)null)) { ((Component)__instance.lamp).transform.position = ((Component)vrCamera).transform.position; ((Component)__instance.lamp).transform.rotation = Quaternion.Lerp(((Component)__instance.lamp).transform.rotation, ((Component)vrCamera).transform.rotation, Time.deltaTime * 8f); } } } } private class Message_Manager_Patch { [HarmonyPostfix] [HarmonyPatch(typeof(Message_Manager), "CreateMessage")] private static void CreateMessage_Postfix(Message __result) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)__result == (Object)null)) { ((Component)__result).transform.localRotation = Quaternion.identity; } } } private class Hand_Takeover_Patch { [HarmonyPrefix] [HarmonyPatch(typeof(Hand_Takeover), "LateUpdate")] private static bool LateUpdate_Prefix(Hand_Takeover __instance, ref float ___curBlend) { if (!MotionControlsActive) { return true; } ___curBlend = 0f; if ((Object)(object)__instance.backgroundRenderer != (Object)null) { ((Component)__instance.backgroundRenderer).gameObject.SetActive(false); } if ((Object)(object)__instance.foregroundRenderer != (Object)null) { ((Component)__instance.foregroundRenderer).gameObject.SetActive(false); } return false; } } private class HandItem_LateUpdate_Patch { private class VisualBinding { public Transform[] containers = Array.Empty(); public Vector3[] authoredLocalPosition = Array.Empty(); public bool freezePosition; public Quaternion[] preCorrectionLocalRotation = Array.Empty(); public Quaternion[] writtenLocalRotation = Array.Empty(); public Transform[] lamps = Array.Empty(); public Vector3[] lampAimWorldPosition = Array.Empty(); public Quaternion[] lampAimWorldRotation = Array.Empty(); public Vector3[] lampPreCorrectionLocalPosition = Array.Empty(); public Quaternion[] lampPreCorrectionLocalRotation = Array.Empty(); public Vector3[] lampWrittenLocalPosition = Array.Empty(); public Quaternion[] lampWrittenLocalRotation = Array.Empty(); public bool hasWritten; public bool nested; } private static readonly Dictionary bindings = new Dictionary(); private static readonly string[] FreezePositionItemNameContains = new string[1] { "handgun" }; public static bool IsNested(Transform root) { if ((Object)(object)root.parent != (Object)null) { return (Object)(object)((Component)root.parent).GetComponentInParent() != (Object)null; } return false; } private static bool UsesFrozenPositionCorrection(HandItem handItem) { string text = ((handItem.item != null && !string.IsNullOrEmpty(handItem.item.itemName)) ? handItem.item.itemName : ((Object)handItem).name); string[] freezePositionItemNameContains = FreezePositionItemNameContains; foreach (string value in freezePositionItemNameContains) { if (text.IndexOf(value, StringComparison.OrdinalIgnoreCase) >= 0) { return true; } } return false; } [HarmonyPostfix] [HarmonyPatch(typeof(HandItem), "LateUpdate")] private static void LateUpdate_Postfix(HandItem __instance) { //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) if (!MotionControlsActive || ((Hand_Base)__instance).hand == null || !VRAimRay.TryGetHandRay(((Hand_Base)__instance).hand.id, out var _, out var direction)) { return; } VisualBinding visualBinding = ResolveBinding(__instance); if (visualBinding.nested) { return; } Transform transform = ((Component)__instance).transform; if (visualBinding.hasWritten) { for (int i = 0; i < visualBinding.containers.Length; i++) { Transform val = visualBinding.containers[i]; if (!((Object)(object)val == (Object)null) && IsUntouchedSinceWrite(val.localRotation, visualBinding.writtenLocalRotation[i])) { val.localRotation = visualBinding.preCorrectionLocalRotation[i]; } } for (int j = 0; j < visualBinding.lamps.Length; j++) { Transform val2 = visualBinding.lamps[j]; if (!((Object)(object)val2 == (Object)null)) { if (IsUntouchedSinceWrite(val2.localPosition, visualBinding.lampWrittenLocalPosition[j])) { val2.localPosition = visualBinding.lampPreCorrectionLocalPosition[j]; } if (IsUntouchedSinceWrite(val2.localRotation, visualBinding.lampWrittenLocalRotation[j])) { val2.localRotation = visualBinding.lampPreCorrectionLocalRotation[j]; } } } } Quaternion rotation = transform.rotation; Quaternion val3 = (transform.rotation = Quaternion.LookRotation(direction, VRHandInput.Hands[((Hand_Base)__instance).hand.id].Up)); for (int k = 0; k < visualBinding.lamps.Length; k++) { Transform val5 = visualBinding.lamps[k]; if (!((Object)(object)val5 == (Object)null)) { visualBinding.lampAimWorldPosition[k] = val5.position; visualBinding.lampAimWorldRotation[k] = val5.rotation; visualBinding.lampPreCorrectionLocalPosition[k] = val5.localPosition; visualBinding.lampPreCorrectionLocalRotation[k] = val5.localRotation; } } Quaternion correction = Quaternion.Inverse(val3) * rotation; Vector3 lossyScale = transform.lossyScale; Quaternion val6 = MirrorAcrossNegativeScaleAxes(correction, lossyScale); for (int l = 0; l < visualBinding.containers.Length; l++) { Transform val7 = visualBinding.containers[l]; if (!((Object)(object)val7 == (Object)null)) { visualBinding.preCorrectionLocalRotation[l] = val7.localRotation; if (visualBinding.freezePosition) { val7.localPosition = CorrectLocalPosition(correction, lossyScale, visualBinding.authoredLocalPosition[l]); } val7.localRotation = val6 * val7.localRotation; visualBinding.writtenLocalRotation[l] = val7.localRotation; } } for (int m = 0; m < visualBinding.lamps.Length; m++) { Transform val8 = visualBinding.lamps[m]; if (!((Object)(object)val8 == (Object)null)) { val8.position = visualBinding.lampAimWorldPosition[m]; val8.rotation = visualBinding.lampAimWorldRotation[m]; visualBinding.lampWrittenLocalPosition[m] = val8.localPosition; visualBinding.lampWrittenLocalRotation[m] = val8.localRotation; } } visualBinding.hasWritten = true; } private static bool IsUntouchedSinceWrite(Vector3 current, Vector3 written) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (current.x == written.x && current.y == written.y) { return current.z == written.z; } return false; } private static bool IsUntouchedSinceWrite(Quaternion current, Quaternion written) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) if (current.x == written.x && current.y == written.y && current.z == written.z) { return current.w == written.w; } return false; } private static Quaternion MirrorAcrossNegativeScaleAxes(Quaternion correction, Vector3 scale) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) if (scale.x < 0f) { ((Quaternion)(ref correction))..ctor(correction.x, 0f - correction.y, 0f - correction.z, correction.w); } if (scale.y < 0f) { ((Quaternion)(ref correction))..ctor(0f - correction.x, correction.y, 0f - correction.z, correction.w); } if (scale.z < 0f) { ((Quaternion)(ref correction))..ctor(0f - correction.x, 0f - correction.y, correction.z, correction.w); } return correction; } private static Vector3 CorrectLocalPosition(Quaternion correction, Vector3 scale, Vector3 localPosition) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) if (Mathf.Approximately(scale.x, scale.y) && Mathf.Approximately(scale.y, scale.z)) { return correction * localPosition; } Vector3 val = Vector3.Scale(scale, localPosition); Vector3 val2 = correction * val; return new Vector3(Mathf.Approximately(scale.x, 0f) ? val2.x : (val2.x / scale.x), Mathf.Approximately(scale.y, 0f) ? val2.y : (val2.y / scale.y), Mathf.Approximately(scale.z, 0f) ? val2.z : (val2.z / scale.z)); } private static void DropBindingsForDestroyedItems() { List list = bindings.Keys.Where((HandItem item) => (Object)(object)item == (Object)null).ToList(); foreach (HandItem item in list) { bindings.Remove(item); } } private static VisualBinding ResolveBinding(HandItem handItem) { if (bindings.TryGetValue(handItem, out VisualBinding value)) { return value; } DropBindingsForDestroyedItems(); Transform transform = ((Component)handItem).transform; VisualBinding visualBinding = new VisualBinding { nested = IsNested(transform) }; if (!visualBinding.nested) { List list = new List(); for (int i = 0; i < transform.childCount; i++) { Transform child = transform.GetChild(i); if (((Component)child).GetComponentsInChildren(true).Length != 0 || ((Component)child).GetComponentsInChildren(true).Length != 0) { list.Add(child); } } visualBinding.containers = list.ToArray(); visualBinding.authoredLocalPosition = list.Select((Transform container) => container.localPosition).ToArray(); visualBinding.freezePosition = UsesFrozenPositionCorrection(handItem); visualBinding.preCorrectionLocalRotation = (Quaternion[])(object)new Quaternion[list.Count]; visualBinding.writtenLocalRotation = (Quaternion[])(object)new Quaternion[list.Count]; List list2 = new List(); foreach (Transform item in list) { CL_Lamp[] componentsInChildren = ((Component)item).GetComponentsInChildren(true); foreach (CL_Lamp val in componentsInChildren) { list2.Add(((Component)val).transform); } } visualBinding.lamps = list2.ToArray(); visualBinding.lampAimWorldPosition = (Vector3[])(object)new Vector3[list2.Count]; visualBinding.lampAimWorldRotation = (Quaternion[])(object)new Quaternion[list2.Count]; visualBinding.lampPreCorrectionLocalPosition = (Vector3[])(object)new Vector3[list2.Count]; visualBinding.lampPreCorrectionLocalRotation = (Quaternion[])(object)new Quaternion[list2.Count]; visualBinding.lampWrittenLocalPosition = (Vector3[])(object)new Vector3[list2.Count]; visualBinding.lampWrittenLocalRotation = (Quaternion[])(object)new Quaternion[list2.Count]; } bindings[handItem] = visualBinding; return visualBinding; } } private class ENT_Player_Hand_Patch { private struct ReachCandidate { public int Index; public float Cost; public Vector3 Point; public Vector3 Normal; public bool Exists => Index >= 0; public static ReachCandidate None => new ReachCandidate { Index = -1, Cost = float.MaxValue, Normal = Vector3.up }; public void TakeIfCheaper(int index, float cost, Vector3 point, Vector3 normal) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (!(cost >= Cost)) { Index = index; Cost = cost; Point = point; Normal = normal; } } } private static readonly VRReach.ReachSample[] sampleBuffer = new VRReach.ReachSample[6]; private static readonly int[] lastSampledFrame = new int[2] { -1, -1 }; private static bool inMultiCast; private static bool castOverrideActive; private static float castOverrideDistance; private static float castOverrideRadius; private const float AngleCostScale = 1000f; [HarmonyPrefix] [HarmonyPatch(typeof(Hand), "EnqueueInteractCast")] private static bool EnqueueInteractCast_Prefix(Hand __instance) { //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) if (inMultiCast) { return true; } castOverrideActive = false; if (!MotionControlsActive) { return true; } ENT_Player player = __instance.player; if ((Object)(object)player == (Object)null || (Object)(object)player.cam == (Object)null) { return true; } int id = __instance.id; int frameCount = Time.frameCount; if (id >= 0 && id < lastSampledFrame.Length && lastSampledFrame[id] == frameCount) { return false; } int num = VRReach.BuildReachSamples(player, id, sampleBuffer); if (num == 0) { if (id >= 0 && id < VRReach.HasLastCastHit.Length) { VRReach.ClearHand(id); } return true; } if (id >= 0 && id < lastSampledFrame.Length) { lastSampledFrame[id] = frameCount; } using (VRCameraSpoof vRCameraSpoof = VRCameraSpoof.Capture()) { try { inMultiCast = true; for (int i = 0; i < num; i++) { VRReach.ReachSample reachSample = sampleBuffer[i]; vRCameraSpoof.Aim(reachSample.Origin, reachSample.Direction); castOverrideDistance = reachSample.Distance; castOverrideRadius = reachSample.Radius; castOverrideActive = true; __instance.EnqueueInteractCast(); } } finally { castOverrideActive = false; inMultiCast = false; } } RecordCastHit(__instance, num); return false; } private static void RecordCastHit(Hand hand, int sampleCount) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_0358: Unknown result type (might be due to invalid IL or missing references) //IL_0365: Unknown result type (might be due to invalid IL or missing references) //IL_036a: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) int id = hand.id; if (id < 0 || id >= VRReach.HasLastCastHit.Length) { return; } List queuedHits = hand.queuedHits; if (queuedHits == null || queuedHits.Count == 0) { VRReach.ClearHand(id); return; } int num = Mathf.Max(0, queuedHits.Count - sampleCount); Vector3 val = VRReach.LastAxisOrigin[id]; Vector3 val2 = VRReach.LastAxisDirection[id]; VRSettings settings = Settings; ReachCandidate none = ReachCandidate.None; ReachCandidate none2 = ReachCandidate.None; for (int i = num; i < queuedHits.Count; i++) { if (TryResolveCandidate(queuedHits[i], out var point, out var normal, out var isHandhold)) { Vector3 val3 = point - val; float magnitude = ((Vector3)(ref val3)).magnitude; float num2 = ((magnitude > 0.0001f) ? Vector3.Angle(val2, val3) : 0f); float num3 = Mathf.Max(0f, num2 - settings.reachAngleTolerance) * 1000f; float num4 = (0f - magnitude) * settings.reachFarthestBias; float cost = num2 + num3 + num4; if (isHandhold) { none.TakeIfCheaper(i, cost, point, normal); } else { none2.TakeIfCheaper(i, cost, point, normal); } } } VRReach.HasHandhold[id] = none.Exists; if (none.Exists) { VRReach.HandholdPoint[id] = none.Point; } VRReach.HasItem[id] = none2.Exists; if (none2.Exists) { VRReach.ItemPoint[id] = none2.Point; } bool exists = none.Exists; bool exists2 = none2.Exists; ResolveGrabExclusivity(id, out var allowHandhold, out var allowItem); exists = exists && allowHandhold; exists2 = exists2 && allowItem; if (!allowHandhold) { hand.memoryTime = 0f; hand.nohandholdsMemoryTime = 0f; } if (exists) { HandPhysicsHits entry = queuedHits[none.Index]; if (FilterEntryForExclusivity(ref entry, allowHandhold, allowItem)) { queuedHits[none.Index] = entry; } else { exists = false; } } if (exists2) { HandPhysicsHits entry2 = queuedHits[none2.Index]; if (FilterEntryForExclusivity(ref entry2, allowHandhold, allowItem)) { queuedHits[none2.Index] = entry2; } else { exists2 = false; } } bool flag = exists && (!exists2 || none.Cost <= none2.Cost); int num5 = -1; int num6 = -1; for (int num7 = queuedHits.Count - 1; num7 >= 0; num7--) { if (TryResolveCandidate(queuedHits[num7], out var _, out var _, out var isHandhold2)) { if (isHandhold2 && exists && num7 == none.Index) { num5 = num7; } else if (!isHandhold2 && exists2 && num7 == none2.Index) { num6 = num7; } else { queuedHits.RemoveAt(num7); if (num5 > num7) { num5--; } if (num6 > num7) { num6--; } } } } if (num5 >= 0 && num6 >= 0) { int num8 = (flag ? num5 : num6); int num9 = (flag ? num6 : num5); if (num8 > num9) { List list = queuedHits; int index = num8; int index2 = num9; HandPhysicsHits value = queuedHits[num9]; HandPhysicsHits value2 = queuedHits[num8]; list[index] = value; queuedHits[index2] = value2; } } if (!exists && !exists2) { VRReach.HasLastCastHit[id] = false; VRReach.LastCastHitIsHandhold[id] = false; return; } ReachCandidate reachCandidate = (flag ? none : none2); VRReach.LastCastHitPoint[id] = reachCandidate.Point; VRReach.LastCastHitNormal[id] = reachCandidate.Normal; VRReach.LastCastHitIsHandhold[id] = flag; VRReach.HasLastCastHit[id] = true; } internal static bool GripIsSecondInput() { if (!VRControllerProfile.DualTargetPaths) { return Settings.indexGripGrabsLedges; } return true; } internal static void ResolveGrabExclusivity(int handId, out bool allowHandhold, out bool allowItem) { VRHand vRHand = VRHandInput.Hands[handId]; bool flag = vRHand.Grip.Pressed || vRHand.Grip.Down; bool flag2 = vRHand.Trigger.Pressed || vRHand.Trigger.Down; bool flag3 = GripIsSecondInput(); if (flag3 && flag) { allowHandhold = true; allowItem = false; } else if (flag3 && flag2) { allowHandhold = false; allowItem = true; } else { allowHandhold = true; allowItem = true; } } private static bool TryResolveCandidate(HandPhysicsHits sample, out Vector3 point, out Vector3 normal, out bool isHandhold) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) if (TryResolveHit(sample.directHit, out point, out normal, out isHandhold)) { return true; } if (TryResolveHit(sample.sphereCastHit, out point, out normal, out isHandhold)) { return true; } point = default(Vector3); normal = Vector3.up; isHandhold = false; return false; } private static bool TryResolveHit(RaycastHit hit, out Vector3 point, out Vector3 normal, out bool isHandhold) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) point = default(Vector3); normal = Vector3.up; isHandhold = false; if ((Object)(object)((RaycastHit)(ref hit)).collider == (Object)null) { return false; } ObjectTagger component = ((Component)((RaycastHit)(ref hit)).collider).GetComponent(); if ((Object)(object)component == (Object)null) { return false; } isHandhold = component.HasTag("Handhold"); if (!isHandhold && !component.HasTag("Item")) { return false; } point = (((Object)(object)((Component)((RaycastHit)(ref hit)).collider).GetComponent() != (Object)null) ? ((RaycastHit)(ref hit)).point : ((RaycastHit)(ref hit)).collider.ClosestPoint(((RaycastHit)(ref hit)).point)); normal = ((RaycastHit)(ref hit)).normal; return true; } private static bool ColliderIsDisallowed(Collider collider, bool allowHandhold, bool allowItem) { ObjectTagger component = ((Component)collider).GetComponent(); if ((Object)(object)component == (Object)null) { return false; } if (component.HasTag("Handhold") && !allowHandhold) { return true; } if (component.HasTag("Item") && !allowItem) { return true; } return false; } private static bool FilterEntryForExclusivity(ref HandPhysicsHits entry, bool allowHandhold, bool allowItem) { Collider collider = ((RaycastHit)(ref entry.directHit)).collider; if ((Object)(object)collider != (Object)null && ColliderIsDisallowed(collider, allowHandhold, allowItem)) { return false; } Collider collider2 = ((RaycastHit)(ref entry.sphereCastHit)).collider; if ((Object)(object)collider2 != (Object)null && ColliderIsDisallowed(collider2, allowHandhold, allowItem)) { return false; } if (!allowHandhold && entry.lineHit != null) { for (int i = 0; i < entry.lineHitCount; i++) { Collider collider3 = ((RaycastHit)(ref entry.lineHit[i])).collider; if (!((Object)(object)collider3 == (Object)null)) { ObjectTagger component = ((Component)collider3).GetComponent(); if ((Object)(object)component != (Object)null && component.HasTag("Handhold")) { entry.lineHitCount = 0; break; } } } } if (entry.sphereCheck != null) { for (int j = 0; j < entry.sphereCheckCount; j++) { Collider val = entry.sphereCheck[j]; if (!((Object)(object)val == (Object)null) && ColliderIsDisallowed(val, allowHandhold, allowItem)) { entry.sphereCheck[j] = null; } } } return true; } [HarmonyPostfix] [HarmonyPatch(typeof(ENT_Player), "GetInteractDistance")] private static void GetInteractDistance_Postfix(ref float __result) { if (castOverrideActive) { __result = castOverrideDistance; } } [HarmonyPostfix] [HarmonyPatch(typeof(ENT_Player), "InteractSphereRadius")] private static void InteractSphereRadius_Postfix(ref float __result) { if (castOverrideActive) { __result = castOverrideRadius; } } } private class ENT_Player_CrouchHeight_Patch { [HarmonyPrefix] [HarmonyPatch(typeof(ENT_Player), "ChangeHeight")] private static bool ChangeHeight_Prefix(ENT_Player __instance, float targetHeight, ref IEnumerator __result) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) if (!MotionControlsActive) { return true; } if (!Settings.physicalCrouchEnabled) { return true; } __instance.cCon.height = targetHeight; __instance.cCon.center = Vector3.up * (targetHeight - __instance.standingHeight) * 0.5f; __result = NoHeightAnimation(); return false; } private static IEnumerator NoHeightAnimation() { yield break; } } private class ENT_Player_Interact_Patch { [HarmonyPrefix] [HarmonyPatch(typeof(ENT_Player), "Interact")] private static void Interact_Prefix(Interaction interaction) { if (MotionControlsActive && interaction != null && !((Object)(object)interaction.tagger == (Object)null) && interaction.curhand != null && (interaction.tagger.HasTag("Button") || interaction.tagger.HasTag("HoldButton"))) { interaction.fireButton = VRHandButtons.UseName(interaction.curhand.id); } } } private class CL_CameraControl_Patch { [HarmonyPrefix] [HarmonyPatch(typeof(CL_CameraControl), "ShakeCamera", new Type[] { typeof(float) })] private static bool ShakeCamera_Patch(CL_CameraControl __instance, float amount) { return false; } } private class FXManager_Patch { private static int lastBlendedFrame = -1; private static FXData? blendedThisFrame; private static Camera? forwardPlusProxy; private static RenderTexture? forwardPlusProxyTarget; [HarmonyPostfix] [HarmonyPatch(typeof(FXManager), "CameraFX")] private static void CameraFX_Postfix() { if (vrInitialized) { if (lastBlendedFrame != Time.frameCount) { lastBlendedFrame = Time.frameCount; blendedThisFrame = FXManager.fxData; } else if (blendedThisFrame != null) { FXManager.fxData = blendedThisFrame; FXManager.FXRender(); } } } [HarmonyPrefix] [HarmonyPatch(typeof(FXManager), "PreRender")] private static bool PreRender_Patch(FXManager __instance, Camera camera) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) if (!vrInitialized) { return true; } Camera vrCamera = VrCamera; if ((Object)(object)vrCamera == (Object)null || (Object)(object)camera != (Object)(object)vrCamera) { return false; } if (LastSetCameraLocalRotationFrame == Time.frameCount) { float num = Quaternion.Angle(((Component)camera).transform.localRotation, LastSetCameraLocalRotation); if (num > 0.05f) { Debug.LogWarning((object)$"Camera rotation drifted between onPreCull and onPreRender: {num:F3} deg, frame={Time.frameCount}"); } } if (Application.isPlaying) { RunForwardPlusForEye(__instance, vrCamera, camera.stereoActiveEye); } return false; } private static void RunForwardPlusForEye(FXManager manager, Camera vrCamera, MonoOrStereoscopicEye activeEye) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) StereoscopicEye val = (StereoscopicEye)((int)activeEye == 1); Camera val2 = ResolveForwardPlusProxy(); int eyeTextureWidth = XRSettings.eyeTextureWidth; int eyeTextureHeight = XRSettings.eyeTextureHeight; if (eyeTextureWidth <= 0 || eyeTextureHeight <= 0) { manager.FXForwardPlus(vrCamera); return; } if ((Object)(object)forwardPlusProxyTarget == (Object)null || ((Texture)forwardPlusProxyTarget).width != eyeTextureWidth || ((Texture)forwardPlusProxyTarget).height != eyeTextureHeight) { forwardPlusProxyTarget = new RenderTexture(eyeTextureWidth, eyeTextureHeight, 0, (RenderTextureFormat)16); val2.targetTexture = forwardPlusProxyTarget; } Matrix4x4 stereoViewMatrix = vrCamera.GetStereoViewMatrix(val); Matrix4x4 inverse = ((Matrix4x4)(ref stereoViewMatrix)).inverse; ((Component)val2).transform.SetPositionAndRotation(Vector4.op_Implicit(((Matrix4x4)(ref inverse)).GetColumn(3)), Quaternion.LookRotation(-Vector4.op_Implicit(((Matrix4x4)(ref inverse)).GetColumn(2)), Vector4.op_Implicit(((Matrix4x4)(ref inverse)).GetColumn(1)))); val2.projectionMatrix = vrCamera.GetStereoProjectionMatrix(val); val2.nearClipPlane = vrCamera.nearClipPlane; val2.farClipPlane = vrCamera.farClipPlane; val2.cullingMask = vrCamera.cullingMask; manager.FXForwardPlus(val2); } private static Camera ResolveForwardPlusProxy() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown if ((Object)(object)forwardPlusProxy != (Object)null) { return forwardPlusProxy; } GameObject val = new GameObject("VR ForwardPlus Eye Proxy"); Object.DontDestroyOnLoad((Object)(object)val); forwardPlusProxy = val.AddComponent(); ((Behaviour)forwardPlusProxy).enabled = false; forwardPlusProxy.stereoTargetEye = (StereoTargetEyeMask)0; return forwardPlusProxy; } } public static VRRenderingPipeline? instance; public static bool vrInitialized = false; public static VRSettings Settings = new VRSettings(); private GameObject? vrCameraOffset; private GameObject? vrCameraGo; private Camera? vrCamera; public static Camera? mainCamera; public static GameObject? mainCameraGo; private GameObject? vrRigGo; private GameObject? clPlayerGo; private GameObject? leftHandGo; private GameObject? rightHandGo; private GameObject? vrLeftHandGo; private GameObject? vrRightHandGo; private readonly bool[] wasGripped = new bool[2]; private readonly Vector3[] handGrabNormal = (Vector3[])(object)new Vector3[2] { Vector3.up, Vector3.up }; private readonly Transform?[] cachedHandModel = (Transform?[])(object)new Transform[2]; private readonly Renderer[]?[] handModelRenderers = new Renderer[2][]; private GameObject? vrLeftHeldItemGo; private GameObject? vrRightHeldItemGo; private readonly HandItem?[] attachedHandItem = (HandItem?[])(object)new HandItem[2]; private readonly Vector3[] attachedHandItemVanillaLocalScale = (Vector3[])(object)new Vector3[2]; private readonly float[] attachedHandItemVanillaToVrScale = new float[2]; private VRItemAimBeam? leftItemAimBeam; private VRItemAimBeam? rightItemAimBeam; private VRBagPlacementMarker? leftPlacementMarker; private VRBagPlacementMarker? rightPlacementMarker; private GameObject? vrLeftInteractIconGo; private GameObject? vrRightInteractIconGo; private GameObject? vrLeftSecondaryIconGo; private GameObject? vrRightSecondaryIconGo; private const float INDICATOR_SURFACE_LIFT = 0.03f; private const float INDICATOR_ANGULAR_SIZE = 0.11f; private const float INDICATOR_MIN_SIZE = 0.05f; private const float INDICATOR_MAX_SIZE = 0.28f; private readonly List menuCanvasGroups = new List(); private readonly List convertedCanvasRoots = new List(); private Vector3 menuHeadPositionReference = Vector3.zero; private bool menuHeadReferenceCaptured; private static float locomotionYaw = 0f; public static Quaternion CanonicalHeadRotation = Quaternion.identity; public static int CanonicalHeadRotationFrame = -1; private Quaternion lastKnownHeadRotation = Quaternion.identity; private bool pauseMenuWasOpen; private static bool spawnYawAligned; public static Quaternion LastSetCameraLocalRotation = Quaternion.identity; public static int LastSetCameraLocalRotationFrame = -1; private const int MaxVRInitAttempts = 5; private float lastMenuCanvasGroupCacheTime; private static bool menuCanvasGroupCacheDirty = false; private bool menuWasVisible; private int menuCanvasGroupCleanScans; private static readonly HashSet forcedVisibleMenuCanvasGroups = new HashSet(); private const string ViewmodelOverlayLayerName = "Overlay"; private int baseWorldCullingMask; private const string ViewmodelHandLayerName = "Player"; public static CameraClearFlags vanillaClearFlags = (CameraClearFlags)2; public static Color vanillaBackgroundColor = Color.black; private static bool vanillaClearCaptured; private const float StrayCameraSettleInterval = 0.25f; private const int StrayCameraScansToSettle = 3; private readonly HashSet suppressedStereoCameraIds = new HashSet(); private float lastStrayCameraSweepTime; private Camera[] strayCameraBuffer = (Camera[])(object)new Camera[8]; private int lastSeenCameraCount = -1; private int strayCameraCleanScans; private bool strayCameraSweepSettled; private Camera? suppressedOverlayCamera; private readonly HashSet suppressedEffectCameraIds = new HashSet(); private bool overlayUiManagerConverted; private Transform? abilityVignettesRoot; private bool wasPlayerDeadForVignetteReset; private static bool hookedMenuRecenter = false; private bool snapTurnReady = true; private static Vector3 previousFixedPlayerPosition = Vector3.zero; private static Vector3 currentFixedPlayerPosition = Vector3.zero; private static bool hasFixedPlayerPositionSample = false; private static Vector3 previousFixedHeadPlayspacePosition = Vector3.zero; private static bool hasFixedHeadPlayspaceSample = false; private static float observedMaxMovementSpeed = 0f; private static float stickSpeedLastTick = 0f; private static Vector3 standingCamTargetLocalPosition; private static bool hasStandingCamTarget; private static bool loggedCamTargetCorrection; private VRLaserPointer? leftLaser; private VRLaserPointer? rightLaser; private readonly bool[] handWasTracked = new bool[2]; private static readonly string[] GripGrabsWhileHeldItemNameContains = new string[1] { "glove" }; public static bool MotionControlsActive { get { if (vrInitialized) { return Settings.useMotionControls; } return false; } } private ManualLogSource Logger => ((BaseUnityPlugin)this).Logger; public static ManualLogSource? StaticLogger => instance?.Logger; public static Camera? VrCamera => instance?.vrCamera; public static Transform? VrLeftHand { get { VRRenderingPipeline? vRRenderingPipeline = instance; if (vRRenderingPipeline == null) { return null; } GameObject? obj = vRRenderingPipeline.vrLeftHandGo; if (obj == null) { return null; } return obj.transform; } } public static Transform? VrRightHand { get { VRRenderingPipeline? vRRenderingPipeline = instance; if (vRRenderingPipeline == null) { return null; } GameObject? obj = vRRenderingPipeline.vrRightHandGo; if (obj == null) { return null; } return obj.transform; } } public static bool MenuOpen { get { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)CL_GameManager.gMan != (Object)null) || !CL_GameManager.gMan.isPaused) { Scene activeScene = SceneManager.GetActiveScene(); return ((Scene)(ref activeScene)).name == Scenes.MainMenu; } return true; } } private void ApplyHarmonyPatches() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown Logger.LogInfo((object)"Applying Harmony Patches"); HarmonyFileLog.Enabled = true; Harmony val = new Harmony("com.whiteknucklevr.harmonypatcher"); val.PatchAll(typeof(CL_CameraControl_Patch)); val.PatchAll(typeof(ENT_Player_Patch)); val.PatchAll(typeof(ENT_Player_Hand_Patch)); val.PatchAll(typeof(ENT_Player_Interact_Patch)); val.PatchAll(typeof(FXManager_Patch)); val.PatchAll(typeof(Inventory_Patch)); val.PatchAll(typeof(InputManager_Patch)); val.PatchAll(typeof(CL_Handhold_Patch)); val.PatchAll(typeof(M_Level_Patch)); val.PatchAll(typeof(CL_HoldLever_Patch)); val.PatchAll(typeof(CL_Prop_Patch)); val.PatchAll(typeof(UT_CameraTakeover_Patch)); val.PatchAll(typeof(HandItem_Aim_Patch)); val.PatchAll(typeof(ViewSway_Patch)); val.PatchAll(typeof(Hand_Takeover_Patch)); val.PatchAll(typeof(HandItem_LateUpdate_Patch)); val.PatchAll(typeof(Message_Manager_Patch)); val.PatchAll(typeof(Inventory_ShowInventory_Patch)); val.PatchAll(typeof(Item_Object_Flashlight_Patch)); val.PatchAll(typeof(CosmeticInfoPanel_Patch)); val.PatchAll(typeof(SubmitSlider_Patch)); IEnumerable patchedMethods = val.GetPatchedMethods(); foreach (MethodBase item in patchedMethods) { if (item != null && Settings.verboseLogging) { Logger.LogInfo((object)$"Patched method: {item.DeclaringType}.{item.Name}"); } } } private void Awake() { if ((Object)(object)instance != (Object)null) { Object.Destroy((Object)(object)this); return; } Settings = VRSettingsManager.Load(Logger); if (!Settings.activateVR) { Logger.LogWarning((object)"activateVR is false in VRToggle.json - running the game unmodified. Set it back to true and relaunch to re-enable VR."); ((Behaviour)this).enabled = false; return; } BepInExConfigGuard.EnsureManagerObjectHidden(Logger); VRDataFolderGuard.EnsureRedistFilesPresent(Logger); XRLibraryInjector.ForceLoadDLLs(Logger); instance = this; Object.DontDestroyOnLoad((Object)(object)this); } private void Start() { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown Logger.LogInfo((object)"VR Mod Starting"); ApplyHarmonyPatches(); SceneManager.sceneLoaded += OnSceneLoaded; SceneManager.sceneUnloaded += OnSceneUnloaded; Camera.onPreCull = (CameraCallback)Delegate.Combine((Delegate?)(object)Camera.onPreCull, (Delegate?)new CameraCallback(ApplyFreshestHeadRotation)); SuppressStereoCameras(); ((MonoBehaviour)this).StartCoroutine(InitializeVR()); ((MonoBehaviour)this).StartCoroutine(SuppressVisualsUntilMainMenu()); } private void SuppressStereoCameras() { Camera[] allCameras = Camera.allCameras; foreach (Camera val in allCameras) { val.stereoTargetEye = (StereoTargetEyeMask)0; } } private void ApplyFreshestHeadRotation(Camera cam) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)cam != (Object)(object)vrCamera) && vrInitialized && !((Object)(object)vrCameraGo == (Object)null)) { LastSetCameraLocalRotation = vrCameraGo.transform.localRotation; LastSetCameraLocalRotationFrame = Time.frameCount; } } private void UpdateCanonicalHeadRotation() { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) if (vrInitialized) { InputDevice deviceAtXRNode = InputDevices.GetDeviceAtXRNode((XRNode)3); Quaternion canonicalHeadRotation = default(Quaternion); if (((InputDevice)(ref deviceAtXRNode)).TryGetFeatureValue(CommonUsages.deviceRotation, ref canonicalHeadRotation)) { CanonicalHeadRotation = canonicalHeadRotation; lastKnownHeadRotation = canonicalHeadRotation; } else { Logger.LogWarning((object)"UpdateCanonicalHeadRotation: TryGetFeatureValue(deviceRotation) failed; keeping last known head rotation for this frame."); CanonicalHeadRotation = lastKnownHeadRotation; } CanonicalHeadRotationFrame = Time.frameCount; } } private void RecentreMenusWhenPauseOpens() { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) bool flag = (Object)(object)CL_GameManager.gMan != (Object)null && CL_GameManager.gMan.isPaused; if (flag == pauseMenuWasOpen) { return; } pauseMenuWasOpen = flag; if (!flag || (Object)(object)vrRigGo == (Object)null || (Object)(object)vrCameraGo == (Object)null) { return; } Transform transform = vrRigGo.transform; Vector3 val = transform.InverseTransformPoint(vrCameraGo.transform.position); Vector3 val2 = transform.InverseTransformDirection(vrCameraGo.transform.forward); val2.y = 0f; if (((Vector3)(ref val2)).sqrMagnitude < 0.0001f) { val2 = Vector3.forward; } ((Vector3)(ref val2)).Normalize(); Quaternion localRotation = Quaternion.LookRotation(val2, Vector3.up); Vector3 localPosition = val + val2 * 1.8f; foreach (Canvas convertedCanvasRoot in convertedCanvasRoots) { if (!((Object)(object)convertedCanvasRoot == (Object)null) && !((Object)(object)((Component)convertedCanvasRoot).transform.parent != (Object)(object)transform)) { ((Component)convertedCanvasRoot).transform.localRotation = localRotation; ((Component)convertedCanvasRoot).transform.localPosition = localPosition; } } } private void FollowMenusWithLookYaw() { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) if (!Settings.menuFollowYaw || (Object)(object)vrRigGo == (Object)null || (Object)(object)vrCameraGo == (Object)null || convertedCanvasRoots.Count == 0) { return; } Transform transform = vrRigGo.transform; Vector3 val = transform.InverseTransformPoint(vrCameraGo.transform.position); Vector3 val2 = transform.InverseTransformDirection(vrCameraGo.transform.forward); val2.y = 0f; if (((Vector3)(ref val2)).sqrMagnitude < 0.0001f) { return; } ((Vector3)(ref val2)).Normalize(); Quaternion val3 = Quaternion.LookRotation(val2, Vector3.up); float y = ((Quaternion)(ref val3)).eulerAngles.y; float menuFollowYawDeadzoneDegrees = Settings.menuFollowYawDeadzoneDegrees; float num = 1f - Mathf.Exp((0f - Settings.menuFollowSpeed) * Time.unscaledDeltaTime); foreach (Canvas convertedCanvasRoot in convertedCanvasRoots) { if (!((Object)(object)convertedCanvasRoot == (Object)null) && !((Object)(object)((Component)convertedCanvasRoot).transform.parent != (Object)(object)transform) && ((Component)convertedCanvasRoot).gameObject.activeInHierarchy) { val3 = ((Component)convertedCanvasRoot).transform.localRotation; float y2 = ((Quaternion)(ref val3)).eulerAngles.y; float num2 = Mathf.DeltaAngle(y2, y); float num3 = y2; if (Mathf.Abs(num2) > menuFollowYawDeadzoneDegrees) { float num4 = y - Mathf.Sign(num2) * menuFollowYawDeadzoneDegrees; num3 = Mathf.LerpAngle(y2, num4, num); } Quaternion val4 = Quaternion.Euler(0f, num3, 0f); ((Component)convertedCanvasRoot).transform.localRotation = val4; ((Component)convertedCanvasRoot).transform.localPosition = val + val4 * Vector3.forward * 1.8f; } } } private void UpdateLocomotionYaw() { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) if (!vrInitialized || (Object)(object)clPlayerGo == (Object)null || ((Object)(object)CL_GameManager.gMan != (Object)null && CL_GameManager.gMan.isPaused)) { return; } VRHand turnHand = VRHandInput.TurnHand; bool flag = VRVirtualGamepad.VrIsActive && turnHand.IsTracked; Gamepad val = VRVirtualGamepad.ActiveDevice ?? Gamepad.current; Vector2 val2 = ((val != null) ? ((InputControl)(object)val.rightStick).ReadValue() : Vector2.zero); float num = (flag ? turnHand.Stick.x : val2.x); float stickY = (flag ? turnHand.Stick.y : val2.y); VRLookOffset.Advance(stickY, Mathf.Min(Time.deltaTime, 1f / 90f)); if (!(Settings.turnStyle == "disabled")) { if (Settings.turnStyle == "snap") { DebounceSnapTurn(num); return; } float num2 = (flag ? 0f : (((InputControl)(object)((Pointer)Mouse.current).delta).ReadValue().x * 0.05f)); float num3 = ((Mathf.Abs(num2) > Mathf.Abs(num)) ? num2 : num); float num4 = Mathf.Min(Time.deltaTime, 1f / 90f); locomotionYaw += num3 * Settings.smoothTurnSpeed * num4; } } public static void AlignLocomotionYawToSpawnOnce(ENT_Player player, float hmdYaw) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) if (!spawnYawAligned && !((Object)(object)player == (Object)null)) { spawnYawAligned = true; float num = MathUtils.RotationAroundAxis(((Component)player).transform.rotation, Vector3.up); locomotionYaw = Mathf.DeltaAngle(hmdYaw, num); if ((Object)(object)instance != (Object)null && (Object)(object)instance.vrRigGo != (Object)null) { instance.vrRigGo.transform.rotation = Quaternion.AngleAxis(locomotionYaw, Vector3.up); } } } private void ResetLocomotionYaw() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) locomotionYaw = 0f; spawnYawAligned = false; VRLookOffset.Reset(); if ((Object)(object)vrRigGo != (Object)null) { vrRigGo.transform.rotation = Quaternion.AngleAxis(locomotionYaw, Vector3.up); } ResetHeadsetMovementBaseline(); } private IEnumerator InitializeVR() { int attempt = 0; while (!XRSettings.isDeviceActive) { attempt++; yield return VRDeviceLoader.InitializeXRSubsystems(Logger, useSinglePassInstanced: false); if (!XRSettings.isDeviceActive) { if (attempt >= 5) { Logger.LogError((object)$"No active XR runtime detected after {attempt} attempts; giving up and staying in flatscreen mode."); yield break; } Logger.LogWarning((object)$"No active XR runtime detected; retrying in 5s (attempt {attempt}/{5})"); yield return (object)new WaitForSeconds(5f); } } XRSettings.eyeTextureResolutionScale = Settings.renderScale; QualitySettings.vSyncCount = 0; Application.targetFrameRate = -1; Logger.LogInfo((object)$"XR active: {XRSettings.isDeviceActive}"); Logger.LogInfo((object)("XR active device name: " + XRSettings.loadedDeviceName)); InitializeVRCamera(); vrInitialized = true; Scene activeScene = SceneManager.GetActiveScene(); bool inGameMain = ((Scene)(ref activeScene)).name == Scenes.GameMain || ((Scene)(ref activeScene)).name == Scenes.Playground; ((MonoBehaviour)this).StartCoroutine(InjectVRCamera(inGameMain)); } private IEnumerator SuppressVisualsUntilMainMenu() { yield return (object)new WaitUntil((Func)(() => (Object)(object)vrCamera != (Object)null)); while (true) { Scene val = SceneManager.GetActiveScene(); if (!(((Scene)(ref val)).name != Scenes.MainMenu)) { break; } Canvas[] array = Resources.FindObjectsOfTypeAll(); foreach (Canvas val2 in array) { val = ((Component)val2).gameObject.scene; if (((Scene)(ref val)).IsValid() && ((Behaviour)val2).enabled) { ((Behaviour)val2).enabled = false; } } yield return null; } baseWorldCullingMask = -1; ApplyMergedCullingMask(); Logger.LogInfo((object)"Loading Main Menu"); } private static bool IsRelevantMenuScene(Scene scene, Scene activeScene) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) if (!((Scene)(ref scene)).IsValid()) { return false; } if (!(scene == activeScene)) { return ((Scene)(ref scene)).name == "DontDestroyOnLoad"; } return true; } private void CacheMenuCanvasGroups() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) menuCanvasGroups.Clear(); Scene activeScene = SceneManager.GetActiveScene(); UI_Menu[] array = Resources.FindObjectsOfTypeAll(); foreach (UI_Menu val in array) { if (IsRelevantMenuScene(((Component)val).gameObject.scene, activeScene) && (Object)(object)val.group != (Object)null) { menuCanvasGroups.Add(val.group); } } UI_MenuScreen[] array2 = Resources.FindObjectsOfTypeAll(); foreach (UI_MenuScreen val2 in array2) { if (IsRelevantMenuScene(((Component)val2).gameObject.scene, activeScene) && (Object)(object)val2.group != (Object)null) { menuCanvasGroups.Add(val2.group); } } } private void RefreshMenuCanvasGroupsPeriodically() { bool menuOpen = MenuOpen; if (menuOpen != menuWasVisible) { menuWasVisible = menuOpen; menuCanvasGroupCacheDirty = menuOpen; menuCanvasGroupCleanScans = 0; } if (menuCanvasGroupCacheDirty && !(Time.unscaledTime - lastMenuCanvasGroupCacheTime < 0.25f)) { lastMenuCanvasGroupCacheTime = Time.unscaledTime; int count = menuCanvasGroups.Count; CacheMenuCanvasGroups(); menuCanvasGroupCleanScans = ((menuCanvasGroups.Count == count) ? (menuCanvasGroupCleanScans + 1) : 0); if (menuCanvasGroupCleanScans >= 3) { menuCanvasGroupCacheDirty = false; } } } public static void InvalidateMenuCanvasGroupCache() { menuCanvasGroupCacheDirty = true; } private void SyncMenuCanvasGroupVisibility() { foreach (CanvasGroup menuCanvasGroup in menuCanvasGroups) { if (!((Object)(object)menuCanvasGroup == (Object)null)) { if (forcedVisibleMenuCanvasGroups.Contains(menuCanvasGroup)) { menuCanvasGroup.alpha = 1f; } else { menuCanvasGroup.alpha = (menuCanvasGroup.interactable ? 1f : 0f); } } } } public static void ForceMenuCanvasGroupVisible(CanvasGroup group) { if (!((Object)(object)group == (Object)null)) { forcedVisibleMenuCanvasGroups.Add(group); group.alpha = 1f; } } public static void ReleaseMenuCanvasGroupVisible(CanvasGroup group) { if (!((Object)(object)group == (Object)null)) { forcedVisibleMenuCanvasGroups.Remove(group); } } public static void RegisterMenuCanvasGroup(CanvasGroup group) { if (!((Object)(object)instance == (Object)null) && !((Object)(object)group == (Object)null) && !instance.menuCanvasGroups.Contains(group)) { instance.menuCanvasGroups.Add(group); } } public static string HierarchyPath(Transform transform) { StringBuilder stringBuilder = new StringBuilder(((Object)transform).name); Transform parent = transform.parent; while ((Object)(object)parent != (Object)null) { stringBuilder.Insert(0, ((Object)parent).name + "/"); parent = parent.parent; } return stringBuilder.ToString(); } private void DisableForeignEventSystems() { EventSystem[] array = Resources.FindObjectsOfTypeAll(); foreach (EventSystem val in array) { if (((Behaviour)val).enabled) { string text = HierarchyPath(((Component)val).transform); if (text.Contains("UniverseLib") || text.Contains("Explorer")) { ((Behaviour)val).enabled = false; } } } } private void ApplyMergedCullingMask() { if (!((Object)(object)vrCamera == (Object)null)) { vrCamera.cullingMask = baseWorldCullingMask | VROverlayLayerTracker.OverlayMask; } } private int ExcludeOverlayLayer(int baseMask) { int num = LayerMask.NameToLayer("Overlay"); if (num < 0) { Logger.LogWarning((object)"No 'Overlay' layer found; drawing all base layers"); return baseMask; } return baseMask & ~(1 << num); } private int IncludeHandLayer(int baseMask) { int num = LayerMask.NameToLayer("Player"); if (num < 0) { Logger.LogWarning((object)"No 'Player' layer found; hands may not render"); return baseMask; } return baseMask | (1 << num); } private void CaptureVanillaClearSettings(Camera cam) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Invalid comparison between Unknown and I4 //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Invalid comparison between Unknown and I4 //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) Color val = ((FXManager.fxData != null) ? FXManager.fxData.fog : Color.black); if ((int)cam.clearFlags == 4 || (int)cam.clearFlags == 3) { vanillaClearFlags = (CameraClearFlags)2; vanillaBackgroundColor = ((FXManager.showFog && FXManager.fxData != null) ? val : Color.black); vanillaBackgroundColor.a = 1f; } else { vanillaClearFlags = cam.clearFlags; vanillaBackgroundColor = cam.backgroundColor; vanillaBackgroundColor.a = 1f; } vanillaClearCaptured = true; ApplyVanillaClearSettings(); } public static void ApplyVanillaClearSettings() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) Camera val = VrCamera; if (!((Object)(object)val == (Object)null) && vanillaClearCaptured) { val.clearFlags = vanillaClearFlags; val.backgroundColor = vanillaBackgroundColor; if ((Object)(object)instance != (Object)null) { instance.Logger.LogInfo((object)$"[clear] VR camera clearFlags={val.clearFlags} background={val.backgroundColor}"); } } } private void InitializeVRCamera() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Expected O, but got Unknown //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Expected O, but got Unknown //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Expected O, but got Unknown //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Expected O, but got Unknown if (!((Object)(object)vrRigGo != (Object)null)) { vrRigGo = new GameObject("VR Rig"); vrCameraOffset = new GameObject("VR Camera Offset"); vrCameraGo = new GameObject("VR Camera GO"); Object.DontDestroyOnLoad((Object)(object)vrRigGo); vrRigGo.transform.position = Vector3.zero; vrRigGo.transform.rotation = Quaternion.identity; vrCameraGo.AddComponent(); vrCamera = vrCameraGo.GetComponent(); vrCamera.clearFlags = (CameraClearFlags)2; vrCamera.stereoTargetEye = (StereoTargetEyeMask)3; vrCamera.nearClipPlane = 0.005f; vrCamera.farClipPlane = 5000f; vrCamera.cullingMask = 0; vrCamera.depthTextureMode = (DepthTextureMode)1; ((Behaviour)vrCamera).enabled = true; vrCamera.backgroundColor = Color.black; ApplyVanillaClearSettings(); vrCameraOffset.transform.SetParent(vrRigGo.transform, false); vrCameraOffset.transform.localPosition = Vector3.zero; vrCameraOffset.transform.rotation = Quaternion.identity; vrCameraGo.transform.SetParent(vrCameraOffset.transform, false); vrLeftHandGo = new GameObject("VR Hand Left"); vrRightHandGo = new GameObject("VR Hand Right"); vrLeftHandGo.transform.SetParent(vrRigGo.transform, false); vrRightHandGo.transform.SetParent(vrRigGo.transform, false); BuildHandVisual(vrLeftHandGo, Color.white); BuildHandVisual(vrRightHandGo, Color.white); vrLeftHeldItemGo = new GameObject("VR Held Item Left"); vrRightHeldItemGo = new GameObject("VR Held Item Right"); vrLeftHeldItemGo.transform.SetParent(vrRigGo.transform, false); vrRightHeldItemGo.transform.SetParent(vrRigGo.transform, false); vrLeftInteractIconGo = BuildInteractIconVisual("VR Interact Icon Left"); vrRightInteractIconGo = BuildInteractIconVisual("VR Interact Icon Right"); vrLeftSecondaryIconGo = BuildInteractIconVisual("VR Secondary Icon Left"); vrRightSecondaryIconGo = BuildInteractIconVisual("VR Secondary Icon Right"); vrLeftInteractIconGo.transform.SetParent(vrRigGo.transform, false); vrRightInteractIconGo.transform.SetParent(vrRigGo.transform, false); vrLeftSecondaryIconGo.transform.SetParent(vrRigGo.transform, false); vrRightSecondaryIconGo.transform.SetParent(vrRigGo.transform, false); vrLeftInteractIconGo.SetActive(false); vrRightInteractIconGo.SetActive(false); vrLeftSecondaryIconGo.SetActive(false); vrRightSecondaryIconGo.SetActive(false); AttachTrackedPoseDriver(vrCameraGo); Logger.LogInfo((object)"VR Camera initialized."); } } private static void BuildHandVisual(GameObject handGo, Color color) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) Shader val = Shader.Find("Standard") ?? Shader.Find("Sprites/Default"); Material val2 = (((Object)(object)val != (Object)null) ? new Material(val) : new Material(Shader.Find("Diffuse"))); val2.color = color; if (val2.HasProperty("_EmissionColor")) { val2.EnableKeyword("_EMISSION"); val2.SetColor("_EmissionColor", color * 0.6f); } GameObject val3 = GameObject.CreatePrimitive((PrimitiveType)0); ((Object)val3).name = "GhostMarker"; val3.transform.SetParent(handGo.transform, false); val3.transform.localScale = Vector3.one * 0.025f; Object.Destroy((Object)(object)val3.GetComponent()); val3.GetComponent().material = val2; } private static GameObject BuildInteractIconVisual(string name) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown GameObject val = new GameObject(name); SpriteRenderer val2 = val.AddComponent(); ((Renderer)val2).sortingOrder = 100; return val; } private void AttachTrackedPoseDriver(GameObject cameraGo) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) TrackedPoseDriver val = cameraGo.AddComponent(); val.trackingType = (TrackingType)1; val.updateType = (UpdateType)2; InputAction val2 = new InputAction("VR Head Rotation", (InputActionType)0, "/centerEyeRotation", (string)null, (string)null, "Quaternion"); val.rotationInput = new InputActionProperty(val2); val2.Enable(); if (Settings.verboseLogging) { Logger.LogInfo((object)($"TrackedPoseDriver attached: trackingType={val.trackingType} updateType={val.updateType} " + $"vSync={QualitySettings.vSyncCount} targetFrameRate={Application.targetFrameRate}")); } } public void RearmStrayCameraSweep() { strayCameraSweepSettled = false; strayCameraCleanScans = 0; lastSeenCameraCount = -1; lastStrayCameraSweepTime = 0f; } private void SuppressStrayStereoCameras() { //IL_00a9: Unknown result type (might be due to invalid IL or missing references) if (!vrInitialized) { return; } int allCamerasCount = Camera.allCamerasCount; if (allCamerasCount != lastSeenCameraCount) { lastSeenCameraCount = allCamerasCount; strayCameraSweepSettled = false; strayCameraCleanScans = 0; } if (strayCameraSweepSettled || Time.unscaledTime - lastStrayCameraSweepTime < 0.25f) { return; } lastStrayCameraSweepTime = Time.unscaledTime; if (strayCameraBuffer.Length < allCamerasCount) { strayCameraBuffer = (Camera[])(object)new Camera[Mathf.NextPowerOfTwo(Mathf.Max(allCamerasCount, 8))]; } Camera.GetAllCameras(strayCameraBuffer); bool flag = false; for (int i = 0; i < allCamerasCount; i++) { Camera val = strayCameraBuffer[i]; if (!((Object)(object)val == (Object)null) && !((Object)(object)val == (Object)(object)vrCamera) && (int)val.stereoTargetEye != 0) { int instanceID = ((Object)val).GetInstanceID(); val.stereoTargetEye = (StereoTargetEyeMask)0; flag = true; } } strayCameraCleanScans = ((!flag) ? (strayCameraCleanScans + 1) : 0); if (strayCameraCleanScans >= 3) { strayCameraSweepSettled = true; } } private void SuppressOverlayCamera() { if (!vrInitialized) { return; } ENT_Player playerObject = ENT_Player.playerObject; if ((Object)(object)playerObject == (Object)null) { return; } Camera overlayCam = playerObject.overlayCam; if (!((Object)(object)overlayCam == (Object)null) && ((Behaviour)overlayCam).enabled) { ((Behaviour)overlayCam).enabled = false; if (suppressedOverlayCamera != overlayCam) { suppressedOverlayCamera = overlayCam; } } } private void SuppressInventoryHandPass() { if (!vrInitialized) { return; } ENT_Player playerObject = ENT_Player.playerObject; if (!((Object)(object)playerObject == (Object)null)) { Camera inventoryCam = playerObject.inventoryCam; if (!((Object)(object)inventoryCam == (Object)null) && inventoryCam.cullingMask != 0) { int cullingMask = inventoryCam.cullingMask; inventoryCam.cullingMask = 0; } } } private void SuppressForeignImageEffects() { if (!vrInitialized || !Settings.suppressForeignImageEffects) { return; } Camera[] allCameras = Camera.allCameras; foreach (Camera val in allCameras) { if ((Object)(object)val == (Object)(object)vrCamera || (Object)(object)val.targetTexture != (Object)null || !suppressedEffectCameraIds.Add(((Object)val).GetInstanceID())) { continue; } Behaviour[] components = ((Component)val).GetComponents(); foreach (Behaviour val2 in components) { if (!(val2 is Camera) && val2.enabled && IsFullScreenImageEffect(val2)) { val2.enabled = false; } } } } private static bool IsFullScreenImageEffect(Behaviour behaviour) { if (!(behaviour is CRTEffect) && !(behaviour is PostProcessLayer)) { return behaviour is PostProcessVolume; } return true; } private IEnumerator InjectVRCamera(bool inGameMain) { yield return (object)new WaitUntil((Func)(() => (Object)(object)Camera.main != (Object)null && ((Behaviour)Camera.main).enabled)); if ((Object)(object)vrCameraGo == (Object)null) { Logger.LogError((object)"InjectVRCamera called before VR camera exists"); yield break; } GameObject vrCam = vrCameraGo; if (inGameMain) { if (Settings.verboseLogging) { Logger.LogInfo((object)"Looking for player"); } clPlayerGo = GameObject.Find("CL_Player"); while ((Object)(object)clPlayerGo == (Object)null) { Logger.LogWarning((object)"Player not found"); yield return null; } leftHandGo = GameObject.Find("Left_Hand_Target"); rightHandGo = GameObject.Find("Right_Hand_Target"); ResetHeadsetMovementBaseline(); if (Settings.verboseLogging) { Logger.LogInfo((object)"Player found"); } } Camera main = Camera.main; GameObject gameObject = ((Component)main).gameObject; mainCamera = main; mainCameraGo = gameObject; CaptureVanillaClearSettings(main); main.stereoTargetEye = (StereoTargetEyeMask)0; gameObject.GetComponent().stereoTargetEye = (StereoTargetEyeMask)0; if (Settings.verboseLogging) { Logger.LogInfo((object)"Duplicating main camera into VR camera"); } if ((Object)(object)vrCam.GetComponent() == (Object)null) { CopyComponent(gameObject.GetComponent(), vrCam); } main.clearFlags = (CameraClearFlags)4; ((Behaviour)gameObject.GetComponent()).enabled = false; DisableIfPresent(gameObject); DisableIfPresent(gameObject); DisableIfPresent(gameObject); if ((Object)(object)gameObject.GetComponent() != (Object)null) { ((Behaviour)gameObject.GetComponent()).enabled = false; } DisableIfPresent(vrCam); DisableIfPresent(vrCam); DisableIfPresent(vrCam); Scene activeScene = SceneManager.GetActiveScene(); bool flag = ((Scene)(ref activeScene)).name == Scenes.MainMenu; if (inGameMain || flag) { baseWorldCullingMask = (inGameMain ? (IncludeHandLayer(ExcludeOverlayLayer(main.cullingMask)) | VRBackpack.LayerMaskForBagContents()) : main.cullingMask); ApplyMergedCullingMask(); } ((Behaviour)main).enabled = true; main.clearFlags = (CameraClearFlags)3; main.cullingMask = 0; main.stereoTargetEye = (StereoTargetEyeMask)0; main.depth = -100f; if (Settings.verboseLogging) { Logger.LogInfo((object)"VR Camera injected!"); } } private void DisableIfPresent(GameObject go) where T : Behaviour { T component = go.GetComponent(); if ((Object)(object)component != (Object)null) { ((Behaviour)component).enabled = false; } } private T CopyComponent(T original, GameObject destination) where T : Component { Type type = ((object)original).GetType(); Component val = destination.AddComponent(type); FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); FieldInfo[] array = fields; foreach (FieldInfo fieldInfo in array) { fieldInfo.SetValue(val, fieldInfo.GetValue(original)); } return (T)(object)val; } private void ClearMainCamera() { mainCamera = null; mainCameraGo = null; } private static bool HasCanvasAncestor(Transform t) { Transform parent = t.parent; while ((Object)(object)parent != (Object)null) { if ((Object)(object)((Component)parent).GetComponent() != (Object)null) { return true; } parent = parent.parent; } return false; } private void TransformSceneCanvasesToWorldSpace() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)vrCamera == (Object)null || (Object)(object)vrRigGo == (Object)null) { return; } Scene activeScene = SceneManager.GetActiveScene(); Canvas[] array = Resources.FindObjectsOfTypeAll(); Canvas[] array2 = array; foreach (Canvas val in array2) { if (!((Object)(object)val == (Object)null)) { Scene scene = ((Component)val).gameObject.scene; if (((Scene)(ref scene)).IsValid() && !(((Component)val).gameObject.scene != activeScene) && !((Object)val).name.Contains("Explorer") && !HasCanvasAncestor(((Component)val).transform) && !(((Object)val).name == "OverlayUIManager")) { ExtractGameUiCanvas(((Component)val).transform); CanvasManager.ConvertCanvasHierarchyToWorldSpace(val, vrRigGo.transform, vrCamera, Logger); convertedCanvasRoots.Add(val); } } } } private void ConvertOverlayUiManagerCanvas() { if (overlayUiManagerConverted || (Object)(object)vrCamera == (Object)null || (Object)(object)vrRigGo == (Object)null) { return; } CL_OverlayUIManager val = CL_OverlayUIManager.instance; if (!((Object)(object)val == (Object)null)) { Canvas component = ((Component)val).GetComponent(); if (!((Object)(object)component == (Object)null)) { CanvasManager.ConvertCanvasHierarchyToWorldSpace(component, vrRigGo.transform, vrCamera, Logger); overlayUiManagerConverted = true; } } } private void ExtractGameUiCanvas(Transform rootCanvasTransform) { //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)vrCamera == (Object)null || (Object)(object)vrCameraGo == (Object)null) { return; } Transform val = rootCanvasTransform.Find("Game UI"); if ((Object)(object)val == (Object)null) { return; } val.SetParent((Transform)null, true); Canvas component = ((Component)val).GetComponent(); bool flag = (Object)(object)component == (Object)null; Canvas val2 = (((Object)(object)component != (Object)null) ? component : ((Component)val).gameObject.AddComponent()); if ((Object)(object)((Component)val).GetComponent() == (Object)null) { ((Component)val).gameObject.AddComponent(); } if (flag) { if (Settings.verboseLogging) { Logger.LogInfo((object)$"Game UI Canvas immediately after AddComponent: renderMode={val2.renderMode}"); } val2.renderMode = (RenderMode)0; } if (Settings.verboseLogging) { Logger.LogInfo((object)"Extracting 'Game UI' to head-locked WorldSpace, sized to match the already-confirmed Pause menu."); } CanvasManager.ConvertCanvasHierarchyToWorldSpace(val2, vrCameraGo.transform, vrCamera, Logger); Transform val3 = val.Find("Crosshairs/InteractHands"); if ((Object)(object)val3 != (Object)null && ((Component)val3).gameObject.activeSelf) { ((Component)val3).gameObject.SetActive(false); } abilityVignettesRoot = val.Find("Ability Vignettes"); if ((Object)(object)abilityVignettesRoot != (Object)null) { ((Component)abilityVignettesRoot).gameObject.SetActive(Settings.vignetteEnabled); abilityVignettesRoot.localScale = Vector3.one * Settings.vignetteScale; } } private void ResetAllVignettesOnDeadToAliveEdge() { if (!((Object)(object)CL_UIManager.instance == (Object)null)) { bool flag = CL_GameManager.isDead(); if (wasPlayerDeadForVignetteReset && !flag) { CL_UIManager.instance.ResetVignettes(); } wasPlayerDeadForVignetteReset = flag; } } private void ClearPlayer() { clPlayerGo = null; leftHandGo = null; rightHandGo = null; VRHandInput.ClearPoseHistory(); VRReach.Clear(); wasGripped[0] = false; wasGripped[1] = false; cachedHandModel[0] = null; cachedHandModel[1] = null; attachedHandItem[0] = null; attachedHandItem[1] = null; ClearHeldItemHolders(); } private IEnumerator OnMainMenu() { yield return (object)new WaitUntil((Func)(() => vrInitialized && (Object)(object)mainCameraGo != (Object)null)); if ((Object)(object)vrRigGo == (Object)null || (Object)(object)mainCameraGo == (Object)null) { Logger.LogError((object)"OnMainMenu ran without VR rig or main camera ready"); yield break; } vrRigGo.transform.SetParent((Transform)null, true); CaptureMenuHeadReference(); EnsureMenuRecenterHook(); TransformSceneCanvasesToWorldSpace(); } private void CaptureMenuHeadReference() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)vrRigGo == (Object)null) && !((Object)(object)mainCameraGo == (Object)null)) { vrRigGo.transform.position = mainCameraGo.transform.position; float num = MathUtils.RotationAroundAxis(mainCameraGo.transform.rotation, Vector3.up); vrRigGo.transform.rotation = Quaternion.AngleAxis(num, Vector3.up); InputDevice deviceAtXRNode = InputDevices.GetDeviceAtXRNode((XRNode)3); Vector3 val = default(Vector3); if (((InputDevice)(ref deviceAtXRNode)).TryGetFeatureValue(CommonUsages.devicePosition, ref val)) { menuHeadPositionReference = val; menuHeadReferenceCaptured = true; } else { menuHeadReferenceCaptured = false; } } } private void EnsureMenuRecenterHook() { if (hookedMenuRecenter) { return; } List list = new List(); SubsystemManager.GetInstances(list); foreach (XRInputSubsystem item in list) { item.trackingOriginUpdated -= OnMenuTrackingOriginUpdated; item.trackingOriginUpdated += OnMenuTrackingOriginUpdated; hookedMenuRecenter = true; } } private void OnMenuTrackingOriginUpdated(XRInputSubsystem subsystem) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) Scene activeScene = SceneManager.GetActiveScene(); if (!(((Scene)(ref activeScene)).name != Scenes.MainMenu)) { CaptureMenuHeadReference(); } } private void OnGameMain() { TransformSceneCanvasesToWorldSpace(); VRPauseMenuTab.InjectAllInScene(Logger); } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { VRVignetteOverlay.HideVanillaVignetteImagesNow(); if (Settings.verboseLogging) { ShaderPatcher.LogShaderCensus(Logger); } VRShimmer.FlattenSpatialPhase(Logger); CacheMenuCanvasGroups(); DisableForeignEventSystems(); bool flag = ((Scene)(ref scene)).name == Scenes.GameMain || ((Scene)(ref scene)).name == Scenes.Playground; ResetLocomotionYaw(); ((MonoBehaviour)this).StartCoroutine(InjectVRCamera(flag)); if (flag) { if (!vrInitialized) { Logger.LogError((object)"Main game accessed without initializing VR!"); } else { OnGameMain(); } } else if (((Scene)(ref scene)).name == Scenes.MainMenu) { ClearPlayer(); ((MonoBehaviour)this).StartCoroutine(OnMainMenu()); } } private void OnSceneUnloaded(Scene scene) { forcedVisibleMenuCanvasGroups.Clear(); VRMenuSelection.ClearSliderEngagement(); ClearMainCamera(); ClearPlayer(); VRBackpack.Reset(); VRHandSwapGesture.Reset(); VRPhysicalCrouch.Reset(); hasStandingCamTarget = false; VRTerminalView.Reset(); VRThrowGesture.Reset(); VRHandCollision.Reset(); VRPlayerBody.Reset(); VRDeathEffects.Reset(); VRCameraFade.Reset(); VRVignetteOverlay.Reset(); ResetLocomotionYaw(); RearmStrayCameraSweep(); menuWasVisible = false; menuCanvasGroupCacheDirty = true; menuCanvasGroupCleanScans = 0; menuCanvasGroups.Clear(); VRPauseMenuTab.PauseMenuRoot = null; menuHeadReferenceCaptured = false; abilityVignettesRoot = null; foreach (Canvas convertedCanvasRoot in convertedCanvasRoots) { if ((Object)(object)convertedCanvasRoot != (Object)null) { Object.Destroy((Object)(object)((Component)convertedCanvasRoot).gameObject); } } convertedCanvasRoots.Clear(); } private void Update() { if (!vrInitialized) { SuppressStereoCameras(); return; } ConvertOverlayUiManagerCanvas(); if (Keyboard.current != null && ((ButtonControl)Keyboard.current.f7Key).wasPressedThisFrame) { DisableForeignEventSystems(); } UpdateCanonicalHeadRotation(); if (MotionControlsActive) { VRControllerProfile.Refresh(Logger); VRHandInput.Advance(); VRMenuHold.Advance(); VRBackpack.Advance(); VRHandSwapGesture.Advance(); VRPhysicalCrouch.Advance(); VRThrowGesture.Advance(); VRPocketDrop.Advance(); VRHandButtons.Sync(); ApplyVrFireButtons(); ApplyVrThrowButtons(); VRVirtualGamepad.Ensure(Logger); VRVirtualGamepad.Submit(); } VRPlayerBody.Advance(); VRDeathEffects.Advance(vrCamera); VRCameraFade.Advance(vrCamera); VRVignetteOverlay.Advance(vrCamera); UpdateLocomotionYaw(); RecentreMenusWhenPauseOpens(); FollowMenusWithLookYaw(); SuppressStrayStereoCameras(); SuppressOverlayCamera(); SuppressInventoryHandPass(); SuppressForeignImageEffects(); RefreshMenuCanvasGroupsPeriodically(); SyncMenuCanvasGroupVisibility(); ResetAllVignettesOnDeadToAliveEdge(); ApplyMergedCullingMask(); } private void DebounceSnapTurn(float stickX) { if (Mathf.Abs(stickX) < 0.5f) { snapTurnReady = true; } else if (snapTurnReady) { locomotionYaw += Mathf.Sign(stickX) * Settings.snapTurnAngle; snapTurnReady = false; } } public static void RecordFixedPlayerPosition(Vector3 position) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) previousFixedPlayerPosition = currentFixedPlayerPosition; currentFixedPlayerPosition = position; hasFixedPlayerPositionSample = true; } private static Vector3 GetInterpolatedPlayerPosition(Vector3 fallback) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) if (!hasFixedPlayerPositionSample) { return fallback; } float num = ((Time.fixedDeltaTime > 0f) ? Mathf.Clamp01((Time.time - Time.fixedTime) / Time.fixedDeltaTime) : 1f); return Vector3.Lerp(previousFixedPlayerPosition, currentFixedPlayerPosition, num); } public static void ResetHeadsetMovementBaseline() { hasFixedHeadPlayspaceSample = false; stickSpeedLastTick = 0f; } public static void RecordStickSpeed(float stickSpeed) { stickSpeedLastTick = stickSpeed; observedMaxMovementSpeed = Mathf.Max(observedMaxMovementSpeed, stickSpeed); } public static void ApplyHeadsetPositionalMovement(ENT_Player player) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) if (!vrInitialized || (Object)(object)instance == (Object)null || (Object)(object)instance.vrRigGo == (Object)null || player.IsMoveLocked()) { return; } InputDevice deviceAtXRNode = InputDevices.GetDeviceAtXRNode((XRNode)3); Vector3 val = default(Vector3); if (!((InputDevice)(ref deviceAtXRNode)).TryGetFeatureValue(CommonUsages.devicePosition, ref val)) { return; } if (!hasFixedHeadPlayspaceSample) { previousFixedHeadPlayspacePosition = val; hasFixedHeadPlayspaceSample = true; return; } Vector3 val2 = val - previousFixedHeadPlayspacePosition; previousFixedHeadPlayspacePosition = val; val2.y = 0f; if (((Vector3)(ref val2)).sqrMagnitude < 1E-08f) { return; } Vector3 val3 = instance.vrRigGo.transform.rotation * val2; float num = Mathf.Max(Settings.maxCombinedPlayspaceSpeed, observedMaxMovementSpeed); float num2 = Mathf.Max(0f, num - stickSpeedLastTick); float num3 = num2 * Time.fixedDeltaTime; Vector3 val4 = Vector3.ClampMagnitude(val3, num3); if (!(((Vector3)(ref val4)).sqrMagnitude < 1E-08f)) { if (player.cCon.isGrounded) { val4.y = (0f - player.cCon.skinWidth) * 2f; } player.cCon.Move(val4); } } private void PinCameraTargetToStandingHeight() { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) if (!Settings.physicalCrouchEnabled) { return; } ENT_Player playerObject = ENT_Player.playerObject; if ((Object)(object)playerObject == (Object)null || (Object)(object)playerObject.mainCamTarget == (Object)null) { return; } Transform mainCamTarget = playerObject.mainCamTarget; if (!hasStandingCamTarget) { standingCamTargetLocalPosition = mainCamTarget.localPosition; hasStandingCamTarget = true; } else if (!(mainCamTarget.localPosition == standingCamTargetLocalPosition)) { if (!loggedCamTargetCorrection) { loggedCamTargetCorrection = true; Logger.LogWarning((object)("ChangeHeight moved mainCamTarget despite the crouch patch " + $"({mainCamTarget.localPosition} vs {standingCamTargetLocalPosition}); pinning it each frame instead.")); } mainCamTarget.localPosition = standingCamTargetLocalPosition; } } private void LateUpdate() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) if (!vrInitialized) { return; } Quaternion val = ((CanonicalHeadRotationFrame == Time.frameCount) ? CanonicalHeadRotation : lastKnownHeadRotation); Vector3 val2 = Vector3.zero; InputDevice deviceAtXRNode = InputDevices.GetDeviceAtXRNode((XRNode)3); Vector3 val3 = default(Vector3); if (((InputDevice)(ref deviceAtXRNode)).TryGetFeatureValue(CommonUsages.devicePosition, ref val3)) { val2 = val3; } if ((Object)(object)vrRigGo == (Object)null || (Object)(object)vrCameraGo == (Object)null) { return; } if ((Object)(object)clPlayerGo != (Object)null && (Object)(object)clPlayerGo.transform != (Object)null && (Object)(object)mainCameraGo != (Object)null) { Vector3 interpolatedPlayerPosition = GetInterpolatedPlayerPosition(clPlayerGo.transform.position); vrRigGo.transform.position = interpolatedPlayerPosition; vrRigGo.transform.rotation = Quaternion.AngleAxis(locomotionYaw, Vector3.up); mainCameraGo.transform.localRotation = val; float num = 0f; if (MotionControlsActive) { PinCameraTargetToStandingHeight(); VRPhysicalCrouch.RefreshCameraOffset(val2.y); num = VRPhysicalCrouch.CameraHeightOffset; } float num2 = mainCameraGo.transform.position.y - interpolatedPlayerPosition.y; if ((Object)(object)vrCameraOffset != (Object)null) { vrCameraOffset.transform.localPosition = new Vector3(0f, num2 + num, 0f); vrCameraOffset.transform.localRotation = VRLookOffset.PitchRotationFor(val); } vrCameraGo.transform.localPosition = Vector3.zero; if (VRTerminalView.TryGetHeadWorldPosition(vrCameraGo.transform.position, val2, vrRigGo.transform.rotation, out var headWorld)) { vrCameraGo.transform.position = headWorld; } } else if (menuHeadReferenceCaptured) { vrCameraGo.transform.localPosition = val2 - menuHeadPositionReference + new Vector3(0f, 0.45f, 0f); } if (MotionControlsActive) { Quaternion rigRotation = (((Object)(object)vrCameraOffset != (Object)null) ? vrCameraOffset.transform.rotation : vrRigGo.transform.rotation); VRHandInput.RefreshWorldPoses(vrCameraGo.transform.position, val2, rigRotation, vrRigGo.transform.rotation); VRHandCollision.Solve(vrCameraGo.transform.position); ApplyVrHandTransforms(); UpdateVrLaserPointers(); UpdateVrInteractIndicators(); UpdateBagPlacementMarkers(); } } private void UpdateVrLaserPointers() { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)vrRigGo == (Object)null) { return; } Color color = default(Color); ((Color)(ref color))..ctor(1f, 1f, 1f, 0.7f); if (leftLaser == null) { leftLaser = new VRLaserPointer(VRHandInput.Left, vrRigGo.transform, color); } if (rightLaser == null) { rightLaser = new VRLaserPointer(VRHandInput.Right, vrRigGo.transform, color); } if (!MenuOpen) { leftLaser.SetVisible(visible: false); rightLaser.SetVisible(visible: false); return; } List raycasters = Resources.FindObjectsOfTypeAll().Where(delegate(GraphicRaycaster r) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) Scene scene = ((Component)r).gameObject.scene; return ((Scene)(ref scene)).IsValid(); }).ToList(); try { leftLaser.UpdateFrame(raycasters, Settings.laserPitchOffsetDegrees); rightLaser.UpdateFrame(raycasters, Settings.laserPitchOffsetDegrees); } catch (Exception arg) { Logger.LogError((object)$"[laser] UpdateFrame threw, disabling for this frame: {arg}"); } } private void ApplyVrFireButtons() { ENT_Player playerObject = ENT_Player.playerObject; if ((Object)(object)playerObject == (Object)null) { return; } bool isOpen = VRBackpack.IsOpen; for (int i = 0; i < playerObject.hands.Length && i < VRHandInput.Hands.Length; i++) { Hand val = playerObject.hands[i]; if (!IsHandGripped(val)) { val.fireButton = ResolveFireButton(i, val, isOpen); } } } private static bool AllowsGripGrabWhileHeld(HandItem handItem) { string text = ((handItem.item != null && !string.IsNullOrEmpty(handItem.item.itemName)) ? handItem.item.itemName : ((Object)handItem).name); string[] gripGrabsWhileHeldItemNameContains = GripGrabsWhileHeldItemNameContains; foreach (string value in gripGrabsWhileHeldItemNameContains) { if (text.IndexOf(value, StringComparison.OrdinalIgnoreCase) >= 0) { return true; } } return false; } private static string ResolveFireButton(int handId, Hand gameHand, bool bagOpen) { if (bagOpen) { return VRHandButtons.UseName(handId); } HandItem handItem = gameHand.GetHandItem(); if ((Object)(object)handItem != (Object)null && !AllowsGripGrabWhileHeld(handItem)) { return VRHandButtons.UseName(handId); } if (ENT_Player_Hand_Patch.GripIsSecondInput()) { VRHand vRHand = VRHandInput.ForHandId(handId); if (!vRHand.Grip.Pressed && !vRHand.Grip.Down) { return VRHandButtons.UseName(handId); } return VRHandButtons.GrabName(handId); } if (!VRReach.HasLastCastHit[handId] || VRReach.LastCastHitIsHandhold[handId]) { return VRHandButtons.GrabName(handId); } return VRHandButtons.UseName(handId); } private void ApplyVrThrowButtons() { ENT_Player playerObject = ENT_Player.playerObject; if ((Object)(object)playerObject == (Object)null) { return; } for (int i = 0; i < playerObject.hands.Length && i < VRHandInput.Hands.Length; i++) { Hand val = playerObject.hands[i]; string text = VRHandButtons.DropName(i); if (val.throwButton != text) { val.throwButton = text; } } } private static bool IsHandGripped(Hand gameHand) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (VRHandState.IsInteractAlive(gameHand.currentInteract)) { return VRHandState.IsGrippingState(gameHand.interactState); } return false; } private void ApplyVrHandTransforms() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) ENT_Player playerObject = ENT_Player.playerObject; if ((Object)(object)vrCameraGo == (Object)null || (Object)(object)vrRigGo == (Object)null) { return; } Vector3 position = vrCameraGo.transform.position; Transform val = (((Object)(object)playerObject != (Object)null) ? ((Component)playerObject).transform : null); Vector3 val2 = (((Object)(object)val != (Object)null) ? val.up : vrRigGo.transform.up); for (int i = 0; i < VRHandInput.Hands.Length; i++) { GameObject val3 = ((i == 0) ? vrLeftHandGo : vrRightHandGo); if ((Object)(object)val3 == (Object)null) { continue; } VRHand vRHand = VRHandInput.Hands[i]; if (!vRHand.IsTracked) { val3.SetActive(false); GetItemAimBeam(i)?.SetVisible(visible: false); continue; } Hand val4 = (((Object)(object)playerObject != (Object)null && i < playerObject.hands.Length) ? playerObject.hands[i] : null); bool flag = val4 != null && IsHandGripped(val4); val3.SetActive(flag); val3.transform.position = VRHandCollision.SolvedPosition(i); val3.transform.rotation = vRHand.WorldRotation; if (val4 == null || (Object)(object)val4.handModel == (Object)null) { GetItemAimBeam(i)?.SetVisible(visible: false); continue; } val4.handModel.localScale = Vector3.one * Settings.defaultHandScale * Settings.vrHandScale; if (flag && !wasGripped[i] && VRReach.HasLastCastHit[i]) { handGrabNormal[i] = VRReach.LastCastHitNormal[i]; } wasGripped[i] = flag; Vector3 val5; if (flag && VRHandState.IsInteractAlive(val4.currentInteract)) { Transform transform = val4.currentInteract.GetGameObject().transform; val5 = transform.TransformPoint(val4.holdPosition) + handGrabNormal[i] * Settings.handSurfaceOffset; } else { val5 = vRHand.WorldPosition; } bool flag2 = (Object)(object)val4.GetHandItem() != (Object)null; SetHandModelVisible(i, val4.handModel, !flag2); if (flag2) { ApplyVrHeldItemTransform(i, val4, vRHand, val5, val2, position); continue; } Vector3 val6 = val5 - position; if (((Vector3)(ref val6)).sqrMagnitude > 0.0001f) { val4.handModel.rotation = Quaternion.LookRotation(val6, val2); } val4.handModel.position = val5; GetItemAimBeam(i)?.SetVisible(visible: false); } } private void SetHandModelVisible(int handId, Transform handModel, bool visible) { if (cachedHandModel[handId] != handModel) { cachedHandModel[handId] = handModel; handModelRenderers[handId] = ((Component)handModel).GetComponentsInChildren(true); } Renderer[] array = handModelRenderers[handId]; if (array != null) { Renderer[] array2 = array; foreach (Renderer val in array2) { val.enabled = visible; } } } private void ApplyVrHeldItemTransform(int handId, Hand gameHand, VRHand hand, Vector3 anchorPos, Vector3 bodyUp, Vector3 headWorld) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) HandItem handItem = gameHand.GetHandItem(); if ((Object)(object)handItem == (Object)null) { return; } AttachHeldItemToHolder(handId, handItem, gameHand); Transform val = HeldItemHolder(handId); if (!((Object)(object)val == (Object)null) && !((Object)(object)vrRigGo == (Object)null)) { Transform transform = vrRigGo.transform; val.localPosition = transform.InverseTransformPoint(anchorPos); Vector3 val2 = anchorPos - headWorld; if (((Vector3)(ref val2)).sqrMagnitude > 0.0001f) { val.localRotation = Quaternion.Inverse(transform.rotation) * Quaternion.LookRotation(val2, bodyUp); } ((Component)handItem).transform.localPosition = Vector3.zero; ((Component)handItem).transform.localRotation = Quaternion.identity; ((Component)handItem).transform.localScale = HeldItemScaleForHand(handId); Vector3 origin; Vector3 direction2; Vector3 direction = (VRAimRay.TryGetHandRay(gameHand.id, out origin, out direction2) ? direction2 : (hand.WorldRotation * Vector3.forward)); GetItemAimBeam(handId)?.UpdateFrame(hand.WorldPosition, direction); } } private Vector3 HeldItemScaleForHand(int handId) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) Transform val = HeldItemHolder(handId); float num = (((Object)(object)val != (Object)null) ? val.lossyScale.y : 1f); if (num < 1E-06f) { num = 1f; } return attachedHandItemVanillaLocalScale[handId] * (attachedHandItemVanillaToVrScale[handId] * Settings.heldItemScale / num); } private VRItemAimBeam? GetItemAimBeam(int handId) { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)vrRigGo == (Object)null) { return null; } Color color = default(Color); ((Color)(ref color))..ctor(1f, 0.55f, 0.1f, 0.7f); if (handId == 0) { return leftItemAimBeam ?? (leftItemAimBeam = new VRItemAimBeam(vrRigGo.transform, color)); } return rightItemAimBeam ?? (rightItemAimBeam = new VRItemAimBeam(vrRigGo.transform, color)); } private VRBagPlacementMarker? GetPlacementMarker(int handId) { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)vrRigGo == (Object)null) { return null; } Color color = default(Color); ((Color)(ref color))..ctor(0.35f, 0.9f, 1f, 0.85f); if (handId == 0) { return leftPlacementMarker ?? (leftPlacementMarker = new VRBagPlacementMarker(vrRigGo.transform, color)); } return rightPlacementMarker ?? (rightPlacementMarker = new VRBagPlacementMarker(vrRigGo.transform, color)); } private void UpdateBagPlacementMarkers() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < VRHandInput.Hands.Length; i++) { VRBagPlacementMarker placementMarker = GetPlacementMarker(i); if (placementMarker != null) { VRHand vRHand = VRHandInput.Hands[i]; if (!vRHand.IsTracked || !VRBackpack.TryGetPlacementPoint(i, out var worldPoint, out var planeRotation)) { placementMarker.SetVisible(visible: false); } else { placementMarker.UpdateFrame(worldPoint, planeRotation, Settings.bagPlacementMarkerRadius, vRHand.WorldPosition); } } } } private void ClearHeldItemHolders() { ClearHeldItemHolder(vrLeftHeldItemGo); ClearHeldItemHolder(vrRightHeldItemGo); } private static void ClearHeldItemHolder(GameObject? holder) { if (!((Object)(object)holder == (Object)null)) { for (int num = holder.transform.childCount - 1; num >= 0; num--) { Object.Destroy((Object)(object)((Component)holder.transform.GetChild(num)).gameObject); } } } private Transform? HeldItemHolder(int handId) { GameObject val = ((handId == 0) ? vrLeftHeldItemGo : vrRightHeldItemGo); if (!((Object)(object)val != (Object)null)) { return null; } return val.transform; } private void AttachHeldItemToHolder(int handId, HandItem handItem, Hand gameHand) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) if (attachedHandItem[handId] == handItem) { return; } Transform val = HeldItemHolder(handId); if ((Object)(object)val == (Object)null) { return; } for (int num = val.childCount - 1; num >= 0; num--) { Transform child = val.GetChild(num); if (child != ((Component)handItem).transform) { Object.Destroy((Object)(object)((Component)child).gameObject); } } Vector3 val2 = VanillaHandItemLocalScale(handId, handItem); Transform parent = ((Component)handItem).transform.parent; float num2 = (((Object)(object)parent != (Object)null) ? parent.lossyScale.y : 1f); ((Component)handItem).transform.SetParent(val, false); ((Component)handItem).transform.localPosition = Vector3.zero; ((Component)handItem).transform.localRotation = Quaternion.identity; attachedHandItem[handId] = handItem; attachedHandItemVanillaLocalScale[handId] = val2; ViewSway viewSway = gameHand.GetViewSway(); float num3 = (((Object)(object)viewSway != (Object)null) ? viewSway.scale : 1f); float num4 = Settings.defaultHandScale * Settings.vrHandScale; attachedHandItemVanillaToVrScale[handId] = num2 * ((num3 > 1E-06f) ? (num4 / num3) : num4); } private static Vector3 VanillaHandItemLocalScale(int handId, HandItem handItem) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) HandItem val = ((handItem.item != null) ? handItem.item.handItemAsset : null); Transform val2 = (((Object)(object)val != (Object)null) ? ((Component)val).transform : ((Component)handItem).transform); Vector3 val3 = val2.localScale; ViewSway component = ((Component)val2).GetComponent(); if ((Object)(object)component != (Object)null && component.changeInitialScale) { val3 *= component.scale; } if (handId == 0) { val3.x = 0f - val3.x; } return val3; } private static void HideCenterScreenHud() { CL_UIManager val = CL_UIManager.instance; if (!((Object)(object)val == (Object)null)) { if ((Object)(object)val.crosshair != (Object)null) { ((Behaviour)val.crosshair).enabled = false; } DisableImages(val.interactImages); DisableImages(val.interactOverlays); } } private static void DisableImages(Image[]? images) { if (images == null) { return; } foreach (Image val in images) { if ((Object)(object)val != (Object)null) { ((Behaviour)val).enabled = false; } } } private void UpdateVrInteractIndicators() { //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) HideCenterScreenHud(); ENT_Player playerObject = ENT_Player.playerObject; if ((Object)(object)playerObject == (Object)null || (Object)(object)vrCameraGo == (Object)null || (Object)(object)vrRigGo == (Object)null) { GameObject? obj = vrLeftInteractIconGo; if (obj != null) { obj.SetActive(false); } GameObject? obj2 = vrRightInteractIconGo; if (obj2 != null) { obj2.SetActive(false); } GameObject? obj3 = vrLeftSecondaryIconGo; if (obj3 != null) { obj3.SetActive(false); } GameObject? obj4 = vrRightSecondaryIconGo; if (obj4 != null) { obj4.SetActive(false); } return; } Vector3 position = vrCameraGo.transform.position; bool isOpen = VRBackpack.IsOpen; for (int i = 0; i < VRHandInput.Hands.Length; i++) { GameObject val = ((i == 0) ? vrLeftInteractIconGo : vrRightInteractIconGo); GameObject val2 = ((i == 0) ? vrLeftSecondaryIconGo : vrRightSecondaryIconGo); if ((Object)(object)val == (Object)null) { continue; } Hand val3 = ((i < playerObject.hands.Length) ? playerObject.hands[i] : null); Image val4 = val3?.uiInteract; bool flag = val3 != null && IsHandGripped(val3); bool flag2 = Settings.showInteractIndicators && !flag && (Object)(object)val4 != (Object)null && ((Component)val4).gameObject.activeSelf && (Object)(object)val4.sprite != (Object)null && VRHandInput.Hands[i].IsTracked; Vector3 worldPoint = Vector3.zero; bool flag3 = (isOpen ? VRBackpack.TryGetHoverPoint(i, out worldPoint) : VRReach.HasLastCastHit[i]); if (!isOpen && flag3) { worldPoint = VRReach.LastCastHitPoint[i]; } PlaceInteractIcon(val, flag2 && flag3, ((Object)(object)val4 != (Object)null) ? val4.sprite : null, ((Object)(object)val4 != (Object)null) ? ((Graphic)val4).color : Color.white, worldPoint, position, i); if ((Object)(object)val2 == (Object)null) { continue; } bool flag4 = flag2 && flag3 && !isOpen && Settings.showSecondaryInteractIndicator && VRControllerProfile.DualTargetPaths; Sprite val5 = null; Vector3 hitPoint = Vector3.zero; if (flag4) { if (VRReach.LastCastHitIsHandhold[i] && VRReach.HasItem[i]) { val5 = GetInteractionSprite(playerObject, "hand-point"); hitPoint = VRReach.ItemPoint[i]; } else if (!VRReach.LastCastHitIsHandhold[i] && VRReach.HasHandhold[i]) { val5 = GetInteractionSprite(playerObject, "hand-open"); hitPoint = VRReach.HandholdPoint[i]; } } Color color = (((Object)(object)val4 != (Object)null) ? ((Graphic)val4).color : Color.white); color.a *= Mathf.Clamp01(Settings.secondaryIndicatorAlpha); PlaceInteractIcon(val2, flag4 && (Object)(object)val5 != (Object)null, val5, color, hitPoint, position, i); } } private static Sprite? GetInteractionSprite(ENT_Player player, string key) { if (player.uiSpriteDict == null) { return null; } if (!player.uiSpriteDict.TryGetValue(key, out var value) || value == null) { return null; } return value.sprite; } private void PlaceInteractIcon(GameObject iconGo, bool show, Sprite? sprite, Color color, Vector3 hitPoint, Vector3 headWorld, int handId) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) iconGo.SetActive(show); if (!show || (Object)(object)sprite == (Object)null || (Object)(object)vrRigGo == (Object)null) { return; } SpriteRenderer component = iconGo.GetComponent(); if (!((Object)(object)component == (Object)null)) { component.sprite = sprite; component.color = color; Vector3 val = headWorld - hitPoint; float magnitude = ((Vector3)(ref val)).magnitude; if (!(magnitude < 0.01f)) { iconGo.transform.position = hitPoint + val / magnitude * 0.03f; iconGo.transform.rotation = Quaternion.LookRotation(-val, vrRigGo.transform.up); float num = Mathf.Clamp(magnitude * 0.11f, 0.05f, 0.28f); iconGo.transform.localScale = new Vector3((handId == 0) ? (0f - num) : num, num, num); } } } private void OnDestroy() { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown Logger.LogInfo((object)"VR Mod unloading!"); VRVirtualGamepad.Remove(); ClearPlayer(); SceneManager.sceneLoaded -= OnSceneLoaded; SceneManager.sceneUnloaded -= OnSceneUnloaded; Camera.onPreCull = (CameraCallback)Delegate.Remove((Delegate?)(object)Camera.onPreCull, (Delegate?)new CameraCallback(ApplyFreshestHeadRotation)); } } internal static class ShaderPatcher { private const string BundleFileName = "wkvr_patched_shaders"; private static readonly string[] PatchedShaderAssetNames = new string[6] { "SHDR_Base", "SHDR_Base_FixedTransparency", "SHDR_Base_Inventory", "SHDR_Outline", "SHDR_SoftEffect", "SHDR_WaterShader" }; private static AssetBundle? loadedBundle; private static readonly Dictionary PatchedShadersByName = new Dictionary(); private static readonly HashSet CensusReportedShaders = new HashSet(); public static bool BundleLoaded => (Object)(object)loadedBundle != (Object)null; public static bool TryLoadBundle(ManualLogSource logger) { if ((Object)(object)loadedBundle != (Object)null) { return true; } string text = Path.Combine(Paths.PluginPath, "wkvr_patched_shaders"); if (!File.Exists(text)) { logger.LogWarning((object)("Patched shader bundle not found at " + text + " - SinglePassInstanced stays unavailable. Build it via Tools/ShaderBundleProject and drop the file next to the mod DLL.")); return false; } loadedBundle = AssetBundle.LoadFromFile(text); if ((Object)(object)loadedBundle == (Object)null) { logger.LogError((object)("Failed to load patched shader bundle from " + text + " - it may be built for a different Unity version.")); return false; } string[] patchedShaderAssetNames = PatchedShaderAssetNames; foreach (string text2 in patchedShaderAssetNames) { Shader val = loadedBundle.LoadAsset(text2); if ((Object)(object)val == (Object)null) { logger.LogError((object)("Patched shader bundle is missing '" + text2 + "' - SinglePassInstanced stays unavailable.")); loadedBundle.Unload(true); loadedBundle = null; PatchedShadersByName.Clear(); return false; } PatchedShadersByName[((Object)val).name] = val; } logger.LogInfo((object)$"Loaded {PatchedShadersByName.Count} patched shaders from {text}."); return true; } public static void LogShaderCensus(ManualLogSource logger) { Dictionary dictionary = new Dictionary(); Material[] array = Resources.FindObjectsOfTypeAll(); foreach (Material val in array) { if (!((Object)(object)val == (Object)null) && !((Object)(object)val.shader == (Object)null)) { string name = ((Object)val.shader).name; dictionary.TryGetValue(name, out var value); dictionary[name] = value + 1; } } List> list = (from entry in dictionary where !CensusReportedShaders.Contains(entry.Key) orderby entry.Value descending select entry).ToList(); if (list.Count == 0) { return; } int num = 0; foreach (KeyValuePair item in list) { CensusReportedShaders.Add(item.Key); bool flag = PatchedShadersByName.ContainsKey(item.Key); if (flag) { num++; } logger.LogInfo((object)string.Format("[shader-census] {0} {1,5} material(s) {2}", flag ? "COVERED " : "UNCOVERED", item.Value, item.Key)); } logger.LogInfo((object)($"[shader-census] {list.Count} newly-seen shader(s): {num} covered by our bundle, {list.Count - num} not. " + $"{CensusReportedShaders.Count} distinct shader(s) seen so far.")); } public static int PatchLoadedMaterials(ManualLogSource logger) { if ((Object)(object)loadedBundle == (Object)null) { return 0; } int num = 0; Material[] array = Resources.FindObjectsOfTypeAll(); foreach (Material val in array) { if (!((Object)(object)val == (Object)null) && !((Object)(object)val.shader == (Object)null) && PatchedShadersByName.TryGetValue(((Object)val.shader).name, out Shader value) && (Object)(object)val.shader != (Object)(object)value) { val.shader = value; num++; } } if (num > 0) { logger.LogInfo((object)$"Patched {num} material(s) onto stereo-instanced shaders."); } return num; } } internal static class VRBackpack { private const float ToggleRequestSeconds = 0.25f; private const float ItemShellLocalRadius = 1.6f; private const float PlacementClampFraction = 0.98f; private static bool desiredOpen; private static float desiredOpenExpiry = -1f; private static bool timeDilationApplied; private static float timescaleMultBeforeBag = 1f; private static bool bagPlaced; private static float bagYaw; private static bool bagFollowingLook; private const float BagFollowSettleDegrees = 0.5f; private static Vector3 originalBagScale = Vector3.one; private static float unscaledShellRadius; private static bool bagBaselineCaptured; private static Transform? detachedBag; private static readonly bool[] handReachingIn = new bool[2]; private static readonly bool[] hoverValid = new bool[2]; private static readonly Vector3[] hoverPoint = (Vector3[])(object)new Vector3[2]; private static readonly bool[] placementValid = new bool[2]; private static readonly Vector3[] placementPoint = (Vector3[])(object)new Vector3[2]; private static Quaternion bagPlaneRotation = Quaternion.identity; private static VRCameraSpoof bagAimSpoof; private static int bagAimDepth; private static float lastDiagnosticTime; private static ButtonInput? overriddenInventoryButton; private static bool savedInventoryDown; private static bool savedInventoryUp; private static bool savedInventoryPressed; public static bool IsOpen { get { if ((Object)(object)Inventory.instance != (Object)null) { return Inventory.instance.showingInventory; } return false; } } public static bool HoldToOpenInventory => !VRRenderingPipeline.Settings.toggleInventory; public static void Reset() { desiredOpen = false; desiredOpenExpiry = -1f; bagPlaced = false; bagBaselineCaptured = false; detachedBag = null; bagAimDepth = 0; bagAimSpoof.Dispose(); for (int i = 0; i < handReachingIn.Length; i++) { handReachingIn[i] = false; hoverValid[i] = false; placementValid[i] = false; } timescaleMultBeforeBag = 1f; RestoreTimescale(); } public static void Advance() { if (VRRenderingPipeline.MotionControlsActive && VRRenderingPipeline.vrInitialized) { VRCameraSpoof.LogTransformIdentityOnce(); AdvanceToggleRequest(); SyncTimeDilation(); UpdateReachState(); LogDiagnostics(); } } public static void RequestClose() { if (IsOpen) { desiredOpen = false; desiredOpenExpiry = Time.unscaledTime + 0.25f; } } private static void AdvanceToggleRequest() { bool isOpen = IsOpen; VRHand left = VRHandInput.Left; if (HoldToOpenInventory) { desiredOpen = left.IsTracked && left.Primary.Pressed; desiredOpenExpiry = Time.unscaledTime + 0.25f; } else if (left.IsTracked && left.Primary.Down) { desiredOpen = !isOpen; desiredOpenExpiry = Time.unscaledTime + 0.25f; } else if (Time.unscaledTime > desiredOpenExpiry) { desiredOpen = isOpen; } } public static void BeginInventoryButtonOverride() { overriddenInventoryButton = null; if (VRRenderingPipeline.vrInitialized && !((Object)(object)InputManager.instance == (Object)null) && InputManager.instance.buttons != null && InputManager.instance.buttons.TryGetValue("Inventory", out var value) && value != null) { overriddenInventoryButton = value; savedInventoryDown = value.Down; savedInventoryUp = value.Up; savedInventoryPressed = value.Pressed; bool isOpen = IsOpen; bool flag = desiredOpen != isOpen; if (SettingsManager.settings != null && SettingsManager.settings.toggleInventory) { value.Down = flag; value.Up = false; value.Pressed = flag; } else { value.Down = flag && desiredOpen; value.Up = flag && !desiredOpen; value.Pressed = desiredOpen; } } } public static void EndInventoryButtonOverride() { if (overriddenInventoryButton != null) { overriddenInventoryButton.Down = savedInventoryDown; overriddenInventoryButton.Up = savedInventoryUp; overriddenInventoryButton.Pressed = savedInventoryPressed; overriddenInventoryButton = null; } } private static void SyncTimeDilation() { if (IsOpen) { if (!timeDilationApplied) { timescaleMultBeforeBag = CL_GameManager.timeScaleMult; CL_GameManager.SetTimescaleMult(VRRenderingPipeline.Settings.bagTimeDilation); timeDilationApplied = true; } } else { RestoreTimescale(); } } private static void RestoreTimescale() { if (timeDilationApplied) { timeDilationApplied = false; CL_GameManager.SetTimescaleMult(timescaleMultBeforeBag); } } private static Transform? GetItemRoot() { Inventory instance = Inventory.instance; if ((Object)(object)instance == (Object)null) { return null; } if (!((Object)(object)instance.itemRoot != (Object)null)) { return instance.inventory; } return instance.itemRoot; } private static float GetItemShellRadius(Transform itemRoot) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) Vector3 val = itemRoot.TransformVector(Vector3.forward * 1.6f); return ((Vector3)(ref val)).magnitude; } private static float GetBagReachRadius(Transform itemRoot) { return GetItemShellRadius(itemRoot) * 0.98f; } private static float GetBagDiscRadius(Transform itemRoot) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) Inventory instance = Inventory.instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance.bagRenderer == (Object)null) { return GetItemShellRadius(itemRoot); } Bounds localBounds = ((Renderer)instance.bagRenderer).localBounds; Vector3 extents = ((Bounds)(ref localBounds)).extents; Vector3 lossyScale = ((Component)instance.bagRenderer).transform.lossyScale; return Mathf.Max(extents.x * lossyScale.x, extents.y * lossyScale.y); } private static void ProjectOntoBagPlane(Transform itemRoot, Vector3 worldPoint, out Vector3 inPlane, out float depth) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) Vector3 val = worldPoint - itemRoot.position; depth = Vector3.Dot(val, itemRoot.forward); inPlane = val - itemRoot.forward * depth; } private static void UpdateReachState() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) Transform itemRoot = GetItemRoot(); bool flag = IsOpen && (Object)(object)itemRoot != (Object)null; VRSettings settings = VRRenderingPipeline.Settings; float num = (flag ? GetBagReachRadius(itemRoot) : 0f); ENT_Player playerObject = ENT_Player.playerObject; if (flag) { bagPlaneRotation = itemRoot.rotation; } for (int i = 0; i < handReachingIn.Length; i++) { VRHand vRHand = VRHandInput.Hands[i]; if (!flag || !vRHand.IsTracked) { handReachingIn[i] = false; placementValid[i] = false; continue; } ProjectOntoBagPlane(itemRoot, vRHand.WorldPosition, out var inPlane, out var depth); handReachingIn[i] = ((Vector3)(ref inPlane)).magnitude <= num + settings.bagReachTolerance && Mathf.Abs(depth) <= settings.bagPlaneDepth; bool flag2 = (Object)(object)playerObject != (Object)null && i < playerObject.hands.Length && (Object)(object)playerObject.hands[i].GetHandItem() != (Object)null; placementValid[i] = handReachingIn[i] && flag2 && !bagFollowingLook; if (placementValid[i]) { placementPoint[i] = itemRoot.position + AimAtPlanePoint(itemRoot, inPlane); } } } public static bool TryGetPlacementPoint(int handId, out Vector3 worldPoint, out Quaternion planeRotation) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) worldPoint = placementPoint[handId]; planeRotation = bagPlaneRotation; return placementValid[handId]; } public static void PlaceBag() { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) Inventory instance = Inventory.instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance.inventory == (Object)null) { return; } if (!instance.showingInventory) { bagPlaced = false; return; } Camera vrCamera = VRRenderingPipeline.VrCamera; Transform itemRoot = GetItemRoot(); if ((Object)(object)vrCamera == (Object)null || (Object)(object)itemRoot == (Object)null) { return; } Transform inventory = instance.inventory; DetachBagFromCamera(inventory); if (!bagBaselineCaptured) { originalBagScale = inventory.localScale; unscaledShellRadius = GetItemShellRadius(itemRoot); bagBaselineCaptured = true; } if (!(unscaledShellRadius < 0.0001f)) { Vector3 position = ((Component)vrCamera).transform.position; float headYaw = MathUtils.RotationAroundAxis(((Component)vrCamera).transform.rotation, Vector3.up); if (!bagPlaced) { bagYaw = headYaw; bagPlaced = true; bagFollowingLook = false; } VRSettings settings = VRRenderingPipeline.Settings; if (settings.bagFollowYaw) { AdvanceBagFollow(headYaw, settings); } Quaternion val = (inventory.rotation = Quaternion.AngleAxis(bagYaw, Vector3.up)); inventory.localScale = originalBagScale * (settings.bagShellRadius / unscaledShellRadius); Vector3 val3 = position + val * new Vector3(0f, settings.bagVerticalOffset, settings.bagDistance); inventory.position += val3 - itemRoot.position; AlignPouchItemsToEyeLine(itemRoot, position); } } private static void AdvanceBagFollow(float headYaw, VRSettings settings) { float num = Mathf.DeltaAngle(bagYaw, headYaw); float menuFollowYawDeadzoneDegrees = settings.menuFollowYawDeadzoneDegrees; if (Mathf.Abs(num) > menuFollowYawDeadzoneDegrees) { bagFollowingLook = true; } if (bagFollowingLook) { float num2 = headYaw - Mathf.Sign(num) * menuFollowYawDeadzoneDegrees; float num3 = 1f - Mathf.Exp((0f - settings.menuFollowSpeed) * Time.unscaledDeltaTime); bagYaw = Mathf.LerpAngle(bagYaw, num2, num3); if (Mathf.Abs(Mathf.DeltaAngle(bagYaw, num2)) < 0.5f) { bagFollowingLook = false; } } } private static void AlignPouchItemsToEyeLine(Transform itemRoot, Vector3 headWorld) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) Inventory instance = Inventory.instance; if ((Object)(object)instance == (Object)null || instance.pouches == null) { return; } Vector3 eyeLocal = itemRoot.InverseTransformPoint(headWorld); foreach (Pouch pouch in instance.pouches) { if (pouch == null || (Object)(object)pouch.pouchVisual == (Object)null || pouch.pouchItems == null || pouch.pouchItems.Count == 0) { continue; } Item val = pouch.pouchItems[0]; if (val == null) { continue; } Item_Object dropObject = val.GetDropObject(true); if (!((Object)(object)dropObject == (Object)null) && ((Component)dropObject).gameObject.activeInHierarchy) { Vector3 localPosition = ((Component)pouch.pouchVisual).transform.localPosition; if (TryProjectShellPointAlongEyeLine(eyeLocal, localPosition, out var shellLocal)) { ((Component)dropObject).transform.localPosition = shellLocal; } } } } private static bool TryProjectShellPointAlongEyeLine(Vector3 eyeLocal, Vector3 throughLocal, out Vector3 shellLocal) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) shellLocal = throughLocal; Vector3 val = throughLocal - eyeLocal; if (((Vector3)(ref val)).sqrMagnitude < 1E-08f) { return false; } ((Vector3)(ref val)).Normalize(); float num = Vector3.Dot(eyeLocal, val); float num2 = ((Vector3)(ref eyeLocal)).sqrMagnitude - 2.5600002f; float num3 = num * num - num2; if (num3 < 0f) { return false; } float num4 = 0f - num + Mathf.Sqrt(num3); if (num4 <= 0f) { return false; } shellLocal = eyeLocal + val * num4; return true; } private static void DetachBagFromCamera(Transform bagTransform) { if (detachedBag != bagTransform) { DisableBagLayerCameras(bagTransform); bagTransform.SetParent((Transform)null, true); detachedBag = bagTransform; bagBaselineCaptured = false; bagPlaced = false; } } private static void DisableBagLayerCameras(Transform bagTransform) { int num = LayerMaskForBagContents(); Transform parent = bagTransform.parent; while ((Object)(object)parent != (Object)null) { Camera component = ((Component)parent).GetComponent(); if (!((Object)(object)component == (Object)null) && ((Behaviour)component).enabled && (component.cullingMask & num) != 0) { ((Behaviour)component).enabled = false; } parent = parent.parent; } } public static int LayerMaskForBagContents() { int num = 0; int num2 = LayerMask.NameToLayer("Inventory"); int num3 = LayerMask.NameToLayer("InventoryBackground"); if (num2 >= 0) { num |= 1 << num2; } if (num3 >= 0) { num |= 1 << num3; } return num; } public static void BeginBagAim(int handId) { //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) if (!VRRenderingPipeline.MotionControlsActive) { return; } bagAimDepth++; if (bagAimDepth != 1 || !VRRenderingPipeline.vrInitialized || !IsOpen) { return; } Transform itemRoot = GetItemRoot(); if (!((Object)(object)itemRoot == (Object)null) && handId >= 0 && handId < VRHandInput.Hands.Length) { VRHand vRHand = VRHandInput.Hands[handId]; if (vRHand.IsTracked) { ENT_Player playerObject = ENT_Player.playerObject; bool holdingItem = (Object)(object)playerObject != (Object)null && handId < playerObject.hands.Length && (Object)(object)playerObject.hands[handId].GetHandItem() != (Object)null; Vector3 forward = ResolveBagAim(itemRoot, vRHand, handId, holdingItem); bagAimSpoof = VRCameraSpoof.LookFrom(itemRoot.position, forward, itemRoot.up); } } } public static bool TryGetHoverPoint(int handId, out Vector3 worldPoint) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) worldPoint = hoverPoint[handId]; return hoverValid[handId]; } private static Vector3 ResolveBagAim(Transform itemRoot, VRHand hand, int handId, bool holdingItem) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) hoverValid[handId] = false; if (!handReachingIn[handId]) { return AimIntoEmptyRearHemisphere(itemRoot); } ProjectOntoBagPlane(itemRoot, hand.WorldPosition, out var inPlane, out var _); if (holdingItem) { return AimAtPlanePoint(itemRoot, inPlane); } if (!TryFindNearestBagItem(itemRoot, inPlane, out var nearestPosition)) { return AimIntoEmptyRearHemisphere(itemRoot); } Vector3 result = nearestPosition - itemRoot.position; if (((Vector3)(ref result)).sqrMagnitude <= 1E-06f) { return AimIntoEmptyRearHemisphere(itemRoot); } hoverValid[handId] = true; hoverPoint[handId] = nearestPosition; return result; } private static Vector3 AimAtPlanePoint(Transform itemRoot, Vector3 inPlane) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) float itemShellRadius = GetItemShellRadius(itemRoot); if (itemShellRadius < 0.0001f) { return itemRoot.forward; } float num = Mathf.Min(((Vector3)(ref inPlane)).magnitude, itemShellRadius * 0.98f); if (num < 0.0001f) { return itemRoot.forward; } float num2 = Mathf.Sqrt(itemShellRadius * itemShellRadius - num * num); return ((Vector3)(ref inPlane)).normalized * num + itemRoot.forward * num2; } private static bool TryFindNearestBagItem(Transform itemRoot, Vector3 handInPlane, out Vector3 nearestPosition) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) nearestPosition = Vector3.zero; float num = VRRenderingPipeline.Settings.bagGrabRadius; bool result = false; for (int i = 0; i < itemRoot.childCount; i++) { Transform child = itemRoot.GetChild(i); if (((Component)child).gameObject.activeInHierarchy && !((Object)(object)((Component)child).GetComponent() == (Object)null)) { ProjectOntoBagPlane(itemRoot, child.position, out var inPlane, out var _); float num2 = Vector3.Distance(inPlane, handInPlane); if (!(num2 >= num)) { num = num2; nearestPosition = child.position; result = true; } } } return result; } private static Vector3 AimIntoEmptyRearHemisphere(Transform itemRoot) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) return -itemRoot.forward; } public static void EndBagAim() { bagAimDepth--; if (bagAimDepth <= 0) { bagAimDepth = 0; bagAimSpoof.Dispose(); } } public static void FilterUseButton(int handId, ButtonInput? button) { if (button != null && button.Down && VRRenderingPipeline.vrInitialized && IsOpen && (!handReachingIn[handId] || bagFollowingLook)) { button.Down = false; } } private static void LogDiagnostics() { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) if (VRRenderingPipeline.Settings.verboseLogging && IsOpen && !(Time.unscaledTime - lastDiagnosticTime < 2f)) { lastDiagnosticTime = Time.unscaledTime; Transform itemRoot = GetItemRoot(); Camera vrCamera = VRRenderingPipeline.VrCamera; if (!((Object)(object)itemRoot == (Object)null) && !((Object)(object)vrCamera == (Object)null)) { float itemShellRadius = GetItemShellRadius(itemRoot); float bagDiscRadius = GetBagDiscRadius(itemRoot); float num = Vector3.Distance(((Component)vrCamera).transform.position, itemRoot.position); VRLog.Verbose($"[bag] reachRadius={GetBagReachRadius(itemRoot):0.000}m discRadius={bagDiscRadius:0.000}m " + $"shellRadius={itemShellRadius:0.000}m headToPlane={num:0.000}m " + $"items={itemRoot.childCount} targetShellRadius={VRRenderingPipeline.Settings.bagShellRadius:0.000}m " + $"planeDepth={VRRenderingPipeline.Settings.bagPlaneDepth:0.000}m " + "left=" + FormatHandReach(0, itemRoot) + " right=" + FormatHandReach(1, itemRoot) + " " + $"timescaleMult={CL_GameManager.timeScaleMult:0.00}"); } } } private static string FormatHandReach(int handId, Transform itemRoot) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) VRHand vRHand = VRHandInput.Hands[handId]; if (!vRHand.IsTracked) { return "untracked"; } ProjectOntoBagPlane(itemRoot, vRHand.WorldPosition, out var inPlane, out var depth); Vector3 nearestPosition; string arg = (TryFindNearestBagItem(itemRoot, inPlane, out nearestPosition) ? $"{Vector3.Distance(nearestPosition, vRHand.WorldPosition):0.000}m" : "none"); return $"planeR={((Vector3)(ref inPlane)).magnitude:0.000}m depth={depth:+0.000;-0.000}m item={arg}" + (handReachingIn[handId] ? " IN" : "") + " ray=" + ProbeBagRay(itemRoot, vRHand, handId); } private static string ProbeBagRay(Transform itemRoot, VRHand hand, int handId) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) ENT_Player playerObject = ENT_Player.playerObject; if ((Object)(object)playerObject == (Object)null) { return "noplayer"; } bool holdingItem = handId < playerObject.hands.Length && (Object)(object)playerObject.hands[handId].GetHandItem() != (Object)null; Vector3 val = ResolveBagAim(itemRoot, hand, handId, holdingItem); RaycastHit val2 = default(RaycastHit); if (!Physics.Raycast(itemRoot.position, ((Vector3)(ref val)).normalized, ref val2, playerObject.GetInteractDistance(handId) * 2f, LayerMask.op_Implicit(playerObject.inventoryItemMask))) { return "miss"; } return $"{((Object)((RaycastHit)(ref val2)).collider).name}@{((RaycastHit)(ref val2)).distance:0.000}m"; } } internal class VRBagPlacementMarker { private const int Segments = 28; private readonly LineRenderer ring; private readonly LineRenderer stem; public VRBagPlacementMarker(Transform parent, Color color) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) ring = CreateLine(parent, "VR Bag Placement Ring", color, 29); stem = CreateLine(parent, "VR Bag Placement Stem", new Color(color.r, color.g, color.b, color.a * 0.5f), 2); } private static LineRenderer CreateLine(Transform parent, string name, Color color, int positionCount) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.transform.SetParent(parent, false); LineRenderer val2 = val.AddComponent(); val2.useWorldSpace = true; val2.positionCount = positionCount; val2.widthMultiplier = 0.004f; ((Renderer)val2).receiveShadows = false; ((Renderer)val2).shadowCastingMode = (ShadowCastingMode)0; Shader val3 = Shader.Find("Sprites/Default") ?? Shader.Find("Standard"); Material val4 = new Material(val3); val4.color = color; ((Renderer)val2).material = val4; val2.startColor = color; val2.endColor = color; ((Renderer)val2).enabled = false; return val2; } public void SetVisible(bool visible) { ((Renderer)ring).enabled = visible; ((Renderer)stem).enabled = visible; } public void UpdateFrame(Vector3 centre, Quaternion planeRotation, float radius, Vector3 handPosition) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) Vector3 val = planeRotation * Vector3.right; Vector3 val2 = planeRotation * Vector3.up; for (int i = 0; i <= 28; i++) { float num = (float)i / 28f * (float)Math.PI * 2f; Vector3 val3 = val * (Mathf.Cos(num) * radius) + val2 * (Mathf.Sin(num) * radius); ring.SetPosition(i, centre + val3); } stem.SetPosition(0, handPosition); stem.SetPosition(1, centre); ((Renderer)ring).enabled = true; ((Renderer)stem).enabled = true; } } internal static class VRCameraFade { private const float QuadDistance = 0.02f; private const float QuadHalfExtent = 0.5f; private const int OverlayRenderQueue = 5000; private const float DiagnosticInterval = 2f; private static GameObject? quad; private static MeshRenderer? quadRenderer; private static Material? quadMaterial; private static float currentAlpha; private static float lastDiagnosticTime; public static void Reset() { currentAlpha = 0f; if ((Object)(object)quad != (Object)null) { Object.Destroy((Object)(object)quad); } quad = null; quadRenderer = null; quadMaterial = null; } public static void Advance(Camera? vrCamera) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)vrCamera == (Object)null)) { EnsureQuad(((Component)vrCamera).transform); VRSettings settings = VRRenderingPipeline.Settings; float num = (settings.cameraFadeOnClip ? MeasureClipFade(((Component)vrCamera).transform.position, settings.cameraFadeDistance) : 0f); currentAlpha = Mathf.MoveTowards(currentAlpha, num, settings.cameraFadeSpeed * Time.unscaledDeltaTime); if ((Object)(object)quadRenderer != (Object)null && (Object)(object)quadMaterial != (Object)null) { ((Renderer)quadRenderer).enabled = currentAlpha > 0.001f; Color color = quadMaterial.color; color.a = currentAlpha; quadMaterial.color = color; } } } private static float MeasureClipFade(Vector3 headWorld, float fadeDistance) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) ENT_Player playerObject = ENT_Player.playerObject; if ((Object)(object)playerObject == (Object)null || (Object)(object)playerObject.cCon == (Object)null) { return 0f; } Vector3 val = ((Component)playerObject).transform.position + playerObject.cCon.center; Vector3 val2 = headWorld - val; if (((Vector3)(ref val2)).sqrMagnitude < 0.0001f) { return 0f; } bool queriesHitBackfaces = Physics.queriesHitBackfaces; Physics.queriesHitBackfaces = false; bool flag; RaycastHit hit = default(RaycastHit); try { flag = Physics.Linecast(val, headWorld, ref hit, LayerMask.op_Implicit(playerObject.jumpMask), (QueryTriggerInteraction)1); } finally { Physics.queriesHitBackfaces = queriesHitBackfaces; } if (!flag) { return 0f; } float num = Vector3.Distance(((RaycastHit)(ref hit)).point, headWorld); LogClipDiagnostic(hit, num); return Mathf.Clamp01(num / Mathf.Max(fadeDistance, 0.001f)); } private static void LogClipDiagnostic(RaycastHit hit, float penetration) { if (VRRenderingPipeline.Settings.verboseLogging && !(Time.unscaledTime - lastDiagnosticTime < 2f)) { lastDiagnosticTime = Time.unscaledTime; Collider collider = ((RaycastHit)(ref hit)).collider; VRLog.Verbose(string.Format("[camfade] head behind '{0}' penetration={1:0.000}m alpha={2:0.00}", ((collider != null) ? ((Object)collider).name : null) ?? "null", penetration, currentAlpha)); } } private static void EnsureQuad(Transform cameraTransform) { //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Expected O, but got Unknown //IL_012d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)quad != (Object)null) { if (quad.transform.parent != cameraTransform) { quad.transform.SetParent(cameraTransform, false); } return; } quad = GameObject.CreatePrimitive((PrimitiveType)5); ((Object)quad).name = "VR Camera Fade"; Object.Destroy((Object)(object)quad.GetComponent()); quad.transform.SetParent(cameraTransform, false); quad.transform.localPosition = new Vector3(0f, 0f, 0.02f); quad.transform.localRotation = Quaternion.identity; quad.transform.localScale = Vector3.one * 1f; quadRenderer = quad.GetComponent(); ((Renderer)quadRenderer).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)quadRenderer).receiveShadows = false; ((Renderer)quadRenderer).enabled = false; Shader val = Shader.Find("UI/Default") ?? Shader.Find("Sprites/Default"); quadMaterial = new Material(val); quadMaterial.color = new Color(0f, 0f, 0f, 0f); quadMaterial.renderQueue = 5000; if (quadMaterial.HasProperty("unity_GUIZTestMode")) { quadMaterial.SetInt("unity_GUIZTestMode", 8); } ((Renderer)quadRenderer).material = quadMaterial; } } internal struct VRCameraSpoof : IDisposable { private Transform? target; private Vector3 savedPosition; private Quaternion savedRotation; private Transform? secondaryTarget; private Vector3 savedSecondaryPosition; private Quaternion savedSecondaryRotation; private static bool loggedTransformIdentity; public static Transform? ResolveCameraTransform() { ENT_Player playerObject = ENT_Player.playerObject; if ((Object)(object)playerObject != (Object)null && (Object)(object)playerObject.cam != (Object)null) { return ((Component)playerObject.cam).transform; } Camera mainCamera = VRRenderingPipeline.mainCamera; if (!((Object)(object)mainCamera != (Object)null)) { return null; } return ((Component)mainCamera).transform; } private static Transform? ResolveSceneMainCameraTransform(Transform? primary) { Camera main = Camera.main; if ((Object)(object)main == (Object)null) { return null; } Transform transform = ((Component)main).transform; if (transform != primary) { return transform; } return null; } private static bool IsAncestorOf(Transform candidate, Transform node) { Transform parent = node.parent; while ((Object)(object)parent != (Object)null) { if (parent == candidate) { return true; } parent = parent.parent; } return false; } public static void LogTransformIdentityOnce() { if (loggedTransformIdentity) { return; } ENT_Player playerObject = ENT_Player.playerObject; if ((Object)(object)playerObject == (Object)null || (Object)(object)playerObject.cam == (Object)null) { return; } loggedTransformIdentity = true; Transform transform = ((Component)playerObject.cam).transform; bool flag = transform == playerObject.camTransform; Transform val = ResolveSceneMainCameraTransform(transform); string arg = (((Object)(object)val == (Object)null) ? "single transform covers everything" : ("also spoofing Camera.main '" + ((Object)val).name + "'")); string text = $"[spoof] cam.transform=='{((Object)transform).name}' camTransform match={flag} " + $"Camera.main match={(Object)(object)val == (Object)null} - {arg}"; if (flag) { VRLog.Verbose(text); return; } ManualLogSource? staticLogger = VRRenderingPipeline.StaticLogger; if (staticLogger != null) { staticLogger.LogWarning((object)(text + " - cam.transform and camTransform differ, aim retargeting may be incomplete.")); } } public static VRCameraSpoof Capture() { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) VRCameraSpoof result = default(VRCameraSpoof); Transform val = ResolveCameraTransform(); if ((Object)(object)val == (Object)null) { return result; } Transform val2 = ResolveSceneMainCameraTransform(val); if ((Object)(object)val2 != (Object)null && IsAncestorOf(val2, val)) { result.target = val2; result.secondaryTarget = val; } else { result.target = val; result.secondaryTarget = val2; } result.savedPosition = result.target.position; result.savedRotation = result.target.rotation; if ((Object)(object)result.secondaryTarget != (Object)null) { result.savedSecondaryPosition = result.secondaryTarget.position; result.savedSecondaryRotation = result.secondaryTarget.rotation; } return result; } public static VRCameraSpoof LookFrom(Vector3 position, Vector3 forward, Vector3 upHint) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) VRCameraSpoof result = Capture(); result.Aim(position, forward, upHint); return result; } public static VRCameraSpoof FaceDirection(Vector3 forward, Vector3 upHint) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) VRCameraSpoof result = Capture(); if ((Object)(object)result.target == (Object)null) { return result; } Quaternion rotation = BuildRotation(forward, upHint); result.target.rotation = rotation; if ((Object)(object)result.secondaryTarget != (Object)null) { result.secondaryTarget.rotation = rotation; } return result; } public void Aim(Vector3 position, Vector3 forward) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) Aim(position, forward, Vector3.up); } public void Aim(Vector3 position, Vector3 forward, Vector3 upHint) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)target == (Object)null)) { Quaternion rotation = BuildRotation(forward, upHint); target.position = position; target.rotation = rotation; if (!((Object)(object)secondaryTarget == (Object)null)) { secondaryTarget.position = position; secondaryTarget.rotation = rotation; } } } private static Quaternion BuildRotation(Vector3 forward, Vector3 upHint) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) if (((Vector3)(ref forward)).sqrMagnitude < 1E-08f) { forward = Vector3.forward; } ((Vector3)(ref forward)).Normalize(); if (((Vector3)(ref upHint)).sqrMagnitude < 1E-08f) { upHint = Vector3.up; } if (Mathf.Abs(Vector3.Dot(forward, ((Vector3)(ref upHint)).normalized)) > 0.999f) { upHint = ((Mathf.Abs(forward.y) > 0.999f) ? Vector3.forward : Vector3.up); } return Quaternion.LookRotation(forward, upHint); } public void Dispose() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)target == (Object)null)) { target.position = savedPosition; target.rotation = savedRotation; target = null; if (!((Object)(object)secondaryTarget == (Object)null)) { secondaryTarget.position = savedSecondaryPosition; secondaryTarget.rotation = savedSecondaryRotation; secondaryTarget = null; } } } } internal static class VRAimRay { public static bool TryGetHandRay(int handId, out Vector3 origin, out Vector3 direction) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) origin = Vector3.zero; direction = Vector3.forward; if (handId < 0 || handId >= VRHandInput.Hands.Length) { return false; } VRHand vRHand = VRHandInput.Hands[handId]; if (!vRHand.IsTracked) { return false; } origin = vRHand.WorldPosition; direction = Quaternion.AngleAxis(VRRenderingPipeline.Settings.laserPitchOffsetDegrees, vRHand.Right) * vRHand.Forward; return true; } public static VRCameraSpoof AimFromHandId(int handId) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) if (!VRRenderingPipeline.vrInitialized) { return default(VRCameraSpoof); } if (!TryGetHandRay(handId, out var origin, out var direction)) { return default(VRCameraSpoof); } return VRCameraSpoof.LookFrom(origin, direction, Vector3.up); } public static VRCameraSpoof AimFromHand(HandItem? handItem) { if ((Object)(object)handItem == (Object)null || ((Hand_Base)handItem).hand == null) { return default(VRCameraSpoof); } return AimFromHandId(((Hand_Base)handItem).hand.id); } } internal class VRCanvasOverlaySentinel : MonoBehaviour { private bool registered; public static void Attach(GameObject go) { if ((Object)(object)go.GetComponent() == (Object)null) { go.AddComponent(); } } private void OnEnable() { VROverlayLayerTracker.Register(((Component)this).gameObject.layer); registered = true; } private void OnDisable() { if (registered) { VROverlayLayerTracker.Unregister(((Component)this).gameObject.layer); registered = false; } } } internal static class VRClimbControl { private const float ClimbVelocityLead = 0.05f; private const float ClimbVelocitySampleWindow = 0.06f; private static readonly bool[] wasHanging = new bool[2]; private static Vector3 smoothedIntent = Vector3.zero; private static Vector3 smoothedVerticalIntent = Vector3.zero; private static Vector3 smoothedLateralIntent = Vector3.zero; private static float jumpGestureCooldownTimer; private static float sprintGestureEnergy; private static Vector3 boostDirection = Vector3.zero; private static float boostMagnitude01; private static float boostTimer; private static float boostDuration = 1f; private static float nextDiagnosticTime; public static Vector3 LastClimbIntentDirection { get; private set; } public static bool JoystickClimbActive { get; private set; } public static void RequestLateralBoost(Vector3 worldDirection, float magnitude01, float duration) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) boostDirection = worldDirection; boostMagnitude01 = Mathf.Clamp01(magnitude01); boostDuration = Mathf.Max(0.01f, duration); boostTimer = boostDuration; } public static void Apply(ENT_Player player) { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) if (!VRRenderingPipeline.vrInitialized) { return; } VRHandState.ReleaseStaleHolds(player); VRSettings settings = VRRenderingPipeline.Settings; bool flag = (Object)(object)CL_GameManager.gMan == (Object)null || (!CL_GameManager.gMan.lockPlayer && !CL_GameManager.gMan.freecam && !CL_GameManager.gMan.lockPlayerInput); Vector3 worldIntent; bool flag2 = ComputeClimbIntent(player, settings, flag, out worldIntent); Vector3 val = ConsumeBoostVector(); JoystickClimbActive = flag2 && JoystickDrivesClimb(settings); if (JoystickClimbActive) { LastClimbIntentDirection = Vector3.zero; LogClimbDiagnostics(player, settings, worldIntent, 0f); } else if (flag2) { Vector3 val2 = worldIntent + val; float num = ((Vector3)(ref val2)).magnitude; if (num > 1f) { val2 /= num; num = 1f; } LastClimbIntentDirection = ((num > 0.0001f) ? (val2 / num) : Vector3.zero); InputManager.GetVector("Move").vector = new Vector2(0f, num); LogClimbDiagnostics(player, settings, worldIntent, num); } else { LastClimbIntentDirection = Vector3.zero; if (val != Vector3.zero) { Vector2 vector = default(Vector2); ((Vector2)(ref vector))..ctor(Vector3.Dot(val, ((Component)player).transform.right), Vector3.Dot(val, ((Component)player).transform.forward)); if (((Vector2)(ref vector)).sqrMagnitude > 1f) { ((Vector2)(ref vector)).Normalize(); } InputManager.GetVector("Move").vector = vector; } } if (flag) { if (flag2) { ApplyDyno(player, settings); } else { ApplyGroundGestures(player, settings); } } } public static Vector3 ProjectIntentOffSurface(ENT_Player player, Vector3 intentDirection, Vector3 fallback) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) if (!player.hasHit) { return intentDirection; } Vector3 hitNormal = player.hitNormal; if (((Vector3)(ref hitNormal)).sqrMagnitude < 0.0001f) { return intentDirection; } ((Vector3)(ref hitNormal)).Normalize(); float num = Vector3.Dot(intentDirection, -hitNormal); if (num <= 0f) { return intentDirection; } Vector3 val = intentDirection + hitNormal * num; if (((Vector3)(ref val)).sqrMagnitude < 0.0001f) { return fallback; } return ((Vector3)(ref val)).normalized; } private static bool JoystickDrivesClimb(VRSettings settings) { string climbMode = settings.climbMode; if (!(climbMode == "joystick")) { if (climbMode == "gesture") { return false; } if (VRHandInput.Left.IsTracked) { return ((Vector2)(ref VRHandInput.Left.Stick)).magnitude > settings.climbJoystickDeadzone; } return false; } return true; } private static void LogClimbDiagnostics(ENT_Player player, VRSettings settings, Vector3 climbIntent, float magnitude) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) if (settings.verboseLogging && !(Time.time < nextDiagnosticTime)) { nextDiagnosticTime = Time.time + 0.2f; Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(player.cCon.velocity.x, 0f, player.cCon.velocity.z); string arg = (JoystickClimbActive ? "joystick" : "gesture"); VRLog.Verbose($"[VRClimb] mode={settings.climbMode} driver={arg} stick={((Vector2)(ref VRHandInput.Left.Stick)).magnitude:0.00} " + $"pose={((Vector3)(ref smoothedIntent)).magnitude:0.00}m intent={((Vector3)(ref climbIntent)).magnitude:0.00} move.y={magnitude:0.00} " + $"dir={LastClimbIntentDirection} bodyLateral={((Vector3)(ref val)).magnitude:0.00}m/s"); } } private static Vector3 ConsumeBoostVector() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) if (boostTimer <= 0f) { return Vector3.zero; } float magnitude = ((Vector2)(ref VRHandInput.Left.Stick)).magnitude; if (magnitude > VRRenderingPipeline.Settings.dynoStickCancelDeadzone) { boostTimer = 0f; return Vector3.zero; } boostTimer -= Time.fixedDeltaTime; float num = boostMagnitude01 * Mathf.Clamp01(boostTimer / boostDuration); if (num <= 0.001f) { return Vector3.zero; } return boostDirection * num; } private static Vector3 HandPoseOffset(Vector3 headWorld, VRHand vrHand, int handId, VRSettings settings) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) float num = ((handId == 0) ? (-1f) : 1f); Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(num * settings.shoulderHalfWidth, 0f - settings.shoulderDrop, settings.climbNeutralForward); Quaternion rigRotation = vrHand.RigRotation; Vector3 val2 = Quaternion.Inverse(rigRotation) * (vrHand.WorldPosition - headWorld); Vector3 val3 = val2 - val; val3.x *= settings.climbPoseFullOffset / settings.climbPoseLateralFullOffset; val3.z *= settings.climbPoseFullOffset / settings.climbPoseDepthFullOffset; return rigRotation * val3; } private static float SmoothingAlpha(float smoothingSeconds) { float num = Mathf.Max(0.001f, smoothingSeconds); return 1f - Mathf.Exp((0f - Time.fixedDeltaTime) / num); } private static bool ComputeClimbIntent(ENT_Player player, VRSettings settings, bool inputAllowed, out Vector3 worldIntent) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Invalid comparison between Unknown and I4 //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) worldIntent = Vector3.zero; Camera vrCamera = VRRenderingPipeline.VrCamera; Vector3 headWorld = (((Object)(object)vrCamera != (Object)null) ? ((Component)vrCamera).transform.position : ((Component)player).transform.position); Vector3 val = Vector3.zero; float num = 0f; bool flag = false; for (int i = 0; i < 2; i++) { Hand val2 = player.hands[i]; bool flag2 = inputAllowed && (int)val2.interactState == 4 && VRHandState.IsInteractAlive(val2.currentInteract); VRHand vRHand = VRHandInput.ForHandId(i); if (flag2 && !wasHanging[i]) { val2.holdTime = Mathf.Max(val2.holdTime, settings.climbGripRampBoost); } wasHanging[i] = flag2; VRDyno.TrackHand(i, flag2, settings); if (flag2) { flag = true; Vector3 val3 = HandPoseOffset(headWorld, vRHand, i, settings); val3 += vRHand.GetPhysicalVelocity(0.06f) * 0.05f; float num2 = Mathf.Pow(((Vector3)(ref val3)).magnitude, settings.climbHandWeightBias); val += val3 * num2; num += num2; } } if (!flag) { smoothedIntent = Vector3.zero; smoothedVerticalIntent = Vector3.zero; smoothedLateralIntent = Vector3.zero; return false; } Vector3 val4 = ((num > 0.0001f) ? (-val / num) : Vector3.zero); Vector3 val5 = default(Vector3); ((Vector3)(ref val5))..ctor(0f, val4.y, 0f); Vector3 val6 = val4 - val5; smoothedVerticalIntent = Vector3.Lerp(smoothedVerticalIntent, val5, SmoothingAlpha(settings.climbIntentSmoothing)); smoothedLateralIntent = Vector3.Lerp(smoothedLateralIntent, val6, SmoothingAlpha(settings.climbLateralSmoothing)); smoothedIntent = smoothedVerticalIntent + smoothedLateralIntent; float magnitude = ((Vector3)(ref smoothedIntent)).magnitude; float climbPoseDeadzone = settings.climbPoseDeadzone; float num3 = Mathf.Max(climbPoseDeadzone + 0.01f, settings.climbPoseFullOffset); float num4 = Mathf.Clamp01((magnitude - climbPoseDeadzone) / (num3 - climbPoseDeadzone)); if (num4 > 0f && magnitude > 0.0001f) { Vector3 val7 = smoothedIntent / magnitude; if (!settings.climbAllowLateralIntent) { Vector3 normalized = ((Vector3)(ref player.climbDir)).normalized; val7 = normalized * Vector3.Dot(val7, normalized); } worldIntent = val7 * num4; } return true; } private static void ApplyDyno(ENT_Player player, VRSettings settings) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) jumpGestureCooldownTimer = settings.gestureJumpCooldown; sprintGestureEnergy = 0f; if (VRDyno.ShouldFire(settings, out var velocity)) { VRDyno.Consume(); Launch(settings, velocity, allowJump: true); } } public static void Launch(VRSettings settings, Vector3 handVelocity, bool allowJump) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) Vector3 val = -handVelocity; float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude < 0.0001f) { return; } float y = val.y; Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(val.x, 0f, val.z); float magnitude2 = ((Vector3)(ref val2)).magnitude; bool flag = y > 0f; VRLog.Verbose($"[VRDyno] launch speed={magnitude:0.00} up={y:0.00} lateral={magnitude2:0.00} " + $"upRatio={y / magnitude:0.00} allowJump={allowJump} jumping={allowJump && flag}"); if (allowJump && flag) { ButtonInput button = InputManager.GetButton("Jump"); button.Pressed = true; button.Down = true; } if (!(magnitude2 <= 0.05f)) { float num = Mathf.Atan2(magnitude2, Mathf.Abs(y)) * 57.29578f; float num2 = Mathf.Max(0.01f, settings.dynoLateralMaxAngle - settings.dynoLateralMinAngle); float num3 = Mathf.Clamp01((num - settings.dynoLateralMinAngle) / num2); VRLog.Verbose($"[VRDyno] lateral angle={num:0.0}deg ramp={num3:0.00} " + $"({settings.dynoLateralMinAngle:0}deg..{settings.dynoLateralMaxAngle:0}deg)"); if (!(num3 <= 0f)) { RequestLateralBoost(val2 / magnitude2, num3 * settings.dynoForceGain, settings.dynoBoostDuration); } } } private static void ApplyGroundGestures(ENT_Player player, VRSettings settings) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) float gestureVelocityWindow = settings.gestureVelocityWindow; float y = VRHandInput.Left.GetPhysicalVelocity(gestureVelocityWindow).y; float y2 = VRHandInput.Right.GetPhysicalVelocity(gestureVelocityWindow).y; bool flag = player.IsGrounded(true) || player.extraJumpsRemaining > 0 || player.temporaryExtraJumpsRemaining > 0; jumpGestureCooldownTimer -= Time.fixedDeltaTime; if (settings.gestureJumpEnabled && flag && jumpGestureCooldownTimer <= 0f && y > settings.gestureJumpVelocityThreshold && y2 > settings.gestureJumpVelocityThreshold) { ButtonInput button = InputManager.GetButton("Jump"); button.Pressed = true; button.Down = true; jumpGestureCooldownTimer = settings.gestureJumpCooldown; } float num = ((y * y2 < 0f && Mathf.Abs(y) > settings.gestureSprintVelocityThreshold && Mathf.Abs(y2) > settings.gestureSprintVelocityThreshold) ? (1f / Mathf.Max(0.01f, settings.gestureSprintEngageSeconds)) : (-1f / Mathf.Max(0.01f, settings.gestureSprintDecaySeconds))); sprintGestureEnergy = Mathf.Clamp01(sprintGestureEnergy + num * Time.fixedDeltaTime); if (settings.gestureSprintEnabled && sprintGestureEnergy > 0.5f && !SettingsManager.settings.alwaysSprint) { InputManager.GetButton("Sprint").Pressed = true; } } } internal static class VRDyno { private const float DynoPeakSpeedBlend = 0.5f; private static readonly bool[] hanging = new bool[2]; private static readonly bool[] releaseHeld = new bool[2]; private static readonly bool[] forceRelease = new bool[2]; private static readonly float[] releaseHoldStart = new float[2]; private static readonly float[] peakSpeed = new float[2]; private static readonly Vector3[] peakVelocity = (Vector3[])(object)new Vector3[2]; private static float armTime = -100f; private static Vector3 armVelocity = Vector3.zero; private static int armHandId = -1; private static float lastFireTime = -100f; public static void TrackHand(int handId, bool isHanging, VRSettings settings) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) hanging[handId] = isHanging; if (!isHanging) { releaseHeld[handId] = false; peakSpeed[handId] = 0f; peakVelocity[handId] = Vector3.zero; return; } VRHand vRHand = VRHandInput.ForHandId(handId); Vector3 physicalVelocity = vRHand.GetPhysicalVelocity(settings.dynoSampleWindow); float magnitude = ((Vector3)(ref physicalVelocity)).magnitude; if (magnitude > peakSpeed[handId]) { peakSpeed[handId] = magnitude; peakVelocity[handId] = physicalVelocity; } if (magnitude < settings.dynoSpeedThreshold || physicalVelocity.y >= 0f || !vRHand.GetPhysicalTravel(settings.dynoArmTravelWindow, out var displacement, out var _) || ((Vector3)(ref displacement)).magnitude < settings.dynoTravelThreshold || displacement.y >= 0f) { return; } bool flag = Time.time - armTime > settings.dynoArmWindow; armTime = Time.time; if (flag || !(magnitude <= ((Vector3)(ref armVelocity)).magnitude)) { armVelocity = physicalVelocity; armHandId = handId; if (flag) { VRLog.Verbose($"[VRDyno] armed hand={handId} speed={magnitude:0.00} down={0f - physicalVelocity.y:0.00} downRatio={(0f - physicalVelocity.y) / magnitude:0.00}"); } } } public static void FilterGrabButton(int handId, ButtonInput? button) { if (button == null || !VRRenderingPipeline.vrInitialized) { return; } VRSettings settings = VRRenderingPipeline.Settings; if (forceRelease[handId]) { forceRelease[handId] = false; button.Up = true; } else if (releaseHeld[handId]) { if (hanging[handId] && !(Time.time - releaseHoldStart[handId] > settings.dynoReleaseHold)) { button.Up = false; return; } releaseHeld[handId] = false; button.Up = true; if (hanging[handId]) { VRLog.Verbose($"[VRDyno] release not confirmed hand={handId}, letting go"); } } else if (button.Up && hanging[handId] && settings.dynoEnabled) { if (Time.time - armTime > settings.dynoArmWindow && !TryArmFromTravel(handId, settings)) { LogUnarmedRelease(handId, settings); } else if (!(Time.time - lastFireTime < settings.dynoCooldown)) { releaseHeld[handId] = true; releaseHoldStart[handId] = Time.time; button.Up = false; } } } private static bool TryArmFromTravel(int handId, VRSettings settings) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) if (!VRHandInput.ForHandId(handId).GetPhysicalTravel(settings.dynoArmTravelWindow, out var displacement, out var elapsed)) { return false; } float magnitude = ((Vector3)(ref displacement)).magnitude; if (magnitude < settings.dynoTravelThreshold) { return false; } if (displacement.y >= 0f) { return false; } armTime = Time.time; armVelocity = displacement / elapsed; armHandId = handId; VRLog.Verbose($"[VRDyno] armed by travel hand={handId} travel={magnitude:0.00}m over {elapsed:0.00}s " + $"chordSpeed={((Vector3)(ref armVelocity)).magnitude:0.00} down={0f - displacement.y:0.00}"); return true; } private static void LogUnarmedRelease(int handId, VRSettings settings) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) Vector3 val = peakVelocity[handId]; float num = ((peakSpeed[handId] > 0.0001f) ? ((0f - val.y) / peakSpeed[handId]) : 0f); VRHandInput.ForHandId(handId).GetPhysicalTravel(settings.dynoArmTravelWindow, out var displacement, out var _); VRLog.Verbose($"[VRDyno] no arm on release hand={handId} peakSpeed={peakSpeed[handId]:0.00} (need {settings.dynoSpeedThreshold:0.00}) " + $"peakDown={0f - val.y:0.00} peakDownRatio={num:0.00} " + $"travel={((Vector3)(ref displacement)).magnitude:0.00}m (need {settings.dynoTravelThreshold:0.00}) travelDown={0f - displacement.y:0.00}"); } private static Vector3 ResolveLaunchVelocity(VRSettings settings) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) if (armHandId < 0) { return armVelocity; } if (!VRHandInput.ForHandId(armHandId).GetPhysicalTravel(settings.dynoArmTravelWindow, out var displacement, out var elapsed)) { return armVelocity; } float magnitude = ((Vector3)(ref displacement)).magnitude; if (magnitude < 0.0001f) { return armVelocity; } float num = magnitude / elapsed; float magnitude2 = ((Vector3)(ref armVelocity)).magnitude; float num2 = Mathf.Lerp(num, magnitude2, 0.5f); VRLog.Verbose($"[VRDyno] chord travel={magnitude:0.00}m over {elapsed:0.00}s chordSpeed={num:0.00} " + $"peakSpeed={magnitude2:0.00} launchSpeed={num2:0.00}"); return displacement / magnitude * num2; } public static bool ShouldFire(VRSettings settings, out Vector3 velocity) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) velocity = armVelocity; int num = 0; int num2 = 0; for (int i = 0; i < 2; i++) { if (hanging[i]) { num++; if (releaseHeld[i]) { num2++; } } } if (num2 == 0) { return false; } if (num2 != num) { return false; } velocity = ResolveLaunchVelocity(settings); return true; } public static void Consume() { lastFireTime = Time.time; armTime = -100f; armHandId = -1; for (int i = 0; i < 2; i++) { ref bool reference = ref forceRelease[i]; reference |= releaseHeld[i]; releaseHeld[i] = false; } } } internal static class VRControllerProfile { private const float RescanInterval = 1f; private static bool indexDetected; private static bool hasScanned; private static float lastScanTime = float.NegativeInfinity; private static string? lastLoggedState; public static bool TriggerClimbs { get { string gripScheme = VRRenderingPipeline.Settings.gripScheme; if (gripScheme == "trigger") { return true; } if (gripScheme == "grip") { return false; } return indexDetected; } } public static bool DualTargetPaths => !TriggerClimbs; public static void Refresh(ManualLogSource logger) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) if (!hasScanned || !(Time.unscaledTime - lastScanTime < 1f)) { lastScanTime = Time.unscaledTime; hasScanned = true; indexDetected = ((IEnumerable)(object)InputSystem.devices).Any((InputDevice device) => device is ValveIndexController); string text = (indexDetected ? "ValveIndexController" : "no Index controller") + " scheme=" + VRRenderingPipeline.Settings.gripScheme + " climbOn=" + (TriggerClimbs ? "trigger" : "grip") + $" dualTargets={DualTargetPaths}"; if (!(text == lastLoggedState)) { lastLoggedState = text; logger.LogInfo((object)("Controller profile: " + text)); } } } } internal static class VRDataFolderGuard { private const string ManifestContent = "{\n \"name\": \"OpenXR XR Plugin\",\n \"version\": \"1.2.8\",\n \"libraryName\": \"UnityOpenXR\",\n \"displays\": [\n {\n \"id\": \"OpenXR Display\"\n }\n ],\n \"inputs\": [\n {\n \"id\": \"OpenXR Input\"\n }\n ]\n}\n"; public static void EnsureRedistFilesPresent(ManualLogSource logger) { string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string path = Path.Combine(Paths.GameRootPath, "White Knuckle_Data"); bool flag = false; flag |= CopyIfMissing(logger, Path.Combine(directoryName, "Managed", "Unity.XR.Management.dll"), Path.Combine(path, "Managed", "Unity.XR.Management.dll")); flag |= CopyIfMissing(logger, Path.Combine(directoryName, "Managed", "Unity.XR.OpenXR.dll"), Path.Combine(path, "Managed", "Unity.XR.OpenXR.dll")); flag |= CopyIfMissing(logger, Path.Combine(directoryName, "x86_64", "UnityOpenXR.dll"), Path.Combine(path, "Plugins", "x86_64", "UnityOpenXR.dll")); flag |= CopyIfMissing(logger, Path.Combine(directoryName, "x86_64", "openxr_loader.dll"), Path.Combine(path, "Plugins", "x86_64", "openxr_loader.dll")); if (flag | WriteManifestIfMissing(logger, Path.Combine(path, "UnitySubsystems", "UnityOpenXR", "UnitySubsystemsManifest.json"))) { logger.LogWarning((object)"================================================================"); logger.LogWarning((object)"Wrote missing OpenXR runtime files directly into White Knuckle_Data/."); logger.LogWarning((object)"Unity binds the OpenXR subsystem to these at engine boot, before any"); logger.LogWarning((object)"plugin runs, so this only takes effect next launch."); logger.LogWarning((object)"RESTART THE GAME to finish loading the VR mod."); logger.LogWarning((object)"================================================================"); } } private static bool CopyIfMissing(ManualLogSource logger, string source, string destination) { if (File.Exists(destination)) { return false; } try { if (!File.Exists(source)) { logger.LogError((object)("Cannot stage " + destination + " - " + source + " is missing from the mod's own folder.")); return false; } Directory.CreateDirectory(Path.GetDirectoryName(destination)); File.Copy(source, destination); return true; } catch (Exception arg) { logger.LogError((object)$"Failed to copy {source} to {destination}: {arg}"); return false; } } private static bool WriteManifestIfMissing(ManualLogSource logger, string path) { if (File.Exists(path)) { return false; } try { Directory.CreateDirectory(Path.GetDirectoryName(path)); File.WriteAllText(path, "{\n \"name\": \"OpenXR XR Plugin\",\n \"version\": \"1.2.8\",\n \"libraryName\": \"UnityOpenXR\",\n \"displays\": [\n {\n \"id\": \"OpenXR Display\"\n }\n ],\n \"inputs\": [\n {\n \"id\": \"OpenXR Input\"\n }\n ]\n}\n"); return true; } catch (Exception arg) { logger.LogError((object)$"Failed to write OpenXR subsystem manifest at {path}: {arg}"); return false; } } } internal static class VRDeathEffects { private const float RescanInterval = 0.1f; private static readonly List suppressedRenderers = new List(); private static float lastScanTime; private static bool wasDead; public static void Reset() { RestoreSuppressed(); wasDead = false; lastScanTime = 0f; } public static void Advance(Camera? vrCamera) { if (!CL_GameManager.isDead()) { if (wasDead) { RestoreSuppressed(); } wasDead = false; return; } if (!wasDead) { lastScanTime = 0f; } wasDead = true; if (!(Time.unscaledTime - lastScanTime < 0.1f)) { lastScanTime = Time.unscaledTime; HideParticlesNearHead(vrCamera); HideRisingMass(); } } private static void HideParticlesNearHead(Camera? vrCamera) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)vrCamera == (Object)null) { return; } float deathEffectCullRadius = VRRenderingPipeline.Settings.deathEffectCullRadius; if (deathEffectCullRadius <= 0f) { return; } Vector3 position = ((Component)vrCamera).transform.position; ParticleSystemRenderer[] array = Object.FindObjectsOfType(); foreach (ParticleSystemRenderer val in array) { if (((Renderer)val).enabled) { Bounds bounds = ((Renderer)val).bounds; if (!(Vector3.Distance(((Bounds)(ref bounds)).center, position) > deathEffectCullRadius)) { Hide((Renderer)(object)val, "gore particle"); } } } } private static void HideRisingMass() { if (!VRRenderingPipeline.Settings.hideMassOnDeath) { return; } DEN_DeathFloor instance = DEN_DeathFloor.instance; if (!((Object)(object)instance == (Object)null)) { if ((Object)(object)instance.visualRoot != (Object)null) { HideRenderersUnder(instance.visualRoot.transform); } UT_GooVisualOverride currentGooVisualOverride = DEN_DeathFloor.currentGooVisualOverride; if ((Object)(object)currentGooVisualOverride != (Object)null) { HideRenderersUnder(((Component)currentGooVisualOverride).transform); } } } private static void HideRenderersUnder(Transform root) { Renderer[] componentsInChildren = ((Component)root).GetComponentsInChildren(true); foreach (Renderer val in componentsInChildren) { if (val.enabled) { Hide(val, "mass"); } } } private static void Hide(Renderer renderer, string reason) { renderer.enabled = false; suppressedRenderers.Add(renderer); } private static void RestoreSuppressed() { foreach (Renderer suppressedRenderer in suppressedRenderers) { if ((Object)(object)suppressedRenderer != (Object)null) { suppressedRenderer.enabled = true; } } suppressedRenderers.Clear(); } } internal static class VRDeviceLoader { public static IEnumerator InitializeXRSubsystems(ManualLogSource logger, bool useSinglePassInstanced) { logger.LogInfo((object)"Attempting modern XR initialization via XR Manager..."); Type type = AccessTools.TypeByName("UnityEngine.XR.Management.XRGeneralSettings"); Type xrManagerSettingsType = AccessTools.TypeByName("UnityEngine.XR.Management.XRManagerSettings"); Type type2 = AccessTools.TypeByName("UnityEngine.XR.OpenXR.OpenXRLoader"); Type type3 = AccessTools.TypeByName("UnityEngine.XR.OpenXR.OpenXRSettings"); if (type == null || xrManagerSettingsType == null || type2 == null || type3 == null) { logger.LogError((object)"Required XR Management or OpenXR types not found. Cannot load VR."); yield break; } object value = AccessTools.Property(type, "Instance").GetValue(null); object obj; if (value == null) { logger.LogWarning((object)"XRGeneralSettings.Instance is null. Manually creating settings objects..."); value = ScriptableObject.CreateInstance(type); obj = ScriptableObject.CreateInstance(xrManagerSettingsType); AccessTools.Property(type, "Manager").SetValue(value, obj); logger.LogInfo((object)"Successfully created XR General Settings and Manager Settings objects."); } else { obj = AccessTools.Property(type, "Manager").GetValue(value); if (obj == null) { obj = ScriptableObject.CreateInstance(xrManagerSettingsType); AccessTools.Property(type, "Manager").SetValue(value, obj); logger.LogInfo((object)"XR General Settings found, but Manager was null. Created new Manager."); } logger.LogInfo((object)"Found existing XR General Settings instance."); } object xrManager = obj; object obj2 = ScriptableObject.CreateInstance(type2); PropertyInfo propertyInfo = AccessTools.Property(xrManagerSettingsType, "loaders"); IList list = (IList)propertyInfo.GetValue(xrManager); list.Clear(); list.Add(obj2); logger.LogInfo((object)("Added custom loader: " + type2.Name + " to the manager's list.")); List enabledFeatures; if (!(bool)AccessTools.Property(xrManagerSettingsType, "isInitializationComplete").GetValue(xrManager)) { MethodInfo methodInfo = AccessTools.Method(xrManagerSettingsType, "InitializeLoaderSync", (Type[])null, (Type[])null); object obj3 = Resources.FindObjectsOfTypeAll(type3).FirstOrDefault(); if (obj3 == null) { obj3 = ScriptableObject.CreateInstance(type3); logger.LogWarning((object)"OpenXRSettings asset not found in memory. Manually created a clean instance."); } else { logger.LogInfo((object)"OpenXR settings asset found in memory."); } Type renderModeEnumType = AccessTools.TypeByName("UnityEngine.XR.OpenXR.OpenXRSettings+RenderMode"); FieldInfo fieldInfo = null; if (renderModeEnumType != null) { fieldInfo = obj3.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).FirstOrDefault((FieldInfo f) => f.FieldType == renderModeEnumType); } if (fieldInfo != null) { string text = (useSinglePassInstanced ? "SinglePassInstanced" : "MultiPass"); if (Enum.IsDefined(fieldInfo.FieldType, text)) { fieldInfo.SetValue(obj3, Enum.Parse(fieldInfo.FieldType, text)); logger.LogInfo((object)("SUCCESS: Forced OpenXRSettings Render Mode field '" + fieldInfo.Name + "' to " + text + " (Found by Type).")); } else { logger.LogWarning((object)("Found render mode field '" + fieldInfo.Name + "', but target mode '" + text + "' not found in enum " + fieldInfo.FieldType.Name + ". Mode not set.")); } } else { logger.LogWarning((object)"Cannot find Render Mode field by type. Render mode not set. Proceeding anyway."); } OpenXRSettings val = (OpenXRSettings)obj3; enabledFeatures = new List(); AddFeature(); AddFeature(); AddFeature(); AddFeature(); AddFeature(); AddFeature(); AddFeature(); AddFeature(); AccessTools.Field(type3, "features")?.SetValue(val, enabledFeatures.ToArray()); logger.LogInfo((object)($"Enabled {enabledFeatures.Count} OpenXR interaction profile features: " + string.Join(", ", enabledFeatures.Select((OpenXRFeature f) => ((object)f).GetType().Name)))); FieldInfo fieldInfo2 = AccessTools.Field(type3, "s_RuntimeInstance"); if (fieldInfo2 != null) { fieldInfo2.SetValue(null, val); logger.LogInfo((object)"Forced OpenXRSettings.Instance to resolve to our configured settings object."); } else { logger.LogWarning((object)"Could not find OpenXRSettings.s_RuntimeInstance by reflection - OpenXRSettings.Instance may return a blank settings object at init time, silently dropping our enabled features."); } FieldInfo field = type2.GetField("m_Settings", BindingFlags.Instance | BindingFlags.NonPublic); if (field == null) { PropertyInfo property = type2.GetProperty("settings", BindingFlags.Instance | BindingFlags.Public); if (property != null) { property.SetValue(obj2, obj3); logger.LogInfo((object)"SUCCESS: Forcibly assigned OpenXRSettings to OpenXRLoader.settings Property."); } else { logger.LogWarning((object)"Cannot find OpenXRLoader.m_Settings field OR public 'settings' property. Initialization might be unstable."); } } else { field.SetValue(obj2, obj3); logger.LogInfo((object)"SUCCESS: Forcibly assigned OpenXRSettings to OpenXRLoader.m_Settings field."); } logger.LogInfo((object)"Invoking InitializeLoaderSync..."); methodInfo?.Invoke(xrManager, null); yield return null; } object value2 = AccessTools.Property(xrManagerSettingsType, "activeLoader").GetValue(xrManager); if (value2 == null) { logger.LogError((object)"Failed to set active XR Loader after InitializeLoaderSync."); yield break; } logger.LogInfo((object)("Starting XR Subsystems via Loader: " + value2.GetType().Name + "...")); AccessTools.Method(xrManagerSettingsType, "StartSubsystems", (Type[])null, (Type[])null)?.Invoke(xrManager, null); yield return null; List list2 = new List(); SubsystemManager.GetInstances(list2); bool flag = false; foreach (XRDisplaySubsystem item in list2) { if (((IntegratedSubsystem)item).running) { flag = true; logger.LogInfo((object)("Active XR Display found: " + ((IntegratedSubsystemDescriptor)((IntegratedSubsystem)(object)item).SubsystemDescriptor).id)); break; } } if (flag) { logger.LogInfo((object)"VR fully initialized and active via XR Manager"); } else { logger.LogError((object)"XR Manager initialized but device is not active/running. Check VR runtime service."); } void AddFeature() where TFeature : OpenXRFeature { TFeature val2 = ScriptableObject.CreateInstance(); ((OpenXRFeature)val2).enabled = true; enabledFeatures.Add((OpenXRFeature)(object)val2); } } } internal static class VRHandCollision { private const float DegenerateHitDistance = 0.01f; private const float MinimumArmExtension = 0.02f; private const float DiagnosticInterval = 10f; private static readonly Vector3[] solvedPosition = (Vector3[])(object)new Vector3[2]; private static readonly bool[] blocked = new bool[2]; private static readonly float[] blockedDepth = new float[2]; private static float lastDiagnosticTime; public static Vector3 SolvedPosition(int handId) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) if (handId < 0 || handId >= solvedPosition.Length) { return Vector3.zero; } return solvedPosition[handId]; } public static void Reset() { for (int i = 0; i < solvedPosition.Length; i++) { blocked[i] = false; blockedDepth[i] = 0f; } } public static Vector3 ShoulderWorld(ENT_Player player, Vector3 headWorld, int handId) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) VRSettings settings = VRRenderingPipeline.Settings; float num = ((handId == 0) ? (-1f) : 1f); return headWorld + ((Component)player).transform.right * (num * settings.shoulderHalfWidth) - ((Component)player).transform.up * settings.shoulderDrop; } public static void Solve(Vector3 headWorld) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) ENT_Player playerObject = ENT_Player.playerObject; VRSettings settings = VRRenderingPipeline.Settings; RaycastHit val4 = default(RaycastHit); for (int i = 0; i < VRHandInput.Hands.Length && i < solvedPosition.Length; i++) { VRHand vRHand = VRHandInput.Hands[i]; solvedPosition[i] = vRHand.WorldPosition; blocked[i] = false; blockedDepth[i] = 0f; if (!vRHand.IsTracked || (Object)(object)playerObject == (Object)null) { continue; } Vector3 val = ShoulderWorld(playerObject, headWorld, i); Vector3 val2 = vRHand.WorldPosition - val; float magnitude = ((Vector3)(ref val2)).magnitude; if (!(magnitude < 0.02f)) { Vector3 val3 = val2 / magnitude; float handCollisionRadius = settings.handCollisionRadius; bool queriesHitBackfaces = Physics.queriesHitBackfaces; Physics.queriesHitBackfaces = false; bool flag; try { flag = Physics.SphereCast(val, handCollisionRadius, val3, ref val4, magnitude, LayerMask.op_Implicit(playerObject.jumpMask), (QueryTriggerInteraction)1); } finally { Physics.queriesHitBackfaces = queriesHitBackfaces; } if (flag && !(((RaycastHit)(ref val4)).distance <= 0.01f)) { solvedPosition[i] = val + val3 * ((RaycastHit)(ref val4)).distance; blocked[i] = true; blockedDepth[i] = magnitude - ((RaycastHit)(ref val4)).distance; } } } LogDiagnostic(); } private static void LogDiagnostic() { if (VRRenderingPipeline.Settings.verboseLogging && (blocked[0] || blocked[1]) && !(Time.unscaledTime - lastDiagnosticTime < 10f)) { lastDiagnosticTime = Time.unscaledTime; VRLog.Verbose($"[handcollide] L blocked={blocked[0]} depth={blockedDepth[0]:0.000}m " + $"R blocked={blocked[1]} depth={blockedDepth[1]:0.000}m " + $"radius={VRRenderingPipeline.Settings.handCollisionRadius:0.00}m"); } } } public struct VRButton { public bool Pressed; public bool Down; public bool Up; public void Advance(bool pressed) { Down = pressed && !Pressed; Up = !pressed && Pressed; Pressed = pressed; } } public class VRHand { public const int LeftId = 0; public const int RightId = 1; private const int PoseHistoryCapacity = 48; private const float AnalogPressThreshold = 0.65f; public readonly int Id; public bool IsTracked; public Vector3 PlayspacePosition; public Quaternion PlayspaceRotation; public Vector3 WorldPosition; public Quaternion WorldRotation; public VRButton Grip; public VRButton Trigger; public VRButton Primary; public VRButton Secondary; public VRButton StickClick; public VRButton Menu; public float GripAmount; public float TriggerAmount; public Vector2 Stick; public Quaternion RigRotation = Quaternion.identity; public Quaternion PhysicalFrameRotation = Quaternion.identity; private readonly Vector3[] historyPosition = (Vector3[])(object)new Vector3[48]; private readonly Vector3[] historyPlayspacePosition = (Vector3[])(object)new Vector3[48]; private readonly float[] historyTime = new float[48]; private int historyCount; private int historyHead; public Vector3 Forward => WorldRotation * Vector3.forward; public Vector3 Up => WorldRotation * Vector3.up; public Vector3 Right => WorldRotation * Vector3.right; public VRHand(int id) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) Id = id; } private static XRNode NodeFor(int id) { if (id == 0) { return (XRNode)4; } return (XRNode)5; } public void Advance() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) InputDevice deviceAtXRNode = InputDevices.GetDeviceAtXRNode(NodeFor(Id)); Vector3 playspacePosition = default(Vector3); bool flag = ((InputDevice)(ref deviceAtXRNode)).TryGetFeatureValue(CommonUsages.devicePosition, ref playspacePosition); Quaternion playspaceRotation = default(Quaternion); bool flag2 = ((InputDevice)(ref deviceAtXRNode)).TryGetFeatureValue(CommonUsages.deviceRotation, ref playspaceRotation); IsTracked = ((InputDevice)(ref deviceAtXRNode)).isValid && flag && flag2; if (IsTracked) { PlayspacePosition = playspacePosition; PlayspaceRotation = playspaceRotation; } float num = default(float); bool flag3 = ((InputDevice)(ref deviceAtXRNode)).TryGetFeatureValue(CommonUsages.grip, ref num); GripAmount = (flag3 ? num : 0f); TriggerAmount = ReadAnalog(deviceAtXRNode, CommonUsages.trigger); Vector2 val = default(Vector2); Stick = (((InputDevice)(ref deviceAtXRNode)).TryGetFeatureValue(CommonUsages.primary2DAxis, ref val) ? val : Vector2.zero); Grip.Advance(flag3 ? CrossesGripThreshold(GripAmount, Grip.Pressed) : ReadButton(deviceAtXRNode, CommonUsages.gripButton, GripAmount)); Trigger.Advance(ReadButton(deviceAtXRNode, CommonUsages.triggerButton, TriggerAmount)); Primary.Advance(ReadButton(deviceAtXRNode, CommonUsages.primaryButton, 0f)); Secondary.Advance(ReadButton(deviceAtXRNode, CommonUsages.secondaryButton, 0f)); StickClick.Advance(ReadButton(deviceAtXRNode, CommonUsages.primary2DAxisClick, 0f)); Menu.Advance(ReadButton(deviceAtXRNode, CommonUsages.menuButton, 0f)); } public void RefreshWorldPose(Vector3 headWorldPosition, Vector3 headPlayspacePosition, Quaternion rigRotation, Quaternion physicalFrameRotation) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) if (IsTracked) { RigRotation = rigRotation; PhysicalFrameRotation = physicalFrameRotation; WorldPosition = headWorldPosition + rigRotation * (PlayspacePosition - headPlayspacePosition); WorldRotation = rigRotation * PlayspaceRotation; PushPoseSample(WorldPosition, PlayspacePosition); } } private static bool CrossesGripThreshold(float value, bool wasPressed) { VRSettings settings = VRRenderingPipeline.Settings; float num = (wasPressed ? settings.gripReleaseThreshold : settings.gripPressThreshold); return value >= num; } private static float ReadAnalog(InputDevice device, InputFeatureUsage usage) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) float result = default(float); if (!((InputDevice)(ref device)).TryGetFeatureValue(usage, ref result)) { return 0f; } return result; } private static bool ReadButton(InputDevice device, InputFeatureUsage usage, float analogFallback) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) bool result = default(bool); if (((InputDevice)(ref device)).TryGetFeatureValue(usage, ref result)) { return result; } return analogFallback >= 0.65f; } private void PushPoseSample(Vector3 worldPosition, Vector3 playspacePosition) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) historyHead = (historyHead + 1) % 48; historyPosition[historyHead] = worldPosition; historyPlayspacePosition[historyHead] = playspacePosition; historyTime[historyHead] = Time.unscaledTime; if (historyCount < 48) { historyCount++; } } public void ClearPoseHistory() { historyCount = 0; historyHead = 0; } public Vector3 GetSmoothedVelocity(float windowSeconds) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) int num = FindOldestWithin(windowSeconds); if (num < 0) { return Vector3.zero; } float num2 = historyTime[historyHead] - historyTime[num]; return (historyPosition[historyHead] - historyPosition[num]) / num2; } public Vector3 GetPhysicalVelocity(float windowSeconds) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) int num = FindOldestWithin(windowSeconds); if (num < 0) { return Vector3.zero; } float num2 = historyTime[historyHead] - historyTime[num]; Vector3 val = (historyPlayspacePosition[historyHead] - historyPlayspacePosition[num]) / num2; return PhysicalFrameRotation * val; } public bool GetPhysicalTravel(float windowSeconds, out Vector3 displacement, out float elapsed) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) displacement = Vector3.zero; elapsed = 0f; if (historyCount < 2) { return false; } float num = historyTime[historyHead]; int i; for (i = 1; i < historyCount; i++) { int num2 = (historyHead - i + 48) % 48; if (num - historyTime[num2] > windowSeconds) { break; } } if (i < 2) { return false; } float num3 = 0f; for (int num4 = i - 1; num4 >= 1; num4--) { int num5 = (historyHead - num4 + 48) % 48; for (int num6 = num4 - 1; num6 >= 0; num6--) { int num7 = (historyHead - num6 + 48) % 48; Vector3 val = historyPlayspacePosition[num7] - historyPlayspacePosition[num5]; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (!(sqrMagnitude <= num3)) { num3 = sqrMagnitude; displacement = val; elapsed = historyTime[num7] - historyTime[num5]; } } } if (num3 <= 0f || elapsed <= 0.0001f) { return false; } displacement = PhysicalFrameRotation * displacement; return true; } private int FindOldestWithin(float windowSeconds) { if (historyCount < 2) { return -1; } float num = historyTime[historyHead]; int num2 = historyHead; for (int i = 1; i < historyCount; i++) { int num3 = (historyHead - i + 48) % 48; if (num - historyTime[num3] > windowSeconds) { break; } num2 = num3; } if (!(num - historyTime[num2] < 0.0001f)) { return num2; } return -1; } } public static class VRHandInput { public static readonly VRHand[] Hands = new VRHand[2] { new VRHand(0), new VRHand(1) }; private static int lastAdvanceFrame = -1; public static VRHand Left => Hands[0]; public static VRHand Right => Hands[1]; public static bool AnyTracked { get { if (!Left.IsTracked) { return Right.IsTracked; } return true; } } private static bool SticksSwapped => VRRenderingPipeline.Settings.swapTurnAndMoveSticks; private static bool StickButtonsSwapped => VRRenderingPipeline.Settings.swapStickButtons; public static VRHand MoveHand { get { if (!SticksSwapped) { return Left; } return Right; } } public static VRHand TurnHand { get { if (!SticksSwapped) { return Right; } return Left; } } public static VRHand SprintHand { get { if (!StickButtonsSwapped) { return Left; } return Right; } } public static VRHand CrouchHand { get { if (!StickButtonsSwapped) { return Right; } return Left; } } public static void Advance() { int frameCount = Time.frameCount; if (lastAdvanceFrame != frameCount) { lastAdvanceFrame = frameCount; for (int i = 0; i < Hands.Length; i++) { Hands[i].Advance(); } } } public static void RefreshWorldPoses(Vector3 headWorldPosition, Vector3 headPlayspacePosition, Quaternion rigRotation, Quaternion physicalFrameRotation) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < Hands.Length; i++) { Hands[i].RefreshWorldPose(headWorldPosition, headPlayspacePosition, rigRotation, physicalFrameRotation); } } public static void ClearPoseHistory() { for (int i = 0; i < Hands.Length; i++) { Hands[i].ClearPoseHistory(); } } public static VRHand ForHandId(int handId) { if (handId != 0) { return Right; } return Left; } } internal static class VRHandState { public static bool IsInteractAlive(Clickable? interact) { return !(((object)interact)?.Equals((object?)null) ?? true); } public static bool IsGrippingState(InteractType state) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected I4, but got Unknown return (state - 2) switch { 2 => true, 0 => true, 1 => true, _ => false, }; } public static void ReleaseStaleHolds(ENT_Player player) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) if (player.hands == null) { return; } for (int i = 0; i < player.hands.Length; i++) { Hand val = player.hands[i]; if (val != null && IsGrippingState(val.interactState) && !IsInteractAlive(val.currentInteract)) { VRLog.Verbose($"[stalehold] hand={i} state={val.interactState} interact destroyed, forcing release"); player.StopInteraction(i, "", true); } } } } internal static class VRHandSwapGesture { private const float CooldownSeconds = 0.6f; private const float ThrowSuppressSeconds = 0.5f; private static bool swapRequested; private static float cooldownExpiry; public static void Reset() { swapRequested = false; cooldownExpiry = -1f; } public static void Advance() { //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Invalid comparison between Unknown and I4 //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) swapRequested = false; if (!VRRenderingPipeline.vrInitialized) { return; } VRSettings settings = VRRenderingPipeline.Settings; if (!settings.handSwapGestureEnabled || Time.unscaledTime < cooldownExpiry || VRBackpack.IsOpen) { return; } VRHand left = VRHandInput.Left; VRHand right = VRHandInput.Right; if (!left.IsTracked || !right.IsTracked || !left.Grip.Pressed || !right.Grip.Pressed || (!left.Grip.Down && !right.Grip.Down)) { return; } ENT_Player playerObject = ENT_Player.playerObject; if ((Object)(object)playerObject == (Object)null || playerObject.hands == null || playerObject.hands.Length < 2) { return; } for (int i = 0; i < 2; i++) { Hand val = playerObject.hands[i]; if (val == null || (int)val.interactState == 4 || ((Object)(object)val.GetHandItem() == (Object)null && (int)val.interactState != 0)) { return; } } if (!((Object)(object)playerObject.hands[0].GetHandItem() == (Object)null) || !((Object)(object)playerObject.hands[1].GetHandItem() == (Object)null)) { float num = Vector3.Distance(left.WorldPosition, right.WorldPosition); if (!(num > settings.handSwapDistance)) { swapRequested = true; cooldownExpiry = Time.unscaledTime + 0.6f; VRThrowGesture.Suppress(0, 0.5f); VRThrowGesture.Suppress(1, 0.5f); string[] obj = new string[5] { $"[handswap] fired separation={num:0.000}m (max {settings.handSwapDistance:0.00}m) ", "left=", null, null, null }; HandItem handItem = playerObject.hands[0].GetHandItem(); obj[2] = ((handItem != null) ? ((Object)handItem).name : null) ?? "empty"; obj[3] = " right="; HandItem handItem2 = playerObject.hands[1].GetHandItem(); obj[4] = ((handItem2 != null) ? ((Object)handItem2).name : null) ?? "empty"; VRLog.Verbose(string.Concat(obj)); } } } public static void WriteSwapInput() { if (swapRequested && !((Object)(object)InputManager.instance == (Object)null)) { ButtonInput button = InputManager.GetButton("Hand-Swap"); if (button != null) { button.Down = true; button.Pressed = true; } } } } internal class VRItemAimBeam { private const float MaxLength = 8f; private const float FallbackLength = 3f; private readonly LineRenderer line; public VRItemAimBeam(Transform parent, Color color) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("VR Item Aim Beam"); val.transform.SetParent(parent, false); line = val.AddComponent(); line.useWorldSpace = true; line.positionCount = 2; line.widthMultiplier = 0.003f; ((Renderer)line).receiveShadows = false; ((Renderer)line).shadowCastingMode = (ShadowCastingMode)0; Shader val2 = Shader.Find("Sprites/Default") ?? Shader.Find("Standard"); Material val3 = new Material(val2); val3.color = color; ((Renderer)line).material = val3; line.startColor = color; line.endColor = new Color(color.r, color.g, color.b, 0f); ((Renderer)line).enabled = false; } public void SetVisible(bool visible) { ((Renderer)line).enabled = visible; } public void UpdateFrame(Vector3 origin, Vector3 direction) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) ((Renderer)line).enabled = true; RaycastHit val = default(RaycastHit); float num = (Physics.Raycast(origin, direction, ref val, 8f) ? ((RaycastHit)(ref val)).distance : 3f); line.SetPosition(0, origin); line.SetPosition(1, origin + direction * num); } } internal class VRLaserPointer { private const float MaxDistance = 6f; private const float DefaultVisualLength = 3f; private const float DotSize = 0.007f; private const float DotSurfaceOffset = 0.002f; private const float LineTailAlpha = 0.12f; private readonly VRHand hand; private readonly LineRenderer line; private readonly Transform dot; private readonly MeshRenderer dotRenderer; private int appliedSortingLayer; private int appliedSortingOrder = int.MinValue; private EventSystem? pointerOwner; private PointerEventData? pointer; private GameObject? hoveredObject; private Selectable? hoveredSelectable; private static int selectionOwnerHandId = -1; private static readonly List ResultsBuffer = new List(); public VRLaserPointer(VRHand hand, Transform parent, Color color) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) this.hand = hand; GameObject val = new GameObject("VR Laser " + ((hand.Id == 0) ? "Left" : "Right")); val.transform.SetParent(parent, false); line = val.AddComponent(); line.useWorldSpace = true; line.positionCount = 2; line.widthMultiplier = 0.004f; ((Renderer)line).receiveShadows = false; ((Renderer)line).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)line).material = BuildOverlayMaterial(color); line.startColor = color; line.endColor = new Color(color.r, color.g, color.b, color.a * 0.12f); ((Renderer)line).enabled = false; GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)5); ((Object)val2).name = "VR Laser Dot " + ((hand.Id == 0) ? "Left" : "Right"); Object.Destroy((Object)(object)val2.GetComponent()); val2.transform.SetParent(parent, false); val2.transform.localScale = Vector3.one * 0.007f; dotRenderer = val2.GetComponent(); ((Renderer)dotRenderer).material = BuildOverlayMaterial(new Color(color.r, color.g, color.b, 1f)); ((Renderer)dotRenderer).receiveShadows = false; ((Renderer)dotRenderer).shadowCastingMode = (ShadowCastingMode)0; dot = val2.transform; val2.SetActive(false); } private static Material BuildOverlayMaterial(Color color) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown //IL_002f: Unknown result type (might be due to invalid IL or missing references) Shader val = Shader.Find("UI/Default") ?? Shader.Find("Sprites/Default") ?? Shader.Find("Standard"); Material val2 = new Material(val); val2.color = color; val2.SetInt("unity_GUIZTestMode", 8); if (val2.HasProperty("_ZTest")) { val2.SetInt("_ZTest", 8); } val2.renderQueue = 4000; return val2; } public void SetVisible(bool visible) { ((Renderer)line).enabled = visible; if (!visible) { ((Component)dot).gameObject.SetActive(false); ClearHover(); } } public void UpdateFrame(List raycasters, float pitchOffsetDegrees) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) if (!hand.IsTracked) { ((Renderer)line).enabled = false; ((Component)dot).gameObject.SetActive(false); ClearHover(); return; } Vector3 worldPosition = hand.WorldPosition; Vector3 val = Quaternion.AngleAxis(pitchOffsetDegrees, hand.Right) * hand.Forward; RaycastResult best; float bestRayDistance; float nearestPlaneDistance; bool flag = TryRaycastUI(worldPosition, val, raycasters, out best, out bestRayDistance, out nearestPlaneDistance); ((Renderer)line).enabled = true; float num = (float.IsPositiveInfinity(nearestPlaneDistance) ? 3f : nearestPlaneDistance); Vector3 val2 = worldPosition + val * (flag ? bestRayDistance : num); line.SetPosition(0, worldPosition); line.SetPosition(1, val2); GameObject val3 = (flag ? ((RaycastResult)(ref best)).gameObject : null); ((Component)dot).gameObject.SetActive((Object)(object)val3 != (Object)null); if ((Object)(object)val3 != (Object)null) { Transform transform = val3.transform; dot.position = val2 - val * 0.002f; dot.rotation = Quaternion.LookRotation(transform.forward, transform.up); BaseRaycaster module = best.module; BaseRaycaster obj = ((module is GraphicRaycaster) ? module : null); Canvas val4 = ((obj != null) ? ((Component)obj).GetComponent() : null); if ((Object)(object)val4 != (Object)null) { SortAboveCanvas(val4); } } PointerEventData val5 = ResolvePointer(); if (flag) { val5.delta = best.screenPosition - val5.position; val5.position = best.screenPosition; val5.pointerCurrentRaycast = best; } else { val5.delta = Vector2.zero; val5.pointerCurrentRaycast = default(RaycastResult); } if ((Object)(object)val3 != (Object)(object)hoveredObject) { if ((Object)(object)hoveredObject != (Object)null) { ExecuteEvents.Execute(hoveredObject, (BaseEventData)(object)val5, ExecuteEvents.pointerExitHandler); } if ((Object)(object)val3 != (Object)null) { ExecuteEvents.Execute(val3, (BaseEventData)(object)val5, ExecuteEvents.pointerEnterHandler); } hoveredObject = val3; hoveredSelectable = ResolveSelectable(val3); if ((Object)(object)hoveredSelectable != (Object)null) { selectionOwnerHandId = hand.Id; } } val5.pointerEnter = val3; AssertSelection(); } private static Selectable? ResolveSelectable(GameObject? target) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)target == (Object)null) { return null; } Selectable componentInParent = target.GetComponentInParent(); if ((Object)(object)componentInParent == (Object)null) { return null; } if (!componentInParent.IsInteractable()) { return null; } Navigation navigation = componentInParent.navigation; if ((int)((Navigation)(ref navigation)).mode == 0) { return null; } return componentInParent; } private void AssertSelection() { if ((Object)(object)hoveredSelectable == (Object)null) { if (selectionOwnerHandId == hand.Id) { selectionOwnerHandId = -1; } } else if (selectionOwnerHandId == hand.Id && !((Object)(object)EventSystem.current == (Object)null) && !VRMenuSelection.SliderEngaged && hoveredSelectable.IsInteractable() && EventSystem.current.currentSelectedGameObject != ((Component)hoveredSelectable).gameObject) { EventSystem.current.SetSelectedGameObject(((Component)hoveredSelectable).gameObject); } } private void SortAboveCanvas(Canvas canvas) { Canvas val = (Canvas)(((Object)(object)canvas.rootCanvas != (Object)null) ? ((object)canvas.rootCanvas) : ((object)canvas)); int sortingLayerID = val.sortingLayerID; int num = val.sortingOrder + 1; if (sortingLayerID != appliedSortingLayer || num != appliedSortingOrder) { appliedSortingLayer = sortingLayerID; appliedSortingOrder = num; ((Renderer)line).sortingLayerID = sortingLayerID; ((Renderer)line).sortingOrder = num; ((Renderer)dotRenderer).sortingLayerID = sortingLayerID; ((Renderer)dotRenderer).sortingOrder = num; } } private PointerEventData ResolvePointer() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown if (pointer != null && pointerOwner == EventSystem.current) { return pointer; } pointerOwner = EventSystem.current; pointer = new PointerEventData(pointerOwner) { pointerId = -100 - hand.Id, button = (InputButton)0 }; return pointer; } private void ClearHover() { if (!((Object)(object)hoveredObject == (Object)null)) { ExecuteEvents.Execute(hoveredObject, (BaseEventData)(object)ResolvePointer(), ExecuteEvents.pointerExitHandler); hoveredObject = null; } } private static bool TryRaycastUI(Vector3 origin, Vector3 direction, List raycasters, out RaycastResult best, out float bestRayDistance, out float nearestPlaneDistance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Invalid comparison between Unknown and I4 //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Expected O, but got Unknown //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) best = default(RaycastResult); bestRayDistance = float.NaN; nearestPlaneDistance = float.PositiveInfinity; bool flag = false; foreach (GraphicRaycaster raycaster in raycasters) { if ((Object)(object)raycaster == (Object)null || !((Behaviour)raycaster).isActiveAndEnabled) { continue; } Canvas component = ((Component)raycaster).GetComponent(); if ((Object)(object)component == (Object)null || (int)component.renderMode != 2 || (Object)(object)component.worldCamera == (Object)null) { continue; } Transform transform = ((Component)component).transform; Vector3 forward = transform.forward; float num = Vector3.Dot(direction, forward); if (Mathf.Abs(num) < 1E-05f) { continue; } float num2 = Vector3.Dot(transform.position - origin, forward) / num; if (num2 <= 0f || num2 > 6f) { continue; } if (num2 < nearestPlaneDistance) { nearestPlaneDistance = num2; } Vector3 val = origin + direction * num2; Vector2 val2 = Vector2.op_Implicit(component.worldCamera.WorldToScreenPoint(val)); PointerEventData val3 = new PointerEventData(EventSystem.current) { position = val2 }; ResultsBuffer.Clear(); ((BaseRaycaster)raycaster).Raycast(val3, ResultsBuffer); if (ResultsBuffer.Count != 0) { RaycastResult val4 = ResultsBuffer[0]; val4.screenPosition = val2; if (!flag || SortsAbove(val4, best)) { best = val4; bestRayDistance = num2; flag = true; } } } return flag; } private static bool SortsAbove(RaycastResult candidate, RaycastResult incumbent) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)candidate.module != (Object)null && (Object)(object)incumbent.module != (Object)null) { if (candidate.module.sortOrderPriority != incumbent.module.sortOrderPriority) { return candidate.module.sortOrderPriority > incumbent.module.sortOrderPriority; } if (candidate.module.renderOrderPriority != incumbent.module.renderOrderPriority) { return candidate.module.renderOrderPriority > incumbent.module.renderOrderPriority; } } if (candidate.sortingLayer != incumbent.sortingLayer) { return SortingLayer.GetLayerValueFromID(candidate.sortingLayer) > SortingLayer.GetLayerValueFromID(incumbent.sortingLayer); } if (candidate.sortingOrder != incumbent.sortingOrder) { return candidate.sortingOrder > incumbent.sortingOrder; } if (candidate.depth != incumbent.depth) { return candidate.depth > incumbent.depth; } if (!Mathf.Approximately(candidate.distance, incumbent.distance)) { return candidate.distance < incumbent.distance; } return candidate.index < incumbent.index; } } internal static class VRLog { public static bool VerboseEnabled => VRRenderingPipeline.Settings.verboseLogging; public static void Verbose(string message) { if (VerboseEnabled) { ManualLogSource? staticLogger = VRRenderingPipeline.StaticLogger; if (staticLogger != null) { staticLogger.LogInfo((object)message); } } } } internal static class VRLookOffset { private const float SnapDeadzone = 0.5f; private const float SnapBackDeflection = 0.8f; private const float SmoothDeadzone = 0.15f; private const float MaxOffsetDegrees = 90f; private const float MultiplierFullEffectDegrees = 45f; private static bool snapReady = true; public static float AccumulatedDegrees { get; private set; } public static void Reset() { AccumulatedDegrees = 0f; snapReady = true; } public static Quaternion PitchRotationFor(Quaternion headRotation) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) Vector3 val = headRotation * Vector3.forward; float headPitchUp = Mathf.Asin(Mathf.Clamp(val.y, -1f, 1f)) * 57.29578f; float num = Mathf.Atan2(val.x, val.z) * 57.29578f; Vector3 val2 = Quaternion.AngleAxis(num, Vector3.up) * Vector3.right; return Quaternion.AngleAxis(0f - OffsetDegreesFor(headPitchUp), val2); } private static float OffsetDegreesFor(float headPitchUp) { VRSettings settings = VRRenderingPipeline.Settings; return Mathf.Clamp(settings.lookUpStyle switch { "smooth" => AccumulatedDegrees, "snap" => AccumulatedDegrees, "multiplier" => MultiplierOffset(headPitchUp, settings.headPitchMultiplier), _ => 0f, }, 0f, 90f); } private static float MultiplierOffset(float headPitchUp, float multiplier) { if (headPitchUp <= 0f) { return 0f; } float num = Mathf.Clamp01(headPitchUp / 45f); return headPitchUp * (Mathf.Pow(multiplier, num) - 1f); } public static void Advance(float stickY, float deltaTime) { VRSettings settings = VRRenderingPipeline.Settings; if (settings.lookUpStyle != "smooth" && settings.lookUpStyle != "snap") { AccumulatedDegrees = 0f; snapReady = true; } else if (settings.lookUpSnapBack && stickY <= -0.8f) { AccumulatedDegrees = 0f; snapReady = false; } else if (settings.lookUpStyle == "snap") { if (Mathf.Abs(stickY) < 0.5f) { snapReady = true; } else if (snapReady) { AccumulatedDegrees = Mathf.Clamp(AccumulatedDegrees + Mathf.Sign(stickY) * settings.snapLookUpAngle, 0f, 90f); snapReady = false; } } else if (!(Mathf.Abs(stickY) < 0.15f)) { AccumulatedDegrees = Mathf.Clamp(AccumulatedDegrees + stickY * settings.smoothLookUpSpeed * deltaTime, 0f, 90f); } } } internal static class VRMenuHold { private const float MenuPulseSeconds = 0.1f; private static float primaryHoldStart = -1f; private static bool primaryMenuFired; private static float stickHoldStart = -1f; private static bool stickMenuFired; private static float menuPulseUntil = float.NegativeInfinity; public static bool MenuPulseActive => Time.unscaledTime < menuPulseUntil; public static void Advance() { if (VRBackpack.HoldToOpenInventory) { primaryHoldStart = -1f; } else { VRHand left = VRHandInput.Left; if (left.IsTracked) { AdvanceHold(left.Primary, ref primaryHoldStart, ref primaryMenuFired, "Left primary"); } else { primaryHoldStart = -1f; } } if (!VRRenderingPipeline.Settings.toggleCrouch) { stickHoldStart = -1f; return; } VRHand crouchHand = VRHandInput.CrouchHand; if (crouchHand.IsTracked) { AdvanceHold(crouchHand.StickClick, ref stickHoldStart, ref stickMenuFired, "Crouch stick click"); } else { stickHoldStart = -1f; } } private static void AdvanceHold(VRButton button, ref float holdStart, ref bool menuFired, string logLabel) { if (button.Down) { holdStart = Time.unscaledTime; menuFired = false; } if (button.Pressed && !menuFired && holdStart >= 0f && Time.unscaledTime - holdStart >= VRRenderingPipeline.Settings.menuHoldSeconds) { menuFired = true; menuPulseUntil = Time.unscaledTime + 0.1f; VRBackpack.RequestClose(); VRLog.Verbose("[menu] " + logLabel + " held - closing bag and opening pause menu"); } if (button.Up) { holdStart = -1f; } } } internal static class VRMenuSelection { private static SubmitSlider? engagedSlider; public static bool SliderEngaged { get { if ((Object)(object)engagedSlider == (Object)null || !((Behaviour)engagedSlider).isActiveAndEnabled) { engagedSlider = null; } return (Object)(object)engagedSlider != (Object)null; } } public static void ToggleSliderEngagement(SubmitSlider slider) { engagedSlider = ((engagedSlider == slider) ? null : slider); } public static void ReleaseSliderEngagement(SubmitSlider slider) { if (engagedSlider == slider) { engagedSlider = null; } } public static void ClearSliderEngagement() { engagedSlider = null; } public static void SelectFirstInteractable(GameObject root) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)root == (Object)null || (Object)(object)EventSystem.current == (Object)null) { return; } Selectable[] componentsInChildren = root.GetComponentsInChildren(true); foreach (Selectable val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && ((UIBehaviour)val).IsActive() && val.IsInteractable()) { Navigation navigation = val.navigation; if ((int)((Navigation)(ref navigation)).mode != 0) { EventSystem.current.SetSelectedGameObject(((Component)val).gameObject); break; } } } } } internal static class VROverlayLayerTracker { private static readonly Dictionary layerRefCounts = new Dictionary(); public static int OverlayMask { get; private set; } public static void Register(int layer) { layerRefCounts.TryGetValue(layer, out var value); layerRefCounts[layer] = value + 1; Recompute(); } public static void Unregister(int layer) { if (layerRefCounts.TryGetValue(layer, out var value)) { value--; if (value <= 0) { layerRefCounts.Remove(layer); } else { layerRefCounts[layer] = value; } Recompute(); } } public static void Clear() { layerRefCounts.Clear(); OverlayMask = 0; } private static void Recompute() { int num = 0; foreach (int key in layerRefCounts.Keys) { num |= 1 << key; } OverlayMask = num; } } internal class VRMenuScroller : MonoBehaviour { private ScrollRect? scroll; private RectTransform? content; private RectTransform? viewport; private GameObject? lastSelected; private readonly Vector3[] worldCorners = (Vector3[])(object)new Vector3[4]; public void Initialize(ScrollRect scrollRect, RectTransform contentRect, RectTransform viewportRect) { scroll = scrollRect; content = contentRect; viewport = viewportRect; } private void Update() { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)scroll == (Object)null || (Object)(object)content == (Object)null || (Object)(object)viewport == (Object)null || (Object)(object)EventSystem.current == (Object)null) { return; } GameObject currentSelectedGameObject = EventSystem.current.currentSelectedGameObject; if ((Object)(object)currentSelectedGameObject == (Object)null || currentSelectedGameObject == lastSelected) { return; } lastSelected = currentSelectedGameObject; Transform transform = currentSelectedGameObject.transform; RectTransform val = (RectTransform)(object)((transform is RectTransform) ? transform : null); if ((Object)(object)val == (Object)null || !((Transform)val).IsChildOf((Transform)(object)content)) { return; } Rect rect = viewport.rect; float height = ((Rect)(ref rect)).height; rect = content.rect; float num = ((Rect)(ref rect)).height - height; if (!(num <= 0f)) { RectTransform val2 = DirectChildOfContent(val, content); val2.GetWorldCorners(worldCorners); rect = content.rect; float num2 = ((Rect)(ref rect)).yMax - ((Transform)content).InverseTransformPoint(worldCorners[1]).y; rect = content.rect; float num3 = ((Rect)(ref rect)).yMax - ((Transform)content).InverseTransformPoint(worldCorners[0]).y; float num4 = content.anchoredPosition.y; if (num2 < num4) { num4 = num2; } else if (num3 > num4 + height) { num4 = num3 - height; } content.anchoredPosition = new Vector2(content.anchoredPosition.x, Mathf.Clamp(num4, 0f, num)); } } private static RectTransform DirectChildOfContent(RectTransform descendant, RectTransform contentRect) { RectTransform val = descendant; while ((Object)(object)((Transform)val).parent != (Object)null && (Object)(object)((Transform)val).parent != (Object)(object)contentRect) { Transform parent = ((Transform)val).parent; RectTransform val2 = (RectTransform)(object)((parent is RectTransform) ? parent : null); if (val2 == null) { break; } val = val2; } return val; } } internal class VRSettingsScreenReset : MonoBehaviour { public CanvasGroup? group; private void OnEnable() { VRRenderingPipeline.InvalidateMenuCanvasGroupCache(); if (!((Object)(object)group == (Object)null)) { group.alpha = 0f; group.interactable = false; group.blocksRaycasts = false; } } } internal class VRSettingsRowHighlight : MonoBehaviour { public Image? background; public Selectable[]? members; public Color normalColor; public Color selectedColor; private void Update() { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)background == (Object)null || members == null) { return; } GameObject val = (((Object)(object)EventSystem.current != (Object)null) ? EventSystem.current.currentSelectedGameObject : null); bool flag = false; Selectable[] array = members; foreach (Selectable val2 in array) { if ((Object)(object)val2 != (Object)null && (Object)(object)val == (Object)(object)((Component)val2).gameObject) { flag = true; break; } } ((Graphic)background).color = (flag ? selectedColor : normalColor); } } internal static class VRPauseMenuTab { public static Transform? PauseMenuRoot; private const string BUTTON_NAME = "VR"; private const string SCREEN_NAME = "VR Settings Menu"; private const float RENDER_SCALE_MIN = 0.1f; private const float RENDER_SCALE_MAX = 1f; private const float RENDER_SCALE_STEP = 0.05f; private const float SMOOTH_TURN_SPEED_MIN = 10f; private const float SMOOTH_TURN_SPEED_MAX = 360f; private const float SMOOTH_TURN_SPEED_STEP = 15f; private const float SNAP_TURN_ANGLE_MIN = 10f; private const float SNAP_TURN_ANGLE_MAX = 180f; private const float SNAP_TURN_ANGLE_STEP = 15f; private const float SNAP_LOOK_UP_ANGLE_MIN = 5f; private const float SNAP_LOOK_UP_ANGLE_MAX = 45f; private const float SNAP_LOOK_UP_ANGLE_STEP = 5f; private const float HEAD_PITCH_MULTIPLIER_MIN = 1f; private const float HEAD_PITCH_MULTIPLIER_MAX = 10f; private const float HEAD_PITCH_MULTIPLIER_STEP = 0.25f; private const float BAG_TIME_DILATION_STEP = 0.05f; private static readonly Color PanelColor = new Color(0.03f, 0.03f, 0.04f, 0.93f); private static readonly Color RowColor = new Color(1f, 1f, 1f, 0.06f); private static readonly Color RowSelectedColor = new Color(1f, 0.62f, 0.16f, 0.3f); private static readonly Color TextColor = new Color(0.92f, 0.92f, 0.92f); private static readonly Color ButtonNormalColor = new Color(1f, 1f, 1f, 0.16f); private static readonly Color ButtonHighlightColor = new Color(1f, 0.72f, 0.28f, 0.85f); private static readonly Color ButtonPressedColor = new Color(1f, 0.85f, 0.55f, 1f); private static readonly Color ButtonDisabledColor = new Color(1f, 1f, 1f, 0.05f); private static readonly string[] TurnStyleOptions = new string[3] { "smooth", "snap", "disabled" }; private static readonly string[] TurnStyleLabels = new string[3] { "Smooth", "Snap", "Disabled" }; private static readonly string[] LookUpStyleOptions = new string[4] { "disabled", "smooth", "snap", "multiplier" }; private static readonly string[] LookUpStyleLabels = new string[4] { "Disabled", "Smooth", "Snap", "Multiplier" }; private static readonly string[] OffOnOptions = new string[2] { "off", "on" }; private static readonly string[] OffOnLabels = new string[2] { "Off", "On" }; private static readonly string[] MovementRelativeOptions = new string[3] { "hmd_relative", "left_hand_relative", "right_hand_relative" }; private static readonly string[] MovementRelativeLabels = new string[3] { "Headset", "Left Hand", "Right Hand" }; private static readonly string[] ClimbModeOptions = new string[3] { "either", "gesture", "joystick" }; private static readonly string[] ClimbModeLabels = new string[3] { "Either", "Gesture Only", "Joystick Only" }; private const float TITLE_HEIGHT = 60f; private const float HEADER_TOP_MARGIN = 40f; private const float VIEWPORT_BOTTOM_MARGIN = 40f; private const float CONTENT_TOP_PADDING = 10f; private const float FOOTER_HEIGHT = 90f; private const float CONTENT_WIDTH = 820f; private static VRSettings Settings => VRRenderingPipeline.Settings; public static void InjectAllInScene(ManualLogSource logger) { Transform[] array = Resources.FindObjectsOfTypeAll().Where(delegate(Transform t) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) if (((Object)t).name == "Pause Menu") { Scene scene = ((Component)t).gameObject.scene; return ((Scene)(ref scene)).IsValid(); } return false; }).ToArray(); if (VRLog.VerboseEnabled) { logger.LogInfo((object)$"VR pause menu: found {array.Length} 'Pause Menu' root(s) in the active scene."); } Transform[] array2 = array; foreach (Transform val in array2) { try { InjectOne(val, logger); } catch (Exception arg) { logger.LogError((object)$"VR pause menu: injection threw for '{((Object)val).name}': {arg}"); } } } private static void InjectOne(Transform pauseMenuRoot, ManualLogSource logger) { Transform val = pauseMenuRoot.Find("Pause Buttons"); UI_Menu val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent() : null); if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null) { logger.LogWarning((object)("VR pause menu: could not find 'Pause Buttons'/UI_Menu under '" + ((Object)pauseMenuRoot).name + "'.")); return; } if (val2.menuButtons.Any((UI_MenuButton b) => (Object)(object)b != (Object)null && ((Object)((Component)b).gameObject).name == "VR")) { if (VRLog.VerboseEnabled) { logger.LogInfo((object)"VR pause menu: already injected into this Pause Menu, skipping."); } return; } Transform val3 = val.Find("Pause Layout"); Transform val4 = (((Object)(object)val3 != (Object)null) ? val3.Find("Settings") : null); if ((Object)(object)val3 == (Object)null || (Object)(object)val4 == (Object)null) { logger.LogWarning((object)("VR pause menu: could not find 'Pause Layout/Settings' button template under '" + ((Object)val).name + "'.")); return; } TextMeshProUGUI componentInChildren = ((Component)pauseMenuRoot).GetComponentInChildren(true); if ((Object)(object)componentInChildren == (Object)null) { logger.LogWarning((object)"VR pause menu: could not find a TextMeshProUGUI in the scene to sample a font from."); return; } Transform val5 = pauseMenuRoot.Find("Settings Menu"); RectTransform fullScreenRectTemplate = (((Object)(object)val5 != (Object)null) ? ((Component)val5).GetComponent() : null); GameObject val6 = BuildScreen(pauseMenuRoot, componentInChildren, fullScreenRectTemplate, logger); UI_MenuScreen component = val6.GetComponent(); GameObject val7 = Object.Instantiate(((Component)val4).gameObject, val3, false); ((Object)val7).name = "VR"; val7.transform.SetSiblingIndex(val4.GetSiblingIndex() + 1); TextMeshProUGUI componentInChildren2 = val7.GetComponentInChildren(); if ((Object)(object)componentInChildren2 != (Object)null) { ((TMP_Text)componentInChildren2).text = "VR"; } UI_MenuButton component2 = val7.GetComponent(); component2.screen = component; bool flag = (Object)(object)val2.group != (Object)null; if (flag) { component2.Initialize(val2); val2.menuButtons.Add(component2); } PauseMenuRoot = pauseMenuRoot; if (VRLog.VerboseEnabled) { logger.LogInfo((object)string.Format("VR pause menu: injected '{0}' button and screen into '{1}' (menuAlreadyAwake={2}).", "VR", ((Object)pauseMenuRoot).name, flag)); } } private static GameObject BuildScreen(Transform pauseMenuRoot, TextMeshProUGUI fontSource, RectTransform? fullScreenRectTemplate, ManualLogSource logger) { //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Expected O, but got Unknown //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Expected O, but got Unknown //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Expected O, but got Unknown //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Expected O, but got Unknown //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_030c: Unknown result type (might be due to invalid IL or missing references) //IL_0326: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Unknown result type (might be due to invalid IL or missing references) //IL_063e: Unknown result type (might be due to invalid IL or missing references) //IL_0648: Expected O, but got Unknown RectTransform val = CreateChild("VR Settings Menu", pauseMenuRoot); if ((Object)(object)fullScreenRectTemplate != (Object)null) { val.anchorMin = fullScreenRectTemplate.anchorMin; val.anchorMax = fullScreenRectTemplate.anchorMax; val.pivot = fullScreenRectTemplate.pivot; val.sizeDelta = fullScreenRectTemplate.sizeDelta; val.anchoredPosition = fullScreenRectTemplate.anchoredPosition; ((Transform)val).localScale = ((Transform)fullScreenRectTemplate).localScale; } else { logger.LogWarning((object)"VR pause menu: 'Settings Menu' rect template not found - falling back to a plain full-stretch rect."); val.anchorMin = Vector2.zero; val.anchorMax = Vector2.one; val.offsetMin = Vector2.zero; val.offsetMax = Vector2.zero; } Image val2 = ((Component)val).gameObject.AddComponent(); ((Graphic)val2).color = PanelColor; CanvasGroup canvasGroup = ((Component)val).gameObject.AddComponent(); canvasGroup.alpha = 0f; canvasGroup.interactable = false; canvasGroup.blocksRaycasts = false; UI_MenuScreen val3 = ((Component)val).gameObject.AddComponent(); val3.startEnabled = false; val3.openEvent = new UnityEvent(); val3.closeEvent = new UnityEvent(); val3.closeEvent.AddListener((UnityAction)delegate { canvasGroup.alpha = 0f; canvasGroup.blocksRaycasts = false; }); ((Component)val).gameObject.AddComponent().group = canvasGroup; VRRenderingPipeline.RegisterMenuCanvasGroup(canvasGroup); RectTransform val4 = CreateChild("Header", (Transform)(object)val); val4.anchorMin = new Vector2(0f, 1f); val4.anchorMax = new Vector2(1f, 1f); val4.pivot = new Vector2(0.5f, 1f); val4.sizeDelta = new Vector2(0f, 60f); val4.anchoredPosition = new Vector2(0f, -40f); TextMeshProUGUI val5 = CreateText((Transform)(object)val4, "Title", fontSource, 42, (TextAlignmentOptions)514); RectTransform val6 = (RectTransform)((TMP_Text)val5).transform; val6.anchorMin = Vector2.zero; val6.anchorMax = Vector2.one; val6.offsetMin = Vector2.zero; val6.offsetMax = Vector2.zero; ((TMP_Text)val5).text = "VR Settings"; ((TMP_Text)val5).fontStyle = (FontStyles)1; RectTransform val7 = CreateChild("Viewport", (Transform)(object)val); val7.anchorMin = new Vector2(0.5f, 0f); val7.anchorMax = new Vector2(0.5f, 1f); val7.pivot = new Vector2(0.5f, 1f); val7.anchoredPosition = new Vector2(0f, -100f); val7.sizeDelta = new Vector2(820f, -140f); ((Component)val7).gameObject.AddComponent(); RectTransform content = CreateChild("Content", (Transform)(object)val7); content.anchorMin = new Vector2(0f, 1f); content.anchorMax = new Vector2(1f, 1f); content.pivot = new Vector2(0.5f, 1f); content.anchoredPosition = Vector2.zero; ScrollRect val8 = ((Component)val7).gameObject.AddComponent(); val8.content = content; val8.viewport = val7; val8.horizontal = false; val8.vertical = true; val8.movementType = (MovementType)2; val8.scrollSensitivity = 45f; val8.inertia = false; List> list = new List> { (float y) => BuildSliderRow((Transform)(object)content, fontSource, y, "Render Scale", 0.1f, 1f, 0.05f, Settings.renderScale, "0.00", "x", delegate(float value) { Settings.renderScale = value; XRSettings.eyeTextureResolutionScale = value; SaveSettings(logger); }), (float y) => BuildCycleRow((Transform)(object)content, fontSource, y, "Turn Style", TurnStyleOptions, TurnStyleLabels, Array.IndexOf(TurnStyleOptions, Settings.turnStyle), delegate(int index) { if (index >= 0 && index < TurnStyleOptions.Length) { Settings.turnStyle = TurnStyleOptions[index]; SaveSettings(logger); } }), (float y) => BuildSliderRow((Transform)(object)content, fontSource, y, "Smooth Turn Speed", 10f, 360f, 15f, Settings.smoothTurnSpeed, "0", " deg/s", delegate(float value) { Settings.smoothTurnSpeed = value; SaveSettings(logger); }), (float y) => BuildSliderRow((Transform)(object)content, fontSource, y, "Snap Turn Angle", 10f, 180f, 15f, Settings.snapTurnAngle, "0", " deg", delegate(float value) { Settings.snapTurnAngle = value; SaveSettings(logger); }), (float y) => BuildCycleRow((Transform)(object)content, fontSource, y, "Look Up Offset", LookUpStyleOptions, LookUpStyleLabels, Array.IndexOf(LookUpStyleOptions, Settings.lookUpStyle), delegate(int index) { if (index >= 0 && index < LookUpStyleOptions.Length) { Settings.lookUpStyle = LookUpStyleOptions[index]; SaveSettings(logger); } }), (float y) => BuildSliderRow((Transform)(object)content, fontSource, y, "Smooth Look Up Speed", 10f, 360f, 15f, Settings.smoothLookUpSpeed, "0", " deg/s", delegate(float value) { Settings.smoothLookUpSpeed = value; SaveSettings(logger); }), (float y) => BuildSliderRow((Transform)(object)content, fontSource, y, "Snap Look Up Angle", 5f, 45f, 5f, Settings.snapLookUpAngle, "0", " deg", delegate(float value) { Settings.snapLookUpAngle = value; SaveSettings(logger); }), (float y) => BuildSliderRow((Transform)(object)content, fontSource, y, "Head Pitch Multiplier", 1f, 10f, 0.25f, Settings.headPitchMultiplier, "0.00", "x", delegate(float value) { Settings.headPitchMultiplier = value; SaveSettings(logger); }), (float y) => BuildCycleRow((Transform)(object)content, fontSource, y, "Look Up Snap Back", OffOnOptions, OffOnLabels, Settings.lookUpSnapBack ? 1 : 0, delegate(int index) { Settings.lookUpSnapBack = index == 1; SaveSettings(logger); }), (float y) => BuildCycleRow((Transform)(object)content, fontSource, y, "Movement Relative To", MovementRelativeOptions, MovementRelativeLabels, Array.IndexOf(MovementRelativeOptions, Settings.movementRelative), delegate(int index) { if (index >= 0 && index < MovementRelativeOptions.Length) { Settings.movementRelative = MovementRelativeOptions[index]; SaveSettings(logger); } }), (float y) => BuildSliderRow((Transform)(object)content, fontSource, y, "Bag Time Dilation", 0.01f, 1f, 0.05f, Settings.bagTimeDilation, "0.00", "x", delegate(float value) { Settings.bagTimeDilation = value; SaveSettings(logger); }), (float y) => BuildCycleRow((Transform)(object)content, fontSource, y, "Climb Mode", ClimbModeOptions, ClimbModeLabels, Array.IndexOf(ClimbModeOptions, Settings.climbMode), delegate(int index) { if (index >= 0 && index < ClimbModeOptions.Length) { Settings.climbMode = ClimbModeOptions[index]; SaveSettings(logger); } }), (float y) => BuildCycleRow((Transform)(object)content, fontSource, y, "Swap Move/Turn Sticks", OffOnOptions, OffOnLabels, Settings.swapTurnAndMoveSticks ? 1 : 0, delegate(int index) { Settings.swapTurnAndMoveSticks = index == 1; SaveSettings(logger); }), (float y) => BuildCycleRow((Transform)(object)content, fontSource, y, "Swap Stick Buttons", OffOnOptions, OffOnLabels, Settings.swapStickButtons ? 1 : 0, delegate(int index) { Settings.swapStickButtons = index == 1; SaveSettings(logger); }), (float y) => BuildCycleRow((Transform)(object)content, fontSource, y, "Toggle Crouch", OffOnOptions, OffOnLabels, Settings.toggleCrouch ? 1 : 0, delegate(int index) { Settings.toggleCrouch = index == 1; SaveSettings(logger); }), (float y) => BuildCycleRow((Transform)(object)content, fontSource, y, "Toggle Inventory", OffOnOptions, OffOnLabels, Settings.toggleInventory ? 1 : 0, delegate(int index) { Settings.toggleInventory = index == 1; SaveSettings(logger); }) }; ResizeContentForRows(content, list.Count, 76f); float num = -10f; List<(Selectable, Selectable)> list2 = new List<(Selectable, Selectable)>(); foreach (Func item in list) { list2.Add(item(num)); num -= 76f; } Button val9 = BuildBackButton((Transform)(object)content, fontSource, num - 14f, canvasGroup, val3); ((Component)val7).gameObject.AddComponent().Initialize(val8, content, val7); for (int num2 = 0; num2 < list2.Count; num2++) { LinkHorizontal(list2[num2].Item1, list2[num2].Item2); Selectable down = (Selectable)((num2 + 1 < list2.Count) ? ((object)list2[num2 + 1].Item1) : ((object)val9)); Selectable down2 = (Selectable)((num2 + 1 < list2.Count) ? ((object)list2[num2 + 1].Item2) : ((object)val9)); LinkVertical(list2[num2].Item1, down); LinkVertical(list2[num2].Item2, down2); } Selectable firstSelectable = list2[0].Item1; ((Component)firstSelectable).gameObject.AddComponent(); val3.openEvent.AddListener((UnityAction)delegate { canvasGroup.alpha = 1f; canvasGroup.blocksRaycasts = true; firstSelectable.Select(); }); return ((Component)val).gameObject; } private static void LinkHorizontal(Selectable left, Selectable right) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) Navigation navigation = left.navigation; ((Navigation)(ref navigation)).mode = (Mode)4; ((Navigation)(ref navigation)).selectOnRight = right; left.navigation = navigation; Navigation navigation2 = right.navigation; ((Navigation)(ref navigation2)).mode = (Mode)4; ((Navigation)(ref navigation2)).selectOnLeft = left; right.navigation = navigation2; } private static void LinkVertical(Selectable up, Selectable down) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) Navigation navigation = up.navigation; ((Navigation)(ref navigation)).mode = (Mode)4; ((Navigation)(ref navigation)).selectOnDown = down; up.navigation = navigation; Navigation navigation2 = down.navigation; ((Navigation)(ref navigation2)).mode = (Mode)4; ((Navigation)(ref navigation2)).selectOnUp = up; down.navigation = navigation2; } private static void SaveSettings(ManualLogSource logger) { VRSettingsManager.Save(Settings, logger); } private static RectTransform CreateChild(string name, Transform parent) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) }); RectTransform component = val.GetComponent(); ((Transform)component).SetParent(parent, false); return component; } private static TextMeshProUGUI CreateText(Transform parent, string name, TextMeshProUGUI fontSource, int fontSize, TextAlignmentOptions alignment) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) RectTransform val = CreateChild(name, parent); TextMeshProUGUI val2 = ((Component)val).gameObject.AddComponent(); ((TMP_Text)val2).font = ((TMP_Text)fontSource).font; ((TMP_Text)val2).fontSharedMaterial = ((TMP_Text)fontSource).fontSharedMaterial; ((TMP_Text)val2).fontSize = fontSize; ((TMP_Text)val2).alignment = alignment; ((Graphic)val2).color = TextColor; ((Graphic)val2).raycastTarget = false; return val2; } private static Button CreateSmallButton(Transform parent, string name, TextMeshProUGUI fontSource, string label, Vector2 anchoredPosition, Vector2 size) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Expected O, but got Unknown //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) RectTransform val = CreateChild(name, parent); val.sizeDelta = size; val.anchoredPosition = anchoredPosition; Image val2 = ((Component)val).gameObject.AddComponent(); ((Graphic)val2).color = Color.white; Button val3 = ((Component)val).gameObject.AddComponent