Decompiled source of JetfireJim Pistol v1.0.0

JetfireJim_Pistol.dll

Decompiled 2 days 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 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 AdvanceLaserSightComponent : LaserLightAttachment
{
	public Transform KnobMesh;

	public Vector3 RotationAxis = Vector3.up;

	public List<float> CustomRotationAngles;

	public GameObject ControlledGameObject;

	public bool[] GameObjectEnableFlags;

	public AudioEvent SettingSwapSound;

	private int previousSettingsIndex = -1;

	private void Start()
	{
		UpdateKnobRotationAndGameObject();
	}

	private void Update()
	{
		UpdateKnobRotationAndGameObject();
	}

	private void UpdateKnobRotationAndGameObject()
	{
		//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)
		if ((Object)(object)KnobMesh != (Object)null && base.Settings.Count > 0 && CustomRotationAngles.Count == base.Settings.Count && GameObjectEnableFlags.Length == base.Settings.Count)
		{
			float num = CustomRotationAngles[base.SettingsIndex];
			KnobMesh.localEulerAngles = RotationAxis * num;
			UpdateControlledGameObject(base.SettingsIndex);
			if (base.SettingsIndex != previousSettingsIndex)
			{
				PlaySettingSwapSound();
				previousSettingsIndex = base.SettingsIndex;
			}
		}
	}

	private void UpdateControlledGameObject(int settingIndex)
	{
		if ((Object)(object)ControlledGameObject != (Object)null)
		{
			ControlledGameObject.SetActive(GameObjectEnableFlags[settingIndex]);
		}
	}

	private void PlaySettingSwapSound()
	{
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		if (SettingSwapSound != null && SettingSwapSound.Clips.Count > 0)
		{
			AudioClip val = SettingSwapSound.Clips[Random.Range(0, SettingSwapSound.Clips.Count)];
			AudioSource.PlayClipAtPoint(val, ((Component)this).transform.position, Random.Range(SettingSwapSound.VolumeRange.x, SettingSwapSound.VolumeRange.y));
		}
	}
}
public class DiceFaceDetector : MonoBehaviour
{
	public ParticleSystem effect;

	public Transform faceOneMarker;

	public float checkThreshold = 0.9f;

	public float cooldownTime = 2f;

	private float lastTriggerTime = 0f;

	private void Update()
	{
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)faceOneMarker == (Object)null) && !(Time.time - lastTriggerTime < cooldownTime) && Vector3.Dot(faceOneMarker.up, Vector3.up) > checkThreshold)
		{
			TriggerEffect();
		}
	}

	private void TriggerEffect()
	{
		if ((Object)(object)effect != (Object)null)
		{
			effect.Play();
			lastTriggerTime = Time.time;
		}
	}
}
public class OpenBoltAltHandle : FVRInteractiveObject
{
	public enum HandleRot
	{
		Down,
		Mid,
		Up
	}

	public enum HandleState
	{
		Forward,
		Mid,
		Rear
	}

	[Header("References")]
	public OpenBoltReceiver Receiver;

	public OpenBoltReceiverBolt Bolt;

	[Header("Linear Travel")]
	public Transform Point_Fore;

	public Transform Point_Rear;

	public float ForwardSpeed = 1.5f;

	[Header("Rotation / Tilt")]
	public Transform BoltHandleRoot;

	public Transform BoltHandle;

	public float MinRot = 0f;

	public float MaxRot = 90f;

	public float UnlockThreshold = 65f;

	public float LockThreshold = 5f;

	public float RotateSnapSpeed = 270f;

	public HandleRot CurRot = HandleRot.Down;

	public HandleRot LastRot = HandleRot.Down;

	public HandleState CurState = HandleState.Forward;

	public HandleState LastState = HandleState.Forward;

	private float m_boltZ_forward;

	private float m_boltZ_rear;

	private float m_currentHandleZ;

	private float m_rotAngle;

	private bool m_hasReleasedBolt;

