Decompiled source of Meats NewPressurePads v2.0.0

Meats_NewPressurePads.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using AndrewFTW;
using BepInEx;
using BepInEx.Logging;
using FistVR;
using HarmonyLib;
using ModularWorkshop;
using OtherLoader;
using UnityEngine;

[assembly: Debuggable(DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace PressurePadAttachment
{
	public class PressurePadAttachmentInterface : FVRFireArmAttachmentInterface
	{
		[Header("Pressure Pad Attachment Config")]
		public float DoubleTapWaitTime = 0.333f;

		private bool _isLightToggle = false;

		private bool _isLaserToggle = false;

		private FVRAlternateGrip _altGrip;

		private bool _wasAltGripGrabbed = false;

		private float _timeWaited = 0f;

		private bool _waitingForDoubleTap = false;

		private bool _irActive = false;

		private bool _strobeActive = false;

		private readonly List<TacticalFlashlight> _flashlights = new List<TacticalFlashlight>();

		private readonly List<LaserPointer> _lasers = new List<LaserPointer>();

		private readonly List<LaserLightAttachment> _laserLights = new List<LaserLightAttachment>();

		private List<AdvancedLaserController> _advancedLaserControllers = new List<AdvancedLaserController>();

		private Dictionary<AdvancedLaserController, List<int>> _advancedLights = new Dictionary<AdvancedLaserController, List<int>>();

		private Dictionary<AdvancedLaserController, List<int>> _advancedLasers = new Dictionary<AdvancedLaserController, List<int>>();

		private Dictionary<AdvancedLaserController, List<int>> _advancedIRLights = new Dictionary<AdvancedLaserController, List<int>>();

		private Dictionary<AdvancedLaserController, List<int>> _advancedIRLasers = new Dictionary<AdvancedLaserController, List<int>>();

		private Dictionary<AdvancedLaserController, List<int>> _advancedStrobes = new Dictionary<AdvancedLaserController, List<int>>();

		private static Dictionary<FVRAlternateGrip, PressurePadAttachmentInterface> _existingPressurePadAttachments;

		private static readonly IntPtr _baseUpdateInteractionPointer;

		private static readonly FieldInfo _advancedLasersCurrentEmmitterIndexFieldInfo;

		static PressurePadAttachmentInterface()
		{
			_existingPressurePadAttachments = new Dictionary<FVRAlternateGrip, PressurePadAttachmentInterface>();
			Harmony.CreateAndPatchAll(typeof(PressurePadAttachmentInterface), (string)null);
			_baseUpdateInteractionPointer = typeof(FVRAlternateGrip).BaseType.GetMethod("UpdateInteraction").MethodHandle.GetFunctionPointer();
			_advancedLasersCurrentEmmitterIndexFieldInfo = typeof(AdvancedLaserController).GetField("_currentEmitterIndex", BindingFlags.Instance | BindingFlags.NonPublic);
		}

		public override void OnDestroy()
		{
			((FVRInteractiveObject)this).OnDestroy();
			if ((Object)(object)_altGrip != (Object)null)
			{
				_existingPressurePadAttachments.Remove(_altGrip);
			}
		}

		public override void OnAttach()
		{
			((FVRFireArmAttachmentInterface)this).OnAttach();
			if ((Object)(object)base.Attachment.curMount != (Object)null && base.Attachment.curMount.GetRootMount().MyObject is FVRFireArm)
			{
				FVRPhysicalObject myObject = base.Attachment.curMount.GetRootMount().MyObject;
				if ((Object)(object)((FVRFireArm)((myObject is FVRFireArm) ? myObject : null)).Foregrip != (Object)null)
				{
					ref FVRAlternateGrip altGrip = ref _altGrip;
					FVRPhysicalObject myObject2 = base.Attachment.curMount.GetRootMount().MyObject;
					altGrip = ((FVRFireArm)((myObject2 is FVRFireArm) ? myObject2 : null)).Foregrip.GetComponent<FVRAlternateGrip>();
				}
				else
				{
					_altGrip = ((Component)base.Attachment.curMount.GetRootMount().MyObject).GetComponentInChildren<FVRAlternateGrip>(true);
				}
			}
		}

		public override void OnDetach()
		{
			if ((Object)(object)_altGrip != (Object)null)
			{
				_existingPressurePadAttachments.Remove(_altGrip);
				_altGrip = null;
			}
			ToggleLights(on: false);
			ToggleLasers(on: false);
			((FVRFireArmAttachmentInterface)this).OnDetach();
		}

		public override void FVRUpdate()
		{
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_0326: Unknown result type (might be due to invalid IL or missing references)
			//IL_032b: Unknown result type (might be due to invalid IL or missing references)
			((FVRInteractiveObject)this).FVRUpdate();
			if (!((Object)(object)_altGrip != (Object)null))
			{
				return;
			}
			if (!_existingPressurePadAttachments.ContainsKey(_altGrip))
			{
				_existingPressurePadAttachments.Add(_altGrip, this);
			}
			FVRViveHand hand = ((FVRInteractiveObject)_altGrip).m_hand;
			if (!_wasAltGripGrabbed && (Object)(object)hand != (Object)null)
			{
				_wasAltGripGrabbed = true;
				CreateDictionaries();
			}
			else if (_wasAltGripGrabbed && (Object)(object)hand == (Object)null)
			{
				_wasAltGripGrabbed = false;
			}
			if (!((Object)(object)hand != (Object)null))
			{
				return;
			}
			if (!hand.IsInStreamlinedMode)
			{
				if (hand.Input.TouchpadDown && Vector2.Angle(hand.Input.TouchpadAxes, Vector2.up) < 45f)
				{
					if (!_waitingForDoubleTap)
					{
						((MonoBehaviour)this).StartCoroutine(WaitForDoubleTap(up: true));
					}
				}
				else if (hand.Input.TouchpadDown && Vector2.Angle(hand.Input.TouchpadAxes, Vector2.down) < 45f && !_waitingForDoubleTap)
				{
					((MonoBehaviour)this).StartCoroutine(WaitForDoubleTap(up: false));
				}
			}
			else if (hand.Input.BYButtonDown)
			{
				if (!_waitingForDoubleTap)
				{
					((MonoBehaviour)this).StartCoroutine(WaitForDoubleTap(up: true));
				}
			}
			else if (hand.Input.AXButtonDown && !_waitingForDoubleTap)
			{
				((MonoBehaviour)this).StartCoroutine(WaitForDoubleTap(up: false));
			}
			if (hand.Input.TouchpadDown && Vector2.Angle(hand.Input.TouchpadAxes, Vector2.left) < 45f)
			{
				ToggleLights(on: false);
				ToggleLasers(on: false);
				_irActive = !_irActive;
				ToggleLights(_isLightToggle);
				ToggleLasers(_isLaserToggle);
			}
			else if (hand.Input.TouchpadDown && Vector2.Angle(hand.Input.TouchpadAxes, Vector2.right) < 45f)
			{
				ToggleStrobe();
			}
			if (!hand.IsInStreamlinedMode)
			{
				if (hand.Input.TouchpadPressed && Vector2.Angle(hand.Input.TouchpadAxes, Vector2.up) < 45f)
				{
					ToggleLights(on: true);
				}
				else if (hand.Input.TouchpadUp && !_isLightToggle)
				{
					ToggleLights(on: false);
				}
			}
			else if (hand.Input.BYButtonPressed)
			{
				ToggleLights(on: true);
			}
			else if (hand.Input.BYButtonUp && !_isLightToggle)
			{
				ToggleLights(on: false);
			}
			if (!hand.IsInStreamlinedMode)
			{
				if (hand.Input.TouchpadPressed && Vector2.Angle(hand.Input.TouchpadAxes, Vector2.down) < 45f)
				{
					ToggleLasers(on: true);
				}
				else if (hand.Input.TouchpadUp && !_isLaserToggle)
				{
					ToggleLasers(on: false);
				}
			}
			else if (hand.Input.AXButtonPressed)
			{
				ToggleLasers(on: true);
			}
			else if (hand.Input.AXButtonUp && !_isLaserToggle)
			{
				ToggleLasers(on: false);
			}
		}

		public override void UpdateInteraction(FVRViveHand hand)
		{
			//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_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			((FVRFireArmAttachmentInterface)this).UpdateInteraction(hand);
			if (hand.Input.TouchpadDown && Vector2.Angle(hand.Input.TouchpadAxes, Vector2.left) < 45f)
			{
				ToggleLights(on: false);
				ToggleLasers(on: false);
				_irActive = !_irActive;
				ToggleLights(_isLightToggle);
				ToggleLasers(_isLaserToggle);
			}
			else if (hand.Input.TouchpadDown && Vector2.Angle(hand.Input.TouchpadAxes, Vector2.right) < 45f)
			{
				ToggleStrobe();
			}
		}

		public void CreateDictionaries()
		{
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Expected O, but got Unknown
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Expected O, but got Unknown
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Expected O, but got Unknown
			//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ff: Invalid comparison between Unknown and I4
			//IL_030d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0313: Invalid comparison between Unknown and I4
			//IL_0371: Unknown result type (might be due to invalid IL or missing references)
			//IL_0377: Invalid comparison between Unknown and I4
			//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03db: Invalid comparison between Unknown and I4
			//IL_0439: Unknown result type (might be due to invalid IL or missing references)
			//IL_043f: Invalid comparison between Unknown and I4
			//IL_049d: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a3: Invalid comparison between Unknown and I4
			foreach (KeyValuePair<AdvancedLaserController, List<int>> advancedLight in _advancedLights)
			{
				advancedLight.Value.Clear();
			}
			foreach (KeyValuePair<AdvancedLaserController, List<int>> advancedLaser in _advancedLasers)
			{
				advancedLaser.Value.Clear();
			}
			foreach (KeyValuePair<AdvancedLaserController, List<int>> advancedIRLight in _advancedIRLights)
			{
				advancedIRLight.Value.Clear();
			}
			foreach (KeyValuePair<AdvancedLaserController, List<int>> advancedIRLaser in _advancedIRLasers)
			{
				advancedIRLaser.Value.Clear();
			}
			foreach (KeyValuePair<AdvancedLaserController, List<int>> advancedStrobe in _advancedStrobes)
			{
				advancedStrobe.Value.Clear();
			}
			_flashlights.Clear();
			_lasers.Clear();
			_laserLights.Clear();
			_advancedLaserControllers.Clear();
			_advancedLights.Clear();
			_advancedLasers.Clear();
			_advancedIRLights.Clear();
			_advancedIRLasers.Clear();
			_advancedStrobes.Clear();
			foreach (FVRFireArmAttachment attachments in base.Attachment.curMount.GetRootMount().MyObject.AttachmentsList)
			{
				if (attachments.AttachmentInterface is TacticalFlashlight)
				{
					_flashlights.Add((TacticalFlashlight)attachments.AttachmentInterface);
					continue;
				}
				if (attachments.AttachmentInterface is LaserPointer)
				{
					_lasers.Add((LaserPointer)attachments.AttachmentInterface);
					continue;
				}
				if (attachments.AttachmentInterface is LaserLightAttachment)
				{
					_laserLights.Add((LaserLightAttachment)attachments.AttachmentInterface);
					continue;
				}
				AdvancedLaserController componentInChildren = ((Component)attachments).GetComponentInChildren<AdvancedLaserController>();
				if ((Object)(object)componentInChildren != (Object)null)
				{
					_advancedLaserControllers.Add(componentInChildren);
				}
			}
			foreach (AdvancedLaserController advancedLaserController in _advancedLaserControllers)
			{
				for (int i = 0; i < advancedLaserController.ListOfEmitterObjects.Count; i++)
				{
					List<int> value;
					if ((int)advancedLaserController.ListOfEmitterTypes[i] == 1 || (int)advancedLaserController.ListOfEmitterTypes[i] == 6)
					{
						if (_advancedLasers.TryGetValue(advancedLaserController, out value))
						{
							value.Add(i);
							continue;
						}
						List<int> list = new List<int>();
						list.Add(i);
						value = list;
						_advancedLasers.Add(advancedLaserController, value);
					}
					else if ((int)advancedLaserController.ListOfEmitterTypes[i] == 3)
					{
						if (_advancedLights.TryGetValue(advancedLaserController, out value))
						{
							value.Add(i);
							continue;
						}
						List<int> list = new List<int>();
						list.Add(i);
						value = list;
						_advancedLights.Add(advancedLaserController, value);
					}
					else if ((int)advancedLaserController.ListOfEmitterTypes[i] == 2)
					{
						if (_advancedIRLasers.TryGetValue(advancedLaserController, out value))
						{
							value.Add(i);
							continue;
						}
						List<int> list = new List<int>();
						list.Add(i);
						value = list;
						_advancedIRLasers.Add(advancedLaserController, value);
					}
					else if ((int)advancedLaserController.ListOfEmitterTypes[i] == 4)
					{
						if (_advancedIRLights.TryGetValue(advancedLaserController, out value))
						{
							value.Add(i);
							continue;
						}
						List<int> list = new List<int>();
						list.Add(i);
						value = list;
						_advancedIRLights.Add(advancedLaserController, value);
					}
					else if ((int)advancedLaserController.ListOfEmitterTypes[i] == 5)
					{
						if (_advancedStrobes.TryGetValue(advancedLaserController, out value))
						{
							value.Add(i);
							continue;
						}
						List<int> list = new List<int>();
						list.Add(i);
						value = list;
						_advancedStrobes.Add(advancedLaserController, value);
					}
				}
			}
		}

		public void ToggleLights(bool on)
		{
			foreach (LaserLightAttachment laserLight in _laserLights)
			{
				if ((Object)(object)laserLight.Light != (Object)null)
				{
					int num = FindCorrectLaserLightSettingsIndex(laserLight, _isLaserToggle, on, _irActive);
					if (num != -1)
					{
						laserLight.SettingsIndex = num;
						laserLight.UpdateParams();
					}
				}
			}
			if (on)
			{
				if (!_irActive)
				{
					foreach (TacticalFlashlight flashlight in _flashlights)
					{
						if (!flashlight.IsOn)
						{
							flashlight.ToggleOn();
						}
					}
					{
						foreach (KeyValuePair<AdvancedLaserController, List<int>> advancedLight in _advancedLights)
						{
							foreach (int item in advancedLight.Value)
							{
								int num2 = (int)_advancedLasersCurrentEmmitterIndexFieldInfo.GetValue(advancedLight.Key);
								_advancedLasersCurrentEmmitterIndexFieldInfo.SetValue(advancedLight.Key, item);
								advancedLight.Key.ToggleRight();
								_advancedLasersCurrentEmmitterIndexFieldInfo.SetValue(advancedLight.Key, num2);
							}
						}
						return;
					}
				}
				{
					foreach (KeyValuePair<AdvancedLaserController, List<int>> advancedIRLight in _advancedIRLights)
					{
						foreach (int item2 in advancedIRLight.Value)
						{
							int num3 = (int)_advancedLasersCurrentEmmitterIndexFieldInfo.GetValue(advancedIRLight.Key);
							_advancedLasersCurrentEmmitterIndexFieldInfo.SetValue(advancedIRLight.Key, item2);
							advancedIRLight.Key.ToggleRight();
							_advancedLasersCurrentEmmitterIndexFieldInfo.SetValue(advancedIRLight.Key, num3);
						}
					}
					return;
				}
			}
			foreach (TacticalFlashlight flashlight2 in _flashlights)
			{
				if (flashlight2.IsOn)
				{
					flashlight2.ToggleOn();
				}
			}
			foreach (KeyValuePair<AdvancedLaserController, List<int>> advancedLight2 in _advancedLights)
			{
				foreach (int item3 in advancedLight2.Value)
				{
					int num4 = (int)_advancedLasersCurrentEmmitterIndexFieldInfo.GetValue(advancedLight2.Key);
					_advancedLasersCurrentEmmitterIndexFieldInfo.SetValue(advancedLight2.Key, item3);
					advancedLight2.Key.ToggleLeft();
					_advancedLasersCurrentEmmitterIndexFieldInfo.SetValue(advancedLight2.Key, num4);
				}
			}
			foreach (KeyValuePair<AdvancedLaserController, List<int>> advancedIRLight2 in _advancedIRLights)
			{
				foreach (int item4 in advancedIRLight2.Value)
				{
					int num5 = (int)_advancedLasersCurrentEmmitterIndexFieldInfo.GetValue(advancedIRLight2.Key);
					_advancedLasersCurrentEmmitterIndexFieldInfo.SetValue(advancedIRLight2.Key, item4);
					advancedIRLight2.Key.ToggleLeft();
					_advancedLasersCurrentEmmitterIndexFieldInfo.SetValue(advancedIRLight2.Key, num5);
				}
			}
		}

		public void ToggleLasers(bool on)
		{
			foreach (LaserLightAttachment laserLight in _laserLights)
			{
				if ((Object)(object)laserLight.LL != (Object)null)
				{
					int num = FindCorrectLaserLightSettingsIndex(laserLight, on, _isLightToggle, _irActive);
					if (num != -1)
					{
						laserLight.SettingsIndex = num;
						laserLight.UpdateParams();
					}
				}
			}
			if (on)
			{
				if (!_irActive)
				{
					foreach (LaserPointer laser in _lasers)
					{
						if (!laser.IsOn)
						{
							laser.ToggleOn();
						}
					}
					{
						foreach (KeyValuePair<AdvancedLaserController, List<int>> advancedLaser in _advancedLasers)
						{
							foreach (int item in advancedLaser.Value)
							{
								int num2 = (int)_advancedLasersCurrentEmmitterIndexFieldInfo.GetValue(advancedLaser.Key);
								_advancedLasersCurrentEmmitterIndexFieldInfo.SetValue(advancedLaser.Key, item);
								advancedLaser.Key.ToggleRight();
								_advancedLasersCurrentEmmitterIndexFieldInfo.SetValue(advancedLaser.Key, num2);
							}
						}
						return;
					}
				}
				{
					foreach (KeyValuePair<AdvancedLaserController, List<int>> advancedIRLaser in _advancedIRLasers)
					{
						foreach (int item2 in advancedIRLaser.Value)
						{
							int num3 = (int)_advancedLasersCurrentEmmitterIndexFieldInfo.GetValue(advancedIRLaser.Key);
							_advancedLasersCurrentEmmitterIndexFieldInfo.SetValue(advancedIRLaser.Key, item2);
							advancedIRLaser.Key.ToggleRight();
							_advancedLasersCurrentEmmitterIndexFieldInfo.SetValue(advancedIRLaser.Key, num3);
						}
					}
					return;
				}
			}
			foreach (LaserPointer laser2 in _lasers)
			{
				if (laser2.IsOn)
				{
					laser2.ToggleOn();
				}
			}
			foreach (KeyValuePair<AdvancedLaserController, List<int>> advancedLaser2 in _advancedLasers)
			{
				foreach (int item3 in advancedLaser2.Value)
				{
					int num4 = (int)_advancedLasersCurrentEmmitterIndexFieldInfo.GetValue(advancedLaser2.Key);
					_advancedLasersCurrentEmmitterIndexFieldInfo.SetValue(advancedLaser2.Key, item3);
					advancedLaser2.Key.ToggleLeft();
					_advancedLasersCurrentEmmitterIndexFieldInfo.SetValue(advancedLaser2.Key, num4);
				}
			}
			foreach (KeyValuePair<AdvancedLaserController, List<int>> advancedIRLaser2 in _advancedIRLasers)
			{
				foreach (int item4 in advancedIRLaser2.Value)
				{
					int num5 = (int)_advancedLasersCurrentEmmitterIndexFieldInfo.GetValue(advancedIRLaser2.Key);
					_advancedLasersCurrentEmmitterIndexFieldInfo.SetValue(advancedIRLaser2.Key, item4);
					advancedIRLaser2.Key.ToggleLeft();
					_advancedLasersCurrentEmmitterIndexFieldInfo.SetValue(advancedIRLaser2.Key, num5);
				}
			}
		}

		public void ToggleStrobe()
		{
			_strobeActive = !_strobeActive;
			foreach (KeyValuePair<AdvancedLaserController, List<int>> advancedStrobe in _advancedStrobes)
			{
				foreach (int item in advancedStrobe.Value)
				{
					int num = (int)_advancedLasersCurrentEmmitterIndexFieldInfo.GetValue(advancedStrobe.Key);
					_advancedLasersCurrentEmmitterIndexFieldInfo.SetValue(advancedStrobe.Key, item);
					if (_strobeActive)
					{
						advancedStrobe.Key.ToggleRight();
					}
					else
					{
						advancedStrobe.Key.ToggleLeft();
					}
					_advancedLasersCurrentEmmitterIndexFieldInfo.SetValue(advancedStrobe.Key, num);
				}
			}
		}

		private IEnumerator WaitForDoubleTap(bool up)
		{
			yield return null;
			_timeWaited = 0f;
			_waitingForDoubleTap = true;
			FVRViveHand hand = ((FVRInteractiveObject)_altGrip).m_hand;
			while (_timeWaited < DoubleTapWaitTime)
			{
				_timeWaited += Time.deltaTime;
				if (!hand.IsInStreamlinedMode)
				{
					if (up && hand.Input.TouchpadDown && Vector2.Angle(hand.Input.TouchpadAxes, Vector2.up) < 45f)
					{
						_isLightToggle = !_isLightToggle;
						break;
					}
					if (!up && hand.Input.TouchpadDown && Vector2.Angle(hand.Input.TouchpadAxes, Vector2.down) < 45f)
					{
						_isLaserToggle = !_isLaserToggle;
						break;
					}
				}
				else
				{
					if (up && hand.Input.BYButtonDown)
					{
						_isLightToggle = !_isLightToggle;
						break;
					}
					if (!up && hand.Input.AXButtonDown)
					{
						_isLaserToggle = !_isLaserToggle;
						break;
					}
				}
				yield return null;
			}
			_waitingForDoubleTap = false;
		}

		private int FindCorrectLaserLightSettingsIndex(LaserLightAttachment laserLight, bool laserOn, bool lightOn, bool IROn)
		{
			int result = -1;
			LaserLightSetting val = laserLight.Settings[laserLight.SettingsIndex];
			if (!laserOn && !lightOn)
			{
				result = laserLight.Settings.FindIndex((LaserLightSetting x) => (int)x.LaserMode == 0 && (int)x.LightMode == 0);
			}
			else if (laserOn && lightOn && !IROn)
			{
				result = laserLight.Settings.FindIndex((LaserLightSetting x) => (int)x.LaserMode == 1 && (int)x.LightMode == 1);
			}
			else if (laserOn && lightOn && IROn)
			{
				result = laserLight.Settings.FindIndex((LaserLightSetting x) => (int)x.LaserMode == 2 && (int)x.LightMode == 3);
			}
			else if (laserOn && !lightOn && !IROn)
			{
				result = laserLight.Settings.FindIndex((LaserLightSetting x) => (int)x.LaserMode == 1 && (int)x.LightMode == 0);
			}
			else if (!laserOn && lightOn && !IROn)
			{
				result = laserLight.Settings.FindIndex((LaserLightSetting x) => (int)x.LaserMode == 0 && (int)x.LightMode == 1);
			}
			else if (laserOn && !lightOn && IROn)
			{
				result = laserLight.Settings.FindIndex((LaserLightSetting x) => (int)x.LaserMode == 2 && (int)x.LightMode == 0);
			}
			else if (!laserOn && lightOn && IROn)
			{
				result = laserLight.Settings.FindIndex((LaserLightSetting x) => (int)x.LaserMode == 0 && (int)x.LightMode == 3);
			}
			else if (laserOn && lightOn && !IROn)
			{
				result = laserLight.Settings.FindIndex((LaserLightSetting x) => (int)x.LaserMode == 1 && (int)x.LightMode == 0);
			}
			else if (laserOn && lightOn && !IROn)
			{
				result = laserLight.Settings.FindIndex((LaserLightSetting x) => (int)x.LaserMode == 0 && (int)x.LightMode == 1);
			}
			else if (laserOn && lightOn && IROn)
			{
				result = laserLight.Settings.FindIndex((LaserLightSetting x) => (int)x.LaserMode == 2 && (int)x.LightMode == 0);
			}
			else if (laserOn && lightOn && IROn)
			{
				result = laserLight.Settings.FindIndex((LaserLightSetting x) => (int)x.LaserMode == 0 && (int)x.LightMode == 3);
			}
			return result;
		}

		[HarmonyPatch(typeof(FVRAlternateGrip), "UpdateInteraction")]
		[HarmonyPrefix]
		public static bool AltGripUpdateInteractionPatch(FVRAlternateGrip __instance, FVRViveHand hand)
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			if (_existingPressurePadAttachments.ContainsKey(__instance))
			{
				Action<FVRViveHand> action = (Action<FVRViveHand>)Activator.CreateInstance(typeof(Action<FVRViveHand>), __instance, _baseUpdateInteractionPointer);
				action(hand);
				Vector2 touchpadAxes = hand.Input.TouchpadAxes;
				bool flag = true;
				if (!__instance.DoesBracing)
				{
					flag = false;
				}
				if (__instance.m_wasGrabbedFromAttachableForegrip && !__instance.m_lastGrabbedInGrip.DoesBracing)
				{
					flag = false;
				}
				if (__instance.PrimaryObject.IsAltHeld)
				{
					flag = false;
				}
				if (flag && hand.Input.TriggerPressed)
				{
					if (!__instance.m_hasSavedPalmPoint)
					{
						__instance.AttemptToGenerateSavedPalmPoint();
						if (__instance.m_hasSavedPalmPoint)
						{
							hand.Buzz(hand.Buzzer.Buzz_BeginInteraction);
						}
					}
					else if (Vector3.Distance(__instance.m_savedRigPalmPos, ((FVRInteractiveObject)__instance).m_hand.PalmTransform.position) > 0.2f)
					{
						__instance.ClearSavedPalmPoint();
					}
				}
				else if (__instance.m_hasSavedPalmPoint)
				{
					__instance.ClearSavedPalmPoint();
				}
				if (hand.Input.TriggerUp)
				{
					__instance.ClearSavedPalmPoint();
				}
				if (!__instance.m_wasGrabbedFromAttachableForegrip && __instance.HasQuickMagEject && __instance.PrimaryObject is FVRFireArm)
				{
					FVRPhysicalObject primaryObject = __instance.PrimaryObject;
					FVRFireArm val = (FVRFireArm)(object)((primaryObject is FVRFireArm) ? primaryObject : null);
					if (val.UsesMagazines && (Object)(object)val.Magazine != (Object)null && !val.Magazine.IsIntegrated)
					{
						if (hand.IsInStreamlinedMode)
						{
							if (hand.Input.AXButtonDown)
							{
								val.EjectMag(false);
							}
						}
						else if (hand.Input.TouchpadDown && Vector2.Angle(Vector2.down, touchpadAxes) < 45f && ((Vector2)(ref touchpadAxes)).magnitude > 0.2f)
						{
							val.EjectMag(false);
						}
					}
				}
				__instance.PassHandInput(hand, (FVRInteractiveObject)(object)__instance);
				return false;
			}
			return true;
		}
	}
}
[RequireComponent(typeof(AudioLowPassFilter))]
[RequireComponent(typeof(AudioSource))]
public class DistanceEqualizer : MonoBehaviour
{
	public bool Cutoff = true;

	public bool VolumeDecrease = true;

	public bool Debugging = true;

	public float StartCutoffFrom = 10f;

	[Range(0f, 1f)]
	public float WallCutoff = 0.5f;

	[Range(0.01f, 1f)]
	public float DistanceCutoff = 0.3f;

	[Range(0f, 1f)]
	public float VolDecPerWall = 0.05f;

	private float distance;

	private float distcut;

	private float wallcut;

	private AudioListener AudioListener;

	private AudioSource AudioSource;

	private RaycastHit[] hits;

	private Ray ray;

	private void Start()
	{
		AudioListener = Object.FindObjectOfType<AudioListener>();
		AudioSource = ((Component)this).gameObject.GetComponent<AudioSource>();
		((Behaviour)((Component)this).gameObject.GetComponent<AudioLowPassFilter>()).enabled = true;
	}

	private void FixedUpdate()
	{
		//IL_0008: 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_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_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: 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_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0202: Unknown result type (might be due to invalid IL or missing references)
		distance = Vector3.Distance(((Component)this).transform.position, ((Component)AudioListener).transform.position);
		if (distance < AudioSource.maxDistance)
		{
			ray = new Ray(((Component)this).transform.position, ((Component)AudioListener).transform.position - ((Component)this).transform.position);
			hits = Physics.RaycastAll(ray, distance);
			if (VolumeDecrease)
			{
				((Component)this).gameObject.GetComponent<AudioSource>().volume = 1f - VolDecPerWall * (float)hits.Length;
			}
			if (Cutoff)
			{
				distcut = 22000f * Mathf.Pow(0.6f, (distance - StartCutoffFrom) * Mathf.Pow(DistanceCutoff * 10f, 3f) / 1000f);
				wallcut = Mathf.Atan((float)hits.Length * (1f + 10f * WallCutoff)) * distcut * WallCutoff;
				((Component)this).gameObject.GetComponent<AudioLowPassFilter>().cutoffFrequency = distcut - wallcut;
			}
			if (Debugging)
			{
				Debug.Log((object)("Gameobject '" + ((Object)((Component)this).gameObject).name + "' :: Walls: " + hits.Length + "; current volume: " + ((Component)this).gameObject.GetComponent<AudioSource>().volume + "; current cutoff: " + ((Component)this).gameObject.GetComponent<AudioLowPassFilter>().cutoffFrequency));
				Debug.DrawLine(((Component)this).transform.position, ((Component)AudioListener).transform.position, Color.green);
			}
		}
	}
}
public class Cam : MonoBehaviour
{
	private GameObject AudioSource;

	public float speed = 10f;

	private void Start()
	{
		speed = 0f - speed;
		AudioSource = GameObject.Find("Turret");
	}

	private void Update()
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		((Component)this).transform.LookAt(AudioSource.transform);
		if (((Component)this).transform.position.z <= -100f || ((Component)this).transform.position.z >= 300f)
		{
			speed = 0f - speed;
		}
		((Component)this).transform.Translate(Vector3.forward * speed * Time.deltaTime, (Space)0);
	}
}
public class Fire : MonoBehaviour
{
	private float random;

