Decompiled source of QuestLumen v1.4.1

Mods/QuestLumen.dll

Decompiled 12 hours ago
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using BoneLib;
using BoneLib.BoneMenu;
using BoneLib.Notifications;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSLZ.Marrow;
using Il2CppSLZ.Marrow.AI;
using Il2CppSLZ.Marrow.Pool;
using Il2CppSLZ.VRMK;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Il2CppSystem.Reflection;
using Il2CppTMPro;
using MelonLoader;
using MelonLoader.Preferences;
using MelonLoader.Utils;
using Microsoft.CodeAnalysis;
using QuestLumen;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
using UnityEngine.Rendering.Universal.Internal;
using UnityEngine.UI;
using UnityEngine.XR;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(QuestLumenMod), "Quest Lumen", "1.4.1", "Gabri", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: MelonColor(255, 64, 210, 255)]
[assembly: AssemblyTitle("Quest Lumen")]
[assembly: AssemblyDescription("Meta Quest Standalone Realtime Per-Pixel Lighting, VR Stereo Multiview Bloom, Realtime 3D Silhouette Shadows, Custom .ini/.txt Presets, and Spawnable LIV LCK Camera & MP4/PNG Recorder for BONELAB.")]
[assembly: AssemblyFileVersion("1.4.1")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.4.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NativeIntegerAttribute : Attribute
	{
		public readonly bool[] TransformFlags;

		public NativeIntegerAttribute()
		{
			TransformFlags = new bool[1] { true };
		}

		public NativeIntegerAttribute(bool[] P_0)
		{
			TransformFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace QuestLumen
{
	public static class LumenDynamicLights
	{
		private sealed class MuzzleFlashSlot
		{
			public Transform Trans;

			public Light Light;

			public float TimeRemaining;

			public float PeakIntensity;
		}

		private sealed class ContactShadowSlot
		{
			public GameObject Go;

			public Transform Trans;

			public MeshRenderer Renderer;
		}

		private const int MuzzlePoolSize = 4;

		private const int ContactShadowPoolSize = 7;

		private static readonly int IdBeamColor = Shader.PropertyToID("_BeamColor");

		private static readonly int IdShadowStrength = Shader.PropertyToID("_ShadowStrength");

		private const int SolidMask = -2081194809;

		private static GameObject _dynRoot;

		private static GameObject _tacGo;

		private static Light _tacLight;

		private static GameObject _beamGo;

		private static MeshRenderer _beamRenderer;

		private static Material _beamMat;

		private static bool _manualHeadlampOverride;

		private static float _lastRightBDownTime = -10f;

		private static float _smoothedWallDim = 1f;

		private static Light _presenceLight;

		private static readonly MuzzleFlashSlot[] _muzzlePool = new MuzzleFlashSlot[4];

		private static int _muzzleCursor;

		private static Material _contactShadowMat;

		private static readonly ContactShadowSlot[] _shadowSlots = new ContactShadowSlot[7];

		private static readonly List<AIBrain> _cachedNpcs = new List<AIBrain>(24);

		private static float _nextNpcScanTime;

		private static bool _stereoSynced;

		public static void MarkDirty()
		{
			_stereoSynced = false;
		}

		public static bool TryGetActiveTacSpotlight(out Vector3 pos, out Vector3 forward, out float range, out float spotAngle)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			pos = Vector3.zero;
			forward = Vector3.forward;
			range = 0f;
			spotAngle = 0f;
			if ((Object)(object)_tacLight == (Object)null || ((Il2CppObjectBase)_tacLight).Pointer == IntPtr.Zero || !((Behaviour)_tacLight).enabled || (Object)(object)_tacGo == (Object)null)
			{
				return false;
			}
			pos = _tacGo.transform.position;
			forward = _tacGo.transform.forward;
			range = _tacLight.range;
			spotAngle = _tacLight.spotAngle;
			return true;
		}

		public static void OnLevelLoaded()
		{
			if (LumenPreferences.IsQuestDevice)
			{
				DestroyAll();
				_cachedNpcs.Clear();
				_nextNpcScanTime = Time.unscaledTime + 1.5f;
				_stereoSynced = false;
			}
		}

		public static void OnLevelUnloaded()
		{
			if (LumenPreferences.IsQuestDevice)
			{
				DestroyAll();
				_cachedNpcs.Clear();
			}
		}

		private static void DestroyAll()
		{
			if ((Object)(object)_dynRoot != (Object)null && ((Il2CppObjectBase)_dynRoot).Pointer != IntPtr.Zero)
			{
				Object.Destroy((Object)(object)_dynRoot);
			}
			_dynRoot = null;
			_tacGo = null;
			_tacLight = null;
			_beamGo = null;
			_beamRenderer = null;
			_presenceLight = null;
			for (int i = 0; i < 4; i++)
			{
				_muzzlePool[i] = null;
			}
			for (int j = 0; j < 7; j++)
			{
				_shadowSlots[j] = null;
			}
		}

		private static void EnsureRigBuilt()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//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_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: 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_00ff: Expected O, but got Unknown
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Expected O, but got Unknown
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Expected O, but got Unknown
			//IL_0281: 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_0307: Unknown result type (might be due to invalid IL or missing references)
			//IL_0314: Expected O, but got Unknown
			//IL_0342: Unknown result type (might be due to invalid IL or missing references)
			//IL_0349: Expected O, but got Unknown
			if (((Object)(object)_dynRoot != (Object)null && ((Il2CppObjectBase)_dynRoot).Pointer != IntPtr.Zero) || !LumenShaderBank.EnsureLoaded())
			{
				return;
			}
			_dynRoot = new GameObject("QuestLumen_DynamicRig");
			_tacGo = new GameObject("QuestLumen_TacLight");
			_tacGo.transform.SetParent(_dynRoot.transform, false);
			_tacLight = _tacGo.AddComponent<Light>();
			_tacLight.type = (LightType)0;
			_tacLight.renderMode = (LightRenderMode)1;
			_tacLight.shadows = (LightShadows)0;
			_tacLight.innerSpotAngle = 22f;
			_tacLight.spotAngle = 48f;
			((Behaviour)_tacLight).enabled = false;
			if ((Object)(object)LumenShaderBank.VolumetricBeamShader != (Object)null && (Object)(object)LumenShaderBank.SharedConeMesh != (Object)null)
			{
				_beamMat = new Material(LumenShaderBank.VolumetricBeamShader)
				{
					name = "QuestLumen_BeamMat",
					hideFlags = (HideFlags)61
				};
				_beamGo = new GameObject("QuestLumen_VolumetricCone");
				_beamGo.transform.SetParent(_tacGo.transform, false);
				_beamGo.AddComponent<MeshFilter>().sharedMesh = LumenShaderBank.SharedConeMesh;
				_beamRenderer = _beamGo.AddComponent<MeshRenderer>();
				((Renderer)_beamRenderer).sharedMaterial = _beamMat;
				((Renderer)_beamRenderer).shadowCastingMode = (ShadowCastingMode)0;
				((Renderer)_beamRenderer).receiveShadows = false;
				_beamGo.SetActive(false);
			}
			GameObject val = new GameObject("QuestLumen_PresenceFill");
			val.transform.SetParent(_dynRoot.transform, false);
			_presenceLight = val.AddComponent<Light>();
			_presenceLight.type = (LightType)2;
			_presenceLight.renderMode = (LightRenderMode)1;
			_presenceLight.shadows = (LightShadows)0;
			_presenceLight.color = new Color(0.95f, 0.97f, 1f);
			_presenceLight.range = 2.4f;
			_presenceLight.intensity = 0.22f;
			((Behaviour)_presenceLight).enabled = false;
			for (int i = 0; i < 4; i++)
			{
				GameObject val2 = new GameObject($"QuestLumen_MuzzleFlash_{i}");
				val2.transform.SetParent(_dynRoot.transform, false);
				Light val3 = val2.AddComponent<Light>();
				val3.type = (LightType)2;
				val3.renderMode = (LightRenderMode)1;
				val3.shadows = (LightShadows)0;
				val3.color = new Color(1f, 0.72f, 0.36f);
				val3.range = 8.2f;
				val3.intensity = 0f;
				((Behaviour)val3).enabled = false;
				_muzzlePool[i] = new MuzzleFlashSlot
				{
					Trans = val2.transform,
					Light = val3
				};
			}
			if ((Object)(object)LumenShaderBank.ContactShadowShader != (Object)null && (Object)(object)LumenShaderBank.SharedQuadMesh != (Object)null)
			{
				_contactShadowMat = new Material(LumenShaderBank.ContactShadowShader)
				{
					name = "QuestLumen_ContactShadowMat",
					hideFlags = (HideFlags)61
				};
				for (int j = 0; j < 7; j++)
				{
					GameObject val4 = new GameObject($"QuestLumen_ContactShadow_{j}");
					val4.transform.SetParent(_dynRoot.transform, false);
					val4.AddComponent<MeshFilter>().sharedMesh = LumenShaderBank.SharedQuadMesh;
					MeshRenderer val5 = val4.AddComponent<MeshRenderer>();
					((Renderer)val5).sharedMaterial = _contactShadowMat;
					((Renderer)val5).shadowCastingMode = (ShadowCastingMode)0;
					((Renderer)val5).receiveShadows = false;
					val4.SetActive(false);
					_shadowSlots[j] = new ContactShadowSlot
					{
						Go = val4,
						Trans = val4.transform,
						Renderer = val5
					};
				}
			}
		}

		public static void ToggleQuickFlashlight()
		{
			if (LumenPreferences.IsQuestDevice)
			{
				if (LumenPreferences.TacLightMount.Value == TacLightMountMode.Headlamp)
				{
					LumenPreferences.TacLightMount.Value = TacLightMountMode.AutoWeaponBarrel;
					_manualHeadlampOverride = false;
					SendToast("Tactical Light: Auto Gun Barrel", "Activates automatically whenever holding a firearm!", (NotificationType)0);
				}
				else
				{
					_manualHeadlampOverride = !_manualHeadlampOverride;
					SendToast(_manualHeadlampOverride ? "Headlamp ON!" : "Headlamp OFF", _manualHeadlampOverride ? "Realtime Per-Pixel Headlamp + Volumetric Beam active!" : "Back to Auto Gun Barrel mode.", (NotificationType)0);
				}
				LumenPreferences.Save();
			}
		}

		public static void NotifyGunFired(Gun gun)
		{
			//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_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: 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)
			if (!LumenPreferences.IsQuestDevice || !LumenPreferences.ModEnabled.Value || !LumenPreferences.EnablePerPixelLighting.Value || !LumenPreferences.EnableMuzzleFlashLight.Value || (Object)(object)gun == (Object)null || ((Il2CppObjectBase)gun).Pointer == IntPtr.Zero)
			{
				return;
			}
			EnsureRigBuilt();
			Transform val = (((Object)(object)gun.firePointTransform != (Object)null) ? gun.firePointTransform : ((Component)gun).transform);
			if ((Object)(object)val == (Object)null || ((Il2CppObjectBase)val).Pointer == IntPtr.Zero)
			{
				return;
			}
			if ((Object)(object)Player.Head != (Object)null)
			{
				Vector3 val2 = val.position - Player.Head.position;
				if (((Vector3)(ref val2)).sqrMagnitude > 900f)
				{
					return;
				}
			}
			MuzzleFlashSlot muzzleFlashSlot = _muzzlePool[_muzzleCursor];
			_muzzleCursor = (_muzzleCursor + 1) % 4;
			if (!((Object)(object)muzzleFlashSlot?.Light == (Object)null))
			{
				muzzleFlashSlot.Trans.position = val.position + val.forward * 0.1f;
				muzzleFlashSlot.PeakIntensity = Mathf.Clamp(LumenPreferences.MuzzleFlashIntensity.Value, 0.5f, 8f);
				muzzleFlashSlot.TimeRemaining = 0.072f;
				muzzleFlashSlot.Light.intensity = muzzleFlashSlot.PeakIntensity;
				((Behaviour)muzzleFlashSlot.Light).enabled = true;
			}
		}

		public static void OnUpdate()
		{
			if (!LumenPreferences.IsQuestDevice || (Object)(object)Player.PhysicsRig == (Object)null || (Object)(object)Player.Head == (Object)null)
			{
				return;
			}
			CheckControllerQuickShortcut();
			if (!LumenPreferences.ModEnabled.Value)
			{
				if ((Object)(object)_dynRoot != (Object)null && _dynRoot.activeSelf)
				{
					_dynRoot.SetActive(false);
				}
				return;
			}
			EnsureRigBuilt();
			if (!((Object)(object)_dynRoot == (Object)null))
			{
				if (!_dynRoot.activeSelf)
				{
					_dynRoot.SetActive(true);
				}
				if (!_stereoSynced && LumenShaderBank.IsHeadsetStereoActive)
				{
					LumenShaderBank.ConfigureStereoKeywords(_beamMat, stereo: true);
					LumenShaderBank.ConfigureStereoKeywords(_contactShadowMat, stereo: true);
					_stereoSynced = true;
				}
				float deltaTime = Time.deltaTime;
				UpdateTacticalLightAndBeam(deltaTime);
				UpdatePresenceLight();
				UpdateMuzzleFlashes(deltaTime);
				UpdateContactShadows();
			}
		}

		private static void CheckControllerQuickShortcut()
		{
			if (!LumenPreferences.DoubleTapBTacToggle.Value || (Object)(object)Player.RightController == (Object)null || (Object)(object)Player.UIRig == (Object)null)
			{
				return;
			}
			try
			{
				if (!Player.UIRig.popUpMenu.m_IsCursorShown && Player.RightController.GetBButtonDown())
				{
					float realtimeSinceStartup = Time.realtimeSinceStartup;
					if (realtimeSinceStartup - _lastRightBDownTime <= 0.3f)
					{
						_lastRightBDownTime = -10f;
						Player.RightController.HapticAction(0f, 0.08f, 150f, 0.55f);
						ToggleQuickFlashlight();
					}
					else
					{
						_lastRightBDownTime = realtimeSinceStartup;
					}
				}
			}
			catch
			{
			}
		}

		private static void UpdateTacticalLightAndBeam(float dt)
		{
			//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_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: 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_023e: 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_0244: 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_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_030b: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: 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_01e1: 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_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0415: Unknown result type (might be due to invalid IL or missing references)
			//IL_0442: 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_0450: Unknown result type (might be due to invalid IL or missing references)
			//IL_0459: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_tacLight == (Object)null)
			{
				return;
			}
			TacLightMountMode tacLightMountMode = (_manualHeadlampOverride ? TacLightMountMode.Headlamp : LumenPreferences.TacLightMount.Value);
			bool flag = LumenPreferences.EnablePerPixelLighting.Value && tacLightMountMode != TacLightMountMode.Off;
			Vector3 pos = Vector3.zero;
			Quaternion rot = Quaternion.identity;
			if (flag)
			{
				switch (tacLightMountMode)
				{
				case TacLightMountMode.AutoWeaponBarrel:
					if (!TryFindHeldGunMuzzle(out pos, out rot))
					{
						flag = false;
					}
					break;
				case TacLightMountMode.Headlamp:
					pos = Player.Head.position + Player.Head.forward * 0.08f - Player.Head.up * 0.04f;
					rot = Player.Head.rotation;
					break;
				case TacLightMountMode.ChestRig:
				{
					PhysTorso torso = Player.PhysicsRig.torso;
					Transform val = (((Object)(object)((torso != null) ? torso.rbChest : null) != (Object)null) ? ((Component)Player.PhysicsRig.torso.rbChest).transform : Player.Head);
					pos = val.position + val.forward * 0.16f + Vector3.up * 0.06f;
					rot = val.rotation;
					break;
				}
				case TacLightMountMode.LeftWrist:
					if ((Object)(object)Player.LeftHand != (Object)null)
					{
						pos = ((Component)Player.LeftHand).transform.position + ((Component)Player.LeftHand).transform.forward * 0.07f;
						rot = ((Component)Player.LeftHand).transform.rotation;
					}
					else
					{
						flag = false;
					}
					break;
				case TacLightMountMode.RightWrist:
					if ((Object)(object)Player.RightHand != (Object)null)
					{
						pos = ((Component)Player.RightHand).transform.position + ((Component)Player.RightHand).transform.forward * 0.07f;
						rot = ((Component)Player.RightHand).transform.rotation;
					}
					else
					{
						flag = false;
					}
					break;
				}
			}
			if (!flag)
			{
				if (((Behaviour)_tacLight).enabled)
				{
					((Behaviour)_tacLight).enabled = false;
				}
				if ((Object)(object)_beamGo != (Object)null && _beamGo.activeSelf)
				{
					_beamGo.SetActive(false);
				}
				return;
			}
			_tacGo.transform.SetPositionAndRotation(pos, rot);
			float num = 1f;
			RaycastHit val2 = default(RaycastHit);
			if (Physics.Raycast(pos, rot * Vector3.forward, ref val2, 1.15f, -2081194809, (QueryTriggerInteraction)1))
			{
				num = Mathf.Lerp(0.32f, 1f, Mathf.Clamp01((((RaycastHit)(ref val2)).distance - 0.15f) / 1f));
			}
			_smoothedWallDim = Mathf.MoveTowards(_smoothedWallDim, num, dt * 5f);
			Color val3 = LumenPreferences.ResolveTacLightColor(LumenPreferences.TacLightColor.Value);
			float num2 = Mathf.Clamp(LumenPreferences.TacLightRange.Value, 3f, 35f);
			float num3 = Mathf.Clamp(LumenPreferences.TacLightSpotAngle.Value, 18f, 95f);
			float num4 = Mathf.Clamp(LumenPreferences.TacLightIntensity.Value, 0.2f, 6f) * _smoothedWallDim;
			_tacLight.color = val3;
			_tacLight.range = num2;
			_tacLight.spotAngle = num3;
			_tacLight.innerSpotAngle = num3 * 0.45f;
			_tacLight.intensity = num4;
			_tacLight.shadows = (LightShadows)0;
			((Behaviour)_tacLight).enabled = true;
			if ((Object)(object)_beamGo != (Object)null && (Object)(object)_beamMat != (Object)null)
			{
				bool value = LumenPreferences.EnableVolumetricBeam.Value;
				if (_beamGo.activeSelf != value)
				{
					_beamGo.SetActive(value);
				}
				if (value)
				{
					float num5 = Mathf.Min(num2 * 0.58f, 7.5f);
					float num6 = num5 * Mathf.Tan(num3 * 0.5f * ((float)Math.PI / 180f)) * 0.88f;
					_beamGo.transform.localPosition = Vector3.zero;
					_beamGo.transform.localRotation = Quaternion.identity;
					_beamGo.transform.localScale = new Vector3(num6, num6, num5);
					float num7 = Mathf.Clamp(num4 * 0.085f, 0.04f, 0.28f);
					_beamMat.SetVector(IdBeamColor, new Vector4(val3.r, val3.g, val3.b, num7));
				}
			}
		}

		private static bool TryFindHeldGunMuzzle(out Vector3 pos, out Quaternion rot)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: 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_00dd: 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_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)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			pos = Vector3.zero;
			rot = Quaternion.identity;
			Hand[] array = (Hand[])(object)new Hand[2]
			{
				Player.RightHand,
				Player.LeftHand
			};
			foreach (Hand val in array)
			{
				GameObject val2 = (((Object)(object)val != (Object)null && ((Il2CppObjectBase)val).Pointer != IntPtr.Zero) ? val.m_CurrentAttachedGO : null);
				if (!((Object)(object)val2 == (Object)null) && !(((Il2CppObjectBase)val2).Pointer == IntPtr.Zero))
				{
					Gun componentInParent = val2.GetComponentInParent<Gun>();
					if ((Object)(object)componentInParent != (Object)null && ((Il2CppObjectBase)componentInParent).Pointer != IntPtr.Zero)
					{
						Transform val3 = (((Object)(object)componentInParent.firePointTransform != (Object)null) ? componentInParent.firePointTransform : ((Component)componentInParent).transform);
						pos = val3.position - val3.up * 0.03f + val3.forward * 0.02f;
						rot = val3.rotation;
						return true;
					}
				}
			}
			return false;
		}

		private static void UpdatePresenceLight()
		{
			//IL_0086: 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_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: 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)
			if ((Object)(object)_presenceLight == (Object)null)
			{
				return;
			}
			if (!LumenPreferences.EnablePerPixelLighting.Value || !LumenPreferences.EnableAvatarPresenceLight.Value)
			{
				if (((Behaviour)_presenceLight).enabled)
				{
					((Behaviour)_presenceLight).enabled = false;
				}
				return;
			}
			PhysTorso torso = Player.PhysicsRig.torso;
			Transform val = (((Object)(object)((torso != null) ? torso.rbChest : null) != (Object)null) ? ((Component)Player.PhysicsRig.torso.rbChest).transform : Player.Head);
			((Component)_presenceLight).transform.position = val.position + val.forward * 0.28f + Vector3.up * 0.22f;
			if (!((Behaviour)_presenceLight).enabled)
			{
				((Behaviour)_presenceLight).enabled = true;
			}
		}

		private static void UpdateMuzzleFlashes(float dt)
		{
			for (int i = 0; i < 4; i++)
			{
				MuzzleFlashSlot muzzleFlashSlot = _muzzlePool[i];
				if (!((Object)(object)muzzleFlashSlot?.Light == (Object)null) && !(muzzleFlashSlot.TimeRemaining <= 0f))
				{
					muzzleFlashSlot.TimeRemaining -= dt;
					if (muzzleFlashSlot.TimeRemaining <= 0f)
					{
						muzzleFlashSlot.TimeRemaining = 0f;
						((Behaviour)muzzleFlashSlot.Light).enabled = false;
					}
					else
					{
						float num = muzzleFlashSlot.TimeRemaining / 0.072f;
						muzzleFlashSlot.Light.intensity = muzzleFlashSlot.PeakIntensity * (num * num);
					}
				}
			}
		}

		private static void UpdateContactShadows()
		{
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: 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_011d: 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_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: 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_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: 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_0273: 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_0292: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_contactShadowMat == (Object)null || _shadowSlots[0] == null)
			{
				return;
			}
			if (LumenRealtimeShadows.IsRenderingShadows || !LumenPreferences.EnableContactShadows.Value || !(LumenPreferences.ContactShadowStrength.Value > 0.02f))
			{
				for (int i = 0; i < 7; i++)
				{
					if ((Object)(object)_shadowSlots[i]?.Go != (Object)null && _shadowSlots[i].Go.activeSelf)
					{
						_shadowSlots[i].Go.SetActive(false);
					}
				}
				return;
			}
			_contactShadowMat.SetFloat(IdShadowStrength, Mathf.Clamp01(LumenPreferences.ContactShadowStrength.Value));
			Vector3 dominantLightDirection = LumenPipelineAndWorldLighting.DominantLightDirection;
			Vector3 flatSunShift = default(Vector3);
			((Vector3)(ref flatSunShift))..ctor(dominantLightDirection.x, 0f, dominantLightDirection.z);
			PhysTorso torso = Player.PhysicsRig.torso;
			Vector3 val = (((Object)(object)((torso != null) ? torso.rbPelvis : null) != (Object)null) ? Player.PhysicsRig.torso.rbPelvis.position : (Player.Head.position - Vector3.up * 0.7f));
			PlaceContactShadow(_shadowSlots[0], val, 0.78f, flatSunShift);
			float unscaledTime = Time.unscaledTime;
			if (unscaledTime >= _nextNpcScanTime)
			{
				_nextNpcScanTime = unscaledTime + 2f;
				_cachedNpcs.Clear();
				try
				{
					foreach (AIBrain item in Object.FindObjectsOfType<AIBrain>())
					{
						if ((Object)(object)item != (Object)null && ((Il2CppObjectBase)item).Pointer != IntPtr.Zero && !item.isDead && ((Component)item).gameObject.activeInHierarchy)
						{
							_cachedNpcs.Add(item);
						}
					}
				}
				catch
				{
				}
			}
			int num = 1;
			for (int j = 0; j < _cachedNpcs.Count; j++)
			{
				if (num >= 7)
				{
					break;
				}
				AIBrain val2 = _cachedNpcs[j];
				if (!((Object)(object)val2 == (Object)null) && !(((Il2CppObjectBase)val2).Pointer == IntPtr.Zero) && !val2.isDead)
				{
					Vector3 val3 = (((Object)(object)val2.puppetMaster != (Object)null && (Object)(object)val2.puppetMaster.targetRoot != (Object)null) ? val2.puppetMaster.targetRoot : ((Component)val2).transform).position + Vector3.up * 0.75f;
					Vector3 val4 = val3 - val;
					if (!(((Vector3)(ref val4)).sqrMagnitude > 324f))
					{
						PlaceContactShadow(_shadowSlots[num], val3, 0.74f, flatSunShift);
						num++;
					}
				}
			}
			for (int k = num; k < 7; k++)
			{
				if ((Object)(object)_shadowSlots[k]?.Go != (Object)null && _shadowSlots[k].Go.activeSelf)
				{
					_shadowSlots[k].Go.SetActive(false);
				}
			}
		}

		private static void PlaceContactShadow(ContactShadowSlot slot, Vector3 origin, float baseDiameter, Vector3 flatSunShift)
		{
			//IL_0015: 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_0034: 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_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)slot?.Go == (Object)null)
			{
				return;
			}
			RaycastHit val = default(RaycastHit);
			if (Physics.Raycast(origin, Vector3.down, ref val, 2.5f, -2081194809, (QueryTriggerInteraction)1) && ((RaycastHit)(ref val)).normal.y > 0.55f)
			{
				float num = Mathf.Max(0f, ((RaycastHit)(ref val)).distance - 0.55f);
				float num2 = baseDiameter * Mathf.Lerp(1f, 1.38f, Mathf.Clamp01(num / 1.5f));
				Vector3 val2 = flatSunShift * Mathf.Clamp(num * 0.25f, 0.03f, 0.3f);
				slot.Trans.position = ((RaycastHit)(ref val)).point + ((RaycastHit)(ref val)).normal * 0.014f + val2;
				slot.Trans.rotation = Quaternion.FromToRotation(Vector3.up, ((RaycastHit)(ref val)).normal);
				slot.Trans.localScale = new Vector3(num2, 1f, num2 * 1.12f);
				if (!slot.Go.activeSelf)
				{
					slot.Go.SetActive(true);
				}
			}
			else if (slot.Go.activeSelf)
			{
				slot.Go.SetActive(false);
			}
		}

		public static void SendToast(string title, string message, NotificationType type = (NotificationType)0, float sec = 2.2f)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: 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_0084: Expected O, but got Unknown
			try
			{
				Notifier.Send(new Notification
				{
					Title = new NotificationText
					{
						Text = title,
						Color = new Color(0.25f, 0.85f, 1f),
						RichText = true
					},
					Message = new NotificationText
					{
						Text = message,
						Color = Color.white,
						RichText = true
					},
					ShowTitleOnPopup = true,
					PopupLength = sec,
					Type = type
				});
			}
			catch
			{
			}
		}
	}
	[HarmonyPatch(typeof(Gun), "OnFire")]
	internal static class GunOnFireLightingPatch
	{
		private static void Postfix(Gun __instance)
		{
			try
			{
				LumenDynamicLights.NotifyGunFired(__instance);
			}
			catch
			{
			}
		}
	}
	public enum LckCameraMode
	{
		Selfie,
		FirstPerson,
		ThirdPerson
	}
	public static class LumenLckCamera
	{
		private sealed class TouchButton
		{
			public string Id;

			public Transform CapTrans;

			public BoxCollider TriggerCollider;

			public Vector3 BaseLocalPos;

			public Vector3 HalfExtents;

			public Material Mat;

			public Color BaseColor;

			public TMP_Text Label;

			public Action OnPress;

			public float PressAnim;
		}

		private static readonly int IdBaseColor = Shader.PropertyToID("_BaseColor");

		private static readonly int IdBaseMap = Shader.PropertyToID("_BaseMap");

		private static readonly int IdScreenParams2 = Shader.PropertyToID("_ScreenParams2");

		private static GameObject _tabletRoot;

		private static Transform _deckRoot;

		private static GameObject _lensHostGo;

		private static Camera _lensCam;

		private static UniversalAdditionalCameraData _lensCamData;

		private static GameObject _leftTipTriggerGo;

		private static SphereCollider _leftTipTriggerCol;

		private static GameObject _rightTipTriggerGo;

		private static SphereCollider _rightTipTriggerCol;

		private static GameObject _palmProbeGo;

		private static SphereCollider _palmProbeCol;

		private static readonly List<BoxCollider> _grabZoneColliders = new List<BoxCollider>(6);

		private static RenderTexture _rawPreviewRT;

		private static RenderTexture _gradedPreviewRT;

		private static RenderTexture _rawCaptureRT;

		private static RenderTexture _gradedCaptureRT;

		private static Material _matChassis;

		private static Material _matHandle;

		private static Material _matScreen;

		private static Material _matWhiteBorder;

		private static Material _matRearTallyLed;

		private static Transform _activeTabBorder;

		private static TMP_Text _fovValueTmp;

		private static TMP_Text _smoothValueTmp;

		private static TMP_Text _hudStatusTmp;

		private static TouchButton _btnMic;

		private static TouchButton _btnAspect;

		private static TouchButton _btnRecord;

		private static readonly List<Renderer> _tabletVisualRenderers = new List<Renderer>(48);

		private static readonly List<Canvas> _tabletCanvases = new List<Canvas>(20);

		private static readonly List<TouchButton> _buttons = new List<TouchButton>(14);

		private static bool _holdingLeft;

		private static bool _holdingRight;

		private static Vector3 _leftGrabLocalPos;

		private static Quaternion _leftGrabLocalRot = Quaternion.identity;

		private static Vector3 _rightGrabLocalPos;

		private static Quaternion _rightGrabLocalRot = Quaternion.identity;

		private static Quaternion _twoHandBaseTabletRot = Quaternion.identity;

		private static Vector3 _twoHandBaseAxis = Vector3.right;

		private static Vector3 _twoHandBaseUp = Vector3.up;

		private static Vector3 _twoHandMidLocalOffset = Vector3.zero;

		private static bool _wasTwoHanded;

		private static bool _prevLeftGrip;

		private static bool _prevRightGrip;

		private static float _nextPokeAllowedAt;

		private static bool _leftFingerInsideAny;

		private static bool _rightFingerInsideAny;

		private static bool _poseInitialized;

		private static Vector3 _smoothedLensPos;

		private static Quaternion _smoothedLensRot = Quaternion.identity;

		private static int _frameCounter;

		private static int _framesSinceLastCapture = 99;

		private static float _nextRecordFrameAt;

		private static float _shutterFlash;

		private static bool _pendingHighResPhoto;

		private static bool _stereoSynced;

		private static int _observerLayer = -1;

		public static bool IsSpawned
		{
			get
			{
				if ((Object)(object)_tabletRoot != (Object)null && ((Il2CppObjectBase)_tabletRoot).Pointer != IntPtr.Zero)
				{
					return _tabletRoot.activeSelf;
				}
				return false;
			}
		}

		public static LckCameraMode CurrentMode { get; private set; } = LckCameraMode.Selfie;

		public static bool IsPortrait { get; private set; }

		public static bool IsFlipped { get; private set; }

		public static void OnLevelLoaded()
		{
			if (LumenPreferences.IsQuestDevice)
			{
				LumenMediaRecorder.InitializePaths();
				DespawnCamera();
				_observerLayer = LayerMask.NameToLayer("Observer");
				_stereoSynced = false;
			}
		}

		public static void OnLevelUnloaded()
		{
			if (LumenPreferences.IsQuestDevice)
			{
				if (LumenMediaRecorder.IsRecording || LumenMediaRecorder.IsBusyFinalizing)
				{
					LumenMediaRecorder.StopVideoRecording(immediate: true);
				}
				DespawnCamera();
			}
		}

		public static void SpawnOrRecallInFrontOfPlayer()
		{
			//IL_0031: 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_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_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_0082: 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_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: 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_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: 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_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)
			if (!LumenPreferences.IsQuestDevice || (Object)(object)Player.Head == (Object)null)
			{
				return;
			}
			EnsureBuilt();
			if (!((Object)(object)_tabletRoot == (Object)null))
			{
				Transform head = Player.Head;
				Vector3 forward = default(Vector3);
				((Vector3)(ref forward))..ctor(head.forward.x, 0f, head.forward.z);
				if (((Vector3)(ref forward)).sqrMagnitude < 0.01f)
				{
					forward = head.forward;
				}
				((Vector3)(ref forward)).Normalize();
				Vector3 val = head.position + forward * 0.52f - Vector3.up * 0.14f;
				Vector3 val2 = val - head.position;
				Quaternion val3 = Quaternion.LookRotation(((Vector3)(ref val2)).normalized, Vector3.up);
				_holdingLeft = false;
				_holdingRight = false;
				_wasTwoHanded = false;
				_tabletRoot.transform.SetPositionAndRotation(val, val3);
				_tabletRoot.SetActive(true);
				_poseInitialized = false;
				RefreshButtonVisuals();
				LumenDynamicLights.SendToast("LCK Camera Ready!", "Grab handles with Grip, and poke buttons with your index fingertip!", (NotificationType)0);
			}
		}

		public static void ToggleSpawn()
		{
			if (IsSpawned)
			{
				DespawnCamera();
			}
			else
			{
				SpawnOrRecallInFrontOfPlayer();
			}
		}

		public static void DespawnCamera()
		{
			if (LumenMediaRecorder.IsRecording)
			{
				LumenMediaRecorder.StopVideoRecording();
			}
			_holdingLeft = false;
			_holdingRight = false;
			_wasTwoHanded = false;
			if ((Object)(object)_tabletRoot != (Object)null && ((Il2CppObjectBase)_tabletRoot).Pointer != IntPtr.Zero)
			{
				Object.Destroy((Object)(object)_tabletRoot);
			}
			if ((Object)(object)_lensHostGo != (Object)null && ((Il2CppObjectBase)_lensHostGo).Pointer != IntPtr.Zero)
			{
				Object.Destroy((Object)(object)_lensHostGo);
			}
			if ((Object)(object)_leftTipTriggerGo != (Object)null && ((Il2CppObjectBase)_leftTipTriggerGo).Pointer != IntPtr.Zero)
			{
				Object.Destroy((Object)(object)_leftTipTriggerGo);
			}
			if ((Object)(object)_rightTipTriggerGo != (Object)null && ((Il2CppObjectBase)_rightTipTriggerGo).Pointer != IntPtr.Zero)
			{
				Object.Destroy((Object)(object)_rightTipTriggerGo);
			}
			if ((Object)(object)_palmProbeGo != (Object)null && ((Il2CppObjectBase)_palmProbeGo).Pointer != IntPtr.Zero)
			{
				Object.Destroy((Object)(object)_palmProbeGo);
			}
			_tabletRoot = null;
			_deckRoot = null;
			_lensHostGo = null;
			_lensCam = null;
			_lensCamData = null;
			_leftTipTriggerGo = null;
			_leftTipTriggerCol = null;
			_rightTipTriggerGo = null;
			_rightTipTriggerCol = null;
			_palmProbeGo = null;
			_palmProbeCol = null;
			_grabZoneColliders.Clear();
			_buttons.Clear();
			_tabletVisualRenderers.Clear();
			_tabletCanvases.Clear();
			ReleaseRT(ref _rawPreviewRT);
			ReleaseRT(ref _gradedPreviewRT);
			ReleaseRT(ref _rawCaptureRT);
			ReleaseRT(ref _gradedCaptureRT);
		}

		private static void ReleaseRT(ref RenderTexture rt)
		{
			if ((Object)(object)rt != (Object)null)
			{
				try
				{
					rt.Release();
					Object.Destroy((Object)(object)rt);
				}
				catch
				{
				}
				rt = null;
			}
		}

		public static void TriggerPhoto()
		{
			if (!IsSpawned)
			{
				SpawnOrRecallInFrontOfPlayer();
			}
			if (IsSpawned)
			{
				_pendingHighResPhoto = true;
				_shutterFlash = 0.85f;
				PulseBothHands(0.05f, 190f, 0.55f);
			}
		}

		public static void ToggleVideoRecording()
		{
			if (LumenMediaRecorder.IsRecording)
			{
				LumenMediaRecorder.StopVideoRecording();
				if ((Object)(object)_matScreen != (Object)null && (Object)(object)_gradedPreviewRT != (Object)null)
				{
					_matScreen.SetTexture(IdBaseMap, (Texture)(object)_gradedPreviewRT);
				}
				PulseBothHands(0.08f, 120f, 0.65f);
				RefreshButtonVisuals();
				return;
			}
			if (!IsSpawned)
			{
				SpawnOrRecallInFrontOfPlayer();
			}
			if (IsSpawned)
			{
				GetTargetVideoSpec(out var outWidth, out var outHeight, out var sceneWidth, out var sceneHeight, out var fps, out var bitrate);
				EnsureCaptureRenderTextures(sceneWidth, sceneHeight, outWidth, outHeight);
				if (LumenMediaRecorder.StartVideoRecording(outWidth, outHeight, fps, bitrate, LumenPreferences.LckRecordGameAudio.Value, LumenPreferences.LckRecordMic.Value))
				{
					_nextRecordFrameAt = Time.realtimeSinceStartup;
					_framesSinceLastCapture = 99;
					PulseBothHands(0.08f, 220f, 0.75f);
					LumenDynamicLights.SendToast("LCK Recording Started!", $"{outWidth}x{outHeight} @ {fps}fps MP4 -> Quest Gallery", (NotificationType)0, 1.8f);
				}
				else
				{
					LumenDynamicLights.SendToast("Recording Error", "Could not initialize Quest hardware video encoder.", (NotificationType)2);
				}
				RefreshButtonVisuals();
			}
		}

		public static void SetMode(LckCameraMode mode)
		{
			CurrentMode = mode;
			_poseInitialized = false;
			RefreshButtonVisuals();
		}

		public static void AdjustFov(float delta)
		{
			float value = Mathf.Clamp(Mathf.Round((LumenPreferences.LckFov.Value + delta) / 5f) * 5f, 50f, 110f);
			LumenPreferences.LckFov.Value = value;
			LumenPreferences.Save();
			RefreshButtonVisuals();
		}

		public static void AdjustSmoothing(int delta)
		{
			int value = Mathf.Clamp(LumenPreferences.LckSmoothing.Value + delta, 0, 10);
			LumenPreferences.LckSmoothing.Value = value;
			LumenPreferences.Save();
			RefreshButtonVisuals();
		}

		private static void GetTargetVideoSpec(out int outWidth, out int outHeight, out int sceneWidth, out int sceneHeight, out int fps, out int bitrate)
		{
			switch (LumenPreferences.LckQuality.Value)
			{
			case LckVideoQuality.Performance_540p_30fps:
				outWidth = 960;
				outHeight = 540;
				sceneWidth = 960;
				sceneHeight = 540;
				fps = 30;
				bitrate = 8000000;
				break;
			case LckVideoQuality.HD_720p_60fps:
				outWidth = 1280;
				outHeight = 720;
				sceneWidth = 960;
				sceneHeight = 540;
				fps = 60;
				bitrate = 12000000;
				break;
			case LckVideoQuality.FullHD_1080p_30fps:
				outWidth = 1920;
				outHeight = 1080;
				sceneWidth = 1280;
				sceneHeight = 720;
				fps = 30;
				bitrate = 15000000;
				break;
			default:
				outWidth = 1280;
				outHeight = 720;
				sceneWidth = 1024;
				sceneHeight = 576;
				fps = 30;
				bitrate = 10000000;
				break;
			}
			if (IsPortrait)
			{
				int num = outHeight;
				int num2 = outWidth;
				outWidth = num;
				outHeight = num2;
				num2 = sceneHeight;
				num = sceneWidth;
				sceneWidth = num2;
				sceneHeight = num;
			}
		}

		private static RenderTextureFormat GetFastHdrFormat()
		{
			if (SystemInfo.SupportsRenderTextureFormat((RenderTextureFormat)22))
			{
				return (RenderTextureFormat)22;
			}
			return (RenderTextureFormat)9;
		}

		private static void EnsurePreviewRenderTextures()
		{
			//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_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Expected O, but got Unknown
			//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_00d7: Expected O, but got Unknown
			int num = (IsPortrait ? 540 : 960);
			int num2 = (IsPortrait ? 960 : 540);
			if ((Object)(object)_rawPreviewRT != (Object)null && (((Texture)_rawPreviewRT).width != num || ((Texture)_rawPreviewRT).height != num2))
			{
				ReleaseRT(ref _rawPreviewRT);
				ReleaseRT(ref _gradedPreviewRT);
			}
			if ((Object)(object)_rawPreviewRT == (Object)null)
			{
				_rawPreviewRT = new RenderTexture(num, num2, 16, GetFastHdrFormat())
				{
					name = "QL_LCK_PreviewRaw",
					antiAliasing = 1,
					hideFlags = (HideFlags)61
				};
				_rawPreviewRT.Create();
			}
			if ((Object)(object)_gradedPreviewRT == (Object)null)
			{
				_gradedPreviewRT = new RenderTexture(num, num2, 0, (RenderTextureFormat)0, (RenderTextureReadWrite)2)
				{
					name = "QL_LCK_PreviewGraded",
					hideFlags = (HideFlags)61
				};
				_gradedPreviewRT.Create();
			}
			if ((Object)(object)_matScreen != (Object)null && !LumenMediaRecorder.IsRecording)
			{
				_matScreen.SetTexture(IdBaseMap, (Texture)(object)_gradedPreviewRT);
			}
		}

		private static void EnsureCaptureRenderTextures(int sceneW, int sceneH, int outW, int outH)
		{
			//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_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Expected O, but got Unknown
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Expected O, but got Unknown
			sceneW = Mathf.Max(64, sceneW & -4);
			sceneH = Mathf.Max(64, sceneH & -2);
			outW = Mathf.Max(64, outW & -16);
			outH = Mathf.Max(64, outH & -2);
			if ((Object)(object)_rawCaptureRT != (Object)null && (((Texture)_rawCaptureRT).width != sceneW || ((Texture)_rawCaptureRT).height != sceneH))
			{
				ReleaseRT(ref _rawCaptureRT);
			}
			if ((Object)(object)_gradedCaptureRT != (Object)null && (((Texture)_gradedCaptureRT).width != outW || ((Texture)_gradedCaptureRT).height != outH))
			{
				ReleaseRT(ref _gradedCaptureRT);
			}
			if ((Object)(object)_rawCaptureRT == (Object)null)
			{
				_rawCaptureRT = new RenderTexture(sceneW, sceneH, 16, GetFastHdrFormat())
				{
					name = "QL_LCK_CaptureRaw",
					antiAliasing = 1,
					hideFlags = (HideFlags)61
				};
				_rawCaptureRT.Create();
			}
			if ((Object)(object)_gradedCaptureRT == (Object)null)
			{
				_gradedCaptureRT = new RenderTexture(outW, outH, 0, (RenderTextureFormat)0, (RenderTextureReadWrite)2)
				{
					name = "QL_LCK_CaptureGraded",
					hideFlags = (HideFlags)61
				};
				_gradedCaptureRT.Create();
			}
		}

		private static void EnsureBuilt()
		{
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: 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_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_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Expected O, but got Unknown
			//IL_011c: 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_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Expected O, but got Unknown
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: 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_0297: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d9: 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_031b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0349: 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_038b: Unknown result type (might be due to invalid IL or missing references)
			//IL_039f: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0409: Unknown result type (might be due to invalid IL or missing references)
			//IL_041d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0445: Unknown result type (might be due to invalid IL or missing references)
			//IL_0459: Unknown result type (might be due to invalid IL or missing references)
			//IL_0486: Unknown result type (might be due to invalid IL or missing references)
			//IL_049a: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0517: Unknown result type (might be due to invalid IL or missing references)
			//IL_052b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0593: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_060e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0618: Unknown result type (might be due to invalid IL or missing references)
			//IL_0661: Unknown result type (might be due to invalid IL or missing references)
			//IL_0675: Unknown result type (might be due to invalid IL or missing references)
			//IL_067f: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_070d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0721: Unknown result type (might be due to invalid IL or missing references)
			//IL_0758: Unknown result type (might be due to invalid IL or missing references)
			//IL_076c: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_0813: Unknown result type (might be due to invalid IL or missing references)
			//IL_0827: Unknown result type (might be due to invalid IL or missing references)
			//IL_0831: Unknown result type (might be due to invalid IL or missing references)
			//IL_0875: Unknown result type (might be due to invalid IL or missing references)
			//IL_0889: Unknown result type (might be due to invalid IL or missing references)
			//IL_0894: Unknown result type (might be due to invalid IL or missing references)
			//IL_08bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_090a: Unknown result type (might be due to invalid IL or missing references)
			//IL_091e: Unknown result type (might be due to invalid IL or missing references)
			//IL_095e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0972: Unknown result type (might be due to invalid IL or missing references)
			//IL_097c: Unknown result type (might be due to invalid IL or missing references)
			//IL_09c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_09d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_09e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a2c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a40: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a4a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a75: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a7a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a90: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aa5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aaf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ac4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ae2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0af6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b24: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b38: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b42: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b8a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b9e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ba8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bf0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c04: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c1d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c61: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c75: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c7f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0caa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cb4: Expected O, but got Unknown
			if (((Object)(object)_tabletRoot != (Object)null && ((Il2CppObjectBase)_tabletRoot).Pointer != IntPtr.Zero) || !LumenShaderBank.EnsureLoaded() || (Object)(object)LumenShaderBank.LckScreenShader == (Object)null || (Object)(object)LumenShaderBank.SharedCubeMesh == (Object)null)
			{
				return;
			}
			_buttons.Clear();
			_tabletVisualRenderers.Clear();
			Shader lckScreenShader = LumenShaderBank.LckScreenShader;
			_matChassis = MakeSolidMat(lckScreenShader, "QL_LCK_Chassis", new Color(0.075f, 0.085f, 0.1f), emissiveFlat: false);
			_matHandle = MakeSolidMat(lckScreenShader, "QL_LCK_Handle", new Color(0.055f, 0.062f, 0.075f), emissiveFlat: false);
			_matWhiteBorder = MakeSolidMat(lckScreenShader, "QL_LCK_Border", new Color(0.95f, 0.97f, 1f), emissiveFlat: true);
			_matRearTallyLed = MakeSolidMat(lckScreenShader, "QL_LCK_Tally", new Color(0.18f, 0.85f, 0.45f), emissiveFlat: true);
			_matScreen = new Material(lckScreenShader)
			{
				name = "QL_LCK_Viewfinder",
				hideFlags = (HideFlags)61
			};
			_matScreen.SetColor(IdBaseColor, Color.white);
			_matScreen.SetVector(IdScreenParams2, new Vector4(1f, 0f, 0f, 0f));
			_tabletRoot = new GameObject("QuestLumen_LCK_Tablet");
			AddBox(_tabletRoot.transform, "MainChassis", new Vector3(0f, 0.012f, 0.002f), new Vector3(0.352f, 0.194f, 0.015f), _matChassis);
			AddBox(_tabletRoot.transform, "RearLensBlock", new Vector3(-0.08f, 0.05f, 0.015f), new Vector3(0.052f, 0.052f, 0.014f), _matHandle);
			AddBox(_tabletRoot.transform, "RearTallyRing", new Vector3(-0.08f, 0.05f, 0.023f), new Vector3(0.024f, 0.024f, 0.004f), _matRearTallyLed);
			AddBox(_tabletRoot.transform, "HandleL_Top", new Vector3(-0.192f, 0.088f, 0.002f), new Vector3(0.044f, 0.018f, 0.016f), _matHandle);
			AddBox(_tabletRoot.transform, "HandleL_Bot", new Vector3(-0.192f, -0.064f, 0.002f), new Vector3(0.044f, 0.018f, 0.016f), _matHandle);
			AddBox(_tabletRoot.transform, "HandleL_Grip", new Vector3(-0.208f, 0.012f, 0.002f), new Vector3(0.018f, 0.168f, 0.02f), _matHandle);
			AddBox(_tabletRoot.transform, "HandleR_Top", new Vector3(0.192f, 0.088f, 0.002f), new Vector3(0.044f, 0.018f, 0.016f), _matHandle);
			AddBox(_tabletRoot.transform, "HandleR_Bot", new Vector3(0.192f, -0.064f, 0.002f), new Vector3(0.044f, 0.018f, 0.016f), _matHandle);
			AddBox(_tabletRoot.transform, "HandleR_Grip", new Vector3(0.208f, 0.012f, 0.002f), new Vector3(0.018f, 0.168f, 0.02f), _matHandle);
			AddGrabTriggerZone(_tabletRoot.transform, "GrabZone_LeftHandle", new Vector3(-0.196f, 0.004f, 0.002f), new Vector3(0.105f, 0.22f, 0.12f));
			AddGrabTriggerZone(_tabletRoot.transform, "GrabZone_RightHandle", new Vector3(0.196f, 0.004f, 0.002f), new Vector3(0.105f, 0.22f, 0.12f));
			AddGrabTriggerZone(_tabletRoot.transform, "GrabZone_RearFrame", new Vector3(0f, 0.008f, 0.036f), new Vector3(0.38f, 0.22f, 0.085f));
			EnsureFingerTipTriggersBuilt();
			AddBox(_tabletRoot.transform, "ViewfinderScreen", new Vector3(-0.046f, -0.008f, -0.0068f), new Vector3(0.236f, 0.133f, 0.002f), _matScreen);
			_hudStatusTmp = Create3DText(_tabletRoot.transform, "HUD_Badge", new Vector3(-0.046f, -0.064f, -0.009f), 0.105f, new Vector2(0.22f, 0.024f), "SELFIE • 1080p");
			_activeTabBorder = AddBox(_tabletRoot.transform, "ActiveModeBorder", new Vector3(-0.125f, 0.082f, -0.0072f), new Vector3(0.079f, 0.039f, 0.002f), _matWhiteBorder).transform;
			Color val = default(Color);
			((Color)(ref val))..ctor(0.16f, 0.17f, 0.19f);
			Color color = default(Color);
			((Color)(ref color))..ctor(0.22f, 0.23f, 0.26f);
			AddTouchButton(_tabletRoot.transform, "Tab_Selfie", "SELFIE", new Vector3(-0.125f, 0.082f, -0.0085f), new Vector3(0.074f, 0.034f, 0.005f), 0.095f, val, delegate
			{
				SetMode(LckCameraMode.Selfie);
			});
			AddTouchButton(_tabletRoot.transform, "Tab_FirstPerson", "FIRST PERSON", new Vector3(-0.045f, 0.082f, -0.0085f), new Vector3(0.078f, 0.034f, 0.005f), 0.078f, val, delegate
			{
				SetMode(LckCameraMode.FirstPerson);
			});
			AddTouchButton(_tabletRoot.transform, "Tab_ThirdPerson", "THIRD PERSON", new Vector3(0.036f, 0.082f, -0.0085f), new Vector3(0.078f, 0.034f, 0.005f), 0.078f, val, delegate
			{
				SetMode(LckCameraMode.ThirdPerson);
			});
			AddBox(_tabletRoot.transform, "FovPanelBg", new Vector3(0.122f, 0.074f, -0.0072f), new Vector3(0.086f, 0.048f, 0.003f), MakeSolidMat(lckScreenShader, "QL_FovBg", val, emissiveFlat: false));
			Create3DText(_tabletRoot.transform, "FovHeader", new Vector3(0.122f, 0.089f, -0.0095f), 0.078f, new Vector2(0.08f, 0.018f), "FOV");
			_fovValueTmp = Create3DText(_tabletRoot.transform, "FovVal", new Vector3(0.122f, 0.066f, -0.0098f), 0.105f, new Vector2(0.04f, 0.022f), "75");
			AddTouchButton(_tabletRoot.transform, "Btn_FovMinus", "-", new Vector3(0.092f, 0.066f, -0.0092f), new Vector3(0.022f, 0.022f, 0.005f), 0.13f, color, delegate
			{
				AdjustFov(-5f);
			});
			AddTouchButton(_tabletRoot.transform, "Btn_FovPlus", "+", new Vector3(0.152f, 0.066f, -0.0092f), new Vector3(0.022f, 0.022f, 0.005f), 0.13f, color, delegate
			{
				AdjustFov(5f);
			});
			AddBox(_tabletRoot.transform, "SmoothPanelBg", new Vector3(0.122f, 0.02f, -0.0072f), new Vector3(0.086f, 0.048f, 0.003f), MakeSolidMat(lckScreenShader, "QL_SmBg", val, emissiveFlat: false));
			Create3DText(_tabletRoot.transform, "SmoothHeader", new Vector3(0.122f, 0.035f, -0.0095f), 0.072f, new Vector2(0.084f, 0.018f), "SMOOTHING");
			_smoothValueTmp = Create3DText(_tabletRoot.transform, "SmoothVal", new Vector3(0.122f, 0.012f, -0.0098f), 0.105f, new Vector2(0.04f, 0.022f), "4");
			AddTouchButton(_tabletRoot.transform, "Btn_SmMinus", "-", new Vector3(0.092f, 0.012f, -0.0092f), new Vector3(0.022f, 0.022f, 0.005f), 0.13f, color, delegate
			{
				AdjustSmoothing(-1);
			});
			AddTouchButton(_tabletRoot.transform, "Btn_SmPlus", "+", new Vector3(0.152f, 0.012f, -0.0092f), new Vector3(0.022f, 0.022f, 0.005f), 0.13f, color, delegate
			{
				AdjustSmoothing(1);
			});
			AddTouchButton(_tabletRoot.transform, "Btn_Flip", "FLIP", new Vector3(0.122f, -0.042f, -0.0085f), new Vector3(0.086f, 0.056f, 0.005f), 0.105f, val, delegate
			{
				IsFlipped = !IsFlipped;
				_poseInitialized = false;
				RefreshButtonVisuals();
			});
			GameObject val2 = new GameObject("LowerControlDeck");
			val2.transform.SetParent(_tabletRoot.transform, false);
			val2.transform.localPosition = new Vector3(0f, -0.104f, -0.02f);
			val2.transform.localRotation = Quaternion.Euler(28f, 0f, 0f);
			_deckRoot = val2.transform;
			AddBox(_deckRoot, "DeckBase", Vector3.zero, new Vector3(0.35f, 0.058f, 0.012f), _matChassis);
			_btnMic = AddTouchButton(_deckRoot, "Btn_Mic", "MIC OFF", new Vector3(-0.132f, 0.002f, -0.0075f), new Vector3(0.058f, 0.042f, 0.006f), 0.082f, color, delegate
			{
				LumenPreferences.LckRecordMic.Value = !LumenPreferences.LckRecordMic.Value;
				LumenPreferences.Save();
				RefreshButtonVisuals();
			});
			_btnAspect = AddTouchButton(_deckRoot, "Btn_Aspect", "16:9", new Vector3(-0.068f, 0.002f, -0.0075f), new Vector3(0.056f, 0.042f, 0.006f), 0.095f, color, delegate
			{
				if (LumenMediaRecorder.IsRecording)
				{
					LumenDynamicLights.SendToast("Stop Recording First", "Stop current video before switching 16:9 / 9:16!", (NotificationType)0);
				}
				else
				{
					IsPortrait = !IsPortrait;
					EnsurePreviewRenderTextures();
					RefreshButtonVisuals();
				}
			});
			AddTouchButton(_deckRoot, "Btn_Photo", "PHOTO", new Vector3(0.002f, 0.002f, -0.0075f), new Vector3(0.068f, 0.042f, 0.006f), 0.092f, new Color(0.18f, 0.34f, 0.52f), TriggerPhoto);
			_btnRecord = AddTouchButton(_deckRoot, "Btn_Record", "RECORD", new Vector3(0.104f, 0.002f, -0.0075f), new Vector3(0.116f, 0.042f, 0.006f), 0.105f, color, ToggleVideoRecording);
			_lensHostGo = new GameObject("QuestLumen_LCK_LensCamera");
			_lensCam = _lensHostGo.AddComponent<Camera>();
			((Behaviour)_lensCam).enabled = false;
			_lensCam.stereoTargetEye = (StereoTargetEyeMask)0;
			_lensCam.nearClipPlane = 0.06f;
			_lensCam.farClipPlane = 180f;
			_lensCam.allowMSAA = false;
			_lensCam.useOcclusionCulling = true;
			_lensCam.fieldOfView = LumenPreferences.LckFov.Value;
			_lensCamData = _lensHostGo.GetComponent<UniversalAdditionalCameraData>() ?? _lensHostGo.AddComponent<UniversalAdditionalCameraData>();
			_lensCamData.renderPostProcessing = false;
			_lensCamData.requiresColorOption = (CameraOverrideOption)0;
			_lensCamData.requiresDepthOption = (CameraOverrideOption)0;
			EnsurePreviewRenderTextures();
			RefreshButtonVisuals();
		}

		private static Material MakeSolidMat(Shader sh, string name, Color col, bool emissiveFlat)
		{
			//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_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Expected O, but got Unknown
			Material val = new Material(sh)
			{
				name = name,
				hideFlags = (HideFlags)61
			};
			val.SetColor(IdBaseColor, col);
			val.SetVector(IdScreenParams2, new Vector4(0f, 0f, 0f, emissiveFlat ? 1f : 0f));
			return val;
		}

		private static GameObject AddBox(Transform parent, string name, Vector3 localPos, Vector3 localScale, Material mat)
		{
			//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_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: 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_0045: 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_008c: Expected O, but got Unknown
			GameObject val = new GameObject("QL_LCK_" + name);
			val.transform.SetParent(parent, false);
			val.transform.localPosition = localPos;
			val.transform.localRotation = Quaternion.identity;
			val.transform.localScale = localScale;
			val.AddComponent<MeshFilter>().sharedMesh = LumenShaderBank.SharedCubeMesh;
			MeshRenderer val2 = val.AddComponent<MeshRenderer>();
			((Renderer)val2).sharedMaterial = mat;
			((Renderer)val2).shadowCastingMode = (ShadowCastingMode)0;
			((Renderer)val2).receiveShadows = false;
			((Renderer)val2).lightProbeUsage = (LightProbeUsage)0;
			((Renderer)val2).reflectionProbeUsage = (ReflectionProbeUsage)0;
			_tabletVisualRenderers.Add((Renderer)(object)val2);
			return val;
		}

		private static void AddGrabTriggerZone(Transform parent, string name, Vector3 localCenter, Vector3 localSize)
		{
			//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_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: 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_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("QL_LCK_" + name);
			val.transform.SetParent(parent, false);
			val.transform.localPosition = localCenter;
			val.transform.localRotation = Quaternion.identity;
			val.transform.localScale = Vector3.one;
			BoxCollider val2 = val.AddComponent<BoxCollider>();
			((Collider)val2).isTrigger = true;
			val2.center = Vector3.zero;
			val2.size = localSize;
			_grabZoneColliders.Add(val2);
		}

		private static void EnsureFingerTipTriggersBuilt()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Expected O, but got Unknown
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Expected O, but got Unknown
			if ((Object)(object)_leftTipTriggerGo == (Object)null || ((Il2CppObjectBase)_leftTipTriggerGo).Pointer == IntPtr.Zero)
			{
				_leftTipTriggerGo = new GameObject("QL_LCK_LeftIndexFingerTip");
				_leftTipTriggerCol = _leftTipTriggerGo.AddComponent<SphereCollider>();
				((Collider)_leftTipTriggerCol).isTrigger = true;
				_leftTipTriggerCol.radius = 0.011f;
				Rigidbody obj = _leftTipTriggerGo.AddComponent<Rigidbody>();
				obj.isKinematic = true;
				obj.useGravity = false;
			}
			if ((Object)(object)_rightTipTriggerGo == (Object)null || ((Il2CppObjectBase)_rightTipTriggerGo).Pointer == IntPtr.Zero)
			{
				_rightTipTriggerGo = new GameObject("QL_LCK_RightIndexFingerTip");
				_rightTipTriggerCol = _rightTipTriggerGo.AddComponent<SphereCollider>();
				((Collider)_rightTipTriggerCol).isTrigger = true;
				_rightTipTriggerCol.radius = 0.011f;
				Rigidbody obj2 = _rightTipTriggerGo.AddComponent<Rigidbody>();
				obj2.isKinematic = true;
				obj2.useGravity = false;
			}
			if ((Object)(object)_palmProbeGo == (Object)null || ((Il2CppObjectBase)_palmProbeGo).Pointer == IntPtr.Zero)
			{
				_palmProbeGo = new GameObject("QL_LCK_HandGrabProbe");
				_palmProbeCol = _palmProbeGo.AddComponent<SphereCollider>();
				((Collider)_palmProbeCol).isTrigger = true;
				_palmProbeCol.radius = 0.045f;
			}
		}

		private static TMP_Text Create3DText(Transform parent, string name, Vector3 localPos, float fontSize, Vector2 sizeDelta, string initialText, Vector3? parentScaleOpt = null)
		{
			//IL_0016: 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_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			//IL_0040: 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_0066: 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_0092: 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_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: 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_011a: 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_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: 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_00c7: 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)
			try
			{
				Vector3 val = (Vector3)(((??)parentScaleOpt) ?? Vector3.one);
				GameObject val2 = new GameObject("QL_LCK_Canvas_" + name);
				val2.transform.SetParent(parent, false);
				val2.transform.localPosition = localPos;
				val2.transform.localRotation = Quaternion.identity;
				val2.transform.localScale = new Vector3(0.001f / Mathf.Max(0.0005f, val.x), 0.001f / Mathf.Max(0.0005f, val.y), 0.001f / Mathf.Max(0.0005f, val.z));
				Canvas val3 = val2.AddComponent<Canvas>();
				val3.renderMode = (RenderMode)2;
				RectTransform component = val2.GetComponent<RectTransform>();
				if ((Object)(object)component != (Object)null)
				{
					component.sizeDelta = sizeDelta * 1000f;
				}
				GameObject val4 = new GameObject("QL_LCK_Txt_" + name);
				val4.transform.SetParent(val2.transform, false);
				val4.transform.localPosition = Vector3.zero;
				val4.transform.localRotation = Quaternion.identity;
				val4.transform.localScale = Vector3.one;
				TextMeshProUGUI obj = val4.AddComponent<TextMeshProUGUI>();
				((Graphic)obj).raycastTarget = false;
				((TMP_Text)obj).alignment = (TextAlignmentOptions)514;
				((TMP_Text)obj).fontSize = fontSize * 100f;
				((TMP_Text)obj).enableWordWrapping = false;
				((TMP_Text)obj).richText = true;
				((Graphic)obj).color = Color.white;
				((TMP_Text)obj).outlineWidth = 0.2f;
				((TMP_Text)obj).outlineColor = new Color32((byte)0, (byte)0, (byte)0, byte.MaxValue);
				((TMP_Text)obj).rectTransform.sizeDelta = sizeDelta * 1000f;
				((TMP_Text)obj).text = initialText;
				_tabletCanvases.Add(val3);
				return (TMP_Text)(object)obj;
			}
			catch
			{
				return null;
			}
		}

		private static TouchButton AddTouchButton(Transform parent, string id, string labelText, Vector3 localPos, Vector3 size, float fontSize, Color color, Action onPress)
		{
			//IL_0010: 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_001c: 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_0062: 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_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: 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_00ed: 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_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: 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_010f: Unknown result type (might be due to invalid IL or missing references)
			Material mat = MakeSolidMat(LumenShaderBank.LckScreenShader, "QL_" + id, color, emissiveFlat: false);
			GameObject val = AddBox(parent, id, localPos, size, mat);
			BoxCollider val2 = val.AddComponent<BoxCollider>();
			((Collider)val2).isTrigger = true;
			val2.center = new Vector3(0f, 0f, -0.3f);
			val2.size = new Vector3(1f, 1f, 0.022f / Mathf.Max(0.001f, size.z));
			TMP_Text label = Create3DText(val.transform, id + "_Lbl", new Vector3(0f, 0f, -0.56f), fontSize, new Vector2(size.x * 0.96f, size.y * 0.92f), labelText, size);
			TouchButton touchButton = new TouchButton
			{
				Id = id,
				CapTrans = val.transform,
				TriggerCollider = val2,
				BaseLocalPos = localPos,
				HalfExtents = size * 0.5f,
				Mat = mat,
				BaseColor = color,
				Label = label,
				OnPress = onPress
			};
			_buttons.Add(touchButton);
			return touchButton;
		}

		public static void RefreshButtonVisuals()
		{
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: 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_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: 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_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0314: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_tabletRoot == (Object)null)
			{
				return;
			}
			if ((Object)(object)_activeTabBorder != (Object)null)
			{
				float num = CurrentMode switch
				{
					LckCameraMode.Selfie => -0.125f, 
					LckCameraMode.FirstPerson => -0.045f, 
					_ => 0.036f, 
				};
				float num2 = ((CurrentMode == LckCameraMode.Selfie) ? 0.079f : 0.083f);
				_activeTabBorder.localPosition = new Vector3(num, 0.082f, -0.0072f);
				_activeTabBorder.localScale = new Vector3(num2, 0.039f, 0.002f);
			}
			if ((Object)(object)_fovValueTmp != (Object)null)
			{
				_fovValueTmp.text = $"{Mathf.RoundToInt(LumenPreferences.LckFov.Value)}";
			}
			if ((Object)(object)_smoothValueTmp != (Object)null)
			{
				_smoothValueTmp.text = $"{LumenPreferences.LckSmoothing.Value}";
			}
			if (_btnMic != null)
			{
				bool value = LumenPreferences.LckRecordMic.Value;
				Color val = (value ? new Color(0.14f, 0.62f, 0.34f) : new Color(0.22f, 0.23f, 0.26f));
				_btnMic.BaseColor = val;
				Material mat = _btnMic.Mat;
				if (mat != null)
				{
					mat.SetColor(IdBaseColor, val);
				}
				if ((Object)(object)_btnMic.Label != (Object)null)
				{
					_btnMic.Label.text = (value ? "MIC ON" : "MIC OFF");
				}
			}
			if (_btnAspect != null && (Object)(object)_btnAspect.Label != (Object)null)
			{
				_btnAspect.Label.text = (IsPortrait ? "9:16" : "16:9");
			}
			bool isRecording = LumenMediaRecorder.IsRecording;
			if (_btnRecord != null)
			{
				Color val2 = (isRecording ? new Color(0.85f, 0.14f, 0.14f) : new Color(0.24f, 0.25f, 0.29f));
				_btnRecord.BaseColor = val2;
				Material mat2 = _btnRecord.Mat;
				if (mat2 != null)
				{
					mat2.SetColor(IdBaseColor, val2);
				}
				if ((Object)(object)_btnRecord.Label != (Object)null)
				{
					_btnRecord.Label.text = (isRecording ? "STOP" : "RECORD");
				}
			}
			if ((Object)(object)_matRearTallyLed != (Object)null)
			{
				_matRearTallyLed.SetColor(IdBaseColor, isRecording ? new Color(1f, 0.12f, 0.12f) : new Color(0.18f, 0.85f, 0.45f));
			}
			if ((Object)(object)_matScreen != (Object)null)
			{
				bool flag = CurrentMode == LckCameraMode.Selfie && !IsFlipped;
				_matScreen.SetVector(IdScreenParams2, new Vector4(1f, IsPortrait ? 1f : 0f, flag ? 1f : 0f, _shutterFlash));
			}
		}

		public static void OnUpdate()
		{
			if (!LumenPreferences.IsQuestDevice)
			{
				return;
			}
			LumenMediaRecorder.Tick();
			if (IsSpawned && !((Object)(object)Player.Head == (Object)null) && !((Object)(object)_lensCam == (Object)null))
			{
				if (!_stereoSynced && LumenShaderBank.IsHeadsetStereoActive)
				{
					SyncStereoMaterials();
					_stereoSynced = true;
				}
				float dt = Mathf.Clamp(Time.unscaledDeltaTime, 0.001f, 0.1f);
				float realtimeSinceStartup = Time.realtimeSinceStartup;
				UpdateVrHandleGrabbing();
				AnimateButtonSpringBack(dt);
				UpdateLensCameraPose(dt);
				UpdateHudAndFlash(dt);
				RenderScheduledCameraPasses(realtimeSinceStartup);
			}
		}

		public static void OnLateUpdate()
		{
			if (LumenPreferences.IsQuestDevice && IsSpawned && !((Object)(object)Player.Head == (Object)null))
			{
				EnsureFingerTipTriggersBuilt();
				UpdateFingerTipButtonTriggers(Time.realtimeSinceStartup);
			}
		}

		private static void SyncStereoMaterials()
		{
			LumenShaderBank.ConfigureStereoKeywords(_matChassis, stereo: true);
			LumenShaderBank.ConfigureStereoKeywords(_matHandle, stereo: true);
			LumenShaderBank.ConfigureStereoKeywords(_matScreen, stereo: true);
			LumenShaderBank.ConfigureStereoKeywords(_matWhiteBorder, stereo: true);
			LumenShaderBank.ConfigureStereoKeywords(_matRearTallyLed, stereo: true);
			for (int i = 0; i < _buttons.Count; i++)
			{
				LumenShaderBank.ConfigureStereoKeywords(_buttons[i].Mat, stereo: true);
			}
		}

		private static void UpdateVrHandleGrabbing()
		{
			//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0400: Unknown result type (might be due to invalid IL or missing references)
			//IL_0405: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: 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_0269: 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_02da: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e8: 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_02ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: 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_0301: Unknown result type (might be due to invalid IL or missing references)
			//IL_0306: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//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_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_02c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c9: 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_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_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0324: Unknown result type (might be due to invalid IL or missing references)
			//IL_033e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0340: 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_034a: Unknown result type (might be due to invalid IL or missing references)
			//IL_034f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0351: Unknown result type (might be due to invalid IL or missing references)
			//IL_0353: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_035f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0364: Unknown result type (might be due to invalid IL or missing references)
			//IL_0370: Unknown result type (might be due to invalid IL or missing references)
			//IL_0372: Unknown result type (might be due to invalid IL or missing references)
			//IL_032d: 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_0339: Unknown result type (might be due to invalid IL or missing references)
			BaseController leftController = Player.LeftController;
			BaseController rightController = Player.RightController;
			Hand leftHand = Player.LeftHand;
			Hand rightHand = Player.RightHand;
			bool flag = (Object)(object)leftController != (Object)null && (leftController.GetGripForce() > 0.62f || leftController.IsGrabbed());
			bool flag2 = (Object)(object)rightController != (Object)null && (rightController.GetGripForce() > 0.62f || rightController.IsGrabbed());
			if (_holdingLeft && (!flag || (Object)(object)leftHand == (Object)null))
			{
				_holdingLeft = false;
				if (_holdingRight && (Object)(object)rightHand != (Object)null)
				{
					CaptureSingleHandOffset(isLeft: false, ((Component)rightHand).transform);
				}
			}
			if (_holdingRight && (!flag2 || (Object)(object)rightHand == (Object)null))
			{
				_holdingRight = false;
				if (_holdingLeft && (Object)(object)leftHand != (Object)null)
				{
					CaptureSingleHandOffset(isLeft: true, ((Component)leftHand).transform);
				}
			}
			if (!_holdingLeft && flag && !_prevLeftGrip && (Object)(object)leftHand != (Object)null && !leftHand.HasAttachedObject() && IsHandInGrabZone(((Component)leftHand).transform.position))
			{
				_holdingLeft = true;
				CaptureSingleHandOffset(isLeft: true, ((Component)leftHand).transform);
				try
				{
					if (leftController != null)
					{
						leftController.HapticAction(0f, 0.04f, 140f, 0.45f);
					}
				}
				catch
				{
				}
			}
			if (!_holdingRight && flag2 && !_prevRightGrip && (Object)(object)rightHand != (Object)null && !rightHand.HasAttachedObject() && IsHandInGrabZone(((Component)rightHand).transform.position))
			{
				_holdingRight = true;
				CaptureSingleHandOffset(isLeft: false, ((Component)rightHand).transform);
				try
				{
					if (rightController != null)
					{
						rightController.HapticAction(0f, 0.04f, 140f, 0.45f);
					}
				}
				catch
				{
				}
			}
			_prevLeftGrip = flag;
			_prevRightGrip = flag2;
			if (_holdingLeft && _holdingRight && (Object)(object)leftHand != (Object)null && (Object)(object)rightHand != (Object)null)
			{
				Vector3 position = ((Component)leftHand).transform.position;
				Vector3 position2 = ((Component)rightHand).transform.position;
				Vector3 val = (position + position2) * 0.5f;
				Vector3 val2 = position2 - position;
				if (((Vector3)(ref val2)).sqrMagnitude < 0.0004f)
				{
					val2 = _tabletRoot.transform.right;
				}
				else
				{
					((Vector3)(ref val2)).Normalize();
				}
				Vector3 val3 = ((Component)leftHand).transform.up + ((Component)rightHand).transform.up;
				if (((Vector3)(ref val3)).sqrMagnitude < 0.001f)
				{
					val3 = Vector3.up;
				}
				((Vector3)(ref val3)).Normalize();
				if (!_wasTwoHanded)
				{
					_wasTwoHanded = true;
					_twoHandBaseTabletRot = _tabletRoot.transform.rotation;
					_twoHandBaseAxis = val2;
					_twoHandBaseUp = val3;
					_twoHandMidLocalOffset = Quaternion.Inverse(_tabletRoot.transform.rotation) * (_tabletRoot.transform.position - val);
				}
				Quaternion val4 = Quaternion.FromToRotation(_twoHandBaseAxis, val2);
				Vector3 val5 = Vector3.ProjectOnPlane(val4 * _twoHandBaseUp, val2);
				Vector3 val6 = Vector3.ProjectOnPlane(val3, val2);
				Quaternion val7 = ((((Vector3)(ref val5)).sqrMagnitude > 0.001f && ((Vector3)(ref val6)).sqrMagnitude > 0.001f) ? Quaternion.FromToRotation(((Vector3)(ref val5)).normalized, ((Vector3)(ref val6)).normalized) : Quaternion.identity) * val4 * _twoHandBaseTabletRot;
				Vector3 val8 = val + val7 * _twoHandMidLocalOffset;
				_tabletRoot.transform.SetPositionAndRotation(val8, val7);
			}
			else if (_holdingLeft && (Object)(object)leftHand != (Object)null)
			{
				_wasTwoHanded = false;
				Transform transform = ((Component)leftHand).transform;
				_tabletRoot.transform.SetPositionAndRotation(transform.TransformPoint(_leftGrabLocalPos), transform.rotation * _leftGrabLocalRot);
			}
			else if (_holdingRight && (Object)(object)rightHand != (Object)null)
			{
				_wasTwoHanded = false;
				Transform transform2 = ((Component)rightHand).transform;
				_tabletRoot.transform.SetPositionAndRotation(transform2.TransformPoint(_rightGrabLocalPos), transform2.rotation * _rightGrabLocalRot);
			}
			else
			{
				_wasTwoHanded = false;
			}
		}

		private static void CaptureSingleHandOffset(bool isLeft, Transform handTrans)
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_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: 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_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			if (isLeft)
			{
				_leftGrabLocalPos = handTrans.InverseTransformPoint(_tabletRoot.transform.position);
				_leftGrabLocalRot = Quaternion.Inverse(handTrans.rotation) * _tabletRoot.transform.rotation;
			}
			else
			{
				_rightGrabLocalPos = handTrans.InverseTransformPoint(_tabletRoot.transform.position