Decompiled source of CarlGustaf Qol v1.0.0

CarlGustaf_Qol.dll

Decompiled 2 days ago
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]
namespace JerryCGQol
{
	[BepInPlugin("JerryCGQol.JerryCGQol", "JCGQ", "1.0.0")]
	[BepInDependency("nrgill28.Sodalite", "1.4.1")]
	[BepInProcess("h3vr.exe")]
	public class CGQol : BaseUnityPlugin
	{
		public FVRViveHand Hand;

		public FVRFireArmChamber Chamber;

		public CarlGustafShellInsertEject[] CGSIEs;

		public FVRFireArmRound[] CGRounds;

		public float cd = 0.5f;

		private void FixedUpdate()
		{
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Invalid comparison between Unknown and I4
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Invalid comparison between Unknown and I4
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Invalid comparison between Unknown and I4
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Invalid comparison between Unknown and I4
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Invalid comparison between Unknown and I4
			//IL_0474: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: 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_036d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0372: Unknown result type (might be due to invalid IL or missing references)
			//IL_038e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0393: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0577: Unknown result type (might be due to invalid IL or missing references)
			//IL_057c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0596: Unknown result type (might be due to invalid IL or missing references)
			//IL_059b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0627: Unknown result type (might be due to invalid IL or missing references)
			//IL_062c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0646: Unknown result type (might be due to invalid IL or missing references)
			//IL_064b: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b2: Invalid comparison between Unknown and I4
			//IL_06ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_06df: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0710: Unknown result type (might be due to invalid IL or missing references)
			//IL_074a: Unknown result type (might be due to invalid IL or missing references)
			//IL_075b: Unknown result type (might be due to invalid IL or missing references)
			//IL_077b: Unknown result type (might be due to invalid IL or missing references)
			//IL_078c: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)GM.CurrentMovementManager != (Object)null))
			{
				return;
			}
			cd -= Time.deltaTime;
			if (cd <= 0f)
			{
				CGRounds = Object.FindObjectsOfType<FVRFireArmRound>();
				CGSIEs = Object.FindObjectsOfType<CarlGustafShellInsertEject>();
				cd = 0.5f;
			}
			FVRFireArmRound[] cGRounds = CGRounds;
			foreach (FVRFireArmRound val in cGRounds)
			{
				if ((Object)(object)val != (Object)null && (int)val.RoundType == 149)
				{
					if ((int)val.RoundClass == 235 && (Object)(object)((Component)val).gameObject.GetComponent<CGRoundQol>() == (Object)null)
					{
						CGRoundQol cGRoundQol = ((Component)val).gameObject.AddComponent<CGRoundQol>();
						cGRoundQol.isHE = true;
					}
					if ((int)val.RoundClass == 238 && (Object)(object)((Component)val).gameObject.GetComponent<CGRoundQol>() == (Object)null)
					{
						CGRoundQol cGRoundQol2 = ((Component)val).gameObject.AddComponent<CGRoundQol>();
						cGRoundQol2.isIlum = true;
					}
					if ((int)val.RoundClass != 238 && (int)val.RoundClass != 235)
					{
						CGRoundQol cGRoundQol3 = ((Component)val).gameObject.AddComponent<CGRoundQol>();
					}
				}
			}
			CarlGustafShellInsertEject[] cGSIEs = CGSIEs;
			foreach (CarlGustafShellInsertEject val2 in cGSIEs)
			{
				if (!((Object)(object)val2 != (Object)null))
				{
					continue;
				}
				if ((Object)(object)((Component)((FVRFireArm)val2.CG).MuzzlePos).gameObject.GetComponentInChildren<CGSightToggle>() == (Object)null)
				{
					ItemSpawnerID spawnerID = IM.GetSpawnerID("CG84Mount");
					FVRObject mainObject = spawnerID.MainObject;
					GameObject val3 = Object.Instantiate<GameObject>(((AnvilAsset)mainObject).GetGameObject(), ((Component)((FVRFireArm)val2.CG).MuzzlePos).gameObject.transform);
					if ((Object)(object)val3.GetComponent<CGSightToggle>() != (Object)null)
					{
						val3.GetComponent<CGSightToggle>().CG = val2.CG;
					}
					if ((Object)(object)val3.GetComponent<FVRPhysicalObject>() != (Object)null)
					{
						Object.Destroy((Object)(object)val3.GetComponent<FVRPhysicalObject>());
					}
				}
				if ((Object)(object)((Component)((Component)val2).transform.parent).transform.parent.Find("RearSight") != (Object)null)
				{
					GameObject gameObject = ((Component)((Component)((Component)val2).transform.parent).transform.parent.Find("RearSight")).gameObject;
					if ((Object)(object)gameObject.GetComponent<AR15HandleSightFlipper>() == (Object)null)
					{
						AR15HandleSightFlipper val4 = gameObject.AddComponent<AR15HandleSightFlipper>();
						((FVRInteractiveObject)val4).IsSimpleInteract = true;
						((FVRInteractiveObject)val4).EndInteractionIfDistant = false;
						val4.Flipsight = gameObject.transform;
						val4.RotAxis = (Axis)1;
						val4.m_flipsightStartRotX = 0f;
						val4.m_flipsightEndRotX = 90f;
						SphereCollider val5 = gameObject.AddComponent<SphereCollider>();
						val5.radius = 0.02f;
						val5.center = new Vector3(-0.029f, -0.02f, 0f);
						((Collider)val5).isTrigger = true;
						gameObject.layer = 10;
					}
					if ((Object)(object)((Component)((Component)val2).transform.parent).transform.parent.Find("FrontSight_7_5") != (Object)null)
					{
						GameObject gameObject2 = ((Component)((Component)((Component)val2).transform.parent).transform.parent.Find("FrontSight_7_5")).gameObject;
						gameObject2.transform.localEulerAngles = new Vector3(Mathf.Lerp(352.5f, 360f, 1f - gameObject.transform.localEulerAngles.y / 90f), 0f - gameObject.transform.localEulerAngles.y, Mathf.Lerp(352.5f, 360f, gameObject2.transform.localEulerAngles.y / 90f));
					}
				}
				if ((Object)(object)((Component)((FVRFireArm)val2.CG).MuzzlePos).gameObject.GetComponent<CGRearGrab>() == (Object)null)
				{
					CGRearGrab cGRearGrab = ((Component)((FVRFireArm)val2.CG).MuzzlePos).gameObject.AddComponent<CGRearGrab>();
					((FVRInteractiveObject)cGRearGrab).EndInteractionIfDistant = false;
					cGRearGrab.CG = val2.CG;
					((Component)((FVRFireArm)val2.CG).MuzzlePos).gameObject.layer = 10;
					CapsuleCollider val6 = ((Component)((FVRFireArm)val2.CG).MuzzlePos).gameObject.AddComponent<CapsuleCollider>();
					((Collider)val6).isTrigger = true;
					val6.direction = 2;
					val6.center = new Vector3(0f, 0f, -0.6f);
					val6.radius = 0.05f;
					val6.height = 0.5f;
				}
				if ((Object)(object)((Component)val2.CG.ChargingHandle).gameObject.GetComponent<Mac11_Stock>() == (Object)null)
				{
					Mac11_Stock val7 = ((Component)val2.CG.ChargingHandle).gameObject.AddComponent<Mac11_Stock>();
					((FVRInteractiveObject)val7).EndInteractionIfDistant = false;
					val7.ForwardPos = val2.CG.ChargingHandForward;
					val7.RearPos = val2.CG.ChargingHandBack;
					((Component)val2.CG.ChargingHandle).gameObject.layer = 10;
					SphereCollider val8 = ((Component)val2.CG.ChargingHandle).gameObject.AddComponent<SphereCollider>();
					((Collider)val8).isTrigger = true;
					val8.radius = 0.025f;
				}
				if ((Object)(object)((Component)val2.CG.ChargingHandle).gameObject.GetComponent<Mac11_Stock>() != (Object)null)
				{
					if (((Component)val2.CG.ChargingHandle).transform.localPosition.z > ((Component)val2.CG.ChargingHandForward).transform.localPosition.z - 0.01f && ((FVRInteractiveObject)((Component)val2.CG.ChargingHandle).gameObject.GetComponent<Mac11_Stock>()).m_isHeld)
					{
						((FVRInteractiveObject)((Component)val2.CG.ChargingHandle).gameObject.GetComponent<Mac11_Stock>()).ForceBreakInteraction();
						val2.CG.TryToChargeHandle();
						((FVRInteractiveObject)((Component)val2.CG.ChargingHandle).gameObject.GetComponent<Mac11_Stock>()).IsSimpleInteract = true;
					}
					if (((Component)val2.CG.ChargingHandle).transform.localPosition.z <= ((Component)val2.CG.ChargingHandForward).transform.localPosition.z - 0.01f)
					{
						((FVRInteractiveObject)((Component)val2.CG.ChargingHandle).gameObject.GetComponent<Mac11_Stock>()).IsSimpleInteract = false;
					}
				}
				if (val2.CG.Chamber.IsFull && !val2.CG.Chamber.IsSpent && (int)val2.CSState == 2)
				{
					if (Vector3.Distance(((Component)GM.CurrentMovementManager.Hands[0]).gameObject.transform.position, val2.CG.ChargingHandBack.position) < Vector3.Distance(((Component)GM.CurrentMovementManager.Hands[1]).gameObject.transform.position, val2.CG.ChargingHandBack.position))
					{
						GM.CurrentMovementManager.Hands[1].ForceSetInteractable((FVRInteractiveObject)(object)val2);
					}
					if (Vector3.Distance(((Component)GM.CurrentMovementManager.Hands[0]).gameObject.transform.position, val2.CG.ChargingHandBack.position) > Vector3.Distance(((Component)GM.CurrentMovementManager.Hands[1]).gameObject.transform.position, val2.CG.ChargingHandBack.position))
					{
						GM.CurrentMovementManager.Hands[0].ForceSetInteractable((FVRInteractiveObject)(object)val2);
					}
				}
			}
		}
	}
	public class CGRearGrab : FVRInteractiveObject
	{
		public CarlGustaf CG;

