Decompiled source of Namco Arcade Lightgun v1.0.0

Namco_Arcade_Lightgun.dll

Decompiled 2 weeks ago
using System;
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 BepInEx;
using BepInEx.Logging;
using FistVR;
using HarmonyLib;
using OtherLoader;
using Sodalite.Api;
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]
public class LightGun : FVRFireArm
{
	public enum FireSelectorModeType
	{
		Single = 1,
		FullAuto,
		Safe,
		Burst
	}

	[Serializable]
	public class FireSelectorMode
	{
		public float SelectorPosition;

		public FireSelectorModeType ModeType;

		public int BurstAmount = 3;

		public float EngagementDelay;
	}

	public enum TriggerStyle
	{
		SA,
		SADA,
		DAO
	}

	public enum HeldTouchpadAction
	{
		None,
		SlideRelease,
		Hammer,
		MagRelease
	}

	[Header("LightGun Params")]
	public LightGunSlide Slide;

	public FVRFireArmChamber Chamber;

	public float reloadCoolDown = 1f;

	public float timeToFlickUp = 0.4f;

	public float flickThreshold = 1.2f;

	public AudioEvent onEmptyReloadVoice;

	public AudioEvent onReloadSFX;

	public AudioEvent onEmptyShootSFX;

	public float reloadSFXCooldown = 0.5f;

	[Header("Spinning Config")]
	public Transform PoseSpinHolder;

	public bool CanSpin;

	private bool m_isSpinning;

	private float xSpinRot;

	private float xSpinVel;

	[Header("Component Connections")]
	public Transform Trigger;

	public Transform Safety;

	public Transform Barrel;

	public Transform Hammer;

	public Transform FireSelector;

	public Transform SlideRelease;

	public GameObject ReloadTriggerWell;

	[Header("Round Positions")]
	public Transform RoundPos_Ejecting;

	public Transform RoundPos_Ejection;

	public Transform RoundPos_Magazine;

	public Vector3 RoundEjectionSpeed;

	public Vector3 RoundEjectionSpin;

	private FVRFirearmMovingProxyRound m_proxy;

	[Header("Trigger Params")]
	public bool HasTrigger;

	public InterpStyle TriggerInterp;

	public Axis TriggerAxis;

	public float TriggerUnheld;

	public float TriggerHeld;

	public float TriggerResetThreshold = 0.45f;

	public float TriggerBreakThreshold = 0.85f;

	public TriggerStyle TriggerType;

	public float TriggerSpeed = 20f;

	public bool HasManualDecocker;

	private float m_triggerTarget;

	private float m_triggerFloat;

	private float m_lastTriggerFloat;

	private bool m_isSeerReady = true;

	[Header("Slide Release Params")]
	public bool HasSlideRelease;

	public bool HasSlideReleaseControl = true;

	public InterpStyle SlideReleaseInterp;

	public Axis SlideReleaseAxis;

	public float SlideReleaseUp;

	public float SlideReleaseDown;

	public bool HasSlideLockFunctionality;

	public float SlideLockRot;

	[Header("Safety Params")]
	public bool HasSafety;

	public bool HasSafetyControl = true;

	public InterpStyle Safety_Interp;

	public Axis SafetyAxis;

	public float SafetyOff;

	public float SafetyOn;

	public bool DoesSafetyRequireSlideForward;

	public bool DoesSafetyLockSlide;

	public bool HasMagazineSafety;

	public bool DoesSafetyRequireCockedHammer;

	public bool DoesSafetyEngagingDecock;

	public bool DoesSafetyDisengageCockHammer;

	[Header("Hammer Params")]
	public bool HasHammer;

	public bool HasHammerControl = true;

	public InterpStyle Hammer_Interp;

	public Axis HammerAxis;

	public float HammerForward;

	public float HammerRearward;

	private bool m_isHammerCocked;

	private float m_hammerDALerp;

	[Header("Barrel Params")]
	public bool HasTiltingBarrel;

	public InterpStyle BarrelInterp;

	public Axis BarrelAxis;

	public float BarrelUntilted;

	public float BarrelTilted;

	[Header("TransferBar Params")]
	public bool HasTransferBar;

	public bool TransferBarRequiresHammerCocked;

	public Transform TransferBar;

	public Vector3 TransferBarPoint1;

	public Vector3 TransferBarPoint2;

	[Header("TriggerSafety Params")]
	public bool HasTriggerSafety;

	public Transform TriggerSafety;

	public InterpStyle TriggerSafetyInterp;

	public Axis TriggerSafetyAxis;

	public float TriggerSafetyUnpressed;

	public float TriggerSafetyPressed;

	[Header("Magazine Release Button")]
	public bool HasMagReleaseButton;

	public Transform MagazineReleaseButton;

	public InterpStyle MagReleaseInterp;

	public Axis MagReleaseAxis;

	public float MagReleaseUnpressed;

	public float MagReleasePressed;

	[Header("FireSelector Params")]
	public bool HasFireSelector;

	public InterpStyle FireSelectorInterpStyle = (InterpStyle)1;

	public Axis FireSelectorAxis;

	public FireSelectorMode[] FireSelectorModes;

	private int m_CamBurst;

	private float m_engagementDelay;

	[Header("Misc Control Vars")]
	public bool HasMagReleaseInput = true;

	[HideInInspector]
	public bool IsSlideLockPushedUp;

	[HideInInspector]
	public bool IsSlideLockHeldDown;

	[HideInInspector]
	public bool IsMagReleaseHeldDown;

	[HideInInspector]
	public bool IsSafetyOn;

	[HideInInspector]
	public bool HasTriggerReset = true;

	[HideInInspector]
	public bool IsSlideLockUp;

	[HideInInspector]
	public bool IsSlideLockExternalPushedUp;

	[HideInInspector]
	public bool IsSlideLockExternalHeldDown;

	public bool CanPhysicsSlideRack = true;

	private HashSet<Collider> m_slideCols = new HashSet<Collider>();

	private HashSet<Collider> m_unRackCols = new HashSet<Collider>();

	private HeldTouchpadAction m_heldTouchpadAction;

	private Vector2 TouchpadClickInitiation = Vector2.zero;

	private float m_timeSinceFiredShot = 1f;

	private float m_lastHammerVal;

	private float m_lastBarrelVal;

	private float m_lastSlideReleaseVal;

	private float m_lastMagReleaseVal;

	private Vector3 m_lastTBarVal = Vector3.zero;

	private Vector3 lastPosition;

	private float m_timeSinceLastFlickDown;

	private float m_timeSinceLastReload;

	private float m_timeSinceLastReloadSound;

	private FVRFireArmRound m_lastFiredRound;

	public bool IsSLideLockMechanismEngaged { get; private set; }

	public bool IsSafetyEngaged { get; private set; }

	public int FireSelectorModeIndex { get; private set; }

	public override void Awake()
	{
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		((FVRFireArm)this).Awake();
		base.FChambers.Add(Chamber);
		m_CamBurst = 1;
		m_proxy = new GameObject("m_proxyRound").AddComponent<FVRFirearmMovingProxyRound>();
		m_proxy.Init(((Component)this).transform);
		m_isHammerCocked = true;
		if (CanPhysicsSlideRack)
		{
			InitSlideCols();
		}
		if ((Object)(object)Chamber != (Object)null)
		{
			Chamber.Firearm = (FVRFireArm)(object)this;
		}
	}

	public override void FVRFixedUpdate()
	{
		((FVRFireArm)this).FVRFixedUpdate();
		UpdateSpinning();
	}

	private void InitSlideCols()
	{
		Transform[] componentsInChildren = ((Component)Slide).gameObject.GetComponentsInChildren<Transform>();
		for (int i = 0; i < componentsInChildren.Length; i++)
		{
			Component val = (Component)(object)componentsInChildren[i];
			Collider component = val.GetComponent<Collider>();
			if ((Object)(object)component != (Object)null && !component.isTrigger)
			{
				m_slideCols.Add(component);
			}
		}
	}

