using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using FishNet; using FishNet.Broadcast; using FishNet.Connection; using FishNet.Object; using FishNet.Serializing; using FishNet.Transporting; using HarmonyLib; using HowToFishVR.Body; using HowToFishVR.Input; using HowToFishVR.Localization; using HowToFishVR.Net; using HowToFishVR.Patches; using HowToFishVR.UI; using HowToFishVR.VR; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Layouts; using UnityEngine.InputSystem.Users; using UnityEngine.InputSystem.Utilities; using UnityEngine.Rendering; using UnityEngine.Rendering.Universal; using UnityEngine.SceneManagement; using UnityEngine.UI; using UnityEngine.XR; using UnityEngine.XR.Interaction.Toolkit.UI; using UnityEngine.XR.Management; using UnityEngine.XR.OpenXR; using UnityEngine.XR.OpenXR.Features; using UnityEngine.XR.OpenXR.Features.Interactions; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("J_axon")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("HowToFishXR - full 6DoF VR mod for How to Fish")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+e3cc92a1988e2680296bae95a521b7a361bab8be")] [assembly: AssemblyProduct("HowToFishVR")] [assembly: AssemblyTitle("HowToFishVR")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace HowToFishVR { public enum TurnMode { Snap, Smooth } public enum BodyMode { FullBodyIK, HandsOnly } public enum ButtonMode { Hold, Toggle } public enum DeathView { FirstPerson, ThirdPerson } public static class VRConfig { public static ConfigEntry DisableVR; public static ConfigEntry WorldScale; public static ConfigEntry RoomscaleMovement; public static ConfigEntry RecenterKey; public static ConfigEntry HeightCalibrateKey; public static ConfigEntry SavedEyeHeight; public static ConfigEntry SavedHeadCalibY; public static ConfigEntry Turning; public static ConfigEntry SnapTurnAngle; public static ConfigEntry SmoothTurnSpeed; public static ConfigEntry TurnDeadzone; public static ConfigEntry MovementDeadzone; public static ConfigEntry HeadRelativeMovement; public static ConfigEntry BoatSteerSensitivity; public static ConfigEntry SprintMode; public static ConfigEntry CrouchMode; public static ConfigEntry HudFollowsHead; public static ConfigEntry HudFollowSmoothing; public static ConfigEntry HudScale; public static ConfigEntry GripThreshold; public static ConfigEntry RealUIBlur; public static ConfigEntry BodyMode; public static ConfigEntry BodyOffset; public static ConfigEntry DeathView; public static ConfigEntry MultiplayerVRSync; public static ConfigEntry VRSyncRate; public static void Init(ConfigFile cfg) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Expected O, but got Unknown //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Expected O, but got Unknown //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Expected O, but got Unknown //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Expected O, but got Unknown //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Expected O, but got Unknown //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Expected O, but got Unknown //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Expected O, but got Unknown //IL_032d: Unknown result type (might be due to invalid IL or missing references) //IL_0337: Expected O, but got Unknown //IL_038c: Unknown result type (might be due to invalid IL or missing references) //IL_03ff: Unknown result type (might be due to invalid IL or missing references) //IL_0409: Expected O, but got Unknown DisableVR = cfg.Bind("General", "Disable VR", false, "Start How to Fish in flatscreen mode while keeping the mod installed. Can also be overridden for one launch with the --disable-vr Steam launch option. Restart required."); WorldScale = cfg.Bind("General", "World Scale", 1f, new ConfigDescription("Scales your perceived size in the world. 1.0 = default.", (AcceptableValueBase)(object)new AcceptableValueRange(0.5f, 2f), Array.Empty())); RoomscaleMovement = cfg.Bind("Calibration", "Roomscale Movement", true, "Allow physically walking/crouching to move the in-game body."); RecenterKey = cfg.Bind("Calibration", "Recenter", new KeyboardShortcut((KeyCode)283, Array.Empty()), "Re-center the headset forward direction."); HeightCalibrateKey = cfg.Bind("Calibration", "Calibrate Height", new KeyboardShortcut((KeyCode)284, Array.Empty()), "Measure and store your standing height / floor level."); SavedEyeHeight = cfg.Bind("Calibration", "Saved Eye Height", 0f, "Your calibrated eye height (m) above the player root, saved by F3 and restored on launch so death/respawn/reloads keep it."); SavedHeadCalibY = cfg.Bind("Calibration", "Saved Head Reference Height", 0f, "Your calibrated standing head height (m), saved by F3. Informational; the live head reference is re-captured each launch."); Turning = cfg.Bind("Turning", "Turn Mode", TurnMode.Snap, "Snap = instant rotation; Smooth = continuous rotation."); SnapTurnAngle = cfg.Bind("Turning", "Snap Angle", 45, new ConfigDescription("Degrees per snap turn.", (AcceptableValueBase)(object)new AcceptableValueRange(15, 90), Array.Empty())); SmoothTurnSpeed = cfg.Bind("Turning", "Smooth Speed", 120f, new ConfigDescription("Degrees per second for smooth turning.", (AcceptableValueBase)(object)new AcceptableValueRange(30f, 360f), Array.Empty())); TurnDeadzone = cfg.Bind("Turning", "Turn Deadzone", 0.75f, new ConfigDescription("Thumbstick threshold to trigger a snap turn (MAVR-style: must return below 0.35 to re-arm).", (AcceptableValueBase)(object)new AcceptableValueRange(0.1f, 0.95f), Array.Empty())); MovementDeadzone = cfg.Bind("Locomotion", "Move Deadzone", 0.15f, new ConfigDescription("Thumbstick deadzone for movement.", (AcceptableValueBase)(object)new AcceptableValueRange(0.05f, 0.5f), Array.Empty())); HeadRelativeMovement = cfg.Bind("Locomotion", "Head Relative Movement", true, "Movement direction follows head gaze (off = follows off-hand controller)."); BoatSteerSensitivity = cfg.Bind("Locomotion", "Boat Steer Sensitivity", 1f, new ConfigDescription("Multiplier for boat steering from the movement stick.", (AcceptableValueBase)(object)new AcceptableValueRange(0.3f, 2.5f), Array.Empty())); SprintMode = cfg.Bind("Locomotion", "Sprint Mode", ButtonMode.Hold, "Left thumbstick click. Hold = sprint while held; Toggle = click to toggle."); CrouchMode = cfg.Bind("Locomotion", "Crouch Mode", ButtonMode.Toggle, "Right thumbstick click. Toggle = click to toggle (default); Hold = crouch while held."); HudFollowsHead = cfg.Bind("HUD", "HUD Follows Head", true, "HUD rotates with head yaw but stays level (not pitched up/down), floating in front of you."); HudFollowSmoothing = cfg.Bind("HUD", "HUD Smoothing", 0.1f, new ConfigDescription("Lower = snappier HUD follow.", (AcceptableValueBase)(object)new AcceptableValueRange(0.02f, 0.5f), Array.Empty())); HudScale = cfg.Bind("HUD", "HUD Scale", 1f, new ConfigDescription("Scale multiplier for the HUD.", (AcceptableValueBase)(object)new AcceptableValueRange(0.5f, 2f), Array.Empty())); GripThreshold = cfg.Bind("Interaction", "Grip Threshold", 0.6f, new ConfigDescription("Grip pull required to grab.", (AcceptableValueBase)(object)new AcceptableValueRange(0.1f, 0.95f), Array.Empty())); RealUIBlur = cfg.Bind("UI", "Real UI Blur", true, "Keep the game's real frosted-glass pixel-blur on UI panels (the actual UniversalBlurUI effect) instead of a flat dark tint. Turn OFF if panels render black on your headset."); BodyMode = cfg.Bind("Body", "Body Mode", HowToFishVR.BodyMode.FullBodyIK, "FullBodyIK = restored body with VR IK arms that bend naturally. HandsOnly = base game: no body shown, hands only. Snap/smooth turning works in both modes (MAVR-style)."); BodyOffset = cfg.Bind("Body", "Body Offset", new Vector3(0f, 0f, -0.2f), "x, y, z nudge for the whole body in body space, metres. Positive z is forward. Default sits it 20cm back so you are not inside your own collar."); DeathView = cfg.Bind("Death", "Death View", HowToFishVR.DeathView.FirstPerson, "FirstPerson = camera stays on the ragdoll's head (free head-look, head model hidden). ThirdPerson = the game's default third-person orbit around your body, head-tracked for VR."); MultiplayerVRSync = cfg.Bind("Multiplayer", "VR Pose Sync", true, "VR players broadcast their full-body poses (head, arms, hands, feet, body yaw) and every modded client — VR or flatscreen — applies them to remote players, so everyone sees VR players exactly as they see themselves (one-hand/two-hand grips included). Head look already syncs via the base game. Flatscreen modded players receive the same syncing as VR players; vanilla hosts are unaffected."); VRSyncRate = cfg.Bind("Multiplayer", "VR Pose Sync Rate", 60f, new ConfigDescription("Pose broadcast rate in Hz (5-60). MAVR-class smoothness is 60 Hz — higher = smoother but more bandwidth.", (AcceptableValueBase)(object)new AcceptableValueRange(5f, 60f), Array.Empty())); } } public static class Entrypoint { public static void Initialize() { VRActions.Initialize(); if (Plugin.VRRequested) { Plugin.VREnabled = OpenXRBoot.Start(); } try { Loc.Register(); } catch { } try { VRNetSync.Create(); RemoteBodyDriver.Create(); ApplyNetPatches(); } catch (Exception arg) { Plugin.Logger.LogError((object)$"VR networking failed to initialize: {arg}"); } if (Plugin.VREnabled) { VRRig.Create(); VRCameraPoser.Create(); VRDesktopMirror.Create(); VRCalibration.Create(); VRDamageOverlay.Create(); VRUIManager.Create(); VRLaser.Create(); VRSettingsPanel.Create(); VRHeldItem.Create(); BodyLifecycle.Create(); BlurCapture.Create(); ApplyPatchesResiliently(); } } private static void ApplyPatchesResiliently() { Type[] types = typeof(Plugin).Assembly.GetTypes(); foreach (Type type in types) { if (type.GetCustomAttributes(typeof(HarmonyPatch), inherit: true).Any() && !type.GetCustomAttributes(typeof(NetOnlyPatchAttribute), inherit: true).Any()) { try { Plugin.HarmonyInstance.CreateClassProcessor(type).Patch(); } catch (Exception ex) { Plugin.Logger.LogError((object)("Patch class '" + type.Name + "' failed: " + ex.Message)); } } } } private static void ApplyNetPatches() { Type[] types = typeof(Plugin).Assembly.GetTypes(); foreach (Type type in types) { if (type.GetCustomAttributes(typeof(NetOnlyPatchAttribute), inherit: true).Any()) { try { Plugin.HarmonyInstance.CreateClassProcessor(type).Patch(); } catch (Exception ex) { Plugin.Logger.LogError((object)("Net patch class '" + type.Name + "' failed: " + ex.Message)); } } } } } [BepInPlugin("com.jaxon.howtofishvr", "HowToFishXR", "1.0.0")] [BepInProcess("How to Fish.exe")] public class Plugin : BaseUnityPlugin { public const string Guid = "com.jaxon.howtofishvr"; public const string Name = "HowToFishXR"; public const string Version = "1.0.0"; public static Plugin Instance { get; private set; } public static ManualLogSource Logger { get; private set; } public static Harmony HarmonyInstance { get; private set; } public static bool VREnabled { get; internal set; } public static bool HeadsetActive { 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) if (!VREnabled) { return false; } try { if (!XRSettings.isDeviceActive) { return false; } InputDevice deviceAtXRNode = InputDevices.GetDeviceAtXRNode((XRNode)2); return ((InputDevice)(ref deviceAtXRNode)).isValid; } catch { return VREnabled; } } } public static bool VRRequested { get; private set; } private void Awake() { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown Instance = this; Logger = ((BaseUnityPlugin)this).Logger; Application.runInBackground = true; ResolveBundledAssemblies(); VRConfig.Init(((BaseUnityPlugin)this).Config); VRRequested = ResolveVRRequested(); HarmonyInstance = new Harmony("com.jaxon.howtofishvr"); try { Entrypoint.Initialize(); } catch (Exception arg) { Logger.LogError((object)$"Fatal error during VR initialization: {arg}"); } } private bool ResolveVRRequested() { bool flag = Environment.GetCommandLineArgs().Contains("--disable-vr", StringComparer.OrdinalIgnoreCase); return !(VRConfig.DisableVR.Value || flag); } private void ResolveBundledAssemblies() { string here = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); AppDomain.CurrentDomain.AssemblyResolve += delegate(object _, ResolveEventArgs args) { string text = new AssemblyName(args.Name).Name + ".dll"; string text2 = Path.Combine(here, text); if (File.Exists(text2)) { try { return Assembly.LoadFrom(text2); } catch { } } string text3 = Path.Combine(here, "RuntimeDeps", text); if (File.Exists(text3)) { try { return Assembly.LoadFrom(text3); } catch { } } return (Assembly)null; }; } } } namespace HowToFishVR.VR { internal sealed class BlurCapture : MonoBehaviour { private int _globalId; private RenderTexture _rt; private bool _haveContent; internal static BlurCapture Instance { get; private set; } internal bool HasBlur { get { if (_haveContent && (Object)(object)_rt != (Object)null) { return _rt.IsCreated(); } return false; } } internal static void Create() { //IL_0013: 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_001e: Expected O, but got Unknown if (!((Object)(object)Instance != (Object)null)) { GameObject val = new GameObject("HowToFishVR BlurCapture"); Object.DontDestroyOnLoad((Object)val); Instance = val.AddComponent(); } } private void Awake() { //IL_0049: Unknown result type (might be due to invalid IL or missing references) _globalId = Shader.PropertyToID("_GlobalUniversalBlurTexture"); int w = Mathf.Max(2, Screen.width / 2); int h = Mathf.Max(2, Screen.height / 2); EnsureRT(w, h); ClearRT(new Color(0.1f, 0.13f, 0.16f, 1f)); } private void OnEnable() { RenderPipelineManager.endCameraRendering += OnEndCamera; } private void OnDisable() { RenderPipelineManager.endCameraRendering -= OnEndCamera; } private void Update() { if ((Object)(object)_rt != (Object)null && _rt.IsCreated()) { Shader.SetGlobalTexture(_globalId, (Texture)(object)_rt); } } private void OnEndCamera(ScriptableRenderContext ctx, Camera cam) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 try { if ((Object)(object)cam == (Object)null || (int)cam.cameraType != 1) { return; } Texture globalTexture = Shader.GetGlobalTexture(_globalId); RenderTexture val = (RenderTexture)(object)((globalTexture is RenderTexture) ? globalTexture : null); if (!((Object)(object)val == (Object)null) && !((Object)(object)val == (Object)(object)_rt) && val.IsCreated()) { EnsureRT(((Texture)val).width, ((Texture)val).height); if (!((Object)(object)_rt == (Object)null)) { Graphics.Blit((Texture)(object)val, _rt); _haveContent = true; } } } catch { } } private void EnsureRT(int w, int h) { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown //IL_00bc: Unknown result type (might be due to invalid IL or missing references) if (w < 2 || h < 2 || ((Object)(object)_rt != (Object)null && ((Texture)_rt).width == w && ((Texture)_rt).height == h && _rt.IsCreated())) { return; } if ((Object)(object)_rt != (Object)null) { try { _rt.Release(); } catch { } } _rt = new RenderTexture(w, h, 0, (RenderTextureFormat)9) { name = "HowToFishVR_BlurCapture", useMipMap = false, autoGenerateMips = false, filterMode = (FilterMode)1, wrapMode = (TextureWrapMode)1 }; try { _rt.Create(); } catch { } ClearRT(new Color(0.1f, 0.13f, 0.16f, 1f)); } private void ClearRT(Color c) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_rt == (Object)null || !_rt.IsCreated()) { return; } RenderTexture active = RenderTexture.active; try { RenderTexture.active = _rt; GL.Clear(true, true, c); } catch { } finally { RenderTexture.active = active; } } private void OnDestroy() { if ((Object)(object)_rt != (Object)null) { try { _rt.Release(); } catch { } _rt = null; } if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } } public static class OpenXRBoot { private static XRGeneralSettings _general; private static XRManagerSettings _manager; private static OpenXRLoader _loader; public static bool Running { get; private set; } public static bool Start() { try { NeutralizeAnalytics(); BuildSettings(); if (!VerifySubsystemManifest()) { Plugin.Logger.LogError((object)"OpenXR subsystem descriptors not found. The native UnityOpenXR plugin / manifest was not staged into How to Fish_Data. Check the preloader ran."); return false; } if (!InitAndStart()) { Plugin.Logger.LogError((object)"OpenXR loader failed to produce a display subsystem. Is a headset connected and an OpenXR runtime active (SteamVR/Oculus/VD)?"); return false; } try { InputSystem.settings.backgroundBehavior = (BackgroundBehavior)2; } catch { } XRSettings.eyeTextureResolutionScale = 1f; SetFloorTrackingOrigin(); Running = true; return true; } catch (Exception arg) { Plugin.Logger.LogError((object)$"Exception while starting OpenXR: {arg}"); return false; } } public static void Stop() { if (!Running) { return; } try { XRManagerSettings manager = _manager; if (manager != null) { manager.StopSubsystems(); } XRManagerSettings manager2 = _manager; if (manager2 != null) { manager2.DeinitializeLoader(); } } catch { } Running = false; } private static void NeutralizeAnalytics() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown Type type = AccessTools.TypeByName("UnityEngine.XR.OpenXR.OpenXRAnalytics"); if (type == null) { return; } HarmonyMethod val = new HarmonyMethod(AccessTools.Method(typeof(OpenXRBoot), "SkipOriginal", (Type[])null, (Type[])null)); MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { if (!(methodInfo.DeclaringType != type) && !methodInfo.IsAbstract && !methodInfo.ContainsGenericParameters) { try { Plugin.HarmonyInstance.Patch((MethodBase)methodInfo, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } catch { } } } } private static bool SkipOriginal() { return false; } private static void BuildSettings() { if (_general == null) { _general = ScriptableObject.CreateInstance(); } if (_manager == null) { _manager = ScriptableObject.CreateInstance(); } if (_loader == null) { _loader = ScriptableObject.CreateInstance(); } Traverse.Create((object)_general).Property("Manager", (object[])null).SetValue((object)_manager); SetActiveLoaders(_manager, new List { (XRLoader)(object)_loader }); _manager.automaticLoading = false; _manager.automaticRunning = false; TrySetXRGeneralSettingsInstance(_general); ConfigureOpenXRSettings(); } private static void ConfigureOpenXRSettings() { OpenXRSettings val = OpenXRSettings.Instance; if ((Object)(object)val == (Object)null) { val = ScriptableObject.CreateInstance(); (AccessTools.Field(typeof(OpenXRSettings), "s_RuntimeSettingsInstance") ?? AccessTools.Field(typeof(OpenXRSettings), "s_Instance") ?? AccessTools.Field(typeof(OpenXRSettings), "m_Instance"))?.SetValue(null, val); } try { val.renderMode = (RenderMode)0; } catch { } try { val.depthSubmissionMode = (DepthSubmissionMode)0; } catch { } OpenXRFeature[] features = BuildInteractionFeatures(); SetFeatures(val, features); } private static OpenXRFeature[] BuildInteractionFeatures() { //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Expected O, but got Unknown Type[] obj = new Type[8] { typeof(OculusTouchControllerProfile), typeof(MetaQuestTouchPlusControllerProfile), typeof(MetaQuestTouchProControllerProfile), typeof(ValveIndexControllerProfile), typeof(HTCViveControllerProfile), typeof(MicrosoftMotionControllerProfile), typeof(HPReverbG2ControllerProfile), typeof(KHRSimpleControllerProfile) }; List list = new List(); Type[] array = obj; foreach (Type type in array) { try { if (typeof(OpenXRFeature).IsAssignableFrom(type)) { OpenXRFeature val = (OpenXRFeature)ScriptableObject.CreateInstance(type); Traverse.Create((object)val).Property("enabled", (object[])null).SetValue((object)true); list.Add(val); } } catch { } } if (list.Count == 0) { Plugin.Logger.LogError((object)"OpenXR started without any controller interaction profiles; motion-controller input will not work."); } return list.ToArray(); } private static bool InitAndStart() { TrySetXRGeneralSettingsInstance(_general); AccessTools.Field(typeof(XRGeneralSettings), "m_InitManagerOnStart")?.SetValue(_general, true); Environment.SetEnvironmentVariable("XR_RUNTIME_JSON", null); InvokePrivate(_general, "InitXRSDK"); InvokePrivate(_general, "Start"); List list = new List(); SubsystemManager.GetSubsystems(list); return list.Count > 0; } private static void InvokePrivate(object target, string method) { try { MethodInfo methodInfo = AccessTools.Method(target.GetType(), method, (Type[])null, (Type[])null); if (!(methodInfo == null)) { methodInfo.Invoke(target, null); } } catch { } } private static void SetFloorTrackingOrigin() { try { List list = new List(); SubsystemManager.GetSubsystems(list); foreach (XRInputSubsystem item in list) { if (item.TrySetTrackingOriginMode((TrackingOriginModeFlags)2)) { item.TryRecenter(); } } } catch { } } private static bool VerifySubsystemManifest() { List list = new List(); SubsystemManager.GetAllSubsystemDescriptors(list); List source = list.Select((ISubsystemDescriptor d) => d.id).ToList(); if (source.Any((string id) => id.Contains("OpenXR Display"))) { return source.Any((string id) => id.Contains("OpenXR Input")); } return false; } private static void SetActiveLoaders(XRManagerSettings manager, List loaders) { try { if (manager.activeLoaders is List list) { list.Clear(); list.AddRange(loaders); return; } } catch { } AccessTools.Field(typeof(XRManagerSettings), "m_Loaders")?.SetValue(manager, loaders); } private static void TrySetXRGeneralSettingsInstance(XRGeneralSettings general) { (AccessTools.Field(typeof(XRGeneralSettings), "s_RuntimeSettingsInstance") ?? AccessTools.Field(typeof(XRGeneralSettings), "s_Instance") ?? AccessTools.Field(typeof(XRGeneralSettings), "k_SettingsInstance"))?.SetValue(null, general); } private static void SetFeatures(OpenXRSettings settings, OpenXRFeature[] features) { PropertyInfo propertyInfo = AccessTools.Property(typeof(OpenXRSettings), "features"); if (propertyInfo != null && propertyInfo.CanWrite) { propertyInfo.SetValue(settings, features); } else { (AccessTools.Field(typeof(OpenXRSettings), "features") ?? AccessTools.Field(typeof(OpenXRSettings), "m_features") ?? AccessTools.Field(typeof(OpenXRSettings), "featureSets"))?.SetValue(settings, features); } } } public class VRCalibration : MonoBehaviour { private enum State { Idle, Prompt, Countdown, Done } private bool _f3WasDown; private State _state; private float _timer; private int _count; private Canvas _canvas; private Text _text; public static VRCalibration Instance { get; private set; } public static void Create() { //IL_0013: 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_001e: Expected O, but got Unknown if (!((Object)(object)Instance != (Object)null)) { GameObject val = new GameObject("HowToFishVR Calibration"); Object.DontDestroyOnLoad((Object)val); Instance = val.AddComponent(); Instance.BuildUI(); } } public void Begin() { if (_state == State.Idle) { _state = State.Prompt; _timer = 0f; } } private void BuildUI() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //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_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_0072: 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_0087: Expected O, but got Unknown //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0102: 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_010d: 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_0118: 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) GameObject val = new GameObject("Calibration Canvas"); val.transform.SetParent(((Component)this).transform, false); val.layer = 5; _canvas = val.AddComponent(); _canvas.renderMode = (RenderMode)2; val.AddComponent(); RectTransform val2 = (RectTransform)((Component)_canvas).transform; val2.sizeDelta = new Vector2(800f, 300f); ((Transform)val2).localScale = Vector3.one * 0.0015f; GameObject val3 = new GameObject("Text"); val3.transform.SetParent(val.transform, false); val3.layer = 5; _text = val3.AddComponent(); _text.font = FindFont(); _text.fontSize = 48; _text.alignment = (TextAnchor)4; ((Graphic)_text).color = Color.white; _text.horizontalOverflow = (HorizontalWrapMode)0; RectTransform val4 = (RectTransform)((Component)_text).transform; val4.anchorMin = Vector2.zero; val4.anchorMax = Vector2.one; val4.offsetMin = Vector2.zero; val4.offsetMax = Vector2.zero; val.SetActive(false); } private static Font FindFont() { try { Font builtinResource = Resources.GetBuiltinResource("LegacyRuntime.ttf"); if ((Object)(object)builtinResource != (Object)null) { return builtinResource; } } catch { } try { Font val = Font.CreateDynamicFontFromOSFont("Arial", 48); if ((Object)(object)val != (Object)null) { return val; } } catch { } try { Font val2 = Font.CreateDynamicFontFromOSFont("Segoe UI", 48); if ((Object)(object)val2 != (Object)null) { return val2; } } catch { } return null; } private void Update() { //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) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: 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_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.VREnabled) { return; } bool flag = false; try { KeyboardShortcut value = VRConfig.HeightCalibrateKey.Value; flag = ((KeyboardShortcut)(ref value)).IsDown(); } catch { } try { if (Input.GetKey((KeyCode)284)) { flag = true; } } catch { } if (flag && !_f3WasDown && _state == State.Idle) { Begin(); } _f3WasDown = flag; VRRig instance = VRRig.Instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance.Head == (Object)null) { return; } bool flag2 = _state != State.Idle; if ((Object)(object)_canvas != (Object)null && ((Component)_canvas).gameObject.activeSelf != flag2) { ((Component)_canvas).gameObject.SetActive(flag2); } if (!flag2) { return; } Transform head = instance.Head; Vector3 forward = head.forward; forward.y = 0f; if (((Vector3)(ref forward)).sqrMagnitude > 0.0001f) { ((Vector3)(ref forward)).Normalize(); ((Component)_canvas).transform.position = head.position + forward * 1.2f; ((Component)_canvas).transform.rotation = Quaternion.LookRotation(forward, Vector3.up); } switch (_state) { case State.Prompt: _text.text = "Stand up straight and hold a T-pose\n(arms straight out to the sides)"; if (IsTPose(instance)) { _timer += Time.deltaTime; if (_timer >= 0.5f) { _state = State.Countdown; _count = 3; _timer = 0f; } } else { _timer = 0f; } break; case State.Countdown: if (!IsTPose(instance)) { _state = State.Prompt; _timer = 0f; break; } _text.text = $"Hold still...\n{_count}"; _timer += Time.deltaTime; if (_timer >= 1f) { _timer = 0f; _count--; if (_count <= 0) { instance.CalibrateNow(); _state = State.Done; _text.text = "Calibrated!"; Pulse(); } } break; case State.Done: _timer += Time.deltaTime; if (_timer >= 1.5f) { _state = State.Idle; _timer = 0f; } break; } } private static void Pulse() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_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) try { InputDevice deviceAtXRNode = InputDevices.GetDeviceAtXRNode((XRNode)4); InputDevice deviceAtXRNode2 = InputDevices.GetDeviceAtXRNode((XRNode)5); if (((InputDevice)(ref deviceAtXRNode)).isValid) { ((InputDevice)(ref deviceAtXRNode)).SendHapticImpulse(0u, 0.6f, 0.25f); } if (((InputDevice)(ref deviceAtXRNode2)).isValid) { ((InputDevice)(ref deviceAtXRNode2)).SendHapticImpulse(0u, 0.6f, 0.25f); } } catch { } } private static bool IsTPose(VRRig rig) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: 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) Vector3 position = rig.Head.position; Vector3 position2 = rig.LeftHand.position; Vector3 position3 = rig.RightHand.position; bool num = Mathf.Abs(position2.y - position.y) < 0.45f && Mathf.Abs(position3.y - position.y) < 0.45f; Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(position2.x - position.x, 0f, position2.z - position.z); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(position3.x - position.x, 0f, position3.z - position.z); bool flag = ((Vector3)(ref val)).magnitude > 0.35f && ((Vector3)(ref val2)).magnitude > 0.35f; bool flag2 = Vector3.Dot(((Vector3)(ref val)).normalized, ((Vector3)(ref val2)).normalized) < -0.3f; return num && flag && flag2; } } public static class VRCameraPoser { public static VRCameraPoser_Behaviour Instance; public static void Create() { //IL_0013: 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_001e: Expected O, but got Unknown if (!((Object)(object)Instance != (Object)null)) { GameObject val = new GameObject("HowToFishVR CameraPoser"); Object.DontDestroyOnLoad((Object)val); Instance = val.AddComponent(); } } } public class VRCameraPoser_Behaviour : MonoBehaviour { private static Transform _deadHead; private static Vector3 _deadHeadScale = Vector3.one; private static bool _deadHeadHidden; private static SelfDrivingBoat _menuBoat; private static Transform _menuCameraTarget; private static Vector3 _menuTargetLocalOffset; private static bool _menuAnchorInit; private static bool _customizationPoseActive; private static SelfDrivingBoat _customizationBoat; private static float _customizationNeutralHeadYaw; private static float _customizationStartTurnYaw; private static bool TryGetRagdollHead(out Vector3 pos) { //IL_0001: 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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) pos = default(Vector3); try { Player localPlayer = Player.LocalPlayer; if ((Object)(object)localPlayer == (Object)null || (Object)(object)localPlayer.Dying == (Object)null || !localPlayer.Dying.IsDead) { return false; } DeadPlayer deadPlayer = localPlayer.Dying.DeadPlayer; if ((Object)(object)deadPlayer == (Object)null) { return false; } if ((Object)(object)deadPlayer._mouthUpper != (Object)null) { pos = deadPlayer._mouthUpper.position; return true; } pos = ((Component)deadPlayer).transform.position + Vector3.up * 0.2f; return true; } catch { return false; } } private static void HideDeadHead() { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) try { if (_deadHeadHidden && (Object)(object)_deadHead != (Object)null) { return; } if ((Object)(object)_deadHead == (Object)null) { Player localPlayer = Player.LocalPlayer; if ((Object)(object)localPlayer == (Object)null || (Object)(object)localPlayer.Dying == (Object)null || (Object)(object)localPlayer.Dying.DeadPlayer == (Object)null) { return; } _deadHead = FindHeadBone(((Component)localPlayer.Dying.DeadPlayer).transform); if ((Object)(object)_deadHead == (Object)null) { _deadHeadHidden = true; return; } _deadHeadScale = _deadHead.localScale; } if ((Object)(object)_deadHead != (Object)null) { _deadHead.localScale = Vector3.zero; } _deadHeadHidden = true; } catch { } } private static void RestoreDeadHead() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_deadHead != (Object)null && _deadHeadHidden) { _deadHead.localScale = _deadHeadScale; } _deadHead = null; _deadHeadHidden = false; } private static Transform FindHeadBone(Transform root) { if ((Object)(object)root == (Object)null) { return null; } Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren(true); foreach (Transform val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && ((Object)val).name != null) { string name = ((Object)val).name; if (name.IndexOf("Head", StringComparison.OrdinalIgnoreCase) >= 0 && name.IndexOf("Holder", StringComparison.OrdinalIgnoreCase) < 0 && name.IndexOf("hold", StringComparison.OrdinalIgnoreCase) < 0 && name.IndexOf("mouth", StringComparison.OrdinalIgnoreCase) < 0 && name.IndexOf("hair", StringComparison.OrdinalIgnoreCase) < 0) { return val; } } } return null; } private static Vector3 MenuBoatAnchor(Camera primary) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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_00ca: 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_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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0109: 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_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_0103: Unknown result type (might be due to invalid IL or missing references) SelfDrivingBoat val = null; Transform val2 = null; Vector3 val3 = default(Vector3); try { MainMenuManager instance = MainMenuManager._instance; if ((Object)(object)instance != (Object)null) { val = instance._boat; } if ((Object)(object)val != (Object)null) { bool isInSkinCustomization = LocalSkin.IsInSkinCustomization; val2 = (isInSkinCustomization ? val._skinCustomizationPos : val._defaultCamPos); if ((Object)(object)val2 == (Object)null) { val2 = ((Component)val).transform; } val3 = val2.position; val3.y = (isInSkinCustomization ? val._skinCustomizationHeight : val._defaultHeight); } } catch { } if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null) { return ((Component)primary).transform.position; } if (!_menuAnchorInit || (Object)(object)_menuBoat != (Object)(object)val) { _menuBoat = val; if (!LocalSkin.IsInSkinCustomization) { _menuTargetLocalOffset = Quaternion.Inverse(val2.rotation) * (((Component)primary).transform.position - val3); } _menuAnchorInit = true; } _menuCameraTarget = val2; if (!LocalSkin.IsInSkinCustomization) { return val3 + val2.rotation * _menuTargetLocalOffset; } return val3; } internal static bool TryGetCustomizationOrigin(Quaternion headRotation, float turnYaw, out Quaternion origin) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: 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_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0103: 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) origin = Quaternion.identity; try { if (!MainMenuManager.IsInMenu || !LocalSkin.IsInSkinCustomization) { _customizationPoseActive = false; _customizationBoat = null; return false; } MainMenuManager instance = MainMenuManager._instance; SelfDrivingBoat val = (((Object)(object)instance != (Object)null) ? instance._boat : null); if ((Object)(object)val == (Object)null || (Object)(object)val._skinCustomizationPos == (Object)null || (Object)(object)val._skinCustomizationLookAt == (Object)null) { return false; } if (!_customizationPoseActive || (Object)(object)_customizationBoat != (Object)(object)val) { _customizationPoseActive = true; _customizationBoat = val; _customizationNeutralHeadYaw = ((Quaternion)(ref headRotation)).eulerAngles.y; _customizationStartTurnYaw = turnYaw; } Vector3 position = val._skinCustomizationPos.position; position.y = val._skinCustomizationHeight; Vector3 val2 = val._skinCustomizationLookAt.position - position; val2.y = 0f; if (((Vector3)(ref val2)).sqrMagnitude < 1E-06f) { return false; } Quaternion val3 = Quaternion.LookRotation(val2, Vector3.up); float y = ((Quaternion)(ref val3)).eulerAngles.y; float num = Mathf.DeltaAngle(_customizationStartTurnYaw, turnYaw); origin = Quaternion.Euler(0f, y - _customizationNeutralHeadYaw + num, 0f); return true; } catch { return false; } } private static void ClearTp() { _menuAnchorInit = false; _menuBoat = null; _menuCameraTarget = null; _customizationPoseActive = false; _customizationBoat = null; } private void OnEnable() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown Application.onBeforeRender += new UnityAction(Pose); } private void OnDisable() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown Application.onBeforeRender -= new UnityAction(Pose); } public void Recalibrate() { } private void Pose() { //IL_0225: 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) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0240: 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_0249: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_025e: 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_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: 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_02d0: 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_0103: 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_0308: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Unknown result type (might be due to invalid IL or missing references) //IL_0318: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Unknown result type (might be due to invalid IL or missing references) //IL_043c: Unknown result type (might be due to invalid IL or missing references) //IL_0441: Unknown result type (might be due to invalid IL or missing references) //IL_0449: Unknown result type (might be due to invalid IL or missing references) //IL_044b: 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_044f: Unknown result type (might be due to invalid IL or missing references) //IL_0454: Unknown result type (might be due to invalid IL or missing references) //IL_046c: Unknown result type (might be due to invalid IL or missing references) //IL_046e: Unknown result type (might be due to invalid IL or missing references) //IL_0470: 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_0473: Unknown result type (might be due to invalid IL or missing references) //IL_0478: Unknown result type (might be due to invalid IL or missing references) //IL_047d: Unknown result type (might be due to invalid IL or missing references) //IL_048e: Unknown result type (might be due to invalid IL or missing references) //IL_0490: Unknown result type (might be due to invalid IL or missing references) //IL_0491: 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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0366: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Unknown result type (might be due to invalid IL or missing references) //IL_0378: Unknown result type (might be due to invalid IL or missing references) //IL_037a: Unknown result type (might be due to invalid IL or missing references) //IL_037b: Unknown result type (might be due to invalid IL or missing references) //IL_0334: Unknown result type (might be due to invalid IL or missing references) //IL_0342: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) try { if (!Plugin.HeadsetActive) { return; } VRActions instance = VRActions.Instance; VRRig instance2 = VRRig.Instance; if (instance == null || (Object)(object)instance2 == (Object)null || (Object)(object)instance2.Root == (Object)null || !instance2.IsCalibrated) { return; } Vector3 headPos = instance.HeadPos; Quaternion headRot = instance.HeadRot; Quaternion rotation = instance2.Root.rotation; Vector3 headCalib = instance2.HeadCalib; Camera val = null; try { Player localPlayer = Player.LocalPlayer; if ((Object)(object)localPlayer != (Object)null && (Object)(object)localPlayer.Camera != (Object)null) { val = localPlayer.Camera.Cam; } } catch { } if ((Object)(object)instance2.Head != (Object)null) { instance2.Head.localPosition = headPos; instance2.Head.localRotation = headRot; } if ((Object)(object)instance2.LeftHand != (Object)null) { instance2.LeftHand.localPosition = instance.LeftPos; instance2.LeftHand.localRotation = instance.LeftRot; } if ((Object)(object)instance2.RightHand != (Object)null) { instance2.RightHand.localPosition = instance.RightPos; instance2.RightHand.localRotation = instance.RightRot; } if ((Object)(object)val != (Object)null) { ClearTp(); if (!((Behaviour)val).isActiveAndEnabled) { Transform val2 = ((Component)val).transform; while ((Object)(object)val2 != (Object)null) { if (!((Component)val2).gameObject.activeSelf) { ((Component)val2).gameObject.SetActive(true); } val2 = val2.parent; } if (!((Behaviour)val).enabled) { ((Behaviour)val).enabled = true; } } if ((Object)(object)val.targetTexture != (Object)null) { val.targetTexture = null; } CameraOutputPatches.EnsureXR(val); if (TryGetRagdollHead(out var pos)) { if (VRConfig.DeathView.Value == DeathView.ThirdPerson) { RestoreDeadHead(); Vector3 val3 = pos; try { DeadPlayer val4 = (((Object)(object)Player.LocalPlayer != (Object)null && (Object)(object)Player.LocalPlayer.Dying != (Object)null) ? Player.LocalPlayer.Dying.DeadPlayer : null); if ((Object)(object)val4 != (Object)null && (Object)(object)((Component)val4).transform != (Object)null) { val3 = ((Component)val4).transform.position; } } catch { } val3 += Vector3.up * 0.55f; Quaternion val5 = rotation * headRot; Vector3 eulerAngles = ((Quaternion)(ref val5)).eulerAngles; Quaternion val6 = Quaternion.Euler(Mathf.Clamp((eulerAngles.x > 180f) ? (eulerAngles.x - 360f) : eulerAngles.x, -85f, 85f), eulerAngles.y, 0f); float num = 2.6f; Vector3 val7 = val3 + val6 * (Vector3.forward * (0f - num)); Vector3 val8 = val3 - val7; Vector3 normalized = ((Vector3)(ref val8)).normalized; RaycastHit val9 = default(RaycastHit); if (Physics.Raycast(val3, normalized, ref val9, num, LayerMask.op_Implicit(GameInfo.LevelLayer))) { val7 = ((RaycastHit)(ref val9)).point - normalized * 0.25f; } ((Component)val).transform.position = val7; ((Component)val).transform.rotation = rotation * headRot; } else { HideDeadHead(); ((Component)val).transform.position = pos; ((Component)val).transform.rotation = rotation * headRot; } } else { RestoreDeadHead(); ((Component)val).transform.position = instance2.Root.TransformPoint(headPos); ((Component)val).transform.rotation = rotation * headRot; } } else { Camera val10 = null; try { MainMenuManager instance3 = MainMenuManager._instance; if ((Object)(object)instance3 != (Object)null && (Object)(object)instance3._menuCam != (Object)null && ((Behaviour)instance3._menuCam).isActiveAndEnabled && (Object)(object)instance3._menuCam.targetTexture == (Object)null) { val10 = instance3._menuCam; } } catch { } Camera[] allCameras = Camera.allCameras; foreach (Camera val11 in allCameras) { if ((Object)(object)val10 == (Object)null && (Object)(object)val11 != (Object)null && ((Behaviour)val11).isActiveAndEnabled && (Object)(object)val11.targetTexture == (Object)null) { val10 = val11; break; } } if ((Object)(object)val10 != (Object)null) { Vector3 val12 = MenuBoatAnchor(val10); instance2.Root.position = val12 - rotation * headCalib; CameraOutputPatches.EnsureXR(val10); ((Component)val10).transform.position = val12 + rotation * (headPos - headCalib); ((Component)val10).transform.rotation = rotation * headRot; } } WaterUnderwaterPatches.UpdateFromRenderedVRView(); VRDamageOverlay.Instance?.RepositionNow(); try { Player localPlayer2 = Player.LocalPlayer; if ((Object)(object)localPlayer2 != (Object)null && (Object)(object)localPlayer2.Hands != (Object)null) { PlayerHandsPatches.ApplyTrackedHands(localPlayer2.Hands); } ArmRig.SolveCurrentPose(localPlayer2); } catch { } VRUIManager.Instance?.RepositionNow(); try { XRSettings.gameViewRenderMode = (GameViewRenderMode)1; } catch { } VRDesktopMirror.Instance?.SyncToViewCamera(); } catch { } } } [HarmonyPatch(typeof(ShaderManager))] public class VRDamageOverlay : MonoBehaviour { private Canvas _canvas; private Image _img; private Image _deathBackdrop; private float _deathBackdropAlpha; private readonly float _alphaMul = 0.95f; private const float NativeDeathBackdropAlpha = 0.4f; private const float NativeDeathFadeSpeed = 2.5f; public static VRDamageOverlay Instance { get; private set; } public static void Create() { //IL_0013: 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_001e: Expected O, but got Unknown if (!((Object)(object)Instance != (Object)null)) { GameObject val = new GameObject("HowToFishVR DamageOverlay"); Object.DontDestroyOnLoad((Object)val); Instance = val.AddComponent(); Instance.Build(); } } private void Build() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: 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_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_00e3: 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_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: 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_0131: Expected O, but got Unknown //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Expected O, but got Unknown //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_017d: 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_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Expected O, but got Unknown GameObject val = new GameObject("Canvas"); val.transform.SetParent(((Component)this).transform, false); val.layer = 5; _canvas = val.AddComponent(); _canvas.renderMode = (RenderMode)2; _canvas.sortingOrder = 600; val.AddComponent(); RectTransform val2 = (RectTransform)val.transform; val2.sizeDelta = new Vector2(1920f, 1080f); ((Transform)val2).localScale = Vector3.one * 0.0016f; GameObject val3 = new GameObject("DeathBackdrop"); val3.transform.SetParent(val.transform, false); val3.layer = 5; _deathBackdrop = val3.AddComponent(); RectTransform val4 = (RectTransform)val3.transform; val4.anchorMin = Vector2.zero; val4.anchorMax = Vector2.one; val4.offsetMin = Vector2.zero; val4.offsetMax = Vector2.zero; ((Graphic)_deathBackdrop).color = Color.clear; ((Graphic)_deathBackdrop).raycastTarget = false; try { ((Graphic)_deathBackdrop).material = new Material(Canvas.GetDefaultCanvasMaterial()) { name = "VR Native Death Backdrop", hideFlags = (HideFlags)61 }; } catch { } GameObject val5 = new GameObject("Vignette"); val5.transform.SetParent(val.transform, false); val5.layer = 5; _img = val5.AddComponent(); RectTransform val6 = (RectTransform)val5.transform; val6.anchorMin = Vector2.zero; val6.anchorMax = Vector2.one; val6.offsetMin = Vector2.zero; val6.offsetMax = Vector2.zero; ((Graphic)_img).color = new Color(0f, 0f, 0f, 0f); ((Graphic)_img).raycastTarget = false; try { _img.sprite = MakeDamageVignetteSprite(); } catch { } try { Material material = new Material(Canvas.GetDefaultCanvasMaterial()) { name = "VR DamageOverlay", hideFlags = (HideFlags)61 }; ((Graphic)_img).material = material; } catch { } val.SetActive(false); } private void LateUpdate() { if (Plugin.VREnabled) { RepositionNow(); UpdateDeathBackdrop(); } } public void RepositionNow() { //IL_008d: 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_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.VREnabled || (Object)(object)_canvas == (Object)null) { return; } VRRig instance = VRRig.Instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance.Head == (Object)null) { return; } Transform val = instance.Head; try { Player localPlayer = Player.LocalPlayer; if ((Object)(object)localPlayer != (Object)null && (Object)(object)localPlayer.Camera != (Object)null && (Object)(object)localPlayer.Camera.Cam != (Object)null) { val = ((Component)localPlayer.Camera.Cam).transform; } } catch { } ((Component)_canvas).transform.position = val.position + val.forward * 0.35f; ((Component)_canvas).transform.rotation = val.rotation; } private void UpdateCanvasActive() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_canvas == (Object)null) && !((Object)(object)_img == (Object)null)) { bool flag = ((Graphic)_img).color.a > 0.005f || _deathBackdropAlpha > 0.005f; if (((Component)_canvas).gameObject.activeSelf != flag) { ((Component)_canvas).gameObject.SetActive(flag); } } } private void UpdateDeathBackdrop() { //IL_00aa: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_deathBackdrop == (Object)null)) { bool flag = false; try { Player localPlayer = Player.LocalPlayer; flag = (Object)(object)localPlayer != (Object)null && (Object)(object)localPlayer.Dying != (Object)null && localPlayer.Dying.IsDead; } catch { } float num = (flag ? 0.4f : 0f); _deathBackdropAlpha = Mathf.Lerp(_deathBackdropAlpha, num, Mathf.Clamp01(Time.deltaTime * 2.5f)); if (Mathf.Abs(_deathBackdropAlpha - num) < 0.001f) { _deathBackdropAlpha = num; } ((Graphic)_deathBackdrop).color = new Color(0f, 0f, 0f, _deathBackdropAlpha); UpdateCanvasActive(); } } private static Sprite MakeDamageVignetteSprite() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_002c: Expected O, but got Unknown //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(256, 256, (TextureFormat)4, false) { name = "VR Damage Vignette Gradient", hideFlags = (HideFlags)61, wrapMode = (TextureWrapMode)1 }; for (int i = 0; i < 256; i++) { for (int j = 0; j < 256; j++) { float num = ((float)j + 0.5f) / 256f * 2f - 1f; float num2 = ((float)i + 0.5f) / 256f * 2f - 1f; float num3 = Mathf.Clamp01((Mathf.Sqrt(num * num + num2 * num2) - 0.55f) / 0.75f); float num4 = num3 * num3 * (3f - 2f * num3); val.SetPixel(j, i, new Color(0f, 0f, 0f, num4)); } } val.Apply(); return Sprite.Create(val, new Rect(0f, 0f, 256f, 256f), new Vector2(0.5f, 0.5f)); } private void Apply(float intensity, Color color) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_img == (Object)null) && !((Object)(object)_canvas == (Object)null)) { float num = Mathf.Clamp01(intensity * _alphaMul); ((Graphic)_img).color = new Color(color.r, color.g, color.b, num); UpdateCanvasActive(); } } [HarmonyPostfix] [HarmonyPatch("UpdateVignette")] private static void OnUpdateVignette(float intensity, Color color) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) if (Plugin.VREnabled && (Object)(object)Instance != (Object)null) { Instance.Apply(intensity, color); } } } public class VRDesktopMirror : MonoBehaviour { private Camera _mirrorCam; private RenderTexture _rt; public static VRDesktopMirror Instance { get; private set; } public static void Create() { //IL_0013: 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_001e: Expected O, but got Unknown if (!((Object)(object)Instance != (Object)null)) { GameObject val = new GameObject("HowToFishVR DesktopMirror"); Object.DontDestroyOnLoad((Object)val); Instance = val.AddComponent(); } } private void Awake() { //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_0022: Expected O, but got Unknown //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Expected O, but got Unknown //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011a: 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_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0130: 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_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) try { _rt = new RenderTexture(1280, 720, 24) { name = "HowToFishVR DesktopMirror RT" }; GameObject val = new GameObject("HowToFishVR DesktopMirrorCam"); val.transform.SetParent(((Component)this).transform, false); _mirrorCam = val.AddComponent(); _mirrorCam.targetTexture = _rt; ((Behaviour)_mirrorCam).enabled = true; _mirrorCam.depth = -100f; _mirrorCam.stereoTargetEye = (StereoTargetEyeMask)0; try { UniversalAdditionalCameraData universalAdditionalCameraData = CameraExtensions.GetUniversalAdditionalCameraData(_mirrorCam); if ((Object)(object)universalAdditionalCameraData != (Object)null) { universalAdditionalCameraData.allowXRRendering = false; universalAdditionalCameraData.renderPostProcessing = false; } } catch { } GameObject val2 = new GameObject("HowToFishVR DesktopMirrorCanvas"); val2.transform.SetParent(((Component)this).transform, false); Canvas obj2 = val2.AddComponent(); obj2.renderMode = (RenderMode)0; obj2.sortingOrder = -1000; GameObject val3 = new GameObject("Mirror", new Type[1] { typeof(RectTransform) }); val3.transform.SetParent(val2.transform, false); RectTransform val4 = (RectTransform)val3.transform; val4.anchorMin = Vector2.zero; val4.anchorMax = Vector2.one; val4.offsetMin = Vector2.zero; val4.offsetMax = Vector2.zero; RawImage obj3 = val3.AddComponent(); obj3.texture = (Texture)(object)_rt; ((Graphic)obj3).raycastTarget = false; obj3.uvRect = new Rect(0f, 0f, 1f, 1f); } catch { } } public void SyncToViewCamera() { //IL_0043: 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) try { if (!((Object)(object)_mirrorCam == (Object)null) && !((Object)(object)_rt == (Object)null)) { Camera viewCamera = GetViewCamera(); if (!((Object)(object)viewCamera == (Object)null)) { ((Component)_mirrorCam).transform.SetPositionAndRotation(((Component)viewCamera).transform.position, ((Component)viewCamera).transform.rotation); _mirrorCam.cullingMask = viewCamera.cullingMask; _mirrorCam.fieldOfView = viewCamera.fieldOfView; _mirrorCam.nearClipPlane = viewCamera.nearClipPlane; _mirrorCam.farClipPlane = viewCamera.farClipPlane; } } } catch { } } private static Camera GetViewCamera() { try { Player localPlayer = Player.LocalPlayer; if ((Object)(object)localPlayer != (Object)null && (Object)(object)localPlayer.Camera != (Object)null && (Object)(object)localPlayer.Camera.Cam != (Object)null && ((Behaviour)localPlayer.Camera.Cam).isActiveAndEnabled) { return localPlayer.Camera.Cam; } } catch { } Camera[] allCameras = Camera.allCameras; foreach (Camera val in allCameras) { if ((Object)(object)val != (Object)null && ((Behaviour)val).isActiveAndEnabled && (Object)(object)val.targetTexture == (Object)null) { return val; } } return null; } private void OnDestroy() { try { if ((Object)(object)_rt != (Object)null) { _rt.Release(); } } catch { } } } [DefaultExecutionOrder(-500)] public class VRHeldItem : MonoBehaviour { private static Item _lastHeld; private static readonly List _frozen = new List(); private static bool _fishTwoHand; private static Item _supportLatchItem; private const float FishLatchRadius = 0.3f; private static bool _revivePinned; private static Vector3 _reviveOffset; private static Quaternion _reviveRotOffset; private static Explosive _lighterGripItem; private static Vector3 _lighterFromHandPos; private static Quaternion _lighterFromHandRot = Quaternion.identity; private static bool _lighterFromHandValid; public static bool FishTwoHand => _fishTwoHand; public static void Create() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown GameObject val = new GameObject("HowToFishVR HeldItem"); Object.DontDestroyOnLoad((Object)val); val.AddComponent(); } private void LateUpdate() { Pose(); } private static void RestoreLastHeld() { if ((Object)(object)_lastHeld == (Object)null && _frozen.Count == 0) { return; } for (int i = 0; i < _frozen.Count; i++) { try { if ((Object)(object)_frozen[i] != (Object)null && _frozen[i].isKinematic) { _frozen[i].isKinematic = false; } } catch { } } _frozen.Clear(); _lastHeld = null; } private static void ClearSupportHandLatch() { _fishTwoHand = false; _supportLatchItem = null; } private static void FreezeWholeItem(Item held) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) _frozen.Clear(); Rigidbody[] array = null; try { array = ((Component)held).GetComponentsInChildren(true); } catch { } if (array != null) { Rigidbody[] array2 = array; foreach (Rigidbody val in array2) { if (!((Object)(object)val == (Object)null) && !val.isKinematic) { val.linearVelocity = Vector3.zero; val.angularVelocity = Vector3.zero; val.isKinematic = true; _frozen.Add(val); } } } else if ((Object)(object)held.Rig != (Object)null && !held.Rig.isKinematic) { held.Rig.isKinematic = true; _frozen.Add(held.Rig); } } private static void FreezeRig(Rigidbody rb) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)rb == (Object)null)) { if (!rb.isKinematic) { rb.linearVelocity = Vector3.zero; rb.angularVelocity = Vector3.zero; } rb.isKinematic = true; } } private static bool TryGetHandPoseLocal(Item held, HandTransforms ht, out Vector3 localPos, out Quaternion localRot) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) localPos = default(Vector3); localRot = Quaternion.identity; if ((Object)(object)held == (Object)null || ht == null || !ht.Exists) { return false; } try { Transform obj = (((Object)(object)ht.Parent != (Object)null) ? ht.Parent : ((Component)held).transform); Vector3 val = obj.TransformPoint(ht.HandPos); Quaternion val2 = obj.rotation * ht.HandRot; localPos = ((Component)held).transform.InverseTransformPoint(val); localRot = Quaternion.Inverse(((Component)held).transform.rotation) * val2; return true; } catch { return false; } } private void Pose() { //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_027e: 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_0238: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0242: 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_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_0335: Unknown result type (might be due to invalid IL or missing references) //IL_033c: Unknown result type (might be due to invalid IL or missing references) //IL_0350: Unknown result type (might be due to invalid IL or missing references) //IL_0355: Unknown result type (might be due to invalid IL or missing references) //IL_035a: Unknown result type (might be due to invalid IL or missing references) //IL_0361: 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_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: 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_0305: Unknown result type (might be due to invalid IL or missing references) //IL_0307: 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_030e: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_031b: Unknown result type (might be due to invalid IL or missing references) //IL_031d: Unknown result type (might be due to invalid IL or missing references) try { if (!Plugin.HeadsetActive) { RestoreLastHeld(); ClearSupportHandLatch(); return; } VRRig instance = VRRig.Instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance.RightHand == (Object)null || (Object)(object)instance.LeftHand == (Object)null) { RestoreLastHeld(); ClearSupportHandLatch(); return; } Player val = null; try { val = Player.LocalPlayer; } catch { } if ((Object)(object)val == (Object)null) { RestoreLastHeld(); ClearSupportHandLatch(); return; } try { if (Boat.IsDrivingLocally) { RestoreLastHeld(); ClearSupportHandLatch(); return; } } catch { } Item val2 = null; try { val2 = (((Object)(object)val.Holding != (Object)null) ? val.Holding.HeldItem : null); } catch { } if ((Object)(object)val2 == (Object)null) { RestoreLastHeld(); ClearSupportHandLatch(); return; } if (val2 is Tool) { RestoreLastHeld(); ClearSupportHandLatch(); return; } if ((Object)(object)((Component)val2).transform == (Object)null) { RestoreLastHeld(); ClearSupportHandLatch(); return; } if (HeldItemHoldPatches.ShouldHandHold(val.Holding)) { RestoreLastHeld(); _lastHeld = null; if ((Object)(object)_supportLatchItem != (Object)(object)val2) { _fishTwoHand = false; _supportLatchItem = val2; } UpdateFishTwoHand(instance, val2); return; } ClearSupportHandLatch(); if ((Object)(object)val2 != (Object)(object)_lastHeld) { RestoreLastHeld(); _fishTwoHand = false; FreezeWholeItem(val2); _lastHeld = val2; } _ = (Object)(object)val2.HandModelRight != (Object)null; _ = (Object)(object)val2.HandModelLeft != (Object)null; Vector3 localPos; Quaternion localRot; bool flag = TryGetHandPoseLocal(val2, val2.HandTransformsRight, out localPos, out localRot); TryGetHandPoseLocal(val2, val2.HandTransformsLeft, out var _, out var _); bool flag2 = false; try { flag2 = ((DeadPlayer)(((val2 is DeadPlayer) ? val2 : null)?))._isResurrecting ?? false; } catch { } Transform mainHand = instance.MainHand; if ((Object)(object)mainHand == (Object)null) { RestoreLastHeld(); return; } if (flag2) { if (!_revivePinned) { _revivePinned = true; _reviveOffset = ((Component)val2).transform.position - mainHand.position; _reviveRotOffset = Quaternion.Inverse(mainHand.rotation) * ((Component)val2).transform.rotation; } ((Component)val2).transform.SetPositionAndRotation(mainHand.position + _reviveOffset, mainHand.rotation * _reviveRotOffset); PinExplosiveLighter(instance, val2); return; } _revivePinned = false; try { Transform handModelRight = val2.HandModelRight; bool flag3 = flag; Vector3 val3 = localPos; Quaternion val4 = localRot; if ((Object)(object)handModelRight != (Object)null) { Quaternion rotation = mainHand.rotation; Vector3 val5 = mainHand.position - rotation * ((Component)val2).transform.InverseTransformPoint(handModelRight.position); ((Component)val2).transform.SetPositionAndRotation(val5, rotation); PinExplosiveLighter(instance, val2); return; } if (flag3) { Quaternion rightGripOffset = PlayerHandsPatches.RightGripOffset; Quaternion val6 = mainHand.rotation * rightGripOffset * Quaternion.Inverse(val4); Vector3 val7 = mainHand.position - val6 * val3; ((Component)val2).transform.SetPositionAndRotation(val7, val6); PinExplosiveLighter(instance, val2); return; } ((Component)val2).transform.SetPositionAndRotation(mainHand.position + mainHand.rotation * new Vector3(0f, -0.06f, 0.2f), mainHand.rotation); } catch { } PinExplosiveLighter(instance, val2); } catch { } } private static void PinExplosiveLighter(VRRig rig, Item held) { //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_019a: 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_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: 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_00fe: 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_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_012e: 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_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0157: 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_015d: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) try { Explosive val = (Explosive)(object)((held is Explosive) ? held : null); if (val == null || (Object)(object)val._lighter == (Object)null || !((Component)val._lighter).gameObject.activeInHierarchy || val._isActivated || val._lighterPickupPercent < 1f) { return; } Player localPlayer = Player.LocalPlayer; PlayerHands val2 = (((Object)(object)localPlayer != (Object)null) ? localPlayer.Hands : null); if ((Object)(object)val2 == (Object)null) { return; } Transform handBoneLeft = val2.HandBoneLeft; if ((Object)(object)handBoneLeft == (Object)null) { return; } if ((Object)(object)_lighterGripItem != (Object)(object)val) { _lighterGripItem = val; _lighterFromHandValid = false; } if (!_lighterFromHandValid) { try { HandTransforms handTransformsLeft = ((Item)val).HandTransformsLeft; if (handTransformsLeft != null && handTransformsLeft.Exists && (Object)(object)handTransformsLeft.Parent != (Object)null && (Object)(object)val._lighter.parent != (Object)null) { Vector3 val3 = handTransformsLeft.Parent.TransformPoint(handTransformsLeft.HandPos); Quaternion val4 = handTransformsLeft.Parent.rotation * handTransformsLeft.HandRot; Vector3 val5 = val._lighter.parent.TransformPoint(val._lighterOrigPos); Quaternion val6 = val._lighter.parent.rotation * val._lighterOrigRot; _lighterFromHandPos = Quaternion.Inverse(val4) * (val5 - val3); _lighterFromHandRot = Quaternion.Inverse(val4) * val6; _lighterFromHandValid = true; } } catch { } } if (_lighterFromHandValid) { val._lighter.SetPositionAndRotation(handBoneLeft.position + handBoneLeft.rotation * _lighterFromHandPos, handBoneLeft.rotation * _lighterFromHandRot); } else { val._lighter.SetPositionAndRotation(handBoneLeft.position, handBoneLeft.rotation); } } catch { } } private static void UpdateFishTwoHand(VRRig rig, Item held) { //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_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: 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_00ee: 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) try { if (held is Fish || (Object)(object)held.Fish != (Object)null) { _fishTwoHand = false; return; } Transform leftHand = rig.LeftHand; if ((Object)(object)leftHand == (Object)null || (Object)(object)leftHand == (Object)(object)rig.MainHand) { _fishTwoHand = false; return; } bool flag = VRActions.Instance.LeftGrip.ReadValue() >= VRConfig.GripThreshold.Value; bool flag2 = false; Vector3 val; if ((Object)(object)held.HandModelLeft != (Object)null) { val = held.HandModelLeft.position; flag2 = true; } else if (held.HandTransformsLeft != null && held.HandTransformsLeft.Exists && (Object)(object)held.HandTransformsLeft.Parent != (Object)null) { val = held.HandTransformsLeft.Parent.TransformPoint(held.HandTransformsLeft.HandPos); flag2 = true; } else { val = leftHand.position; } if (!flag2) { _fishTwoHand = false; } else if (!_fishTwoHand) { if (flag && Vector3.Distance(leftHand.position, val) <= 0.3f) { _fishTwoHand = true; } } else if (!flag) { _fishTwoHand = false; } } catch { } } } [DefaultExecutionOrder(-1000)] public class VRRig : MonoBehaviour { public float YawOffset; public float GameEyeHeight = 1.5f; private bool _snapReady = true; private float _invScrollCd; private bool _calibrated; private Vector3 _headCalib; private float _yHoldTime; private Vector3 _lastHead; private bool _lastHeadValid; private Vector3 _roomOffset; private Vector2 _lastHmdPlanar; private bool _planarInit; private bool _needsReanchor; private bool _wasDead; private Vector3 _deathAnchor; private bool _setGameView; private bool _gameHeightSet; private bool _sprintToggle; private bool _crouchToggle; private bool _physCrouch; private const float PhysCrouchEngageDrop = 0.22f; private const float PhysCrouchReleaseDrop = 0.14f; private Boat _drivingBoat; private float _lastBoatYaw; private bool _boatYawInit; public static VRRig Instance { get; private set; } public Transform Root { get; private set; } public Transform Head { get; private set; } public Transform LeftHand { get; private set; } public Transform RightHand { get; private set; } public Transform MainHand => RightHand; public Transform OffHand => LeftHand; public bool SnapTurned { get; private set; } public float SnapTurnYaw { get; private set; } public bool IsCalibrated => _calibrated; public Vector3 HeadCalib => _headCalib; public static void Create() { //IL_0013: 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_001e: Expected O, but got Unknown if (!((Object)(object)Instance != (Object)null)) { GameObject val = new GameObject("HowToFishVR Rig"); Object.DontDestroyOnLoad((Object)val); Instance = val.AddComponent(); Instance.Build(); } } private void Build() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) Root = ((Component)this).transform; Head = new GameObject("Head").transform; LeftHand = new GameObject("LeftHand").transform; RightHand = new GameObject("RightHand").transform; Head.SetParent(Root, false); LeftHand.SetParent(Root, false); RightHand.SetParent(Root, false); try { if (VRConfig.SavedEyeHeight.Value > 0.2f) { GameEyeHeight = VRConfig.SavedEyeHeight.Value; _gameHeightSet = true; } } catch { } } private void Update() { //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_0326: Unknown result type (might be due to invalid IL or missing references) //IL_0337: Unknown result type (might be due to invalid IL or missing references) //IL_0348: 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_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_028b: 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_028f: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: 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_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0228: 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_013d: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_0119: 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_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0168: 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_017a: 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_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_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) VRActions instance = VRActions.Instance; if (instance == null) { return; } if (!Application.runInBackground) { Application.runInBackground = true; } if (!_setGameView) { _setGameView = true; try { XRSettings.gameViewRenderMode = (GameViewRenderMode)1; } catch { } } Player localPlayer = Player.LocalPlayer; if ((Object)(object)localPlayer != (Object)null) { VRBindings.TryInject(); } if ((Object)(object)localPlayer != (Object)null && !_gameHeightSet) { try { if ((Object)(object)localPlayer.Camera != (Object)null) { GameEyeHeight = localPlayer.Camera.CamHeight; _gameHeightSet = true; } } catch { } } CameraOutputPatches.EnsureAll(); bool flag = false; try { flag = (Object)(object)localPlayer != (Object)null && (Object)(object)localPlayer.Dying != (Object)null && localPlayer.Dying.IsDead; } catch { } Vector3 headPos = instance.HeadPos; if (!_calibrated && ((Vector3)(ref headPos)).sqrMagnitude > 1E-06f) { _headCalib = headPos; _calibrated = true; } if (_needsReanchor && ((Vector3)(ref headPos)).sqrMagnitude > 1E-06f) { _needsReanchor = false; _roomOffset = Vector3.zero; _lastHmdPlanar = new Vector2(headPos.x, headPos.z); _planarInit = true; } if (((Vector3)(ref _roomOffset)).magnitude > 10f) { _roomOffset = Vector3.zero; _planarInit = false; } if (_calibrated && _lastHeadValid && !flag) { Vector3 val = headPos - _lastHead; if (((Vector3)(ref val)).magnitude > 0.35f) { _headCalib = headPos; _roomOffset = Vector3.zero; _lastHmdPlanar = new Vector2(headPos.x, headPos.z); } } _lastHead = headPos; _lastHeadValid = true; HandleTurning(); FollowBoatYaw(); Quaternion val2 = Quaternion.Euler(0f, YawOffset, 0f); if ((Object)(object)localPlayer == (Object)null) { try { if (VRCameraPoser_Behaviour.TryGetCustomizationOrigin(instance.HeadRot, YawOffset, out var origin)) { val2 = origin; } } catch { } } _wasDead = flag; if ((Object)(object)localPlayer != (Object)null && (Object)(object)localPlayer.Transform != (Object)null) { Vector3 position = localPlayer.Transform.position; bool flag2 = false; if ((Object)(object)_drivingBoat != (Object)null) { try { if ((Object)(object)_drivingBoat.DriverPos != (Object)null) { position = _drivingBoat.DriverPos.position; flag2 = true; } } catch { } } if (flag2) { Vector3 val3 = position + Vector3.up * GameEyeHeight; Root.position = val3 - val2 * headPos; } else { Vector3 val4 = position - _roomOffset + Vector3.up * GameEyeHeight; Root.position = val4 - val2 * _headCalib; } } Root.rotation = val2; Head.localPosition = headPos; Head.localRotation = instance.HeadRot; LeftHand.localPosition = instance.LeftPos; LeftHand.localRotation = instance.LeftRot; RightHand.localPosition = instance.RightPos; RightHand.localRotation = instance.RightRot; ApplySprintCrouch(); KeyboardShortcut value = VRConfig.RecenterKey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { Recenter(); } } private void FixedUpdate() { //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_0088: 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_00b8: 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_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_00c8: 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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_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_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_012c: 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_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) if (!Plugin.VREnabled) { return; } VRActions instance = VRActions.Instance; if (instance == null) { return; } if (!VRConfig.RoomscaleMovement.Value) { _planarInit = false; return; } Player localPlayer = Player.LocalPlayer; Rigidbody val = (((Object)(object)localPlayer != (Object)null) ? localPlayer.Rigidbody : null); if ((Object)(object)localPlayer == (Object)null || (Object)(object)val == (Object)null) { _planarInit = false; return; } bool flag = false; try { flag = Boat.IsDrivingLocally || localPlayer.Dying.IsDead || localPlayer.BlockInputs; } catch { } Vector3 headPos = instance.HeadPos; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(headPos.x, headPos.z); if (!_planarInit || flag) { _lastHmdPlanar = val2; _planarInit = true; return; } Vector2 val3 = val2 - _lastHmdPlanar; _lastHmdPlanar = val2; if (!(((Vector2)(ref val3)).sqrMagnitude < 1E-08f) && !(((Vector2)(ref val3)).magnitude > 0.5f)) { Vector3 val4 = Root.rotation * new Vector3(val3.x, 0f, val3.y); val.MovePosition(val.position + val4); _roomOffset += val4; } } public void CalibrateNow() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: 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_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) VRActions instance = VRActions.Instance; if (instance != null) { _headCalib = instance.HeadPos; _lastHmdPlanar = new Vector2(_headCalib.x, _headCalib.z); _planarInit = true; } try { Player localPlayer = Player.LocalPlayer; if ((Object)(object)localPlayer != (Object)null && (Object)(object)localPlayer.Camera != (Object)null && localPlayer.Camera.CamHeight > 0.2f) { GameEyeHeight = localPlayer.Camera.CamHeight; _gameHeightSet = true; } else { GameEyeHeight = _headCalib.y; } } catch { } _roomOffset = Vector3.zero; _calibrated = true; Recenter(); _lastHmdPlanar = (Vector2)((instance != null) ? new Vector2(instance.HeadPos.x, instance.HeadPos.z) : _lastHmdPlanar); _planarInit = true; try { VRConfig.SavedEyeHeight.Value = GameEyeHeight; VRConfig.SavedHeadCalibY.Value = _headCalib.y; } catch { } try { HowToFishBody.ApplyBodyMode(); } catch { } } public void OnRespawn() { _needsReanchor = true; } private void ApplySprintCrouch() { //IL_00be: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.LocalPlayer; if ((Object)(object)localPlayer == (Object)null || (Object)(object)localPlayer.Movement == (Object)null) { return; } VRActions instance = VRActions.Instance; bool sprintInput; if (VRConfig.SprintMode.Value == ButtonMode.Hold) { sprintInput = instance.SprintButton.IsPressed(); } else { if (instance.SprintButton.WasPressedThisFrame()) { _sprintToggle = !_sprintToggle; } sprintInput = _sprintToggle; } bool crouchInput; if (VRConfig.CrouchMode.Value == ButtonMode.Hold) { crouchInput = instance.CrouchButton.IsPressed(); } else { if (instance.CrouchButton.WasPressedThisFrame()) { _crouchToggle = !_crouchToggle; } crouchInput = _crouchToggle; } if (VRConfig.RoomscaleMovement.Value && _calibrated) { float num = _headCalib.y - instance.HeadPos.y; if (_physCrouch) { if (num < 0.14f) { _physCrouch = false; } } else if (num >= 0.22f) { _physCrouch = true; } if (_physCrouch) { crouchInput = true; } } localPlayer.Movement._sprintInput = sprintInput; localPlayer.Movement._crouchInput = crouchInput; } private void FollowBoatYaw() { //IL_00bf: Unknown result type (might be due to invalid IL or missing references) bool flag = false; try { flag = Boat.IsDrivingLocally; } catch { } if (!flag) { _drivingBoat = null; _boatYawInit = false; return; } if ((Object)(object)_drivingBoat == (Object)null) { try { Boat[] array = Object.FindObjectsByType((FindObjectsSortMode)0); foreach (Boat val in array) { if ((Object)(object)val != (Object)null && (Object)(object)val.Driver == (Object)(object)Player.LocalPlayer) { _drivingBoat = val; break; } } } catch { } } if ((Object)(object)_drivingBoat == (Object)null) { return; } Transform val2 = null; try { val2 = _drivingBoat.DriverPos; } catch { } if ((Object)(object)val2 == (Object)null) { try { val2 = _drivingBoat.VisualBoat; } catch { } } if (!((Object)(object)val2 == (Object)null)) { float y = val2.eulerAngles.y; if (!_boatYawInit) { _lastBoatYaw = y; _boatYawInit = true; } else { YawOffset += Mathf.DeltaAngle(_lastBoatYaw, y); _lastBoatYaw = y; } } } private void HandleTurning() { //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: 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_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) SnapTurned = false; VRActions instance = VRActions.Instance; if (instance == null) { return; } float num = instance.TurnAxis.ReadValue(); if (VRConfig.Turning.Value == TurnMode.Snap) { if (Mathf.Abs(num) < 0.35f) { _snapReady = true; } else if (_snapReady && Mathf.Abs(num) >= 0.75f) { _snapReady = false; ArmRig.PrepareForSnapTurn(); RotateYawAboutHead(Mathf.Sign(num) * (float)VRConfig.SnapTurnAngle.Value); SnapTurned = true; Quaternion val = Quaternion.Euler(0f, YawOffset, 0f) * instance.HeadRot; SnapTurnYaw = ((Quaternion)(ref val)).eulerAngles.y; try { InputDevice deviceAtXRNode = InputDevices.GetDeviceAtXRNode((XRNode)5); if (((InputDevice)(ref deviceAtXRNode)).isValid) { ((InputDevice)(ref deviceAtXRNode)).SendHapticImpulse(0u, 0.35f, 0.06f); } } catch { } } } else if (Mathf.Abs(num) >= 0.15f) { float num2 = (Mathf.Abs(num) - 0.15f) / 0.85f; RotateYawAboutHead(Mathf.Sign(num) * num2 * VRConfig.SmoothTurnSpeed.Value * Time.deltaTime); } if (_invScrollCd > 0f) { _invScrollCd -= Time.deltaTime; } float num3 = instance.TurnAxisY.ReadValue(); bool flag = true; try { Player localPlayer = Player.LocalPlayer; if ((Object)(object)localPlayer == (Object)null) { flag = false; } else if ((Object)(object)localPlayer.Dying != (Object)null && localPlayer.Dying.IsDead) { flag = false; } else if (localPlayer.BlockInputs) { flag = false; } else if (Boat.IsDrivingLocally) { flag = false; } } catch { } if (flag && Mathf.Abs(num3) >= 0.7f && _invScrollCd <= 0f) { _invScrollCd = 0.25f; ScrollInventory((!(num3 > 0f)) ? 1 : (-1)); } } private static void ScrollInventory(int dir) { try { Player localPlayer = Player.LocalPlayer; if ((Object)(object)localPlayer == (Object)null || (Object)(object)localPlayer.Inventory == (Object)null) { return; } List availableSlots = localPlayer.Inventory._availableSlots; if (availableSlots != null && availableSlots.Count != 0) { int num = localPlayer.Inventory._localCurSlot + dir; if (num < 0) { num = availableSlots.Count - 1; } else if (num >= availableSlots.Count) { num = 0; } localPlayer.Inventory.LocalTrySelectSlot(num); } } catch { } } private void RotateYawAboutHead(float deltaDeg) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) if (!(Mathf.Abs(deltaDeg) < 0.0001f)) { VRActions instance = VRActions.Instance; if (instance != null) { Vector3 val = instance.HeadPos - _headCalib; Quaternion val2 = Quaternion.Euler(0f, YawOffset, 0f); YawOffset += deltaDeg; Quaternion val3 = Quaternion.Euler(0f, YawOffset, 0f); _roomOffset += val3 * val - val2 * val; } } } public void Recenter() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0041: 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_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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_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_008b: Unknown result type (might be due to invalid IL or missing references) VRActions instance = VRActions.Instance; if (instance != null) { ArmRig.PrepareForSnapTurn(); Vector3 val = instance.HeadPos - _headCalib; Quaternion val2 = Quaternion.Euler(0f, YawOffset, 0f); Quaternion headRot = instance.HeadRot; float y = ((Quaternion)(ref headRot)).eulerAngles.y; YawOffset = 0f - y; Quaternion val3 = Quaternion.Euler(0f, YawOffset, 0f); _roomOffset += val3 * val - val2 * val; _planarInit = false; VRCameraPoser.Instance?.Recalibrate(); } } public Quaternion MovementHeading() { //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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_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) Vector3 forward = (VRConfig.HeadRelativeMovement.Value ? Head : OffHand).forward; forward.y = 0f; if (((Vector3)(ref forward)).sqrMagnitude < 0.0001f) { forward = Root.forward; } return Quaternion.LookRotation(((Vector3)(ref forward)).normalized, Vector3.up); } } } namespace HowToFishVR.UI { [DefaultExecutionOrder(-1000)] public class VRLaser : MonoBehaviour { private sealed class Ray { public GameObject Go; public LineRenderer Line; public bool Left; } private Ray _right; private static EventSystem _configuredEventSystem; private const float Length = 5f; internal static readonly Quaternion PointerTilt = Quaternion.Euler(45f, 0f, 0f); public static VRLaser Instance { get; private set; } public static void Create() { //IL_0013: 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_001e: Expected O, but got Unknown if (!((Object)(object)Instance != (Object)null)) { GameObject val = new GameObject("HowToFishVR Laser"); Object.DontDestroyOnLoad((Object)val); Instance = val.AddComponent(); Instance.Init(); } } private void Init() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown _right = BuildRay(left: false); Application.onBeforeRender += new UnityAction(PoseAndDraw); } private void OnDestroy() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown Application.onBeforeRender -= new UnityAction(PoseAndDraw); } private static VRPointerInputModule EnsureModule() { EventSystem current = EventSystem.current; if ((Object)(object)current == (Object)null) { return null; } BaseInputModule[] components = ((Component)current).GetComponents(); foreach (BaseInputModule val in components) { if (!(val is VRPointerInputModule)) { ((Behaviour)val).enabled = false; } } VRPointerInputModule vRPointerInputModule = ((Component)current).GetComponent(); if ((Object)(object)vRPointerInputModule == (Object)null) { vRPointerInputModule = ((Component)current).gameObject.AddComponent(); } ((Behaviour)vRPointerInputModule).enabled = true; if ((Object)(object)_configuredEventSystem != (Object)(object)current) { _configuredEventSystem = current; } return vRPointerInputModule; } private Ray BuildRay(bool left) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown //IL_00bb: 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_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: 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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(left ? "LeftRay" : "RightRay"); val.layer = 5; val.transform.SetParent(((Component)this).transform, false); LineRenderer val2 = val.AddComponent(); val2.useWorldSpace = true; val2.positionCount = 2; val2.widthMultiplier = 0.006f; val2.numCapVertices = 2; Shader val3 = Shader.Find("Universal Render Pipeline/Unlit") ?? Shader.Find("Sprites/Default"); if ((Object)(object)val3 != (Object)null) { ((Renderer)val2).material = new Material(val3); ((Renderer)val2).material.renderQueue = 4000; } Color val4 = (val2.startColor = (left ? new Color(1f, 0.72f, 0.2f) : new Color(0.25f, 0.85f, 1f))); val2.endColor = new Color(val4.r, val4.g, val4.b, 0.3f); Ray result = new Ray { Go = val, Line = val2, Left = left }; val.SetActive(false); return result; } internal static bool LaserActive() { try { if (MainMenuManager.IsInMenu) { return true; } } catch { } try { if (PauseManager.IsPaused) { return true; } } catch { } try { if (VRSettingsPanel.IsOpen) { return true; } } catch { } return false; } private void Update() { VRPointerInputModule vRPointerInputModule = EnsureModule(); bool flag = LaserActive(); SetRayActive(_right, flag); if ((Object)(object)vRPointerInputModule != (Object)null) { vRPointerInputModule.SetLaserActive(flag); } if (flag) { PoseTransform(_right); } } private static void SetRayActive(Ray r, bool active) { if ((Object)(object)r?.Go != (Object)null && r.Go.activeSelf != active) { r.Go.SetActive(active); } } private void PoseAndDraw() { bool flag = LaserActive(); if ((Object)(object)_right?.Line != (Object)null) { ((Renderer)_right.Line).enabled = flag; } if (flag) { Draw(_right); } } private static void PoseTransform(Ray r) { //IL_0051: 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_0061: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)r?.Go == (Object)null) { return; } VRRig instance = VRRig.Instance; if (!((Object)(object)instance == (Object)null)) { Transform val = (r.Left ? instance.LeftHand : instance.RightHand); if ((Object)(object)val != (Object)null) { r.Go.transform.SetPositionAndRotation(val.position, val.rotation * PointerTilt); } } } private static void Draw(Ray r) { //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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)r?.Go == (Object)null) && !((Object)(object)r.Line == (Object)null)) { PoseTransform(r); Vector3 position = r.Go.transform.position; VRPointerInputModule instance = VRPointerInputModule.Instance; instance?.RefreshRaycastForRender(); Vector3 val = position + r.Go.transform.forward * 5f; if ((Object)(object)instance != (Object)null && instance.HasHit) { val = instance.HitPoint; } r.Line.SetPosition(0, position); r.Line.SetPosition(1, val); } } } internal sealed class VRPointerInputModule : BaseInputModule { private const float MaxDistance = 25f; private const float ClickForgivenessSeconds = 0.18f; private Transform _rayOrigin; private Camera _eventCamera; private PointerEventData _pointer; private GameObject _hover; private GameObject _lastValidHover; private float _lastValidHoverTime; private Plane _pressPlane; private Transform _pressReference; private Vector3 _pressCameraLocalPosition; private Quaternion _pressCameraLocalRotation; private Vector3 _pressPointLocal; private bool _cameraFrozen; private bool _laserActive; private bool _lastTrigger; private bool _rightHeld; internal static VRPointerInputModule Instance { get; private set; } internal bool HasHit { get; private set; } internal Vector3 HitPoint { get; private set; } protected override void Awake() { ((UIBehaviour)this).Awake(); Instance = this; } protected override void OnDestroy() { if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } ((UIBehaviour)this).OnDestroy(); } protected override void OnEnable() { ((BaseInputModule)this).OnEnable(); BaseInputModule[] components = ((Component)this).GetComponents(); foreach (BaseInputModule val in components) { if ((Object)(object)val != (Object)(object)this) { ((Behaviour)val).enabled = false; } } } internal void SetLaserActive(bool active) { _laserActive = active; } internal void RefreshRaycastForRender() { if (!_laserActive || !EnsureSetup()) { HasHit = false; return; } PoseRay(); UpdatePointerPosition(_lastTrigger); VRUIManager.ReassignLaserEventCamera(_eventCamera); DoRaycast(); } private bool EnsureSetup() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Expected O, but got Unknown if ((Object)(object)_rayOrigin != (Object)null && (Object)(object)_eventCamera != (Object)null && _pointer != null) { return true; } GameObject val = new GameObject("VRPointerRayOrigin"); val.transform.SetParent(((Component)this).transform, false); _rayOrigin = val.transform; GameObject val2 = new GameObject("VRPointerEventCamera"); val2.transform.SetParent(_rayOrigin, false); _eventCamera = val2.AddComponent(); ((Behaviour)_eventCamera).enabled = false; _eventCamera.clearFlags = (CameraClearFlags)4; _eventCamera.cullingMask = 32; _eventCamera.nearClipPlane = 0.01f; _eventCamera.farClipPlane = 25f; _eventCamera.fieldOfView = 60f; _eventCamera.stereoTargetEye = (StereoTargetEyeMask)0; _pointer = new PointerEventData(((BaseInputModule)this).eventSystem) { pointerId = -120 }; return true; } public override void Process() { if (!EnsureSetup()) { return; } bool flag = ReadTrigger((XRNode)5, _rightHeld); if (!_laserActive) { if (_lastTrigger) { ReleasePointer(); } ClearHover(); HasHit = false; _lastTrigger = false; _rightHeld = flag; return; } _rightHeld = flag; bool flag2 = flag; bool num = flag2 && !_lastTrigger; bool flag3 = !flag2 && _lastTrigger; PoseRay(); UpdatePointerPosition(flag2); VRUIManager.ReassignLaserEventCamera(_eventCamera); DoRaycast(); UpdateHover(flag2); if (num && (Object)(object)_hover != (Object)null) { PressPointer(); } if (flag2) { DragPointer(); } if (flag3) { ReleasePointer(); } _lastTrigger = flag2; } private static bool ReadTrigger(XRNode node, bool wasHeld) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) float num = 0f; try { InputDevice deviceAtXRNode = InputDevices.GetDeviceAtXRNode(node); if (((InputDevice)(ref deviceAtXRNode)).isValid) { ((InputDevice)(ref deviceAtXRNode)).TryGetFeatureValue(CommonUsages.trigger, ref num); } } catch { } if (!wasHeld) { return num >= 0.35f; } return num >= 0.18f; } private void PoseRay() { //IL_0028: 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_006c: 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) VRRig instance = VRRig.Instance; if ((Object)(object)instance == (Object)null) { return; } Transform rightHand = instance.RightHand; if (!((Object)(object)rightHand == (Object)null)) { _rayOrigin.SetPositionAndRotation(rightHand.position, rightHand.rotation * VRLaser.PointerTilt); if (!_cameraFrozen) { ((Component)_eventCamera).transform.SetParent(_rayOrigin, false); ((Component)_eventCamera).transform.localPosition = Vector3.zero; ((Component)_eventCamera).transform.localRotation = Quaternion.identity; } else { UpdateFrozenReferenceFrame(); } } } private void UpdateFrozenReferenceFrame() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) if (_cameraFrozen && !((Object)(object)_pressReference == (Object)null) && !((Object)(object)_eventCamera == (Object)null)) { ((Component)_eventCamera).transform.SetPositionAndRotation(_pressReference.TransformPoint(_pressCameraLocalPosition), _pressReference.rotation * _pressCameraLocalRotation); Vector3 val = _pressReference.TransformPoint(_pressPointLocal); _pressPlane = new Plane(-_pressReference.forward, val); } } private void UpdatePointerPosition(bool pressed) { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: 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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_0074: 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_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) Vector2 position = default(Vector2); if (pressed && _cameraFrozen) { Ray val = default(Ray); ((Ray)(ref val))..ctor(_rayOrigin.position, _rayOrigin.forward); float num = default(float); if (((Plane)(ref _pressPlane)).Raycast(val, ref num) && num <= 25f) { Vector3 val2 = _eventCamera.WorldToScreenPoint(((Ray)(ref val)).GetPoint(num)); ((Vector2)(ref position))..ctor(val2.x, val2.y); } else { position = _pointer.position; } } else { ((Vector2)(ref position))..ctor((float)_eventCamera.pixelWidth * 0.5f, (float)_eventCamera.pixelHeight * 0.5f); } _pointer.delta = position - _pointer.position; _pointer.position = position; } private void DoRaycast() { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: 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_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) ((BaseInputModule)this).eventSystem.RaycastAll(_pointer, base.m_RaycastResultCache); for (int num = base.m_RaycastResultCache.Count - 1; num >= 0; num--) { RaycastResult val = base.m_RaycastResultCache[num]; if (!VRUIManager.IsLaserManaged(((RaycastResult)(ref val)).gameObject)) { base.m_RaycastResultCache.RemoveAt(num); } } RaycastResult pointerCurrentRaycast = BaseInputModule.FindFirstRaycast(base.m_RaycastResultCache); base.m_RaycastResultCache.Clear(); _pointer.pointerCurrentRaycast = pointerCurrentRaycast; if ((Object)(object)((RaycastResult)(ref pointerCurrentRaycast)).gameObject == (Object)null) { HasHit = false; return; } Transform transform = ((RaycastResult)(ref pointerCurrentRaycast)).gameObject.transform; Plane val2 = default(Plane); ((Plane)(ref val2))..ctor(-transform.forward, transform.position); Ray val3 = default(Ray); ((Ray)(ref val3))..ctor(_rayOrigin.position, _rayOrigin.forward); float num2 = default(float); HasHit = ((Plane)(ref val2)).Raycast(val3, ref num2) && num2 <= 25f; HitPoint = (HasHit ? ((Ray)(ref val3)).GetPoint(num2) : transform.position); } private void UpdateHover(bool pressed) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) RaycastResult pointerCurrentRaycast = _pointer.pointerCurrentRaycast; GameObject val = ((RaycastResult)(ref pointerCurrentRaycast)).gameObject; if (pressed && (Object)(object)_pointer.pointerDrag != (Object)null && (Object)(object)val == (Object)null) { val = _hover; } if ((Object)(object)val != (Object)(object)_hover) { ((BaseInputModule)this).HandlePointerExitAndEnter(_pointer, val); _hover = val; } if ((Object)(object)_hover != (Object)null) { _lastValidHover = _hover; _lastValidHoverTime = Time.unscaledTime; } } private void PressPointer() { //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_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_013a: 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_0144: 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_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) GameObject hover = _hover; _pointer.eligibleForClick = true; _pointer.pressPosition = _pointer.position; _pointer.pointerPressRaycast = _pointer.pointerCurrentRaycast; _pointer.useDragThreshold = true; _pointer.button = (InputButton)0; GameObject val = ExecuteEvents.ExecuteHierarchy(hover, (BaseEventData)(object)_pointer, ExecuteEvents.pointerDownHandler); if ((Object)(object)val == (Object)null) { val = ExecuteEvents.GetEventHandler(hover); } _pointer.pointerPress = val; _pointer.rawPointerPress = hover; _pointer.clickTime = Time.unscaledTime; _pointer.pointerDrag = ExecuteEvents.GetEventHandler(hover); if ((Object)(object)_pointer.pointerDrag != (Object)null) { ExecuteEvents.Execute(_pointer.pointerDrag, (BaseEventData)(object)_pointer, ExecuteEvents.initializePotentialDrag); } Canvas componentInParent = hover.GetComponentInParent(); Transform val2 = (_pressReference = (((Object)(object)componentInParent != (Object)null) ? ((Component)componentInParent).transform : hover.transform)); _pressCameraLocalPosition = val2.InverseTransformPoint(((Component)_eventCamera).transform.position); _pressCameraLocalRotation = Quaternion.Inverse(val2.rotation) * ((Component)_eventCamera).transform.rotation; _pressPointLocal = val2.InverseTransformPoint(HasHit ? HitPoint : val2.position); ((Component)_eventCamera).transform.SetParent((Transform)null, true); _cameraFrozen = true; UpdateFrozenReferenceFrame(); ((BaseInputModule)this).eventSystem.SetSelectedGameObject(val, (BaseEventData)(object)_pointer); } private void DragPointer() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_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) if ((Object)(object)_pointer.pointerDrag == (Object)null) { return; } float num = ((BaseInputModule)this).eventSystem.pixelDragThreshold; if (!_pointer.dragging) { Vector2 val = _pointer.pressPosition - _pointer.position; if (((Vector2)(ref val)).sqrMagnitude >= num * num) { ExecuteEvents.Execute(_pointer.pointerDrag, (BaseEventData)(object)_pointer, ExecuteEvents.beginDragHandler); _pointer.dragging = true; } } if (_pointer.dragging) { if ((Object)(object)_pointer.pointerPress != (Object)(object)_pointer.pointerDrag) { ExecuteEvents.Execute(_pointer.pointerPress, (BaseEventData)(object)_pointer, ExecuteEvents.pointerUpHandler); _pointer.eligibleForClick = false; _pointer.pointerPress = null; _pointer.rawPointerPress = null; } ExecuteEvents.Execute(_pointer.pointerDrag, (BaseEventData)(object)_pointer, ExecuteEvents.dragHandler); } } private void ReleasePointer() { //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) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) if (_pointer != null) { RaycastResult pointerCurrentRaycast = _pointer.pointerCurrentRaycast; GameObject gameObject = ((RaycastResult)(ref pointerCurrentRaycast)).gameObject; ExecuteEvents.Execute(_pointer.pointerPress, (BaseEventData)(object)_pointer, ExecuteEvents.pointerUpHandler); GameObject val = gameObject; if ((Object)(object)val == (Object)null && Time.unscaledTime - _lastValidHoverTime <= 0.18f) { val = _lastValidHover; } GameObject eventHandler = ExecuteEvents.GetEventHandler(val); if ((Object)(object)_pointer.pointerPress != (Object)null && _pointer.eligibleForClick && (Object)(object)eventHandler == (Object)(object)_pointer.pointerPress) { ExecuteEvents.Execute(_pointer.pointerPress, (BaseEventData)(object)_pointer, ExecuteEvents.pointerClickHandler); } else if ((Object)(object)_pointer.pointerDrag != (Object)null && _pointer.dragging && (Object)(object)gameObject != (Object)null) { ExecuteEvents.ExecuteHierarchy(gameObject, (BaseEventData)(object)_pointer, ExecuteEvents.dropHandler); } if (_pointer.dragging) { ExecuteEvents.Execute(_pointer.pointerDrag, (BaseEventData)(object)_pointer, ExecuteEvents.endDragHandler); } _pointer.dragging = false; _pointer.eligibleForClick = false; _pointer.pointerPress = null; _pointer.rawPointerPress = null; _pointer.pointerDrag = null; if ((Object)(object)_eventCamera != (Object)null && (Object)(object)_rayOrigin != (Object)null) { ((Component)_eventCamera).transform.SetParent(_rayOrigin, false); ((Component)_eventCamera).transform.localPosition = Vector3.zero; ((Component)_eventCamera).transform.localRotation = Quaternion.identity; } _cameraFrozen = false; _pressReference = null; } } private void ClearHover() { if (_pointer != null) { ((BaseInputModule)this).HandlePointerExitAndEnter(_pointer, (GameObject)null); } _hover = null; } } public class VRSettingsPanel : MonoBehaviour { private enum RowKind { Stepper, Toggle, Slider, Button } private struct SettingRow { public string Label; public RowKind Kind; public Func Value; public Action OnPrev; public Action OnNext; public Action OnClick; public Func GetBool; public Action SetBool; public Func GetFloat; public Action SetFloat; public float Min; public float Max; public bool WholeNumbers; } private GameObject _pauseEntryButton; private GameObject _mainMenuEntryButton; private GameObject _buttonTemplate; private Image _nativeBackdropStyle; private GameObject _nativeToggleTemplate; private GameObject _nativeSliderTemplate; private bool _templatesScanned; private GameObject _page; private bool _pageOpen; private bool _openedFromPause; private GameObject _pauseHolder; private GameObject _pauseMainScreen; private bool _pauseMainScreenWasActive; private Transform _mainCanvasRoot; private GameObject _mainMenuPage; private GameObject _mainMenuTitle; private GameObject _discordButton; private bool _mainMenuHidden; private readonly List<(GameObject, Func)> _valueRefreshers = new List<(GameObject, Func)>(); private float _nextProbe; private bool _prevBothSticks; private bool _wasPaused; private bool _wasInMenu; public static VRSettingsPanel Instance { get; private set; } public static bool IsOpen { get { if ((Object)(object)Instance != (Object)null) { return Instance._pageOpen; } return false; } } public static void Create() { //IL_0013: 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_001e: Expected O, but got Unknown if (!((Object)(object)Instance != (Object)null)) { GameObject val = new GameObject("HowToFishVR Settings"); Object.DontDestroyOnLoad((Object)val); Instance = val.AddComponent(); } } private void Update() { bool flag = false; try { if (Input.GetKeyDown((KeyCode)282)) { flag = true; } } catch { } VRActions instance = VRActions.Instance; if (instance != null) { bool flag2 = instance.SprintButton.IsPressed() && instance.CrouchButton.IsPressed(); if (flag2 && !_prevBothSticks) { flag = true; } _prevBothSticks = flag2; } if (flag) { if (_pageOpen) { Close(); } else { bool flag3 = false; try { flag3 = MainMenuManager.IsInMenu; } catch { } bool flag4 = false; try { flag4 = PauseManager.IsPaused; } catch { } if (flag3) { Open(fromPause: false); } else if (flag4) { Open(fromPause: true); } } } Tick(); } private void Tick() { if (!Plugin.VREnabled) { return; } bool flag = IsInMenu(); bool flag2 = IsPaused() && !flag; if (flag2 && !_wasPaused && (Object)(object)_pauseEntryButton == (Object)null) { TryInjectPause(); } if (flag && !_wasInMenu && (Object)(object)_mainMenuEntryButton == (Object)null) { TryInjectMainMenu(); } _wasPaused = flag2; _wasInMenu = flag; if ((Object)(object)_mainMenuEntryButton != (Object)null) { _mainMenuEntryButton.SetActive(flag && !_pageOpen); } if ((Object)(object)_pauseEntryButton != (Object)null) { _pauseEntryButton.SetActive(flag2 && (Object)(object)_pauseMainScreen != (Object)null && _pauseMainScreen.activeSelf && !_pageOpen); } if (Time.unscaledTime < _nextProbe) { return; } _nextProbe = Time.unscaledTime + (((Object)(object)_pauseEntryButton == (Object)null || (Object)(object)_mainMenuEntryButton == (Object)null) ? 0.2f : 1f); if ((Object)(object)_mainMenuEntryButton == (Object)null && flag) { TryInjectMainMenu(); } if ((Object)(object)_pauseEntryButton == (Object)null && flag2) { TryInjectPause(); } if (_pageOpen) { if ((Object)(object)_page == (Object)null) { BuildPage(); } else if (!_page.activeSelf) { _page.SetActive(true); } else if ((Object)(object)_page.transform.parent != (Object)null) { _page.transform.SetAsLastSibling(); } } if (_pageOpen && _openedFromPause && !flag2) { Close(); } else if (_pageOpen && !_openedFromPause && !flag) { Close(); } } private static bool IsInMenu() { try { return MainMenuManager.IsInMenu; } catch { return false; } } private static bool IsPaused() { try { return PauseManager.IsPaused; } catch { return false; } } private void TryInjectPause() { //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Expected O, but got Unknown try { PauseManager val = Object.FindObjectOfType(true); if ((Object)(object)val == (Object)null || (Object)(object)val._pauseHolder == (Object)null || (Object)(object)val._mainScreen == (Object)null) { return; } _pauseHolder = val._pauseHolder; _pauseMainScreen = val._mainScreen; TextMeshProUGUI val2 = FindMenuText(_pauseMainScreen.transform, "Options"); if ((Object)(object)val2 == (Object)null) { return; } Button componentInParent = ((Component)val2).GetComponentInParent