	protected 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)
		((FVRInteractiveObject)this).Awake();
		m_boltZ_forward = Point_Fore.localPosition.z;
		m_boltZ_rear = Point_Rear.localPosition.z;
		m_currentHandleZ = BoltHandleRoot.localPosition.z;
		m_rotAngle = MinRot;
		m_hasReleasedBolt = true;
	}

	public override void UpdateInteraction(FVRViveHand hand)
	{
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		((FVRInteractiveObject)this).UpdateInteraction(hand);
		UpdateRotationFromHand(hand);
		if (CurRot == HandleRot.Up || CurState != 0)
		{
			Vector3 closestValidPoint = ((FVRInteractiveObject)this).GetClosestValidPoint(Point_Fore.position, Point_Rear.position, ((HandInput)(ref hand.Input)).Pos);
			BoltHandleRoot.position = closestValidPoint;
			m_currentHandleZ = BoltHandleRoot.localPosition.z;
		}
		UpdateHandleState();
		UpdateRotState();
		if (CurState != 0)
		{
			float num = Mathf.InverseLerp(m_boltZ_forward, m_boltZ_rear, m_currentHandleZ);
			Bolt.ChargingHandleHeld(num);
		}
		else if (CurRot != 0)
		{
			Bolt.ChargingHandleHeld(0f);
		}
		if (CurState == HandleState.Forward && CurRot == HandleRot.Down)
		{
			if (!m_hasReleasedBolt)
			{
				Bolt.ChargingHandleReleased();
				m_hasReleasedBolt = true;
			}
		}
		else
		{
			m_hasReleasedBolt = false;
		}
		HandleRotAudioEvents();
		HandleStateAudioEvents();
		LastRot = CurRot;
		LastState = CurState;
	}

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

	protected void FVRUpdate()
	{
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: 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_0085: 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)
		((FVRInteractiveObject)this).FVRUpdate();
		if (((FVRInteractiveObject)this).IsHeld)
		{
			return;
		}
		if (Mathf.Abs(m_currentHandleZ - m_boltZ_forward) > 0.001f)
		{
			m_currentHandleZ = Mathf.MoveTowards(m_currentHandleZ, m_boltZ_forward, Time.deltaTime * ForwardSpeed);
			BoltHandleRoot.localPosition = new Vector3(BoltHandleRoot.localPosition.x, BoltHandleRoot.localPosition.y, m_currentHandleZ);
			if (CurState != 0)
			{
				float num = Mathf.InverseLerp(m_boltZ_forward, m_boltZ_rear, m_currentHandleZ);
				Bolt.ChargingHandleHeld(num);
			}
		}
		if ((CurState == HandleState.Forward || CurState == HandleState.Mid) && m_rotAngle > MinRot + 0.5f)
		{
			m_rotAngle = Mathf.MoveTowards(m_rotAngle, MinRot, Time.deltaTime * RotateSnapSpeed);
			BoltHandle.localEulerAngles = new Vector3(0f, 0f, m_rotAngle);
		}
		UpdateHandleState();
		UpdateRotState();
		if (CurState == HandleState.Forward && CurRot == HandleRot.Down && !m_hasReleasedBolt)
		{
			Bolt.ChargingHandleReleased();
			m_hasReleasedBolt = true;
		}
		HandleStateAudioEvents();
		HandleRotAudioEvents();
		LastRot = CurRot;
		LastState = CurState;
	}

	private void UpdateRotationFromHand(FVRViveHand hand)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: 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_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: 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_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = ((HandInput)(ref hand.Input)).Pos - BoltHandle.position;
		Vector3 val2 = Vector3.ProjectOnPlane(val, BoltHandleRoot.forward);
		val = ((Vector3)(ref val2)).normalized;
		Vector3 right = BoltHandleRoot.right;
		float num = Mathf.Atan2(Vector3.Dot(BoltHandleRoot.forward, Vector3.Cross(right, val)), Vector3.Dot(right, val)) * 57.29578f;
		m_rotAngle = Mathf.Clamp(num, MinRot, MaxRot);
		BoltHandle.localEulerAngles = new Vector3(0f, 0f, m_rotAngle);
	}

	private void UpdateRotState()
	{
		if (m_rotAngle >= UnlockThreshold)
		{
			CurRot = HandleRot.Up;
		}
		else if (m_rotAngle <= MinRot + LockThreshold)
		{
			CurRot = HandleRot.Down;
		}
		else
		{
			CurRot = HandleRot.Mid;
		}
	}

	private void UpdateHandleState()
	{
		if (Mathf.Abs(m_currentHandleZ - m_boltZ_forward) < 0.005f)
		{
			CurState = HandleState.Forward;
		}
		else if (Mathf.Abs(m_currentHandleZ - m_boltZ_rear) < 0.005f)
		{
			CurState = HandleState.Rear;
		}
		else
		{
			CurState = HandleState.Mid;
		}
	}

	private void HandleRotAudioEvents()
	{
		if (!((Object)(object)Receiver == (Object)null))
		{
			if (CurRot == HandleRot.Up && LastRot != HandleRot.Up)
			{
				((FVRFireArm)Receiver).PlayAudioEvent((FirearmAudioEventType)12, 1f);
			}
			else if (CurRot == HandleRot.Down && LastRot != 0)
			{
				((FVRFireArm)Receiver).PlayAudioEvent((FirearmAudioEventType)13, 1f);
			}
		}
	}

	private void HandleStateAudioEvents()
	{
		if (!((Object)(object)Receiver == (Object)null))
		{
			if (CurState == HandleState.Rear && LastState != HandleState.Rear)
			{
				((FVRFireArm)Receiver).PlayAudioEvent((FirearmAudioEventType)10, 1f);
			}
			else if (CurState == HandleState.Forward && LastState != 0)
			{
				((FVRFireArm)Receiver).PlayAudioEvent((FirearmAudioEventType)11, 1f);
			}
		}
	}
}
namespace Volks.JetfireJim_Pistol;