		public bool IsAltgrabbed;

		public FVRViveHand curhand;

		private void FixedUpdate()
		{
			if (IsAltgrabbed)
			{
				if ((Object)(object)((FVRFireArm)CG).Foregrip.gameObject.GetComponent<Collider>() != (Object)null)
				{
					((FVRFireArm)CG).Foregrip.gameObject.GetComponent<Collider>().enabled = false;
				}
				((Component)this).gameObject.GetComponent<Collider>().enabled = false;
			}
			if (!IsAltgrabbed)
			{
				if ((Object)(object)((FVRFireArm)CG).Foregrip.gameObject.GetComponent<Collider>() != (Object)null)
				{
					((FVRFireArm)CG).Foregrip.gameObject.GetComponent<Collider>().enabled = true;
				}
				((Component)this).gameObject.GetComponent<Collider>().enabled = true;
			}
			if (base.m_isHeld && (Object)(object)CG != (Object)null)
			{
				if (!((FVRInteractiveObject)CG).m_isHeld && !((FVRPhysicalObject)CG).IsAltHeld && !IsAltgrabbed)
				{
					if ((Object)(object)base.m_hand != (Object)null)
					{
						curhand = base.m_hand;
					}
					if ((Object)(object)curhand != (Object)null)
					{
						((FVRPhysicalObject)CG).BeginInteractionThroughAltGrip(curhand, ((FVRPhysicalObject)CG).m_altGrip);
						IsAltgrabbed = true;
					}
				}
				if (((FVRInteractiveObject)CG).m_isHeld && ((FVRPhysicalObject)CG).IsAltHeld && (Object)(object)((FVRInteractiveObject)CG).m_hand != (Object)null)
				{
					((FVRInteractiveObject)CG).BeginInteraction(((FVRInteractiveObject)CG).m_hand);
				}
			}
			if (!((Object)(object)CG != (Object)null))
			{
				return;
			}
			if (!((FVRInteractiveObject)CG).m_isHeld)
			{
				IsAltgrabbed = false;
				curhand = null;
			}
			if (((FVRInteractiveObject)CG).m_isHeld && (Object)(object)curhand != (Object)null && (Object)(object)((FVRInteractiveObject)CG).m_hand != (Object)null && (Object)(object)((FVRInteractiveObject)CG).m_hand == (Object)(object)curhand.OtherHand && (Object)(object)curhand.OtherHand.m_currentInteractable != (Object)null)
			{
				if ((Object)(object)curhand.OtherHand.m_currentInteractable == (Object)(object)CG || (Object)(object)curhand.OtherHand.m_currentInteractable == (Object)(object)((FVRPhysicalObject)CG).m_altGrip)
				{
					((FVRInteractiveObject)CG).BeginInteraction(curhand.OtherHand);
				}
				((FVRPhysicalObject)CG).IsAltHeld = false;
				IsAltgrabbed = false;
				curhand = null;
			}
		}
	}
	public class CGRoundQol : MonoBehaviour
	{
		public FVRFireArmRound Round;

