Decompiled source of Better Beehives v1.3.0

plugins/BetterBeehives.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using BetterBeehives.Compatibility;
using BetterBeehives.Data;
using BetterBeehives.Scripts;
using HarmonyLib;
using JetBrains.Annotations;
using LazyVikings;
using Microsoft.CodeAnalysis;
using SeedBed;
using SeedBed.Functions;
using ServerSync;
using TMPro;
using UnityEngine;
using ZenBeehive;

[assembly: AssemblyProduct("BetterBeehives")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyCompany("BetterBeehives")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: CompilationRelaxations(8)]
[assembly: AssemblyTitle("BetterBeehives")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[<55826d48-8f86-4ad2-9dab-db55fae63997>Embedded]
	internal sealed class <55826d48-8f86-4ad2-9dab-db55fae63997>EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	[<55826d48-8f86-4ad2-9dab-db55fae63997>Embedded]
	[CompilerGenerated]
	internal sealed class <5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public <5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public <5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	[<55826d48-8f86-4ad2-9dab-db55fae63997>Embedded]
	[CompilerGenerated]
	internal sealed class <a33d1f5c-09cf-435c-999c-1ff9e12f226e>NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public <a33d1f5c-09cf-435c-999c-1ff9e12f226e>NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace BetterBeehives
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(0)]
	[<a33d1f5c-09cf-435c-999c-1ff9e12f226e>NullableContext(1)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("maxfoxgaming.betterbeehives", "BetterBeehives", "1.3.0")]
	public class Main : BaseUnityPlugin
	{
		public const string PluginGUID = "maxfoxgaming.betterbeehives";

		public const string PluginName = "BetterBeehives";

		public const string PluginVersion = "1.3.0";

		[<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(2)]
		private static Main instance;

		public static Harmony harmony = new Harmony("maxfoxgaming.betterbeehives");

		public static readonly string ModPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

		[<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(2)]
		public static ManualLogSource Log;

		public static bool SeasonalityPatchDone = false;

		public static bool ZenBeehivePatchDone = false;

		public static bool SeedBedPatchDone = false;

		public static bool GrowBedPatchDone = false;

		public static bool LazyVikingsPatchDone = false;

		public static readonly string Queen = "QueenBee";

		public static readonly string Jelly = "RoyalJelly";

		public void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			instance = this;
			ConfigManager.CreateConfigValues((BaseUnityPlugin)(object)this);
			Harmony val = harmony;
			if (val != null)
			{
				val.PatchAll();
			}
			if (SeasonalityCompatibility.Enabled && !SeasonalityPatchDone)
			{
				SeasonalityPatchDone = SeasonalityCompatibility.DoCompatibilityPatching(val);
			}
			if (ZenBeehiveCompatibility.Enabled && !ZenBeehivePatchDone)
			{
				ZenBeehivePatchDone = ZenBeehiveCompatibility.DoCompatibilityPatching(val);
			}
			if (GrowBedCompatibility.Enabled && !GrowBedPatchDone)
			{
				GrowBedPatchDone = GrowBedCompatibility.DoCompatibilityPatching(val);
			}
			if (SeedBedCompatibility.Enabled && !SeedBedPatchDone)
			{
				SeedBedPatchDone = SeedBedCompatibility.DoCompatibilityPatching(val);
			}
			if (LazyVikingsCompatibility.Enabled && !LazyVikingsPatchDone)
			{
				LazyVikingsPatchDone = LazyVikingsCompatibility.DoCompatibilityPatching(val);
			}
		}

		public void OnDestroy()
		{
			Harmony val = harmony;
			if (val != null)
			{
				val.UnpatchSelf();
			}
			instance = null;
		}

		[<a33d1f5c-09cf-435c-999c-1ff9e12f226e>NullableContext(2)]
		public static Main GetInstance()
		{
			return instance;
		}

		public static void LogMessage(string message)
		{
			if (ConfigManager.DebugLogging.Value)
			{
				Log.LogMessage((object)message);
			}
		}
	}
}
namespace BetterBeehives.Scripts
{
	[<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(0)]
	[<a33d1f5c-09cf-435c-999c-1ff9e12f226e>NullableContext(2)]
	public class BeePollinate : MonoBehaviour
	{
		public ZNetView m_nview;

		public GameObject m_beeEffect;

		public bool m_isSeedBed = false;

		public bool m_isGrowbed = false;

		public void Awake()
		{
			m_nview = ((Component)this).gameObject.GetComponent<ZNetView>();
			m_isSeedBed = ((Object)((Component)this).gameObject).name.NoClone() == "BSB_SeedBed";
			m_isGrowbed = new List<string> { "piece_growbed_wood", "piece_growbed_bronze", "piece_growbed_iron", "piece_growbed_silver" }.Contains(((Object)((Component)this).gameObject).name.NoClone());
			if (!((Object)(object)m_nview == (Object)null) && m_nview.GetZDO() != null)
			{
				m_beeEffect = Object.Instantiate<GameObject>(ZNetScene.instance.GetPrefab("piece_beehive").GetComponent<Beehive>().m_beeEffect, ((Component)this).transform);
				((MonoBehaviour)this).InvokeRepeating("SlowUpdate", 0f, Random.Range(8f, 10f));
			}
		}

		public void SlowUpdate()
		{
			if (ConfigManager.NearbyPlantGrowthChance.Value != 0f && ConfigManager.NearbyPlantGrowthRange.Value != 0f)
			{
				bool flag = Random.Range(0f, 1f) < ConfigManager.BeeDensity.Value;
				bool flag2 = CheckSeedBed() || CheckGrowbed();
				m_beeEffect.SetActive(flag && flag2 && HasActiveHiveNearby());
			}
		}

		public bool HasActiveHiveNearby()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			Collider[] array = Physics.OverlapSphere(((Component)this).transform.position, ConfigManager.NearbyPlantGrowthRange.Value);
			Collider[] array2 = array;
			foreach (Collider val in array2)
			{
				Beehive component = ((Component)((Component)val).transform.root).gameObject.GetComponent<Beehive>();
				if (!((Object)(object)component == (Object)null) && component.ShouldActivateEffect())
				{
					return true;
				}
			}
			return false;
		}

		public bool CheckSeedBed()
		{
			if (SeedBedCompatibility.Enabled && Main.SeedBedPatchDone && m_isSeedBed)
			{
				return ((Component)this).gameObject.IsSeedBedGerminatingOrFinished() && ((Component)this).gameObject.SeedBedHasCorrectPlant();
			}
			return true;
		}

		public bool CheckGrowbed()
		{
			if (GrowBedCompatibility.Enabled && Main.GrowBedPatchDone && m_isGrowbed)
			{
				return ((Component)this).gameObject.IsGrowbedGerminatingOrFinished() && ((Component)this).gameObject.GrowbedHasCorrectPlant();
			}
			return true;
		}
	}
}
namespace BetterBeehives.Patch
{
	internal class Beehive_Extract
	{
		[HarmonyPatch(typeof(Beehive), "RPC_Extract")]
		[<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(0)]
		[<a33d1f5c-09cf-435c-999c-1ff9e12f226e>NullableContext(1)]
		public static class Beehive_RPC_Extract_Patches
		{
			public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
			{
				//IL_0100: Unknown result type (might be due to invalid IL or missing references)
				//IL_010a: Expected O, but got Unknown
				//IL_0112: Unknown result type (might be due to invalid IL or missing references)
				//IL_011c: Expected O, but got Unknown
				//IL_0124: Unknown result type (might be due to invalid IL or missing references)
				//IL_012e: Expected O, but got Unknown
				Main.LogMessage("Applying transpiler patch to Beehive.RPC_Extract()");
				List<CodeInstruction> list = new List<CodeInstruction>(instructions);
				if (!typeof(Beehive).TryGetMethod("ResetLevel", out var method))
				{
					return instructions;
				}
				if (!typeof(Beehive_RPC_Extract_Patches).TryGetMethod("DropQueenBeeAndJelly", out var method2))
				{
					return instructions;
				}
				int num = -1;
				for (int i = 0; i < list.Count - 1; i++)
				{
					if (!(list[i].opcode != OpCodes.Ldarg_0) && !(list[i + 1].opcode != OpCodes.Call) && !(list[i + 1].operand as MethodInfo != method))
					{
						num = i;
						break;
					}
				}
				if (num == -1)
				{
					return instructions;
				}
				List<CodeInstruction> collection = new List<CodeInstruction>
				{
					new CodeInstruction(OpCodes.Ldarg_0, (object)null),
					new CodeInstruction(OpCodes.Ldloc_0, (object)null),
					new CodeInstruction(OpCodes.Call, (object)method2)
				};
				list.InsertRange(num, collection);
				Main.LogMessage("Patch done");
				return list.AsEnumerable();
			}