	private float curTime;

	private AudioSource AudioSource;

	private GameObject Flash1;

	private GameObject Flash2;

	private void Start()
	{
		AudioSource = ((Component)this).gameObject.GetComponent<AudioSource>();
		Flash1 = GameObject.Find("Fire1");
		Flash2 = GameObject.Find("Fire2");
	}

	private void FixedUpdate()
	{
		random = Random.Range(0, 100);
		if (random > 95f && !AudioSource.isPlaying)
		{
			AudioSource.Play();
		}
		if (AudioSource.isPlaying)
		{
			curTime += Time.deltaTime;
			if ((double)curTime > 0.1)
			{
				((Behaviour)Flash1.GetComponent<Light>()).enabled = !((Behaviour)Flash1.GetComponent<Light>()).enabled;
				if (((Behaviour)Flash1.GetComponent<Light>()).enabled)
				{
					((Behaviour)Flash2.GetComponent<Light>()).enabled = false;
				}
				else
				{
					((Behaviour)Flash2.GetComponent<Light>()).enabled = true;
				}
				curTime = 0f;
			}
		}
		else
		{
			((Behaviour)Flash1.GetComponent<Light>()).enabled = false;
			((Behaviour)Flash2.GetComponent<Light>()).enabled = false;
		}
	}
}
public class Look : MonoBehaviour
{
	private AudioListener AudioListener;