	public void ResetCamBurst()
	{
		m_engagementDelay = 0f;
		if (FireSelectorModes.Length > 0)
		{
			m_CamBurst = FireSelectorModes[FireSelectorModeIndex].BurstAmount;
		}
	}

	public override void OnCollisionEnter(Collision c)
	{
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		if (((FVRInteractiveObject)this).IsHeld && CanPhysicsSlideRack && c.contacts.Length > 0 && m_slideCols.Contains(((ContactPoint)(ref c.contacts[0])).thisCollider) && !IsSLideLockMechanismEngaged && !IsSafetyEngaged && (double)Vector3.Angle(((Component)this).transform.forward, c.relativeVelocity) > 135.0)
		{
			Vector3 relativeVelocity = c.relativeVelocity;
			if ((double)((Vector3)(ref relativeVelocity)).magnitude > 3.0)
			{
				m_unRackCols.Add(c.collider);
				Slide.KnockToRear();
			}
		}
		((FVRPhysicalObject)this).OnCollisionEnter(c);
	}

	public void OnCollisionExit(Collision c)
	{
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		if (((FVRInteractiveObject)this).IsHeld && CanPhysicsSlideRack && m_unRackCols.Contains(c.collider))
		{
			Vector3 relativeVelocity = c.relativeVelocity;
			if ((double)((Vector3)(ref relativeVelocity)).magnitude > 3.0)
			{
				IsSlideLockExternalHeldDown = true;
			}
			m_unRackCols.Clear();
		}
	}

	public override int GetTutorialState()
	{
		if ((Object)(object)base.Magazine == (Object)null)
		{
			return 0;
		}
		if (IsSafetyEngaged)
		{
			return 4;
		}
		if (Chamber.IsFull || (double)Slide.GetSlideSpeed() > 0.0 || (double)m_timeSinceFiredShot <= 0.25)
		{
			return 2;
		}
		return base.Magazine.HasARound() ? 1 : 3;
	}

	public void EjectExtractedRound()
	{
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: 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_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: 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_00ee: Unknown result type (might be due to invalid IL or missing references)
		if (Chamber.IsFull)
		{
			Chamber.EjectRound(RoundPos_Ejection.position, ((Component)this).transform.right * RoundEjectionSpeed.x + ((Component)this).transform.up * RoundEjectionSpeed.y + ((Component)this).transform.forward * RoundEjectionSpeed.z, ((Component)this).transform.right * RoundEjectionSpin.x + ((Component)this).transform.up * RoundEjectionSpin.y + ((Component)this).transform.forward * RoundEjectionSpin.z, RoundPos_Ejection.position, RoundPos_Ejection.rotation, false);
		}
	}

	public void ExtractRound()
	{
		if (!((Object)(object)base.Magazine == (Object)null) && !m_proxy.IsFull && base.Magazine.HasARound())
		{
			m_proxy.SetFromPrefabReference(base.Magazine.RemoveRound(false));
		}
	}

	public bool ChamberRound()
	{
		if (!m_proxy.IsFull || Chamber.IsFull)
		{
			return false;
		}
		Chamber.SetRound(m_proxy.Round, false);
		m_proxy.ClearProxy();
		return true;
	}

	public bool CycleFireSelector()
	{
		m_engagementDelay = 0f;
		if (FireSelectorModes.Length <= 1)
		{
			return false;
		}
		bool flag = true;
		bool flag2 = true;
		int fireSelectorModeIndex = FireSelectorModeIndex;
		FireSelectorModeIndex++;
		if (FireSelectorModeIndex >= FireSelectorModes.Length)
		{
			FireSelectorModeIndex -= FireSelectorModes.Length;
		}
		if (HasSafety)
		{
			if (FireSelectorModes[FireSelectorModeIndex].ModeType == FireSelectorModeType.Safe)
			{
				flag2 = SetSafetyState(s: true);
			}
			else
			{
				SetSafetyState(s: false);
			}
		}
		if (!flag2)
		{
			flag = false;
			FireSelectorModeIndex = fireSelectorModeIndex;
		}
		if (flag)
		{
			((FVRFireArm)this).PlayAudioEvent((FirearmAudioEventType)15, 1f);
		}
		if (FireSelectorModes.Length > 0)
		{
			FireSelectorMode fireSelectorMode = FireSelectorModes[FireSelectorModeIndex];
			if ((double)m_triggerFloat < 0.10000000149011612)
			{
				m_CamBurst = fireSelectorMode.BurstAmount;
			}
		}
		return true;
	}

	public bool SetFireSelectorByIndex(int i)
	{
		if (FireSelectorModes.Length <= 1)
		{
			return false;
		}
		FireSelectorModeIndex = i;
		if (FireSelectorModeIndex >= FireSelectorModes.Length)
		{
			FireSelectorModeIndex -= FireSelectorModes.Length;
		}
		if (HasSafety)
		{
			if (FireSelectorModes[FireSelectorModeIndex].ModeType == FireSelectorModeType.Safe)
			{
				SetSafetyState(s: true);
			}
			else
			{
				SetSafetyState(s: false);
			}
		}
		return true;
	}

	public bool ToggleSafety()
	{
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Invalid comparison between Unknown and I4
		if (!HasSafety || (DoesSafetyRequireSlideForward && (int)Slide.CurPos != 0) || ((int)Slide.CurPos != 0 && (int)Slide.CurPos < 2))
		{
			return false;
		}
		if (IsSafetyEngaged)
		{
			((FVRFireArm)this).PlayAudioEvent((FirearmAudioEventType)14, 1f);
			IsSafetyEngaged = false;
			if (DoesSafetyDisengageCockHammer)
			{
				CockHammer(isManual: true);
			}
		}
		else
		{
			bool flag = true;
			if (DoesSafetyRequireCockedHammer && !m_isHammerCocked)
			{
				flag = false;
			}
			if (flag)
			{
				IsSafetyEngaged = true;
				if (DoesSafetyEngagingDecock)
				{
					DeCockHammer(isManual: true, isLoud: true);
				}
				((FVRFireArm)this).PlayAudioEvent((FirearmAudioEventType)14, 1f);
			}
		}
		UpdateSafetyPos();
		return true;
	}

	public bool SetSafetyState(bool s)
	{
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Invalid comparison between Unknown and I4
		if (!HasSafety || (DoesSafetyRequireSlideForward && (int)Slide.CurPos != 0) || ((int)Slide.CurPos != 0 && (int)Slide.CurPos != 2))
		{
			return false;
		}
		if (IsSafetyEngaged && !s)
		{
			((FVRFireArm)this).PlayAudioEvent((FirearmAudioEventType)14, 1f);
			IsSafetyEngaged = false;
			if (DoesSafetyDisengageCockHammer)
			{
				CockHammer(isManual: true);
			}
			UpdateSafetyPos();
			return true;
		}
		if (IsSafetyEngaged || !s)
		{
			return false;
		}
		bool flag = true;
		if (DoesSafetyRequireCockedHammer && !m_isHammerCocked)
		{
			flag = false;
		}
		if (flag)
		{
			IsSafetyEngaged = true;
			if (DoesSafetyEngagingDecock)
			{
				DeCockHammer(isManual: true, isLoud: true);
			}
			((FVRFireArm)this).PlayAudioEvent((FirearmAudioEventType)14, 1f);
		}
		UpdateSafetyPos();
		return true;
	}

	private void UpdateSafetyPos()
	{
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		if (HasSafety)
		{
			float num = SafetyOff;
			if (IsSafetyEngaged)
			{
				num = SafetyOn;
			}
			((FVRPhysicalObject)this).SetAnimatedComponent(Safety, num, Safety_Interp, SafetyAxis);
		}
	}