			public static void DropQueenBeeAndJelly(Beehive beehive, int __state)
			{
				//IL_0079: Unknown result type (might be due to invalid IL or missing references)
				//IL_0083: Unknown result type (might be due to invalid IL or missing references)
				//IL_0088: Unknown result type (might be due to invalid IL or missing references)
				//IL_008f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0094: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
				//IL_0127: Unknown result type (might be due to invalid IL or missing references)
				//IL_012d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0132: Unknown result type (might be due to invalid IL or missing references)
				//IL_0137: Unknown result type (might be due to invalid IL or missing references)
				//IL_013c: Unknown result type (might be due to invalid IL or missing references)
				//IL_013e: Unknown result type (might be due to invalid IL or missing references)
				//IL_013f: Unknown result type (might be due to invalid IL or missing references)
				Main.LogMessage("DropQueenBeeAndJelly");
				if (ZenBeehiveCompatibility.Enabled && Main.ZenBeehivePatchDone && ((Object)((Component)beehive).gameObject).name.Replace("(Clone)", "") == "piece_beehive")
				{
					Main.LogMessage("ZenBeehive detected. Extract cancelling.");
					return;
				}
				if (!beehive.ShouldAddQueenBee(__state))
				{
					Main.LogMessage("No queen will drop.");
					return;
				}
				Vector2 val = Random.insideUnitCircle * 0.5f;
				Vector3 val2 = beehive.m_spawnPoint.position + new Vector3(val.x, 0.25f * (float)__state, val.y);
				ItemDrop component = ObjectDB.instance.GetItemPrefab(Main.Queen).GetComponent<ItemDrop>();
				Main.LogMessage("Queen Bee Dropped!");
				Object.Instantiate<ItemDrop>(component, val2, Quaternion.identity);
				ItemDrop component2 = ObjectDB.instance.GetItemPrefab(Main.Jelly).GetComponent<ItemDrop>();
				int num = 0;
				for (int i = 0; i < ConfigManager.RoyalJellyDropAttempts.Value; i++)
				{
					if (!(Random.Range(0f, 1f) > ConfigManager.RoyalJellyDropChance.Value))
					{
						num++;
						val2 += 0.25f * Vector3.up;
						Object.Instantiate<ItemDrop>(component2, val2, Quaternion.identity);
					}
				}
				Main.LogMessage("Dropping " + num + " royal jelly.");
			}
		}
	}
	internal class Beehive_IncreaseLevel
	{
		[<a33d1f5c-09cf-435c-999c-1ff9e12f226e>NullableContext(1)]
		[HarmonyPatch(typeof(Beehive), "IncreseLevel")]
		[<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(0)]
		public static class Beehive_IncreaseLevel_Patches
		{
			public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator il)
			{
				//IL_0180: Unknown result type (might be due to invalid IL or missing references)
				//IL_018a: Expected O, but got Unknown
				//IL_0192: Unknown result type (might be due to invalid IL or missing references)
				//IL_019c: Expected O, but got Unknown
				//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b5: Expected O, but got Unknown
				//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c7: Expected O, but got Unknown
				//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d9: Expected O, but got Unknown
				//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
				//IL_01eb: Expected O, but got Unknown
				//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
				//IL_01fd: Expected O, but got Unknown
				//IL_0205: Unknown result type (might be due to invalid IL or missing references)
				//IL_020f: Expected O, but got Unknown
				//IL_0217: Unknown result type (might be due to invalid IL or missing references)
				//IL_0221: Expected O, but got Unknown
				//IL_0229: Unknown result type (might be due to invalid IL or missing references)
				//IL_0233: Expected O, but got Unknown
				//IL_023c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0246: Expected O, but got Unknown
				//IL_024e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0258: Expected O, but got Unknown
				//IL_0260: Unknown result type (might be due to invalid IL or missing references)
				//IL_026a: Expected O, but got Unknown
				//IL_0273: Unknown result type (might be due to invalid IL or missing references)
				//IL_027d: Expected O, but got Unknown
				Main.LogMessage("Applying transpiler patch to Beehive.IncreseLevel()");
				LocalBuilder localBuilder = il.DeclareLocal(typeof(int));
				LocalBuilder localBuilder2 = il.DeclareLocal(typeof(bool));
				List<CodeInstruction> list = new List<CodeInstruction>(instructions);
				if (!typeof(Beehive).TryGetMethod("GetHoneyLevel", out var method))
				{
					return instructions;
				}
				if (!typeof(Beehive_IncreaseLevel_Patches).TryGetMethod("GrowPlants", out var method2))
				{
					return instructions;
				}
				if (!typeof(Beehive_IncreaseLevel_Patches).TryGetMethod("FillContainer", out var method3))
				{
					return instructions;
				}
				int num = -1;
				int index = list.Count - 1;
				for (int i = 2; i < list.Count; i++)
				{
					if (!(list[i - 2].opcode != OpCodes.Ldarg_0) && !(list[i - 1].opcode != OpCodes.Call) && !(list[i - 1].operand as MethodInfo != method) && !(list[i].opcode != OpCodes.Stloc_0))
					{
						num = i + 1;
						break;
					}
				}
				if (num == -1)
				{
					return instructions;
				}
				List<CodeInstruction> collection = new List<CodeInstruction>
				{
					new CodeInstruction(OpCodes.Ldloc_0, (object)null),
					new CodeInstruction(OpCodes.Stloc_S, (object)localBuilder)
				};
				List<CodeInstruction> collection2 = new List<CodeInstruction>
				{
					new CodeInstruction(OpCodes.Ldloc_0, (object)null),
					new CodeInstruction(OpCodes.Ldloc_S, (object)localBuilder),
					new CodeInstruction(OpCodes.Ceq, (object)null),
					new CodeInstruction(OpCodes.Ldc_I4_0, (object)null),
					new CodeInstruction(OpCodes.Ceq, (object)null),
					new CodeInstruction(OpCodes.Stloc_S, (object)localBuilder2),
					new CodeInstruction(OpCodes.Ldarg_0, (object)null),
					new CodeInstruction(OpCodes.Ldloc_S, (object)localBuilder2),
					new CodeInstruction(OpCodes.Call, (object)method2),
					new CodeInstruction(OpCodes.Ldarg_0, (object)null),
					new CodeInstruction(OpCodes.Ldloc_S, (object)localBuilder2),
					new CodeInstruction(OpCodes.Call, (object)method3)
				};
				list.InsertRange(index, collection2);
				list.InsertRange(num, collection);
				Main.LogMessage("Patch Done");
				return list;
			}

			public static void GrowPlants(Beehive __instance, bool changed)
			{
				//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
				Main.LogMessage("Growing Plants and Pickables");
				if (!changed)
				{
					Main.LogMessage("Invalid State");
					return;
				}
				if (!__instance.m_nview.IsOwner())
				{
					Main.LogMessage("Not the owner.");
					return;
				}
				GameObject gameObject = ((Component)__instance).gameObject;
				if ((Object)(object)gameObject == (Object)null)
				{
					Main.LogMessage("No beehive.");
					return;
				}
				if (!__instance.CheckBiome())
				{
					Main.LogMessage("Not the correct biome.");
					return;
				}
				if (!EnvManHelper.BeesCanPollinateInCurrentSeason())
				{
					Main.LogMessage("Not the correct season.");
					return;
				}
				List<GameObject> list = __instance.FindAllPollinatesInRadius(ConfigManager.NearbyPlantGrowthRange.Value);
				foreach (GameObject item in list)
				{
					Main.LogMessage("Found GameObject " + ((Object)item).name.NoClone() + " at coordinates " + ((object)item.transform.position/*cast due to .constrained prefix*/).ToString());
					HandlePlantGrowth(item);
					HandlePickableGrowth(item);
					if (SeedBedCompatibility.Enabled && Main.SeedBedPatchDone)
					{
						SeedBedCompatibility.HandleSeedBedGrowth(item);
					}
					if (GrowBedCompatibility.Enabled && Main.GrowBedPatchDone)
					{
						GrowBedCompatibility.HandleSeedBedGrowth(item);
					}
				}
			}

			public static void FillContainer(Beehive beehive, bool changed)
			{
				Main.LogMessage("ZenBeehive Compatibility: Filling Beehive Container");
				if (!ZenBeehiveCompatibility.Enabled)
				{
					Main.LogMessage("ZenBeehive not enabled. Skipping.");
					return;
				}
				if (!changed)
				{
					Main.LogMessage("No change to honey level");
					return;
				}
				Container component = ((Component)beehive).gameObject.GetComponent<Container>();
				if ((Object)(object)component == (Object)null)
				{
					Main.LogMessage("Container not found.");
					return;
				}
				GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(((Object)beehive.m_honeyItem).name);
				GameObject itemPrefab2 = ObjectDB.instance.GetItemPrefab(Main.Queen);
				GameObject itemPrefab3 = ObjectDB.instance.GetItemPrefab(Main.Jelly);
				int honeyLevel = beehive.GetHoneyLevel();
				Inventory inventory = component.GetInventory();
				inventory.SetItem(itemPrefab, honeyLevel, 0, 0);
				Main.LogMessage("Set honey level to " + honeyLevel + " in hive.");
				if (!inventory.HasItemInSlot(itemPrefab2, 1, 0) && inventory.GetItemAt(1, 0) != null)
				{
					inventory.RemoveItemAt(1, 0);
				}
				if (!inventory.HasItemInSlot(itemPrefab3, 2, 0) && inventory.GetItemAt(2, 0) != null)
				{
					inventory.RemoveItemAt(2, 0);
				}
				if (!beehive.ShouldAddQueenBee())
				{
					Main.LogMessage("Queen bee conditions not met. Not adding.");
					return;
				}
				if (!inventory.SetItem(itemPrefab2, 1, 1, 0))
				{
					Main.LogMessage("Tried to add queen bee but failed. Inventory has no room.");
					return;
				}
				Main.LogMessage("Added queen bee to internal inventory.");
				if (inventory.HasItemInSlot(itemPrefab3, 2, 0))
				{
					Main.LogMessage("Royal Jelly already present in hive. No need to add more.");
					return;
				}
				int num = 0;
				for (int i = 0; i < ConfigManager.RoyalJellyDropAttempts.Value; i++)
				{
					if (!(Random.Range(0f, 1f) > ConfigManager.RoyalJellyDropChance.Value))
					{
						num++;
					}
				}
				if (num != 0)
				{
					inventory.SetItem(itemPrefab3, num, 2, 0);
					Main.LogMessage("Added " + num + " royal jelly to container.");
				}
			}

			public static void HandlePlantGrowth(GameObject gameObject)
			{
				if (!gameObject.TryGetPlantComponent(out var plant))
				{
					Main.LogMessage("Could not find a Plant component.");
					return;
				}
				Main.LogMessage("Found a Plant component. Attempting to grow.");
				float num = Random.Range(0f, 1f);
				if (num > ConfigManager.NearbyPlantGrowthChance.Value)
				{
					Main.LogMessage("Failed probability check. Plant will not grow.");
					return;
				}
				Main.LogMessage("Passed probability check. Growing plant.");
				gameObject.SetGrowthEffects();
				plant.Grow();
			}

			public static void HandlePickableGrowth(GameObject gameObject)
			{
				if (!gameObject.TryGetPickableComponent(out var pickable))
				{
					Main.LogMessage("Could not find a Pickable component.");
					return;
				}
				Main.LogMessage("Found a Pickable component.");
				if (pickable.CanBePicked())
				{
					Main.LogMessage("Pickable is ready to be picked now. No need to grow.");
					return;
				}
				float num = Random.Range(0f, 1f);
				if (num > ConfigManager.NearbyPlantGrowthChance.Value)
				{
					Main.LogMessage("Failed probability check. Pickable will not grow.");
					return;
				}
				Main.LogMessage("Passed probability check. Growing pickable.");
				gameObject.SetGrowthEffects();
				pickable.m_nview.InvokeRPC(ZNetView.Everybody, "RPC_SetPicked", new object[1] { false });
			}
		}
	}
	internal class ZNetScene_Awake
	{
		[HarmonyPatch(typeof(ZNetScene), "Awake")]
		public static class ZNetScene_Awake_Patches
		{
			[<a33d1f5c-09cf-435c-999c-1ff9e12f226e>NullableContext(1)]
			public static void Postfix(ZNetScene __instance)
			{
				foreach (string item in ConfigManager.NearbyPlantsGrowthList.Value)
				{
					__instance.AddBeePollinateComponent(item);
				}
				foreach (string item2 in ConfigManager.NearbyPickablesGrowthList.Value)
				{
					__instance.AddBeePollinateComponent(item2);
				}
			}
		}
	}
}
namespace BetterBeehives.Data
{
	[<a33d1f5c-09cf-435c-999c-1ff9e12f226e>NullableContext(2)]
	[<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(0)]
	public class ConfigManager
	{
		public static ConfigSync configSync;

		public static ConfigEntry<bool> DebugLogging;

		[<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(new byte[] { 2, 1 })]
		public static ConfigEntry<string> BeehivePrefabs;

		public static ConfigEntry<float> QueenBeeDropChance;

		public static ConfigEntry<float> RoyalJellyDropChance;

		public static ConfigEntry<int> RoyalJellyDropAttempts;

		public static ConfigEntry<float> NearbyPlantGrowthChance;

		public static ConfigEntry<float> NearbyPlantGrowthRange;

		[<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(new byte[] { 2, 1 })]
		public static ConfigEntry<string> NearbyPlantsGrowth;

		[<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(new byte[] { 2, 1 })]
		public static ConfigEntry<string> NearbyPickablesGrowth;

		public static ConfigEntry<float> BeeDensity;

		[<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(new byte[] { 2, 1 })]
		public static ConfigEntry<string> GlobalKeySpring;

		[<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(new byte[] { 2, 1 })]
		public static ConfigEntry<string> GlobalKeySummer;

		[<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(new byte[] { 2, 1 })]
		public static ConfigEntry<string> GlobalKeyFall;

		[<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(new byte[] { 2, 1 })]
		public static ConfigEntry<string> GlobalKeyWinter;

		public static ConfigEntry<bool> PollinateInSpring;

		public static ConfigEntry<bool> PollinateInSummer;

		public static ConfigEntry<bool> PollinateInFall;

		public static ConfigEntry<bool> PollinateInWinter;

		[<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(new byte[] { 2, 1 })]
		public static ConfigEntry<string> SeedBedPlants;

		[<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(new byte[] { 2, 1, 1 })]
		public static CustomSyncedValue<List<string>> BeehivePrefabsList;

		[<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(new byte[] { 2, 1, 1 })]
		public static CustomSyncedValue<List<string>> NearbyPlantsGrowthList;