	private void Start()
	{
		AudioListener = Object.FindObjectOfType<AudioListener>();
	}

	private void Update()
	{
		((Component)this).transform.LookAt(((Component)AudioListener).transform);
	}
}
public class OrientationAxis : MonoBehaviour
{
	public enum AxisEnum
	{
		None = -1,
		X,
		Y,
		Z,
		XY,
		XZ,
		YZ,
		XYZ
	}

	public AxisEnum axis = AxisEnum.None;

	public Transform directionObject;

	public Vector3 worldDirection = Vector3.up;

	private void Update()
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0117: Unknown result type (might be due to invalid IL or missing references)
		//IL_0118: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)directionObject.parent == (Object)null))
		{
			Vector3 val = worldDirection;
			Quaternion rotation = directionObject.parent.rotation;
			Vector3 eulerAngles = ((Quaternion)(ref rotation)).eulerAngles;
			switch (axis)
			{
			case AxisEnum.X:
				val.y = eulerAngles.y;
				val.z = eulerAngles.z;
				break;
			case AxisEnum.Y:
				val.x = eulerAngles.x;
				val.z = eulerAngles.z;
				break;
			case AxisEnum.Z:
				val.x = eulerAngles.x;
				val.y = eulerAngles.y;
				break;
			case AxisEnum.XY:
				val.z = eulerAngles.z;
				break;
			case AxisEnum.XZ:
				val.y = eulerAngles.y;
				break;
			case AxisEnum.YZ:
				val.x = eulerAngles.x;
				break;
			}
			directionObject.rotation = Quaternion.Euler(val);
		}
	}
}
public class AutoRotate : MonoBehaviour
{
	public float m_Speed = 30f;

