Decompiled source of CannonBind v1.0.0

FurfCannonbind.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using Configgy;
using HarmonyLib;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("FurfCannonbind")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Railcannon Rebind")]
[assembly: AssemblyTitle("FurfCannonbind")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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 FurfCannonbind
{
	[BepInPlugin("FurfCannonbind", "Railcannon Rebind", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(GunControl), "SwitchWeapon")]
		private static class Patch
		{
			private static void Prefix(ref int targetSlotIndex, int? targetVariationIndex = null, bool useRetainedVariation = false, bool cycleSlot = false, bool cycleVariation = false)
			{
				float raicharge = MonoSingleton<WeaponCharges>.Instance.raicharge;
				bool flag = raicharge < 0.04f * mincharge;
				if (targetSlotIndex == 4 && flag && !cycleSlot)
				{
					targetSlotIndex = replacement;
				}
			}
		}

		internal static ManualLogSource Logger;

		[Configgable("", "Mod enabled", 0, null)]
		public static bool enab = true;

		[Configgable("", "replacement index", 0, null)]
		public static int replacement = 1;

		[Configgable("", "minimum charge percent (out of 100)", 0, null)]
		public static float mincharge = 95f;

		private void Awake()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			ConfigBuilder val = new ConfigBuilder("FurfCannonbind", "Railcannon Rebind");
			val.BuildAll();
			Harmony val2 = new Harmony("FurfCannonbind");
			val2.PatchAll();
			Logger.LogInfo((object)"Plugin FurfCannonbind is loaded!");
			MethodInfo methodInfo = AccessTools.Method(typeof(GunControl), "SwitchWeapon", (Type[])null, (Type[])null);
			if (methodInfo == null)
			{
				Logger.LogError((object)"[ERROR] SwitchWeapons method not found!");
			}
			else
			{
				Logger.LogInfo((object)"[DEBUG] Found SwitchWeapons method!");
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "FurfCannonbind";

		public const string PLUGIN_NAME = "Railcannon Rebind";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}