[BepInPlugin("Volks.JetfireJim_Pistol", "JetfireJim_Pistol", "1.0.0")]
[BepInProcess("h3vr.exe")]
[Description("Built with MeatKit")]
[BepInDependency("h3vr.otherloader", "1.3.0")]
public class JetfireJim_PistolPlugin : 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(), "Volks.JetfireJim_Pistol");
		OtherLoader.RegisterDirectLoad(BasePath, "Volks.JetfireJim_Pistol", "", "", "jetfirejim_pistols", "");
	}
}
public class AdvanceMagazineAudioProfile : MonoBehaviour
{
	[Header("References")]
	[Tooltip("Auto-populated from this GameObject if left empty.")]
	public FVRFireArmMagazine Magazine;

	[Header("Audio — Empty Magazine")]
	[Tooltip("Profile used for MagazineIn / MagazineOut when the magazine is empty.")]
	public FVRFirearmMagazineAudioSet EmptyProfile;

	private FVRFirearmMagazineAudioSet _originalProfileOverride;

	private bool _originalUsesOverrideInOut;

	private bool _wasEmpty;

	private void Start()
	{
		if ((Object)(object)Magazine == (Object)null)
		{
			Magazine = ((Component)this).GetComponent<FVRFireArmMagazine>();
		}
		if ((Object)(object)Magazine == (Object)null)
		{
			Debug.LogWarning((object)"[AdvanceMagazineAudioProfile] No FVRFireArmMagazine found on this GameObject.", (Object)(object)this);
			((Behaviour)this).enabled = false;
			return;
		}
		_originalProfileOverride = Magazine.ProfileOverride;
		_originalUsesOverrideInOut = Magazine.UsesOverrideInOut;
		_wasEmpty = !Magazine.HasARound();
		ApplyProfile(_wasEmpty);
	}

	private void Update()
	{
		if (!((Object)(object)Magazine == (Object)null))
		{
			bool flag = !Magazine.HasARound();
			if (flag != _wasEmpty)
			{
				_wasEmpty = flag;
				ApplyProfile(flag);
			}
		}
	}

	private void ApplyProfile(bool isEmpty)
	{
		if (isEmpty && (Object)(object)EmptyProfile != (Object)null)
		{
			Magazine.UsesOverrideInOut = true;
			Magazine.ProfileOverride = EmptyProfile;
		}
		else
		{
			Magazine.UsesOverrideInOut = _originalUsesOverrideInOut;
			Magazine.ProfileOverride = _originalProfileOverride;
		}
	}
}
public class BoltReleaseChargingHandle : MonoBehaviour
{
	public ClosedBoltWeapon Weapon;

