Decompiled source of Cross Fire M4A1 Leigod v0.1.3

M4A1LeigodPrototype.dll

Decompiled an hour 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 M4A1Leigod
{
	public class LeigodAiming : MonoBehaviour
	{
		public Transform Muzzle;

		public Transform ReflexWindow;

		public Transform SurfaceDot;

		public float ConvergenceDistance = 50f;

		public float LaserMaxRange = 300f;

		public LayerMask HitMask = LayerMask.op_Implicit(-5);

		public bool ReflexEnabled = true;

		public bool LaserEnabled = false;

		private readonly RaycastHit[] hits = (RaycastHit[])(object)new RaycastHit[64];

		private MaterialPropertyBlock reflexProperties;

		public void UpdateAim()
		{
			//IL_0055: 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_006b: 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_0075: 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_0083: 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_0093: 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_00c3: 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_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Expected O, but got Unknown
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: 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_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Muzzle == (Object)null || (Object)(object)ReflexWindow == (Object)null || (Object)(object)SurfaceDot == (Object)null)
			{
				return;
			}
			((Component)ReflexWindow).gameObject.SetActive(ReflexEnabled);
			Vector3 val = Muzzle.position + Muzzle.forward * ConvergenceDistance;
			ReflexWindow.rotation = Quaternion.LookRotation(val - ReflexWindow.position, ((Component)this).transform.up);
			if (reflexProperties == null)
			{
				reflexProperties = new MaterialPropertyBlock();
			}
			reflexProperties.SetFloat("_ZeroDistance", Vector3.Distance(val, ReflexWindow.position));
			((Component)ReflexWindow).GetComponent<Renderer>().SetPropertyBlock(reflexProperties);
			((Component)SurfaceDot).gameObject.SetActive(false);
			if (!LaserEnabled)
			{
				return;
			}
			int num = Physics.RaycastNonAlloc(Muzzle.position, Muzzle.forward, hits, LaserMaxRange, LayerMask.op_Implicit(HitMask), (QueryTriggerInteraction)1);
			RaycastHit[] array = hits;
			if (num == hits.Length)
			{
				array = Physics.RaycastAll(Muzzle.position, Muzzle.forward, LaserMaxRange, LayerMask.op_Implicit(HitMask), (QueryTriggerInteraction)1);
				num = array.Length;
			}
			float num2 = float.MaxValue;
			RaycastHit val2 = default(RaycastHit);
			bool flag = false;
			for (int i = 0; i < num; i++)
			{
				RaycastHit val3 = array[i];
				if (!((Object)(object)((RaycastHit)(ref val3)).collider == (Object)null) && !((Component)((RaycastHit)(ref val3)).collider).transform.IsChildOf(((Component)this).transform) && !(((RaycastHit)(ref val3)).distance >= num2))
				{
					num2 = ((RaycastHit)(ref val3)).distance;
					val2 = val3;
					flag = true;
				}
			}
			if (flag)
			{
				SurfaceDot.position = ((RaycastHit)(ref val2)).point + ((RaycastHit)(ref val2)).normal * 0.0008f;
				SurfaceDot.rotation = Quaternion.LookRotation(((RaycastHit)(ref val2)).normal);
				float num3 = Mathf.Clamp(0.003f + num2 * 3E-05f, 0.003f, 0.018f);
				SurfaceDot.localScale = Vector3.one * num3;
				((Component)SurfaceDot).gameObject.SetActive(true);
			}
		}

		private void LateUpdate()
		{
			UpdateAim();
		}
	}
	public class LeigodMagazineAmmo : FVRFireArmMagazine
	{
		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_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected I4, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			FireArmRoundClass[] array = (FireArmRoundClass[])(object)new FireArmRoundClass[base.m_capacity];
			FireArmRoundClass defaultRoundClass = AM.GetDefaultRoundClass(base.RoundType);
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = (FireArmRoundClass)(int)defaultRoundClass;
			}
			FVRMagazineLoadingPattern val = new FVRMagazineLoadingPattern();
			val.Classes = array;
			base.DefaultLoadingPattern = val;
			((FVRFireArmMagazine)this).Awake();
		}
	}
}
namespace LocalTest.M4A1LeigodPrototype
{
	[BepInPlugin("LocalTest.M4A1LeigodPrototype", "M4A1LeigodPrototype", "0.1.2")]
	[BepInProcess("h3vr.exe")]
	[Description("Built with MeatKit")]
	[BepInDependency("h3vr.otherloader", "1.3.0")]
	public class M4A1LeigodPrototypePlugin : 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(), "LocalTest.M4A1LeigodPrototype");
			OtherLoader.RegisterDirectLoad(BasePath, "LocalTest.M4A1LeigodPrototype", "", "", "m4a1_leigod", "");
		}
	}
}