Decompiled source of BeeFree v1.0.1

BeeFree.dll

Decompiled 4 hours ago
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace BeeFree;

[BepInPlugin("BeeFree", "BeeFree", "1.0.1")]
public class BeeFreePlugin : BaseUnityPlugin
{
	public const string PluginGuid = "BeeFree";

	public const string PluginName = "BeeFree";

	public const string PluginVersion = "1.0.1";

	internal static ConfigEntry<bool> Enabled;

	internal static ConfigEntry<bool> ProduceAnywhere;

	internal static ConfigEntry<float> HoneyCapacityPercent;

	internal static ManualLogSource Log;

	private void Awake()
	{
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		Log = ((BaseUnityPlugin)this).Logger;
		Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Master switch for BeeFree.");
		ProduceAnywhere = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ProduceAnywhere", true, "Let beehives produce honey anywhere: any biome, indoors, underground, and while covered/roofed.");
		HoneyCapacityPercent = ((BaseUnityPlugin)this).Config.Bind<float>("General", "HoneyCapacityPercent", 200f, "How much honey a hive can hold, as a percentage of the normal maximum. 200 = double the vanilla capacity. Applied when each hive loads.");
		new Harmony("BeeFree").PatchAll();
		Log.LogInfo((object)"BeeFree v1.0.1 loaded.");
	}
}
[HarmonyPatch(typeof(Beehive), "CheckBiome")]
internal static class Beehive_CheckBiome_Patch
{
	private static void Postfix(ref bool __result)
	{
		if (BeeFreePlugin.Enabled != null && BeeFreePlugin.Enabled.Value && BeeFreePlugin.ProduceAnywhere != null && BeeFreePlugin.ProduceAnywhere.Value)
		{
			__result = true;
		}
	}
}
[HarmonyPatch(typeof(Beehive), "HaveFreeSpace")]
internal static class Beehive_HaveFreeSpace_Patch
{
	private static void Postfix(ref bool __result)
	{
		if (BeeFreePlugin.Enabled != null && BeeFreePlugin.Enabled.Value && BeeFreePlugin.ProduceAnywhere != null && BeeFreePlugin.ProduceAnywhere.Value)
		{
			__result = true;
		}
	}
}
[HarmonyPatch(typeof(Beehive), "Awake")]
internal static class Beehive_Awake_Patch
{
	private static void Postfix(Beehive __instance)
	{
		if (BeeFreePlugin.Enabled == null || !BeeFreePlugin.Enabled.Value || BeeFreePlugin.HoneyCapacityPercent == null)
		{
			return;
		}
		float value = BeeFreePlugin.HoneyCapacityPercent.Value;
		if (!(value <= 0f))
		{
			int num = Mathf.RoundToInt((float)__instance.m_maxHoney * (value / 100f));
			if (num < 1)
			{
				num = 1;
			}
			__instance.m_maxHoney = num;
		}
	}
}