	public ClosedBoltHandle Handle;

	public float LaunchSpeed = 5f;

	[Tooltip("If true, the handle stays at Rear until bolt release is pressed again. If false, it returns forward when pulled back manually.")]
	public bool HandleReturnsManually = false;

	private bool m_wasLocked;

	private void Start()
	{
		if ((Object)(object)Weapon == (Object)null || (Object)(object)Handle == (Object)null)
		{
			Debug.LogWarning((object)"[BoltReleaseChargingHandle] Weapon or Handle reference is missing.", (Object)(object)this);
			((Behaviour)this).enabled = false;
		}
		else
		{
			m_wasLocked = Weapon.Bolt.IsBoltLocked();
		}
	}

	private void Update()
	{
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Invalid comparison between Unknown and I4
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: Invalid comparison between Unknown and I4
		bool flag = Weapon.Bolt.IsBoltLocked();
		if (m_wasLocked && !flag && Weapon.HasBoltReleaseButton && (int)Handle.CurPos == 4)
		{
			Handle.Speed_Forward = LaunchSpeed;
		}
		if ((int)Handle.CurPos == 0 && Handle.Speed_Forward > 0f)
		{
			Handle.Speed_Forward = 0f;
		}
		if (!HandleReturnsManually && !flag && !((FVRInteractiveObject)Handle).IsHeld && (int)Handle.CurPos == 4 && Handle.Speed_Forward == 0f)
		{
			Handle.Speed_Forward = LaunchSpeed;
		}
		m_wasLocked = flag;
	}
}
public class PartRecoilImpulse : MonoBehaviour
{
	public enum ImpulseMode
	{
		Rotation,
		Translation
	}

	public enum ImpulseAxis
	{
		X,
		Y,
		Z
	}

	[Serializable]
	public class RecoilPart
	{
		public Transform Piece;

		public ImpulseMode Mode = ImpulseMode.Rotation;

		public ImpulseAxis Axis = ImpulseAxis.X;

		public Vector2 Range = new Vector2(0f, 45f);

		public float ReturnSpeed = 5f;

		public float ImpulseStrength = 1f;

		[NonSerialized]
		public float CurrentLerp = 0f;
	}

	[Header("Parts")]
	public List<RecoilPart> Parts = new List<RecoilPart>();

	private FVRFireArm m_firearm;

	private void Awake()
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Expected O, but got Unknown
		GM.CurrentSceneSettings.ShotFiredEvent += new ShotFired(OnShotFired);
	}

	private void OnDestroy()
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Expected O, but got Unknown
		if ((Object)(object)GM.CurrentSceneSettings != (Object)null)
		{
			GM.CurrentSceneSettings.ShotFiredEvent -= new ShotFired(OnShotFired);
		}
	}

	private void Start()
	{
		m_firearm = ((Component)this).GetComponentInParent<FVRFireArm>();
		if ((Object)(object)m_firearm == (Object)null)
		{
			Debug.LogWarning((object)"[PartRecoilImpulse] No FVRFireArm found in parent hierarchy.", (Object)(object)this);
		}
		for (int i = 0; i < Parts.Count; i++)
		{
			ApplyToPart(Parts[i]);
		}
	}

	private void OnShotFired(FVRFireArm firearm)
	{
		if (!((Object)(object)firearm != (Object)(object)m_firearm))
		{
			for (int i = 0; i < Parts.Count; i++)
			{
				Parts[i].CurrentLerp = Mathf.Clamp01(Parts[i].ImpulseStrength);
				ApplyToPart(Parts[i]);
			}
		}
	}

	private void Update()
	{
		for (int i = 0; i < Parts.Count; i++)
		{
			RecoilPart recoilPart = Parts[i];
			if (recoilPart.CurrentLerp > 0f)
			{
				recoilPart.CurrentLerp = Mathf.MoveTowards(recoilPart.CurrentLerp, 0f, Time.deltaTime * recoilPart.ReturnSpeed);
				ApplyToPart(recoilPart);
			}
		}
	}

	private void ApplyToPart(RecoilPart part)
	{
		//IL_00a3: 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_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_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)part.Piece == (Object)null)
		{
			return;
		}
		float num = Mathf.Lerp(part.Range.x, part.Range.y, part.CurrentLerp);
		if (part.Mode == ImpulseMode.Rotation)
		{
			Vector3 localEulerAngles = part.Piece.localEulerAngles;
			if (part.Axis == ImpulseAxis.X)
			{
				localEulerAngles.x = num;
			}
			else if (part.Axis == ImpulseAxis.Y)
			{
				localEulerAngles.y = num;
			}
			else
			{
				localEulerAngles.z = num;
			}
			part.Piece.localEulerAngles = localEulerAngles;
		}
		else
		{
			Vector3 localPosition = part.Piece.localPosition;
			if (part.Axis == ImpulseAxis.X)
			{
				localPosition.x = num;
			}
			else if (part.Axis == ImpulseAxis.Y)
			{
				localPosition.y = num;
			}
			else
			{
				localPosition.z = num;
			}
			part.Piece.localPosition = localPosition;
		}
	}
}
public class SecondaryMagPos : MonoBehaviour
{
	[Header("References")]
	public FVRFireArm FireArm;

