Decompiled source of BindableWeaponWheel v1.0.0

BindableWeaponWheel.dll

Decompiled 17 hours ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using HarmonyLib.PatchExtensions;
using Microsoft.CodeAnalysis;
using PluginConfig.API;
using PluginConfig.API.Fields;
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("BindableWeaponWheel")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BindableWeaponWheel")]
[assembly: AssemblyTitle("BindableWeaponWheel")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace BindableWeaponWheel
{
	[BepInPlugin("com.commi.bindableWeaponWheel", "Bindable Weapon Wheel", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string PluginGuid = "com.commi.bindableWeaponWheel";

		public const string PluginName = "Bindable Weapon Wheel";

		public const string PluginVersion = "1.0.0";

		private PluginConfigurator config;

		public static KeyCodeField WheelKey;

		public static string workingPath;

		public static string workingDir;

		private Harmony harmony;

		internal static ManualLogSource Log;

		private void Awake()
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogInfo((object)"Bindable Weapon Wheel loaded");
			config = PluginConfigurator.Create("Bindable Weapon Wheel", "com.commi.bindableWeaponWheel");
			WheelKey = new KeyCodeField(config.rootPanel, "WEAPON WHEEL", "WeaponWheelKey", (KeyCode)116);
			workingPath = Assembly.GetExecutingAssembly().Location;
			workingDir = Path.GetDirectoryName(workingPath);
			config.SetIconWithURL(Path.Combine(workingDir, "icon.png"));
			harmony = new Harmony("com.commi.bindableWeaponWheel");
			MixinLoader.ApplyPatches(harmony, Assembly.GetExecutingAssembly());
			harmony.PatchAll();
		}

		private void OnDestroy()
		{
			harmony.UnpatchSelf();
		}
	}
	[HarmonyPatch(typeof(WeaponWheel), "Show")]
	public class DontShow
	{
		public static bool AllowWeaponWheel;

		private static bool Prefix(WeaponWheel __instance)
		{
			return AllowWeaponWheel;
		}
	}
	[HarmonyPatch(typeof(GunControl), "Update")]
	public class ChangeKeybind
	{
		private static void Prefix(GunControl __instance)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			if (Input.GetKey(Plugin.WheelKey.value))
			{
				DontShow.AllowWeaponWheel = true;
				if (__instance.activated && !GameStateManager.Instance.PlayerInputLocked && !MonoSingleton<OptionsManager>.Instance.inIntro && !MonoSingleton<OptionsManager>.Instance.paused && !MonoSingleton<NewMovement>.Instance.dead && (Object)(object)MonoSingleton<WeaponWheel>.Instance != (Object)null && !((Component)MonoSingleton<WeaponWheel>.Instance).gameObject.activeSelf)
				{
					MonoSingleton<WeaponWheel>.Instance.Show();
				}
			}
			else if (!Input.GetKeyUp(Plugin.WheelKey.value))
			{
				DontShow.AllowWeaponWheel = false;
				if ((Object)(object)MonoSingleton<WeaponWheel>.Instance != (Object)null)
				{
					((Component)MonoSingleton<WeaponWheel>.Instance).gameObject.SetActive(false);
				}
			}
		}
	}
	public static class RedirectPatches
	{
		[Patch(/*Could not decode attribute arguments.*/)]
		public static bool ReplaceCall(InputActionState instance)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return Input.GetKeyUp(Plugin.WheelKey.value);
		}
	}
}