	public void ReleaseSeer()
	{
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		if (HasTriggerReset && ((Object)(object)Chamber.m_round == (Object)null || Chamber.m_round.IsSpent))
		{
			SM.PlayGenericSound(onEmptyShootSFX, ((Component)this).transform.position);
		}
		HasTriggerReset = false;
		if (m_isHammerCocked && m_isSeerReady)
		{
			if (FireSelectorModes[FireSelectorModeIndex].ModeType == FireSelectorModeType.Single || (FireSelectorModes[FireSelectorModeIndex].ModeType == FireSelectorModeType.Burst && m_CamBurst < 1))
			{
				m_isSeerReady = false;
			}
			DropHammer(isManual: false);
		}
	}

	public void CockHammer(bool isManual)
	{
		if (isManual && !m_isHammerCocked)
		{
			((FVRFireArm)this).PlayAudioEvent((FirearmAudioEventType)7, 1f);
		}
		m_isHammerCocked = true;
	}

	public void DeCockHammer(bool isManual, bool isLoud)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		if ((int)Slide.CurPos != 0)
		{
			return;
		}
		if (isManual && m_isHammerCocked)
		{
			if (isLoud)
			{
				((FVRFireArm)this).PlayAudioEvent((FirearmAudioEventType)6, 1f);
			}
			else
			{
				((FVRFireArm)this).PlayAudioEvent((FirearmAudioEventType)16, 1f);
			}
		}
		m_isHammerCocked = false;
	}

	public void DropSlideRelease()
	{
		if (IsSlideLockUp)
		{
			((FVRFireArm)this).PlayAudioEvent((FirearmAudioEventType)8, 1f);
		}
		IsSlideLockUp = false;
	}

	public void EngageSlideRelease()
	{
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		if (!IsSlideLockUp)
		{
			if (m_timeSinceLastReload >= reloadSFXCooldown)
			{
				m_timeSinceLastReload = 0f;
				SM.PlayGenericSound(onEmptyReloadVoice, ((Component)this).transform.position);
			}
			IsSlideLockUp = true;
		}
	}

	private void EngageSlideLockMechanism()
	{
		if (!IsSLideLockMechanismEngaged)
		{
			IsSLideLockMechanismEngaged = true;
			((FVRFireArm)this).PlayAudioEvent((FirearmAudioEventType)15, 1f);
		}
	}

	private void DisEngageSlideLockMechanism()
	{
		if (IsSLideLockMechanismEngaged)
		{
			IsSLideLockMechanismEngaged = false;
			((FVRFireArm)this).PlayAudioEvent((FirearmAudioEventType)15, 1f);
		}
	}

	public bool IsSlideCatchEngaged()
	{
		return IsSlideLockUp;
	}

	public void DropHammer(bool isManual)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		if ((int)Slide.CurPos == 0 && m_isHammerCocked)
		{
			m_isHammerCocked = false;
			if (m_CamBurst > 0)
			{
				m_CamBurst--;
			}
			Fire();
			((FVRFireArm)this).PlayAudioEvent((FirearmAudioEventType)6, 1f);
		}
	}

	public bool Fire()
	{
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		if (!Chamber.Fire())
		{
			return false;
		}
		m_lastFiredRound = Chamber.m_round;
		m_timeSinceFiredShot = 0f;
		((FVRFireArm)this).Fire(Chamber, ((FVRFireArm)this).GetMuzzle(), true, 1f, -1f);
		((FVRFireArm)this).FireMuzzleSmoke();
		bool flag = ((FVRFireArm)this).IsTwoHandStabilized();
		bool flag2 = ((FVRFireArm)this).IsForegripStabilized();
		bool flag3 = ((FVRFireArm)this).IsShoulderStabilized();
		float num = 1f;
		float num2 = 1f;
		if (IsSLideLockMechanismEngaged)
		{
			num = 0.4f;
			num2 = 1.5f;
		}
		((FVRFireArm)this).Recoil(flag, flag2, flag3, ((FVRFireArm)this).GetRecoilProfile(), num2);
		((FVRFireArm)this).PlayAudioGunShot(Chamber.GetRound(), GM.CurrentPlayerBody.GetCurrentSoundEnvironment(), num);
		if (!IsSLideLockMechanismEngaged)
		{
			Slide.ImpartFiringImpulse();
		}
		return true;
	}

	public override void FVRUpdate()
	{
		((FVRFireArm)this).FVRUpdate();
		if ((double)m_engagementDelay > 0.0)
		{
			m_engagementDelay -= Time.deltaTime;
		}
		UpdateComponents();
		Slide.UpdateSlide();
		UpdateDisplayRoundPositions();
		if (m_timeSinceLastFlickDown < timeToFlickUp)
		{
			m_timeSinceLastFlickDown += Time.deltaTime;
		}
		if (m_timeSinceLastReload < reloadCoolDown)
		{
			m_timeSinceLastReload += Time.deltaTime;
		}
		if (m_timeSinceLastReload < reloadSFXCooldown)
		{
			m_timeSinceLastReloadSound += Time.deltaTime;
		}
		if (!((double)m_timeSinceFiredShot >= 1.0))
		{
			m_timeSinceFiredShot += Time.deltaTime;
		}
	}

	public void DetectFlick(FVRViveHand hand)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		Vector3 position = ((Component)hand).transform.position;
		Vector3 val = (position - lastPosition) / Time.deltaTime;
		if (val.y < 0f - flickThreshold)
		{
			m_timeSinceLastFlickDown = 0f;
		}
		if (val.y > flickThreshold && m_timeSinceLastFlickDown <= timeToFlickUp && m_timeSinceLastReload >= reloadCoolDown)
		{
			m_timeSinceLastReload = 0f;
			ReloadMag();
		}
		lastPosition = position;
	}

	public override void UpdateInteraction(FVRViveHand hand)
	{
		((FVRPhysicalObject)this).UpdateInteraction(hand);
		DetectFlick(hand);
		UpdateInputAndAnimate(hand);
	}

	private void UpdateInputAndAnimate(FVRViveHand hand)
	{
		//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0203: Unknown result type (might be due to invalid IL or missing references)
		//IL_0216: Unknown result type (might be due to invalid IL or missing references)
		//IL_0217: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0233: Unknown result type (might be due to invalid IL or missing references)
		//IL_0234: Unknown result type (might be due to invalid IL or missing references)
		//IL_0259: Unknown result type (might be due to invalid IL or missing references)
		//IL_025a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0295: Unknown result type (might be due to invalid IL or missing references)
		//IL_0296: Unknown result type (might be due to invalid IL or missing references)
		//IL_032d: Unknown result type (might be due to invalid IL or missing references)
		//IL_032e: Unknown result type (might be due to invalid IL or missing references)
		//IL_04f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_05ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_040d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0483: Unknown result type (might be due to invalid IL or missing references)
		bool isSpinning = false;
		IsSlideLockHeldDown = false;
		IsSlideLockPushedUp = false;
		IsMagReleaseHeldDown = false;
		if (((FVRPhysicalObject)this).IsAltHeld)
		{
			return;
		}
		if (((FVRInteractiveObject)this).m_hasTriggeredUpSinceBegin)
		{
			m_triggerTarget = ((!((double)m_engagementDelay > 0.0)) ? hand.Input.TriggerFloat : 0f);
			if (m_isHammerCocked && TriggerType == TriggerStyle.SADA)
			{
				m_triggerTarget = Mathf.Max(TriggerResetThreshold * 0.9f, hand.Input.TriggerFloat);
			}
		}
		else
		{
			m_triggerTarget = ((m_isHammerCocked && TriggerType == TriggerStyle.SADA) ? (TriggerResetThreshold * 0.9f) : 0f);
		}
		m_triggerFloat = ((!((double)m_triggerTarget <= (double)m_triggerFloat)) ? Mathf.MoveTowards(m_triggerFloat, m_triggerTarget, Time.deltaTime * TriggerSpeed) : Mathf.MoveTowards(m_triggerFloat, m_triggerTarget, (float)((double)Time.deltaTime * (double)TriggerSpeed * 2.0)));
		if (!HasTriggerReset && (double)m_triggerFloat <= (double)TriggerResetThreshold)
		{
			HasTriggerReset = true;
			m_isSeerReady = true;
			((FVRFireArm)this).PlayAudioEvent((FirearmAudioEventType)16, 1f);
			if (FireSelectorModes.Length > 0)
			{
				m_CamBurst = FireSelectorModes[FireSelectorModeIndex].BurstAmount;
			}
		}
		if (hand.IsInStreamlinedMode)
		{
			if (hand.Input.AXButtonPressed)
			{
				isSpinning = true;
			}
			if (hand.Input.BYButtonDown)
			{
				m_heldTouchpadAction = HeldTouchpadAction.None;
				if (HasSlideReleaseControl && IsSlideCatchEngaged())
				{
					DropSlideRelease();
				}
			}
		}
		else
		{
			Vector2 touchpadAxes = hand.Input.TouchpadAxes;
			if (hand.Input.TouchpadDown)
			{
				TouchpadClickInitiation = touchpadAxes;
				if ((double)((Vector2)(ref touchpadAxes)).magnitude > 0.20000000298023224)
				{
					if ((double)Vector2.Angle(touchpadAxes, Vector2.down) <= 45.0)
					{
						m_heldTouchpadAction = HeldTouchpadAction.MagRelease;
					}
					else if ((double)Vector2.Angle(touchpadAxes, Vector2.left) <= 45.0 && HasSlideRelease && HasSlideReleaseControl)
					{
						m_heldTouchpadAction = HeldTouchpadAction.SlideRelease;
					}
					else if ((double)Vector2.Angle(touchpadAxes, Vector2.right) <= 45.0 && TriggerType != TriggerStyle.DAO && HasHammerControl)
					{
						m_heldTouchpadAction = HeldTouchpadAction.Hammer;
					}
				}
			}
			if (hand.Input.TouchpadPressed)
			{
				if ((double)Vector2.Angle(touchpadAxes, Vector2.up) <= 45.0)
				{
					m_heldTouchpadAction = HeldTouchpadAction.None;
					isSpinning = true;
				}
				else if (m_heldTouchpadAction == HeldTouchpadAction.MagRelease)
				{
					if ((double)((Vector2)(ref touchpadAxes)).magnitude > 0.20000000298023224 && (double)Vector2.Angle(touchpadAxes, Vector2.down) <= 45.0)
					{
						IsMagReleaseHeldDown = true;
					}
				}
				else if (m_heldTouchpadAction == HeldTouchpadAction.SlideRelease)
				{
					if ((double)touchpadAxes.y >= (double)TouchpadClickInitiation.y + 0.05000000074505806)
					{
						IsSlideLockPushedUp = true;
					}
					else if ((double)touchpadAxes.y <= (double)TouchpadClickInitiation.y - 0.05000000074505806)
					{
						IsSlideLockHeldDown = true;
					}
				}
				else if (m_heldTouchpadAction == HeldTouchpadAction.Hammer)
				{
					if ((double)touchpadAxes.y <= (double)TouchpadClickInitiation.y - 0.05000000074505806 && TriggerType != TriggerStyle.DAO && !m_isHammerCocked && (int)Slide.CurPos == 0)
					{
						CockHammer(isManual: true);
					}
					else if ((double)touchpadAxes.y >= (double)TouchpadClickInitiation.y + 0.05000000074505806 && TriggerType != TriggerStyle.DAO && m_isHammerCocked && ((double)m_triggerFloat > 0.10000000149011612 || HasManualDecocker) && (int)Slide.CurPos == 0)
					{
						DeCockHammer(isManual: true, isLoud: false);
					}
				}
			}
			if (hand.Input.TouchpadUp)
			{
				m_heldTouchpadAction = HeldTouchpadAction.None;
			}
		}
		m_isSpinning = isSpinning;
		if ((double)m_triggerFloat >= (double)TriggerBreakThreshold)
		{
			if (!m_isHammerCocked && (TriggerType == TriggerStyle.SADA || TriggerType == TriggerStyle.DAO) && (int)Slide.CurPos == 0 && (!HasMagazineSafety || (Object)(object)base.Magazine != (Object)null))
			{
				if ((double)m_hammerDALerp >= 1.0 && m_isSeerReady)
				{
					CockHammer(isManual: false);
				}
			}
			else if (!IsSafetyEngaged && (!HasMagazineSafety || (Object)(object)base.Magazine != (Object)null))
			{
				ReleaseSeer();
			}
		}
		m_hammerDALerp = ((!m_isHammerCocked && !IsSafetyEngaged && (TriggerType == TriggerStyle.SADA || TriggerType == TriggerStyle.DAO) && (int)Slide.CurPos == 0 && m_isSeerReady) ? Mathf.InverseLerp(TriggerResetThreshold, TriggerBreakThreshold, m_triggerFloat) : 0f);
		if (IsMagReleaseHeldDown && HasMagReleaseInput)
		{
			if ((Object)(object)base.Magazine != (Object)null)
			{
				((FVRFireArm)this).EjectMag(false);
			}
			if ((Object)(object)ReloadTriggerWell != (Object)null)
			{
				ReloadTriggerWell.SetActive(false);
			}
		}
		else if ((Object)(object)ReloadTriggerWell != (Object)null)
		{
			ReloadTriggerWell.SetActive(true);
		}
	}

	private void UpdateSpinning()
	{
		//IL_0238: Unknown result type (might be due to invalid IL or missing references)
		//IL_023d: Unknown result type (might be due to invalid IL or missing references)
		//IL_024d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0263: Unknown result type (might be due to invalid IL or missing references)
		//IL_0268: Unknown result type (might be due to invalid IL or missing references)
		//IL_027a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0102: Unknown result type (might be due to invalid IL or missing references)
		//IL_014b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0150: Unknown result type (might be due to invalid IL or missing references)
		if (!((FVRInteractiveObject)this).IsHeld)
		{
			m_isSpinning = false;
		}
		if (m_isSpinning)
		{
			Vector3 val = Vector3.zero;
			if ((Object)(object)((FVRInteractiveObject)this).m_hand != (Object)null)
			{
				val = ((FVRInteractiveObject)this).m_hand.Input.VelLinearLocal;
			}
			float num = Vector3.Dot(((Vector3)(ref val)).normalized, ((Component)this).transform.up);
			num = Mathf.Clamp(num, 0f - ((Vector3)(ref val)).magnitude, ((Vector3)(ref val)).magnitude);
			if (Mathf.Abs(xSpinVel) < 90f)
			{
				xSpinVel += num * Time.deltaTime * 600f;
			}
			else if (Mathf.Sign(num) == Mathf.Sign(xSpinVel))
			{
				xSpinVel += num * Time.deltaTime * 600f;
			}
			if (Mathf.Abs(xSpinVel) < 90f)
			{
				if (Vector3.Dot(((Component)this).transform.up, Vector3.down) >= 0f && Mathf.Sign(xSpinVel) == 1f)
				{
					xSpinVel += Time.deltaTime * 50f;
				}
				if (Vector3.Dot(((Component)this).transform.up, Vector3.down) < 0f && Mathf.Sign(xSpinVel) == -1f)
				{
					xSpinVel -= Time.deltaTime * 50f;
				}
			}
			xSpinVel = Mathf.Clamp(xSpinVel, -500f, 500f);
			xSpinRot += xSpinVel * Time.deltaTime * 5f;
			PoseSpinHolder.localEulerAngles = new Vector3(xSpinRot, 0f, 0f);
			xSpinVel = Mathf.Lerp(xSpinVel, 0f, Time.deltaTime * 0.6f);
		}
		else
		{
			xSpinRot = 0f;
			xSpinVel = 0f;
			PoseSpinHolder.localRotation = Quaternion.RotateTowards(PoseSpinHolder.localRotation, Quaternion.identity, Time.deltaTime * 500f);
			PoseSpinHolder.localEulerAngles = new Vector3(PoseSpinHolder.localEulerAngles.x, 0f, 0f);
		}
	}

	public void ReloadMag()
	{
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)base.Magazine))
		{
			return;
		}
		bool flag = false;
		while (base.Magazine.m_numRounds < base.Magazine.m_capacity)
		{
			flag = true;
			if ((Object)(object)m_lastFiredRound != (Object)null)
			{
				base.Magazine.AddRound(m_lastFiredRound.RoundClass, false, false);
			}
			else
			{
				base.Magazine.AddRound(base.Magazine.DefaultLoadingPattern.Classes[0], false, false);
			}
		}
		if (flag)
		{
			SM.PlayGenericSound(onReloadSFX, ((Component)this).transform.position);
		}
		if (IsSlideLockUp)
		{
			DropSlideRelease();
		}
	}

	public void ReleaseMag()
	{
		if ((Object)(object)base.Magazine != (Object)null)
		{
			((FVRFireArm)this).EjectMag(false);
		}
	}

	private void UpdateComponents()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Invalid comparison between Unknown and I4
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_025b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0261: Unknown result type (might be due to invalid IL or missing references)
		//IL_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_0170: Unknown result type (might be due to invalid IL or missing references)
		//IL_0383: Unknown result type (might be due to invalid IL or missing references)
		//IL_0389: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0302: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_0678: Unknown result type (might be due to invalid IL or missing references)
		//IL_067d: Unknown result type (might be due to invalid IL or missing references)
		//IL_067f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0693: Unknown result type (might be due to invalid IL or missing references)
		//IL_0698: Unknown result type (might be due to invalid IL or missing references)
		//IL_069b: Unknown result type (might be due to invalid IL or missing references)
		//IL_06a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_06a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0686: Unknown result type (might be due to invalid IL or missing references)
		//IL_0689: Invalid comparison between Unknown and I4
		//IL_0461: Unknown result type (might be due to invalid IL or missing references)
		//IL_0466: Unknown result type (might be due to invalid IL or missing references)
		//IL_0468: Unknown result type (might be due to invalid IL or missing references)
		//IL_06a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_06ac: Invalid comparison between Unknown and I4
		//IL_072a: Unknown result type (might be due to invalid IL or missing references)
		//IL_072f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0732: Unknown result type (might be due to invalid IL or missing references)
		//IL_0737: Unknown result type (might be due to invalid IL or missing references)
		//IL_0739: Unknown result type (might be due to invalid IL or missing references)
		//IL_0482: Unknown result type (might be due to invalid IL or missing references)
		//IL_0487: Unknown result type (might be due to invalid IL or missing references)
		//IL_048a: Unknown result type (might be due to invalid IL or missing references)
		//IL_048f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0491: Unknown result type (might be due to invalid IL or missing references)
		//IL_046f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0472: Invalid comparison between Unknown and I4
		//IL_044f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0455: Unknown result type (might be due to invalid IL or missing references)
		//IL_040c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0412: Unknown result type (might be due to invalid IL or missing references)
		//IL_071e: Unknown result type (might be due to invalid IL or missing references)
		//IL_06b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_06b4: Invalid comparison between Unknown and I4
		//IL_0740: Unknown result type (might be due to invalid IL or missing references)
		//IL_0743: Invalid comparison between Unknown and I4
		//IL_0498: Unknown result type (might be due to invalid IL or missing references)
		//IL_049b: Invalid comparison between Unknown and I4
		//IL_052e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0533: Unknown result type (might be due to invalid IL or missing references)
		//IL_0536: Unknown result type (might be due to invalid IL or missing references)
		//IL_053b: Unknown result type (might be due to invalid IL or missing references)
		//IL_053d: Unknown result type (might be due to invalid IL or missing references)
		//IL_07b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0748: Unknown result type (might be due to invalid IL or missing references)
		//IL_074b: Invalid comparison between Unknown and I4
		//IL_051c: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a3: Invalid comparison between Unknown and I4
		//IL_0544: Unknown result type (might be due to invalid IL or missing references)
		//IL_0547: Invalid comparison between Unknown and I4
		//IL_05c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_054c: Unknown result type (might be due to invalid IL or missing references)
		//IL_054f: Invalid comparison between Unknown and I4
		//IL_05e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_05e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_05ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0605: Unknown result type (might be due to invalid IL or missing references)
		//IL_0610: Unknown result type (might be due to invalid IL or missing references)
		//IL_0630: Unknown result type (might be due to invalid IL or missing references)
		//IL_0632: Unknown result type (might be due to invalid IL or missing references)
		//IL_0635: Unknown result type (might be due to invalid IL or missing references)
		//IL_061b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0621: Unknown result type (might be due to invalid IL or missing references)
		//IL_062b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0650: Unknown result type (might be due to invalid IL or missing references)
		//IL_0652: Unknown result type (might be due to invalid IL or missing references)
		//IL_065d: Unknown result type (might be due to invalid IL or missing references)
		if ((int)Slide.CurPos < 2)
		{
			IsSlideLockUp = false;
		}
		else if (IsSlideLockPushedUp || IsSlideLockExternalPushedUp)
		{
			EngageSlideRelease();
		}
		else if ((IsSlideLockHeldDown || IsSlideLockExternalHeldDown) && (Object)(object)((FVRInteractiveObject)Slide).m_hand == (Object)null)
		{
			DropSlideRelease();
			IsSlideLockExternalHeldDown = false;
		}
		IsSlideLockExternalHeldDown = false;
		if (HasSlideLockFunctionality && (int)Slide.CurPos == 0)
		{
			if (IsSlideLockHeldDown)
			{
				EngageSlideLockMechanism();
			}
			else if (IsSlideLockPushedUp)
			{
				DisEngageSlideLockMechanism();
			}
		}
		if (HasHammer)
		{
			float num = 0f;
			switch (TriggerType)
			{
			case TriggerStyle.SA:
				num = (m_isHammerCocked ? 1f : (1f - Slide.GetSlideLerpBetweenLockAndFore()));
				break;
			case TriggerStyle.SADA:
				num = (m_isHammerCocked ? 1f : (((int)Slide.CurPos == 0) ? m_hammerDALerp : (1f - Slide.GetSlideLerpBetweenLockAndFore())));
				break;
			case TriggerStyle.DAO:
				num = (((int)Slide.CurPos == 0 && m_isSeerReady) ? m_hammerDALerp : (1f - Slide.GetSlideLerpBetweenLockAndFore()));
				break;
			}
			float num2 = Mathf.Lerp(HammerForward, HammerRearward, num);
			if ((double)Mathf.Abs(num2 - m_lastHammerVal) >= 9.999999747378752E-06)
			{
				m_lastHammerVal = num2;
				((FVRPhysicalObject)this).SetAnimatedComponent(Hammer, num2, Hammer_Interp, HammerAxis);
			}
		}
		if (HasTiltingBarrel)
		{
			float num3 = Mathf.Lerp(BarrelUntilted, BarrelTilted, (1f - Slide.GetSlideLerpBetweenLockAndFore()) * 4f);
			if ((double)Mathf.Abs(num3 - m_lastBarrelVal) >= 9.999999747378752E-06)
			{
				m_lastBarrelVal = num3;
				((FVRPhysicalObject)this).SetAnimatedComponent(Barrel, num3, BarrelInterp, BarrelAxis);
			}
		}
		if (HasSlideRelease)
		{
			float num4 = 0f;
			if (IsSlideLockUp)
			{
				num4 = 1f;
			}
			float num5 = SlideReleaseDown;
			float num6 = SlideReleaseUp;
			if (IsSLideLockMechanismEngaged)
			{
				num5 = SlideLockRot;
				num6 = SlideLockRot;
			}
			float num7 = Mathf.Lerp(num5, num6, num4);
			if ((double)Mathf.Abs(num7 - m_lastSlideReleaseVal) >= 9.999999747378752E-06)
			{
				m_lastSlideReleaseVal = num7;
				((FVRPhysicalObject)this).SetAnimatedComponent(SlideRelease, num7, SlideReleaseInterp, SlideReleaseAxis);
			}
		}
		if (HasMagReleaseButton)
		{
			float num8 = 0f;
			if (IsMagReleaseHeldDown && HasMagReleaseInput)
			{
				num8 = 1f;
			}
			float num9 = Mathf.Lerp(MagReleaseUnpressed, MagReleasePressed, num8);
			if ((double)Mathf.Abs(num9 - m_lastMagReleaseVal) >= 9.999999747378752E-06)
			{
				m_lastMagReleaseVal = num9;
				((FVRPhysicalObject)this).SetAnimatedComponent(MagazineReleaseButton, num9, MagReleaseInterp, MagReleaseAxis);
			}
		}
		bool flag = false;
		if ((double)Mathf.Abs(m_triggerFloat - m_lastTriggerFloat) > 9.999999747378752E-05)
		{
			m_lastTriggerFloat = m_triggerFloat;
			flag = true;
		}
		if (HasTrigger && flag)
		{
			if (HasTriggerSafety)
			{
				if ((double)m_triggerFloat < 0.20000000298023224)
				{
					((FVRPhysicalObject)this).SetAnimatedComponent(TriggerSafety, TriggerSafetyUnpressed, TriggerSafetyInterp, TriggerSafetyAxis);
				}
				else
				{
					((FVRPhysicalObject)this).SetAnimatedComponent(TriggerSafety, Mathf.Lerp(TriggerSafetyUnpressed, TriggerSafetyPressed, Mathf.InverseLerp(0.2f, 0.4f, m_triggerFloat)), TriggerSafetyInterp, TriggerSafetyAxis);
				}
			}
			InterpStyle triggerInterp = TriggerInterp;
			if ((int)triggerInterp != 0)
			{
				if ((int)triggerInterp == 1)
				{
					Vector3 localEulerAngles = Trigger.localEulerAngles;
					Axis triggerAxis = TriggerAxis;
					if ((int)triggerAxis != 0)
					{
						if ((int)triggerAxis != 1)
						{
							if ((int)triggerAxis == 2)
							{
								localEulerAngles.z = Mathf.Lerp(TriggerUnheld, TriggerHeld, m_triggerFloat);
							}
						}
						else
						{
							localEulerAngles.y = Mathf.Lerp(TriggerUnheld, TriggerHeld, m_triggerFloat);
						}
					}
					else
					{
						localEulerAngles.x = Mathf.Lerp(TriggerUnheld, TriggerHeld, m_triggerFloat);
					}
					Trigger.localEulerAngles = localEulerAngles;
				}
			}
			else
			{
				Vector3 localPosition = Trigger.localPosition;
				Axis triggerAxis2 = TriggerAxis;
				if ((int)triggerAxis2 != 0)
				{
					if ((int)triggerAxis2 != 1)
					{
						if ((int)triggerAxis2 == 2)
						{
							localPosition.z = Mathf.Lerp(TriggerUnheld, TriggerHeld, m_triggerFloat);
						}
					}
					else
					{
						localPosition.y = Mathf.Lerp(TriggerUnheld, TriggerHeld, m_triggerFloat);
					}
				}
				else
				{
					localPosition.x = Mathf.Lerp(TriggerUnheld, TriggerHeld, m_triggerFloat);
				}
				Trigger.localPosition = localPosition;
			}
			if (HasTransferBar)
			{
				Vector3 lastTBarVal = m_lastTBarVal;
				Vector3 val = ((TransferBarRequiresHammerCocked && !m_isHammerCocked) ? Vector3.Lerp(TransferBarPoint1, TransferBarPoint2, 0f) : Vector3.Lerp(TransferBarPoint1, TransferBarPoint2, m_triggerFloat));
				if ((double)Vector3.Distance(val, m_lastTBarVal) > 9.999999747378752E-05)
				{
					m_lastTBarVal = val;
					TransferBar.localPosition = val;
				}
			}
		}
		if (!HasFireSelector)
		{
			return;
		}
		InterpStyle fireSelectorInterpStyle = FireSelectorInterpStyle;
		if ((int)fireSelectorInterpStyle != 0)
		{
			if ((int)fireSelectorInterpStyle != 1)
			{
				return;
			}
			Vector3 zero = Vector3.zero;
			Axis fireSelectorAxis = FireSelectorAxis;
			if ((int)fireSelectorAxis != 0)
			{
				if ((int)fireSelectorAxis != 1)
				{
					if ((int)fireSelectorAxis == 2)
					{
						zero.z = FireSelectorModes[FireSelectorModeIndex].SelectorPosition;
					}
				}
				else
				{
					zero.y = FireSelectorModes[FireSelectorModeIndex].SelectorPosition;
				}
			}
			else
			{
				zero.x = FireSelectorModes[FireSelectorModeIndex].SelectorPosition;
			}
			FireSelector.localEulerAngles = zero;
			return;
		}
		Vector3 zero2 = Vector3.zero;
		Axis fireSelectorAxis2 = FireSelectorAxis;
		if ((int)fireSelectorAxis2 != 0)
		{
			if ((int)fireSelectorAxis2 != 1)
			{
				if ((int)fireSelectorAxis2 == 2)
				{
					zero2.z = FireSelectorModes[FireSelectorModeIndex].SelectorPosition;
				}
			}
			else
			{
				zero2.y = FireSelectorModes[FireSelectorModeIndex].SelectorPosition;
			}
		}
		else
		{
			zero2.x = FireSelectorModes[FireSelectorModeIndex].SelectorPosition;
		}
		FireSelector.localPosition = zero2;
	}

	private void UpdateDisplayRoundPositions()
	{
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
		float slideLerpBetweenLockAndFore = Slide.GetSlideLerpBetweenLockAndFore();
		if (m_proxy.IsFull)
		{
			m_proxy.ProxyRound.position = Vector3.Lerp(RoundPos_Magazine.position, ((Component)Chamber).transform.position, slideLerpBetweenLockAndFore);
			m_proxy.ProxyRound.rotation = Quaternion.Slerp(RoundPos_Magazine.rotation, ((Component)Chamber).transform.rotation, slideLerpBetweenLockAndFore);
		}
		else if (Chamber.IsFull)
		{
			Chamber.ProxyRound.position = Vector3.Lerp(RoundPos_Ejecting.position, ((Component)Chamber).transform.position, slideLerpBetweenLockAndFore);
			Chamber.ProxyRound.rotation = Quaternion.Slerp(RoundPos_Ejecting.rotation, ((Component)Chamber).transform.rotation, slideLerpBetweenLockAndFore);
		}
		if ((int)Slide.CurPos == 0)
		{
			Chamber.IsAccessible = false;
		}
		else
		{
			Chamber.IsAccessible = true;
		}
	}

	public override List<FireArmRoundClass> GetChamberRoundList()
	{
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		if (!Chamber.IsFull || Chamber.IsSpent)
		{
			return null;
		}
		List<FireArmRoundClass> list = new List<FireArmRoundClass>();
		list.Add(Chamber.GetRound().RoundClass);
		return list;
	}

	public override void SetLoadedChambers(List<FireArmRoundClass> rounds)
	{
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		if (rounds.Count > 0)
		{
			Chamber.Autochamber(rounds[0]);
		}
	}

	public override void ConfigureFromFlagDic(Dictionary<string, string> f)
	{
		string empty = string.Empty;
		string empty2 = string.Empty;
		string key = "HammerState";
		if (f.ContainsKey(key) && f[key] == "Cocked")
		{
			CockHammer(isManual: false);
		}
		if (HasSafety)
		{
			string key2 = "SafetyState";
			if (f.ContainsKey(key2) && f[key2] == "On")
			{
				SetSafetyState(s: true);
			}
		}
		if (HasFireSelector)
		{
			string key3 = "FireSelectorState";
			if (f.ContainsKey(key3))
			{
				string s = f[key3];
				int result = 0;
				int.TryParse(s, out result);
				SetFireSelectorByIndex(result);
			}
		}
		UpdateComponents();
		UpdateSafetyPos();
		((FVRFireArm)this).ConfigureFromFlagDic(f);
	}

	public override Dictionary<string, string> GetFlagDic()
	{
		Dictionary<string, string> flagDic = ((FVRFireArm)this).GetFlagDic();
		string key = "HammerState";
		string value = "Uncocked";
		if (m_isHammerCocked)
		{
			value = "Cocked";
		}
		flagDic.Add(key, value);
		if (HasSafety)
		{
			string key2 = "SafetyState";
			string value2 = "Off";
			if (IsSafetyEngaged)
			{
				value2 = "On";
			}
			flagDic.Add(key2, value2);
		}
		if (HasFireSelector)
		{
			string key3 = "FireSelectorState";
			string value3 = FireSelectorModeIndex.ToString();
			flagDic.Add(key3, value3);
		}
		return flagDic;
	}
}
public class LightGunLaser : FVRInteractiveObject
{
	public GameObject BeamHitPoint;