	public FVRFireArmReloadTriggerWell TriggerWell;

	[Header("Mount Override")]
	public Transform MountPos;

	public Transform EjectPos;

	private Transform m_defaultMountPos;

	private Transform m_defaultEjectPos;

	private Vector3 m_defaultMountLocalPos;

	private Quaternion m_defaultMountLocalRot;

	private Vector3 m_defaultEjectLocalPos;

	private Quaternion m_defaultEjectLocalRot;

	private bool m_initialized = false;

	private bool m_overrideActive = false;

	private FVRFireArmMagazine m_pendingMag;

	private int m_pendingStableFrames;

	private const int kStableFramesRequired = 2;

	private FVRFireArmMagazine m_appliedMag;

	private void Start()
	{
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00da: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)FireArm == (Object)null || (Object)(object)TriggerWell == (Object)null)
		{
			((Behaviour)this).enabled = false;
			return;
		}
		if ((Object)(object)MountPos == (Object)null)
		{
			((Behaviour)this).enabled = false;
			return;
		}
		m_defaultMountPos = FireArm.MagazineMountPos;
		m_defaultEjectPos = FireArm.MagazineEjectPos;
		if ((Object)(object)m_defaultMountPos == (Object)null)
		{
			((Behaviour)this).enabled = false;
			return;
		}
		m_defaultMountLocalPos = m_defaultMountPos.localPosition;
		m_defaultMountLocalRot = m_defaultMountPos.localRotation;
		if ((Object)(object)m_defaultEjectPos != (Object)null)
		{
			m_defaultEjectLocalPos = m_defaultEjectPos.localPosition;
			m_defaultEjectLocalRot = m_defaultEjectPos.localRotation;
		}
		m_initialized = true;
		m_pendingMag = null;
		m_pendingStableFrames = 0;
		m_appliedMag = null;
	}

	private void Update()
	{
		//IL_00b1: 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_00b6: 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_00d3: Unknown result type (might be due to invalid IL or missing references)
		if (!m_initialized)
		{
			return;
		}
		FVRFireArmMagazine magazine = FireArm.Magazine;
		if ((Object)(object)magazine == (Object)(object)m_pendingMag)
		{
			if (m_pendingStableFrames < 2)
			{
				m_pendingStableFrames++;
			}
		}
		else
		{
			m_pendingMag = magazine;
			m_pendingStableFrames = 0;
		}
		if (m_pendingStableFrames < 2 || (Object)(object)m_pendingMag == (Object)(object)m_appliedMag)
		{
			return;
		}
		FireArmMagazineType val = ((!TriggerWell.UsesTypeOverride) ? FireArm.MagazineType : TriggerWell.TypeOverride);
		if ((Object)(object)m_pendingMag != (Object)null && m_pendingMag.MagazineType == val)
		{
			m_overrideActive = true;
			m_appliedMag = m_pendingMag;
			return;
		}
		if (m_overrideActive)
		{
			m_overrideActive = false;
			RestoreDefaults();
		}
		m_appliedMag = null;
	}

	private void LateUpdate()
	{
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: 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_008d: Unknown result type (might be due to invalid IL or missing references)
		if (m_initialized && m_overrideActive)
		{
			m_defaultMountPos.position = MountPos.position;
			m_defaultMountPos.rotation = MountPos.rotation;
			if ((Object)(object)m_defaultEjectPos != (Object)null && (Object)(object)EjectPos != (Object)null)
			{
				m_defaultEjectPos.position = EjectPos.position;
				m_defaultEjectPos.rotation = EjectPos.rotation;
			}
		}
	}

	private void RestoreDefaults()
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		m_defaultMountPos.localPosition = m_defaultMountLocalPos;
		m_defaultMountPos.localRotation = m_defaultMountLocalRot;
		if ((Object)(object)m_defaultEjectPos != (Object)null)
		{
			m_defaultEjectPos.localPosition = m_defaultEjectLocalPos;
			m_defaultEjectPos.localRotation = m_defaultEjectLocalRot;
		}
	}

	private void OnDisable()
	{
		if (m_initialized)
		{
			RestoreDefaults();
		}
	}

	private void OnDestroy()
	{
		if (m_initialized)
		{
			RestoreDefaults();
		}
	}
}
public class InvertClosedBolt : MonoBehaviour
{
	public Transform OptionalLockPointOverride;

