Decompiled source of HitscanWeapons v1.0.0

HitscanWeapons.dll

Decompiled 2 days ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using Configgy;
using HarmonyLib;
using UnityEngine;
using UnityEngine.AddressableAssets;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Ultracoins")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Ultracoins")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("9e04a71c-24d2-4cd7-b19b-0da76f660cc9")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace HirtscanWeapons;

[BepInPlugin("plonk.hitscanguns", "Hitscan Weapons", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class RocketGatling : BaseUnityPlugin
{
	[HarmonyPatch]
	public class RocketGatlingPatches
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(Shotgun), "Shoot")]
		public static bool HitscanShotgunPatch(Shotgun __instance)
		{
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: 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)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_0636: 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_0650: Unknown result type (might be due to invalid IL or missing references)
			//IL_065d: Unknown result type (might be due to invalid IL or missing references)
			//IL_066d: Unknown result type (might be due to invalid IL or missing references)
			//IL_067a: Unknown result type (might be due to invalid IL or missing references)
			//IL_06bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_06cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0692: 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_06ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0711: Unknown result type (might be due to invalid IL or missing references)
			//IL_0716: Unknown result type (might be due to invalid IL or missing references)
			//IL_071a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0460: Unknown result type (might be due to invalid IL or missing references)
			//IL_0465: Unknown result type (might be due to invalid IL or missing references)
			//IL_0469: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0331: Unknown result type (might be due to invalid IL or missing references)
			//IL_033c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0341: Unknown result type (might be due to invalid IL or missing references)
			//IL_0346: Unknown result type (might be due to invalid IL or missing references)
			//IL_034a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0354: Unknown result type (might be due to invalid IL or missing references)
			//IL_035b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0861: Unknown result type (might be due to invalid IL or missing references)
			//IL_086d: Unknown result type (might be due to invalid IL or missing references)
			//IL_08b1: Unknown result type (might be due to invalid IL or missing references)
			bool flag = false;
			switch (__instance.variation)
			{
			case 0:
				if (((ConfigValueElement<bool>)(object)ShotgunGatling1).Value)
				{
					flag = true;
				}
				break;
			case 1:
				if (((ConfigValueElement<bool>)(object)ShotgunGatling2).Value)
				{
					flag = true;
				}
				break;
			case 2:
				if (((ConfigValueElement<bool>)(object)ShotgunGatling3).Value)
				{
					flag = true;
				}
				break;
			}
			if (flag)
			{
				__instance.gunReady = false;
				int num = 12;
				if (__instance.variation == 1)
				{
					switch (__instance.primaryCharge)
					{
					case 0:
						num = 10;
						__instance.gunAud.pitch = Random.Range(1.15f, 1.25f);
						break;
					case 1:
						num = 16;
						__instance.gunAud.pitch = Random.Range(0.95f, 1.05f);
						break;
					case 2:
						num = 24;
						__instance.gunAud.pitch = Random.Range(0.75f, 0.85f);
						break;
					case 3:
						num = 0;
						__instance.gunAud.pitch = Random.Range(0.75f, 0.85f);
						break;
					}
				}
				MonoSingleton<CameraController>.Instance.StopShake();
				Vector3 val = __instance.cam.transform.forward;
				Bounds bounds;
				if (Object.op_Implicit((Object)(object)__instance.targeter.CurrentTarget) && __instance.targeter.IsAutoAimed)
				{
					bounds = __instance.targeter.CurrentTarget.bounds;
					val = ((Bounds)(ref bounds)).center - __instance.cam.transform.position;
				}
				__instance.rhits = Physics.RaycastAll(__instance.cam.transform.position, val, 4f, LayerMask.op_Implicit(__instance.shotgunZoneLayerMask));
				if (__instance.rhits.Length != 0)
				{
					RaycastHit[] rhits = __instance.rhits;
					for (int i = 0; i < rhits.Length; i++)
					{
						RaycastHit val2 = rhits[i];
						if (!((Component)((RaycastHit)(ref val2)).collider).gameObject.CompareTag("Body"))
						{
							continue;
						}
						EnemyIdentifierIdentifier componentInParent = ((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent<EnemyIdentifierIdentifier>();
						if (!Object.op_Implicit((Object)(object)componentInParent) || !Object.op_Implicit((Object)(object)componentInParent.eid))
						{
							continue;
						}
						EnemyIdentifier eid = componentInParent.eid;
						if (!eid.dead && !eid.blessed)
						{
							AnimatorStateInfo currentAnimatorStateInfo = __instance.anim.GetCurrentAnimatorStateInfo(0);
							if (((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("Equip"))
							{
								MonoSingleton<StyleHUD>.Instance.AddPoints(50, "ultrakill.quickdraw", __instance.gc.currentWeapon, eid, -1, "", "");
							}
						}
						eid.hitter = "shotgunzone";
						if (!eid.hitterWeapons.Contains("shotgun" + __instance.variation))
						{
							eid.hitterWeapons.Add("shotgun" + __instance.variation);
						}
						GameObject gameObject = ((Component)((RaycastHit)(ref val2)).collider).gameObject;
						Vector3 val3 = ((Component)eid).transform.position - ((Component)__instance).transform.position;
						eid.DeliverDamage(gameObject, ((Vector3)(ref val3)).normalized * 10000f, ((RaycastHit)(ref val2)).point, 4f, false, 0f, ((Component)__instance).gameObject, false, false);
					}
				}
				MonoSingleton<RumbleManager>.Instance.SetVibrationTracked(RumbleProperties.GunFireProjectiles, ((Component)__instance).gameObject);
				if (__instance.variation != 1 || __instance.primaryCharge != 3)
				{
					for (int j = 0; j < num; j++)
					{
						GameObject val4 = Object.Instantiate<GameObject>(Fetch<GameObject>("Assets/Prefabs/Attacks and Projectiles/Hitscan Beams/Revolver Beam.prefab"), __instance.cam.transform.position, __instance.cam.transform.rotation);
						RevolverBeam component = val4.GetComponent<RevolverBeam>();
						component.damage = 0.25f;
						component.sourceWeapon = __instance.gc.currentWeapon;
						if (Object.op_Implicit((Object)(object)__instance.targeter.CurrentTarget) && __instance.targeter.IsAutoAimed)
						{
							Transform transform = val4.transform;
							bounds = __instance.targeter.CurrentTarget.bounds;
							transform.LookAt(((Bounds)(ref bounds)).center);
						}
						if (__instance.variation == 1)
						{
							switch (__instance.primaryCharge)
							{
							case 0:
								val4.transform.Rotate(Random.Range((0f - __instance.spread) / 1.5f, __instance.spread / 1.5f), Random.Range((0f - __instance.spread) / 1.5f, __instance.spread / 1.5f), Random.Range((0f - __instance.spread) / 1.5f, __instance.spread / 1.5f));
								break;
							case 1:
								val4.transform.Rotate(Random.Range(0f - __instance.spread, __instance.spread), Random.Range(0f - __instance.spread, __instance.spread), Random.Range(0f - __instance.spread, __instance.spread));
								break;
							case 2:
								val4.transform.Rotate(Random.Range((0f - __instance.spread) * 2f, __instance.spread * 2f), Random.Range((0f - __instance.spread) * 2f, __instance.spread * 2f), Random.Range((0f - __instance.spread) * 2f, __instance.spread * 2f));
								break;
							}
						}
						else
						{
							val4.transform.Rotate(Random.Range(0f - __instance.spread, __instance.spread), Random.Range(0f - __instance.spread, __instance.spread), Random.Range(0f - __instance.spread, __instance.spread));
						}
					}
				}
				else
				{
					Vector3 val5 = __instance.cam.transform.position + __instance.cam.transform.forward;
					RaycastHit val6 = default(RaycastHit);
					if (Physics.Raycast(__instance.cam.transform.position, __instance.cam.transform.forward, ref val6, 1f, LayerMask.op_Implicit(LayerMaskDefaults.Get((LMD)1))))
					{
						val5 = ((RaycastHit)(ref val6)).point - __instance.cam.transform.forward * 0.1f;
					}
					GameObject val7 = Object.Instantiate<GameObject>(__instance.explosion, val5, __instance.cam.transform.rotation);
					if (Object.op_Implicit((Object)(object)__instance.targeter.CurrentTarget) && __instance.targeter.IsAutoAimed)
					{
						Transform transform2 = val7.transform;
						bounds = __instance.targeter.CurrentTarget.bounds;
						transform2.LookAt(((Bounds)(ref bounds)).center);
					}
					Explosion[] componentsInChildren = val7.GetComponentsInChildren<Explosion>();
					foreach (Explosion val8 in componentsInChildren)
					{
						val8.sourceWeapon = __instance.gc.currentWeapon;
						val8.enemyDamageMultiplier = 1f;
						val8.maxSize *= 1.5f;
						val8.damage = 50;
					}
				}
				if (__instance.variation != 1)
				{
					__instance.gunAud.pitch = Random.Range(0.95f, 1.05f);
				}
				__instance.gunAud.clip = __instance.shootSound;
				__instance.gunAud.volume = 0.45f;
				__instance.gunAud.panStereo = 0f;
				__instance.gunAud.Play();
				__instance.cc.CameraShake(1f);
				if (__instance.variation == 1)
				{
					__instance.anim.SetTrigger("PumpFire");
				}
				else
				{
					__instance.anim.SetTrigger("Fire");
				}
				Transform[] shootPoints = __instance.shootPoints;
				foreach (Transform val9 in shootPoints)
				{
					Object.Instantiate<GameObject>(__instance.muzzleFlash, ((Component)val9).transform.position, ((Component)val9).transform.rotation);
				}
				__instance.releasingHeat = false;
				__instance.tempColor.a = 1f;
				((Renderer)__instance.heatSinkSMR).sharedMaterials[3].SetColor("_TintColor", __instance.tempColor);
				if (__instance.variation == 1)
				{
					__instance.primaryCharge = 0;
				}
				return false;
			}
			return true;
		}
	}

	public static GameObject rocket;

	public static GameObject sgpellet;

	public static GameObject muzzleflash;

	public static GameObject grenade;

	public static GameObject malrailbeam;

	public static GameObject pistolbeam;

	public static float animspeed;

	public static Vector3 playerpos;

	public static GameObject[] companions;

	public static float inttimer;

	public static GameObject projectile;

	[Configgable("Shotgun", "Variation 1 Shotgun Hitscan Enabled", 0, null)]
	private static ConfigToggle ShotgunGatling1 = new ConfigToggle(false);

	[Configgable("Shotgun", "Variation 2 Shotgun Hitscan Enabled", 0, null)]
	private static ConfigToggle ShotgunGatling2 = new ConfigToggle(true);

	[Configgable("Shotgun", "Variation 3 Shotgun Hitscan Enabled", 0, null)]
	private static ConfigToggle ShotgunGatling3 = new ConfigToggle(false);

	public static ConfigBuilder ConfigBuilder { get; private set; }

	public void Awake()
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Expected O, but got Unknown
		ConfigBuilder = new ConfigBuilder("plonk.hitscanShotgun", "Hitscan Weapons Mod");
		ConfigBuilder.Build();
	}

	public static T Fetch<T>(string key)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		return Addressables.LoadAssetAsync<T>((object)key).WaitForCompletion();
	}

	public static void SendHudMessage(string msg, int delay, bool silent)
	{
		MonoSingleton<HudMessageReceiver>.Instance.SendHudMessage(msg, "", "", delay, silent);
	}

	public static void Log(string log, int type = 1)
	{
		switch (type)
		{
		case 1:
			Debug.Log((object)log);
			break;
		case 2:
			Debug.LogWarning((object)log);
			break;
		case 3:
			Debug.LogError((object)log);
			break;
		}
	}

	public void Start()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		Harmony val = new Harmony("plonk.sitscanHhotgun");
		val.PatchAll();
		projectile = Fetch<GameObject>("Assets/Prefabs/Attacks and Projectiles/Projectile.prefab");
	}
}