Decompiled source of OhBeehive v1.0.0

OhBeehive.dll

Decompiled a day ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("OhBeehive")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OhBeehive")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("da885ebe-3d04-4039-8a85-58847b91c3a0")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[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 OhBeehive
{
	public sealed class HoneyExtractor : MonoBehaviour
	{
		private Beehive _beehive;

		private void Awake()
		{
			_beehive = ((Component)this).GetComponent<Beehive>();
			if (PluginConfig.IsModEnabled.Value)
			{
				((MonoBehaviour)this).InvokeRepeating("LootBeehive", 1f, 0.6f);
			}
		}

		public void LootBeehive()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			if (PluginConfig.IsModEnabled.Value && Object.op_Implicit((Object)(object)Player.m_localPlayer) && !(Vector3.Distance(((Component)this).transform.position, ((Component)Player.m_localPlayer).transform.position) > PluginConfig.AutoExtractRange.Value))
			{
				if (!PrivateArea.CheckAccess(((Component)this).transform.position, 0f, true, false))
				{
					((Terminal)Chat.m_instance).AddString("You are not on the ward for this area.");
					return;
				}
				_beehive.Extract();
				ZLog.Log((object)"Attempting Honey Extraction");
			}
		}
	}
	public static class PluginConfig
	{
		public static ConfigEntry<bool> IsModEnabled { get; private set; }

		public static ConfigEntry<float> AutoExtractRange { get; private set; }

		public static void BindConfig(ConfigFile config)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			IsModEnabled = config.Bind<bool>("_Global", "IsModEnabled", true, "Enable or Disable this mod");
			AutoExtractRange = config.Bind<float>("Extract", "AutoExtractRange", 1f, new ConfigDescription("Range to extract Honey.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.875f, 3f), Array.Empty<object>()));
		}
	}
	[BepInPlugin("EardwulfDoesMods.valheim.OhBeehive", "OhBeehive", "1.0.0")]
	public class OhBeehive : BaseUnityPlugin
	{
		public const string PluginGuid = "EardwulfDoesMods.valheim.OhBeehive";

		public const string PluginName = "OhBeehive";

		public const string PluginVersion = "1.0.0";

		private Harmony _harmony;

		public void Awake()
		{
			PluginConfig.BindConfig(((BaseUnityPlugin)this).Config);
			_harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "EardwulfDoesMods.valheim.OhBeehive");
		}
	}
	[HarmonyPatch(typeof(Beehive))]
	internal static class BeehivePatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("Awake")]
		private static void AwakePostFix(Beehive __instance)
		{
			if (PluginConfig.IsModEnabled.Value && __instance.GetHoneyLevel() > 0)
			{
				((Component)__instance).gameObject.AddComponent<HoneyExtractor>();
				ZLog.Log((object)"Attaching HoneyExtractor component.");
			}
		}
	}
}