		[<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(new byte[] { 2, 1, 1 })]
		public static CustomSyncedValue<List<string>> NearbyPickablesGrowthList;

		[<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(new byte[] { 2, 1, 1 })]
		public static CustomSyncedValue<List<string>> SeedBedPlantsList;

		[<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(new byte[] { 2, 1, 1 })]
		public static CustomSyncedValue<List<string>> BeehivePrefabsLowerList;

		[<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(new byte[] { 2, 1, 1 })]
		public static CustomSyncedValue<List<string>> NearbyPlantsGrowthLowerList;

		[<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(new byte[] { 2, 1, 1 })]
		public static CustomSyncedValue<List<string>> NearbyPickablesGrowthLowerList;

		[<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(new byte[] { 2, 1, 1 })]
		public static CustomSyncedValue<List<string>> SeedBedPlantsLowerList;

		[<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(1)]
		public static List<string> DefaultPlants = new List<string>
		{
			"sapling_barley", "sapling_carrot", "sapling_flax", "sapling_jotunpuffs", "sapling_kale", "sapling_magecap", "sapling_oat", "sapling_onion", "sapling_poteitr", "sapling_turnip",
			"sapling_seedcarrot", "sapling_seedonion", "sapling_seedturnip", "sapling_seedKale", "VineAsh_sapling", "VineGreen_sapling"
		};

		[<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(1)]
		public static List<string> DefaultPickables = new List<string>
		{
			"Pickable_Dandelion", "Pickable_Fiddlehead", "Pickable_Mushroom", "Pickable_Mushroom_yellow", "Pickable_Mushroom_JotunPuffs", "Pickable_Mushroom_Magecap", "Pickable_Oat", "Pickable_Onion", "Pickable_Poteitr", "Pickable_SeedCarrot",
			"Pickable_SeedKale", "Pickable_SeedOnion", "Pickable_SeedTurnip", "Pickable_SmokePuff", "Pickable_Thistle", "Pickable_Turnip", "RaspberryBush", "BlueberryBush", "CloudberryBush", "LingonberryBush"
		};

		[<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(1)]
		public static List<string> DefaultPlantsForSeedBeds = new List<string>
		{
			"Barley", "Carrot", "Dandelion", "Flax", "Kale", "Mushroom", "MushroomYellow", "MushroomJotunPuffs", "MushroomMagecap", "MushroomSmokePuff",
			"Oat", "Onion", "Poteitr", "Turnip", "Acorn", "BeechSeeds", "BirchSeeds", "CarrotSeeds", "KaleSeeds", "OatSeeds",
			"OnionSeeds", "PoteitrSeeds", "TurnipSeeds", "VineberrySeeds", "VineGreenSeeds"
		};

		[<a33d1f5c-09cf-435c-999c-1ff9e12f226e>NullableContext(1)]
		public static void CreateConfigValues(BaseUnityPlugin plugin)
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Expected O, but got Unknown
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Expected O, but got Unknown
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Expected O, but got Unknown
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Expected O, but got Unknown
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Expected O, but got Unknown
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Expected O, but got Unknown
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Expected O, but got Unknown
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Expected O, but got Unknown
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Expected O, but got Unknown
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Expected O, but got Unknown
			//IL_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Expected O, but got Unknown
			//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: Expected O, but got Unknown
			//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0300: Expected O, but got Unknown
			//IL_0325: Unknown result type (might be due to invalid IL or missing references)
			//IL_0330: Expected O, but got Unknown
			//IL_0351: Unknown result type (might be due to invalid IL or missing references)
			//IL_035c: Expected O, but got Unknown
			//IL_037d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0388: Expected O, but got Unknown
			//IL_03a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b4: Expected O, but got Unknown
			//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e0: Expected O, but got Unknown
			//IL_040f: Unknown result type (might be due to invalid IL or missing references)
			//IL_041a: Expected O, but got Unknown
			configSync = new ConfigSync("maxfoxgaming.betterbeehives")
			{
				DisplayName = "BetterBeehives",
				CurrentVersion = "1.3.0",
				MinimumRequiredVersion = "1.3.0"
			};
			plugin.Config.SaveOnConfigSet = true;
			DebugLogging = plugin.Config.BindServer("0. Logging", "Logs Enabled", value: false, new ConfigDescription("Whether the mod should print outputs and data to the console. Only needed for debugging.", (AcceptableValueBase)null, Array.Empty<object>()));
			BeehivePrefabs = plugin.Config.BindServer("1. Beehives", "Beehive Prefabs", "piece_beehive", new ConfigDescription("A comma separated list of build pieces that should be considered for Better Beehives.", (AcceptableValueBase)null, Array.Empty<object>()));
			QueenBeeDropChance = plugin.Config.BindServer("1. Beehives", "Queen Bee Drop Chance", 0.05f, new ConfigDescription("When the beehive has full honey level, this is the chance that a queen bee will also be collected.\nYou can still harvest with less than full honey and the resulting chance will be scaled down to match how full the hive is.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			RoyalJellyDropChance = plugin.Config.BindServer("1. Beehives", "Royal Jelly Drop Chance", 0.6f, new ConfigDescription("If a queen bee is successfully retrieved, this is the chance that you will also get royal jelly.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			RoyalJellyDropAttempts = plugin.Config.BindServer("1. Beehives", "Royal Jelly Drop Attempts", 3, new ConfigDescription("How many attempts are made to drop a piece of Royal Jelly. Each piece will haev the configured set chance to spawn.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 5), Array.Empty<object>()));
			NearbyPlantGrowthChance = plugin.Config.BindServer("2. Plants", "Nearby Plants Growth Chance", 0.05f, new ConfigDescription("When the beehive ticks and generates a honey, this value determines how likely a nearby plant is to grow (per plant).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			NearbyPlantGrowthRange = plugin.Config.BindServer("2. Plants", "Nearby Plants Range", 5f, new ConfigDescription("The range around a beehive that plants grow. Spherical.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 20f), Array.Empty<object>()));
			NearbyPlantsGrowth = plugin.Config.BindServer("2. Plants", "Nearby Growable Plants", string.Join(",", DefaultPlants), new ConfigDescription("Player placed plants that can be grown faster by nearby beehives.", (AcceptableValueBase)null, Array.Empty<object>()));
			NearbyPickablesGrowth = plugin.Config.BindServer("2. Plants", "Nearby Growable Pickables", string.Join(",", DefaultPickables), new ConfigDescription("Pickable items that can be regrown by nearby beehives that are not player placed crops and plants.", (AcceptableValueBase)null, Array.Empty<object>()));
			BeeDensity = plugin.Config.Bind<float>("3. Client", "Bee Density", 0.4f, new ConfigDescription("If bees are set to nearby plants, this will control how many bee particles appear around plants that are affected.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			GlobalKeySpring = plugin.Config.BindServer("4. Season Mod Integration", "Global Key for Spring", "season_spring", new ConfigDescription("If a seasons mod is installed such as Seasonality or Seasons, what global key is used to represent Spring. Note that for Shudnal's Seasons mod, you must turn on seasonal global keys. It is on by default in Seasonality.", (AcceptableValueBase)null, Array.Empty<object>()));
			GlobalKeySummer = plugin.Config.BindServer("4. Season Mod Integration", "Global Key for Summer", "season_summer", new ConfigDescription("If a seasons mod is installed such as Seasonality or Seasons, what global key is used to represent Summer. Note that for Shudnal's Seasons mod, you must turn on seasonal global keys. It is on by default in Seasonality.", (AcceptableValueBase)null, Array.Empty<object>()));
			GlobalKeyFall = plugin.Config.BindServer("4. Season Mod Integration", "Global Key for Fall", "season_fall", new ConfigDescription("If a seasons mod is installed such as Seasonality or Seasons, what global key is used to represent Fall. Note that for Shudnal's Seasons mod, you must turn on seasonal global keys. It is on by default in Seasonality.", (AcceptableValueBase)null, Array.Empty<object>()));
			GlobalKeyWinter = plugin.Config.BindServer("4. Season Mod Integration", "Global Key for Winter", "season_winter", new ConfigDescription("If a seasons mod is installed such as Seasonality or Seasons, what global key is used to represent Winter. Note that for Shudnal's Seasons mod, you must turn on seasonal global keys. It is on by default in Seasonality.", (AcceptableValueBase)null, Array.Empty<object>()));
			PollinateInSpring = plugin.Config.BindServer("4. Season Mod Integration", "Pollinate in Spring", value: true, new ConfigDescription("Whether the beehive should increase plant growth during Spring. If Seasons is installed, only the plant growth is affected since Seasons handles whether the hive itself is active or not. If Seasonality is installed, this will also determine if the hive itself is active.", (AcceptableValueBase)null, Array.Empty<object>()));
			PollinateInSummer = plugin.Config.BindServer("4. Season Mod Integration", "Pollinate in Summer", value: true, new ConfigDescription("Whether the beehive should increase plant growth during Summer. If Seasons is installed, only the plant growth is affected since Seasons handles whether the hive itself is active or not. If Seasonality is installed, this will also determine if the hive itself is active.", (AcceptableValueBase)null, Array.Empty<object>()));
			PollinateInFall = plugin.Config.BindServer("4. Season Mod Integration", "Pollinate in Fall", value: true, new ConfigDescription("Whether the beehive should increase plant growth during Fall. If Seasons is installed, only the plant growth is affected since Seasons handles whether the hive itself is active or not. If Seasonality is installed, this will also determine if the hive itself is active.", (AcceptableValueBase)null, Array.Empty<object>()));
			PollinateInWinter = plugin.Config.BindServer("4. Season Mod Integration", "Pollinate in Winter", value: false, new ConfigDescription("Whether the beehive should increase plant growth during Winter. If Seasons is installed, only the plant growth is affected since Seasons handles whether the hive itself is active or not. If Seasonality is installed, this will also determine if the hive itself is active.", (AcceptableValueBase)null, Array.Empty<object>()));
			SeedBedPlants = plugin.Config.BindServer("5. SeedBed / Growbed Mod Integration", "Additional Plants for Grow Beds", string.Join(",", DefaultPlantsForSeedBeds), new ConfigDescription("If SeedBed or Growbeds is installed, these plant names will also be checked when attempting to boost growth.", (AcceptableValueBase)null, Array.Empty<object>()));
			BeehivePrefabsList = new CustomSyncedValue<List<string>>(configSync, "BetterBeehivesBeehivePrefabsList", BeehivePrefabs.Value.Replace(" ", "").Split().ToList());
			NearbyPlantsGrowthList = new CustomSyncedValue<List<string>>(configSync, "BetterBeehivesPlantsGrowthList", NearbyPlantsGrowth.Value.Replace(" ", "").Split(new char[1] { ',' }).ToList());
			NearbyPickablesGrowthList = new CustomSyncedValue<List<string>>(configSync, "BetterBeehivesPickablesGrowthList", NearbyPickablesGrowth.Value.Replace(" ", "").Split(new char[1] { ',' }).ToList());
			SeedBedPlantsList = new CustomSyncedValue<List<string>>(configSync, "BetterBeehivesSeedBedPlantsList", SeedBedPlants.Value.Replace(" ", "").Split(new char[1] { ',' }).ToList());
			BeehivePrefabsLowerList = new CustomSyncedValue<List<string>>(configSync, "BetterBeehivesBeehivePrefabsLowerList", BeehivePrefabs.Value.Replace(" ", "").ToLower().Split()
				.ToList());
			NearbyPlantsGrowthLowerList = new CustomSyncedValue<List<string>>(configSync, "BetterBeehivesPlantsGrowthLowerList", NearbyPlantsGrowth.Value.Replace(" ", "").ToLower().Split(new char[1] { ',' })
				.ToList());
			NearbyPickablesGrowthLowerList = new CustomSyncedValue<List<string>>(configSync, "BetterBeehivesPickablesGrowthLowerList", NearbyPickablesGrowth.Value.Replace(" ", "").ToLower().Split(new char[1] { ',' })
				.ToList());
			SeedBedPlantsLowerList = new CustomSyncedValue<List<string>>(configSync, "BetterBeehivesSeedBedPlantsLowerList", SeedBedPlants.Value.Replace(" ", "").ToLower().Split(new char[1] { ',' })
				.ToList());
		}
	}
	public static class EnvManHelper
	{
		public enum Season
		{
			Spring,
			Summer,
			Fall,
			Winter,
			None
		}

		public static bool BeesCanPollinateInCurrentSeason()
		{
			Season season = GetSeason();
			Main.LogMessage($"Current Season: {season}");
			return season switch
			{
				Season.Spring => ConfigManager.PollinateInSpring.Value, 
				Season.Summer => ConfigManager.PollinateInSummer.Value, 
				Season.Fall => ConfigManager.PollinateInFall.Value, 
				Season.Winter => ConfigManager.PollinateInWinter.Value, 
				_ => true, 
			};
		}

		public static Season GetSeason()
		{
			ZoneSystem instance = ZoneSystem.instance;
			List<string> list = ((instance != null) ? instance.GetGlobalKeys() : null) ?? new List<string>();
			if (list.Contains(ConfigManager.GlobalKeySpring.Value))
			{
				return Season.Spring;
			}
			if (list.Contains(ConfigManager.GlobalKeySummer.Value))
			{
				return Season.Summer;
			}
			if (list.Contains(ConfigManager.GlobalKeyFall.Value))
			{
				return Season.Fall;
			}
			if (list.Contains(ConfigManager.GlobalKeyWinter.Value))
			{
				return Season.Winter;
			}
			return Season.None;
		}
	}
	[<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(0)]
	[<a33d1f5c-09cf-435c-999c-1ff9e12f226e>NullableContext(1)]
	public static class Helper
	{
		public static ConfigEntry<T> BindServer<[<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(2)] T>(this ConfigFile config, string group, string name, T value, ConfigDescription description, bool synchronizedSetting = true)
		{
			ConfigEntry<T> val = config.Bind<T>(group, name, value, description);
			SyncedConfigEntry<T> syncedConfigEntry = ConfigManager.configSync.AddConfigEntry<T>(val);
			syncedConfigEntry.SynchronizedConfig = synchronizedSetting;
			return val;
		}

		public static void PrintInstructions(this List<CodeInstruction> instructions)
		{
			for (int i = 0; i < instructions.Count; i++)
			{
				Main.LogMessage(((object)instructions[i]).ToString());
			}
		}

		public static bool TryGetField(this Assembly assembly, string typeName, string fieldName, [<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(2)] out FieldInfo field)
		{
			field = null;
			Type type = assembly.GetType(typeName);
			if (type == null)
			{
				Main.LogMessage(typeName + " class not found.");
				return false;
			}
			return type.TryGetField(fieldName, out field);
		}

		public static bool TryGetField(this Type type, string fieldName, [<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(2)] out FieldInfo field)
		{
			field = type.GetField(fieldName, AccessTools.all);
			return field != null;
		}

		public static bool TryGetMethod(this Assembly assembly, string typeName, string methodName, [<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(2)] out MethodInfo method)
		{
			method = null;
			Type type = assembly.GetType(typeName);
			if (type == null)
			{
				Main.LogMessage(typeName + " class not found.");
				return false;
			}
			return type.TryGetMethod(methodName, out method);
		}

		public static bool TryGetMethod(this Type type, string methodName, [<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(2)] out MethodInfo method)
		{
			method = type.GetMethod(methodName, AccessTools.all);
			return method != null;
		}

		public static void SetupPollinatePrefab(this GameObject prefab)
		{
			BeePollinate component = prefab.GetComponent<BeePollinate>();
			if ((Object)(object)component == (Object)null)
			{
				prefab.AddComponent<BeePollinate>();
			}
			Main.LogMessage("Applied BeePollinate MonoBehaviour to " + ((Object)prefab).name);
		}

		public static void AddBeePollinateComponent(this ZNetScene zNetScene, string prefabName)
		{
			GameObject prefab = zNetScene.GetPrefab(prefabName);
			if (!((Object)(object)prefab == (Object)null))
			{
				prefab.SetupPollinatePrefab();
			}
		}

		public static bool TryGetBeePollinateComponent(this GameObject gameObject, out BeePollinate beePollinate)
		{
			return (Object)(object)(beePollinate = gameObject.GetComponent<BeePollinate>()) != (Object)null;
		}

		public static bool TryGetPlantComponent(this GameObject gameObject, [<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(2)] out Plant plant)
		{
			return (Object)(object)(plant = gameObject.GetComponent<Plant>()) != (Object)null && ConfigManager.NearbyPlantsGrowthLowerList.Value.Contains(((Object)gameObject).name.ToLower().NoClone());
		}

		public static bool TryGetPickableComponent(this GameObject gameObject, [<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(2)] out Pickable pickable)
		{
			return (Object)(object)(pickable = gameObject.GetComponent<Pickable>()) != (Object)null && ConfigManager.NearbyPickablesGrowthLowerList.Value.Contains(((Object)gameObject).name.ToLower().NoClone());
		}

		public static bool ShouldAddQueenBee(this Beehive beehive, int honeyLevel = -1)
		{
			int num = ((honeyLevel == -1) ? beehive.GetHoneyLevel() : honeyLevel);
			float num2 = (float)num / (float)beehive.m_maxHoney * ConfigManager.QueenBeeDropChance.Value;
			return Random.Range(0f, 1f) <= num2;
		}

		public static bool ShouldActivateEffect(this Beehive beehive)
		{
			bool flag = beehive.CheckBiome();
			bool flag2 = beehive.HaveFreeSpace();
			bool flag3 = !beehive.m_effectOnlyInDaylight || EnvMan.IsDaylight();
			bool flag4 = EnvManHelper.BeesCanPollinateInCurrentSeason();
			return flag && flag2 && flag3 && flag4;
		}

		public static void SetGrowthEffects(this GameObject gameObject)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			EffectList val = new EffectList();
			val.m_effectPrefabs = (EffectData[])(object)new EffectData[1]
			{
				new EffectData
				{
					m_prefab = ZNetScene.s_instance.GetPrefab("fx_BonusYield"),
					m_enabled = true,
					m_variant = -1
				}
			};
			val.Create(gameObject.transform.position, gameObject.transform.rotation, (Transform)null, 1f, -1, default(ZDOID));
		}

		public static List<BeePollinate> GetNearbyBeePollinatePlants(this GameObject beehive)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			List<BeePollinate> list = new List<BeePollinate>();
			Collider[] array = Physics.OverlapSphere(beehive.transform.position, ConfigManager.NearbyPlantGrowthRange.Value);
			Collider[] array2 = array;
			foreach (Collider val in array2)
			{
				GameObject gameObject = ((Component)val).gameObject;
				if (gameObject.TryGetBeePollinateComponent(out var beePollinate))
				{
					list.Add(beePollinate);
				}
			}
			return list;
		}

		public static List<GameObject> GetNearbyPickablesPlants(this GameObject beehive)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			List<GameObject> list = new List<GameObject>();
			Collider[] array = Physics.OverlapSphere(beehive.transform.position, ConfigManager.NearbyPlantGrowthRange.Value);
			Collider[] array2 = array;
			foreach (Collider val in array2)
			{
				GameObject gameObject = ((Component)val).gameObject;
				if (gameObject.TryGetPlantComponent(out var _) || gameObject.TryGetPickableComponent(out var _))
				{
					list.Add(gameObject);
				}
			}
			return list;
		}

		public static bool AddBeeEffectToPlant(this Beehive beehive, GameObject plant, [<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(2)] out GameObject effect)
		{
			effect = null;
			if ((Object)(object)beehive.m_beeEffect == (Object)null)
			{
				return false;
			}
			if (beehive.TryGetBeeEffect(plant, out effect))
			{
				return true;
			}
			effect = Object.Instantiate<GameObject>(beehive.m_beeEffect, plant.transform);
			effect.SetActive(false);
			return true;
		}

		public static bool TryGetBeeEffect(this Beehive beehive, GameObject plant, [<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(2)] out GameObject effect)
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			effect = null;
			if ((Object)(object)beehive.m_beeEffect == (Object)null)
			{
				return false;
			}
			string text = ((Object)beehive.m_beeEffect.transform).name.ToLower().NoClone();
			foreach (Transform item in plant.transform)
			{
				Transform val = item;
				if (((Object)val).name.ToLower().NoClone() != text)
				{
					continue;
				}
				effect = ((Component)val).gameObject;
				return true;
			}
			return false;
		}