	public Transform Aperture;

	public LayerMask LM;

	public RaycastHit m_hit;

	public bool m_isOn;

	public bool UsesAutoOnOff;

	public FVRPhysicalObject PO;

	public GameObject laserOriginVfx;

	public Transform Muzzle;

	public AudioEvent turnOnOffSound;

	public override void SimpleInteraction(FVRViveHand hand)
	{
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		((FVRInteractiveObject)this).SimpleInteraction(hand);
		SM.PlayGenericSound(turnOnOffSound, ((Component)this).transform.position);
		TurnOnOrOff();
	}

	public void TurnOnOrOff()
	{
		if (m_isOn)
		{
			TurnOff();
		}
		else
		{
			TurnOn();
		}
	}

	public void TurnOn()
	{
		laserOriginVfx.SetActive(true);
		m_isOn = true;
	}

	public void TurnOff()
	{
		laserOriginVfx.SetActive(false);
		m_isOn = false;
	}

	public void Update()
	{
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_010e: 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_012a: Unknown result type (might be due to invalid IL or missing references)
		//IL_017e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0195: Unknown result type (might be due to invalid IL or missing references)
		//IL_0146: Unknown result type (might be due to invalid IL or missing references)
		//IL_014b: Unknown result type (might be due to invalid IL or missing references)
		if (UsesAutoOnOff)
		{
			if (((FVRInteractiveObject)PO).IsHeld)
			{
				TurnOn();
			}
			else
			{
				TurnOff();
			}
		}
		if (m_isOn)
		{
			if ((Object)(object)Muzzle != (Object)null)
			{
				((Component)Aperture).transform.LookAt(Muzzle.position + Muzzle.forward * 25f);
				((Component)Aperture).transform.localEulerAngles = new Vector3(((Component)Aperture).transform.localEulerAngles.x, 0f, 0f);
			}
			if (!BeamHitPoint.activeSelf)
			{
				BeamHitPoint.SetActive(true);
			}
			Vector3 position = Aperture.position + Aperture.forward * 1000f;
			float num = 1000f;
			if (Physics.Raycast(Aperture.position, Aperture.forward, ref m_hit, 1000f, LayerMask.op_Implicit(LM), (QueryTriggerInteraction)1))
			{
				position = ((RaycastHit)(ref m_hit)).point;
				num = ((RaycastHit)(ref m_hit)).distance;
			}
			float num2 = num * 0.01f;
			float num3 = Mathf.Lerp(0.01f, 0.2f, num2);
			BeamHitPoint.transform.position = position;
			BeamHitPoint.transform.localScale = new Vector3(num3, num3, num3);
		}
		else if (BeamHitPoint.activeSelf)
		{
			BeamHitPoint.SetActive(false);
		}
	}
}
public class LightGunSlide : FVRInteractiveObject
{
	public enum SlidePos
	{
		Forward,
		ForwardToMid,
		Locked,
		LockedToRear,
		Rear
	}

