Decompiled source of Hoovernt v1.1.0

Hoovernt.dll

Decompiled a year ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Hoovernt")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Hoovernt")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("91482d55-3928-4faf-8804-b9df96fbf821")]
[assembly: AssemblyFileVersion("1.1.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.1.0.0")]
namespace Hoovernt
{
	[BepInPlugin("mayo.is.an.instrument.hoovernt", "Hoovern't", "1.1.0")]
	public class Hoovernt : BaseUnityPlugin
	{
		public const string PluginGuid = "mayo.is.an.instrument.hoovernt";

		public const string PluginName = "Hoovern't";

		public const string PluginVersion = "1.1.0";

		public static bool AutoPickup;

		private Harmony _harmony;

		public void Awake()
		{
			PluginConfig.BindConfig(((BaseUnityPlugin)this).Config);
			AutoPickup = PluginConfig.DefaultPickupSetting.Value;
			_harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "mayo.is.an.instrument.hoovernt");
		}

		public void OnDestroy()
		{
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}
	}
	public class PluginConfig
	{
		public static ConfigEntry<bool> IsModEnabled { get; private set; }

		public static ConfigEntry<bool> DefaultPickupSetting { get; private set; }

		public static void BindConfig(ConfigFile config)
		{
			IsModEnabled = config.Bind<bool>("_Global", "isModEnabled", true, "Globally enable or disable this mod.");
			DefaultPickupSetting = config.Bind<bool>("Player", "Default Autopickup Setting", true, "Autopickup setting that is applied when you log in.");
		}
	}
}
namespace Hoovernt.Patches
{
	[HarmonyPatch(typeof(Player))]
	internal class PlayerPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("OnDeath")]
		private static void OnDeathPrefix(ref bool ___m_enableAutoPickup)
		{
			if (PluginConfig.IsModEnabled.Value)
			{
				Hoovernt.AutoPickup = ___m_enableAutoPickup;
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("Awake")]
		private static void AwakePostFix(ref bool ___m_enableAutoPickup)
		{
			if (PluginConfig.IsModEnabled.Value)
			{
				___m_enableAutoPickup = Hoovernt.AutoPickup;
			}
		}
	}
}