		public bool isHE;

		public bool isIlum;

		public FVRInteractiveObject GrabKnob;

		public float lastRot;

		public float curRot;

		public GameObject rot;

		public GameObject rotlerp;

		public GameObject WarHead;

		public GameObject Indicator;

		public bool isGrab = false;

		public bool Spawned = false;

		public void Start()
		{
			Round = ((Component)this).gameObject.GetComponent<FVRFireArmRound>();
		}

		private void FixedUpdate()
		{
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: 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_0681: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_044e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0599: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c7a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c90: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c95: Unknown result type (might be due to invalid IL or missing references)
			//IL_0956: Unknown result type (might be due to invalid IL or missing references)
			//IL_095b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0971: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cfa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d13: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d18: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d31: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a49: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a4e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a6c: Unknown result type (might be due to invalid IL or missing references)
			//IL_09a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_09ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_09d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_09de: Unknown result type (might be due to invalid IL or missing references)
			//IL_09f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ab7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0abc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ada: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d53: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d58: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b25: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b2a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b48: Unknown result type (might be due to invalid IL or missing references)
			//IL_10af: Unknown result type (might be due to invalid IL or missing references)
			//IL_10b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_10cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_10e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_10e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0de3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0de8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d76: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d7b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b93: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b98: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bb6: Unknown result type (might be due to invalid IL or missing references)
			//IL_1170: Unknown result type (might be due to invalid IL or missing references)
			//IL_1175: Unknown result type (might be due to invalid IL or missing references)
			//IL_1103: Unknown result type (might be due to invalid IL or missing references)
			//IL_1108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e88: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e8d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ea4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0eb9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ebe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e06: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e0b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0da9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0dcd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c01: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c06: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c24: Unknown result type (might be due to invalid IL or missing references)
			//IL_1200: Unknown result type (might be due to invalid IL or missing references)
			//IL_1205: Unknown result type (might be due to invalid IL or missing references)
			//IL_1193: Unknown result type (might be due to invalid IL or missing references)
			//IL_1198: Unknown result type (might be due to invalid IL or missing references)
			//IL_1136: Unknown result type (might be due to invalid IL or missing references)
			//IL_115a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f4e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f53: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ee1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ee6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e39: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e5d: Unknown result type (might be due to invalid IL or missing references)
			//IL_1290: Unknown result type (might be due to invalid IL or missing references)
			//IL_1295: Unknown result type (might be due to invalid IL or missing references)
			//IL_1223: Unknown result type (might be due to invalid IL or missing references)
			//IL_1228: Unknown result type (might be due to invalid IL or missing references)
			//IL_11c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_11ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fde: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fe3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f71: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f76: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f14: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f38: Unknown result type (might be due to invalid IL or missing references)
			//IL_1320: Unknown result type (might be due to invalid IL or missing references)
			//IL_1325: Unknown result type (might be due to invalid IL or missing references)
			//IL_12b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_12b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_1256: Unknown result type (might be due to invalid IL or missing references)
			//IL_127a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fa4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fc8: Unknown result type (might be due to invalid IL or missing references)
			//IL_1382: Unknown result type (might be due to invalid IL or missing references)
			//IL_1387: Unknown result type (might be due to invalid IL or missing references)
			//IL_1343: Unknown result type (might be due to invalid IL or missing references)
			//IL_1348: Unknown result type (might be due to invalid IL or missing references)
			//IL_12e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_130a: Unknown result type (might be due to invalid IL or missing references)
			//IL_13e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_13e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_13a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_13aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_1446: Unknown result type (might be due to invalid IL or missing references)
			//IL_144b: Unknown result type (might be due to invalid IL or missing references)
			//IL_1407: Unknown result type (might be due to invalid IL or missing references)
			//IL_140c: Unknown result type (might be due to invalid IL or missing references)
			//IL_14a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_14ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_1469: Unknown result type (might be due to invalid IL or missing references)
			//IL_146e: Unknown result type (might be due to invalid IL or missing references)
			//IL_14cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_14d0: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)Round != (Object)null))
			{
				return;
			}
			if (((FVRInteractiveObject)Round).m_isHeld)
			{
				if ((Object)(object)((FVRInteractiveObject)Round).m_hand.OtherHand.m_currentInteractable != (Object)null)
				{
					if ((Object)(object)((Component)((FVRInteractiveObject)Round).m_hand.OtherHand.m_currentInteractable).gameObject.GetComponent<CarlGustaf>() != (Object)null)
					{
						((Component)((FVRInteractiveObject)Round).PoseOverride).gameObject.transform.localEulerAngles = new Vector3(225f, 0f, 0f);
						if ((Object)(object)WarHead != (Object)null && (Object)(object)WarHead.gameObject.GetComponent<Collider>() != (Object)null)
						{
							WarHead.gameObject.GetComponent<Collider>().enabled = false;
						}
					}
					if ((Object)(object)((Component)((FVRInteractiveObject)Round).m_hand.OtherHand.m_currentInteractable).gameObject.GetComponent<CarlGustaf>() == (Object)null)
					{
						((Component)((FVRInteractiveObject)Round).PoseOverride).gameObject.transform.localEulerAngles = new Vector3(35f, 0f, 0f);
						if ((Object)(object)WarHead != (Object)null && (Object)(object)WarHead.gameObject.GetComponent<Collider>() != (Object)null)
						{
							WarHead.gameObject.GetComponent<Collider>().enabled = true;
						}
					}
				}
				if ((Object)(object)((FVRInteractiveObject)Round).m_hand.OtherHand.m_currentInteractable == (Object)null)
				{
					((Component)((FVRInteractiveObject)Round).PoseOverride).gameObject.transform.localEulerAngles = new Vector3(35f, 0f, 0f);
					if ((Object)(object)WarHead != (Object)null && (Object)(object)WarHead.gameObject.GetComponent<Collider>() != (Object)null)
					{
						WarHead.gameObject.GetComponent<Collider>().enabled = true;
					}
				}
			}
			if (!((FVRInteractiveObject)Round).m_isHeld && (Object)(object)WarHead != (Object)null)
			{
				((Component)((FVRInteractiveObject)Round).PoseOverride).gameObject.transform.localEulerAngles = new Vector3(35f, 0f, 0f);
				if ((Object)(object)WarHead.gameObject.GetComponent<Collider>() != (Object)null)
				{
					WarHead.gameObject.GetComponent<Collider>().enabled = true;
				}
			}
			if ((isHE || isIlum) && !Spawned)
			{
				if (isHE || isIlum)
				{
					curRot = 0f;
					lastRot = 0f;
					ItemSpawnerID spawnerID = IM.GetSpawnerID("CG84Rot");
					FVRObject mainObject = spawnerID.MainObject;
					rot = Object.Instantiate<GameObject>(((AnvilAsset)mainObject).GetGameObject(), ((Component)Round).gameObject.transform);
					if ((Object)(object)rot.GetComponent<FVRPhysicalObject>() != (Object)null)
					{
						Object.Destroy((Object)(object)rot.GetComponent<FVRPhysicalObject>());
					}
					ItemSpawnerID spawnerID2 = IM.GetSpawnerID("CG84RotLerp");
					FVRObject mainObject2 = spawnerID2.MainObject;
					rotlerp = Object.Instantiate<GameObject>(((AnvilAsset)mainObject2).GetGameObject(), ((Component)Round).gameObject.transform);
					if ((Object)(object)rotlerp.GetComponent<FVRPhysicalObject>() != (Object)null)
					{
						Object.Destroy((Object)(object)rotlerp.GetComponent<FVRPhysicalObject>());
					}
					if (isHE)
					{
						ItemSpawnerID spawnerID3 = IM.GetSpawnerID("HE441BWarHead");
						FVRObject mainObject3 = spawnerID3.MainObject;
						WarHead = Object.Instantiate<GameObject>(((AnvilAsset)mainObject3).GetGameObject(), ((Component)Round).gameObject.transform);
						if ((Object)(object)WarHead.GetComponent<FVRPhysicalObject>() != (Object)null)
						{
							Object.Destroy((Object)(object)WarHead.GetComponent<FVRPhysicalObject>());
							GrabKnob = WarHead.AddComponent<FVRInteractiveObject>();
							SphereCollider val = WarHead.AddComponent<SphereCollider>();
							val.radius = 0.04f;
							val.center = new Vector3(0f, 0f, -0.05f);
							((Collider)val).isTrigger = true;
							WarHead.layer = 10;
							GrabKnob.EndInteractionIfDistant = false;
						}
						ItemSpawnerID spawnerID4 = IM.GetSpawnerID("CG84IndiHE");
						FVRObject mainObject4 = spawnerID4.MainObject;
						Indicator = Object.Instantiate<GameObject>(((AnvilAsset)mainObject4).GetGameObject(), ((Component)Round).gameObject.transform);
						if ((Object)(object)Indicator.GetComponent<FVRPhysicalObject>() != (Object)null)
						{
							Object.Destroy((Object)(object)Indicator.GetComponent<FVRPhysicalObject>());
						}
						Round.BallisticProjectilePrefab.GetComponent<BallisticProjectile>().MaxRange = 5000f;
					}
					if (isIlum)
					{
						ItemSpawnerID spawnerID5 = IM.GetSpawnerID("M545CWarHead");
						FVRObject mainObject5 = spawnerID5.MainObject;
						WarHead = Object.Instantiate<GameObject>(((AnvilAsset)mainObject5).GetGameObject(), ((Component)Round).gameObject.transform);
						if ((Object)(object)WarHead.GetComponent<FVRPhysicalObject>() != (Object)null)
						{
							Object.Destroy((Object)(object)WarHead.GetComponent<FVRPhysicalObject>());
							GrabKnob = WarHead.AddComponent<FVRInteractiveObject>();
							SphereCollider val2 = WarHead.AddComponent<SphereCollider>();
							val2.radius = 0.04f;
							val2.center = new Vector3(0f, 0f, -0.08f);
							((Collider)val2).isTrigger = true;
							WarHead.layer = 10;
							GrabKnob.EndInteractionIfDistant = false;
						}
						ItemSpawnerID spawnerID6 = IM.GetSpawnerID("CG84IndiIlum");
						FVRObject mainObject6 = spawnerID6.MainObject;
						Indicator = Object.Instantiate<GameObject>(((AnvilAsset)mainObject6).GetGameObject(), ((Component)Round).gameObject.transform);
						if ((Object)(object)Indicator.GetComponent<FVRPhysicalObject>() != (Object)null)
						{
							Object.Destroy((Object)(object)Indicator.GetComponent<FVRPhysicalObject>());
						}
						Round.BallisticProjectilePrefab.GetComponent<BallisticProjectile>().MaxRange = 300f;
					}
				}
				Spawned = true;
			}
			if ((Object)(object)WarHead != (Object)null)
			{
				if (isHE)
				{
					WarHead.transform.localPosition = new Vector3(0f, 0f, 0.3667f);
				}
				if (isIlum)
				{
					WarHead.transform.localPosition = new Vector3(0f, 0f, 0.4752f);
				}
				if (!Round.IsChambered)
				{
					((Component)Round.UnfiredRenderer).gameObject.SetActive(false);
					((Component)Round.FiredRenderer).gameObject.SetActive(true);
					Round.UnfiredRenderer.enabled = false;
					Round.FiredRenderer.enabled = true;
					if (!Round.m_isSpent)
					{
						WarHead.SetActive(true);
					}
					if (Round.m_isSpent)
					{
						GrabKnob.ForceBreakInteraction();
						WarHead.SetActive(false);
					}
				}
				if (Round.IsChambered)
				{
					GrabKnob.ForceBreakInteraction();
					WarHead.SetActive(false);
					Indicator.SetActive(false);
					if (!Round.m_isSpent)
					{
						((Component)Round.UnfiredRenderer).gameObject.SetActive(true);
						Round.UnfiredRenderer.enabled = true;
						((Component)Round.FiredRenderer).gameObject.SetActive(false);
						Round.FiredRenderer.enabled = false;
					}
					if (Round.m_isSpent)
					{
						((Component)Round.UnfiredRenderer).gameObject.SetActive(false);
						Round.UnfiredRenderer.enabled = false;
						((Component)Round.FiredRenderer).gameObject.SetActive(true);
						Round.FiredRenderer.enabled = true;
					}
				}
			}
			if ((!isHE && !isIlum) || !((Object)(object)GrabKnob != (Object)null))
			{
				return;
			}
			if (((FVRInteractiveObject)Round).m_isHeld)
			{
				GrabKnob.IsSimpleInteract = false;
			}
			if (!((FVRInteractiveObject)Round).m_isHeld)
			{
				GrabKnob.IsSimpleInteract = true;
				GrabKnob.ForceBreakInteraction();
			}
			if (!GrabKnob.m_isHeld)
			{
				Indicator.SetActive(false);
				isGrab = false;
				if (isHE)
				{
					if (Round.BallisticProjectilePrefab.GetComponent<BallisticProjectile>().MaxRange <= 1000f)
					{
						float z = Mathf.Lerp(-77.5f, 144f, Mathf.Clamp01(Round.BallisticProjectilePrefab.GetComponent<BallisticProjectile>().MaxRange / 1000f));
						Vector3 localEulerAngles = WarHead.transform.localEulerAngles;
						localEulerAngles.z = z;
						WarHead.transform.localEulerAngles = localEulerAngles;
					}
					if (Round.BallisticProjectilePrefab.GetComponent<BallisticProjectile>().MaxRange == 5000f)
					{
						float z2 = Mathf.Lerp(WarHead.gameObject.transform.localEulerAngles.z, 282.5f, Time.deltaTime * 2.5f);
						Vector3 localEulerAngles2 = WarHead.transform.localEulerAngles;
						localEulerAngles2.z = z2;
						WarHead.transform.localEulerAngles = localEulerAngles2;
					}
				}
				if (isIlum)
				{
					if (Round.BallisticProjectilePrefab.GetComponent<BallisticProjectile>().MaxRange == 300f)
					{
						WarHead.transform.localEulerAngles = new Vector3(0f, 0f, Mathf.Lerp(WarHead.transform.localEulerAngles.z, 359.9f, Time.deltaTime * 2.5f));
					}
					if (Round.BallisticProjectilePrefab.GetComponent<BallisticProjectile>().MaxRange == 600f)
					{
						WarHead.transform.localEulerAngles = new Vector3(0f, 0f, Mathf.Lerp(WarHead.transform.localEulerAngles.z, 315f, Time.deltaTime * 2.5f));
					}
					if (Round.BallisticProjectilePrefab.GetComponent<BallisticProjectile>().MaxRange == 900f)
					{
						WarHead.transform.localEulerAngles = new Vector3(0f, 0f, Mathf.Lerp(WarHead.transform.localEulerAngles.z, 270f, Time.deltaTime * 2.5f));
					}
					if (Round.BallisticProjectilePrefab.GetComponent<BallisticProjectile>().MaxRange == 1200f)
					{
						WarHead.transform.localEulerAngles = new Vector3(0f, 0f, Mathf.Lerp(WarHead.transform.localEulerAngles.z, 225f, Time.deltaTime * 2.5f));
					}
					if (Round.BallisticProjectilePrefab.GetComponent<BallisticProjectile>().MaxRange == 2100f)
					{
						WarHead.transform.localEulerAngles = new Vector3(0f, 0f, Mathf.Lerp(WarHead.transform.localEulerAngles.z, 180.1f, Time.deltaTime * 2.5f));
					}
				}
				lastRot = curRot;
			}
			if (!GrabKnob.m_isHeld)
			{
				return;
			}
			Indicator.SetActive(true);
			rot.transform.eulerAngles = ((Component)GrabKnob.m_hand).gameObject.transform.eulerAngles;
			curRot = rot.transform.localEulerAngles.z;
			if (!isGrab)
			{
				lastRot = curRot;
				isGrab = true;
			}
			if (isHE || isIlum)
			{
				WarHead.transform.localEulerAngles = new Vector3(0f, 0f, Mathf.Lerp(WarHead.transform.localEulerAngles.z, rotlerp.transform.localEulerAngles.z, Time.deltaTime * 50f));
			}
			if (isHE)
			{
				if (rotlerp.transform.localEulerAngles.z <= 0.1f && rotlerp.transform.localEulerAngles.z >= 0f)
				{
					rotlerp.transform.localEulerAngles = new Vector3(0f, 0f, 359.9f);
					WarHead.transform.localEulerAngles = new Vector3(0f, 0f, 359.9f);
				}
				if (rotlerp.transform.localEulerAngles.z <= 360f && rotlerp.transform.localEulerAngles.z >= 359.9f)
				{
					rotlerp.transform.localEulerAngles = new Vector3(0f, 0f, 0.1f);
					WarHead.transform.localEulerAngles = new Vector3(0f, 0f, 0.1f);
				}
				rotlerp.transform.localEulerAngles = new Vector3(0f, 0f, rotlerp.transform.localEulerAngles.z + (curRot - lastRot));
				if ((double)rotlerp.transform.localEulerAngles.z < 282.5 && rotlerp.transform.localEulerAngles.z >= 180f)
				{
					rotlerp.transform.localEulerAngles = new Vector3(0f, 0f, 282.5f);
					WarHead.transform.localEulerAngles = new Vector3(0f, 0f, 282.5f);
				}
				if (rotlerp.transform.localEulerAngles.z <= 180f && rotlerp.transform.localEulerAngles.z > 144f)
				{
					rotlerp.transform.localEulerAngles = new Vector3(0f, 0f, 144f);
					WarHead.transform.localEulerAngles = new Vector3(0f, 0f, 144f);
				}
				float z3 = WarHead.transform.localEulerAngles.z;
				z3 = Mathf.Repeat(z3 + 180f, 360f) - 180f;
				if (z3 >= -66f && z3 <= 144f)
				{
					Round.BallisticProjectilePrefab.GetComponent<BallisticProjectile>().MaxRange = Mathf.InverseLerp(-77.5f, 144f, z3) * 1000f;
				}
				if (z3 <= -66f && z3 >= 77.5f)
				{
					Round.BallisticProjectilePrefab.GetComponent<BallisticProjectile>().MaxRange = 5000f;
				}
			}
			if (isIlum)
			{
				rotlerp.transform.localEulerAngles = new Vector3(0f, 0f, rotlerp.transform.localEulerAngles.z + (curRot - lastRot));
				if (rotlerp.transform.localEulerAngles.z > 0f && rotlerp.transform.localEulerAngles.z < 90f)
				{
					rotlerp.transform.localEulerAngles = new Vector3(0f, 0f, 0f);
					WarHead.transform.localEulerAngles = new Vector3(0f, 0f, 0f);
				}
				if (rotlerp.transform.localEulerAngles.z > 90f && rotlerp.transform.localEulerAngles.z < 180f)
				{
					rotlerp.transform.localEulerAngles = new Vector3(0f, 0f, 180f);
					WarHead.transform.localEulerAngles = new Vector3(0f, 0f, 180f);
				}
				if (rotlerp.transform.localEulerAngles.z < 0f && rotlerp.transform.localEulerAngles.z > 359.9f)
				{
					rotlerp.transform.localEulerAngles = new Vector3(0f, 0f, 359.9f);
					WarHead.transform.localEulerAngles = new Vector3(0f, 0f, 359.9f);
				}
				if (rotlerp.transform.localEulerAngles.z < 180.1f && rotlerp.transform.localEulerAngles.z > 180f)
				{
					rotlerp.transform.localEulerAngles = new Vector3(0f, 0f, 180.1f);
					WarHead.transform.localEulerAngles = new Vector3(0f, 0f, 180.1f);
				}
				if (WarHead.transform.localEulerAngles.z <= 359.9f && WarHead.transform.localEulerAngles.z > 337.5f)
				{
					Round.BallisticProjectilePrefab.GetComponent<BallisticProjectile>().MaxRange = 300f;
				}
				if (WarHead.transform.localEulerAngles.z <= 337.5f && WarHead.transform.localEulerAngles.z > 292.5f)
				{
					Round.BallisticProjectilePrefab.GetComponent<BallisticProjectile>().MaxRange = 600f;
				}
				if (WarHead.transform.localEulerAngles.z <= 292.5f && WarHead.transform.localEulerAngles.z > 247.5f)
				{
					Round.BallisticProjectilePrefab.GetComponent<BallisticProjectile>().MaxRange = 900f;
				}
				if (WarHead.transform.localEulerAngles.z <= 247.5f && WarHead.transform.localEulerAngles.z > 202.5f)
				{
					Round.BallisticProjectilePrefab.GetComponent<BallisticProjectile>().MaxRange = 1200f;
				}
				if (WarHead.transform.localEulerAngles.z <= 202.5f && WarHead.transform.localEulerAngles.z >= 180.1f)
				{
					Round.BallisticProjectilePrefab.GetComponent<BallisticProjectile>().MaxRange = 2100f;
				}
			}
			lastRot = curRot;
		}
	}
	public class CGSightToggle : MonoBehaviour
	{
		public FVRFireArmAttachmentMount[] mounts;

