Decompiled source of AK MagRelease Flipper v1.0.2

AK_MagRelease_Flipper.dll

Decompiled 3 weeks 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 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 JerryAKMagEject
{
	[BepInPlugin("JerryAKMagEject", "JAKME", "1.0.0")]
	[BepInProcess("h3vr.exe")]
	public class AKMagFingerEject : BaseUnityPlugin
	{
		public FVRFireArmMagazine mag;

		public FVRFireArmMagazine mag2;

		public FVRFireArmMagazine mag3;

		public FVRFireArmMagazine mag4;

		public float cd = 0.5f;

		public float cd2 = 0.5f;

		public bool has;

		public bool isC;

		public bool check;

		public bool has2;

		public bool isC2;

		public bool check2;

		public FVRInteractiveObject obj;

		public FVRInteractiveObject obj2;

		private void Update()
		{
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: 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_06a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ad6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ae6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0af6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b00: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b05: 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_05f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b19: 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_034b: Unknown result type (might be due to invalid IL or missing references)
			//IL_087e: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0467: Unknown result type (might be due to invalid IL or missing references)
			//IL_0471: Unknown result type (might be due to invalid IL or missing references)
			//IL_099a: Unknown result type (might be due to invalid IL or missing references)
			//IL_09a4: 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_0545: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a6e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a78: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)mag2 != (Object)null)
			{
				if (cd > 0f)
				{
					cd -= Time.deltaTime;
				}
				else if (cd <= 0f)
				{
					cd = 0.5f;
					((Component)((Component)mag2).gameObject.GetComponentInChildren<FVRFireArmReloadTriggerMag>(true)).gameObject.SetActive(true);
					mag2 = null;
				}
			}
			if ((Object)(object)mag4 != (Object)null)
			{
				if (cd2 > 0f)
				{
					cd2 -= Time.deltaTime;
				}
				else if (cd2 <= 0f)
				{
					cd2 = 0.5f;
					((Component)((Component)mag4).gameObject.GetComponentInChildren<FVRFireArmReloadTriggerMag>(true)).gameObject.SetActive(true);
					mag4 = null;
				}
			}
			if ((Object)(object)GM.CurrentMovementManager.Hands[0].m_currentInteractable != (Object)null && (Object)(object)((Component)GM.CurrentMovementManager.Hands[0].m_currentInteractable).gameObject.GetComponentInChildren<PhysicalMagazineReleaseLatch>() != (Object)null)
			{
				PhysicalMagazineReleaseLatch componentInChildren = ((Component)GM.CurrentMovementManager.Hands[0].m_currentInteractable).gameObject.GetComponentInChildren<PhysicalMagazineReleaseLatch>();
				Vector3 velLinearWorld = GM.CurrentMovementManager.Hands[0].OtherHand.Input.VelLinearWorld;
				if ((Object)(object)mag != (Object)null)
				{
					if (!check)
					{
						if ((Object)(object)GM.CurrentMovementManager.Hands[0].OtherHand.m_currentInteractable != (Object)null)
						{
							if ((Object)(object)((Component)GM.CurrentMovementManager.Hands[0]).gameObject.GetComponent<HingeJoint>() != (Object)null)
							{
								isC = true;
							}
							else if ((Object)(object)((Component)GM.CurrentMovementManager.Hands[0]).gameObject.GetComponent<HingeJoint>() == (Object)null)
							{
								isC = false;
							}
							has = true;
							check = true;
						}
						if ((Object)(object)GM.CurrentMovementManager.Hands[0].OtherHand.m_currentInteractable == (Object)null)
						{
							if ((Object)(object)((Component)GM.CurrentMovementManager.Hands[0]).gameObject.GetComponent<HingeJoint>() != (Object)null)
							{
								isC = true;
							}
							else if ((Object)(object)((Component)GM.CurrentMovementManager.Hands[0]).gameObject.GetComponent<HingeJoint>() == (Object)null)
							{
								isC = false;
							}
							has = false;
							check = true;
						}
					}
					if (check)
					{
						if ((Object)(object)mag.FireArm != (Object)null)
						{
							if (has)
							{
								obj = GM.CurrentMovementManager.Hands[0].OtherHand.m_currentInteractable;
								obj.ForceBreakInteraction();
								GM.CurrentMovementManager.Hands[0].OtherHand.ForceSetInteractable((FVRInteractiveObject)(object)mag);
								((FVRInteractiveObject)mag).BeginInteraction(GM.CurrentMovementManager.Hands[0].OtherHand);
								((Component)componentInChildren).transform.localEulerAngles = new Vector3(320f, 0f, 0f);
							}
							else if (!has)
							{
								GM.CurrentMovementManager.Hands[0].OtherHand.ForceSetInteractable((FVRInteractiveObject)(object)mag);
								((FVRInteractiveObject)mag).BeginInteraction(GM.CurrentMovementManager.Hands[0].OtherHand);
								((Component)componentInChildren).transform.localEulerAngles = new Vector3(320f, 0f, 0f);
							}
							if (isC)
							{
								((Component)((Component)mag).gameObject.GetComponentInChildren<FVRFireArmReloadTriggerMag>(true)).gameObject.SetActive(false);
								cd = 0.5f;
							}
							if (!isC)
							{
								componentInChildren.FireArm.EjectMag(false);
							}
						}
						if ((Object)(object)mag.FireArm == (Object)null)
						{
							if (has)
							{
								((FVRInteractiveObject)mag).ForceBreakInteraction();
								if ((Object)(object)((Component)mag).gameObject.GetComponent<Rigidbody>() != (Object)null)
								{
									((Component)mag).gameObject.GetComponent<Rigidbody>().AddRelativeForce(Vector3.forward * 3f, (ForceMode)2);
								}
								mag2 = mag;
								mag = null;
								GM.CurrentMovementManager.Hands[0].OtherHand.ForceSetInteractable(obj);
								obj.BeginInteraction(GM.CurrentMovementManager.Hands[0].OtherHand);
								obj = null;
								check = false;
							}
							else if (!has && (Object)(object)((Component)componentInChildren.FireArm).gameObject.GetComponent<Joint>() == (Object)null)
							{
								((FVRInteractiveObject)mag).ForceBreakInteraction();
								if ((Object)(object)((Component)mag).gameObject.GetComponent<Rigidbody>() != (Object)null)
								{
									((Component)mag).gameObject.GetComponent<Rigidbody>().AddRelativeForce(Vector3.forward * 3f, (ForceMode)2);
								}
								mag2 = mag;
								mag = null;
								obj = null;
								check = false;
							}
						}
					}
				}
				if ((Object)(object)componentInChildren.FireArm.Magazine != (Object)null && Vector3.Distance(GM.CurrentMovementManager.Hands[0].OtherHand.PointingTransform.position, ((Component)componentInChildren).gameObject.transform.position + ((Component)componentInChildren).gameObject.transform.up * -0.1f) < 0.1f && Vector3.Angle(velLinearWorld, ((Component)componentInChildren).gameObject.transform.forward) < 50f && ((Vector3)(ref velLinearWorld)).magnitude > 2f)
				{
					mag = componentInChildren.FireArm.Magazine;
				}
			}
			if (!((Object)(object)GM.CurrentMovementManager.Hands[1].m_currentInteractable != (Object)null) || !((Object)(object)((Component)GM.CurrentMovementManager.Hands[1].m_currentInteractable).gameObject.GetComponentInChildren<PhysicalMagazineReleaseLatch>() != (Object)null))
			{
				return;
			}
			PhysicalMagazineReleaseLatch componentInChildren2 = ((Component)GM.CurrentMovementManager.Hands[1].m_currentInteractable).gameObject.GetComponentInChildren<PhysicalMagazineReleaseLatch>();
			Vector3 velLinearWorld2 = GM.CurrentMovementManager.Hands[1].OtherHand.Input.VelLinearWorld;
			if ((Object)(object)mag3 != (Object)null)
			{
				if (!check2)
				{
					if ((Object)(object)GM.CurrentMovementManager.Hands[1].OtherHand.m_currentInteractable != (Object)null)
					{
						if ((Object)(object)((Component)GM.CurrentMovementManager.Hands[1]).gameObject.GetComponent<HingeJoint>() != (Object)null)
						{
							isC2 = true;
						}
						else if ((Object)(object)((Component)GM.CurrentMovementManager.Hands[1]).gameObject.GetComponent<HingeJoint>() == (Object)null)
						{
							isC2 = false;
						}
						has2 = true;
						check2 = true;
					}
					if ((Object)(object)GM.CurrentMovementManager.Hands[1].OtherHand.m_currentInteractable == (Object)null)
					{
						if ((Object)(object)((Component)GM.CurrentMovementManager.Hands[1]).gameObject.GetComponent<HingeJoint>() != (Object)null)
						{
							isC2 = true;
						}
						else if ((Object)(object)((Component)GM.CurrentMovementManager.Hands[1]).gameObject.GetComponent<HingeJoint>() == (Object)null)
						{
							isC2 = false;
						}
						has2 = false;
						check2 = true;
					}
				}
				if (check2)
				{
					if ((Object)(object)mag3.FireArm != (Object)null)
					{
						if (has2)
						{
							obj2 = GM.CurrentMovementManager.Hands[1].OtherHand.m_currentInteractable;
							obj2.ForceBreakInteraction();
							GM.CurrentMovementManager.Hands[1].OtherHand.ForceSetInteractable((FVRInteractiveObject)(object)mag3);
							((FVRInteractiveObject)mag3).BeginInteraction(GM.CurrentMovementManager.Hands[1].OtherHand);
							((Component)componentInChildren2).transform.localEulerAngles = new Vector3(320f, 0f, 0f);
						}
						else if (!has2)
						{
							GM.CurrentMovementManager.Hands[1].OtherHand.ForceSetInteractable((FVRInteractiveObject)(object)mag3);
							((FVRInteractiveObject)mag3).BeginInteraction(GM.CurrentMovementManager.Hands[1].OtherHand);
							((Component)componentInChildren2).transform.localEulerAngles = new Vector3(320f, 0f, 0f);
						}
						if (isC2)
						{
							((Component)((Component)mag3).gameObject.GetComponentInChildren<FVRFireArmReloadTriggerMag>(true)).gameObject.SetActive(false);
							cd2 = 0.5f;
						}
						if (!isC2)
						{
							componentInChildren2.FireArm.EjectMag(false);
						}
					}
					if ((Object)(object)mag3.FireArm == (Object)null)
					{
						if (has2)
						{
							((FVRInteractiveObject)mag3).ForceBreakInteraction();
							if ((Object)(object)((Component)mag3).gameObject.GetComponent<Rigidbody>() != (Object)null)
							{
								((Component)mag3).gameObject.GetComponent<Rigidbody>().AddRelativeForce(Vector3.forward * 3f, (ForceMode)2);
							}
							mag4 = mag3;
							mag3 = null;
							GM.CurrentMovementManager.Hands[1].OtherHand.ForceSetInteractable(obj2);
							obj2.BeginInteraction(GM.CurrentMovementManager.Hands[1].OtherHand);
							obj2 = null;
							check2 = false;
						}
						else if (!has2 && (Object)(object)((Component)componentInChildren2.FireArm).gameObject.GetComponent<Joint>() == (Object)null)
						{
							((FVRInteractiveObject)mag3).ForceBreakInteraction();
							if ((Object)(object)((Component)mag3).gameObject.GetComponent<Rigidbody>() != (Object)null)
							{
								((Component)mag3).gameObject.GetComponent<Rigidbody>().AddRelativeForce(Vector3.forward * 3f, (ForceMode)2);
							}
							mag4 = mag3;
							mag3 = null;
							obj2 = null;
							check2 = false;
						}
					}
				}
			}
			if ((Object)(object)componentInChildren2.FireArm.Magazine != (Object)null && Vector3.Distance(GM.CurrentMovementManager.Hands[1].OtherHand.PointingTransform.position, ((Component)componentInChildren2).gameObject.transform.position + ((Component)componentInChildren2).gameObject.transform.up * -0.1f) < 0.1f && Vector3.Angle(velLinearWorld2, ((Component)componentInChildren2).gameObject.transform.forward) < 50f && ((Vector3)(ref velLinearWorld2)).magnitude > 2f)
			{
				mag3 = componentInChildren2.FireArm.Magazine;
			}
		}
	}
}
namespace JerryAr.AK_MagRelease_Flipper
{
	[BepInPlugin("JerryAr.AK_MagRelease_Flipper", "AK_MagRelease_Flipper", "1.0.2")]
	[BepInProcess("h3vr.exe")]
	[Description("Built with MeatKit")]
	public class AK_MagRelease_FlipperPlugin : 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.AK_MagRelease_Flipper");
		}
	}
}
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;
	}
}