using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Timers; using AmplifyOcclusion; using BepInEx; using BepInEx.Configuration; using Bhaptics.Tact; using GUIFramework; using HarmonyLib; using Microsoft.CodeAnalysis; using NDesk.Options; using RootMotion.FinalIK; using TMPro; using Unity.XR.OpenVR; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.InputSystem; using UnityEngine.InputSystem.UI; using UnityEngine.PostProcessing; using UnityEngine.Rendering; using UnityEngine.SceneManagement; using UnityEngine.SpatialTracking; using UnityEngine.UI; using UnityEngine.XR; using UnityEngine.XR.Management; using UnityStandardAssets.ImageEffects; using Valheim.SettingsGui; using ValheimVRMod.Patches; using ValheimVRMod.Scripts; using ValheimVRMod.Scripts.Block; using ValheimVRMod.Scripts.PostProcessing; using ValheimVRMod.Utilities; using ValheimVRMod.VRCore; using ValheimVRMod.VRCore.UI; using ValheimVRMod.VRCore.UI.HudElements; using Valve.Newtonsoft.Json; using Valve.VR; using Valve.VR.Extras; using Valve.VR.InteractionSystem; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("ValheimVRMod")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("ValheimVRMod")] [assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("86b846a5-747b-47dc-ac73-fda218e4361f")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class IsReadOnlyAttribute : Attribute { } } internal class FogComponentPatches { [HarmonyPatch(typeof(FogComponent), "PopulateCommandBuffer")] private class FogComponent_PopulateCommandBuffer_Patch { private static class Uniforms { internal static readonly int _FogColor = Shader.PropertyToID("_FogColor"); internal static readonly int _Density = Shader.PropertyToID("_Density"); internal static readonly int _Start = Shader.PropertyToID("_Start"); internal static readonly int _End = Shader.PropertyToID("_End"); internal static readonly int _TempRT = Shader.PropertyToID("_TempRT"); internal static readonly int _TopLeft = Shader.PropertyToID("_TopLeft"); internal static readonly int _TopRight = Shader.PropertyToID("_TopRight"); internal static readonly int _BottomLeft = Shader.PropertyToID("_BottomLeft"); internal static readonly int _BottomRight = Shader.PropertyToID("_BottomRight"); internal static readonly int _SunDir = Shader.PropertyToID("_SunDir"); internal static readonly int _SunFogColor = Shader.PropertyToID("_SunFogColor"); } private static Vector3[] _frustumCornersBuffer = (Vector3[])(object)new Vector3[4]; private static bool Prefix(CommandBuffer cb, FogComponent __instance) { //IL_001b: 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_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_005c: 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_00d1: 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_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) //IL_00fe: 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_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_011a: 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_0124: 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_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0141: 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_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0165: 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_0178: 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_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_018c: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0190: 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) //IL_01a5: Expected I4, but got Unknown //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_022f: 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) if (VHVRConfig.NonVrPlayer()) { return true; } Settings settings = ((PostProcessingComponent)(object)__instance).model.settings; Material val = ((PostProcessingComponentBase)__instance).context.materialFactory.Get("Hidden/Post FX/Fog"); val.shaderKeywords = null; int fogColor = Uniforms._FogColor; Color val2; if (!GraphicsUtils.isLinearColorSpace) { val2 = RenderSettings.fogColor; } else { Color fogColor2 = RenderSettings.fogColor; val2 = ((Color)(ref fogColor2)).linear; } val.SetColor(fogColor, val2); val.SetFloat(Uniforms._Density, Mathf.Lerp(RenderSettings.fogDensity, 0.125f, UnderwaterEffectsUpdater.Underwaterness)); val.SetFloat(Uniforms._Start, RenderSettings.fogStartDistance); val.SetFloat(Uniforms._End, RenderSettings.fogEndDistance); Camera camera = ((PostProcessingComponentBase)__instance).context.camera; Transform transform = ((Component)camera).transform; camera.CalculateFrustumCorners(new Rect(0f, 0f, 1f, 1f), camera.farClipPlane, camera.stereoActiveEye, _frustumCornersBuffer); Vector3 val3 = transform.TransformVector(_frustumCornersBuffer[1]); Vector3 val4 = transform.TransformVector(_frustumCornersBuffer[2]); Vector3 val5 = transform.TransformVector(_frustumCornersBuffer[0]); Vector3 val6 = transform.TransformVector(_frustumCornersBuffer[3]); val.SetVector(Uniforms._TopLeft, Vector4.op_Implicit(val3)); val.SetVector(Uniforms._TopRight, Vector4.op_Implicit(val4)); val.SetVector(Uniforms._BottomLeft, Vector4.op_Implicit(val5)); val.SetVector(Uniforms._BottomRight, Vector4.op_Implicit(val6)); FogMode fogMode = RenderSettings.fogMode; FogMode val7 = fogMode; switch (val7 - 1) { case 0: val.EnableKeyword("FOG_LINEAR"); break; case 1: val.EnableKeyword("FOG_EXP"); break; case 2: val.EnableKeyword("FOG_EXP2"); break; } RenderTextureFormat val8 = (RenderTextureFormat)(((PostProcessingComponentBase)__instance).context.isHdr ? 9 : 7); cb.GetTemporaryRT(Uniforms._TempRT, ((PostProcessingComponentBase)__instance).context.width, ((PostProcessingComponentBase)__instance).context.height, 24, (FilterMode)1, val8); cb.Blit(RenderTargetIdentifier.op_Implicit((BuiltinRenderTextureType)2), RenderTargetIdentifier.op_Implicit(Uniforms._TempRT)); cb.Blit(RenderTargetIdentifier.op_Implicit(Uniforms._TempRT), RenderTargetIdentifier.op_Implicit((BuiltinRenderTextureType)2), val, settings.excludeSkybox ? 1 : 0); cb.ReleaseTemporaryRT(Uniforms._TempRT); return false; } } } [DisallowMultipleComponent] public class Outline : MonoBehaviour { public enum Mode { OutlineAll, OutlineVisible, OutlineHidden, OutlineAndSilhouette, SilhouetteOnly } [Serializable] private class ListVector3 { public List data; } private static HashSet registeredMeshes = new HashSet(); [SerializeField] private Mode outlineMode; [SerializeField] private Color outlineColor = Color.white; [SerializeField] [Range(0f, 10f)] private float outlineWidth = 2f; [Header("Optional")] [SerializeField] [Tooltip("Precompute enabled: Per-vertex calculations are performed in the editor and serialized with the object. Precompute disabled: Per-vertex calculations are performed at runtime in Awake(). This may cause a pause for large meshes.")] private bool precomputeOutline; [SerializeField] [HideInInspector] private List bakeKeys = new List(); [SerializeField] [HideInInspector] private List bakeValues = new List(); private Renderer[] renderers; private static Material sharedOutlineMaskMaterial; private static Material sharedOutlineFillMaterial; private Material outlineMaskMaterial; private Material outlineFillMaterial; private bool needsUpdate; public Mode OutlineMode { get { return outlineMode; } set { outlineMode = value; needsUpdate = true; } } public Color OutlineColor { get { //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_000a: Unknown result type (might be due to invalid IL or missing references) return outlineColor; } set { //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) outlineColor = value; needsUpdate = true; } } public float OutlineWidth { get { return outlineWidth; } set { outlineWidth = value; needsUpdate = true; } } private void Awake() { renderers = ((Component)this).GetComponentsInChildren(); tryInitMaterials(); LoadSmoothNormals(); needsUpdate = true; } private void tryInitMaterials() { //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Expected O, but got Unknown //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown if (!((Object)(object)outlineMaskMaterial != (Object)null) || !((Object)(object)outlineFillMaterial != (Object)null)) { if ((Object)(object)sharedOutlineMaskMaterial == (Object)null) { sharedOutlineMaskMaterial = Object.Instantiate(VRAssetManager.GetAsset("OutlineMask")); ((Object)sharedOutlineMaskMaterial).name = "OutlineMask (Instance)"; } if ((Object)(object)sharedOutlineFillMaterial == (Object)null) { sharedOutlineFillMaterial = Object.Instantiate(VRAssetManager.GetAsset("OutlineFill")); ((Object)sharedOutlineMaskMaterial).name = "OutlineFill (Instance)"; } outlineMaskMaterial = new Material(sharedOutlineMaskMaterial); outlineFillMaterial = new Material(sharedOutlineFillMaterial); } } private bool IsPlayerHairMaterials(List materials) { foreach (Material material in materials) { if (((Object)material).name.StartsWith("PlayerHair")) { return true; } } return false; } private void OnEnable() { Renderer[] array = renderers; foreach (Renderer val in array) { if (!(((object)val).GetType() == typeof(ParticleSystemRenderer))) { List list = val.sharedMaterials.ToList(); if (!IsPlayerHairMaterials(list)) { list.Add(outlineMaskMaterial); list.Add(outlineFillMaterial); val.materials = list.ToArray(); } } } } private void OnValidate() { needsUpdate = true; if ((!precomputeOutline && bakeKeys.Count != 0) || bakeKeys.Count != bakeValues.Count) { bakeKeys.Clear(); bakeValues.Clear(); } if (precomputeOutline && bakeKeys.Count == 0) { Bake(); } } private void Update() { if (needsUpdate) { needsUpdate = false; UpdateMaterialProperties(); } } private void OnDisable() { Renderer[] array = renderers; foreach (Renderer val in array) { if (!((Object)(object)val == (Object)null) && !(((object)val).GetType() == typeof(ParticleSystemRenderer)) && val.sharedMaterials != null) { List list = val.sharedMaterials.ToList(); list.Remove(outlineMaskMaterial); list.Remove(outlineFillMaterial); val.materials = list.ToArray(); } } } private void Bake() { HashSet hashSet = new HashSet(); MeshFilter[] componentsInChildren = ((Component)this).GetComponentsInChildren(); foreach (MeshFilter val in componentsInChildren) { if (hashSet.Add(val.sharedMesh)) { List data = SmoothNormals(val.sharedMesh); bakeKeys.Add(val.sharedMesh); bakeValues.Add(new ListVector3 { data = data }); } } } private void LoadSmoothNormals() { MeshFilter[] componentsInChildren = ((Component)this).GetComponentsInChildren(); foreach (MeshFilter val in componentsInChildren) { if (val.sharedMesh.isReadable && registeredMeshes.Add(val.sharedMesh)) { int num = bakeKeys.IndexOf(val.sharedMesh); List list = ((num >= 0) ? bakeValues[num].data : SmoothNormals(val.sharedMesh)); val.sharedMesh.SetUVs(3, list); } } SkinnedMeshRenderer[] componentsInChildren2 = ((Component)this).GetComponentsInChildren(); foreach (SkinnedMeshRenderer val2 in componentsInChildren2) { if (val2.sharedMesh.isReadable && registeredMeshes.Add(val2.sharedMesh)) { val2.sharedMesh.uv4 = (Vector2[])(object)new Vector2[val2.sharedMesh.vertexCount]; } } } private List SmoothNormals(Mesh mesh) { //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: 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_00b1: 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_00fb: Unknown result type (might be due to invalid IL or missing references) IEnumerable>> enumerable = from pair in mesh.vertices.Select((Vector3 vertex, int index) => new KeyValuePair(vertex, index)) group pair by pair.Key; List list = new List(mesh.normals); foreach (IGrouping> item in enumerable) { if (item.Count() == 1) { continue; } Vector3 val = Vector3.zero; foreach (KeyValuePair item2 in item) { val += mesh.normals[item2.Value]; } ((Vector3)(ref val)).Normalize(); foreach (KeyValuePair item3 in item) { list[item3.Value] = val; } } return list; } private void UpdateMaterialProperties() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) outlineFillMaterial.SetColor("_OutlineColor", outlineColor); switch (outlineMode) { case Mode.OutlineAll: outlineMaskMaterial.SetFloat("_ZTest", 8f); outlineFillMaterial.SetFloat("_ZTest", 8f); outlineFillMaterial.SetFloat("_OutlineWidth", outlineWidth); break; case Mode.OutlineVisible: outlineMaskMaterial.SetFloat("_ZTest", 8f); outlineFillMaterial.SetFloat("_ZTest", 4f); outlineFillMaterial.SetFloat("_OutlineWidth", outlineWidth); break; case Mode.OutlineHidden: outlineMaskMaterial.SetFloat("_ZTest", 8f); outlineFillMaterial.SetFloat("_ZTest", 5f); outlineFillMaterial.SetFloat("_OutlineWidth", outlineWidth); break; case Mode.OutlineAndSilhouette: outlineMaskMaterial.SetFloat("_ZTest", 4f); outlineFillMaterial.SetFloat("_ZTest", 8f); outlineFillMaterial.SetFloat("_OutlineWidth", outlineWidth); break; case Mode.SilhouetteOnly: outlineMaskMaterial.SetFloat("_ZTest", 4f); outlineFillMaterial.SetFloat("_ZTest", 5f); outlineFillMaterial.SetFloat("_OutlineWidth", 0f); break; } } } namespace ValheimVRMod { [BepInPlugin("org.bepinex.plugins.valheimvrmod", "ValheimVR Mod", "0.9.20")] public class ValheimVRMod : BaseUnityPlugin { private static Version _version; private GameObject vrPlayer; private GameObject vrGui; private GameObject BhapticsTactsuit; public static Version PLUGIN_VERSION => _version; public static bool failedToInitializeVR { get; private set; } private void Awake() { _version = ((BaseUnityPlugin)this).Info.Metadata.Version; VHVRConfig.InitializeConfiguration(((BaseUnityPlugin)this).Config); LogUtils.LogInfo("Pre-release VHVR"); if (!VHVRConfig.ModEnabled()) { LogUtils.LogInfo("ValheimVRMod is disabled via configuration."); ((Behaviour)this).enabled = false; } else { Game.isModded = true; LogUtils.LogInfo("ValheimVR Mod Awakens!"); } } private void Start() { StartValheimVR(); } private void Update() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) if (!VHVRConfig.NonVrPlayer()) { if (Input.GetKeyDown(VHVRConfig.GetRecenterKey())) { VRManager.tryRecenter(); } if (!Input.GetKeyDown((KeyCode)92)) { } } } private void StartValheimVR() { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Expected O, but got Unknown //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Expected O, but got Unknown bool flag = false; if (!VHVRConfig.NonVrPlayer()) { flag = VRManager.InitializeVR(); if (!flag) { LogUtils.LogError("Could not initialize VR."); failedToInitializeVR = true; } } HarmonyPatcher.DoPatching(); if (!VRAssetManager.Initialize()) { LogUtils.LogError("Problem initializing VR Assets"); flag = false; } if (!flag) { LogUtils.LogDebug("Non VR Mode Patching Complete."); return; } VRManager.StartVR(); vrPlayer = new GameObject("VRPlayer"); Object.DontDestroyOnLoad((Object)(object)vrPlayer); vrPlayer.AddComponent(); vrGui = new GameObject("VRGui"); Object.DontDestroyOnLoad((Object)(object)vrGui); vrGui.AddComponent(); if (VHVRConfig.RecenterOnStart()) { VRManager.tryRecenter(); } if (VHVRConfig.BhapticsEnabled()) { BhapticsTactsuit = new GameObject("BhapticsTactsuit"); Object.DontDestroyOnLoad((Object)(object)BhapticsTactsuit); BhapticsTactsuit.AddComponent(); } } private void dumpall() { GameObject[] array = Object.FindObjectsOfType(); foreach (GameObject val in array) { LogUtils.LogDebug("Name + " + ((Object)val).name + " Layer = " + val.layer); } } } } namespace ValheimVRMod.VRCore { internal class VRManager { public static bool InitializeVR() { LogUtils.LogDebug("PreInitializing SteamVR Actions..."); SteamVR_Actions.PreInitialize(); LogUtils.LogInfo("Initializing VR..."); if (!InitXRSDK()) { LogUtils.LogError("Failed to initialize VR!."); return false; } if (!InitializeSteamVR()) { LogUtils.LogError("Problem initializing SteamVR"); return false; } return true; } public static bool StartVR() { LogUtils.LogInfo("Starting VR..."); return StartXRSDK(); } public static bool InitializeSteamVR() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Invalid comparison between Unknown and I4 LogUtils.LogInfo("Initializing SteamVR..."); SteamVR.Initialize(false); if ((int)SteamVR.initializedState != 2) { LogUtils.LogError("Problem Initializing SteamVR"); return false; } if (!SteamVR_Input.initialized) { LogUtils.LogError("Problem Initializing SteamVR_Input"); return false; } ApplicationManifestHelper.UpdateManifest(Path.Combine(Application.streamingAssetsPath, "valheim.vrmanifest"), "steam.app.892970", "https://steamcdn-a.akamaihd.net/steam/apps/892970/header.jpg", "Valheim VR", "VR mod for Valheim", 892970, steamBuild: true); return true; } private static bool StartXRSDK() { LogUtils.LogInfo("Starting XRSDK!"); if ((Object)(object)XRGeneralSettings.Instance != (Object)null && (Object)(object)XRGeneralSettings.Instance.Manager != (Object)null && (Object)(object)XRGeneralSettings.Instance.Manager.activeLoader != (Object)null) { XRGeneralSettings.Instance.Manager.StartSubsystems(); } else { LogUtils.LogError("Error Starting XRSDK!"); if ((Object)(object)XRGeneralSettings.Instance == (Object)null) { LogUtils.LogError("XRGeneralSettings Instance is null!"); return false; } if ((Object)(object)XRGeneralSettings.Instance.Manager == (Object)null) { LogUtils.LogError("XRManager instance is null!"); return false; } if ((Object)(object)XRGeneralSettings.Instance.Manager.activeLoader == (Object)null) { LogUtils.LogError("Active loader is null!"); return false; } } return true; } private static bool InitXRSDK() { XRGeneralSettings val = LoadXRSettingsFromAssetBundle(); if ((Object)(object)val == (Object)null) { LogUtils.LogInfo("XRGeneralSettings Instance is null!"); return false; } LogUtils.LogDebug("Loaded XRGeneralSettings!"); return InitializeXRSDKLoaders(val.Manager); } private static XRGeneralSettings LoadXRSettingsFromAssetBundle() { string text = Path.Combine(Application.streamingAssetsPath, "xrmanager"); LogUtils.LogDebug("Loading XR Settings from AssetBundle: " + text); AssetBundle val = AssetBundle.LoadFromFile(text); Object[] array = val.LoadAllAssets(); foreach (Object val2 in array) { LogUtils.LogDebug("XRManagement Asset Loaded: " + val2.name); } XRGeneralSettings instance = XRGeneralSettings.Instance; if ((Object)(object)instance == (Object)null) { LogUtils.LogError("XRGeneralSettings Instance is null!"); return null; } LogUtils.LogDebug("XRGeneralSettings Instance is non-null."); return instance; } private static bool InitializeXRSDKLoaders(XRManagerSettings managerSettings) { //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_00c5: Unknown result type (might be due to invalid IL or missing references) LogUtils.LogDebug("Initializing XRSDK Loaders..."); if ((Object)(object)managerSettings == (Object)null) { LogUtils.LogError("XRManagerSettings instance is null, cannot initialize loader."); return false; } int num = 0; do { managerSettings.InitializeLoaderSync(); num++; } while ((Object)(object)managerSettings.activeLoader == (Object)null && num < VHVRConfig.MaxVRInitializationTries()); if ((Object)(object)managerSettings.activeLoader == (Object)null) { LogUtils.LogError("managerSettings.activeLoader is null after " + num + " tries."); return false; } OpenVRSettings settings = OpenVRSettings.GetSettings(false); if ((Object)(object)settings != (Object)null) { MirrorViewModes mirrorViewMode = VHVRConfig.GetMirrorViewMode(); LogUtils.LogInfo("Mirror View Mode: " + ((object)(MirrorViewModes)(ref mirrorViewMode)).ToString()); settings.SetMirrorViewMode(mirrorViewMode); } LogUtils.LogDebug("Got non-null Active Loader."); return true; } public static void tryRecenter() { if (VRPlayer.ShouldPauseMovement) { return; } List list = new List(); SubsystemManager.GetInstances(list); foreach (XRInputSubsystem item in list) { LogUtils.LogDebug("Recentering Input Subsystem: " + (object)item); item.TryRecenter(); } VRPlayer.RequestRecentering(); VRPlayer.RequestPelvisCaliberation(); VRPlayer.vrPlayerInstance?.ResetRoomscaleCamera(); } private static void PrintSteamVRSettings() { SteamVR_Settings instance = SteamVR_Settings.instance; if ((Object)(object)instance == (Object)null) { LogUtils.LogWarning("SteamVR Settings are null."); return; } LogUtils.LogDebug("SteamVR Settings:"); LogUtils.LogDebug(" actionsFilePath: " + instance.actionsFilePath); LogUtils.LogDebug(" editorAppKey: " + instance.editorAppKey); LogUtils.LogDebug(" activateFirstActionSetOnStart: " + instance.activateFirstActionSetOnStart); LogUtils.LogDebug(" autoEnableVR: " + instance.autoEnableVR); LogUtils.LogDebug(" inputUpdateMode: " + ((object)(SteamVR_UpdateModes)(ref instance.inputUpdateMode)).ToString()); LogUtils.LogDebug(" legacyMixedRealityCamera: " + instance.legacyMixedRealityCamera); LogUtils.LogDebug(" mixedRealityCameraPose: " + (object)instance.mixedRealityCameraPose); LogUtils.LogDebug(" lockPhysicsUpdateRateToRenderFrequency: " + instance.lockPhysicsUpdateRateToRenderFrequency); LogUtils.LogDebug(" mixedRealityActionSetAutoEnable: " + instance.mixedRealityActionSetAutoEnable); LogUtils.LogDebug(" mixedRealityCameraInputSource: " + ((object)(SteamVR_Input_Sources)(ref instance.mixedRealityCameraInputSource)).ToString()); LogUtils.LogDebug(" mixedRealityCameraPose: " + (object)instance.mixedRealityCameraPose); LogUtils.LogDebug(" pauseGameWhenDashboardVisible: " + instance.pauseGameWhenDashboardVisible); LogUtils.LogDebug(" poseUpdateMode: " + ((object)(SteamVR_UpdateModes)(ref instance.poseUpdateMode)).ToString()); LogUtils.LogDebug(" previewHandLeft: " + (object)instance.previewHandLeft); LogUtils.LogDebug(" previewHandRight: " + (object)instance.previewHandRight); LogUtils.LogDebug(" steamVRInputPath: " + instance.steamVRInputPath); } private static void PrintOpenVRSettings() { OpenVRSettings settings = OpenVRSettings.GetSettings(false); if ((Object)(object)settings == (Object)null) { LogUtils.LogWarning("OpenVRSettings are null."); return; } LogUtils.LogDebug("OpenVR Settings:"); LogUtils.LogDebug(" StereoRenderingMode: " + ((object)(StereoRenderingModes)(ref settings.StereoRenderingMode)).ToString()); LogUtils.LogDebug(" InitializationType: " + ((object)(InitializationTypes)(ref settings.InitializationType)).ToString()); LogUtils.LogDebug(" ActionManifestFileRelativeFilePath: " + settings.ActionManifestFileRelativeFilePath); LogUtils.LogDebug(" MirrorView: " + ((object)(MirrorViewModes)(ref settings.MirrorView)).ToString()); } private static void PrintUnityXRSettings() { //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_0051: 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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) LogUtils.LogDebug("Unity.XR.XRSettings: "); LogUtils.LogDebug(" enabled: " + XRSettings.enabled); TextureDimension deviceEyeTextureDimension = XRSettings.deviceEyeTextureDimension; LogUtils.LogDebug(" deviceEyeTextureDimension: " + ((object)(TextureDimension)(ref deviceEyeTextureDimension)).ToString()); RenderTextureDescriptor eyeTextureDesc = XRSettings.eyeTextureDesc; LogUtils.LogDebug(" eyeTextureDesc: " + ((object)(RenderTextureDescriptor)(ref eyeTextureDesc)).ToString()); LogUtils.LogDebug(" eyeTextureHeight: " + XRSettings.eyeTextureHeight); LogUtils.LogDebug(" eyeTextureResolutionScale: " + XRSettings.eyeTextureResolutionScale); LogUtils.LogDebug(" eyeTextureWidth: " + XRSettings.eyeTextureWidth); GameViewRenderMode gameViewRenderMode = XRSettings.gameViewRenderMode; LogUtils.LogDebug(" gameViewRenderMode: " + ((object)(GameViewRenderMode)(ref gameViewRenderMode)).ToString()); LogUtils.LogDebug(" isDeviceActive: " + XRSettings.isDeviceActive); LogUtils.LogDebug(" loadedDeviceName: " + XRSettings.loadedDeviceName); LogUtils.LogDebug(" occlusionMaskScale: " + XRSettings.occlusionMaskScale); LogUtils.LogDebug(" renderViewportScale: " + XRSettings.renderViewportScale); LogUtils.LogDebug(" showDeviceView: " + XRSettings.showDeviceView); StereoRenderingMode stereoRenderingMode = XRSettings.stereoRenderingMode; LogUtils.LogDebug(" stereoRenderingMode: " + ((object)(StereoRenderingMode)(ref stereoRenderingMode)).ToString()); LogUtils.LogDebug(" supportedDevices: " + XRSettings.supportedDevices); LogUtils.LogDebug(" useOcclusionMesh: " + XRSettings.useOcclusionMesh); } } internal class VRPlayer : MonoBehaviour { private enum HeadZoomLevel { FirstPerson, ThirdPerson0, ThirdPerson1, ThirdPerson2, ThirdPerson3 } private static readonly string PLAYER_PREFAB_NAME = "ValheimVRPlayer"; private static readonly string START_SCENE = "start"; public static readonly string RIGHT_HAND = "RightHand"; public static readonly string LEFT_HAND = "LeftHand"; private const float MAX_ROOMSCALE_MOVEMENT_SPEED = 4f; private static Vector3 firstPersonOffset = Vector3.zero; private static float CROUCH_HEIGHT_ADJUST = -0.4f; private static float RIDE_HEIGHT_ADJUST = -0.85f; private static float SIT_ATTACH_HEIGHT_ADJUST = -0.6f; private static float SIT_HEIGHT_ADJUST = -0.7f; private static Vector3 THIRD_PERSON_0_OFFSET = new Vector3(0f, 1f, -0.6f); private static Vector3 THIRD_PERSON_1_OFFSET = new Vector3(0f, 1.4f, -1.5f); private static Vector3 THIRD_PERSON_2_OFFSET = new Vector3(0f, 1.9f, -2.6f); private static Vector3 THIRD_PERSON_3_OFFSET = new Vector3(0f, 3.2f, -4.4f); private static Vector3 THIRD_PERSON_CONFIG_OFFSET = Vector3.zero; private const float NECK_OFFSET = 0.25f; public const float ROOMSCALE_STEP_ANIMATION_SMOOTHING = 0.3f; public const float ROOMSCALE_ANIMATION_WEIGHT = 2f; private static MeshRenderer hipTrackerRenderer; private Vector3 initialRoomscaleLocomotiveOffsetFromHead; private static bool _isRoomscaleSneaking = false; public static bool offHandWield; private static GameObject _prefab; private static GameObject _instance; private static VRPlayer _vrPlayerInstance; private static HeadZoomLevel _headZoomLevel = HeadZoomLevel.FirstPerson; private Camera _vrCam; private Camera _handsCam; private Camera _skyboxCam; private Camera _thirdPersonCamera; private Transform _vrCameraRig; private Vector3 lastRoomscaleLocomotivePosition = Vector3.zero; private Vector3 _lastPlayerPosition = Vector3.zero; private Vector3 _lastPlayerAttachmentPosition = Vector3.zero; private FadingManager _fadeManager; private float _forwardSmoothVel = 0f; private float _sideSmoothVel = 0f; private static float _roomscaleAnimationForwardSpeed = 0f; private static float _roomscaleAnimationSideSpeed = 0f; private static SteamVR_LaserPointer _leftPointer; private static SteamVR_LaserPointer _rightPointer; private string _preferredHand; private Vector3 roomLocalPositionBeforeDodge; private Transform _dodgingRoom; private bool pausedMovement = false; private float timerLeft; private float timerRight; private static float baseFootHeight; public static bool attachedToPlayer = false; private static float? firstPersonHeightOffset = null; private static bool bodyTrackingCaliberationPending; private static Vector3 caliberatedPelvisLocalPosition = Vector3.zero; private static Quaternion caliberatedPelvisLocalRotation = Quaternion.identity; private static SteamVR_TrackedObject[] trackedObjects = (SteamVR_TrackedObject[])(object)new SteamVR_TrackedObject[32]; private static int hipTrackerIndex = 0; public static float MainCameraFarClipPlane { get; private set; } public static VRIK vrikRef { get; private set; } private static SteamVR_TrackedObject hipTracker => trackedObjects[hipTrackerIndex]; public static Transform pelvis { get; private set; } private Vector3 roomscaleLocomotive => (VHVRConfig.IsHipTrackingEnabled() && (Object)(object)hipTracker != (Object)null && hipTracker.isValid) ? ((Component)hipTracker).transform.localPosition : ((Component)_vrCam).transform.localPosition; public static Camera vrCam => ((Object)(object)vrPlayerInstance != (Object)null) ? vrPlayerInstance._vrCam : null; public static float referencePlayerHeight { get; private set; } public static bool startingSit { get; private set; } public static bool isRoomscaleSneaking => _isRoomscaleSneaking; public static float roomscaleAnimationForwardSpeed => _roomscaleAnimationForwardSpeed; public static float roomscaleAnimationSideSpeed => _roomscaleAnimationSideSpeed; public static Vector3 roomscaleMovement { get; private set; } public bool wasDodging { get; private set; } = false; public static GesturedLocomotionManager gesturedLocomotionManager { get; private set; } = null; private Transform dodgingRoom => ((Object)(object)_dodgingRoom == (Object)null) ? (_dodgingRoom = new GameObject().transform) : _dodgingRoom; public static Hand leftHand { get; private set; } public static Hand rightHand { get; private set; } public static Transform leftHandBone { get; private set; } public static Transform rightHandBone { get; private set; } public static bool isLeftHandMainWeaponHand => VHVRConfig.LeftHanded() ^ offHandWield; public static bool isRightHandMainWeaponHand => VHVRConfig.LeftHanded() ^ !offHandWield; public static ItemData leftHandItem => isRightHandMainWeaponHand ? ((Humanoid)Player.m_localPlayer).GetLeftItem() : ((Humanoid)Player.m_localPlayer).GetRightItem(); public static ItemData rightHandItem => isRightHandMainWeaponHand ? ((Humanoid)Player.m_localPlayer).GetRightItem() : ((Humanoid)Player.m_localPlayer).GetLeftItem(); public static Hand mainWeaponHand => isRightHandMainWeaponHand ? rightHand : leftHand; public static Hand arrowHand => (VHVRConfig.LeftHanded() ^ offHandWield) ? leftHand : rightHand; public static Hand bowHand => (VHVRConfig.LeftHanded() ^ offHandWield) ? rightHand : leftHand; public static bool ShouldPauseMovement => PlayerCustomizaton.IsBarberGuiVisible() || (Menu.IsVisible() && !VHVRConfig.AllowMovementWhenInMenu()); public static bool IsClickableGuiOpen => Hud.IsPieceSelectionVisible() || StoreGui.IsVisible() || InventoryGui.IsVisible() || Menu.IsVisible() || (Object.op_Implicit((Object)(object)TextViewer.instance) && TextViewer.instance.IsVisible()) || Minimap.IsOpen(); public static PhysicsEstimator leftHandPhysicsEstimator { get { PhysicsEstimator physicsEstimator = ((Component)leftHand).gameObject.GetComponent(); if ((Object)(object)physicsEstimator == (Object)null && attachedToPlayer) { physicsEstimator = ((Component)leftHand).gameObject.AddComponent(); physicsEstimator.UseVrHandControllerPhysics(leftHand); PhysicsEstimator physicsEstimator2 = physicsEstimator; Camera camera = CameraUtils.getCamera("VRCamera"); physicsEstimator2.refTransform = ((camera != null) ? ((Component)camera).transform.parent : null); } return physicsEstimator; } } public static PhysicsEstimator rightHandPhysicsEstimator { get { PhysicsEstimator physicsEstimator = ((Component)rightHand).gameObject.GetComponent(); if ((Object)(object)physicsEstimator == (Object)null && attachedToPlayer) { physicsEstimator = ((Component)rightHand).gameObject.AddComponent(); physicsEstimator.UseVrHandControllerPhysics(rightHand); PhysicsEstimator physicsEstimator2 = physicsEstimator; Camera camera = CameraUtils.getCamera("VRCamera"); physicsEstimator2.refTransform = ((camera != null) ? ((Component)camera).transform.parent : null); } return physicsEstimator; } } public static PhysicsEstimator headPhysicsEstimator { get { Camera camera = CameraUtils.getCamera("VRCamera"); if ((Object)(object)camera == (Object)null) { return null; } PhysicsEstimator physicsEstimator = ((Component)camera).GetComponent(); if ((Object)(object)physicsEstimator == (Object)null && attachedToPlayer) { physicsEstimator = ((Component)camera).gameObject.AddComponent(); physicsEstimator.refTransform = ((Component)camera).transform.parent; } return physicsEstimator; } } public static PhysicsEstimator leftFootPhysicsEstimator { get; private set; } public static PhysicsEstimator rightFootPhysicsEstimator { get; private set; } public static float leftFootElevation => ((Object)(object)leftFoot.parent == (Object)null || (Object)(object)vrPlayerInstance == (Object)null) ? 0f : (vrPlayerInstance._vrCameraRig.InverseTransformPoint(leftFoot.position).y - baseFootHeight); public static float rightFootElevation => ((Object)(object)rightFoot.parent == (Object)null || (Object)(object)vrPlayerInstance == (Object)null) ? 0f : (vrPlayerInstance._vrCameraRig.InverseTransformPoint(rightFoot.position).y - baseFootHeight); public static SteamVR_Input_Sources mainWeaponHandInputSource => (SteamVR_Input_Sources)((VHVRConfig.LeftHanded() ^ offHandWield) ? 1 : 2); public static SteamVR_Input_Sources secondaryWeaponHandInputSource => (SteamVR_Input_Sources)((!(VHVRConfig.LeftHanded() ^ offHandWield)) ? 1 : 2); public static SteamVR_Input_Sources arrowHandInputSource => (SteamVR_Input_Sources)((VHVRConfig.LeftHanded() ^ offHandWield) ? 1 : 2); public static SteamVR_Input_Sources bowHandInputSource => (SteamVR_Input_Sources)((!(VHVRConfig.LeftHanded() ^ offHandWield)) ? 1 : 2); public static bool handsActive => handIsActive(leftHand, _leftPointer) && handIsActive(rightHand, _rightPointer); public static SteamVR_LaserPointer leftPointer => _leftPointer; public static SteamVR_LaserPointer rightPointer => _rightPointer; public static Vector3 dominantHandRayDirection { get { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: 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_0025: 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_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) SteamVR_LaserPointer val = (VHVRConfig.LeftHanded() ? leftPointer : rightPointer); Vector3 val2 = val.rayDirection * Vector3.forward; return ((Vector3)(ref val2)).normalized; } } public static SteamVR_LaserPointer activePointer { get { if ((Object)(object)leftPointer != (Object)null && leftPointer.pointerIsActive()) { return leftPointer; } if ((Object)(object)rightPointer != (Object)null && rightPointer.pointerIsActive()) { return rightPointer; } return null; } } public static bool inFirstPerson => _headZoomLevel == HeadZoomLevel.FirstPerson && attachedToPlayer; public static bool isMoving { get { //IL_0020: 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_0039: 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_004e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Player.m_localPlayer != (Object)null && attachedToPlayer) { Vector3 val = ((Character)Player.m_localPlayer).GetVelocity(); if (Object.op_Implicit((Object)(object)((Character)Player.m_localPlayer).m_lastGroundBody)) { val -= ((Character)Player.m_localPlayer).m_lastGroundBody.velocity; } return ((Vector3)(ref val)).magnitude > 0.5f; } return false; } } public static bool inImmersiveDodge { get { if (!VHVRConfig.ImmersiveDodgeRoll() || (Object)(object)Player.m_localPlayer == (Object)null || (Object)(object)vrPlayerInstance == (Object)null) { return false; } return ((Character)Player.m_localPlayer).InDodge() || vrPlayerInstance.wasDodging; } } public static GameObject instance => _instance; public static VRPlayer vrPlayerInstance => _vrPlayerInstance; public static bool headPositionInitialized { get; private set; } public static Transform leftFoot { get; private set; } public static Transform rightFoot { get; private set; } public static void RequestRecentering() { //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) headPositionInitialized = false; firstPersonOffset = Vector3.zero; firstPersonHeightOffset = null; } public static void RequestPelvisCaliberation() { bodyTrackingCaliberationPending = true; } public static void DestroyVrik() { if (!((Object)(object)vrikRef == (Object)null)) { Object.Destroy((Object)(object)vrikRef); vrikRef = null; LogUtils.LogDebug("Destroyed local player stale VRIK"); } } private void Awake() { //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_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) _vrPlayerInstance = this; _prefab = VRAssetManager.GetAsset(PLAYER_PREFAB_NAME); _preferredHand = VHVRConfig.GetPreferredHand(); headPositionInitialized = false; firstPersonOffset = Vector3.zero; THIRD_PERSON_CONFIG_OFFSET = VHVRConfig.GetThirdPersonHeadOffset(); ensurePlayerInstance(); ((Component)this).gameObject.AddComponent(); } private void Update() { //IL_00a7: 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_00d1: 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) if (!ensurePlayerInstance()) { return; } if (ensureBodyTrackers()) { ((Renderer)hipTrackerRenderer).enabled = VHVRConfig.IsHipTrackingEnabled() && (Menu.IsVisible() || ((Object)(object)FejdStartup.m_instance != (Object)null && ((Behaviour)FejdStartup.m_instance).isActiveAndEnabled)); Transform val = (((Component)hipTrackerRenderer).transform.parent = ((Component)hipTracker).transform); if (Object.op_Implicit((Object)(object)val)) { ((Component)hipTrackerRenderer).transform.SetParent(((Component)hipTracker).transform, false); ((Component)hipTrackerRenderer).transform.localPosition = Vector3.zero; ((Component)hipTrackerRenderer).transform.localRotation = Quaternion.identity; ((Component)hipTrackerRenderer).transform.localScale = Vector3.one * 0.125f; } } maybeUpdateHeadPosition(); attachVrPlayerToWorldObject(); enableCameras(); checkAndSetHandsAndPointers(); updateBodyTracking(); updateVrik(); maybeMoveVRPlayerDuringDodge(); UpdateAmplifyOcclusionStatus(); Pose.checkInteractions(); CheckSitRoomscale(); CheckSneakRoomscale(); MountedAttackUtils.CheckMountedMagicAndCrossbowAttack(); if (timerLeft > 0f) { timerLeft -= Time.deltaTime; leftHand.hapticAction.Execute(0f, 0.1f, 20f, 0.1f, (SteamVR_Input_Sources)1); } if (timerRight > 0f) { timerRight -= Time.deltaTime; rightHand.hapticAction.Execute(0f, 0.1f, 20f, 0.1f, (SteamVR_Input_Sources)2); } } private void OnDestroy() { if ((Object)(object)_dodgingRoom != (Object)null) { Object.Destroy((Object)(object)((Component)_dodgingRoom).gameObject); } } private void FixedUpdate() { //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) //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_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_0076: 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_0088: 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) if (ShouldPauseMovement) { if (vrikEnabled() && !pausedMovement) { VrikCreator.PauseLocalPlayerVrik(); pausedMovement = true; } } else { if (vrikEnabled() && pausedMovement) { Transform vrCameraRig = _vrCameraRig; vrCameraRig.localPosition -= Vector3.ProjectOnPlane(roomscaleLocomotive - lastRoomscaleLocomotivePosition, Vector3.up); lastRoomscaleLocomotivePosition = roomscaleLocomotive; VrikCreator.UnpauseLocalPlayerVrik(); pausedMovement = false; } if (inFirstPerson) { if (VHVRConfig.CharaterMovesWithHeadset()) { DoRoomScaleMovement(Time.fixedDeltaTime); } gesturedLocomotionManager?.UpdateMovementFromGestures(Time.fixedDeltaTime); } else { roomscaleMovement = Vector3.zero; } } UpdateThirdPersonCamera(); } public static void StartSit() { startingSit = true; _isRoomscaleSneaking = false; } private void UpdateThirdPersonCamera() { if ((Object)(object)_thirdPersonCamera == (Object)null) { if (!VHVRConfig.UseThirdPersonCameraOnFlatscreen()) { return; } enableThirdPersonCamera(); if ((Object)(object)_thirdPersonCamera == (Object)null) { return; } } ((Component)_thirdPersonCamera).gameObject.SetActive(VHVRConfig.UseThirdPersonCameraOnFlatscreen()); } private static void UpdateTrackedPoseDriverPoseSource() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) Transform hmdTransform = Player.instance.hmdTransform; TrackedPoseDriver component = ((Component)hmdTransform).gameObject.GetComponent(); if ((Object)(object)component == (Object)null) { LogUtils.LogWarning("Null TrackedPoseDriver on HMD transform."); return; } LogUtils.LogInfo("Setting TrackedPoseDriver.poseSource to Head."); component.SetPoseSource(component.deviceType, (TrackedPose)3); } private void maybeUpdateHeadPosition() { //IL_000e: 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_002d: 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_0058: 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_0083: 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_00b0: 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_00dd: 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) if (VHVRConfig.AllowHeadRepositioning()) { if (Input.GetKeyDown(VHVRConfig.GetHeadForwardKey())) { updateHeadOffset(new Vector3(0f, 0f, 0.1f)); } if (Input.GetKeyDown(VHVRConfig.GetHeadBackwardKey())) { updateHeadOffset(new Vector3(0f, 0f, -0.1f)); } if (Input.GetKeyDown(VHVRConfig.GetHeadLeftKey())) { updateHeadOffset(new Vector3(-0.1f, 0f, 0f)); } if (Input.GetKeyDown(VHVRConfig.GetHeadRightKey())) { updateHeadOffset(new Vector3(0.1f, 0f, 0f)); } if (Input.GetKeyDown(VHVRConfig.GetHeadUpKey())) { updateHeadOffset(new Vector3(0f, 0.1f, 0f)); } if (Input.GetKeyDown(VHVRConfig.GetHeadDownKey())) { updateHeadOffset(new Vector3(0f, -0.1f, 0f)); } } } private void updateHeadOffset(Vector3 offset) { //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_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_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_0020: 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) if (attachedToPlayer) { if (inFirstPerson) { firstPersonOffset += offset; return; } THIRD_PERSON_CONFIG_OFFSET += offset; VHVRConfig.UpdateThirdPersonHeadOffset(THIRD_PERSON_CONFIG_OFFSET); } } private void UpdateAmplifyOcclusionStatus() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_vrCam == (Object)null) && !((Object)(object)((Component)_vrCam).gameObject.GetComponent() == (Object)null)) { AmplifyOcclusionEffect component = ((Component)_vrCam).gameObject.GetComponent(); component.SampleCount = (SampleCountLevel)1; ((Behaviour)component).enabled = VHVRConfig.UseAmplifyOcclusion(); } } private void checkAndSetHandsAndPointers() { tryInitializeHands(); if ((Object)(object)leftHand != (Object)null) { ((Behaviour)leftHand).enabled = VHVRConfig.UseVrControls(); leftHand.SetVisibility(((Behaviour)leftHand).enabled && !vrikEnabled()); } if ((Object)(object)rightHand != (Object)null) { ((Behaviour)rightHand).enabled = VHVRConfig.UseVrControls(); rightHand.SetVisibility(((Behaviour)rightHand).enabled && !vrikEnabled()); } if (handIsActive(leftHand, _leftPointer) && handIsActive(rightHand, _rightPointer)) { if (_preferredHand == LEFT_HAND) { setPointerActive(_leftPointer, active: true); setPointerActive(_rightPointer, active: false); } else { setPointerActive(_rightPointer, active: true); setPointerActive(_leftPointer, active: false); } } else if (handIsActive(rightHand, _rightPointer)) { setPointerActive(_rightPointer, active: true); setPointerActive(_leftPointer, active: false); } else if (handIsActive(leftHand, _leftPointer)) { setPointerActive(_leftPointer, active: true); setPointerActive(_rightPointer, active: false); } else { setPointerActive(_leftPointer, active: false); setPointerActive(_rightPointer, active: false); } } private void tryInitializeHands() { //IL_004a: 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_0080: 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_012d: 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) if ((Object)(object)leftHand == (Object)null || (Object)(object)_leftPointer == (Object)null) { leftHand = getHand(LEFT_HAND, _instance); if ((Object)(object)leftHand != (Object)null) { (leftHandBone = new GameObject().transform).parent = ((Component)leftHand).transform; leftHandBone.localPosition = VrikCreator.leftUnequippedPosition; leftHandBone.localRotation = VrikCreator.leftUnequippedRotation; _leftPointer = ((Component)leftHand).GetComponent(); if ((Object)(object)_leftPointer != (Object)null) { _leftPointer.raycastLayerMask = 128; } } } if (!((Object)(object)rightHand == (Object)null) && !((Object)(object)_rightPointer == (Object)null)) { return; } rightHand = getHand(RIGHT_HAND, _instance); if ((Object)(object)rightHand != (Object)null) { (rightHandBone = new GameObject().transform).parent = ((Component)rightHand).transform; rightHandBone.localPosition = VrikCreator.rightUnequippedPosition; rightHandBone.localRotation = VrikCreator.rightUnequippedRotation; _rightPointer = ((Component)rightHand).GetComponent(); if ((Object)(object)_rightPointer != (Object)null) { _rightPointer.raycastLayerMask = 128; } } } private void setPointerActive(SteamVR_LaserPointer p, bool active) { if (!((Object)(object)p == (Object)null)) { p.setUsePointer(active && shouldLaserPointersBeActive()); p.setVisible(p.pointerIsActive() && Cursor.visible); } } private bool shouldLaserPointersBeActive() { bool flag = (Object)(object)getPlayerCharacter() != (Object)null && ((Character)getPlayerCharacter()).InPlaceMode(); return VHVRConfig.UseVrControls() && (Cursor.visible || flag); } private static bool handIsActive(Hand h, SteamVR_LaserPointer p) { if ((Object)(object)h == (Object)null || (Object)(object)p == (Object)null) { return false; } return ((Behaviour)h).enabled && h.isActive && h.isPoseValid; } private Hand getHand(string hand, GameObject playerInstance) { Hand[] componentsInChildren = playerInstance.GetComponentsInChildren(); foreach (Hand val in componentsInChildren) { if (((Object)((Component)val).gameObject).name == hand) { return val; } } return null; } private bool ensurePlayerInstance() { if ((Object)(object)_instance == (Object)null) { if ((Object)(object)_prefab == (Object)null) { LogUtils.LogError("SteamVR Player Prefab is not loaded!"); return false; } _instance = Object.Instantiate(_prefab); if ((Object)(object)_instance != (Object)null) { DisableRigidBodies(_instance); UpdateTrackedPoseDriverPoseSource(); } } return (Object)(object)_instance != (Object)null; } private bool ensureBodyTrackers() { //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0179: 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) if ((Object)(object)trackedObjects[0] != (Object)null) { return true; } if ((Object)(object)_vrCam == (Object)null || (Object)(object)((Component)_vrCam).transform.parent == (Object)null) { return false; } for (int i = 0; i < trackedObjects.Length; i++) { if ((Object)(object)trackedObjects[i] == (Object)null) { trackedObjects[i] = new GameObject().AddComponent(); } trackedObjects[i].SetDeviceIndex(i); ((Component)trackedObjects[i]).transform.parent = _vrCameraRig; } pelvis = new GameObject().transform; pelvis.parent = ((Component)hipTracker).transform; hipTrackerRenderer = GameObject.CreatePrimitive((PrimitiveType)3).GetComponent(); ((Component)hipTrackerRenderer).transform.SetParent(((Component)hipTracker).transform, false); ((Component)hipTrackerRenderer).gameObject.layer = LayerUtils.getWorldspaceUiLayer(); ((Component)hipTrackerRenderer).transform.localScale = new Vector3(0.125f, 0.125f, 0.125f); ((Renderer)hipTrackerRenderer).material = Object.Instantiate(VRAssetManager.GetAsset("Unlit")); ((Renderer)hipTrackerRenderer).material.color = Color.op_Implicit(new Vector4(0.5f, 0.5f, 0f, 0.5f)); ((Renderer)hipTrackerRenderer).receiveShadows = false; RequestPelvisCaliberation(); return true; } private void enableCameras() { if ((Object)(object)_vrCam == (Object)null || !((Behaviour)_vrCam).enabled) { if ((Object)(object)_thirdPersonCamera != (Object)null) { Object.Destroy((Object)(object)_thirdPersonCamera); } enableVrCamera(); } else { _vrCam.nearClipPlane = VHVRConfig.GetNearClipPlane(); } if ((Object)(object)_handsCam == (Object)null || !((Behaviour)_handsCam).enabled) { enableHandsCamera(); } if ((Object)(object)_skyboxCam == (Object)null || !((Behaviour)_skyboxCam).enabled) { enableSkyboxCamera(); } } private void enableVrCamera() { if ((Object)(object)_instance == (Object)null) { LogUtils.LogError("Cannot enable VR Camera with null SteamVR Player instance."); return; } Camera camera = CameraUtils.getCamera("Main Camera"); if ((Object)(object)camera == (Object)null) { LogUtils.LogError("Main Camera is null."); return; } Camera camera2 = CameraUtils.getCamera("VRCamera"); CameraUtils.copyCamera(camera, camera2); maybeCopyPostProcessingEffects(camera2, camera); maybeAddAmplifyOcclusion(camera2); camera2.nearClipPlane = VHVRConfig.GetNearClipPlane(); MainCameraFarClipPlane = camera.farClipPlane; camera2.cullingMask &= ~(1 << LayerUtils.getUiPanelLayer()); camera2.cullingMask &= ~(1 << LayerMask.NameToLayer("UI")); camera2.cullingMask &= ~(1 << LayerUtils.getHandsLayer()); camera2.cullingMask &= ~(1 << LayerUtils.getWorldspaceUiLayer()); camera2.cullingMask &= -16385; ((Behaviour)camera).enabled = false; AudioListener component = ((Component)camera).GetComponent(); if ((Object)(object)component != (Object)null) { LogUtils.LogDebug("Destroying MainCamera AudioListener"); Object.DestroyImmediate((Object)(object)component); } _fadeManager = ((Component)camera2).gameObject.AddComponent(); _instance.SetActive(true); ((Behaviour)camera2).enabled = true; _vrCam = camera2; _vrCameraRig = ((Component)camera2).transform.parent; gesturedLocomotionManager = new GesturedLocomotionManager(); _fadeManager.OnFadeToWorld += delegate { //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) headPositionInitialized = false; firstPersonOffset = Vector3.zero; vrPlayerInstance?.ResetRoomscaleCamera(); }; } private void enableHandsCamera() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown Camera camera = CameraUtils.getCamera("VRCamera"); if (!((Object)(object)camera == (Object)null) && !((Object)(object)((Component)camera).gameObject == (Object)null)) { LogUtils.LogDebug("Enabling Hands Camera"); GameObject val = new GameObject("VRHandsCamera"); Camera val2 = val.AddComponent(); val2.CopyFrom(CameraUtils.getCamera("VRCamera")); val2.depth = 4f; val2.clearFlags = (CameraClearFlags)3; val2.cullingMask = 8388608; ((Component)val2).transform.SetParent(((Component)camera).transform); ((Behaviour)val2).enabled = true; _handsCam = val2; } } private void enableThirdPersonCamera() { //IL_005b: 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) Camera camera = CameraUtils.getCamera("VRCamera"); if (!((Object)(object)camera == (Object)null) && !((Object)(object)((Component)camera).gameObject == (Object)null) && (!PlayerOnDeathPatch.hasCharacterDied || attachedToPlayer)) { LogUtils.LogDebug("Enabling third person camera"); _thirdPersonCamera = new GameObject("FollowCamera").AddComponent(); _thirdPersonCamera.CopyFrom(camera); _thirdPersonCamera.depth = 4f; Camera thirdPersonCamera = _thirdPersonCamera; thirdPersonCamera.cullingMask |= 0x4000; Camera thirdPersonCamera2 = _thirdPersonCamera; thirdPersonCamera2.cullingMask |= 1 << LayerUtils.getUiPanelLayer(); Camera thirdPersonCamera3 = _thirdPersonCamera; thirdPersonCamera3.cullingMask |= 1 << LayerUtils.getWorldspaceUiLayer(); ((Component)_thirdPersonCamera).transform.position = ((Component)camera).transform.position; _thirdPersonCamera.stereoTargetEye = (StereoTargetEyeMask)0; ((Component)_thirdPersonCamera).gameObject.AddComponent(); ((Behaviour)_thirdPersonCamera).enabled = true; _thirdPersonCamera.ResetAspect(); _thirdPersonCamera.fieldOfView = 75f; } } private void enableSkyboxCamera() { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown Camera camera = CameraUtils.getCamera("SkyboxCamera"); if (!((Object)(object)camera == (Object)null) && !((Object)(object)((Component)camera).gameObject == (Object)null)) { Camera camera2 = CameraUtils.getCamera("VRCamera"); if (!((Object)(object)camera2 == (Object)null) && !((Object)(object)((Component)camera2).gameObject == (Object)null)) { GameObject val = new GameObject("VRSkyboxCamera"); Camera val2 = val.AddComponent(); val2.CopyFrom(camera); val2.depth = -2f; ((Component)val2).transform.SetParent(((Component)camera2).transform); ((Behaviour)camera).enabled = false; ((Behaviour)val2).enabled = true; _skyboxCam = val2; } } } private void attachVrPlayerToWorldObject() { if (shouldAttachToPlayerCharacter()) { updateZoomLevel(); attachVrPlayerToPlayerCharacter(); } else { attachVrPlayerToMainCamera(); } } private void updateZoomLevel() { if (canAdjustCameraDistance()) { float axis = Input.GetAxis("Mouse ScrollWheel"); if (axis > 0f) { zoomCamera(zoomIn: true); } else if (axis < 0f) { zoomCamera(zoomIn: false); } } } private void zoomCamera(bool zoomIn) { switch (_headZoomLevel) { case HeadZoomLevel.FirstPerson: _headZoomLevel = ((!zoomIn) ? HeadZoomLevel.ThirdPerson0 : HeadZoomLevel.FirstPerson); break; case HeadZoomLevel.ThirdPerson0: _headZoomLevel = ((!zoomIn) ? HeadZoomLevel.ThirdPerson1 : HeadZoomLevel.FirstPerson); break; case HeadZoomLevel.ThirdPerson1: _headZoomLevel = (zoomIn ? HeadZoomLevel.ThirdPerson0 : HeadZoomLevel.ThirdPerson2); break; case HeadZoomLevel.ThirdPerson2: _headZoomLevel = (zoomIn ? HeadZoomLevel.ThirdPerson1 : HeadZoomLevel.ThirdPerson3); break; case HeadZoomLevel.ThirdPerson3: _headZoomLevel = (zoomIn ? HeadZoomLevel.ThirdPerson2 : HeadZoomLevel.ThirdPerson3); break; } } private static Vector3 getHeadOffset(HeadZoomLevel headZoomLevel) { //IL_0021: 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_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_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_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_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_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_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_005f: 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_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_0079: 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) return (Vector3)(headZoomLevel switch { HeadZoomLevel.FirstPerson => firstPersonOffset, HeadZoomLevel.ThirdPerson0 => THIRD_PERSON_0_OFFSET + THIRD_PERSON_CONFIG_OFFSET, HeadZoomLevel.ThirdPerson1 => THIRD_PERSON_1_OFFSET + THIRD_PERSON_CONFIG_OFFSET, HeadZoomLevel.ThirdPerson2 => THIRD_PERSON_2_OFFSET + THIRD_PERSON_CONFIG_OFFSET, HeadZoomLevel.ThirdPerson3 => THIRD_PERSON_3_OFFSET + THIRD_PERSON_CONFIG_OFFSET, _ => firstPersonOffset, }); } private bool canAdjustCameraDistance() { return !IsClickableGuiOpen && (!Object.op_Implicit((Object)(object)Chat.instance) || !Chat.instance.HasFocus()) && !Console.IsVisible() && attachedToPlayer && !((Character)getPlayerCharacter()).InCutscene() && !((Character)getPlayerCharacter()).InPlaceMode(); } private bool shouldAttachToPlayerCharacter() { //IL_000f: 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) int result; if ((Object)(object)getPlayerCharacter() != (Object)null) { Scene activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).name != START_SCENE && ensurePlayerInstance() && !((Character)getPlayerCharacter()).InCutscene() && !((Character)getPlayerCharacter()).IsDead() && !((Character)getPlayerCharacter()).InBed()) { result = ((!PlayerCustomizaton.IsBarberGuiVisible()) ? 1 : 0); goto IL_0062; } } result = 0; goto IL_0062; IL_0062: return (byte)result != 0; } private void attachVrPlayerToPlayerCharacter() { //IL_0063: 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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: 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_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: 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_0114: 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) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012c: 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_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: 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_015b: 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_016a: 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_0174: 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_0238: Unknown result type (might be due to invalid IL or missing references) //IL_0218: 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_0224: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_022e: 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_01f0: 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_0204: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: 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) Player playerCharacter = getPlayerCharacter(); if ((Object)(object)playerCharacter == (Object)null) { LogUtils.LogError("Player character is null. Cannot attach!"); return; } if (!ensurePlayerInstance()) { LogUtils.LogError("SteamVR Player instance is null. Cannot attach!"); return; } _instance.transform.SetParent(((Component)playerCharacter).transform, false); _instance.transform.localScale = Vector3.one / 0.9f; attachedToPlayer = true; maybeExitDodge(); maybeInitHeadPosition(playerCharacter); if (bodyTrackingCaliberationPending) { caliberateBodyTracking(); if (!bodyTrackingCaliberationPending) { initialRoomscaleLocomotiveOffsetFromHead = roomscaleLocomotive - ((Component)vrCam).transform.localPosition; } } else { initialRoomscaleLocomotiveOffsetFromHead = Vector3.zero; } float num = (inFirstPerson ? firstPersonHeightOffset.Value : 0f); setHeadVisibility(!inFirstPerson); _instance.transform.localPosition = getDesiredLocalPosition(playerCharacter) + (num + getHeadHeightAdjust(playerCharacter)) * Vector3.up; if (_headZoomLevel != 0) { Transform transform = _instance.transform; transform.localPosition += getHeadOffset(_headZoomLevel) + Vector3.forward * 0.25f; setPlayerVisualsOffset(((Component)playerCharacter).transform, Vector3.zero); return; } Vector3 val = -getHeadOffset(_headZoomLevel); if (((Character)playerCharacter).IsSitting()) { if (((Character)playerCharacter).IsAttached()) { Transform transform2 = _instance.transform; transform2.localPosition += Vector3.forward * 0.33f; } val += Vector3.forward * 0.0625f; } else if (!VHVRConfig.TrackFeet()) { val -= Vector3.forward * 0.25f; } setPlayerVisualsOffset(((Component)playerCharacter).transform, val); } private void setPlayerVisualsOffset(Transform playerTransform, Vector3 offset) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < playerTransform.childCount; i++) { Transform child = playerTransform.GetChild(i); if (!((Object)(object)child == (Object)(object)_instance.transform) && !(((Object)child).name == "EyePos")) { playerTransform.GetChild(i).localPosition = offset; } } } private float getHeadHeightAdjust(Player player) { if (((Character)player).IsRiding() || MountedAttackUtils.IsRidingMount()) { return RIDE_HEIGHT_ADJUST; } if (MountedAttackUtils.IsSteering()) { return SIT_ATTACH_HEIGHT_ADJUST; } if (((Character)player).IsSitting()) { if (((Character)player).IsAttached()) { Transform attachPoint = player.m_attachPoint; Chair val = ((attachPoint != null) ? ((Component)attachPoint).GetComponentInParent() : null); return ((Object)(object)val != (Object)null && val.m_name == "$piece_asksvinskeleton") ? (-1.1f) : SIT_ATTACH_HEIGHT_ADJUST; } if (!VHVRConfig.CharaterMovesWithHeadset()) { return SIT_HEIGHT_ADJUST; } } if (((Character)player).IsCrouching() && Player_SetControls_SneakPatch.isJoystickSneaking) { return CROUCH_HEIGHT_ADJUST; } return VHVRConfig.PlayerHeightAdjust(); } private void updateBodyTracking() { //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_0285: 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_01e4: 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_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_021d: 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_0370: Unknown result type (might be due to invalid IL or missing references) //IL_03a4: Unknown result type (might be due to invalid IL or missing references) //IL_0420: Unknown result type (might be due to invalid IL or missing references) //IL_0425: Unknown result type (might be due to invalid IL or missing references) //IL_042a: Unknown result type (might be due to invalid IL or missing references) //IL_042f: Unknown result type (might be due to invalid IL or missing references) //IL_0434: Unknown result type (might be due to invalid IL or missing references) //IL_0439: Unknown result type (might be due to invalid IL or missing references) //IL_043b: Unknown result type (might be due to invalid IL or missing references) //IL_0443: Unknown result type (might be due to invalid IL or missing references) //IL_0448: Unknown result type (might be due to invalid IL or missing references) //IL_044d: Unknown result type (might be due to invalid IL or missing references) //IL_03c8: Unknown result type (might be due to invalid IL or missing references) //IL_03d7: Unknown result type (might be due to invalid IL or missing references) //IL_03dc: Unknown result type (might be due to invalid IL or missing references) //IL_03e1: Unknown result type (might be due to invalid IL or missing references) //IL_03eb: Unknown result type (might be due to invalid IL or missing references) //IL_048a: Unknown result type (might be due to invalid IL or missing references) //IL_0469: Unknown result type (might be due to invalid IL or missing references) //IL_0471: Unknown result type (might be due to invalid IL or missing references) //IL_0476: Unknown result type (might be due to invalid IL or missing references) //IL_04b0: Unknown result type (might be due to invalid IL or missing references) //IL_04bb: Unknown result type (might be due to invalid IL or missing references) //IL_04c0: Unknown result type (might be due to invalid IL or missing references) //IL_04c5: Unknown result type (might be due to invalid IL or missing references) //IL_04cd: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if (!ensureBodyTrackers()) { return; } Transform val = vrikRef?.solver?.spine?.pelvisTarget; if ((Object)(object)localPlayer == (Object)null || (Object)(object)vrikRef == (Object)null || (Object)(object)val == (Object)null || !headPositionInitialized || (Object)(object)_vrCam == (Object)null || !VHVRConfig.UseVrControls() || pausedMovement) { return; } vrikRef.solver.spine.maintainPelvisPosition = ((!attachedToPlayer) ? 1 : 0); vrikRef.solver.spine.pelvisRotationWeight = (attachedToPlayer ? 1 : 0); if (!VHVRConfig.IsHipTrackingEnabled()) { vrikRef.solver.leftLeg.positionWeight = (vrikRef.solver.rightLeg.positionWeight = 0f); vrikRef.solver.leftLeg.rotationWeight = (vrikRef.solver.rightLeg.rotationWeight = 0f); ((Component)StaticObjects.leftFootCollision()).gameObject.SetActive(false); ((Component)StaticObjects.rightFootCollision()).gameObject.SetActive(false); if (((Character)localPlayer).IsAttached() || ((Character)localPlayer).IsSitting() || Player.instance.eyeHeight > referencePlayerHeight * 0.125f) { vrikRef.solver.spine.pelvisPositionWeight = 0f; vrikRef.solver.spine.pelvisRotationWeight = 1f; Vector3 val2 = inferPelvisFacingFromPlayerHeadingAndHands(((Component)localPlayer).transform, ((Character)localPlayer).IsAttached()); pelvis.rotation = Quaternion.LookRotation(val2, ((Component)localPlayer).transform.up); vrikRef.solver.spine.rootHeadingOffset = Vector3.SignedAngle(((Component)localPlayer).transform.forward, val2, ((Component)localPlayer).transform.up); } else { vrikRef.solver.spine.pelvisPositionWeight = 1f; vrikRef.solver.spine.pelvisRotationWeight = 0f; pelvis.position = inferPelvisPositionFromHead(((Component)_vrCam).transform.up); vrikRef.solver.spine.rootHeadingOffset = 0f; } return; } bool flag = !((Character)localPlayer).IsAttached() && !((Character)localPlayer).IsSitting() && Vector3.Angle(pelvis.parent.rotation * caliberatedPelvisLocalRotation * Vector3.up, ((Component)localPlayer).transform.up) < 30f && Player.instance.eyeHeight > referencePlayerHeight * 0.75f; if (((Character)localPlayer).IsAttached() || (!VHVRConfig.TrackFeet() && (((Character)localPlayer).IsSneaking() || ((Character)localPlayer).IsSitting() || flag))) { vrikRef.solver.spine.pelvisPositionWeight = 0f; pelvis.position = vrikRef.references.pelvis.position; } else { vrikRef.solver.spine.pelvisPositionWeight = (attachedToPlayer ? 1 : 0); pelvis.localPosition = caliberatedPelvisLocalPosition; } if (((Character)localPlayer).IsAttached()) { pelvis.rotation = Quaternion.Lerp(((Component)localPlayer).transform.rotation, pelvis.parent.rotation * caliberatedPelvisLocalRotation, 0.25f); vrikRef.solver.spine.rootHeadingOffset = 0f; } else { Vector3 val3 = pelvis.parent.rotation * caliberatedPelvisLocalRotation * Vector3.forward; Vector3 val4 = Vector3.ProjectOnPlane(val3, ((Component)localPlayer).transform.up); if (flag && !VHVRConfig.TrackFeet()) { pelvis.rotation = Quaternion.LookRotation(val4, ((Component)localPlayer).transform.up); } else { pelvis.localRotation = caliberatedPelvisLocalRotation; } vrikRef.solver.spine.rootHeadingOffset = Vector3.SignedAngle(Vector3.ProjectOnPlane(((Component)_vrCam).transform.forward, ((Component)localPlayer).transform.up), val4, ((Component)localPlayer).transform.up); } if (shouldTrackFeet()) { VrikCreator.EnableFootTracking(vrikRef); ((Component)StaticObjects.leftFootCollision()).gameObject.SetActive(true); ((Component)StaticObjects.rightFootCollision()).gameObject.SetActive(true); } else { VrikCreator.DisableFootTracking(vrikRef); ((Component)StaticObjects.leftFootCollision()).gameObject.SetActive(false); ((Component)StaticObjects.rightFootCollision()).gameObject.SetActive(false); } } public bool shouldTrackFeet() { //IL_0051: 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_007d: 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_00c4: 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_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) if (!VHVRConfig.TrackFeet() || !attachedToPlayer || (Object)(object)Player.m_localPlayer == (Object)null || ((Character)Player.m_localPlayer).IsAttached()) { return false; } if (GesturedLocomotionManager.isUsingFootTracking) { return true; } float num = ((Component)_vrCam).transform.localPosition.y - Player.instance.eyeHeight + referencePlayerHeight; if (!(_vrCameraRig.InverseTransformPoint(leftFoot.position).y > num - 1.5f - VHVRConfig.PlayerHeightAdjust()) && !(_vrCameraRig.InverseTransformPoint(rightFoot.position).y > num - 1.5f - VHVRConfig.PlayerHeightAdjust())) { Vector3 val = Vector3.ProjectOnPlane(leftFoot.position - rightFoot.position, _vrCameraRig.up); if (!(((Vector3)(ref val)).magnitude > 0.5f)) { if (VRControls.smoothWalkX > 0.1f || VRControls.smoothWalkY > 0.1f || VRControls.smoothWalkX < -0.1f || VRControls.smoothWalkY < -0.1f || gesturedLocomotionManager.stickOutputX > 0.1f || gesturedLocomotionManager.stickOutputY > 0.1f || gesturedLocomotionManager.stickOutputX < -0.1f || gesturedLocomotionManager.stickOutputY < -0.1f) { return false; } return ((Character)Player.m_localPlayer).IsOnGround(); } } return true; } private Vector3 inferPelvisPositionFromHead(Vector3? upDirection = null) { //IL_002e: 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_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_0054: 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_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_0072: 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_0075: Unknown result type (might be due to invalid IL or missing references) if (!upDirection.HasValue) { upDirection = _vrCameraRig.up; } return ((Component)_vrCam).transform.position - ((Component)_vrCam).transform.forward * 0.1f - upDirection.Value * 0.89f * 0.9f; } private Vector3 inferPelvisFacingFromPlayerHeadingAndHands(Transform playerTransform, bool isPlayerAttached) { //IL_0030: 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_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_0035: 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_0076: 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_00ed: 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_0081: 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_0090: 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_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_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_00bd: 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_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: 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_00d8: 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_00df: 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_00cf: 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_00d1: 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) Vector3 val = (isPlayerAttached ? ((Component)Player.m_localPlayer).transform.forward : Vector3.ProjectOnPlane(((Component)_vrCam).transform.forward, _vrCameraRig.up)); if (GesturedLocomotionManager.isInUse && Mathf.Abs(gesturedLocomotionManager.stickOutputY) > 0.25f) { return val; } Vector3 val2 = (isPlayerAttached ? playerTransform.up : _vrCameraRig.up); Vector3 val3 = rightHandBone.TransformPoint(-Vector3.up * 0.25f) - leftHandBone.TransformPoint(-Vector3.up * 0.25f); Vector3 val4 = Vector3.Cross(Vector3.ProjectOnPlane(val3, val2), val2); return isPlayerAttached ? (val + val4 * 0.5f) : (val + val4); } private void updateVrik() { Player playerCharacter = getPlayerCharacter(); if (!((Object)(object)playerCharacter == (Object)null)) { maybeAddVrik(playerCharacter); if (!((Object)(object)vrikRef == (Object)null)) { ((Behaviour)vrikRef).enabled = VHVRConfig.UseVrControls() && inFirstPerson && !((Character)playerCharacter).InDodge() && !((Character)playerCharacter).IsStaggering() && !playerCharacter.IsSleeping() && validVrikAnimatorState(((Component)playerCharacter).GetComponentInChildren()); LeftHandQuickMenu.instance.UpdateWristBar(); RightHandQuickMenu.instance.UpdateWristBar(); } } } private void maybeExitDodge() { //IL_0051: 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_005a: 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_007f: 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_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_0093: 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_00ad: 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_00bb: 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_0100: 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_0117: 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_0122: 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_012c: 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_0141: 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_0153: 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) Player playerCharacter = getPlayerCharacter(); if (!((Object)(object)playerCharacter == (Object)null) && !((Character)playerCharacter).InDodge() && wasDodging) { if (attachedToPlayer && VHVRConfig.ImmersiveDodgeRoll()) { Quaternion localRotation = ((Component)_vrCam).transform.localRotation; float y = ((Quaternion)(ref localRotation)).eulerAngles.y; Vector3 lookDir = _instance.transform.rotation * Quaternion.Euler(0f, y, 0f) * Vector3.forward; _vrCameraRig.localPosition = roomLocalPositionBeforeDodge; _vrCameraRig.localRotation = Quaternion.identity; ((Character)playerCharacter).m_lookDir = lookDir; playerCharacter.FaceLookDirection(); _instance.transform.localRotation = Quaternion.Euler(0f, 0f - y, 0f); _vrCam.nearClipPlane = VHVRConfig.GetNearClipPlane(); Transform vrCameraRig = _vrCameraRig; vrCameraRig.position += Vector3.ProjectOnPlane(((Component)playerCharacter).transform.position - _vrCameraRig.TransformPoint(roomscaleLocomotive - initialRoomscaleLocomotiveOffsetFromHead), _vrCameraRig.up); lastRoomscaleLocomotivePosition = roomscaleLocomotive; roomscaleMovement = Vector3.zero; } wasDodging = false; } } private void maybeMoveVRPlayerDuringDodge() { //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_0067: 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_00c8: 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_00e3: 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_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)getPlayerCharacter() == (Object)null) && ((Character)getPlayerCharacter()).InDodge()) { if (!wasDodging) { roomLocalPositionBeforeDodge = _vrCameraRig.localPosition; dodgingRoom.parent = getHeadBone(); dodgingRoom.SetPositionAndRotation(_vrCameraRig.position, _vrCameraRig.rotation); _vrCam.nearClipPlane = 0.3f; wasDodging = true; } else if (attachedToPlayer && VHVRConfig.ImmersiveDodgeRoll()) { float dodgeExitSmoothener = GetDodgeExitSmoothener(); ((Component)_vrCameraRig).transform.position = Vector3.Lerp(dodgingRoom.position, _instance.transform.TransformPoint(roomLocalPositionBeforeDodge), dodgeExitSmoothener); ((Component)_vrCameraRig).transform.rotation = Quaternion.Slerp(dodgingRoom.rotation, _instance.transform.rotation, dodgeExitSmoothener); } } } private float GetDodgeExitSmoothener() { float num = 0.3f; return (UpdateDodgeVr.currdodgetimer > num) ? 0f : ((num - UpdateDodgeVr.currdodgetimer) / num); } private bool validVrikAnimatorState(Animator animator) { if ((Object)(object)animator == (Object)null) { return false; } return !animator.GetBool("wakeup"); } private void maybeAddVrik(Player player) { //IL_0044: 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) if (VHVRConfig.UseVrControls() && !((Object)(object)vrikRef != (Object)null) && attachedToPlayer) { Camera camera = CameraUtils.getCamera("VRCamera"); leftFootPhysicsEstimator = ((Component)(((Object)(object)leftFoot != (Object)null) ? leftFoot : (leftFoot = new GameObject().transform))).gameObject.GetOrAddComponent(); rightFootPhysicsEstimator = ((Component)(((Object)(object)rightFoot != (Object)null) ? rightFoot : (rightFoot = new GameObject().transform))).gameObject.GetOrAddComponent(); PhysicsEstimator physicsEstimator = leftFootPhysicsEstimator; Transform refTransform = (rightFootPhysicsEstimator.refTransform = _vrCameraRig); physicsEstimator.refTransform = refTransform; vrikRef = VrikCreator.initialize(((Component)player).gameObject, ((Component)leftHand).transform, ((Component)rightHand).transform, ((Component)camera).transform, pelvis, leftFoot, rightFoot); if (!((Object)(object)vrikRef == (Object)null)) { VRPlayerSync component = ((Component)player).gameObject.GetComponent(); component.camera = ((Component)camera).gameObject; component.leftHand = ((Component)vrikRef.solver.leftArm.target.parent).gameObject; component.rightHand = ((Component)vrikRef.solver.rightArm.target.parent).gameObject; VrikCreator.resetVrikHandTransform((Humanoid)(object)player); HandGesture orAddComponent = ((Component)vrikRef.references.leftHand).gameObject.GetOrAddComponent(); HandGesture orAddComponent2 = ((Component)vrikRef.references.rightHand).gameObject.GetOrAddComponent(); orAddComponent.sourceHand = leftHand; orAddComponent2.sourceHand = rightHand; StaticObjects.leftFist().setColliderParent(leftHandBone, orAddComponent, isRightHand: false); StaticObjects.rightFist().setColliderParent(rightHandBone, orAddComponent2, isRightHand: true); StaticObjects.leftFootCollision().setColliderParent(leftFoot); StaticObjects.rightFootCollision().setColliderParent(rightFoot); ((Component)player).gameObject.GetOrAddComponent(); ((Component)player).gameObject.GetOrAddComponent().Initialize(orAddComponent, orAddComponent2); Reining orAddComponent3 = ((Component)player).gameObject.GetOrAddComponent(); orAddComponent3.leftHandGesture = orAddComponent; orAddComponent3.rightHandGesture = orAddComponent2; StaticObjects.mouthCollider(((Component)camera).transform); StaticObjects.addQuickMenus(); LeftHandQuickMenu.instance.refreshItems(); RightHandQuickMenu.instance.refreshItems(); } } } private bool vrikEnabled() { Player playerCharacter = getPlayerCharacter(); if ((Object)(object)playerCharacter == (Object)null) { return false; } VRIK component = ((Component)playerCharacter).gameObject.GetComponent(); if ((Object)(object)component != (Object)null && (Object)(object)component != (Object)null) { return ((Behaviour)component).enabled && !Game.IsPaused(); } return false; } private void maybeInitHeadPosition(Player playerCharacter) { //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_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_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0153: 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_0129: Unknown result type (might be due to invalid IL or missing references) //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_0180: 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_0189: 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_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) if (!headPositionInitialized && !((Character)playerCharacter).InDodge() && (Object)(object)_vrCam != (Object)null) { Camera[] array = Object.FindObjectsOfType(); foreach (Camera val in array) { if (((Object)val).name == "VRCamera" && (Object)(object)val != (Object)(object)_vrCam) { LogUtils.LogWarning("VR Camera is stale!"); _vrCam = null; return; } } } if (!headPositionInitialized && inFirstPerson && !((Character)playerCharacter).InDodge()) { _instance.transform.localPosition = getDesiredLocalPosition(playerCharacter); Transform hmdTransform = Player.instance.hmdTransform; if (!firstPersonHeightOffset.HasValue) { firstPersonHeightOffset = Vector3.Dot(_instance.transform.position - hmdTransform.position, ((Component)playerCharacter).transform.up); } if (_headZoomLevel != 0) { Transform transform = _instance.transform; transform.localPosition += getHeadOffset(_headZoomLevel); } else { setPlayerVisualsOffset(((Component)playerCharacter).transform, -getHeadOffset(_headZoomLevel)); } if (VHVRConfig.UseLookLocomotion()) { Transform transform2 = _instance.transform; Quaternion localRotation = hmdTransform.localRotation; transform2.localRotation = Quaternion.Euler(0f, 0f - ((Quaternion)(ref localRotation)).eulerAngles.y, 0f); } if (PlayerCustomizaton.IsBarberGuiVisible()) { Transform transform3 = _instance.transform; transform3.localRotation *= Quaternion.Euler(0f, 180f, 0f); } headPositionInitialized = true; referencePlayerHeight = Player.instance.eyeHeight; LogUtils.LogDebug("Reference player height: " + referencePlayerHeight); } } private static Vector3 getDesiredLocalPosition(Player playerCharacter) { //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_0026: 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_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_0041: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)playerCharacter == (Object)null) { return Vector3.zero; } Vector3 result = ((Component)playerCharacter).transform.InverseTransformPoint(((Character)playerCharacter).GetEyePoint()); result.x = (result.z = 0f); return result; } private void caliberateBodyTracking() { //IL_00a3: 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_00cd: 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_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: 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_00f3: 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_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)vrCam == (Object)null) && !((Object)(object)((Component)vrCam).transform.parent == (Object)null) && headPositionInitialized && !((Object)(object)vrikRef?.solver?.spine?.pelvisTarget == (Object)null) && VHVRConfig.IsHipTrackingEnabled()) { hipTrackerIndex = ((VHVRConfig.HipTrackerIndex() <= 0) ? detectHipDeviceIndex() : VHVRConfig.HipTrackerIndex()); Vector3 up = ((Component)vrCam).transform.parent.up; pelvis.parent = ((Component)hipTracker).transform; pelvis.position = inferPelvisPositionFromHead(); pelvis.rotation = Quaternion.LookRotation(Vector3.ProjectOnPlane(((Component)vrCam).transform.forward, up), up); caliberatedPelvisLocalPosition = pelvis.localPosition; caliberatedPelvisLocalRotation = pelvis.localRotation; caliberateFeet(); if ((Object)(object)vrikRef != (Object)null) { VrikCreator.ResetPelvisAndFootTransform(vrikRef); } bodyTrackingCaliberationPending = false; } } private void caliberateFeet() { //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_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_0128: 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_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0182: 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_0197: Unknown result type (might be due to invalid IL or missing references) //IL_0198: 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_01a2: 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_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_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01be: 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_01d4: 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_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: 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_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) int num = VHVRConfig.LeftFootTrackerIndex(); int num2 = VHVRConfig.RightFootTrackerIndex(); if (num <= 0) { num = detectFootDeviceIndex(-1); } if (num2 <= 0) { num2 = detectFootDeviceIndex(num); } if (num < 0 || num2 < 0) { leftFoot.parent = null; rightFoot.parent = null; return; } if (((Component)vrCam).transform.InverseTransformPoint(((Component)trackedObjects[num]).transform.position).x < ((Component)vrCam).transform.InverseTransformPoint(((Component)trackedObjects[num2]).transform.position).x) { leftFoot.parent = ((Component)trackedObjects[num]).transform; rightFoot.parent = ((Component)trackedObjects[num2]).transform; } else { leftFoot.parent = ((Component)trackedObjects[num2]).transform; rightFoot.parent = ((Component)trackedObjects[num]).transform; } leftFoot.rotation = pelvis.rotation; rightFoot.rotation = pelvis.rotation; Vector3 up = ((Component)vrCam).transform.parent.up; Vector3 val = ((Component)_vrCam).transform.position - ((Component)_vrCam).transform.forward * 0.1f - (1.7f + VHVRConfig.PlayerHeightAdjust()) * up; leftFoot.position = val + Vector3.ProjectOnPlane(leftFoot.parent.position - val, up); rightFoot.position = val + Vector3.ProjectOnPlane(rightFoot.parent.position - val, up); baseFootHeight = _vrCameraRig.InverseTransformPoint(val).y; if ((Object)(object)vrikRef != (Object)null) { vrikRef.solver.leftLeg.target.SetParent(leftFoot, false); vrikRef.solver.rightLeg.target.SetParent(rightFoot, false); } } private int detectHipDeviceIndex() { //IL_0025: 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_0058: 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_008f: 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) int num = 0; for (int i = 1; i < trackedObjects.Length; i++) { if (trackedObjects[i].isValid && !(((Component)trackedObjects[i]).transform.localPosition.y - ((Component)_vrCam).transform.localPosition.y < -0.8f) && !(Vector3.Distance(((Component)trackedObjects[i]).transform.position, ((Component)_vrCam).transform.position) > 1.5f) && ((Component)trackedObjects[i]).transform.localPosition.y < ((Component)trackedObjects[num]).transform.localPosition.y) { num = i; } } LogUtils.LogDebug("Detected hip tracker index: " + num); return num; } private int detectFootDeviceIndex(int otherFootDeviceIndex) { //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_0075: 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_00a1: 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) int num = -1; for (int i = 0; i < trackedObjects.Length; i++) { if (trackedObjects[i].isValid && i != otherFootDeviceIndex && i != VHVRConfig.HipTrackerIndex() && !(((Component)trackedObjects[i]).transform.localPosition.y > ((Component)hipTracker).transform.localPosition.y)) { if (num < 0) { num = i; } else if (Vector3.Distance(((Component)trackedObjects[i]).transform.localPosition, ((Component)hipTracker).transform.localPosition) < 2f && ((Component)trackedObjects[i]).transform.localPosition.y < ((Component)trackedObjects[num]).transform.localPosition.y) { num = i; } } } return num; } private void attachVrPlayerToMainCamera() { //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_00bf: 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_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_00a5: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_instance == (Object)null) { LogUtils.LogError("SteamVR Player instance is null while attaching to main camera!"); return; } Camera camera = CameraUtils.getCamera("Main Camera"); if ((Object)(object)camera == (Object)null) { LogUtils.LogError("Main camera not found."); return; } setHeadVisibility(isVisible: true); _instance.transform.parent = ((Component)camera).gameObject.transform; Vector3 position = ((Component)camera).gameObject.transform.position; if (PlayerCustomizaton.IsBarberGuiVisible() && Object.op_Implicit((Object)(object)getPlayerCharacter())) { position.y = ((Component)getPlayerCharacter()).transform.position.y; } _instance.transform.position = position; _instance.transform.rotation = ((Component)camera).gameObject.transform.rotation; attachedToPlayer = false; headPositionInitialized = false; firstPersonOffset = Vector3.zero; } private void setHeadVisibility(bool isVisible) { //IL_0049: 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) if (!VHVRConfig.UseVrControls()) { Transform headBone = getHeadBone(); if ((Object)(object)headBone != (Object)null) { headBone.localScale = (isVisible ? new Vector3(1f, 1f, 1f) : new Vector3(0.001f, 0.001f, 0.001f)); } } } private Transform getHeadBone() { Player playerCharacter = getPlayerCharacter(); if ((Object)(object)playerCharacter == (Object)null) { return null; } Animator componentInChildren = ((Component)playerCharacter).GetComponentInChildren(); if ((Object)(object)componentInChildren == (Object)null) { return null; } return componentInChildren.GetBoneTransform((HumanBodyBones)10); } private void maybeAddAmplifyOcclusion(Camera vrCamera) { if (!((Object)(object)vrCamera == (Object)null)) { AmplifyOcclusionEffect component = ((Component)vrCamera).gameObject.GetComponent(); if (!((Object)(object)component != (Object)null)) { ((Component)vrCamera).gameObject.AddComponent(); } } } private void maybeCopyPostProcessingEffects(Camera vrCamera, Camera mainCamera) { //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) if ((Object)(object)vrCamera == (Object)null || (Object)(object)mainCamera == (Object)null || (Object)(object)((Component)vrCamera).gameObject.GetComponent() != (Object)null) { return; } PostProcessingBehaviour val = null; bool flag = false; PostProcessingBehaviour[] array = Object.FindObjectsOfType(); foreach (PostProcessingBehaviour val2 in array) { if (((Object)val2).name == "Main Camera") { flag = true; val = ((Component)vrCamera).gameObject.AddComponent(); LogUtils.LogDebug("Copying Main Camera PostProcessingBehaviour"); PostProcessingProfile profile = Object.Instantiate(val2.profile); val.profile = profile; val.jitteredMatrixFunc = val2.jitteredMatrixFunc; if (((Behaviour)val2).enabled) { ((Behaviour)val2).enabled = false; } } } if (flag) { DepthOfField component = ((Component)mainCamera).gameObject.GetComponent(); DepthOfField dest = ((Component)vrCamera).gameObject.AddComponent(); if ((Object)(object)component != (Object)null) { CopyClassFields(component, ref dest); } SunShafts dest2 = ((Component)vrCamera).gameObject.AddComponent(); SunShafts component2 = ((Component)mainCamera).gameObject.GetComponent(); if ((Object)(object)component2 != (Object)null) { CopyClassFields(component2, ref dest2); } CameraEffects val3 = ((Component)vrCamera).gameObject.AddComponent(); CameraEffects component3 = ((Component)mainCamera).gameObject.GetComponent(); if ((Object)(object)component3 != (Object)null) { val3.m_forceDof = component3.m_forceDof; val3.m_dofRayMask = component3.m_dofRayMask; val3.m_dofAutoFocus = component3.m_dofAutoFocus; val3.m_dofMinDistance = component3.m_dofMinDistance; val3.m_dofMaxDistance = component3.m_dofMaxDistance; } ((Component)vrCamera).gameObject.AddComponent().Init(vrCamera, val, val.profile); } } private void CopyClassFields(T source, ref T dest) { FieldInfo[] fields = source.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); FieldInfo[] array = fields; foreach (FieldInfo fieldInfo in array) { object value = fieldInfo.GetValue(source); fieldInfo.SetValue(dest, value); } } private Player getPlayerCharacter() { return Player.m_localPlayer; } private static void DisableRigidBodies(GameObject root) { Rigidbody[] componentsInChildren = root.GetComponentsInChildren(); foreach (Rigidbody val in componentsInChildren) { ((Component)val).gameObject.SetActive(false); } SphereCollider[] componentsInChildren2 = root.GetComponentsInChildren(); foreach (SphereCollider val2 in componentsInChildren2) { ((Component)val2).gameObject.SetActive(false); } } private void CheckSitRoomscale() { //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_02f6: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_0322: 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_0250: 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_025a: 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_0270: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_018c: 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_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) //IL_01bc: 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_0298: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01de: 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_034d: 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_035d: Unknown result type (might be due to invalid IL or missing references) //IL_0362: Unknown result type (might be due to invalid IL or missing references) //IL_0366: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_036d: Unknown result type (might be due to invalid IL or missing references) //IL_036e: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_020b: 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_037c: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Unknown result type (might be due to invalid IL or missing references) //IL_03aa: Unknown result type (might be due to invalid IL or missing references) //IL_03ac: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: Unknown result type (might be due to invalid IL or missing references) //IL_03b3: Unknown result type (might be due to invalid IL or missing references) //IL_03b4: Unknown result type (might be due to invalid IL or missing references) //IL_03c2: Unknown result type (might be due to invalid IL or missing references) //IL_03c4: Unknown result type (might be due to invalid IL or missing references) Player playerCharacter = getPlayerCharacter(); if (!VHVRConfig.UseVrControls() || (Object)(object)_vrCam == (Object)null || (Object)(object)playerCharacter == (Object)null || ((Character)playerCharacter).IsAttached() || !((Character)playerCharacter).IsOnGround()) { startingSit = false; } else if (((Character)playerCharacter).IsSitting()) { startingSit = false; } else if (startingSit) { if (!((Character)playerCharacter).InEmote()) { playerCharacter.StartEmote("sit", false); } } else { if (VRControls.smoothWalkX > 0.1f || VRControls.smoothWalkY > 0.1f || VRControls.smoothWalkX < -0.1f || VRControls.smoothWalkY < -0.1f || gesturedLocomotionManager.stickOutputX > 0.1f || gesturedLocomotionManager.stickOutputY > 0.1f || gesturedLocomotionManager.stickOutputX < -0.1f || gesturedLocomotionManager.stickOutputY < -0.1f) { return; } float eyeHeight = Player.instance.eyeHeight; float num = referencePlayerHeight * VHVRConfig.RoomScaleSneakHeight(); if (eyeHeight > num - 0.1f || SteamVR_Actions.valheim_StopGesturedLocomotion.GetState((SteamVR_Input_Sources)0) || EquipScript.getRight() == EquipType.Fishing) { return; } if (VHVRConfig.IsHipTrackingEnabled()) { if (VHVRConfig.TrackFeet()) { Vector3 val = Vector3.ProjectOnPlane(pelvis.forward, _vrCameraRig.up); if (Vector3.Dot(leftFoot.position - pelvis.position, val) > 0.3f && Vector3.Dot(rightFoot.position - pelvis.position, val) > 0.3f && Vector3.Dot(((Component)_vrCam).transform.position - pelvis.position, val) < 0.1f) { startingSit = true; return; } } else { Vector3 val2 = Vector3.ProjectOnPlane(((Component)vrCam).transform.forward, _vrCameraRig.up); if (Vector3.Dot(pelvis.position - ((Component)vrCam).transform.position, val2) > 0.15f && Vector3.Dot(pelvis.forward, _vrCameraRig.up) > 0.8f) { startingSit = true; return; } } } Vector3 val3 = leftHandBone.position - ((Component)_vrCam).transform.position; Vector3 val4 = rightHandBone.position - ((Component)_vrCam).transform.position; if (Vector3.Dot(val3, _vrCameraRig.up) > -0.25f || Vector3.Dot(val4, _vrCameraRig.up) > -0.25f) { return; } Vector3 val5 = Vector3.ProjectOnPlane(((Component)_vrCam).transform.forward, _vrCameraRig.up); Vector3 normalized = ((Vector3)(ref val5)).normalized; if (Vector3.Dot(val3, normalized) < -0.33f && Vector3.Dot(val4, normalized) < -0.33f) { startingSit = true; return; } Vector3 val6 = Vector3.Cross(_vrCameraRig.up, normalized); if (Vector3.Dot(val3, val6) > 0.0625f && Vector3.Dot(val4, val6) < -0.0625f) { startingSit = true; } } } private void CheckSneakRoomscale() { if (!VHVRConfig.RoomScaleSneakEnabled() || startingSit) { _isRoomscaleSneaking = false; return; } Player playerCharacter = getPlayerCharacter(); if ((Object)(object)playerCharacter == (Object)null) { _isRoomscaleSneaking = false; return; } float eyeHeight = Player.instance.eyeHeight; float num = referencePlayerHeight * VHVRConfig.RoomScaleSneakHeight(); if (eyeHeight < num && !((Character)playerCharacter).IsSitting()) { _isRoomscaleSneaking = true; } else if (eyeHeight > num + num * 0.05f) { _isRoomscaleSneaking = false; } } private void DoRoomScaleMovement(float deltaTime) { //IL_0043: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_0114: 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_029a: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0234: 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_023a: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_024f: 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_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_014a: 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_015a: 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_016f: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: 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_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019b: 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_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_0222: 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_0227: Unknown result type (might be due to invalid IL or missing references) Player playerCharacter = getPlayerCharacter(); if ((Object)(object)_vrCam == (Object)null || (Object)(object)playerCharacter == (Object)null || (Object)(object)((Component)playerCharacter).gameObject == (Object)null || ((Character)playerCharacter).IsAttached()) { return; } Vector3 val = roomscaleLocomotive - lastRoomscaleLocomotivePosition; val.y = 0f; float num = (((Character)playerCharacter).IsSitting() ? 0.5f : 0.005f); if (!VHVRConfig.IsHipTrackingEnabled()) { switch (EquipScript.getRight()) { case EquipType.None: case EquipType.Hammer: case EquipType.Tankard: case EquipType.Claws: case EquipType.DualKnives: case EquipType.Knife: if (GesturedLocomotionManager.isInUse || SteamVR_Actions.valheim_Grab.GetState((SteamVR_Input_Sources)0)) { num = 1f; } break; } } bool flag = ((Vector3)(ref val)).magnitude > num; if (flag) { float num2 = deltaTime * 4f; if (((Vector3)(ref val)).magnitude > num2) { val = ((Vector3)(ref val)).normalized * num2; } if (VHVRConfig.RoomscaleFadeToBlack() && !_fadeManager.IsFadingToBlack) { Vector3 val2 = ((Character)playerCharacter).m_body.position - _lastPlayerPosition; if (Object.op_Implicit((Object)(object)((Character)playerCharacter).m_lastAttachBody) && _lastPlayerAttachmentPosition != Vector3.zero) { val2 -= ((Character)playerCharacter).m_lastAttachBody.position - _lastPlayerAttachmentPosition; } val2.y = 0f; Vector3 val3 = roomscaleMovement; if (((Vector3)(ref val3)).magnitude * 0.6f > ((Vector3)(ref val2)).magnitude) { SteamVR_Fade.Start(Color.black, 0f, false); SteamVR_Fade.Start(Color.clear, 1.5f, false); } _lastPlayerPosition = ((Character)playerCharacter).m_body.position; _lastPlayerAttachmentPosition = (Object.op_Implicit((Object)(object)((Character)playerCharacter).m_lastAttachBody) ? ((Character)playerCharacter).m_lastAttachBody.position : Vector3.zero); } lastRoomscaleLocomotivePosition += val; Vector3 val4 = _instance.transform.TransformVector(val); val4.y = 0f; roomscaleMovement = val4; Transform vrCameraRig = _vrCameraRig; vrCameraRig.localPosition -= val; } else { roomscaleMovement = Vector3.zero; } _roomscaleAnimationForwardSpeed = Mathf.SmoothDamp(_roomscaleAnimationForwardSpeed, flag ? (val.z / Time.fixedDeltaTime) : 0f, ref _forwardSmoothVel, 0.3f, 99f); _roomscaleAnimationSideSpeed = Mathf.SmoothDamp(_roomscaleAnimationSideSpeed, flag ? (val.x / Time.fixedDeltaTime) : 0f, ref _sideSmoothVel, 0.3f, 99f); } public void ResetRoomscaleCamera() { //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_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_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) if (!((Object)(object)_vrCameraRig == (Object)null)) { Vector3 localPosition = ((Component)_vrCam).transform.localPosition; localPosition.y = 0f; _vrCameraRig.localPosition = -localPosition; lastRoomscaleLocomotivePosition = roomscaleLocomotive; } } public void TriggerHandVibration(float time) { timerLeft = time; timerRight = time; } } } namespace ValheimVRMod.VRCore.UI { public class ConfigSettings { private class SettingsCloneMarker : MonoBehaviour { } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static UnityAction <>9__28_0; public static UnityAction <>9__28_1; public static UnityAction <>9__38_0; internal void b__28_0() { doSave = true; Object.Destroy((Object)(object)settings); } internal void b__28_1() { doSave = false; Object.Destroy((Object)(object)settings); } internal void b__38_0(string param) { } } private const bool ENABLE_VHVR_SETTINGS_DIALOG = true; private const float MENU_ENTRY_HEIGHT = 40f; private const string MenuName = "VHVR"; private const int TabButtonWidth = 100; private static GameObject tabButtonPrefab; private static GameObject controlSettingsPrefab; private static GameObject togglePrefab; private static GameObject sliderPrefab; private static GameObject chooserPrefab; private static GameObject settingsPrefab; private static GameObject keyBindingPrefab; private static GameObject transformButtonPrefab; private static GameObject settings; private static Transform menuList; private static Transform menuParent; private static ConfigComponent tmpComfigComponent; private static bool enableTransformButtons; private static int tabCounter; public static bool doSave; public static GameObject toolTip; public static KeyboardMouseSettings keyboardMouseSettings; public static void instantiate(Transform mList, Transform mParent, GameObject sPrefab, bool enableTransformButtons) { menuList = ((Component)((Component)mList).transform.Find("MenuEntries")).transform; menuParent = mParent; settingsPrefab = sPrefab; createMenuEntry(); generatePrefabs(); ConfigSettings.enableTransformButtons = enableTransformButtons; } public static bool isVHVRClone(KeyboardMouseSettings settings) { return (Object)(object)((Component)settings).GetComponentInParent(true) != (Object)null; } private static void createMenuEntry() { //IL_0039: 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_004f: Expected O, but got Unknown //IL_005b: 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_006c: 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_0082: Expected O, but got Unknown //IL_008d: 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_009e: 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_00b4: Expected O, but got Unknown //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: 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) int num = 0; for (int i = 0; i < menuList.childCount; i++) { Transform child = menuList.GetChild(i); if (((Object)child).name == "Settings") { bool flag = true; AddMenuEntry("VHVR", child, Vector2.zero, new UnityAction(createModSettings)); num++; AddMenuEntry("Screenshot", child, Vector2.up * 40f * (float)num, new UnityAction(CaptureScreenshot)); num++; AddMenuEntry("Toggle auto-pickup", child, Vector2.up * 40f * (float)num, new UnityAction(ToggleAutoPickup)); num++; } else if (num > 0) { RectTransform component = ((Component)menuList.GetChild(i)).GetComponent(); component.anchoredPosition += Vector2.up * 40f * (float)num; } } } private static void AddMenuEntry(string text, Transform original, Vector2 offsetFromOriginal, UnityAction onClick) { //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) Transform val = Object.Instantiate(original, menuList); ((TMP_Text)((Component)val).GetComponentInChildren()).text = text; ((UnityEventBase)((Component)val).GetComponent