	private void Update()
	{
		float num = Time.deltaTime * m_Speed;
		((Component)this).transform.Rotate(num, num, 0f);
	}
}
public class Demo : MonoBehaviour
{
	private void Start()
	{
		QualitySettings.antiAliasing = 8;
	}

	private void OnGUI()
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		GUI.Box(new Rect(10f, 10f, 150f, 25f), "Heat Wave Demo");
	}
}
[RequireComponent(typeof(Camera))]
public class FreeCamera : MonoBehaviour
{
	public float m_MoveSpeed = 0f;

	public float m_RotateSpeed = 0f;

	public KeyCode m_ForwardButton = (KeyCode)119;

	public KeyCode m_BackwardButton = (KeyCode)115;

	public KeyCode m_RightButton = (KeyCode)100;

	public KeyCode m_LeftButton = (KeyCode)97;

	public KeyCode m_UpButton = (KeyCode)113;

	public KeyCode m_DownButton = (KeyCode)101;

	private void Update()
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: 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_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: 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_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_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0144: Unknown result type (might be due to invalid IL or missing references)
		Vector3 moveTo = Vector3.zero;
		Move(m_ForwardButton, ref moveTo, ((Component)this).transform.forward);
		Move(m_BackwardButton, ref moveTo, -((Component)this).transform.forward);
		Move(m_RightButton, ref moveTo, ((Component)this).transform.right);
		Move(m_LeftButton, ref moveTo, -((Component)this).transform.right);
		Move(m_UpButton, ref moveTo, ((Component)this).transform.up);
		Move(m_DownButton, ref moveTo, -((Component)this).transform.up);
		Transform transform = ((Component)this).transform;
		transform.position += moveTo * m_MoveSpeed * Time.deltaTime;
		if (Input.GetMouseButton(0))
		{
			Vector3 eulerAngles = ((Component)this).transform.eulerAngles;
			eulerAngles.x += (0f - Input.GetAxis("Mouse Y")) * 359f * m_RotateSpeed;
			eulerAngles.y += Input.GetAxis("Mouse X") * 359f * m_RotateSpeed;
			((Component)this).transform.eulerAngles = eulerAngles;
		}
	}

	private void Move(KeyCode key, ref Vector3 moveTo, Vector3 dir)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		if (Input.GetKey(key))
		{
			moveTo = dir;
		}
	}
}
[RequireComponent(typeof(Camera))]
public class HeatWave : MonoBehaviour
{
	[Range(0.003f, 0.02f)]
	public float m_Strength = 0.01f;