	private void Start()
	{
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		ClosedBolt component = ((Component)this).GetComponent<ClosedBolt>();
		if ((Object)(object)component == (Object)null)
		{
			Debug.LogWarning((object)"[InvertClosedBolt] No ClosedBolt component found on this GameObject.");
			return;
		}
		Transform point_Bolt_Forward = component.Point_Bolt_Forward;
		component.Point_Bolt_Forward = component.Point_Bolt_Rear;
		component.Point_Bolt_Rear = point_Bolt_Forward;
		if ((Object)(object)OptionalLockPointOverride != (Object)null)
		{
			component.Point_Bolt_LockPoint = OptionalLockPointOverride;
		}
		SetPrivateFloat(component, "m_boltZ_forward", LocalZ(component.Point_Bolt_Forward));
		SetPrivateFloat(component, "m_boltZ_rear", LocalZ(component.Point_Bolt_Rear));
		SetPrivateFloat(component, "m_boltZ_lock", LocalZ(component.Point_Bolt_LockPoint));
		SetPrivateFloat(component, "m_boltZ_current", ((Component)component).transform.localPosition.z);
		if (component.UsesAKSafetyLock && (Object)(object)component.Point_Bolt_SafetyLock != (Object)null)
		{
			SetPrivateFloat(component, "m_boltZ_safetylock", LocalZ(component.Point_Bolt_SafetyLock));
		}
		component.SnapToRear();
		component.UpdateBolt();
	}

	private static float LocalZ(Transform t)
	{
		//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)
		return (!((Object)(object)t != (Object)null)) ? 0f : t.localPosition.z;
	}

	private static void SetPrivateFloat(ClosedBolt cb, string name, float value)
	{
		typeof(ClosedBolt).GetField(name, BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(cb, value);
	}
}
internal class AutoReleaseOnMagLoad : MonoBehaviour
{
	private FVRFireArm weapon;

	private Handgun handgun;

	private bool wasLoaded;

	public void Start()
	{
		weapon = ((Component)this).GetComponent<FVRFireArm>();
		if (!((Object)(object)weapon == (Object)null) && weapon is Handgun)
		{
			ref Handgun reference = ref handgun;
			FVRFireArm obj = weapon;
			reference = (Handgun)(object)((obj is Handgun) ? obj : null);
		}
	}