		public static string NoClone(this string str)
		{
			return str.Replace("(Clone)", "").Trim();
		}

		public static bool SetItem(this Inventory inventory, [<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(2)] GameObject prefab, int amount, int x, int y)
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			inventory.RemoveItemAt(x, y);
			if ((Object)(object)prefab == (Object)null || amount <= 0)
			{
				return true;
			}
			ItemData val = prefab.GetComponent<ItemDrop>().m_itemData.Clone();
			val.m_dropPrefab = prefab;
			val.m_stack = Mathf.Min(amount, val.m_shared.m_maxStackSize);
			val.m_worldLevel = (byte)Game.m_worldLevel;
			return inventory.AddItem(val, new Vector2i(x, y));
		}

		public static bool RemoveItemAt(this Inventory inventory, int x, int y)
		{
			if (inventory.GetItemAt(x, y) == null)
			{
				return false;
			}
			int num = y * inventory.m_width + x;
			return inventory.RemoveItem(num);
		}

		public static bool HasItemInSlot(this Inventory inventory, GameObject prefab, int x, int y)
		{
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			ItemDrop component = prefab.GetComponent<ItemDrop>();
			if ((Object)(object)component == (Object)null)
			{
				return false;
			}
			ItemData itemData = component.m_itemData;
			Vector2i val = default(Vector2i);
			((Vector2i)(ref val))..ctor(x, y);
			foreach (ItemData item in inventory.m_inventory)
			{
				if (item.m_shared.m_name != itemData.m_shared.m_name || item.m_gridPos != val)
				{
					continue;
				}
				return true;
			}
			return false;
		}

		public static void SetMaxStackValueAtIndex(this InventoryGrid grid, int index, int maxStack)
		{
			Inventory inventory = grid.GetInventory();
			if (inventory.m_inventory.Count > index)
			{
				ItemData item = grid.GetInventory().GetItem(index);
				if (item != null)
				{
					int num = Math.Min(item.m_shared.m_maxStackSize, maxStack);
					grid.m_elements[index].m_amount.text = $"{item.m_stack}/{num}";
				}
			}
		}

		public static List<GameObject> FindAllPollinatesInRadius(this Beehive beehive, float radius)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			float num = radius * radius;
			BeePollinate[] array = Object.FindObjectsByType<BeePollinate>((FindObjectsSortMode)0);
			List<GameObject> list = new List<GameObject>();
			BeePollinate[] array2 = array;
			foreach (BeePollinate beePollinate in array2)
			{
				if (!(CalculateSquaredDistanceXZ(((Component)beePollinate).gameObject.transform.position, ((Component)beehive).gameObject.transform.position) > num))
				{
					list.Add(((Component)beePollinate).gameObject);
				}
			}
			return list;
		}

		public static float CalculateSquaredDistanceXZ(Vector3 vector1, Vector3 vector2)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			float num = vector2.z - vector1.z;
			float num2 = vector2.x - vector1.x;
			return num * num + num2 * num2;
		}
	}
}
namespace BetterBeehives.Compatibility
{
	[<a33d1f5c-09cf-435c-999c-1ff9e12f226e>NullableContext(1)]
	[<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(0)]
	public static class GrowBedCompatibility
	{
		[<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(2)]
		private static MethodInfo GrowbedAwakeM;