	public Material m_MatHeatWave;

	public bool m_ShowInternalMaps = false;

	[Header("Internal")]
	private LayerMask m_LmHeatWave;

	public Shader m_SdrDepthOnly;

	public RenderTexture m_RTMask;

	public Camera m_RTCamera;

	public GameObject m_RTCameraGo;

	private void Start()
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Expected O, but got Unknown
		if (!SystemInfo.supportsImageEffects)
		{
			((Behaviour)this).enabled = false;
			return;
		}
		m_LmHeatWave = LayerMask.op_Implicit(LayerMask.NameToLayer("TransparentFX"));
		m_RTMask = new RenderTexture(Screen.width, Screen.height, 16);
		((Object)m_RTMask).hideFlags = (HideFlags)52;
		m_SdrDepthOnly = Shader.Find("Heat Wave/Depth Only");
	}

	private void Update()
	{
		//IL_008c: 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_00e9: 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_003c: Expected O, but got Unknown
		Camera main = Camera.main;
		if ((Object)(object)m_RTCamera == (Object)null)
		{
			m_RTCameraGo = new GameObject("Mask Camera", new Type[1] { typeof(Camera) });
			((Object)m_RTCameraGo).hideFlags = (HideFlags)52;
			m_RTCamera = m_RTCameraGo.GetComponent<Camera>();
		}
		m_RTCamera.CopyFrom(main);
		((Behaviour)m_RTCamera).enabled = false;
		m_RTCamera.targetTexture = m_RTMask;
		m_RTCamera.cullingMask = ~(1 << LayerMask.op_Implicit(m_LmHeatWave));
		m_RTCamera.clearFlags = (CameraClearFlags)2;
		m_RTCamera.backgroundColor = new Color(0.5f, 0.5f, 1f);
		m_RTCamera.RenderWithShader(m_SdrDepthOnly, "");
		m_RTCamera.cullingMask = 1 << LayerMask.op_Implicit(m_LmHeatWave);
		m_RTCamera.clearFlags = (CameraClearFlags)4;
		m_RTCamera.Render();
	}

	private void OnDisable()
	{
		if (Object.op_Implicit((Object)(object)m_RTCamera))
		{
			Object.DestroyImmediate((Object)(object)m_RTCamera);
			m_RTCamera = null;
		}
		if (Object.op_Implicit((Object)(object)m_RTCameraGo))
		{
			Object.DestroyImmediate((Object)(object)m_RTCameraGo);
			m_RTCameraGo = null;
		}
	}

	private void OnRenderImage(RenderTexture src, RenderTexture dst)
	{
		m_MatHeatWave.SetFloat("_Strength", m_Strength);
		m_MatHeatWave.SetTexture("_DistortionTex", (Texture)(object)m_RTMask);
		Graphics.Blit((Texture)(object)src, dst, m_MatHeatWave);
	}

	private void OnGUI()
	{
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		if (m_ShowInternalMaps)
		{
			GUI.DrawTextureWithTexCoords(new Rect(10f, 10f, 128f, 128f), (Texture)(object)m_RTMask, new Rect(0f, 0f, 1f, 1f));
		}
	}
}
public class EnableObjOnSkinSelect : MonoBehaviour
{
	[Header("Hover Over Variables To Read The Tooltips!!!")]
	[Tooltip("Your weapon object.")]
	public GameObject ModularWeapon;

