Decompiled source of AltMarksmanBuff v1.1.0

BepInEx/plugins/AltMarksmanBuff.dll

Decompiled 4 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("AltMarksmanBuff")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("A buff for the Alternate Marksman. Regular fire now punches coins.")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1")]
[assembly: AssemblyProduct("AltMarksmanBuff")]
[assembly: AssemblyTitle("AltMarksmanBuff")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 AltMarksmanBuff
{
	[BepInPlugin("mica.ultrakill.altmarksmanbuff", "AltMarksmanBuff", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string PLUGIN_NAME = "AltMarksmanBuff";

		public const string PLUGIN_GUID = "mica.ultrakill.altmarksmanbuff";

		public const string PLUGIN_VERSION = "1.0.0";

		public static Harmony harmony;

		private void Awake()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Expected O, but got Unknown
			harmony = new Harmony("mica.ultrakill.altmarksmanbuff");
			harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin mica.ultrakill.altmarksmanbuff is loaded!");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "AltMarksmanBuff";

		public const string PLUGIN_NAME = "AltMarksmanBuff";

		public const string PLUGIN_VERSION = "1.0.1";
	}
}
namespace AltMarksmanBuff.Patches
{
	[HarmonyPatch(typeof(Coin), "ReflectRevolver")]
	public static class Coin_ReflectRevolver
	{
		[HarmonyTranspiler]
		public static IEnumerable Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator il)
		{
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Expected O, but got Unknown
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Expected O, but got Unknown
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Expected O, but got Unknown
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Expected O, but got Unknown
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Expected O, but got Unknown
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Expected O, but got Unknown
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Expected O, but got Unknown
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Expected O, but got Unknown
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Expected O, but got Unknown
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Expected O, but got Unknown
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Expected O, but got Unknown
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Expected O, but got Unknown
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Expected O, but got Unknown
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Expected O, but got Unknown
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: Expected O, but got Unknown
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Expected O, but got Unknown
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Expected O, but got Unknown
			//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b5: Expected O, but got Unknown
			List<CodeInstruction> list = instructions.ToList();
			for (int i = 0; i < list.Count; i++)
			{
				if (list[i].opcode == OpCodes.Stloc_S && list[i - 1].opcode == OpCodes.Ldc_I4_1 && list[i].operand.ToString() == "System.Boolean (4)")
				{
					Label label = il.DefineLabel();
					List<CodeInstruction> list2 = new List<CodeInstruction>();
					list2.Add(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(GunControl), "get_Instance", (Type[])null, (Type[])null)));
					list2.Add(new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(GunControl), "currentSlot")));
					list2.Add(new CodeInstruction(OpCodes.Ldc_I4_1, (object)null));
					list2.Add(new CodeInstruction(OpCodes.Bne_Un_S, (object)label));
					list2.Add(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(GunControl), "get_Instance", (Type[])null, (Type[])null)));
					list2.Add(new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(GunControl), "currentWeapon")));
					list2.Add(new CodeInstruction(OpCodes.Callvirt, (object)AccessTools.Method(typeof(GameObject), "GetComponent", (Type[])null, new Type[1] { typeof(Revolver) })));
					list2.Add(new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(Revolver), "gunVariation")));
					list2.Add(new CodeInstruction(OpCodes.Ldc_I4_1, (object)null));
					list2.Add(new CodeInstruction(OpCodes.Bne_Un_S, (object)label));
					list2.Add(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(GunControl), "get_Instance", (Type[])null, (Type[])null)));
					list2.Add(new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(GunControl), "currentWeapon")));
					list2.Add(new CodeInstruction(OpCodes.Callvirt, (object)AccessTools.Method(typeof(GameObject), "GetComponent", (Type[])null, new Type[1] { typeof(Revolver) })));
					list2.Add(new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(Revolver), "altVersion")));
					list2.Add(new CodeInstruction(OpCodes.Brfalse_S, (object)label));
					list2.Add(new CodeInstruction(OpCodes.Ldarg_0, (object)null));
					list2.Add(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(Coin), "Punchflection", (Type[])null, (Type[])null)));
					list2.Add(new CodeInstruction(OpCodes.Ret, (object)null));
					list[i + 1].labels.Add(label);
					list.InsertRange(i + 1, list2);
				}
			}
			return list.AsEnumerable();
		}
	}
	[HarmonyPatch(typeof(WeaponCharges), "Charge")]
	public static class WeaponCharges_Charge
	{
		private static void Postfix(float amount)
		{
			GunControl instance = MonoSingleton<GunControl>.Instance;
			WeaponCharges instance2 = MonoSingleton<WeaponCharges>.Instance;
			if (instance.currentSlot != 1)
			{
				return;
			}
			Revolver component = instance.currentWeapon.GetComponent<Revolver>();
			if (component.gunVariation == 1 && component.altVersion)
			{
				instance2.rev1charge = Mathf.Min(instance2.rev1charge, 200f);
				if (instance2.rev1charge < 200f)
				{
					instance2.rev1charge -= 21.75f * amount;
				}
			}
		}
	}
}