Decompiled source of altgunsbutfaster v0.1.0

AltGunsbutunhinged.dll

Decompiled 5 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using Configgy;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("AltGunsbutunhinged")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("AltGunsbutunhinged")]
[assembly: AssemblyTitle("AltGunsbutunhinged")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace AltGunsbutunhinged
{
	[BepInPlugin("mastoor144.altgunsbutunhinged", "Alt Guns but Unhinged", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		private ConfigBuilder config;

		[Configgable("Alt Gun Settings", "Damage Multiplier", 0, null)]
		[Range(1f, 10f)]
		public static float DamageMultiplier = 3f;

		[Configgable("Alt Gun Settings", "Disable Recoil and Shake", 0, null)]
		public static bool ZeroRecoil = true;

		[Configgable("Alt Gun Settings", "Rapid Primary Fire", 0, null)]
		public static bool FastFire = true;

		[Configgable("Alt Gun Settings", "Alt Special Cooldown Multiplier", 0, null)]
		[Range(0f, 500f)]
		public static float CooldownSpeed = 5f;

		internal static bool IsShootingAltWeapon = false;

		private void Awake()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			config = new ConfigBuilder("mastoor144.altgunsbutunhinged", "Alt Guns but Unhinged");
			config.BuildAll();
			new Harmony("mastoor144.altgunsbutunhinged").PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"AltGunsbutunhinged loaded with Slab + Sawblade mayhem!");
		}
	}
	[HarmonyPatch(typeof(RevolverBeam), "Start")]
	public class SlabBeamPatch
	{
		private static void Prefix(RevolverBeam __instance)
		{
			if (!((Object)(object)__instance == (Object)null) && !((Object)(object)__instance.sourceWeapon == (Object)null))
			{
				Revolver val = __instance.sourceWeapon.GetComponent<Revolver>();
				if ((Object)(object)val == (Object)null)
				{
					val = __instance.sourceWeapon.GetComponentInParent<Revolver>();
				}
				if ((Object)(object)val != (Object)null && val.altVersion)
				{
					__instance.damage *= Plugin.DamageMultiplier;
				}
			}
		}
	}
	[HarmonyPatch(typeof(Revolver), "Update")]
	public class SlabFastFirePatch
	{
		private static readonly FieldInfo ShootChargeField = AccessTools.Field(typeof(Revolver), "shootCharge");

		private static readonly FieldInfo PierceChargeField = AccessTools.Field(typeof(Revolver), "pierceCharge");

		private static readonly FieldInfo PierceReadyField = AccessTools.Field(typeof(Revolver), "pierceReady");

		private static void Postfix(Revolver __instance)
		{
			if ((Object)(object)__instance == (Object)null || !__instance.altVersion)
			{
				return;
			}
			if (Plugin.FastFire)
			{
				if (ShootChargeField != null)
				{
					ShootChargeField.SetValue(__instance, 100f);
				}
				Animator val = ((Component)__instance).GetComponent<Animator>();
				if ((Object)(object)val == (Object)null)
				{
					val = ((Component)__instance).GetComponentInChildren<Animator>();
				}
				if ((Object)(object)val != (Object)null)
				{
					val.speed = 10f;
				}
			}
			if (!(PierceChargeField != null))
			{
				return;
			}
			float num = (float)PierceChargeField.GetValue(__instance);
			if (Plugin.CooldownSpeed > 0f)
			{
				if (num < 100f)
				{
					float num2 = num + Time.deltaTime * 50f * Plugin.CooldownSpeed;
					PierceChargeField.SetValue(__instance, Mathf.Min(100f, num2));
				}
				if (PierceReadyField != null && (float)PierceChargeField.GetValue(__instance) >= 100f)
				{
					PierceReadyField.SetValue(__instance, true);
				}
			}
		}
	}
	[HarmonyPatch(typeof(Revolver), "OnDisable")]
	public class SlabResetAnimPatch
	{
		private static void Prefix(Revolver __instance)
		{
			if ((Object)(object)__instance != (Object)null)
			{
				Animator val = ((Component)__instance).GetComponent<Animator>();
				if ((Object)(object)val == (Object)null)
				{
					val = ((Component)__instance).GetComponentInChildren<Animator>();
				}
				if ((Object)(object)val != (Object)null)
				{
					val.speed = 1f;
				}
			}
		}
	}
	[HarmonyPatch(typeof(Revolver), "Shoot")]
	public class SlabShootPatch
	{
		private static void Prefix(Revolver __instance)
		{
			if ((Object)(object)__instance != (Object)null && __instance.altVersion)
			{
				Plugin.IsShootingAltWeapon = true;
			}
		}

		private static void Postfix()
		{
			Plugin.IsShootingAltWeapon = false;
		}
	}
	[HarmonyPatch(typeof(Nailgun), "Update")]
	public class SawbladeFastFirePatch
	{
		private static readonly FieldInfo FireRateCheckField = AccessTools.Field(typeof(Nailgun), "fireRateCheck");

		private static readonly FieldInfo HeatSinkChargeField = AccessTools.Field(typeof(Nailgun), "heatSinkAmount");

		private static void Postfix(Nailgun __instance)
		{
			if ((Object)(object)__instance == (Object)null || !__instance.altVersion)
			{
				return;
			}
			if (Plugin.FastFire)
			{
				if (FireRateCheckField != null)
				{
					FireRateCheckField.SetValue(__instance, 0f);
				}
				Animator val = ((Component)__instance).GetComponent<Animator>();
				if ((Object)(object)val == (Object)null)
				{
					val = ((Component)__instance).GetComponentInChildren<Animator>();
				}
				if ((Object)(object)val != (Object)null)
				{
					val.speed = 10f;
				}
			}
			if (HeatSinkChargeField != null && Plugin.CooldownSpeed > 0f)
			{
				float num = (float)HeatSinkChargeField.GetValue(__instance);
				if (num < 1f)
				{
					float num2 = num + Time.deltaTime * 0.2f * Plugin.CooldownSpeed;
					HeatSinkChargeField.SetValue(__instance, Mathf.Min(1f, num2));
				}
			}
		}
	}
	[HarmonyPatch(typeof(Nailgun), "OnDisable")]
	public class SawbladeResetAnimPatch
	{
		private static void Prefix(Nailgun __instance)
		{
			if ((Object)(object)__instance != (Object)null)
			{
				Animator val = ((Component)__instance).GetComponent<Animator>();
				if ((Object)(object)val == (Object)null)
				{
					val = ((Component)__instance).GetComponentInChildren<Animator>();
				}
				if ((Object)(object)val != (Object)null)
				{
					val.speed = 1f;
				}
			}
		}
	}
	[HarmonyPatch(typeof(Nailgun), "Shoot")]
	public class SawbladeShootPatch
	{
		private static void Prefix(Nailgun __instance)
		{
			if ((Object)(object)__instance != (Object)null && __instance.altVersion)
			{
				Plugin.IsShootingAltWeapon = true;
			}
		}

		private static void Postfix()
		{
			Plugin.IsShootingAltWeapon = false;
		}
	}
	[HarmonyPatch(typeof(Nail), "Start")]
	public class SawDamagePatch
	{
		private static void Prefix(Nail __instance)
		{
			if ((Object)(object)__instance != (Object)null && __instance.sawblade)
			{
				__instance.damage *= Plugin.DamageMultiplier;
			}
		}
	}
	[HarmonyPatch(typeof(CameraController), "CameraScale")]
	[HarmonyPatch(typeof(CameraController), "CameraShake")]
	public class AltNoShakePatch
	{
		private static bool Prefix()
		{
			if (Plugin.ZeroRecoil && Plugin.IsShootingAltWeapon)
			{
				return false;
			}
			return true;
		}
	}
}