	[Tooltip("ID of the skin to enable/disable objects on.")]
	public string skinID;

	[Tooltip("All objects you want enabled when the skin is selected.")]
	public GameObject[] objectsEnabled;

	[Tooltip("All objects you want disabled when the skin is selected.")]
	public GameObject[] objectsDisabled;

	private IModularWeapon weapon;

	private void Update()
	{
		if (weapon == null)
		{
			weapon = ModularWeapon.GetComponent<IModularWeapon>();
		}
		if (weapon.GetModularFVRFireArm.CurrentSelectedReceiverSkinID == skinID)
		{
			GameObject[] array = objectsEnabled;
			foreach (GameObject val in array)
			{
				val.SetActive(true);
			}
			GameObject[] array2 = objectsDisabled;
			foreach (GameObject val2 in array2)
			{
				val2.SetActive(false);
			}
		}
	}
}
[ExecuteInEditMode]
public class HolographicSight : MonoBehaviour
{
	public Transform VirtualQuad;

	public float Scale = 1f;

	public bool SizeCompensation = true;

	private MaterialPropertyBlock m_block;

	private void OnEnable()
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		m_block = new MaterialPropertyBlock();
		((Component)this).GetComponent<Renderer>().SetPropertyBlock(m_block);
	}

	private void OnWillRenderObject()
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = ((Component)this).transform.InverseTransformPoint(((Component)VirtualQuad).transform.position);
		m_block.SetVector("_Offset", Vector4.op_Implicit(val));
		m_block.SetFloat("_Scale", Scale);
		m_block.SetFloat("_SizeCompensation", (!SizeCompensation) ? 0f : 1f);
		((Component)this).GetComponent<Renderer>().SetPropertyBlock(m_block);
	}
}
namespace Meat_banono.Meats_NewPressurePads
{
	[BepInPlugin("Meat_banono.Meats_NewPressurePads", "Meats_NewPressurePads", "2.0.0")]
	[BepInProcess("h3vr.exe")]
	[Description("Built with MeatKit")]
	[BepInDependency("h3vr.otherloader", "1.3.0")]
	public class Meats_NewPressurePadsPlugin : BaseUnityPlugin
	{
		private static readonly string BasePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

		internal static ManualLogSource Logger;

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			LoadAssets();
		}

		private void LoadAssets()
		{
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "Meat_banono.Meats_NewPressurePads");
			OtherLoader.RegisterDirectLoad(BasePath, "Meat_banono.Meats_NewPressurePads", "", "", "pressurepads", "");
		}
	}
}