Decompiled source of Bag Of Scripts v1.9.1

BagOfScripts.dll

Decompiled 3 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using FistVR;
using Microsoft.CodeAnalysis;
using On.FistVR;
using UnityEngine;
using UnityEngine.Events;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyCompany("BagOfScripts")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BagOfScripts")]
[assembly: AssemblyTitle("BagOfScripts")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace BagOfScripts
{
	internal class ContinuousFiringSound : MonoBehaviour
	{
		[Header("Closed bolt, open bolt or pistol")]
		[SerializeField]
		private FVRFireArm firearm;

		[SerializeField]
		private AudioSource fireLoop;

		[Header("Optional")]
		[SerializeField]
		private bool hasSingleShot;

		[SerializeField]
		private AudioEvent? singleShot;

		[Space(5f)]
		[SerializeField]
		private bool hasFiringStart;

		[SerializeField]
		private AudioEvent? firingStart;

		[SerializeField]
		private bool hasFiringStop;

		[SerializeField]
		private AudioEvent? firingStop;

		[Header("Fade Out")]
		[SerializeField]
		private bool fadesOut;

		[SerializeField]
		private AnimationCurve? fadeOutCurve;

		private float _fadeOutDuration;

		private float _origAudioVolume;

		private float timeSinceFadeOutStart;

		private IEnumerator _FadeOutCoroutine;

		private bool _isFiringSoundPlaying;

		private bool _isFiring;

		private bool hasFiredSingleShot;

		private void Awake()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Expected O, but got Unknown
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Expected O, but got Unknown
			GM.CurrentSceneSettings.ShotFiredEvent += new ShotFired(OnShotFired);
			if (fadesOut && fadeOutCurve != null)
			{
				_fadeOutDuration = ((Keyframe)(ref fadeOutCurve.keys[fadeOutCurve.length - 1])).time;
				_origAudioVolume = fireLoop.volume;
				_FadeOutCoroutine = FiringSoundFadeOut();
				((MonoBehaviour)this).StartCoroutine(_FadeOutCoroutine);
			}
			if (firearm is ClosedBoltWeapon)
			{
				ClosedBoltWeapon.UpdateInputAndAnimate += new hook_UpdateInputAndAnimate(ClosedBoltWeapon_UpdateInputAndAnimate);
			}
			else if (firearm is OpenBoltReceiver)
			{
				OpenBoltReceiver.UpdateInteraction += new hook_UpdateInteraction(OpenBoltReceiver_UpdateInteraction);
			}
			else
			{
				Debug.LogError((object)"Unsupported firearm type!");
			}
		}

		private void OnShotFired(FVRFireArm _firearm)
		{
			if ((Object)(object)_firearm == (Object)(object)firearm)
			{
				_isFiring = true;
				if (fadesOut)
				{
					fireLoop.volume = _origAudioVolume;
					timeSinceFadeOutStart = 0f;
				}
			}
		}

		private void TryPlayFiringAudio()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			if (!_isFiringSoundPlaying)
			{
				if (hasFiringStart)
				{
					SM.PlayCoreSound((FVRPooledAudioType)10, firingStart, firearm.GetMuzzle().position);
				}
				fireLoop.Play();
				_isFiringSoundPlaying = true;
			}
		}

		private void StopFiringAudio()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			if (!fadesOut)
			{
				fireLoop.Stop();
				if (hasFiringStop)
				{
					SM.PlayCoreSound((FVRPooledAudioType)10, firingStop, firearm.GetMuzzle().position);
				}
			}
			_isFiringSoundPlaying = false;
			_isFiring = false;
			hasFiredSingleShot = false;
		}

		private IEnumerator FiringSoundFadeOut()
		{
			while (true)
			{
				if (!_isFiring && fireLoop.isPlaying)
				{
					fireLoop.volume = _origAudioVolume * fadeOutCurve.Evaluate(timeSinceFadeOutStart);
					timeSinceFadeOutStart += Time.deltaTime;
					if (timeSinceFadeOutStart > _fadeOutDuration)
					{
						fireLoop.volume = 0f;
						fireLoop.Stop();
					}
				}
				yield return null;
			}
		}

		private void ClosedBoltWeapon_UpdateInputAndAnimate(orig_UpdateInputAndAnimate orig, ClosedBoltWeapon self, FVRViveHand hand)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Invalid comparison between Unknown and I4
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Invalid comparison between Unknown and I4
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self, hand);
			if (!((Object)(object)self == (Object)(object)firearm) || !_isFiring)
			{
				return;
			}
			FireSelectorModeType modeType = self.FireSelector_Modes[self.m_fireSelectorMode].ModeType;
			if (self.m_triggerFloat < self.TriggerFiringThreshold || (Object)(object)((FVRFireArm)self).Magazine == (Object)null || ((Object)(object)((FVRFireArm)self).Magazine != (Object)null && ((FVRFireArm)self).Magazine.m_numRounds < 1 && !self.Chamber.IsFull && !self.m_proxy.IsFull) || ((int)modeType == 2 && self.m_CamBurst < 1))
			{
				StopFiringAudio();
			}
			else if ((int)modeType == 1)
			{
				if (!hasFiredSingleShot)
				{
					if (hasSingleShot)
					{
						hasFiredSingleShot = true;
						SM.PlayCoreSound((FVRPooledAudioType)10, singleShot, firearm.GetMuzzle().position);
					}
					else
					{
						TryPlayFiringAudio();
						StopFiringAudio();
					}
				}
			}
			else if ((int)modeType != 0)
			{
				TryPlayFiringAudio();
			}
		}

		private void OpenBoltReceiver_UpdateInteraction(orig_UpdateInteraction orig, OpenBoltReceiver self, FVRViveHand hand)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Invalid comparison between Unknown and I4
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Invalid comparison between Unknown and I4
			//IL_00e7: 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_0112: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self, hand);
			if (!((Object)(object)self == (Object)(object)firearm) || !_isFiring)
			{
				return;
			}
			FireSelectorModeType modeType = self.FireSelector_Modes[self.m_fireSelectorMode].ModeType;
			if (self.m_triggerFloat < self.TriggerFiringThreshold || (Object)(object)((FVRFireArm)self).Magazine == (Object)null || ((Object)(object)((FVRFireArm)self).Magazine != (Object)null && ((FVRFireArm)self).Magazine.m_numRounds < 1 && !self.Chamber.IsFull && !self.m_proxy.IsFull) || ((int)modeType == 3 && self.m_CamBurst < 1))
			{
				StopFiringAudio();
			}
			else if ((int)modeType == 1)
			{
				if (!hasFiredSingleShot)
				{
					if (hasSingleShot)
					{
						hasFiredSingleShot = true;
						SM.PlayCoreSound((FVRPooledAudioType)10, singleShot, firearm.GetMuzzle().position);
					}
					else
					{
						TryPlayFiringAudio();
						StopFiringAudio();
					}
				}
			}
			else
			{
				if ((int)modeType == 0)
				{
					return;
				}
				if (((FVRInteractiveObject)self.Bolt).IsHeld)
				{
					if (hasSingleShot)
					{
						SM.PlayCoreSound((FVRPooledAudioType)10, singleShot, firearm.GetMuzzle().position);
					}
					else
					{
						TryPlayFiringAudio();
						StopFiringAudio();
					}
				}
				TryPlayFiringAudio();
			}
		}

		private void OnDestroy()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			GM.CurrentSceneSettings.ShotFiredEvent -= new ShotFired(OnShotFired);
			ClosedBoltWeapon.UpdateInputAndAnimate -= new hook_UpdateInputAndAnimate(ClosedBoltWeapon_UpdateInputAndAnimate);
			OpenBoltReceiver.UpdateInteraction -= new hook_UpdateInteraction(OpenBoltReceiver_UpdateInteraction);
			((MonoBehaviour)this).StopCoroutine(_FadeOutCoroutine);
		}
	}
	internal class CustomCenterOfMass : MonoBehaviour
	{
		[Header("Note: Will probably cause stuttering with break-action weapons!")]
		[SerializeField]
		private FVRPhysicalObject mainObject;

		[SerializeField]
		private Transform centerOfMassOverride;

		[Tooltip("Set to true if you want attachments to change the weapon's center of mass. This will ignore the center of mass override, nothing I can do about that unfortunately.")]
		public bool attachmentsChangeCenterOfMass;

		private void Awake()
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			if ((Object)(object)mainObject == (Object)null)
			{
				Debug.LogError((object)"mainObject is not assigned!");
			}
			else if ((Object)(object)centerOfMassOverride == (Object)null)
			{
				Debug.LogError((object)"centerOfMassOverride is not assigned!");
			}
			else
			{
				FVRPhysicalObject.ResetClampCOM += new hook_ResetClampCOM(FVRPhysicalObject_ResetClampCOM);
			}
		}

		private void OnDestroy()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			FVRPhysicalObject.ResetClampCOM -= new hook_ResetClampCOM(FVRPhysicalObject_ResetClampCOM);
		}

		private void Start()
		{
			//IL_0011: 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)
			mainObject.RootRigidbody.centerOfMass = centerOfMassOverride.localPosition;
			mainObject.m_storedCOMLocal = centerOfMassOverride.localPosition;
		}

		private void FVRPhysicalObject_ResetClampCOM(orig_ResetClampCOM orig, FVRPhysicalObject self)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			if (attachmentsChangeCenterOfMass)
			{
				orig.Invoke(self);
				if (mainObject.AttachmentsList.Count == 0)
				{
					mainObject.RootRigidbody.centerOfMass = centerOfMassOverride.localPosition;
				}
			}
		}
	}
	internal class DropSlideOnMagRelease : MonoBehaviour
	{
		[Header("Weapon type must have an external magazine and a bolt or slide!")]
		public FVRFireArm firearm;

		private void Awake()
		{
			Hook();
		}

		private void OnDestroy()
		{
			Unhook();
		}

		private void FVRFireArm_EjectMag(orig_EjectMag orig, FVRFireArm self, bool PhysicalRelease)
		{
			orig.Invoke(self, PhysicalRelease);
			Handgun val = (Handgun)(object)((self is Handgun) ? self : null);
			if (val != null && (Object)(object)val == (Object)(object)firearm && (Object)(object)val.Slide != (Object)null)
			{
				val.DropSlideRelease();
				return;
			}
			ClosedBoltWeapon val2 = (ClosedBoltWeapon)(object)((self is ClosedBoltWeapon) ? self : null);
			if (val2 != null && (Object)(object)val2 == (Object)(object)firearm && (Object)(object)val2.Bolt != (Object)null)
			{
				val2.Bolt.ReleaseBolt();
				return;
			}
			FVRFireArm obj = firearm;
			OpenBoltReceiver val3 = (OpenBoltReceiver)(object)((obj is OpenBoltReceiver) ? obj : null);
			if (val3 != null && (Object)(object)val3 == (Object)(object)firearm && (Object)(object)val3.Bolt != (Object)null)
			{
				val3.ReleaseSeer();
			}
		}

		private void Hook()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			FVRFireArm.EjectMag += new hook_EjectMag(FVRFireArm_EjectMag);
		}

		private void Unhook()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			FVRFireArm.EjectMag -= new hook_EjectMag(FVRFireArm_EjectMag);
		}
	}
	public class Hooks
	{
		public void Hook()
		{
		}

		public void Unhook()
		{
		}
	}
	public class JukeBox : MonoBehaviour
	{
		[SerializeField]
		private AudioClip recordStartSound;

		[HideInInspector]
		public RecordDisc curDisc;

		private RecordDisc prevDisc;

		[SerializeField]
		private AudioSource music;

		[SerializeField]
		private AudioSource startSoundSource;

		[SerializeField]
		private Transform discPosition;

		[SerializeField]
		private float discRotateSpeed = 1f;

		public bool isPlaying;

		public bool hasMusicStarted;

		private float songProgress;

		private float songLength;

		[SerializeField]
		private JukeBoxButton pausePlayInteractable;

		[SerializeField]
		private JukeBoxButton muteInteractable;

		private GameObject rotatingArm;

		[SerializeField]
		private Vector2 minMaxYArmRot;

		private void Start()
		{
			rotatingArm = muteInteractable.thingNegativeObject;
			startSoundSource.clip = recordStartSound;
		}

		private void OnTriggerEnter(Collider other)
		{
			if ((Object)(object)curDisc == (Object)null)
			{
				RecordDisc componentInParent = ((Component)other).GetComponentInParent<RecordDisc>();
				if ((Object)(object)componentInParent != (Object)null && (Object)(object)componentInParent != (Object)(object)prevDisc)
				{
					DiscInsert(componentInParent);
				}
			}
		}

		private void OnTriggerExit(Collider other)
		{
			if ((Object)(object)prevDisc != (Object)null && (Object)(object)((Component)other).gameObject == (Object)(object)((Component)prevDisc).gameObject)
			{
				prevDisc = null;
			}
		}

		private void Update()
		{
			//IL_00bd: 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)
			if (hasMusicStarted && isPlaying)
			{
				discPosition.Rotate(0f, Time.deltaTime * discRotateSpeed, 0f);
				if (songLength != 0f)
				{
					songProgress = music.time / songLength;
					rotatingArm.transform.localRotation = Quaternion.Euler(0f, Mathf.Lerp(minMaxYArmRot.x, minMaxYArmRot.y, songProgress), 0f);
				}
				else
				{
					rotatingArm.transform.localRotation = Quaternion.Euler(0f, minMaxYArmRot.x, 0f);
				}
			}
		}

		private void DiscInsert(RecordDisc D)
		{
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			((FVRInteractiveObject)D).ForceBreakInteraction();
			D.CurBox = this;
			curDisc = D;
			prevDisc = null;
			music.clip = D.RecordSong;
			songLength = music.clip.length;
			songProgress = 0f;
			music.mute = true;
			((FVRPhysicalObject)D).SetParentage(discPosition);
			((FVRInteractiveObject)D).Transform.localPosition = new Vector3(0f, 0f, 0f);
			((FVRInteractiveObject)D).Transform.localRotation = Quaternion.identity;
			((FVRPhysicalObject)D).StoreAndDestroyRigidbody();
			if (pausePlayInteractable.thingPositiveObject.activeSelf)
			{
				startMusic();
			}
		}

		public void DiscExit()
		{
			songProgress = 0f;
			stopMusic();
			music.clip = null;
			((FVRPhysicalObject)curDisc).RecoverRigidbody();
			prevDisc = curDisc;
			curDisc = null;
			music.mute = true;
			muteInteractable.SetPositive();
		}

		public void startMusic()
		{
			if ((Object)(object)music.clip != (Object)null)
			{
				hasMusicStarted = true;
				if (muteInteractable.thingNegativeObject.activeSelf)
				{
					startSoundSource.Play();
					music.PlayDelayed(recordStartSound.length);
				}
				else
				{
					music.Play();
				}
				isPlaying = true;
				pausePlayInteractable.SetPositive();
			}
		}

		public void stopMusic()
		{
			startSoundSource.Stop();
			music.UnPause();
			music.Stop();
			hasMusicStarted = false;
		}

		public void pausePlay()
		{
			if (isPlaying)
			{
				music.Pause();
				isPlaying = false;
				if ((Object)(object)pausePlayInteractable != (Object)null)
				{
					pausePlayInteractable.SetNegative();
				}
			}
			else
			{
				music.UnPause();
				isPlaying = true;
				if ((Object)(object)pausePlayInteractable != (Object)null)
				{
					pausePlayInteractable.SetPositive();
				}
			}
		}

		public void restartMusic()
		{
			hasMusicStarted = true;
			startSoundSource.Stop();
			music.Stop();
			startSoundSource.Play();
			music.PlayDelayed(recordStartSound.length);
			isPlaying = false;
		}

		public void repeatMusic()
		{
			music.loop = !music.loop;
		}

		public void muteMusic()
		{
			music.mute = !music.mute;
			if ((Object)(object)curDisc != (Object)null)
			{
				muteInteractable.swapActiveObjects();
			}
		}
	}
	public class JukeBoxButton : FVRInteractiveObject
	{
		public enum JBButtonTypes
		{
			Restart,
			PausePlay,
			Eject,
			Repeat,
			Start,
			Mute
		}

		public JukeBox jukebox;

		public JBButtonTypes ButtonTypes;

		public GameObject thingPositiveObject;

		public GameObject thingNegativeObject;

		[SerializeField]
		private AudioEvent positiveButtonSounds;

		[SerializeField]
		private AudioEvent negativeButtonSounds;

		public override void SimpleInteraction(FVRViveHand hand)
		{
			((FVRInteractiveObject)this).SimpleInteraction(hand);
			switch (ButtonTypes)
			{
			case JBButtonTypes.Restart:
				jukebox.restartMusic();
				break;
			case JBButtonTypes.PausePlay:
				if ((Object)(object)jukebox.curDisc != (Object)null)
				{
					if (!jukebox.hasMusicStarted)
					{
						jukebox.startMusic();
					}
					else
					{
						jukebox.pausePlay();
					}
					break;
				}
				swapActiveObjects();
				if (thingPositiveObject.activeSelf)
				{
					jukebox.isPlaying = true;
				}
				else
				{
					jukebox.isPlaying = false;
				}
				break;
			case JBButtonTypes.Repeat:
				jukebox.repeatMusic();
				swapActiveObjects();
				break;
			case JBButtonTypes.Start:
				jukebox.startMusic();
				break;
			case JBButtonTypes.Mute:
				jukebox.muteMusic();
				break;
			case JBButtonTypes.Eject:
				break;
			}
		}

		public void swapActiveObjects()
		{
			if ((Object)(object)thingPositiveObject != (Object)null && (Object)(object)thingPositiveObject != (Object)null)
			{
				if (thingNegativeObject.activeSelf)
				{
					thingNegativeObject.SetActive(false);
					thingPositiveObject.SetActive(true);
					PlayToggleButtonSound(isPositive: true);
				}
				else if (thingPositiveObject.activeSelf)
				{
					thingNegativeObject.SetActive(true);
					thingPositiveObject.SetActive(false);
					PlayToggleButtonSound(isPositive: false);
				}
			}
		}

		public void SetPositive()
		{
			if ((Object)(object)thingPositiveObject != (Object)null && (Object)(object)thingPositiveObject != (Object)null)
			{
				thingPositiveObject.SetActive(true);
				thingNegativeObject.SetActive(false);
			}
			PlayToggleButtonSound(isPositive: true);
		}

		public void SetNegative()
		{
			if ((Object)(object)thingPositiveObject != (Object)null && (Object)(object)thingPositiveObject != (Object)null)
			{
				thingPositiveObject.SetActive(false);
				thingNegativeObject.SetActive(true);
			}
			PlayToggleButtonSound(isPositive: false);
		}

		public void PlayToggleButtonSound(bool isPositive)
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			if (isPositive)
			{
				if (positiveButtonSounds.Clips.Count > 0)
				{
					SM.PlayGenericSound(positiveButtonSounds, ((Component)this).transform.position);
				}
			}
			else if (negativeButtonSounds.Clips.Count > 0)
			{
				SM.PlayGenericSound(negativeButtonSounds, ((Component)this).transform.position);
			}
		}
	}
	internal class TogglePosBreakActionWeapon : BreakActionWeapon
	{
		private GameObject movingBreachObject;

		private Vector3 oldPos;

		private Vector3 oldRot;

		private Vector3 oldScale;

		[SerializeField]
		private Vector3 newPos;

		[SerializeField]
		private Vector3 newRot;

		[SerializeField]
		private Vector3 newScale;

		private bool isLatchedPrevFrame;

		public override void Awake()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			((BreakActionWeapon)this).Awake();
			if ((Object)(object)movingBreachObject != (Object)null)
			{
				((MonoBehaviour)this).StartCoroutine(CheckBreachState());
				oldPos = movingBreachObject.transform.localPosition;
				Quaternion localRotation = movingBreachObject.transform.localRotation;
				oldRot = ((Quaternion)(ref localRotation)).eulerAngles;
				oldPos = movingBreachObject.transform.localScale;
			}
			else
			{
				Debug.LogWarning((object)"movingBreachObject is not assigned");
			}
		}

		public override void OnDestroy()
		{
			((FVRPhysicalObject)this).OnDestroy();
			((MonoBehaviour)this).StopCoroutine(CheckBreachState());
		}

		private IEnumerator CheckBreachState()
		{
			while (true)
			{
				if (isLatchedPrevFrame != base.m_isLatched)
				{
					if (!base.m_isLatched)
					{
						SetNewTransforms();
					}
					else
					{
						SetOldTransforms();
					}
					isLatchedPrevFrame = base.m_isLatched;
				}
				yield return null;
			}
		}

		private void SetNewTransforms()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			movingBreachObject.transform.localPosition = newPos;
			movingBreachObject.transform.localRotation = Quaternion.Euler(newRot);
			movingBreachObject.transform.localScale = newScale;
		}

		private void SetOldTransforms()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			movingBreachObject.transform.localPosition = oldPos;
			movingBreachObject.transform.localRotation = Quaternion.Euler(oldRot);
			movingBreachObject.transform.localScale = oldScale;
		}
	}
	[RequireComponent(typeof(Collider))]
	internal class NambuSear : FVRInteractiveObject, IFVRDamageable
	{
		private enum SearType
		{
			trigger,
			collision
		}

		[SerializeField]
		private Handgun handgun;

		[Tooltip("Remember to tick the \"is trigger\" checkbox if using trigger mode.")]
		[SerializeField]
		private SearType searType;

		public override void Awake()
		{
			if ((Object)(object)handgun == (Object)null)
			{
				Debug.LogError((object)"handgun is not assigned!");
			}
		}

		public override void SimpleInteraction(FVRViveHand hand)
		{
			((FVRInteractiveObject)this).SimpleInteraction(hand);
			if (searType == SearType.trigger)
			{
				handgun.ReleaseSeer();
			}
		}

		public void Damage(Damage d)
		{
			if (searType == SearType.collision)
			{
				handgun.ReleaseSeer();
			}
		}

		private void Update()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			if (!handgun.m_isSeerReady && !((FVRInteractiveObject)handgun).IsHeld && (int)handgun.Slide.CurPos == 0)
			{
				handgun.m_isSeerReady = true;
			}
		}
	}
	internal class PermanentlyAttachedWeapon : AttachableFirearmPhysicalObject
	{
		public override bool CanDetach()
		{
			return false;
		}
	}
	public class PistolBrace : AttachableStock
	{
		public static FVRFireArm? bracedFirearm;

		[HideInInspector]
		public bool isInBraceMode;

		public AudioEvent? audClipBraceMode;

		public AudioEvent? audClipStockMode;

		public ToggleAnimation braceToggleAnimation;

		private bool FVRFireArm_IsTwoHandStabilized(orig_IsTwoHandStabilized orig, FVRFireArm self)
		{
			if ((Object)(object)bracedFirearm == (Object)(object)self && isInBraceMode)
			{
				return true;
			}
			return orig.Invoke(self);
		}

		private void Hook()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			FVRFireArm.IsTwoHandStabilized += new hook_IsTwoHandStabilized(FVRFireArm_IsTwoHandStabilized);
		}

		private void Unhook()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			FVRFireArm.IsTwoHandStabilized -= new hook_IsTwoHandStabilized(FVRFireArm_IsTwoHandStabilized);
		}

		public override void OnAttach()
		{
			((AttachableStock)this).OnAttach();
			FVRPhysicalObject parent = ((FVRFireArmAttachmentInterface)this).Attachment.curMount.GetRootMount().Parent;
			FVRFireArm val = (FVRFireArm)(object)((parent is FVRFireArm) ? parent : null);
			if (val != null)
			{
				bracedFirearm = val;
				if (isInBraceMode)
				{
					val.HasActiveShoulderStock = false;
				}
				val.UsesStockedRecoilProfile = false;
			}
			Hook();
		}

		public override void OnDetach()
		{
			((AttachableStock)this).OnDetach();
			FVRPhysicalObject parent = ((FVRFireArmAttachmentInterface)this).Attachment.curMount.GetRootMount().Parent;
			FVRFireArm val = (FVRFireArm)(object)((parent is FVRFireArm) ? parent : null);
			if (val != null && (Object)(object)val == (Object)(object)bracedFirearm)
			{
				if ((Object)(object)val.RecoilProfileStocked != (Object)null)
				{
					val.UsesStockedRecoilProfile = true;
				}
				bracedFirearm = null;
			}
			Unhook();
		}

		public override void OnDestroy()
		{
			Unhook();
		}

		public void ToggleBrace()
		{
			//IL_0071: 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)
			isInBraceMode = !isInBraceMode;
			if ((Object)(object)bracedFirearm != (Object)null)
			{
				if (isInBraceMode)
				{
					bracedFirearm.HasActiveShoulderStock = false;
					SM.PlayCoreSound((FVRPooledAudioType)0, audClipBraceMode, ((Component)this).transform.position);
					braceToggleAnimation.Toggle(isInBraceMode);
				}
				else
				{
					bracedFirearm.HasActiveShoulderStock = true;
					SM.PlayCoreSound((FVRPooledAudioType)0, audClipStockMode, ((Component)this).transform.position);
					braceToggleAnimation.Toggle(isInBraceMode);
				}
			}
		}
	}
	internal class PistolBraceToggle : FVRInteractiveObject
	{
		public PistolBrace pistolBraceInterface;

		public override void Awake()
		{
			((FVRInteractiveObject)this).Awake();
			if ((Object)(object)pistolBraceInterface != (Object)null)
			{
				pistolBraceInterface.isInBraceMode = false;
			}
		}

		public override void SimpleInteraction(FVRViveHand hand)
		{
			((FVRInteractiveObject)this).SimpleInteraction(hand);
			if ((Object)(object)pistolBraceInterface != (Object)null)
			{
				pistolBraceInterface.ToggleBrace();
			}
			else
			{
				Debug.Log((object)"pistolBraceInterface is missing!");
			}
		}
	}
	internal class PlaySoundOnLoadState : MonoBehaviour
	{
		[Header("Only fill firearm or external magazine, not both!")]
		[Header("If script is attached to firearm")]
		[SerializeField]
		private FVRFireArm? firearm;

		[Tooltip("Do you want the sound to play on the final shot, even if the gun doesn't have a magazine loaded in it?")]
		public bool finalShotRequiresMagazine;

		[Header("If script is attached to external magazine")]
		[SerializeField]
		private FVRFireArmMagazine? magazine;

		[Header("Clips")]
		public bool playSoundOnMagazineFull;

		[Tooltip("The sound the gun plays when the magazine is fully loaded.")]
		[SerializeField]
		private AudioEvent? onMagazineFull;

		public bool playSoundOnFirearmEmpty;

		[Tooltip("The sound the gun plays when it fires its final shot.")]
		[SerializeField]
		private AudioEvent? onFirearmEmpty;

		private void Awake()
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			if ((Object)(object)firearm != (Object)null && (Object)(object)magazine != (Object)null)
			{
				Debug.LogError((object)"Warning: Both firearm and external magazine fields are filled out!");
			}
			if ((Object)(object)firearm == (Object)null && (Object)(object)magazine == (Object)null)
			{
				Debug.LogError((object)"Warning: no FVRFireArm or FVRFireArmMagazine assigned!");
			}
			if (playSoundOnFirearmEmpty)
			{
				GM.CurrentSceneSettings.ShotFiredEvent += new ShotFired(OnShotFired);
			}
			if (playSoundOnMagazineFull)
			{
				Hook();
			}
		}

		private void Hook()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			FVRFireArmMagazine.AddRound_FVRFireArmRound_bool_bool_bool += new hook_AddRound_FVRFireArmRound_bool_bool_bool(FVRFireArmMagazine_AddRound_FVRFireArmRound_bool_bool_bool);
		}

		private void Unhook()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			FVRFireArmMagazine.AddRound_FVRFireArmRound_bool_bool_bool -= new hook_AddRound_FVRFireArmRound_bool_bool_bool(FVRFireArmMagazine_AddRound_FVRFireArmRound_bool_bool_bool);
		}

		private void FVRFireArmMagazine_AddRound_FVRFireArmRound_bool_bool_bool(orig_AddRound_FVRFireArmRound_bool_bool_bool orig, FVRFireArmMagazine self, FVRFireArmRound round, bool makeSound, bool updateDisplay, bool animate)
		{
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self, round, makeSound, updateDisplay, animate);
			if ((Object)(object)firearm != (Object)null && (Object)(object)magazine == (Object)null && (Object)(object)self != (Object)null && (Object)(object)self == (Object)(object)firearm.Magazine && self.m_numRounds == self.m_capacity)
			{
				SM.PlayCoreSound((FVRPooledAudioType)0, onMagazineFull, ((Component)firearm.Magazine).transform.position);
			}
			if ((Object)(object)firearm == (Object)null && (Object)(object)magazine != (Object)null && (Object)(object)self != (Object)null && (Object)(object)self == (Object)(object)magazine && self.m_numRounds == self.m_capacity)
			{
				SM.PlayCoreSound((FVRPooledAudioType)0, onMagazineFull, ((Component)magazine).transform.position);
			}
		}

		private void OnShotFired(FVRFireArm _firearm)
		{
			//IL_00ff: 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_00a0: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)firearm != (Object)null && (Object)(object)magazine == (Object)null && (Object)(object)_firearm == (Object)(object)firearm)
			{
				if (!finalShotRequiresMagazine && (Object)(object)firearm.Magazine == (Object)null)
				{
					SM.PlayCoreSound((FVRPooledAudioType)0, onFirearmEmpty, ((Component)firearm).transform.position);
				}
				if ((Object)(object)firearm.Magazine != (Object)null && firearm.Magazine.m_numRounds < 1)
				{
					SM.PlayCoreSound((FVRPooledAudioType)0, onFirearmEmpty, ((Component)firearm).transform.position);
				}
			}
			if ((Object)(object)firearm == (Object)null && (Object)(object)magazine != (Object)null && (Object)(object)magazine.FireArm == (Object)(object)_firearm && magazine.m_numRounds < 1)
			{
				SM.PlayCoreSound((FVRPooledAudioType)0, onFirearmEmpty, ((Component)magazine.FireArm).transform.position);
			}
		}

		private void OnDestroy()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			GM.CurrentSceneSettings.ShotFiredEvent -= new ShotFired(OnShotFired);
			Unhook();
		}
	}
	[BepInPlugin("okkim.bagofscripts", "Bag Of Scripts", "1.9.1")]
	[BepInProcess("h3vr.exe")]
	public class Plugin : BaseUnityPlugin
	{
		private readonly Hooks _hooks;

		public Plugin()
		{
			_hooks = new Hooks();
			_hooks.Hook();
		}

		private void Awake()
		{
		}

		private void Update()
		{
		}

		private void OnDestroy()
		{
			_hooks.Unhook();
		}
	}
	internal static class PluginInfo
	{
		internal const string NAME = "Bag Of Scripts";

		internal const string GUID = "okkim.bagofscripts";

		internal const string VERSION = "1.9.1";
	}
	public class RecordDisc : FVRPhysicalObject
	{
		public AudioClip RecordSong;

		[HideInInspector]
		public JukeBox CurBox;

		public override void BeginInteraction(FVRViveHand hand)
		{
			((FVRPhysicalObject)this).BeginInteraction(hand);
			if ((Object)(object)CurBox != (Object)null)
			{
				CurBox.DiscExit();
				((Component)this).transform.parent = null;
				CurBox = null;
			}
		}
	}
	[RequireComponent(typeof(Collider))]
	internal class RPMSecondarySwitch : FVRInteractiveObject
	{
		private enum BoltType
		{
			Null,
			Open,
			Closed
		}

		[Serializable]
		public class BoltSettings
		{
			public float selectorPosition;

			public float forwardSpeed;

			public float rearwardSpeed;

			public float springStiffness;
		}

		[Header("RPM Secondary Switch Params")]
		[SerializeField]
		private FVRFireArm? firearm;

		[SerializeField]
		private GameObject? openOrClosedBolt;

		[SerializeField]
		private BoltSettings[] boltRPMSettings;

		private int index;

		private BoltType boltType;

		[Header("Visual Params")]
		public Transform secondarySwitch;

		public Axis axis;

		public InterpStyle interpStyle;

		private void OnValidate()
		{
			if ((Object)(object)firearm != (Object)null && (Object)(object)((Component)firearm).GetComponent<ClosedBoltWeapon>() == (Object)null && (Object)(object)((Component)firearm).GetComponent<OpenBoltReceiver>() == (Object)null)
			{
				firearm = null;
				Debug.LogError((object)"Assigned firearm is not an open or closed bolt weapon!");
			}
			if ((Object)(object)openOrClosedBolt != (Object)null && (Object)(object)openOrClosedBolt.GetComponent<OpenBoltReceiverBolt>() == (Object)null && (Object)(object)openOrClosedBolt.GetComponent<ClosedBolt>() == (Object)null)
			{
				openOrClosedBolt = null;
				Debug.LogError((object)"Object assigned as bolt has no open or closed bolt component!");
			}
		}

		public override void Awake()
		{
			if ((Object)(object)openOrClosedBolt != (Object)null)
			{
				if ((Object)(object)openOrClosedBolt.GetComponent<OpenBoltReceiverBolt>() != (Object)null)
				{
					boltType = BoltType.Open;
				}
				else if ((Object)(object)openOrClosedBolt.GetComponent<ClosedBolt>() != (Object)null)
				{
					boltType = BoltType.Closed;
				}
			}
			else
			{
				Debug.LogError((object)"No open or closed bolt assigned!");
			}
		}

		public override void SimpleInteraction(FVRViveHand hand)
		{
			((FVRInteractiveObject)this).SimpleInteraction(hand);
			AdvanceSecondarySwitch();
		}

		private void AdvanceSecondarySwitch()
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			index++;
			if (index == boltRPMSettings.Length)
			{
				index = 0;
			}
			((FVRPhysicalObject)firearm).SetAnimatedComponent(secondarySwitch, boltRPMSettings[index].selectorPosition, interpStyle, axis);
			switch (boltType)
			{
			case BoltType.Open:
			{
				OpenBoltReceiverBolt component2 = openOrClosedBolt.GetComponent<OpenBoltReceiverBolt>();
				component2.BoltSpeed_Forward = boltRPMSettings[index].forwardSpeed;
				component2.BoltSpeed_Rearward = boltRPMSettings[index].rearwardSpeed;
				component2.BoltSpringStiffness = boltRPMSettings[index].springStiffness;
				break;
			}
			case BoltType.Closed:
			{
				ClosedBolt component = openOrClosedBolt.GetComponent<ClosedBolt>();
				component.Speed_Forward = boltRPMSettings[index].forwardSpeed;
				component.Speed_Rearward = boltRPMSettings[index].rearwardSpeed;
				component.SpringStiffness = boltRPMSettings[index].springStiffness;
				break;
			}
			}
		}
	}
	[RequireComponent(typeof(Collider))]
	internal class SecondaryAttachmentDetachPoint : FVRInteractiveObject
	{
		public FVRFireArmAttachmentInterface interfaceToDetach;

		public Collider grabTrigger;

		public override void Awake()
		{
			((FVRInteractiveObject)this).Awake();
			if ((Object)(object)grabTrigger == (Object)null)
			{
				if ((Object)(object)((Component)this).GetComponent<Collider>() != (Object)null)
				{
					grabTrigger = ((Component)this).GetComponent<Collider>();
				}
				else
				{
					Debug.LogError((object)"No collider for SecondaryAttachmentDetachPoint!");
				}
			}
			if ((Object)(object)grabTrigger != (Object)null && !grabTrigger.isTrigger)
			{
				Debug.LogError((object)"SecondaryAttachmentDetachPoint's collider is not a trigger!");
			}
		}

		public override void FVRUpdate()
		{
			((FVRInteractiveObject)this).FVRUpdate();
			if ((Object)(object)interfaceToDetach.Attachment.curMount != (Object)null)
			{
				grabTrigger.enabled = true;
			}
			else
			{
				grabTrigger.enabled = false;
			}
		}

		public override void UpdateInteraction(FVRViveHand hand)
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			((FVRInteractiveObject)this).UpdateInteraction(hand);
			bool flag = false;
			if (hand.IsInStreamlinedMode)
			{
				if (hand.Input.AXButtonDown)
				{
					flag = true;
				}
			}
			else if (hand.Input.TouchpadDown && ((Vector2)(ref hand.Input.TouchpadAxes)).magnitude > 0.25f && Vector2.Angle(hand.Input.TouchpadAxes, Vector2.down) <= 45f)
			{
				flag = true;
			}
			if (flag && !interfaceToDetach.IsLocked && (Object)(object)interfaceToDetach.Attachment != (Object)null && (Object)(object)interfaceToDetach.Attachment.curMount != (Object)null && !interfaceToDetach.HasAttachmentsOnIt() && interfaceToDetach.Attachment.CanDetach())
			{
				interfaceToDetach.DetachRoutine(hand);
				grabTrigger.enabled = false;
			}
		}
	}
	public class ToggleAnimation : MonoBehaviour
	{
		private enum ToggleType
		{
			Animation,
			Visibility
		}

		private float animLength;

		private float animProgress;

		private bool isForward;

		[SerializeField]
		private ToggleType toggleType;

		[Header("Only used with ToggleType of Animation")]
		public GameObject objectToAnimate;

		public string? forwardAnimationName;

		public string? rewindAnimationName;

		private Animator? animator;

		[Header("Only used with ToggleType of Visibility")]
		public GameObject? forwardObject;

		public GameObject? rewindObject;

		private void Awake()
		{
			switch (toggleType)
			{
			case ToggleType.Animation:
				if ((Object)(object)objectToAnimate != (Object)null)
				{
					animator = objectToAnimate.GetComponent<Animator>();
					if ((Object)(object)animator != (Object)null && animator.runtimeAnimatorController.animationClips.Length == 2)
					{
						animLength = animator.runtimeAnimatorController.animationClips[0].length;
						if (animator.runtimeAnimatorController.animationClips[0].length != animator.runtimeAnimatorController.animationClips[0].length)
						{
							Debug.LogWarning((object)("The two animations in " + ((object)objectToAnimate)?.ToString() + "are of differing lengths. This will cause jittery movement."));
						}
					}
					else
					{
						Debug.LogError((object)"animator is missing or it doesn't have only two animations!");
					}
				}
				else
				{
					Debug.LogError((object)"objectToAnimate is missing!");
				}
				break;
			case ToggleType.Visibility:
				if ((Object)(object)forwardObject == (Object)null && (Object)(object)rewindObject == (Object)null)
				{
					Debug.LogError((object)"forward and rewind objects are both missing, or ToggleType is accidentally on Visibility!");
				}
				break;
			}
		}

		private void Update()
		{
			if (isForward)
			{
				animProgress += Time.deltaTime;
			}
			else if (!isForward)
			{
				animProgress -= Time.deltaTime;
			}
			animProgress = Mathf.Clamp(animProgress, 0f, animLength);
		}

		public void Toggle(bool _isForward)
		{
			if (_isForward)
			{
				if (toggleType == ToggleType.Animation)
				{
					animator.Play(forwardAnimationName, 0, animProgress / animLength);
					return;
				}
				if ((Object)(object)forwardObject != (Object)null)
				{
					forwardObject.SetActive(true);
				}
				if ((Object)(object)rewindObject != (Object)null)
				{
					rewindObject.SetActive(false);
				}
			}
			else if (toggleType == ToggleType.Animation)
			{
				animator.Play(rewindAnimationName, 0, 1f - animProgress / animLength);
			}
			else
			{
				if ((Object)(object)forwardObject != (Object)null)
				{
					forwardObject.SetActive(false);
				}
				if ((Object)(object)rewindObject != (Object)null)
				{
					rewindObject.SetActive(true);
				}
			}
		}
	}
	public class ToggleLerp : FVRInteractiveObject
	{
		public enum LerpState
		{
			A,
			AtoB,
			B,
			BtoA
		}

		[Tooltip("The root FVRPhysicalObject this is parented to")]
		[SerializeField]
		private FVRPhysicalObject mainObject;

		[SerializeField]
		private GameObject objectToMove;

		[SerializeField]
		private Vector2 endPointValues;

		[Tooltip("How long (in seconds) it takes to move the object between positions")]
		[SerializeField]
		private float lerpDuration = 0.5f;

		[SerializeField]
		private Axis interpAxis;

		[Tooltip("Rotations will not work beyond 180 degrees because of quaternion fuckery")]
		[SerializeField]
		private InterpStyle interpStyle;

		[SerializeField]
		private AudioEvent audioEvent_AToB;

		[SerializeField]
		private AudioEvent audioEvent_BToA;

		[Tooltip("Does the object need to reach the end point before it can be reactivated?")]
		[SerializeField]
		private bool requireReachingEndToReactivate;

		[SerializeField]
		private UnityEvent OnStartAToB;

		[SerializeField]
		private UnityEvent OnStartBToA;

		[SerializeField]
		private UnityEvent OnReachB;

		[SerializeField]
		private UnityEvent OnReachA;

		[HideInInspector]
		public LerpState lerpState;

		private float lerpProgress;

		public override void Awake()
		{
			((FVRInteractiveObject)this).Awake();
			if ((Object)(object)objectToMove == (Object)null)
			{
				Debug.LogError((object)"objectToMove is not assigned!");
			}
		}

		public override void FVRUpdate()
		{
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			((FVRInteractiveObject)this).FVRUpdate();
			if (lerpState == LerpState.AtoB || lerpState == LerpState.BtoA)
			{
				float num = Time.deltaTime / lerpDuration;
				if (lerpState == LerpState.BtoA)
				{
					num *= -1f;
				}
				lerpProgress += num;
				if (lerpProgress >= 1f)
				{
					lerpProgress = 1f;
					lerpState = LerpState.B;
					OnReachB.Invoke();
				}
				else if (lerpProgress <= 0f)
				{
					lerpProgress = 0f;
					lerpState = LerpState.A;
					OnReachA.Invoke();
				}
				mainObject.SetAnimatedComponent(objectToMove.transform, Mathf.Lerp(endPointValues.x, endPointValues.y, lerpProgress), interpStyle, interpAxis);
			}
		}

		public void ToggleLerpState()
		{
			if (lerpState == LerpState.A || (!requireReachingEndToReactivate && lerpState == LerpState.BtoA))
			{
				LerpAtoB();
			}
			else if (lerpState == LerpState.B || (!requireReachingEndToReactivate && lerpState == LerpState.AtoB))
			{
				LerpBtoA();
			}
		}

		private void LerpAtoB()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			lerpState = LerpState.AtoB;
			if (audioEvent_AToB != null)
			{
				SM.PlayCoreSound((FVRPooledAudioType)0, audioEvent_AToB, ((Component)this).transform.position);
			}
			OnStartAToB.Invoke();
		}

		private void LerpBtoA()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			lerpState = LerpState.BtoA;
			if (audioEvent_AToB != null)
			{
				SM.PlayCoreSound((FVRPooledAudioType)0, audioEvent_BToA, ((Component)this).transform.position);
			}
			OnStartBToA.Invoke();
		}

		public override void SimpleInteraction(FVRViveHand hand)
		{
			((FVRInteractiveObject)this).SimpleInteraction(hand);
			ToggleLerpState();
		}
	}
	internal class TriggerActivatedLaser : MonoBehaviour
	{
		public static readonly Dictionary<LaserLightAttachment, TriggerActivatedLaser> _existingTriggerActivatedLasers;

		[Header("Do not put this script onto an inactive gameobject!")]
		public LaserLightAttachment laser;

		public bool playSoundOnLaserToggle;

		public float laserTriggerDeadzone = 0.01f;

		private FVRFireArm? curFireArm;

		private bool triggerPulled;

		static TriggerActivatedLaser()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			_existingTriggerActivatedLasers = new Dictionary<LaserLightAttachment, TriggerActivatedLaser>();
			LaserLightAttachment.OnAttach += new hook_OnAttach(LaserLightAttachment_OnAttach);
			LaserLightAttachment.OnDetach += new hook_OnDetach(LaserLightAttachment_OnDetach);
		}

		private void Awake()
		{
			if ((Object)(object)laser == (Object)null && (Object)(object)((Component)this).GetComponent<LaserLightAttachment>() != (Object)null)
			{
				laser = ((Component)this).GetComponentInChildren<LaserLightAttachment>(true);
			}
			_existingTriggerActivatedLasers.Add(laser, this);
		}

		private void OnDestroy()
		{
			_existingTriggerActivatedLasers.Remove(laser);
		}

		private void Update()
		{
			if ((Object)(object)((FVRFireArmAttachmentInterface)laser).Attachment.curMount == (Object)null)
			{
				DisableLaser();
			}
			else
			{
				if (!((Object)(object)curFireArm != (Object)null) || !((Object)(object)((FVRInteractiveObject)curFireArm).m_hand != (Object)null))
				{
					return;
				}
				float triggerFloat = ((FVRInteractiveObject)curFireArm).m_hand.Input.TriggerFloat;
				if (!triggerPulled)
				{
					if (triggerFloat >= laserTriggerDeadzone)
					{
						triggerPulled = true;
						EnableLaser();
					}
				}
				else if (triggerFloat < laserTriggerDeadzone)
				{
					triggerPulled = false;
					DisableLaser();
				}
			}
		}

		private void EnableLaser()
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			laser.SettingsIndex = laser.m_savedSetting;
			if (playSoundOnLaserToggle && (Object)(object)laser.UI != (Object)null)
			{
				SM.PlayCoreSound((FVRPooledAudioType)10, laser.UI.AudEvent_Click, ((Component)this).transform.position);
			}
			laser.UpdateParams();
		}

		private void DisableLaser()
		{
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			if (laser.SettingsIndex != 0)
			{
				laser.m_savedSetting = laser.SettingsIndex;
			}
			laser.SettingsIndex = 0;
			if (playSoundOnLaserToggle && (Object)(object)laser.UI != (Object)null)
			{
				SM.PlayCoreSound((FVRPooledAudioType)10, laser.UI.AudEvent_Clack, ((Component)this).transform.position);
			}
			laser.UpdateParams();
		}

		private static void LaserLightAttachment_OnAttach(orig_OnAttach orig, LaserLightAttachment self)
		{
			orig.Invoke(self);
			if (_existingTriggerActivatedLasers.TryGetValue(self, out TriggerActivatedLaser value) && ((FVRFireArmAttachmentInterface)self).Attachment.curMount.GetRootMount().MyObject is FVRFireArm)
			{
				ref FVRFireArm? reference = ref value.curFireArm;
				FVRPhysicalObject myObject = ((FVRFireArmAttachmentInterface)value.laser).Attachment.curMount.GetRootMount().MyObject;
				reference = (FVRFireArm?)(object)((myObject is FVRFireArm) ? myObject : null);
			}
		}

		private static void LaserLightAttachment_OnDetach(orig_OnDetach orig, LaserLightAttachment self)
		{
			orig.Invoke(self);
			if (_existingTriggerActivatedLasers.TryGetValue(self, out TriggerActivatedLaser value))
			{
				value.curFireArm = null;
			}
		}
	}
}