	[Header("Handgun Params")]
	public LightGun LightGun;

	public float Speed_Forward;

	public float Speed_Rearward;

	public float Speed_Held;

	public float SpringStiffness = 5f;

	public SlidePos CurPos;

	public SlidePos LastPos;

	public Transform Point_Slide_Forward;

	public Transform Point_Slide_LockPoint;

	public Transform Point_Slide_Rear;

	public bool HasLastRoundSlideHoldOpen = true;

	private float m_curSlideSpeed;

	private float m_slideZ_current;

	private float m_slideZ_heldTarget;

	private float m_slideZ_forward;

	private float m_slideZ_lock;

	private float m_slideZ_rear;

	private float m_handZOffset;

	public override void Awake()
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		((FVRInteractiveObject)this).Awake();
		m_slideZ_current = ((Component)this).transform.localPosition.z;
		m_slideZ_forward = Point_Slide_Forward.localPosition.z;
		m_slideZ_lock = Point_Slide_LockPoint.localPosition.z;
		m_slideZ_rear = Point_Slide_Rear.localPosition.z;
	}

	public override bool IsInteractable()
	{
		return !LightGun.IsSLideLockMechanismEngaged && ((FVRInteractiveObject)this).IsInteractable();
	}

	public float GetSlideSpeed()
	{
		return m_curSlideSpeed;
	}

	public float GetSlideLerpBetweenLockAndFore()
	{
		return Mathf.InverseLerp(m_slideZ_lock, m_slideZ_forward, m_slideZ_current);
	}

	public float GetSlideLerpBetweenRearAndFore()
	{
		return Mathf.InverseLerp(m_slideZ_rear, m_slideZ_forward, m_slideZ_current);
	}

	public void ImpartFiringImpulse()
	{
		m_curSlideSpeed = Speed_Rearward;
	}

	public override void BeginInteraction(FVRViveHand hand)
	{
		//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_0040: Unknown result type (might be due to invalid IL or missing references)
		((FVRInteractiveObject)this).BeginInteraction(hand);
		if ((Object)(object)((FVRFireArm)LightGun).Clip != (Object)null)
		{
			((FVRFireArm)LightGun).EjectClip();
		}
		m_handZOffset = ((Component)this).transform.InverseTransformPoint(((HandInput)(ref hand.Input)).Pos).z;
	}

	public override void EndInteraction(FVRViveHand hand)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Invalid comparison between Unknown and I4
		if ((int)CurPos >= 2 && !LightGun.IsSlideLockUp)
		{
			((FVRFireArm)LightGun).PlayAudioEvent((FirearmAudioEventType)8, 1f);
		}
		((FVRInteractiveObject)this).EndInteraction(hand);
	}

	public void KnockToRear()
	{
		ImpartFiringImpulse();
	}

	public void UpdateSlide()
	{
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_0160: Unknown result type (might be due to invalid IL or missing references)
		//IL_0166: Invalid comparison between Unknown and I4
		//IL_0181: Unknown result type (might be due to invalid IL or missing references)
		//IL_0187: Invalid comparison between Unknown and I4
		//IL_023e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0243: Unknown result type (might be due to invalid IL or missing references)
		//IL_0252: Unknown result type (might be due to invalid IL or missing references)
		//IL_0257: Unknown result type (might be due to invalid IL or missing references)
		//IL_0266: Unknown result type (might be due to invalid IL or missing references)
		//IL_0282: Unknown result type (might be due to invalid IL or missing references)
		//IL_0287: Unknown result type (might be due to invalid IL or missing references)
		//IL_0318: Unknown result type (might be due to invalid IL or missing references)
		//IL_031b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0322: Expected I4, but got Unknown
		//IL_0323: Unknown result type (might be due to invalid IL or missing references)
		//IL_0332: Expected I4, but got Unknown
		//IL_0332: Unknown result type (might be due to invalid IL or missing references)
		//IL_0338: Unknown result type (might be due to invalid IL or missing references)
		//IL_0359: Unknown result type (might be due to invalid IL or missing references)
		//IL_035f: Invalid comparison between Unknown and I4
		//IL_0343: Unknown result type (might be due to invalid IL or missing references)
		//IL_0371: Unknown result type (might be due to invalid IL or missing references)
		//IL_0377: Invalid comparison between Unknown and I4
		//IL_0365: Unknown result type (might be due to invalid IL or missing references)
		//IL_0394: Unknown result type (might be due to invalid IL or missing references)
		//IL_039a: Invalid comparison between Unknown and I4
		//IL_037d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0383: Invalid comparison between Unknown and I4
		//IL_03f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ff: Invalid comparison between Unknown and I4
		//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_03bd: Invalid comparison between Unknown and I4
		//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a6: Invalid comparison between Unknown and I4
		//IL_0457: Unknown result type (might be due to invalid IL or missing references)
		//IL_045c: Unknown result type (might be due to invalid IL or missing references)
		//IL_03da: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e0: Invalid comparison between Unknown and I4
		//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c9: Invalid comparison between Unknown and I4
		//IL_03e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ec: Invalid comparison between Unknown and I4
		bool flag = false;
		if (((FVRInteractiveObject)this).IsHeld)
		{
			flag = true;
		}
		if ((LightGun.DoesSafetyLockSlide && LightGun.IsSafetyEngaged) || LightGun.IsSLideLockMechanismEngaged)
		{
			return;
		}
		if (((FVRInteractiveObject)this).IsHeld)
		{
			m_slideZ_heldTarget = ((Component)LightGun).transform.InverseTransformPoint(((FVRInteractiveObject)this).GetClosestValidPoint(Point_Slide_Forward.position, Point_Slide_Rear.position, ((HandInput)(ref base.m_hand.Input)).Pos + -((Component)this).transform.forward * m_handZOffset * ((Component)LightGun).transform.localScale.x)).z;
		}
		Vector2 val = default(Vector2);
		((Vector2)(ref val))..ctor(m_slideZ_rear, m_slideZ_forward);
		if ((double)m_slideZ_current <= (double)m_slideZ_lock && LightGun.IsSlideCatchEngaged())
		{
			((Vector2)(ref val))..ctor(m_slideZ_rear, m_slideZ_lock);
		}
		if ((Object)(object)((FVRFireArm)LightGun).Clip != (Object)null)
		{
			((Vector2)(ref val))..ctor(m_slideZ_rear, m_slideZ_lock);
		}
		if (flag)
		{
			m_curSlideSpeed = 0f;
		}
		else if (((int)CurPos < 3 && (double)m_curSlideSpeed >= 0.0) || (int)LastPos >= 4)
		{
			m_curSlideSpeed = Mathf.MoveTowards(m_curSlideSpeed, Speed_Forward, Time.deltaTime * SpringStiffness);
		}
		float slideZ_current = m_slideZ_current;
		float slideZ_current2 = m_slideZ_current;
		float num = Mathf.Clamp(flag ? Mathf.MoveTowards(m_slideZ_current, m_slideZ_heldTarget, Speed_Held * Time.deltaTime) : (m_slideZ_current + m_curSlideSpeed * Time.deltaTime), val.x, val.y);
		if ((double)Mathf.Abs(num - m_slideZ_current) > (double)Mathf.Epsilon)
		{
			m_slideZ_current = num;
			((Component)this).transform.localPosition = new Vector3(((Component)this).transform.localPosition.x, ((Component)this).transform.localPosition.y, m_slideZ_current);
		}
		else
		{
			m_curSlideSpeed = 0f;
		}
		SlidePos curPos = CurPos;
		SlidePos val2 = (SlidePos)(((double)Mathf.Abs(m_slideZ_current - m_slideZ_forward) >= 0.001) ? ((!((double)Mathf.Abs(m_slideZ_current - m_slideZ_lock) >= 0.001)) ? 2 : ((!((double)Mathf.Abs(m_slideZ_current - m_slideZ_rear) >= 0.001)) ? 4 : ((!((double)m_slideZ_current <= (double)m_slideZ_lock)) ? 1 : 3))) : 0);
		int num2 = (int)CurPos;
		CurPos = (SlidePos)Mathf.Clamp((int)val2, num2 - 1, num2 + 1);
		if ((int)CurPos == 0 && (int)LastPos != 0)
		{
			SlideEvent_ArriveAtFore();
		}
		else if ((int)CurPos != 1 || (int)LastPos != 0)
		{
			if ((int)CurPos == 2 && (int)LastPos == 1)
			{
				SlideEvent_EjectRound();
			}
			else if ((int)CurPos == 1 && (int)LastPos == 2)
			{
				SlideEvent_ExtractRoundFromMag();
			}
			else if ((int)CurPos == 2 && (int)LastPos == 3)
			{
				SlideEvent_SlideCaught();
			}
			else if ((int)CurPos == 4 && (int)LastPos != 4)
			{
				SlideEvent_SmackRear();
			}
		}
		if ((int)CurPos >= 2 && HasLastRoundSlideHoldOpen && (Object)(object)((FVRFireArm)LightGun).Magazine != (Object)null && !((FVRFireArm)LightGun).Magazine.HasARound() && !LightGun.IsSlideCatchEngaged())
		{
			LightGun.EngageSlideRelease();
		}
		LastPos = CurPos;
	}

	private void SlideEvent_ArriveAtFore()
	{
		LightGun.ChamberRound();
		if (((FVRInteractiveObject)this).IsHeld)
		{
			((FVRFireArm)LightGun).PlayAudioEvent((FirearmAudioEventType)2, 1f);
		}
		else
		{
			((FVRFireArm)LightGun).PlayAudioEvent((FirearmAudioEventType)0, 1f);
		}
	}

	private void SlideEvent_EjectRound()
	{
		LightGun.EjectExtractedRound();
		if (LightGun.TriggerType != LightGun.TriggerStyle.DAO)
		{
			LightGun.CockHammer(isManual: false);
		}
	}

	private void SlideEvent_ExtractRoundFromMag()
	{
		LightGun.ExtractRound();
	}

	private void SlideEvent_SmackRear()
	{
		LightGun.DropSlideRelease();
		if (((FVRInteractiveObject)this).IsHeld)
		{
			((FVRFireArm)LightGun).PlayAudioEvent((FirearmAudioEventType)3, 1f);
		}
		else
		{
			((FVRFireArm)LightGun).PlayAudioEvent((FirearmAudioEventType)1, 1f);
		}
	}

	private void SlideEvent_SlideCaught()
	{
		if (LightGun.IsSlideCatchEngaged())
		{
			((FVRFireArm)LightGun).PlayAudioEvent((FirearmAudioEventType)4, 1f);
		}
	}
}
namespace Prime_Vr.Namco_Arcade_Lightgun;

[BepInPlugin("Prime_Vr.Namco_Arcade_Lightgun", "Namco_Arcade_Lightgun", "1.0.0")]
[BepInProcess("h3vr.exe")]
[Description("Built with MeatKit")]
[BepInDependency("h3vr.otherloader", "1.3.0")]
[BepInDependency("h3vr.cityrobo.ModularWorkshopManager", "1.0.0")]
[BepInDependency("nrgill28.Sodalite", "1.4.1")]
public class Namco_Arcade_LightgunPlugin : 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(), "Prime_Vr.Namco_Arcade_Lightgun");
		OtherLoader.RegisterDirectLoad(BasePath, "Prime_Vr.Namco_Arcade_Lightgun", "", "", "primevr-namco-lightgun", "");
		GameAPI.PreloadAllAssets(Path.Combine(BasePath, "mw_namco_arcade_lightgun"));
	}
}