		public AR15HandleSightFlipper Tog;

		public GameObject Mount;

		public bool isON;

		public AudioEvent aud;

		public CarlGustaf CG;

		public void Start()
		{
			Mount.SetActive(false);
		}

		private void FixedUpdate()
		{
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)CG != (Object)null)
			{
				FVRFireArmAttachmentMount[] array = mounts;
				foreach (FVRFireArmAttachmentMount val in array)
				{
					if (!((FVRPhysicalObject)CG).AttachmentMounts.Contains(val))
					{
						((FVRPhysicalObject)CG).AttachmentMounts.Add(val);
					}
					if ((Object)(object)val.MyObject == (Object)null)
					{
						val.MyObject = (FVRPhysicalObject)(object)CG;
					}
					if ((Object)(object)val.Parent == (Object)null)
					{
						val.Parent = (FVRPhysicalObject)(object)CG;
					}
				}
			}
			if (Tog.m_isLargeAperture && isON)
			{
				SM.PlayCoreSound((FVRPooledAudioType)41, aud, ((Component)this).gameObject.transform.position);
				Mount.SetActive(false);
				isON = false;
			}
			if (!Tog.m_isLargeAperture && !isON)
			{
				SM.PlayCoreSound((FVRPooledAudioType)41, aud, ((Component)this).gameObject.transform.position);
				Mount.SetActive(true);
				isON = true;
			}
		}
	}
}
namespace JerryAr.CarlGustaf_Qol
{
	[BepInPlugin("JerryAr.CarlGustaf_Qol", "CarlGustaf_Qol", "1.0.0")]
	[BepInProcess("h3vr.exe")]
	[Description("Built with MeatKit")]
	[BepInDependency("h3vr.otherloader", "1.3.0")]
	public class CarlGustaf_QolPlugin : 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(), "JerryAr.CarlGustaf_Qol");
			OtherLoader.RegisterDirectLoad(BasePath, "JerryAr.CarlGustaf_Qol", "", "", "carlgustafqol", "");
		}
	}
}
public class SnapToPoint : MonoBehaviour
{
	public GameObject Obj;

	public GameObject Targ;

	private void Start()
	{
	}

	private void Update()
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		Obj.transform.position = Targ.transform.position;
		Obj.transform.rotation = Targ.transform.rotation;
	}
}