		[<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(2)]
		private static MethodInfo ZNetSceneAwakeM;

		[<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(2)]
		private static MethodInfo GrowbedAwakeTranspilerM;

		[<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(2)]
		private static MethodInfo ZNetSceneAwakePostfixM;

		private static readonly string ModGUID = "com.noodle.growbed";

		private static float _germinationHalfDuration = 0f;

		private static bool? _enabled;

		public static bool Enabled
		{
			get
			{
				if (!_enabled.HasValue)
				{
					_enabled = Chainloader.PluginInfos.ContainsKey(ModGUID);
				}
				return _enabled.Value;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static bool DoCompatibilityPatching(Harmony harmony)
		{
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Expected O, but got Unknown
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Expected O, but got Unknown
			Main.LogMessage("GrowBed is installed. Starting compatibility patches...");
			bool flag = true;
			flag &= TryGetGrowBedMethod("GrowbedMod.Growbed", "Awake", out GrowbedAwakeM);
			flag &= typeof(ZNetScene).TryGetMethod("Awake", out ZNetSceneAwakeM);
			flag &= TryGetBetterBeehivesMethod("GrowbedAwakeTranspiler", out GrowbedAwakeTranspilerM);
			if (!(flag & TryGetBetterBeehivesMethod("ZNetSceneAwakePostfix", out ZNetSceneAwakePostfixM)))
			{
				Main.LogMessage("A problem occurred when attempting to patch GrowBed. Operation cancelled.");
				return false;
			}
			harmony.Patch((MethodBase)GrowbedAwakeM, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(GrowbedAwakeTranspilerM), (HarmonyMethod)null, (HarmonyMethod)null);
			harmony.Patch((MethodBase)ZNetSceneAwakeM, (HarmonyMethod)null, new HarmonyMethod(ZNetSceneAwakePostfixM), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			Main.LogMessage("All patches done.");
			return true;
		}

		public static bool TryGetBetterBeehivesMethod(string methodName, [<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(2)] out MethodInfo method)
		{
			method = typeof(GrowBedCompatibility).GetMethod(methodName, AccessTools.all);
			return method != null;
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static bool TryGetGrowBedMethod(string typeName, string methodName, [<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(2)] out MethodInfo method)
		{
			method = null;
			if (!Enabled)
			{
				Main.LogMessage("GrowBed not found.");
				return false;
			}
			Assembly assembly = FindAssembly();
			if (assembly == null)
			{
				Main.LogMessage("Could not find GrowBed assembly.");
				return false;
			}
			return assembly.TryGetMethod(typeName, methodName, out method);
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static bool TryGetGrowBedField(string typeName, string fieldName, [<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(2)] out FieldInfo field)
		{
			field = null;
			if (!Enabled)
			{
				Main.LogMessage("GrowBed not found.");
				return false;
			}
			Assembly assembly = FindAssembly();
			if (assembly == null)
			{
				Main.LogMessage("Could not find GrowBed assembly.");
				return false;
			}
			return assembly.TryGetField(typeName, fieldName, out field);
		}

		[<a33d1f5c-09cf-435c-999c-1ff9e12f226e>NullableContext(2)]
		private static Assembly FindAssembly()
		{
			Assembly result = null;
			if (Chainloader.PluginInfos.TryGetValue(ModGUID, out var value))
			{
				result = ((object)value.Instance).GetType().Assembly;
			}
			return result;
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void ZNetSceneAwakePostfix(ZNetScene __instance)
		{
			if (!Enabled || !Main.GrowBedPatchDone)
			{
				return;
			}
			List<string> list = new List<string> { "piece_growbed_wood", "piece_growbed_bronze", "piece_growbed_iron", "piece_growbed_silver" };
			foreach (string item in list)
			{
				__instance.AddBeePollinateComponent(item);
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static IEnumerable<CodeInstruction> GrowbedAwakeTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Expected O, but got Unknown
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Expected O, but got Unknown
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Expected O, but got Unknown
			Main.LogMessage("Applying transpiler patch to GrowbedMod.Growbed.Awake()");
			if (!TryGetBetterBeehivesMethod("RegisterUpdateTimeRPC", out var method))
			{
				return instructions;
			}
			if (!TryGetGrowBedField("GrowbedMod.Growbed", "m_nview", out var field))
			{
				return instructions;
			}
			Main.LogMessage("1");
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			int num = -1;
			for (int num2 = list.Count - 1; num2 >= 0; num2--)
			{
				if (!(list[num2].opcode != OpCodes.Ret))
				{
					num = num2;
					break;
				}
			}
			if (num == -1)
			{
				return instructions;
			}
			list[num].opcode = OpCodes.Ldarg_0;
			list.Add(new CodeInstruction(OpCodes.Ldfld, (object)field));
			list.Add(new CodeInstruction(OpCodes.Callvirt, (object)method));
			list.Add(new CodeInstruction(OpCodes.Ret, (object)null));
			Main.LogMessage("Patch Done");
			return list.AsEnumerable();
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void RegisterUpdateTimeRPC(ZNetView zNetView)
		{
			zNetView.Register("RPC_BetterBeehivesUpdateGrowbedTime", (Action<long>)delegate
			{
				Main.LogMessage("Invoked RPC_BetterBeehivesUpdateGrowbedTime");
				ZDO zDO = zNetView.GetZDO();
				long num = ((zDO != null) ? zDO.GetLong("growbed_planted", 0L) : 0);
				Main.LogMessage($"Growbed start time is currently {num}");
				if (zNetView.IsOwner() && num != 0)
				{
					long num2 = 1200L;
					long num3 = num - num2;
					Main.LogMessage($"Growbed start time changed to {num} and altered by {num2}");
					ZDO zDO2 = zNetView.GetZDO();
					if (zDO2 != null)
					{
						zDO2.Set("growbed_planted", num3);
					}
				}
			});
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void HandleSeedBedGrowth(GameObject gameObject)
		{
			if (gameObject.GrowbedHasCorrectPlant())
			{
				float num = Random.Range(0f, 1f);
				if (num <= ConfigManager.NearbyPlantGrowthChance.Value)
				{
					gameObject.SetGrowthEffects();
					gameObject.UpdateTime();
				}
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static bool IsGrowbedGerminatingOrFinished(this GameObject gameObject)
		{
			if (!TryGetZNetViewFromGrowbedComponent(gameObject, out var zNetView))
			{
				return true;
			}
			long? obj;
			if (zNetView == null)
			{
				obj = null;
			}
			else
			{
				ZDO zDO = zNetView.GetZDO();
				obj = ((zDO != null) ? new long?(zDO.GetLong("growbed_planted", 0L)) : ((long?)null));
			}
			long? num = obj;
			long valueOrDefault = num.GetValueOrDefault();
			return valueOrDefault > 0;
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static bool TryGetZNetViewFromGrowbedComponent(GameObject gameObject, [<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(2)] out ZNetView zNetView)
		{
			zNetView = null;
			if (!TryGetGrowbedComponent(gameObject, out var componentType, out var component))
			{
				Main.LogMessage("Could not get Growbed component from GameObject.");
				return false;
			}
			FieldInfo field = componentType.GetField("m_nview", AccessTools.all);
			if (field == null)
			{
				Main.LogMessage("Could not get ZNetView field.");
				return false;
			}
			object? value = field.GetValue(component);
			return (Object)(object)(zNetView = (ZNetView)((value is ZNetView) ? value : null)) != (Object)null;
		}

		[<a33d1f5c-09cf-435c-999c-1ff9e12f226e>NullableContext(2)]
		public static bool TryGetGrowbedComponent([<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(1)] GameObject gameObject, out Type componentType, out Component component)
		{
			component = null;
			componentType = null;
			Assembly assembly = FindAssembly();
			if (assembly == null)
			{
				Main.LogMessage("Could not find Growbed assembly.");
				return false;
			}
			componentType = assembly.GetType("GrowbedMod.Growbed");
			if (componentType == null)
			{
				Main.LogMessage("Could not find Growbed component type.");
				return false;
			}
			return (Object)(object)(component = gameObject.GetComponent(componentType)) != (Object)null;
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static bool GrowbedHasCorrectPlant(this GameObject gameObject)
		{
			Main.LogMessage("Trying to detect seed in growbed...");
			if (!TryGetZNetViewFromGrowbedComponent(gameObject, out var zNetView))
			{
				return false;
			}
			object obj;
			if (zNetView == null)
			{
				obj = null;
			}
			else
			{
				ZDO zDO = zNetView.GetZDO();
				obj = ((zDO != null) ? zDO.GetString("growbed_seed", string.Empty) : null);
			}
			if (obj == null)
			{
				obj = string.Empty;
			}
			string text = (string)obj;
			if (text.Equals(string.Empty))
			{
				return false;
			}
			Main.LogMessage("Growbed seed found: " + text);
			return ConfigManager.NearbyPlantsGrowthLowerList.Value.Contains(text.ToLower()) || ConfigManager.NearbyPickablesGrowthLowerList.Value.Contains(text.ToLower()) || ConfigManager.SeedBedPlantsLowerList.Value.Contains(text.ToLower());
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void UpdateTime(this GameObject gameObject)
		{
			if (!TryGetZNetViewFromGrowbedComponent(gameObject, out var zNetView))
			{
				Main.LogMessage("Could not get ZNetView for component");
			}
			else if (zNetView != null)
			{
				zNetView.InvokeRPC("RPC_BetterBeehivesUpdateGrowbedTime", Array.Empty<object>());
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static float GetGerminationHalfDuration()
		{
			if (_germinationHalfDuration > 0f)
			{
				return _germinationHalfDuration;
			}
			if (!Enabled)
			{
				return _germinationHalfDuration = 1200f;
			}
			if (Plugin._germinationDuration == null)
			{
				return _germinationHalfDuration = 1200f;
			}
			return _germinationHalfDuration = Plugin._germinationDuration.Value / 3f;
		}
	}
	[<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(0)]
	[<a33d1f5c-09cf-435c-999c-1ff9e12f226e>NullableContext(1)]
	public static class LazyVikingsCompatibility
	{
		[<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(2)]
		private static MethodInfo DepositToContainersM;

		[<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(2)]
		private static MethodInfo DepositToContainersTranspilerM;

		private static readonly string ModGUID = "blacks7ar.LazyVikings";

		private static bool? _enabled;

		public static bool Enabled
		{
			get
			{
				if (!_enabled.HasValue)
				{
					_enabled = Chainloader.PluginInfos.ContainsKey(ModGUID);
				}
				return _enabled.Value;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static bool DoCompatibilityPatching(Harmony harmony)
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected O, but got Unknown
			Main.LogMessage("LazyVikings is installed. Starting compatibility patches...");
			bool flag = true;
			flag &= TryGetLazyVikingsMethod("LazyVikings.Patches.BeehivePatch", "DepositToContainers", out DepositToContainersM);
			if (!(flag & TryGetBetterBeehivesMethod("DepositToContainersTranspiler", out DepositToContainersTranspilerM)))
			{
				Main.LogMessage("A problem occurred when attempting to patch LazyVikings. Operation cancelled.");
				return false;
			}
			harmony.Patch((MethodBase)DepositToContainersM, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(DepositToContainersTranspilerM), (HarmonyMethod)null, (HarmonyMethod)null);
			Main.LogMessage("All patches done.");
			return true;
		}

		public static bool TryGetBetterBeehivesMethod(string methodName, [<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(2)] out MethodInfo method)
		{
			method = typeof(LazyVikingsCompatibility).GetMethod(methodName, AccessTools.all);
			return method != null;
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static bool TryGetLazyVikingsField(string typeName, string fieldName, [<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(2)] out FieldInfo field)
		{
			field = null;
			if (!Enabled)
			{
				Main.LogMessage("LazyVikings not found.");
				return false;
			}
			Assembly assembly = Assembly.GetAssembly(typeof(Plugin));
			return assembly.TryGetField(typeName, fieldName, out field);
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static bool TryGetLazyVikingsMethod(string typeName, string methodName, [<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(2)] out MethodInfo method)
		{
			method = null;
			if (!Enabled)
			{
				Main.LogMessage("LazyVikings not found.");
				return false;
			}
			Assembly assembly = Assembly.GetAssembly(typeof(Plugin));
			return assembly.TryGetMethod(typeName, methodName, out method);
		}

		public static IEnumerable<CodeInstruction> DepositToContainersTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0316: Unknown result type (might be due to invalid IL or missing references)
			//IL_0320: Expected O, but got Unknown
			//IL_0329: Unknown result type (might be due to invalid IL or missing references)
			//IL_0333: Expected O, but got Unknown
			//IL_033b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0345: Expected O, but got Unknown
			//IL_034e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0358: Expected O, but got Unknown
			//IL_0360: Unknown result type (might be due to invalid IL or missing references)
			//IL_036a: Expected O, but got Unknown
			//IL_0372: Unknown result type (might be due to invalid IL or missing references)
			//IL_037c: Expected O, but got Unknown
			Main.LogMessage("Applying transpiler patch to LazyVikings.Patch.DepositToContainers()");
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			if (!TryGetBetterBeehivesMethod("AddItemsToContainers", out var method))
			{
				return instructions;
			}
			if (!TryGetLazyVikingsMethod("LazyVikings.Utils.Helper", "GetNearbyContainers", out var method2))
			{
				return instructions;
			}
			if (!typeof(Beehive).TryGetMethod("GetHoneyLevel", out var method3))
			{
				return instructions;
			}
			int num = -1;
			for (int i = 2; i < list.Count; i++)
			{
				if (!(list[i - 2].opcode != OpCodes.Ldarg_0) && !(list[i - 1].opcode != OpCodes.Ldind_Ref) && !(list[i].opcode != OpCodes.Stfld))
				{
					num = i;
					break;
				}
			}
			if (num == -1)
			{
				return instructions;
			}
			FieldInfo fieldInfo = (FieldInfo)list[num].operand;
			if (fieldInfo == null)
			{
				return instructions;
			}
			int num2 = -1;
			for (int j = num; j < list.Count; j++)
			{
				if (!(list[j - 3].opcode != OpCodes.Ldloc_1) && !(list[j - 2].opcode != OpCodes.Ldc_I4_1) && !(list[j - 1].opcode != OpCodes.Call) && !(list[j - 1].operand as MethodInfo != method2) && !(list[j].opcode != OpCodes.Stfld))
				{
					num2 = j;
					break;
				}
			}
			if (num2 == -1)
			{
				return instructions;
			}
			FieldInfo fieldInfo2 = (FieldInfo)list[num2].operand;
			if (fieldInfo2 == null)
			{
				return instructions;
			}
			int num3 = -1;
			for (int k = num2; k < list.Count; k++)
			{
				if (!(list[k - 2].opcode != OpCodes.Callvirt) && !(list[k - 2].operand as MethodInfo != method3) && !(list[k - 1].opcode != OpCodes.Ldc_I4_0) && !(list[k].opcode != OpCodes.Bgt))
				{
					num3 = k + 1;
					break;
				}
			}
			if (num3 == -1)
			{
				return instructions;
			}
			List<CodeInstruction> collection = new List<CodeInstruction>
			{
				new CodeInstruction(OpCodes.Ldloc_0, (object)null),
				new CodeInstruction(OpCodes.Ldfld, (object)fieldInfo),
				new CodeInstruction(OpCodes.Ldloc_0, (object)null),
				new CodeInstruction(OpCodes.Ldfld, (object)fieldInfo2),
				new CodeInstruction(OpCodes.Ldloc_3, (object)null),
				new CodeInstruction(OpCodes.Call, (object)method)
			};
			list.InsertRange(num3, collection);
			Main.LogMessage("Patch Done");
			return list.AsEnumerable();
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void AddItemsToContainers(Beehive beehive, List<Container> nearbyContainers, bool mustHaveItem)
		{
			if (!beehive.ShouldAddQueenBee(beehive.m_maxHoney) || !AddItemToContainer(nearbyContainers, Main.Queen, mustHaveItem))
			{
				return;
			}
			int num = 0;
			for (int i = 0; i < ConfigManager.RoyalJellyDropAttempts.Value; i++)
			{
				if (Random.Range(0f, 1f) <= ConfigManager.RoyalJellyDropChance.Value)
				{
					num++;
				}
			}
			AddItemToContainer(nearbyContainers, Main.Jelly, mustHaveItem, num);
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static bool AddItemToContainer(List<Container> nearbyContainers, string prefabName, bool mustHaveItem, int amount = 1)
		{
			if (amount < 1)
			{
				return false;
			}
			GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(prefabName);
			if ((Object)(object)itemPrefab == (Object)null)
			{
				return false;
			}
			ZNetView.m_forceDisableInit = true;
			GameObject val = Object.Instantiate<GameObject>(itemPrefab);
			ZNetView.m_forceDisableInit = false;
			ItemDrop component = val.GetComponent<ItemDrop>();
			bool result = false;
			if ((Object)(object)component != (Object)null)
			{
				component.m_itemData.m_stack = amount;
				result = SpawnInsideContainers(nearbyContainers, component, mustHaveItem);
			}
			Object.Destroy((Object)(object)val);
			return result;
		}

		private static bool SpawnInsideContainers(List<Container> nearbyContainers, ItemDrop item, bool mustHaveItem)
		{
			using (List<Container>.Enumerator enumerator = nearbyContainers.GetEnumerator())
			{
				if (enumerator.MoveNext())
				{
					Container current = enumerator.Current;
					Inventory inventory = current.GetInventory();
					if ((mustHaveItem && !inventory.HaveItem(item.m_itemData.m_shared.m_name, true)) || !inventory.AddItem(item.m_itemData))
					{
						return false;
					}
					current.Save();
					current.GetInventory().Changed(false, false);
					return true;
				}
			}
			if (mustHaveItem)
			{
				return SpawnInsideContainers(nearbyContainers, item, mustHaveItem: false);
			}
			return false;
		}
	}
	[<a33d1f5c-09cf-435c-999c-1ff9e12f226e>NullableContext(1)]
	[<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(0)]
	public static class SeasonalityCompatibility
	{
		[<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(2)]
		private static MethodInfo InteractM;

		[<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(2)]
		private static MethodInfo InteractTranspilerM;

		[<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(2)]
		private static MethodInfo UpdateBeesM;

		[<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(2)]
		private static MethodInfo UpdateBeesPrefixM;

		private static readonly string ModGUID = "RustyMods.Seasonality";

		private static bool? _enabled;

		public static bool Enabled
		{
			get
			{
				if (!_enabled.HasValue)
				{
					_enabled = Chainloader.PluginInfos.ContainsKey(ModGUID);
				}
				return _enabled.Value;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static bool DoCompatibilityPatching(Harmony harmony)
		{
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Expected O, but got Unknown
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Expected O, but got Unknown
			Main.LogMessage("Seasonality is installed. Starting compatibility patches...");
			bool flag = true;
			flag &= (UpdateBeesM = typeof(Beehive).GetMethod("UpdateBees", AccessTools.all)) != null;
			flag &= TryGetBetterBeehivesMethod("UpdateBeesPrefix", out UpdateBeesPrefixM);
			flag &= (InteractM = typeof(Beehive).GetMethod("Interact", AccessTools.all)) != null;
			if (!(flag & TryGetBetterBeehivesMethod("InteractTranspiler", out InteractTranspilerM)))
			{
				Main.LogMessage("A problem occurred when attempting to patch Seasonality. Operation cancelled.");
				return false;
			}
			harmony.Patch((MethodBase)UpdateBeesM, new HarmonyMethod(UpdateBeesPrefixM), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			harmony.Patch((MethodBase)InteractM, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(InteractTranspilerM), (HarmonyMethod)null, (HarmonyMethod)null);
			Main.LogMessage("All patches done.");
			return true;
		}

		public static bool TryGetBetterBeehivesMethod(string methodName, [<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(2)] out MethodInfo method)
		{
			method = typeof(SeasonalityCompatibility).GetMethod(methodName, AccessTools.all);
			return method != null;
		}

		public static bool UpdateBeesPrefix(Beehive __instance)
		{
			if (EnvManHelper.BeesCanPollinateInCurrentSeason())
			{
				return true;
			}
			__instance.m_beeEffect.SetActive(false);
			return false;
		}

		public static IEnumerable<CodeInstruction> InteractTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Expected O, but got Unknown
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Expected O, but got Unknown
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Expected O, but got Unknown
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Expected O, but got Unknown
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Expected O, but got Unknown
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Expected O, but got Unknown
			Main.LogMessage("Applying transpiler patch to Beehive.Interact()");
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			if (!TryGetBetterBeehivesMethod("ShowSleepTextIfWrongSeason", out var method))
			{
				return instructions;
			}
			MethodInfo method2;
			if ((method2 = typeof(Beehive).GetMethod("CheckBiome", AccessTools.all)) == null)
			{
				return instructions;
			}
			int num = -1;
			int num2 = -1;
			for (int i = 0; i < list.Count - 3; i++)
			{
				if (!(list[i].opcode != OpCodes.Ldarg_0) && !(list[i + 1].opcode != OpCodes.Call) && !((MethodInfo)list[i + 1].operand != method2) && !(list[i + 2].opcode != OpCodes.Brtrue))
				{
					num = i;
					num2 = i;
					break;
				}
			}
			if (num == -1 || num2 == -1)
			{
				return instructions;
			}
			if (list[num2].labels.Count == 0)
			{
				return instructions;
			}
			Label item = list[num2].labels[0];
			Label label = default(Label);
			list[num2].labels[0] = label;
			List<CodeInstruction> collection = new List<CodeInstruction>
			{
				CodeInstructionExtensions.WithLabels(new CodeInstruction(OpCodes.Ldarg_0, (object)null), (IEnumerable<Label>)new List<Label> { item }),
				new CodeInstruction(OpCodes.Ldarg_1, (object)null),
				new CodeInstruction(OpCodes.Call, (object)method),
				new CodeInstruction(OpCodes.Brtrue, (object)label),
				new CodeInstruction(OpCodes.Ldc_I4_1, (object)null),
				new CodeInstruction(OpCodes.Ret, (object)null)
			};
			list.InsertRange(num, collection);
			Main.LogMessage("Patch Done");
			return list.AsEnumerable();
		}

		public static bool ShowSleepTextIfWrongSeason(Beehive beehive, Humanoid character)
		{
			Main.LogMessage("Checking if bees can be active in this season...");
			if (!EnvManHelper.BeesCanPollinateInCurrentSeason())
			{
				Main.LogMessage("Bees cannot be active in this season.");
				((Character)character).Message((MessageType)2, beehive.m_sleepText, 0, (Sprite)null, false);
				return false;
			}
			Main.LogMessage("Bees can be active in this season.");
			return true;
		}
	}
	[<a33d1f5c-09cf-435c-999c-1ff9e12f226e>NullableContext(1)]
	[<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(0)]
	public static class SeedBedCompatibility
	{
		[<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(2)]
		private static MethodInfo GerminationAwakeM;

		[<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(2)]
		private static MethodInfo ZNetSceneAwakeM;

		[<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(2)]
		private static MethodInfo GerminationAwakeTranspilerM;

		[<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(2)]
		private static MethodInfo ZNetSceneAwakePostfixM;

		private static readonly string ModGUID = "blacks7ar.SeedBed";

		private static float _germinationHalfDuration = 0f;

		private static bool? _enabled;

		public static bool Enabled
		{
			get
			{
				if (!_enabled.HasValue)
				{
					_enabled = Chainloader.PluginInfos.ContainsKey(ModGUID);
				}
				return _enabled.Value;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static bool DoCompatibilityPatching(Harmony harmony)
		{
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Expected O, but got Unknown
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Expected O, but got Unknown
			Main.LogMessage("SeedBed is installed. Starting compatibility patches...");
			bool flag = true;
			flag &= TryGetSeedBedMethod("SeedBed.Functions.Germination", "Awake", out GerminationAwakeM);
			flag &= typeof(ZNetScene).TryGetMethod("Awake", out ZNetSceneAwakeM);
			flag &= TryGetBetterBeehivesMethod("GerminationAwakeTranspiler", out GerminationAwakeTranspilerM);
			if (!(flag & TryGetBetterBeehivesMethod("ZNetSceneAwakePostfix", out ZNetSceneAwakePostfixM)))
			{
				Main.LogMessage("A problem occurred when attempting to patch SeedBed. Operation cancelled.");
				return false;
			}
			harmony.Patch((MethodBase)GerminationAwakeM, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(GerminationAwakeTranspilerM), (HarmonyMethod)null, (HarmonyMethod)null);
			harmony.Patch((MethodBase)ZNetSceneAwakeM, (HarmonyMethod)null, new HarmonyMethod(ZNetSceneAwakePostfixM), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			Main.LogMessage("All patches done.");
			return true;
		}

		public static bool TryGetBetterBeehivesMethod(string methodName, [<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(2)] out MethodInfo method)
		{
			method = typeof(SeedBedCompatibility).GetMethod(methodName, AccessTools.all);
			return method != null;
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static bool TryGetSeedBedMethod(string typeName, string methodName, [<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(2)] out MethodInfo method)
		{
			method = null;
			if (!Enabled)
			{
				Main.LogMessage("SeedBed not found.");
				return false;
			}
			Assembly assembly = Assembly.GetAssembly(typeof(Plugin));
			if (assembly == null)
			{
				Main.LogMessage("Could not find SeedBed assembly.");
				return false;
			}
			return assembly.TryGetMethod(typeName, methodName, out method);
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void ZNetSceneAwakePostfix(ZNetScene __instance)
		{
			if (Enabled && Main.SeedBedPatchDone)
			{
				__instance.AddBeePollinateComponent("BSB_SeedBed");
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static IEnumerable<CodeInstruction> GerminationAwakeTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Expected O, but got Unknown
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Expected O, but got Unknown
			Main.LogMessage("Applying transpiler patch to SeedBed.Germination.Awake()");
			if (!TryGetBetterBeehivesMethod("RegisterUpdateTimeRPC", out var method))
			{
				return instructions;
			}
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			int num = -1;
			for (int num2 = list.Count - 1; num2 >= 0; num2--)
			{
				if (!(list[num2].opcode != OpCodes.Ret))
				{
					num = num2;
					break;
				}
			}
			if (num == -1)
			{
				return instructions;
			}
			list[num].opcode = OpCodes.Ldarg_0;
			list.Add(new CodeInstruction(OpCodes.Callvirt, (object)method));
			list.Add(new CodeInstruction(OpCodes.Ret, (object)null));
			Main.LogMessage("Patch Done");
			return list.AsEnumerable();
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void RegisterUpdateTimeRPC(Germination germination)
		{
			germination.m_nview.Register("RPC_BetterBeehivesUpdateSeedBedTime", (Action<long>)delegate
			{
				long ticks = new DateTime(germination.m_nview.GetZDO().GetLong(ZDOVars.s_startTime, 0L)).Ticks;
				if (germination.m_nview.IsOwner() && ticks != 0)
				{
					long num = (long)((double)GetGerminationHalfDuration() * 1000.0 * 10000.0);
					long num2 = ticks - num;
					germination.m_nview.GetZDO().Set(ZDOVars.s_startTime, num2);
				}
			});
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void HandleSeedBedGrowth(GameObject gameObject)
		{
			if (gameObject.TryGetGerminationComponent(out var germination) && germination.HasCorrectPlant())
			{
				float num = Random.Range(0f, 1f);
				if (num <= ConfigManager.NearbyPlantGrowthChance.Value)
				{
					gameObject.SetGrowthEffects();
					germination.UpdateTime();
				}
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static bool IsSeedBedGerminatingOrFinished(this GameObject gameObject)
		{
			if (!gameObject.TryGetGerminationComponent(out var germination))
			{
				return true;
			}
			return germination.IsGerminatingOrFinished();
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static bool IsGerminatingOrFinished(this Germination germination)
		{
			if ((Object)(object)germination.m_nview == (Object)null)
			{
				return false;
			}
			return new DateTime(germination.m_nview.GetZDO().GetLong(ZDOVars.s_startTime, 0L)).Ticks > 0;
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static bool SeedBedHasCorrectPlant(this GameObject gameObject)
		{
			if (!gameObject.TryGetGerminationComponent(out var germination))
			{
				return true;
			}
			return germination.HasCorrectPlant();
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static bool HasCorrectPlant(this Germination germination)
		{
			List<Transform> list = new List<Transform>
			{
				germination.m_saplingT5x5.transform.GetChild(0),
				germination.m_saplingT3x1.transform.GetChild(0),
				germination.m_saplingVine.transform.GetChild(0)
			};
			string text = "";
			foreach (Transform item in list)
			{
				string firstChildName = item.GetFirstChildName();
				if (firstChildName != "")
				{
					text = firstChildName;
					break;
				}
			}
			if (text == "")
			{
				return false;
			}
			Main.LogMessage("Found plant " + text);
			return ConfigManager.NearbyPickablesGrowthLowerList.Value.Contains(text.ToLower()) || ConfigManager.NearbyPlantsGrowthLowerList.Value.Contains(text.ToLower()) || ConfigManager.SeedBedPlantsLowerList.Value.Contains(text.ToLower());
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static string GetFirstChildName(this Transform parent)
		{
			if (parent.childCount == 0)
			{
				return "";
			}
			return ((Object)parent.GetChild(0)).name;
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void UpdateTime(this Germination germination)
		{
			if (!((Object)(object)germination.m_nview == (Object)null))
			{
				germination.m_nview.InvokeRPC("RPC_BetterBeehivesUpdateSeedBedTime", Array.Empty<object>());
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static bool TryGetGerminationComponent(this GameObject gameObject, out Germination germination)
		{
			germination = gameObject.GetComponentInChildren<Germination>();
			return (Object)(object)germination != (Object)null;
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static float GetGerminationHalfDuration()
		{
			if (_germinationHalfDuration > 0f)
			{
				return _germinationHalfDuration;
			}
			if (!Enabled)
			{
				return _germinationHalfDuration = 1200f;
			}
			if (Plugin._germinationDuration == null)
			{
				return _germinationHalfDuration = 1200f;
			}
			return _germinationHalfDuration = Plugin._germinationDuration.Value / 3f;
		}
	}
	[<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(0)]
	[<a33d1f5c-09cf-435c-999c-1ff9e12f226e>NullableContext(1)]
	public static class ZenBeehiveCompatibility
	{
		private static readonly string ModGUID = "ZenDragon.ZenBeehive";

		private static bool? _enabled;

		[<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(2)]
		public static MethodInfo SetupPrefabM;

		[<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(2)]
		public static MethodInfo BeehiveUpdateBeesM;

		[<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(2)]
		public static MethodInfo InventoryGridUpdateGuiM;

		[<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(2)]
		public static MethodInfo SetupPrefabTranspilerM;

		[<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(2)]
		public static MethodInfo BeehiveUpdateBeesTranspilerM;

		[<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(2)]
		public static MethodInfo InventoryGridUpdateGuiTranspilerM;

		public static bool Enabled
		{
			get
			{
				if (!_enabled.HasValue)
				{
					_enabled = Chainloader.PluginInfos.ContainsKey(ModGUID);
				}
				return _enabled.Value;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static bool DoCompatibilityPatching(Harmony harmony)
		{
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Expected O, but got Unknown
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Expected O, but got Unknown
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Expected O, but got Unknown
			Main.LogMessage("ZenBeehive is installed. Starting compatibility patches...");
			bool flag = true;
			flag &= TryGetZenBeehiveMethod("ZenBeehive.BeehivePatches", "SetupPrefab", out SetupPrefabM);
			flag &= TryGetZenBeehiveMethod("ZenBeehive.BeehivePatches", "Beehive_UpdateBees", out BeehiveUpdateBeesM);
			flag &= TryGetZenBeehiveMethod("ZenBeehive.BeehivePatches", "InventoryGrid_UpdateGui", out InventoryGridUpdateGuiM);
			flag &= TryGetBetterBeehivesMethod("SetupPrefabTranspiler", out SetupPrefabTranspilerM);
			flag &= TryGetBetterBeehivesMethod("Beehive_UpdateBeesTranspiler", out BeehiveUpdateBeesTranspilerM);
			if (!(flag & TryGetBetterBeehivesMethod("InventoryGrid_UpdateGuiTranspiler", out InventoryGridUpdateGuiTranspilerM)))
			{
				Main.LogMessage("A problem occurred when attempting to patch ZenBeehive. Operation cancelled.");
				return false;
			}
			harmony.Patch((MethodBase)SetupPrefabM, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(SetupPrefabTranspilerM), (HarmonyMethod)null, (HarmonyMethod)null);
			harmony.Patch((MethodBase)BeehiveUpdateBeesM, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(BeehiveUpdateBeesTranspilerM), (HarmonyMethod)null, (HarmonyMethod)null);
			harmony.Patch((MethodBase)InventoryGridUpdateGuiM, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(InventoryGridUpdateGuiTranspilerM), (HarmonyMethod)null, (HarmonyMethod)null);
			Main.LogMessage("All patches done.");
			return true;
		}

		public static bool TryGetBetterBeehivesMethod(string methodName, [<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(2)] out MethodInfo method)
		{
			method = typeof(ZenBeehiveCompatibility).GetMethod(methodName, AccessTools.all);
			return method != null;
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static bool TryGetZenBeehiveMethod(string typeName, string methodName, [<5663fbac-f7a7-4db6-b0a5-0a9fabdeca33>Nullable(2)] out MethodInfo method)
		{
			method = null;
			if (!Enabled)
			{
				Main.LogMessage("ZenBeehive not found.");
				return false;
			}
			Assembly assembly = Assembly.GetAssembly(typeof(Configs));
			return assembly.TryGetMethod(typeName, methodName, out method);
		}

		public static IEnumerable<CodeInstruction> InventoryGrid_UpdateGuiTranspiler(IEnumerable<CodeInstruction> instructions, ILGenerator il)
		{
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Expected O, but got Unknown
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Expected O, but got Unknown
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Expected O, but got Unknown
			Main.LogMessage("Applying transpiler patch to ZenBeehive.InventoryGrid_UpdateGui()");
			if (!TryGetBetterBeehivesMethod("ZenBeehiveInventoryGuiAdditions", out var method))
			{
				return instructions;
			}
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			int num = -1;
			int num2 = -1;
			for (int i = 0; i < list.Count - 2; i++)
			{
				if (!(list[i].opcode != OpCodes.Call) && !(list[i + 1].opcode != OpCodes.Brtrue) && !(list[i + 2].opcode != OpCodes.Ret))
				{
					num = i + 1;
					num2 = i + 2;
					break;
				}
			}
			if (num == -1 || num2 == -1)
			{
				return instructions;
			}
			Label label = il.DefineLabel();
			list[num].operand = label;
			List<CodeInstruction> list2 = new List<CodeInstruction>();
			for (int j = 0; j <= num2; j++)
			{
				list2.Add(list[j]);
			}
			CodeInstruction val = new CodeInstruction(OpCodes.Ldarg_0, (object)null);
			val.labels.Add(label);
			list2.Add(val);
			list2.Add(new CodeInstruction(OpCodes.Call, (object)method));
			list2.Add(new CodeInstruction(OpCodes.Ret, (object)null));
			Main.LogMessage("Patch Done");
			return list2.AsEnumerable();
		}

		public static IEnumerable<CodeInstruction> Beehive_UpdateBeesTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			Main.LogMessage("Applying transpiler patch to ZenBeehive.Beehive_UpdateBees()");
			Main.LogMessage("Patch Donr");
			return new List<CodeInstruction>
			{
				new CodeInstruction(OpCodes.Ret, (object)null)
			}.AsEnumerable();
		}

		public static IEnumerable<CodeInstruction> SetupPrefabTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			Main.LogMessage("Applying transpiler patch to ZenBeehive.SetupPrefab()");
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			FieldInfo fieldInfo = AccessTools.Field(typeof(Container), "m_width");
			if (fieldInfo == null)
			{
				return instructions;
			}
			int num = -1;
			for (int i = 1; i < list.Count - 1; i++)
			{
				if (!(list[i - 1].opcode != OpCodes.Ldloc_1) && !(list[i].opcode != OpCodes.Ldc_I4_1) && !(list[i + 1].opcode != OpCodes.Stfld) && !((FieldInfo)list[i + 1].operand != fieldInfo))
				{
					num = i;
					break;
				}
			}
			if (num == -1)
			{
				return instructions;
			}
			list[num].opcode = OpCodes.Ldc_I4_3;
			Main.LogMessage("Patch Done");
			return list.AsEnumerable();
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void ZenBeehiveInventoryGuiAdditions(InventoryGrid grid)
		{
			grid.SetMaxStackValueAtIndex(0, Configs.MaxHoney.Value);
			grid.SetMaxStackValueAtIndex(1, 1);
			grid.SetMaxStackValueAtIndex(2, ConfigManager.RoyalJellyDropAttempts.Value);
		}
	}
}
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]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	[Embedded]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	[Embedded]
	[CompilerGenerated]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ServerSync
{
	[PublicAPI]
	internal abstract class OwnConfigEntryBase
	{
		public object? LocalBaseValue;

		public bool SynchronizedConfig = true;

		public abstract ConfigEntryBase BaseConfig { get; }
	}
	[PublicAPI]
	internal class SyncedConfigEntry<T>(ConfigEntry<T> sourceConfig) : OwnConfigEntryBase()
	{
		public readonly ConfigEntry<T> SourceConfig = sourceConfig;

		public override ConfigEntryBase BaseConfig => (ConfigEntryBase)(object)SourceConfig;

		public T Value
		{
			get
			{
				return SourceConfig.Value;
			}
			set
			{
				SourceConfig.Value = value;
			}
		}

		public void AssignLocalValue(T value)
		{
			if (LocalBaseValue == null)
			{
				Value = value;
			}
			else
			{
				LocalBaseValue = value;
			}
		}
	}
	internal abstract class CustomSyncedValueBase
	{
		public object? LocalBaseValue;

		public readonly string Identifier;

		public readonly Type Type;

		private object? boxedValue;

		protected bool localIsOwner;

		public readonly int Priority;

		public object? BoxedValue
		{
			get
			{
				return boxedValue;
			}
			set
			{
				boxedValue = value;
				this.ValueChanged?.Invoke();
			}
		}

		public event Action? ValueChanged;

		protected CustomSyncedValueBase(ConfigSync configSync, string identifier, Type type, int priority)
		{
			Priority = priority;
			Identifier = identifier;
			Type = type;
			configSync.AddCustomValue(this);
			localIsOwner = configSync.IsSourceOfTruth;
			configSync.SourceOfTruthChanged += delegate(bool truth)
			{
				localIsOwner = truth;
			};
		}
	}
	[PublicAPI]
	internal sealed class CustomSyncedValue<T> : CustomSyncedValueBase
	{
		public T Value
		{
			get
			{
				return (T)base.BoxedValue;
			}
			set
			{
				base.BoxedValue = value;
			}
		}

		public CustomSyncedValue(ConfigSync configSync, string identifier, T value = default(T), int priority = 0)
			: base(configSync, identifier, typeof(T), priority)
		{
			Value = value;
		}

		public void AssignLocalValue(T value)
		{
			if (localIsOwner)
			{
				Value = value;
			}
			else
			{
				LocalBaseValue = value;
			}
		}
	}
	internal class ConfigurationManagerAttributes
	{
		[UsedImplicitly]
		public bool? ReadOnly = false;
	}
	[PublicAPI]
	internal class ConfigSync
	{
		[HarmonyPatch(typeof(ZRpc), "HandlePackage")]
		private static class SnatchCurrentlyHandlingRPC
		{
			public static ZRpc? currentRpc;

			[HarmonyPrefix]
			private static void Prefix(ZRpc __instance)
			{
				currentRpc = __instance;
			}
		}

		[HarmonyPatch(typeof(ZNet), "Awake")]
		internal static class RegisterRPCPatch
		{
			[HarmonyPostfix]
			private static void Postfix(ZNet __instance)
			{
				isServer = __instance.IsServer();
				foreach (ConfigSync configSync2 in configSyncs)
				{
					ZRoutedRpc.instance.Register<ZPackage>(configSync2.Name + " ConfigSync", (Action<long, ZPackage>)configSync2.RPC_FromOtherClientConfigSync);
					if (isServer)
					{
						configSync2.InitialSyncDone = true;
						Debug.Log((object)("Registered '" + configSync2.Name + " ConfigSync' RPC - waiting for incoming connections"));
					}
				}
				if (isServer)
				{
					((MonoBehaviour)__instance).StartCoroutine(WatchAdminListChanges());
				}
				static void SendAdmin(List<ZNetPeer> peers, bool isAdmin)
				{
					ZPackage package = ConfigsToPackage(null, null, new PackageEntry[1]
					{
						new PackageEntry
						{
							section = "Internal",
							key = "lockexempt",
							type = typeof(bool),
							value = isAdmin
						}
					});
					ConfigSync configSync = configSyncs.First();
					if (configSync != null)
					{
						((MonoBehaviour)ZNet.instance).StartCoroutine(configSync.sendZPackage(peers, package));
					}
				}
				static IEnumerator WatchAdminListChanges()
				{
					MethodInfo listContainsId = AccessTools.DeclaredMethod(typeof(ZNet), "ListContainsId", (Type[])null, (Type[])null);
					SyncedList adminList = (SyncedList)AccessTools.DeclaredField(typeof(ZNet), "m_adminList").GetValue(ZNet.instance);
					List<string> CurrentList = new List<string>(adminList.GetList());
					while (true)
					{
						yield return (object)new WaitForSeconds(30f);
						if (!adminList.GetList().SequenceEqual(CurrentList))
						{
							CurrentList = new List<string>(adminList.GetList());
							List<ZNetPeer> adminPeer = ZNet.instance.GetPeers().Where(delegate(ZNetPeer p)
							{
								string hostName = p.m_rpc.GetSocket().GetHostName();
								return ((object)listContainsId == null) ? adminList.Contains(hostName) : ((bool)listContainsId.Invoke(ZNet.instance, new object[2] { adminList, hostName }));
							}).ToList();
							List<ZNetPeer> nonAdminPeer = ZNet.instance.GetPeers().Except(adminPeer).ToList();
							SendAdmin(nonAdminPeer, isAdmin: false);
							SendAdmin(adminPeer, isAdmin: true);
						}
					}
				}
			}
		}

		[HarmonyPatch(typeof(ZNet), "OnNewConnection")]
		private static class RegisterClientRPCPatch
		{
			[HarmonyPostfix]
			private static void Postfix(ZNet __instance, ZNetPeer peer)
			{
				if (__instance.IsServer())
				{
					return;
				}
				foreach (ConfigSync configSync in configSyncs)
				{
					peer.m_rpc.Register<ZPackage>(configSync.Name + " ConfigSync", (Action<ZRpc, ZPackage>)configSync.RPC_FromServerConfigSync);
				}
			}
		}

		private class ParsedConfigs
		{
			public readonly Dictionary<OwnConfigEntryBase, object?> configValues = new Dictionary<OwnConfigEntryBase, object>();

			public readonly Dictionary<CustomSyncedValueBase, object?> customValues = new Dictionary<CustomSyncedValueBase, object>();
		}

		[HarmonyPatch(typeof(ZNet), "Shutdown")]
		private class ResetConfigsOnShutdown
		{
			[HarmonyPostfix]
			private static void Postfix()
			{
				ProcessingServerUpdate = true;
				foreach (ConfigSync configSync in configSyncs)
				{
					configSync.resetConfigsFromServer();
					configSync.IsSourceOfTruth = true;
					configSync.InitialSyncDone = false;
				}
				ProcessingServerUpdate = false;
			}
		}

		[HarmonyPatch(typeof(ZNet), "RPC_PeerInfo")]
		private class SendConfigsAfterLogin
		{
			private class BufferingSocket : ZPlayFabSocket, ISocket
			{
				public volatile bool finished = false;

				public volatile int versionMatchQueued = -1;

				public readonly List<ZPackage> Package = new List<ZPackage>();

				public readonly ISocket Original;

				public BufferingSocket(ISocket original)
				{
					Original = original;
					((ZPlayFabSocket)this)..ctor();
				}

				public bool IsConnected()
				{
					return Original.IsConnected();
				}

				public ZPackage Recv()
				{
					return Original.Recv();
				}

				public int GetSendQueueSize()
				{
					return Original.GetSendQueueSize();
				}

				public int GetCurrentSendRate()
				{
					return Original.GetCurrentSendRate();
				}

				public bool IsHost()
				{
					return Original.IsHost();
				}

				public void Dispose()
				{
					Original.Dispose();
				}

				public bool GotNewData()
				{
					return Original.GotNewData();
				}

				public void Close()
				{
					Original.Close();
				}

				public string GetEndPointString()
				{
					return Original.GetEndPointString();
				}

				public void GetAndResetStats(out int totalSent, out int totalRecv)
				{
					Original.GetAndResetStats(ref totalSent, ref totalRecv);
				}

				public void GetConnectionQuality(out float localQuality, out float remoteQuality, out int ping, out float outByteSec, out float inByteSec)
				{
					Original.GetConnectionQuality(ref localQuality, ref remoteQuality, ref ping, ref outByteSec, ref inByteSec);
				}

				public ISocket Accept()
				{
					return Original.Accept();
				}

				public int GetHostPort()
				{
					return Original.GetHostPort();
				}

				public bool Flush()
				{
					return Original.Flush();
				}

				public string GetHostName()
				{
					return Original.GetHostName();
				}

				public void VersionMatch()
				{
					if (finished)
					{
						Original.VersionMatch();
					}
					else
					{
						versionMatchQueued = Package.Count;
					}
				}

				public void Send(ZPackage pkg)
				{
					//IL_0057: Unknown result type (might be due to invalid IL or missing references)
					//IL_005d: Expected O, but got Unknown
					int pos = pkg.GetPos();
					pkg.SetPos(0);
					int num = pkg.ReadInt();
					if ((num == StringExtensionMethods.GetStableHashCode("PeerInfo") || num == StringExtensionMethods.GetStableHashCode("RoutedRPC") || num == StringExtensionMet