	public void FixedUpdate()
	{
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Invalid comparison between Unknown and I4
		if ((Object)(object)handgun != (Object)null)
		{
			if ((Object)(object)weapon.Magazine != (Object)null)
			{
				if (weapon.Magazine.HasARound())
				{
					if ((int)handgun.Slide.CurPos >= 2 && !wasLoaded)
					{
						handgun.Slide.ImpartFiringImpulse();
						wasLoaded = true;
					}
				}
				else
				{
					wasLoaded = false;
				}
			}
			else
			{
				wasLoaded = false;
			}
		}
		else
		{
			wasLoaded = false;
		}
	}
}
public class StreamlineDecocker : MonoBehaviour
{
	public enum EStreamlineInputType
	{
		AXButton,
		BYButton
	}

	public enum EInputType
	{
		TouchpadUp,
		TouchpadDown,
		TouchpadLeft,
		TouchpadRight
	}

	[Header("Manual Handgun Decocker")]
	public Handgun Handgun;

	[Header("Streamlined Controls Input")]
	public EStreamlineInputType StreamlineInputType;

	[Header("Classic Controls Input")]
	public EInputType InputType;

	[Tooltip("Use this if you wanna use the safety as it is configured on the handgun itself.")]
	public bool UsesHandgunSafetyObjectInstead = false;

	[Header("Standalone decocker object.")]
	public Transform Decocker;

	public Axis DecockerAxis;

	public InterpStyle DecockerInterpStyle;

	public float DecockerReleased;

	public float DecockerPressed;

	private bool _wasDecocked = false;

	public void Update()
	{
		//IL_012e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0139: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f7: 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_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)Handgun == (Object)null)
		{
			return;
		}
		FVRViveHand hand = ((FVRInteractiveObject)Handgun).m_hand;
		if ((Object)(object)hand != (Object)null && CorrectInput(hand))
		{
			if (!_wasDecocked)
			{
				Handgun.DeCockHammer(true, true);
				if (!UsesHandgunSafetyObjectInstead)
				{
					((FVRPhysicalObject)Handgun).SetAnimatedComponent(Decocker, DecockerPressed, DecockerInterpStyle, DecockerAxis);
				}
				else
				{
					((FVRPhysicalObject)Handgun).SetAnimatedComponent(Handgun.Safety, Handgun.SafetyOn, Handgun.Safety_Interp, Handgun.SafetyAxis);
				}
				_wasDecocked = true;
			}
		}
		else if (_wasDecocked)
		{
			if (!UsesHandgunSafetyObjectInstead)
			{
				((FVRPhysicalObject)Handgun).SetAnimatedComponent(Decocker, DecockerReleased, DecockerInterpStyle, DecockerAxis);
			}
			else
			{
				((FVRPhysicalObject)Handgun).SetAnimatedComponent(Handgun.Safety, Handgun.SafetyOff, Handgun.Safety_Interp, Handgun.SafetyAxis);
			}
			_wasDecocked = false;
		}
	}

	private bool CorrectInput(FVRViveHand hand)
	{
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		if (hand.IsInStreamlinedMode)
		{
			return StreamlineInputType switch
			{
				EStreamlineInputType.AXButton => hand.Input.AXButtonPressed, 
				EStreamlineInputType.BYButton => hand.Input.BYButtonDown, 
				_ => false, 
			};
		}
		Vector2 dir;
		switch (InputType)
		{
		case EInputType.TouchpadUp:
			dir = Vector2.up;
			break;
		case EInputType.TouchpadDown:
			dir = Vector2.down;
			break;
		case EInputType.TouchpadLeft:
			dir = Vector2.left;
			break;
		case EInputType.TouchpadRight:
			dir = Vector2.right;
			break;
		default:
			return false;
		}
		return TouchpadDirPressed(hand, dir);
	}

	private bool TouchpadDirPressed(FVRViveHand hand, Vector2 dir)
	{
		//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_0025: 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)
		Vector2 touchpadAxes = hand.Input.TouchpadAxes;
		if (((Vector2)(ref touchpadAxes)).magnitude <= 0.2f)
		{
			return false;
		}
		float num = Vector2.Angle(touchpadAxes, dir);
		if (num > 45f)
		{
			return false;
		}
		if (hand.Input.TouchpadDown || hand.Input.TouchpadPressed)
		{
			return true;
		}
		return false;
	}
}