Decompiled source of JGQoL v0.4.1

BepInEx/plugins/JGQoL.dll

Decompiled 12 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Extensions;
using Jotunn.Managers;
using Jotunn.Utils;
using Splatform;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("JGQoL")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("JGQoL")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")]
[assembly: AssemblyFileVersion("0.4.1")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.4.1.0")]
namespace JGQoL;

[BepInPlugin("com.jongr.jgqol", "JGQoL", "0.4.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
internal class JGQoL : BaseUnityPlugin
{
	private class PlantableResourceRemnant : MonoBehaviour
	{
		private Pickable _pickable;

		private GameObject _marker;

		private float _nextUpdate;

		private void Awake()
		{
			_pickable = ((Component)this).GetComponent<Pickable>();
			Transform val = ((Component)this).transform.Find("_JGQoL_PlantableRemnant");
			_marker = (((Object)(object)val != (Object)null) ? ((Component)val).gameObject : null);
			UpdateMarker();
		}

		private void Update()
		{
			if (!(Time.time < _nextUpdate))
			{
				_nextUpdate = Time.time + 0.25f;
				UpdateMarker();
			}
		}

		private void UpdateMarker()
		{
			if ((Object)(object)_pickable == (Object)null || (Object)(object)_marker == (Object)null)
			{
				return;
			}
			bool flag = _pickable.m_picked;
			if ((Object)(object)_pickable.m_nview != (Object)null && _pickable.m_nview.IsValid())
			{
				ZDO zDO = _pickable.m_nview.GetZDO();
				if (zDO != null)
				{
					flag = zDO.GetBool("picked", flag);
				}
			}
			if (_marker.activeSelf != flag)
			{
				_marker.SetActive(flag);
			}
		}
	}

	private class PlantableResourceRemnantHover : MonoBehaviour, Hoverable
	{
		private Pickable _pickable;

		private void Awake()
		{
			_pickable = ((Component)this).GetComponentInParent<Pickable>();
		}

		public string GetHoverText()
		{
			if ((Object)(object)_pickable == (Object)null)
			{
				return "";
			}
			return _pickable.GetHoverText();
		}

		public string GetHoverName()
		{
			if ((Object)(object)_pickable == (Object)null)
			{
				return "";
			}
			return _pickable.GetHoverName();
		}

		public float GetHoverOffset()
		{
			return 0f;
		}
	}

	private class ContainerPullRequest
	{
		public string ItemName;

		public int Quality;

		public int Amount;
	}

	[HarmonyPatch(typeof(Player), "GetMaxCarryWeight")]
	private static class Player_GetMaxCarryWeight_Patch
	{
		private static void Prefix(ref float ___m_maxCarryWeight)
		{
			___m_maxCarryWeight = CarryWeightBase.Value;
		}

		private static void Postfix(Player __instance, ref float __result)
		{
			int stableHashCode = StringExtensionMethods.GetStableHashCode("BeltStrength");
			if (((Character)__instance).m_seman.HaveStatusEffect(stableHashCode))
			{
				__result = CarryWeightBase.Value + MegingjordBonus.Value;
			}
		}
	}

	[HarmonyPatch(typeof(Player), "Awake")]
	private static class Player_Awake_PickupRange_Patch
	{
		private static void Postfix(Player __instance)
		{
			__instance.m_autoPickupRange = AutoPickupRange.Value;
		}
	}

	[HarmonyPatch(typeof(WearNTear), "HaveRoof")]
	private static class WearNTear_HaveRoof_Patch
	{
		private static void Postfix(ref bool __result)
		{
			if (NoWeatherDamage.Value)
			{
				__result = true;
			}
		}
	}

	[HarmonyPatch(typeof(WearNTear), "IsUnderWater")]
	private static class WearNTear_IsUnderWater_Patch
	{
		private static void Postfix(ref bool __result)
		{
			if (NoWaterDamage.Value)
			{
				__result = false;
			}
		}
	}

	[HarmonyPatch(typeof(CraftingStation), "Start")]
	private static class CraftingStation_Start_Range_Patch
	{
		private static void Postfix(CraftingStation __instance)
		{
			ApplyCraftingStationRanges(__instance);
		}
	}

	[HarmonyPatch(typeof(CraftingStation), "CustomUpdate")]
	private static class CraftingStation_CustomUpdate_Range_Patch
	{
		private static void Postfix(CraftingStation __instance)
		{
			ApplyPlayerBaseRange(__instance);
		}
	}

	[HarmonyPatch(typeof(CraftingStation), "CheckUsable")]
	private static class CraftingStation_CheckUsable_Roof_Patch
	{
		private static void Prefix(CraftingStation __instance)
		{
			if (NoRoofRequirement.Value)
			{
				__instance.m_craftRequireRoof = false;
			}
		}
	}

	[HarmonyPatch(typeof(InventoryGui), "UpdateRepair")]
	private static class InventoryGui_UpdateRepair_AutoRepair_Patch
	{
		private static void Prefix(InventoryGui __instance)
		{
			if (AutoRepairWorkbench.Value && !((Object)(object)Player.m_localPlayer == (Object)null) && !((Object)(object)Player.m_localPlayer.GetCurrentCraftingStation() == (Object)null))
			{
				int num = 0;
				while (__instance.HaveRepairableItems() && num < 100)
				{
					__instance.RepairOneItem();
					num++;
				}
			}
		}
	}

	[HarmonyPatch(typeof(Player), "Repair")]
	private static class Player_Repair_AreaRepair_Patch
	{
		private static bool _areaRepairInProgress;

		private static void Prefix(Player __instance, ref Piece __state)
		{
			if (!_areaRepairInProgress)
			{
				__state = __instance.GetHoveringPiece();
			}
		}

		private static void Postfix(Player __instance, ItemData __0, Piece __1, Piece __state)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			if (_areaRepairInProgress || !EnableAreaRepair.Value || (Object)(object)__state == (Object)null)
			{
				return;
			}
			List<Piece> list = new List<Piece>();
			Piece.GetAllPiecesInRadius(((Component)__state).transform.position, AreaRepairRadius.Value, list);
			Piece hoveringPiece = __instance.m_hoveringPiece;
			_areaRepairInProgress = true;
			try
			{
				foreach (Piece item in list)
				{
					if (!((Object)(object)item == (Object)null) && !((Object)(object)item == (Object)(object)__state))
					{
						__instance.m_hoveringPiece = item;
						__instance.Repair(__0, __1);
					}
				}
			}
			finally
			{
				__instance.m_hoveringPiece = hoveringPiece;
				_areaRepairInProgress = false;
			}
		}
	}

	[HarmonyPatch(typeof(Humanoid), "HideHandItems")]
	private static class Humanoid_HideHandItems_Swimming_Patch
	{
		private static bool Prefix(Humanoid __instance)
		{
			if (!KeepEquipmentWhileSwimming.Value)
			{
				return true;
			}
			Player val = (Player)(object)((__instance is Player) ? __instance : null);
			if (val != null && ((Character)val).IsSwimming() && !((Character)val).IsOnGround())
			{
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(Piece), "Awake")]
	private static class Piece_Awake_VehicleDeconstruction_Patch
	{
		private static void Postfix(Piece __instance)
		{
			if (!((Object)(object)__instance == (Object)null))
			{
				if ((Object)(object)((Component)__instance).GetComponentInParent<Ship>() != (Object)null && DeconstructShipsWithHammer.Value)
				{
					__instance.m_canBeRemoved = true;
				}
				else if ((Object)(object)((Component)__instance).GetComponentInParent<Vagon>() != (Object)null && DeconstructCartsWithHammer.Value)
				{
					__instance.m_canBeRemoved = true;
				}
			}
		}
	}

	[HarmonyPatch(typeof(InventoryGui), "UpdateItemDrag")]
	private static class InventoryGui_UpdateItemDrag_DeleteItem_Patch
	{
		private static void Postfix(InventoryGui __instance)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			if (!Input.GetKeyDown(DeleteKey.Value))
			{
				return;
			}
			ItemData dragItem = __instance.m_dragItem;
			Inventory dragInventory = __instance.m_dragInventory;
			int dragAmount = __instance.m_dragAmount;
			if (dragItem != null && dragInventory != null && dragAmount > 0 && (!((Object)(object)Player.m_localPlayer != (Object)null) || !((Humanoid)Player.m_localPlayer).IsItemEquiped(dragItem)))
			{
				if (dragAmount >= dragItem.m_stack)
				{
					dragInventory.RemoveItem(dragItem);
				}
				else
				{
					dragInventory.RemoveItem(dragItem, dragAmount);
				}
				__instance.SetupDragItem((ItemData)null, (Inventory)null, 0);
			}
		}
	}

	[HarmonyPatch(typeof(ItemDrop), "Awake")]
	private static class ItemDrop_Awake_FloatingItems_Patch
	{
		private static void Postfix(ItemDrop __instance)
		{
			if (!EnableFloatingItems.Value || (Object)(object)__instance == (Object)null)
			{
				return;
			}
			Floating component = ((Component)__instance).GetComponent<Floating>();
			if ((Object)(object)component != (Object)null)
			{
				return;
			}
			component = ((Component)__instance).gameObject.AddComponent<Floating>();
			ObjectDB instance = ObjectDB.instance;
			GameObject val = ((instance != null) ? instance.GetItemPrefab("Wood") : null);
			if (!((Object)(object)val == (Object)null))
			{
				Floating component2 = val.GetComponent<Floating>();
				if (!((Object)(object)component2 == (Object)null))
				{
					component.m_waterLevelOffset = component2.m_waterLevelOffset;
					component.m_force = component2.m_force;
					component.m_forceDistance = component2.m_forceDistance;
					component.m_balanceForceFraction = component2.m_balanceForceFraction;
				}
			}
		}
	}

	[HarmonyPatch(typeof(Fireplace), "Awake")]
	private static class Fireplace_Awake_QoL_Patch
	{
		private static void Postfix(Fireplace __instance)
		{
			if ((Object)(object)__instance == (Object)null)
			{
				return;
			}
			if (NoFuelRequired.Value)
			{
				__instance.m_secPerFuel = 0f;
				__instance.m_canRefill = false;
				if ((Object)(object)__instance.m_nview != (Object)null && __instance.m_nview.IsValid())
				{
					__instance.m_nview.InvokeRPC("RPC_SetFuelAmount", new object[1] { 1f });
				}
			}
			if (MakeToggleable.Value)
			{
				__instance.m_canTurnOff = true;
			}
		}
	}

	[HarmonyPatch(typeof(Smelter), "OnAddOre")]
	private static class Smelter_OnAddOre_BulkFeed_Patch
	{
		private static bool _bulkFeedInProgress;

		private static bool Prefix(Smelter __instance, Switch sw, Humanoid user, ItemData item, ref bool __result)
		{
			if (_bulkFeedInProgress)
			{
				return true;
			}
			if (!BulkFeedEnabled.Value || !IsBulkModifierHeld() || item != null)
			{
				return true;
			}
			if ((Object)(object)user == (Object)null)
			{
				return true;
			}
			Inventory inventory = user.GetInventory();
			if (inventory == null)
			{
				return true;
			}
			if (FindSmelterInput(__instance, inventory) == null)
			{
				return true;
			}
			int value = Traverse.Create((object)__instance).Method("GetQueueSize", Array.Empty<object>()).GetValue<int>();
			int num = __instance.m_maxOre - value;
			if (num <= 0)
			{
				return true;
			}
			int num2 = 0;
			_bulkFeedInProgress = true;
			try
			{
				for (int i = 0; i < num; i++)
				{
					ItemData val = FindSmelterInput(__instance, inventory);
					if (val == null || !__instance.OnAddOre(sw, user, val))
					{
						break;
					}
					num2++;
				}
			}
			finally
			{
				_bulkFeedInProgress = false;
			}
			__result = num2 > 0;
			return false;
		}
	}

	[HarmonyPatch(typeof(Smelter), "OnAddFuel")]
	private static class Smelter_OnAddFuel_BulkFeed_Patch
	{
		private static bool _bulkFeedInProgress;

		private static bool Prefix(Smelter __instance, Switch sw, Humanoid user, ItemData item, ref bool __result)
		{
			if (_bulkFeedInProgress)
			{
				return true;
			}
			if (!BulkFeedEnabled.Value || !IsBulkModifierHeld() || item != null)
			{
				return true;
			}
			if ((Object)(object)user == (Object)null || (Object)(object)__instance.m_fuelItem == (Object)null)
			{
				return true;
			}
			Inventory inventory = user.GetInventory();
			if (inventory == null)
			{
				return true;
			}
			string name = __instance.m_fuelItem.m_itemData.m_shared.m_name;
			ItemData item2 = inventory.GetItem(name, -1, false);
			if (item2 == null)
			{
				return true;
			}
			float value = Traverse.Create((object)__instance).Method("GetFuel", Array.Empty<object>()).GetValue<float>();
			int num = __instance.m_maxFuel - Mathf.CeilToInt(value);
			if (num <= 0)
			{
				return true;
			}
			int num2 = 0;
			_bulkFeedInProgress = true;
			try
			{
				for (int i = 0; i < num; i++)
				{
					item2 = inventory.GetItem(name, -1, false);
					if (item2 == null || !__instance.OnAddFuel(sw, user, item2))
					{
						break;
					}
					num2++;
				}
			}
			finally
			{
				_bulkFeedInProgress = false;
			}
			__result = num2 > 0;
			return false;
		}
	}

	[HarmonyPatch(typeof(Smelter), "OnHoverAddOre")]
	private static class Smelter_OnHoverAddOre_BulkHint_Patch
	{
		private static void Postfix(ref string __result)
		{
			if (BulkFeedEnabled.Value)
			{
				__result += GetBulkActionHint("Bulk fill");
			}
		}
	}

	[HarmonyPatch(typeof(Smelter), "OnHoverAddFuel")]
	private static class Smelter_OnHoverAddFuel_BulkHint_Patch
	{
		private static void Postfix(ref string __result)
		{
			if (BulkFeedEnabled.Value)
			{
				__result += GetBulkActionHint("Bulk fill");
			}
		}
	}

	[HarmonyPatch(typeof(Windmill), "GetPowerOutput")]
	private static class Windmill_GetPowerOutput_IgnoreWind_Patch
	{
		private static bool Prefix(ref float __result)
		{
			if (!WindmillIgnoreWind.Value)
			{
				return true;
			}
			__result = 0.5f;
			return false;
		}
	}

	[HarmonyPatch(typeof(Player), "Interact")]
	private static class Player_Interact_BulkHarvest_Patch
	{
		private static void Prefix(Player __instance, GameObject go, bool hold, bool alt)
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			if (!BulkHarvestEnabled.Value || hold || !IsBulkModifierHeld() || (Object)(object)__instance == (Object)null || (Object)(object)go == (Object)null)
			{
				return;
			}
			Interactable componentInParent = go.GetComponentInParent<Interactable>();
			Pickable val = (Pickable)(object)((componentInParent is Pickable) ? componentInParent : null);
			Beehive val2 = (Beehive)(object)((componentInParent is Beehive) ? componentInParent : null);
			if ((Object)(object)val == (Object)null && (Object)(object)val2 == (Object)null)
			{
				return;
			}
			Collider[] array = Physics.OverlapSphere(go.transform.position, HarvestRadius.Value);
			int num = 1;
			if ((Object)(object)val != (Object)null)
			{
				HashSet<Pickable> hashSet = new HashSet<Pickable>();
				hashSet.Add(val);
				Collider[] array2 = array;
				foreach (Collider val3 in array2)
				{
					if (num >= MaxHarvestTargets.Value)
					{
						break;
					}
					if (!((Object)(object)val3 == (Object)null))
					{
						Pickable componentInParent2 = ((Component)val3).GetComponentInParent<Pickable>();
						if (!((Object)(object)componentInParent2 == (Object)null) && !((Object)(object)componentInParent2 == (Object)(object)val) && hashSet.Add(componentInParent2) && (!HarvestSameTypeOnly.Value || IsSamePickableType(val, componentInParent2)) && componentInParent2.Interact((Humanoid)(object)__instance, false, alt))
						{
							num++;
						}
					}
				}
			}
			else
			{
				if (!((Object)(object)val2 != (Object)null) || !IncludeBeehives.Value)
				{
					return;
				}
				HashSet<Beehive> hashSet2 = new HashSet<Beehive>();
				hashSet2.Add(val2);
				Collider[] array2 = array;
				foreach (Collider val4 in array2)
				{
					if (num >= MaxHarvestTargets.Value)
					{
						break;
					}
					if (!((Object)(object)val4 == (Object)null))
					{
						Beehive componentInParent3 = ((Component)val4).GetComponentInParent<Beehive>();
						if (!((Object)(object)componentInParent3 == (Object)null) && !((Object)(object)componentInParent3 == (Object)(object)val2) && hashSet2.Add(componentInParent3) && PrivateArea.CheckAccess(((Component)componentInParent3).transform.position, 0f, true, false) && componentInParent3.Interact((Humanoid)(object)__instance, false, alt))
						{
							num++;
						}
					}
				}
			}
		}
	}

	[HarmonyPatch(typeof(Pickable), "GetHoverText")]
	private static class Pickable_GetHoverText_BulkHarvestHint_Patch
	{
		private static void Postfix(ref string __result)
		{
			if (BulkHarvestEnabled.Value && ShowBulkHarvestHint.Value && !string.IsNullOrEmpty(__result))
			{
				__result += GetBulkActionHint("Bulk harvest");
			}
		}
	}

	[HarmonyPatch(typeof(Beehive), "GetHoverText")]
	private static class Beehive_GetHoverText_BulkHarvestHint_Patch
	{
		private static void Postfix(Beehive __instance, ref string __result)
		{
			if (BulkHarvestEnabled.Value && ShowBulkHarvestHint.Value && IncludeBeehives.Value && !((Object)(object)__instance == (Object)null) && __instance.GetHoneyLevel() > 0 && !string.IsNullOrEmpty(__result))
			{
				__result += GetBulkActionHint("Bulk harvest");
			}
		}
	}

	[HarmonyPatch(typeof(Plant), "GetHoverText")]
	private static class Plant_GetHoverText_GrowthTimer_Patch
	{
		private static void Postfix(Plant __instance, ref string __result)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			if (PlantGrowthTimer.Value && !((Object)(object)__instance == (Object)null) && (int)__instance.m_status == 0 && !((Object)(object)__instance.m_nview == (Object)null) && __instance.m_nview.IsValid() && __instance.m_nview.GetZDO() != null)
			{
				double num = __instance.GetGrowTime();
				double num2 = __instance.TimeSincePlanted();
				double num3 = num - num2;
				if (!(num3 <= 0.0))
				{
					__result = __result + "\n<color=yellow>Ready in: " + FormatTimeRemaining(num3) + "</color>";
				}
			}
		}
	}

	[HarmonyPatch(typeof(Fermenter), "GetHoverText")]
	private static class Fermenter_GetHoverText_Timer_Patch
	{
		private static void Postfix(Fermenter __instance, ref string __result)
		{
			if (!FermenterTimer.Value || (Object)(object)__instance == (Object)null || (Object)(object)__instance.m_nview == (Object)null || !__instance.m_nview.IsValid() || __instance.m_nview.GetZDO() == null)
			{
				return;
			}
			object value = Traverse.Create((object)__instance).Method("GetStatus", Array.Empty<object>()).GetValue();
			if (value != null && !(value.ToString() != "Fermenting"))
			{
				double value2 = Traverse.Create((object)__instance).Method("GetFermentationTime", Array.Empty<object>()).GetValue<double>();
				double num = (double)__instance.m_fermentationDuration - value2;
				if (!(num <= 0.0))
				{
					__result = __result + "\n<color=yellow>Ready in: " + FormatTimeRemaining(num) + "</color>";
				}
			}
		}
	}

	[HarmonyPatch(typeof(CookingStation), "GetHoverText")]
	private static class CookingStation_GetHoverText_Timer_Patch
	{
		private static void Postfix(CookingStation __instance, ref string __result)
		{
			if (!CookingTimer.Value || (Object)(object)__instance == (Object)null || __instance.m_slots == null || __instance.m_slots.Length == 0)
			{
				return;
			}
			List<string> list = new List<string>();
			for (int i = 0; i < __instance.m_slots.Length; i++)
			{
				if (!TryGetCookingSlot(__instance, i, out var itemName, out var cookedTime) || string.IsNullOrEmpty(itemName))
				{
					continue;
				}
				ItemConversion itemConversion = __instance.GetItemConversion(itemName);
				if (itemConversion != null && !((Object)(object)itemConversion.m_from == (Object)null) && !(itemName != ((Object)itemConversion.m_from).name))
				{
					float num = itemConversion.m_cookTime - cookedTime;
					if (!(num <= 0f))
					{
						string text = Localization.instance.Localize(itemConversion.m_from.m_itemData.m_shared.m_name);
						list.Add(text + " — " + FormatTimeRemaining(num));
					}
				}
			}
			if (list.Count != 0)
			{
				__result = __result + "\n<color=yellow>" + string.Join("\n", list) + "</color>";
			}
		}
	}

	[HarmonyPatch(typeof(Beehive), "GetHoverText")]
	private static class Beehive_GetHoverText_Timer_Patch
	{
		private static void Postfix(Beehive __instance, ref string __result)
		{
			if (BeehiveTimer.Value && !((Object)(object)__instance == (Object)null) && !((Object)(object)__instance.m_nview == (Object)null) && __instance.m_nview.IsValid() && __instance.m_nview.GetZDO() != null && __instance.GetHoneyLevel() < __instance.m_maxHoney)
			{
				float num = __instance.m_nview.GetZDO().GetFloat("product", 0f);
				float num2 = __instance.m_secPerUnit - num;
				if (!(num2 <= 0f))
				{
					__result = __result + "\n<color=yellow>Next honey: " + FormatTimeRemaining(num2) + "</color>";
				}
			}
		}
	}

	[HarmonyPatch(typeof(Pickable), "GetHoverText")]
	private static class Pickable_GetHoverText_RespawnTimer_Patch
	{
		private static void Postfix(Pickable __instance, ref string __result)
		{
			if (!PickableRespawnTimer.Value || (Object)(object)__instance == (Object)null || (Object)(object)__instance.m_nview == (Object)null || !__instance.m_nview.IsValid())
			{
				return;
			}
			ZDO zDO = __instance.m_nview.GetZDO();
			if (zDO == null || !zDO.GetBool("picked", false))
			{
				return;
			}
			double pickableRespawnMinutes = GetPickableRespawnMinutes(__instance);
			if (pickableRespawnMinutes <= 0.0)
			{
				return;
			}
			long num = zDO.GetLong("picked_time", 0L);
			if (num <= 0)
			{
				return;
			}
			double totalSeconds = new TimeSpan(ZNet.instance.GetTime().Ticks - num).TotalSeconds;
			double num2 = pickableRespawnMinutes * 60.0 - totalSeconds;
			if (num2 <= 0.0)
			{
				return;
			}
			string text = "";
			if ((Object)(object)__instance.m_itemPrefab != (Object)null)
			{
				ItemDrop component = __instance.m_itemPrefab.GetComponent<ItemDrop>();
				if ((Object)(object)component != (Object)null)
				{
					text = Localization.instance.Localize(component.m_itemData.m_shared.m_name);
				}
			}
			if (string.IsNullOrEmpty(__result))
			{
				if (!string.IsNullOrEmpty(text))
				{
					__result = text + "\n";
				}
			}
			else
			{
				__result += "\n";
			}
			__result = __result + "<color=yellow>Respawns in: " + FormatTimeRemaining(num2) + "</color>";
		}
	}

	[HarmonyPatch(typeof(Tameable), "GetHoverText")]
	private static class Tameable_GetHoverText_Timer_Patch
	{
		private static void Postfix(Tameable __instance, ref string __result)
		{
			if (!TamingTimer.Value || (Object)(object)__instance == (Object)null || __instance.IsTamed())
			{
				return;
			}
			ZNetView component = ((Component)__instance).GetComponent<ZNetView>();
			if ((Object)(object)component == (Object)null || !component.IsValid())
			{
				return;
			}
			ZDO zDO = component.GetZDO();
			if (zDO == null)
			{
				return;
			}
			float tamingTime = __instance.m_tamingTime;
			if (!(tamingTime <= 0f))
			{
				float num = zDO.GetFloat(ZDOVars.s_tameTimeLeft, tamingTime);
				if (!(num <= 0f) && !(num >= tamingTime))
				{
					__result = __result + "\n<color=yellow>Tamed in: " + FormatTimeRemaining(num) + "</color>";
				}
			}
		}
	}

	[HarmonyPatch(typeof(Player), "HaveRequirements", new Type[]
	{
		typeof(Piece),
		typeof(RequirementMode)
	})]
	private static class Player_HaveRequirements_Piece_Containers_Patch
	{
		private static void Prefix(Player __instance, Piece __0, RequirementMode __1)
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected I4, but got Unknown
			if (!CraftFromContainersEnabled.Value || (Object)(object)__instance == (Object)null || (Object)(object)__0 == (Object)null)
			{
				return;
			}
			if ((Object)(object)((Component)__0).GetComponent<Plant>() != (Object)null || (Object)(object)((Component)__0).GetComponentInChildren<Plant>() != (Object)null)
			{
				if (!CraftFromContainersPlanting.Value)
				{
					return;
				}
			}
			else if (!CraftFromContainersBuilding.Value)
			{
				return;
			}
			switch ((int)__1)
			{
			case 0:
				_buildRequirementPlayer = __instance;
				_countContainerResourcesForBuilding = true;
				break;
			case 2:
				_buildRequirementPlayer = __instance;
				_countAnyContainerResourceForBuilding = true;
				break;
			}
		}

		private static void Postfix()
		{
			_countContainerResourcesForBuilding = false;
			_countAnyContainerResourceForBuilding = false;
			_buildRequirementPlayer = null;
		}

		private static Exception Finalizer(Exception __exception)
		{
			_countContainerResourcesForBuilding = false;
			_countAnyContainerResourceForBuilding = false;
			_buildRequirementPlayer = null;
			return __exception;
		}
	}

	[HarmonyPatch(typeof(Player), "HaveRequirements", new Type[]
	{
		typeof(Recipe),
		typeof(bool),
		typeof(int),
		typeof(int)
	})]
	private static class Player_HaveRequirements_Containers_Patch
	{
		private static void Prefix(Player __instance, Recipe __0, bool __1)
		{
			if (CraftFromContainersEnabled.Value && CraftFromContainersCrafting.Value && !((Object)(object)__instance == (Object)null) && !((Object)(object)__0 == (Object)null) && !__1)
			{
				_craftRequirementPlayer = __instance;
				_countContainerResourcesForCrafting = true;
			}
		}

		private static void Postfix()
		{
			_countContainerResourcesForCrafting = false;
			_craftRequirementPlayer = null;
		}

		private static Exception Finalizer(Exception __exception)
		{
			_countContainerResourcesForCrafting = false;
			_craftRequirementPlayer = null;
			return __exception;
		}
	}

	[HarmonyPatch(typeof(InventoryGui), "SetupRequirement", new Type[]
	{
		typeof(Transform),
		typeof(Requirement),
		typeof(Player),
		typeof(bool),
		typeof(int),
		typeof(int)
	})]
	private static class InventoryGui_SetupRequirement_Containers_Patch
	{
		private static void Prefix(Player __2)
		{
			if (CraftFromContainersEnabled.Value && CraftFromContainersCrafting.Value && !((Object)(object)__2 == (Object)null))
			{
				_displayRequirementPlayer = __2;
				_countContainerResourcesForDisplay = true;
			}
		}

		private static void Postfix()
		{
			_countContainerResourcesForDisplay = false;
			_displayRequirementPlayer = null;
		}

		private static Exception Finalizer(Exception __exception)
		{
			_countContainerResourcesForDisplay = false;
			_displayRequirementPlayer = null;
			return __exception;
		}
	}

	[HarmonyPatch(typeof(Inventory), "CountItems", new Type[]
	{
		typeof(string),
		typeof(int),
		typeof(bool)
	})]
	private static class Inventory_CountItems_CraftContainers_Patch
	{
		private static void Postfix(Inventory __instance, string __0, int __1, bool __2, ref int __result)
		{
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			Player val = null;
			if (_countContainerResourcesForCrafting && (Object)(object)_craftRequirementPlayer != (Object)null)
			{
				val = _craftRequirementPlayer;
			}
			else if (_countContainerResourcesForDisplay && (Object)(object)_displayRequirementPlayer != (Object)null)
			{
				val = _displayRequirementPlayer;
			}
			else if (_countContainerResourcesForBuilding && (Object)(object)_buildRequirementPlayer != (Object)null)
			{
				val = _buildRequirementPlayer;
			}
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			Inventory inventory = ((Humanoid)val).GetInventory();
			if (__instance != inventory)
			{
				return;
			}
			foreach (Container nearbyCraftContainer in GetNearbyCraftContainers(((Component)val).transform.position))
			{
				Inventory inventory2 = nearbyCraftContainer.GetInventory();
				if (inventory2 != null && inventory2 != inventory)
				{
					__result += inventory2.CountItems(__0, __1, __2);
				}
			}
		}
	}

	[HarmonyPatch(typeof(Inventory), "HaveItem", new Type[]
	{
		typeof(string),
		typeof(bool)
	})]
	private static class Inventory_HaveItem_BuildContainers_Patch
	{
		private static void Postfix(Inventory __instance, string __0, bool __1, ref bool __result)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			if (__result || !_countAnyContainerResourceForBuilding || (Object)(object)_buildRequirementPlayer == (Object)null)
			{
				return;
			}
			Inventory inventory = ((Humanoid)_buildRequirementPlayer).GetInventory();
			if (__instance != inventory)
			{
				return;
			}
			foreach (Container nearbyCraftContainer in GetNearbyCraftContainers(((Component)_buildRequirementPlayer).transform.position))
			{
				Inventory inventory2 = nearbyCraftContainer.GetInventory();
				if (inventory2 != null && inventory2.CountItems(__0, -1, __1) > 0)
				{
					__result = true;
					break;
				}
			}
		}
	}

	[HarmonyPatch(typeof(Player), "ConsumeResources", new Type[]
	{
		typeof(Requirement[]),
		typeof(int),
		typeof(int),
		typeof(int)
	})]
	private static class Player_ConsumeResources_Containers_Patch
	{
		private static void Prefix(Player __instance, Requirement[] __0, int __1, int __2, int __3, ref List<ContainerPullRequest> __state)
		{
			__state = null;
			if (!CraftFromContainersEnabled.Value || (!CraftFromContainersCrafting.Value && !CraftFromContainersBuilding.Value && !CraftFromContainersPlanting.Value) || (Object)(object)__instance == (Object)null || __0 == null)
			{
				return;
			}
			Inventory inventory = ((Humanoid)__instance).GetInventory();
			if (inventory == null)
			{
				return;
			}
			List<ContainerPullRequest> list = new List<ContainerPullRequest>();
			foreach (Requirement val in __0)
			{
				if (val == null || (Object)(object)val.m_resItem == (Object)null)
				{
					continue;
				}
				int num = val.GetAmount(__1) * __3;
				if (num > 0)
				{
					string name = val.m_resItem.m_itemData.m_shared.m_name;
					int num2 = inventory.CountItems(name, __2, true);
					int num3 = num - num2;
					if (num3 > 0)
					{
						list.Add(new ContainerPullRequest
						{
							ItemName = name,
							Quality = __2,
							Amount = num3
						});
					}
				}
			}
			if (list.Count > 0)
			{
				__state = list;
			}
		}

		private static void Postfix(Player __instance, List<ContainerPullRequest> __state)
		{
			if (__state == null || (Object)(object)__instance == (Object)null)
			{
				return;
			}
			foreach (ContainerPullRequest item in __state)
			{
				RemoveResourceFromContainers(__instance, item.ItemName, item.Amount, item.Quality);
			}
		}
	}

	[HarmonyPatch(typeof(Container), "Awake")]
	private static class Container_Awake_CraftFromContainers_Patch
	{
		private static void Postfix(Container __instance)
		{
			if (!((Object)(object)__instance == (Object)null))
			{
				TrackedCraftContainers.Add(__instance);
			}
		}
	}

	[HarmonyPatch(typeof(Container), "OnDestroyed")]
	private static class Container_OnDestroyed_CraftFromContainers_Patch
	{
		private static void Prefix(Container __instance)
		{
			if (!((Object)(object)__instance == (Object)null))
			{
				TrackedCraftContainers.Remove(__instance);
			}
		}
	}

	[HarmonyPatch(typeof(Player), "UpdatePlacementGhost")]
	private static class Player_UpdatePlacementGhost_PlantRow_Patch
	{
		private static void Postfix(Player __instance)
		{
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			if (!PlantRowEnabled.Value || !PlantRowShowPreview.Value)
			{
				SetPlantRowPreviewActive(active: false);
				return;
			}
			if ((Object)(object)__instance == (Object)null)
			{
				SetPlantRowPreviewActive(active: false);
				return;
			}
			GameObject value = Traverse.Create((object)__instance).Field("m_placementGhost").GetValue<GameObject>();
			if ((Object)(object)value == (Object)null || !value.activeSelf)
			{
				SetPlantRowPreviewActive(active: false);
				return;
			}
			Plant component = value.GetComponent<Plant>();
			Piece component2 = value.GetComponent<Piece>();
			if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null)
			{
				SetPlantRowPreviewActive(active: false);
				return;
			}
			if (!EnsurePlantRowPreviewGhosts(__instance, value))
			{
				SetPlantRowPreviewActive(active: false);
				return;
			}
			float num = Mathf.Max(PlantRowSpacing.Value, component.m_growRadius * 2f);
			Vector3 val = value.transform.rotation * Vector3.right;
			int affordablePlantRowCount = GetAffordablePlantRowCount(__instance, component2);
			int[] array = new int[4] { -1, 1, -2, 2 };
			for (int i = 0; i < PlantRowPreviewGhosts.Length; i++)
			{
				GameObject val2 = PlantRowPreviewGhosts[i];
				if ((Object)(object)val2 == (Object)null)
				{
					continue;
				}
				if (i + 2 > affordablePlantRowCount)
				{
					val2.SetActive(false);
					continue;
				}
				Vector3 val3 = value.transform.position + val * num * (float)array[i];
				if ((Object)(object)ZoneSystem.instance != (Object)null)
				{
					val3.y = ZoneSystem.instance.GetGroundHeight(val3);
				}
				val2.transform.position = val3;
				val2.transform.rotation = value.transform.rotation;
				val2.SetActive(true);
				bool invalidPlacementHeightlight = false;
				Heightmap val4 = Heightmap.FindHeightmap(val3);
				if (component2.m_cultivatedGroundOnly && ((Object)(object)val4 == (Object)null || !val4.IsCultivated(val3)))
				{
					invalidPlacementHeightlight = true;
				}
				if (!HasPlantRowGrowSpace(val3, component))
				{
					invalidPlacementHeightlight = true;
				}
				Piece component3 = val2.GetComponent<Piece>();
				if ((Object)(object)component3 != (Object)null)
				{
					component3.SetInvalidPlacementHeightlight(invalidPlacementHeightlight);
				}
			}
		}
	}

	[HarmonyPatch(typeof(Player), "TryPlacePiece", new Type[] { typeof(Piece) })]
	private static class Player_TryPlacePiece_PlantRow_Patch
	{
		private static void Prefix(Player __instance, Piece __0)
		{
			_plantRowRestoreRotation = false;
			if (PlantRowEnabled.Value && !((Object)(object)__instance == (Object)null) && !((Object)(object)__0 == (Object)null) && !((Object)(object)((Component)__0).GetComponent<Plant>() == (Object)null))
			{
				_plantRowSavedPlaceRotation = Traverse.Create((object)__instance).Field("m_placeRotation").GetValue<int>();
				_plantRowSavedScrollAmount = Traverse.Create((object)__instance).Field("m_scrollCurrAmount").GetValue<float>();
			}
		}

		private static void Postfix(Player __instance, Piece __0, bool __result)
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			_plantRowPlaceSuccessful = false;
			_plantRowPlacedPiece = null;
			if (PlantRowEnabled.Value && __result && !((Object)(object)__instance == (Object)null) && !((Object)(object)__0 == (Object)null) && !((Object)(object)((Component)__0).GetComponent<Plant>() == (Object)null))
			{
				GameObject value = Traverse.Create((object)__instance).Field("m_placementGhost").GetValue<GameObject>();
				if (!((Object)(object)value == (Object)null))
				{
					_plantRowPlacedPosition = value.transform.position;
					_plantRowPlacedRotation = value.transform.rotation;
					_plantRowPlacedPiece = __0;
					_plantRowPlaceSuccessful = true;
					_plantRowRestoreRotation = true;
				}
			}
		}
	}

	[HarmonyPatch(typeof(Player), "UpdatePlacement")]
	private static class Player_UpdatePlacement_PlantRow_Patch
	{
		private static void Postfix(Player __instance)
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: 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_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			if (!_plantRowPlaceSuccessful)
			{
				return;
			}
			try
			{
				if (!PlantRowEnabled.Value || (Object)(object)__instance == (Object)null || (Object)(object)_plantRowPlacedPiece == (Object)null)
				{
					return;
				}
				Plant component = ((Component)_plantRowPlacedPiece).GetComponent<Plant>();
				if ((Object)(object)component == (Object)null)
				{
					return;
				}
				float num = Mathf.Max(PlantRowSpacing.Value, component.m_growRadius * 2f);
				Vector3 val = _plantRowPlacedRotation * Vector3.right;
				int[] obj = new int[4] { -1, 1, -2, 2 };
				bool value = Traverse.Create((object)__instance).Field("m_noPlacementCost").GetValue<bool>();
				int[] array = obj;
				foreach (int num2 in array)
				{
					Vector3 val2 = _plantRowPlacedPosition + val * num * (float)num2;
					if ((Object)(object)ZoneSystem.instance != (Object)null)
					{
						val2.y = ZoneSystem.instance.GetGroundHeight(val2);
					}
					Heightmap val3 = Heightmap.FindHeightmap(val2);
					if ((!_plantRowPlacedPiece.m_cultivatedGroundOnly || (!((Object)(object)val3 == (Object)null) && val3.IsCultivated(val2))) && HasPlantRowGrowSpace(val2, component))
					{
						if (!value && !__instance.HaveRequirements(_plantRowPlacedPiece, (RequirementMode)0))
						{
							break;
						}
						float num3 = Mathf.Max(0f, PlantRowExtraStaminaCost.Value);
						if (PlantRowConsumeStamina.Value && num3 > 0f && !((Character)__instance).HaveStamina(num3))
						{
							break;
						}
						GameObject val4 = Object.Instantiate<GameObject>(((Component)_plantRowPlacedPiece).gameObject, val2, _plantRowPlacedRotation);
						Piece component2 = val4.GetComponent<Piece>();
						if ((Object)(object)component2 != (Object)null)
						{
							component2.SetCreator(__instance.GetPlayerID(), ((IUser)PlatformManager.DistributionPlatform.LocalUser).PlatformUserID);
						}
						if (_plantRowPlacedPiece.m_placeEffect != null)
						{
							_plantRowPlacedPiece.m_placeEffect.Create(val2, _plantRowPlacedRotation, val4.transform, 1f, -1, default(ZDOID));
						}
						if (!value)
						{
							__instance.ConsumeResources(_plantRowPlacedPiece.m_resources, 0, -1, 1);
						}
						if (PlantRowConsumeStamina.Value && num3 > 0f)
						{
							((Character)__instance).UseStamina(num3);
						}
					}
				}
			}
			finally
			{
				if (_plantRowRestoreRotation && (Object)(object)__instance != (Object)null)
				{
					Traverse.Create((object)__instance).Field("m_placeRotation").SetValue((object)_plantRowSavedPlaceRotation);
					Traverse.Create((object)__instance).Field("m_scrollCurrAmount").SetValue((object)_plantRowSavedScrollAmount);
				}
				_plantRowRestoreRotation = false;
				_plantRowPlaceSuccessful = false;
				_plantRowPlacedPiece = null;
			}
		}
	}

	[HarmonyPatch(typeof(Player), "GetTotalFoodValue")]
	private static class Player_GetTotalFoodValue_NoFoodDegradation_Patch
	{
		private static void Prefix(Player __instance)
		{
			if (!DisableFoodDegradation.Value || (Object)(object)__instance == (Object)null)
			{
				return;
			}
			foreach (Food food in __instance.m_foods)
			{
				if (food != null && food.m_item != null && food.m_item.m_shared != null)
				{
					SharedData shared = food.m_item.m_shared;
					food.m_health = shared.m_food;
					food.m_stamina = shared.m_foodStamina;
					food.m_eitr = shared.m_foodEitr;
				}
			}
		}
	}

	[HarmonyPatch(typeof(CinematicsManager), "Awake")]
	private static class CinematicsManager_Awake_SkipStartup_Patch
	{
		private static void Postfix()
		{
			DisableStartupIntroIfReady();
		}
	}

	[HarmonyPatch(typeof(SceneLoader), "StartLoading")]
	private static class SceneLoader_StartLoading_SkipLogos_Patch
	{
		private static void Prefix(SceneLoader __instance)
		{
			DisableSceneLoaderLogos(__instance);
		}

		private static void Postfix(SceneLoader __instance)
		{
			DisableSceneLoaderLogos(__instance);
		}
	}

	[HarmonyPatch(typeof(SceneLoader), "Update")]
	private static class SceneLoader_Update_SkipLogos_Patch
	{
		private static void Prefix(SceneLoader __instance)
		{
			DisableSceneLoaderLogos(__instance);
		}
	}

	[HarmonyPatch(typeof(Player), "GetJogSpeedFactor")]
	private static class Player_GetJogSpeedFactor_SurfaceSpeed_Patch
	{
		private static void Postfix(Player __instance, ref float __result)
		{
			if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer))
			{
				__result *= GetSurfaceMovementSpeedMultiplier(__instance);
			}
		}
	}

	[HarmonyPatch(typeof(Player), "GetRunSpeedFactor")]
	private static class Player_GetRunSpeedFactor_SurfaceSpeed_Patch
	{
		private static void Postfix(Player __instance, ref float __result)
		{
			if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer))
			{
				__result *= GetSurfaceMovementSpeedMultiplier(__instance);
			}
		}
	}

	[HarmonyPatch(typeof(Character), "UpdateWalking")]
	private static class Character_UpdateWalking_SurfaceSpeed_Patch
	{
		private static void Prefix(Character __instance, out float __state)
		{
			__state = __instance.m_walkSpeed;
			Player val = (Player)(object)((__instance is Player) ? __instance : null);
			if (!((Object)(object)val == (Object)null) && !((Object)(object)val != (Object)(object)Player.m_localPlayer))
			{
				__instance.m_walkSpeed *= GetSurfaceMovementSpeedMultiplier(val);
			}
		}

		private static void Finalizer(Character __instance, float __state)
		{
			__instance.m_walkSpeed = __state;
		}
	}

	[HarmonyPatch(typeof(InventoryGui), "Awake")]
	private static class InventoryGui_Awake_CraftQuantity_Patch
	{
		private static void Postfix(InventoryGui __instance)
		{
			if (!((Object)(object)__instance == (Object)null))
			{
				_craftQuantityBaseDuration = __instance.m_craftDuration;
				_craftQuantityBaseMultiDuration = __instance.m_multiCraftDuration;
				if (__instance.m_multiCraftAmount > 1)
				{
					_craftQuantityVanillaMultiAmount = __instance.m_multiCraftAmount;
				}
				else
				{
					_craftQuantityVanillaMultiAmount = 5;
				}
				CreateCraftQuantityUI(__instance);
			}
		}
	}

	[HarmonyPatch(typeof(InventoryGui), "UpdateRecipe", new Type[]
	{
		typeof(Player),
		typeof(float)
	})]
	private static class InventoryGui_UpdateRecipe_CraftQuantity_Patch
	{
		private static void Prefix(InventoryGui __instance, ref bool ___m_touchMultiCrafting)
		{
			if ((Object)(object)_craftQuantityRoot != (Object)null)
			{
				bool active = CraftQuantityEnabled.Value && (Object)(object)__instance != (Object)null && __instance.InCraftTab();
				_craftQuantityRoot.SetActive(active);
			}
			if (CraftQuantityEnabled.Value && !((Object)(object)__instance == (Object)null) && __instance.InCraftTab())
			{
				ApplyCraftQuantity(__instance, ref ___m_touchMultiCrafting);
			}
		}
	}

	[HarmonyPatch(typeof(InventoryGui), "OnCraftPressed")]
	private static class InventoryGui_OnCraftPressed_CraftQuantity_Patch
	{
		private static void Prefix(InventoryGui __instance, ref bool ___m_touchMultiCrafting)
		{
			if (CraftQuantityEnabled.Value && !((Object)(object)__instance == (Object)null) && __instance.InCraftTab())
			{
				OnCraftQuantityEndEdit(((Object)(object)_craftQuantityInput != (Object)null) ? _craftQuantityInput.text : "1");
				ApplyCraftQuantity(__instance, ref ___m_touchMultiCrafting);
			}
		}
	}

	[HarmonyPatch(typeof(InventoryGui), "SetRecipe")]
	private static class InventoryGui_SetRecipe_CraftQuantity_Patch
	{
		private static void Postfix()
		{
			if (CraftQuantityEnabled.Value)
			{
				SetCraftQuantityAmount(1);
			}
		}
	}

	[HarmonyPatch(typeof(InventoryGui), "DoCrafting", new Type[] { typeof(Player) })]
	private static class InventoryGui_DoCrafting_CraftQuantity_Patch
	{
		private static void Postfix(InventoryGui __instance)
		{
			if (CraftQuantityEnabled.Value && !((Object)(object)__instance == (Object)null))
			{
				SetCraftQuantityAmount(1);
			}
		}
	}

	public const string PluginGUID = "com.jongr.jgqol";

	public const string PluginName = "JGQoL";

	public const string PluginVersion = "0.4.1";

	internal static ConfigEntry<float> CarryWeightBase;

	internal static ConfigEntry<float> MegingjordBonus;

	internal static ConfigEntry<float> AutoPickupRange;

	internal static ConfigEntry<bool> KeepEquipmentWhileSwimming;

	internal static ConfigEntry<bool> NoWeatherDamage;

	internal static ConfigEntry<bool> NoWaterDamage;

	internal static ConfigEntry<float> WorkBenchRange;

	internal static ConfigEntry<float> WorkBenchPlayerBase;

	internal static ConfigEntry<bool> NoRoofRequirement;

	internal static ConfigEntry<bool> AutoRepairWorkbench;

	internal static ConfigEntry<bool> EnableAreaRepair;

	internal static ConfigEntry<float> AreaRepairRadius;

	internal static ConfigEntry<bool> DeconstructCartsWithHammer;

	internal static ConfigEntry<bool> DeconstructShipsWithHammer;

	internal static ConfigEntry<KeyCode> DeleteKey;

	internal static ConfigEntry<bool> EnableFloatingItems;

	internal static ConfigEntry<bool> NoFuelRequired;

	internal static ConfigEntry<bool> MakeToggleable;

	internal static ConfigEntry<bool> BulkFeedEnabled;

	internal static ConfigEntry<bool> WindmillIgnoreWind;

	internal static ConfigEntry<bool> BulkHarvestEnabled;

	internal static ConfigEntry<float> HarvestRadius;

	internal static ConfigEntry<int> MaxHarvestTargets;

	internal static ConfigEntry<bool> HarvestSameTypeOnly;

	internal static ConfigEntry<bool> IncludeBeehives;

	internal static ConfigEntry<bool> ShowBulkHarvestHint;

	internal static ConfigEntry<bool> PlantGrowthTimer;

	internal static ConfigEntry<bool> FermenterTimer;

	internal static ConfigEntry<bool> CookingTimer;

	internal static ConfigEntry<bool> BeehiveTimer;

	internal static ConfigEntry<bool> PickableRespawnTimer;

	internal static ConfigEntry<bool> TamingTimer;

	internal static ConfigEntry<bool> CraftFromContainersEnabled;

	internal static ConfigEntry<float> ContainerRange;

	internal static ConfigEntry<bool> CraftFromContainersCrafting;

	internal static ConfigEntry<bool> CraftFromContainersBuilding;

	internal static ConfigEntry<bool> CraftFromContainersPlanting;

	internal static ConfigEntry<bool> DisableFoodDegradation;

	internal static ConfigEntry<bool> SkipStartupSequence;

	internal static ConfigEntry<bool> PlantableResourcesEnabled;

	internal static ConfigEntry<bool> PlantRowEnabled;

	internal static ConfigEntry<float> PlantRowSpacing;

	internal static ConfigEntry<bool> PlantRowShowPreview;

	internal static ConfigEntry<bool> PlantRowConsumeStamina;

	internal static ConfigEntry<float> PlantRowExtraStaminaCost;

	internal static ConfigEntry<bool> SurfaceMovementSpeedEnabled;

	internal static ConfigEntry<float> PathSpeedMultiplier;

	internal static ConfigEntry<float> WoodFloorSpeedMultiplier;

	internal static ConfigEntry<float> StoneFloorSpeedMultiplier;

	internal static ConfigEntry<bool> CraftQuantityEnabled;

	internal static ConfigEntry<int> CraftQuantityMaximum;

	private static int _plantRowSavedPlaceRotation;

	private static float _plantRowSavedScrollAmount;

	private static bool _plantRowRestoreRotation;

	private Harmony _harmony;

	private static readonly HashSet<Container> TrackedCraftContainers = new HashSet<Container>();

	private static bool _countContainerResourcesForCrafting;

	private static Player _craftRequirementPlayer;

	private static bool _countContainerResourcesForDisplay;

	private static Player _displayRequirementPlayer;

	private static bool _countContainerResourcesForBuilding;

	private static bool _countAnyContainerResourceForBuilding;

	private static Player _buildRequirementPlayer;

	private static GameObject _craftQuantityRoot;

	private static TMP_InputField _craftQuantityInput;

	private static int _craftQuantityAmount = 1;

	private static float _craftQuantityBaseDuration = 2f;

	private static float _craftQuantityBaseMultiDuration = 6f;

	private static int _craftQuantityVanillaMultiAmount = 5;

	private const string PlantableRemnantName = "_JGQoL_PlantableRemnant";

	private static readonly GameObject[] PlantRowPreviewGhosts = (GameObject[])(object)new GameObject[4];

	private static string _plantRowPreviewSourceName = null;

	private static bool _plantRowPlaceSuccessful;

	private static Vector3 _plantRowPlacedPosition;

	private static Quaternion _plantRowPlacedRotation;

	private static Piece _plantRowPlacedPiece;

	private static readonly int PlantRowGrowSpaceMask = LayerMask.GetMask(new string[5] { "Default", "static_solid", "Default_small", "piece", "piece_nonsolid" });

	private void Awake()
	{
		//IL_0604: Unknown result type (might be due to invalid IL or missing references)
		//IL_060e: Expected O, but got Unknown
		CarryWeightBase = BindSynced("CarryWeight", "CarryWeightBase", 500f, "Sets the player's base carry capacity.");
		MegingjordBonus = BindSynced("CarryWeight", "MegingjordBonus", 500f, "Sets the carry capacity added by Megingjord.");
		AutoPickupRange = BindSynced("Player", "AutoPickupRange", 5f, "Sets the automatic item pickup radius in meters.");
		SurfaceMovementSpeedEnabled = BindSynced("MovementSpeed", "Enabled", defaultValue: true, "Enables movement speed bonuses on paths and constructed flooring.");
		PathSpeedMultiplier = BindSynced("MovementSpeed", "PathSpeedMultiplier", 1.1f, "Movement speed multiplier while on pathened or paved terrain. 1.10 = 10% faster.");
		WoodFloorSpeedMultiplier = BindSynced("MovementSpeed", "WoodFloorSpeedMultiplier", 1.2f, "Movement speed multiplier while standing on wood or hardwood construction. 1.20 = 20% faster.");
		StoneFloorSpeedMultiplier = BindSynced("MovementSpeed", "StoneFloorSpeedMultiplier", 1.3f, "Movement speed multiplier while standing on stone, marble or grausten construction. 1.30 = 30% faster.");
		KeepEquipmentWhileSwimming = BindSynced("Player", "KeepEquipmentWhileSwimming", defaultValue: true, "Prevents weapons, shields, tools and torches from being automatically hidden while swimming.");
		NoWeatherDamage = BindSynced("WearNTear", "NoWeatherDamage", defaultValue: true, "Prevents normal rain weathering damage to building pieces.");
		NoWaterDamage = BindSynced("WearNTear", "NoWaterDamage", defaultValue: true, "Prevents underwater weathering damage to building pieces.");
		WorkBenchRange = BindSynced("Workbench", "WorkBenchRange", 50f, "Sets the workbench building radius in meters.");
		WorkBenchPlayerBase = BindSynced("Workbench", "WorkBenchPlayerBase", 50f, "Sets the workbench player-base radius used for systems such as enemy spawn suppression.");
		NoRoofRequirement = BindSynced("Workbench", "NoRoofRequirement", defaultValue: true, "Removes the roof and exposure requirement from crafting stations.");
		AutoRepairWorkbench = BindSynced("Workbench", "AutoRepairWorkbench", defaultValue: true, "Repairs every repairable equipped or inventory item when using a valid crafting station.");
		EnableAreaRepair = BindSynced("Workbench", "EnableAreaRepair", defaultValue: true, "Repairs nearby damaged structures when using the hammer repair action.");
		AreaRepairRadius = BindSynced("Workbench", "AreaRepairRadius", 10f, "Sets the area-repair radius in meters.");
		DeconstructCartsWithHammer = BindSynced("Vehicles", "DeconstructCartsWithHammer", defaultValue: true, "Allows carts to be deconstructed with the hammer.");
		DeconstructShipsWithHammer = BindSynced("Vehicles", "DeconstructShipsWithHammer", defaultValue: true, "Allows ships to be deconstructed with the hammer.");
		DeleteKey = BindLocal<KeyCode>("DeleteItem", "DeleteKey", (KeyCode)127, "Permanently deletes the item currently held by the inventory cursor.");
		EnableFloatingItems = BindSynced("FloatingItems", "EnableFloatingItems", defaultValue: true, "Makes dropped items float on water.");
		NoFuelRequired = BindSynced("FireSources", "NoFuelRequired", defaultValue: true, "Makes Fireplace-based fire sources work without consuming fuel.");
		MakeToggleable = BindSynced("FireSources", "MakeToggleable", defaultValue: true, "Allows Fireplace-based fire sources to be turned on and off with the Use key.");
		BulkFeedEnabled = BindSynced("Smelters", "BulkFeedEnabled", defaultValue: true, "Allows the bulk-action modifier + Use to fill Smelter-based machines with as many matching items as possible.");
		WindmillIgnoreWind = BindSynced("Smelters", "WindmillIgnoreWind", defaultValue: true, "Makes Windmill production run at full power regardless of wind strength.");
		BulkHarvestEnabled = BindSynced("BulkHarvest", "Enabled", defaultValue: true, "Enables area harvesting with the bulk-action modifier + Use.");
		HarvestRadius = BindSynced("BulkHarvest", "HarvestRadius", 10f, "Sets the search radius for bulk harvesting in meters.");
		MaxHarvestTargets = BindSynced("BulkHarvest", "MaxTargets", 50, "Limits how many objects one bulk-harvest action can interact with, including the original target.");
		HarvestSameTypeOnly = BindSynced("BulkHarvest", "HarvestSameTypeOnly", defaultValue: true, "If true, only harvests the same pickable type as the original target.");
		IncludeBeehives = BindSynced("BulkHarvest", "IncludeBeehives", defaultValue: true, "Includes nearby beehives when bulk harvesting.");
		ShowBulkHarvestHint = BindLocal("BulkHarvest", "ShowHoverHint", defaultValue: true, "Shows the bulk-harvest control hint.");
		PlantGrowthTimer = BindLocal("HoverTimers", "PlantGrowth", defaultValue: true, "Shows the remaining growth time when hovering over a growing planted crop or sapling.");
		FermenterTimer = BindLocal("HoverTimers", "Fermenter", defaultValue: true, "Shows the remaining fermentation time when hovering over an active fermenter.");
		CookingTimer = BindLocal("HoverTimers", "Cooking", defaultValue: true, "Shows the remaining cooking time for items in cooking stations and ovens.");
		BeehiveTimer = BindLocal("HoverTimers", "Beehive", defaultValue: true, "Shows the remaining time until the next honey is produced.");
		PickableRespawnTimer = BindLocal("HoverTimers", "PickableRespawn", defaultValue: true, "Shows the remaining respawn time when hovering over a harvested renewable pickable.");
		TamingTimer = BindLocal("HoverTimers", "Taming", defaultValue: true, "Shows the remaining taming time when hovering over a creature that is currently being tamed.");
		CraftFromContainersEnabled = BindSynced("CraftFromContainers", "Enabled", defaultValue: true, "Allows resources in nearby containers to be used for crafting, building and planting.");
		ContainerRange = BindSynced("CraftFromContainers", "ContainerRange", 50f, "Maximum distance in meters from which resources can be pulled from containers.");
		CraftFromContainersCrafting = BindSynced("CraftFromContainers", "Crafting", defaultValue: true, "Allows normal crafting recipes to use resources from nearby containers.");
		CraftFromContainersBuilding = BindSynced("CraftFromContainers", "Building", defaultValue: true, "Allows building pieces to use resources from nearby containers.");
		CraftFromContainersPlanting = BindSynced("CraftFromContainers", "Planting", defaultValue: true, "Allows planting to use resources from nearby containers.");
		CraftQuantityEnabled = BindSynced("CraftQuantity", "Enabled", defaultValue: true, "Adds an in-game quantity field for crafting multiple items at once.");
		CraftQuantityMaximum = BindSynced("CraftQuantity", "MaximumCraftAmount", 100, "Maximum number of crafting operations allowed in one craft. Hard capped at 100.");
		DisableFoodDegradation = BindSynced("Food", "DisableFoodDegradation", defaultValue: true, "Prevents food health, stamina and eitr bonuses from decreasing over time. Food remains at full strength until it expires.");
		SkipStartupSequence = BindLocal("Startup", "SkipStartupSequence", defaultValue: true, "Skips the startup developer logos, opening cinematic and first-start menu intro.");
		PlantableResourcesEnabled = BindSynced("PlantableResources", "Enabled", defaultValue: true, "Adds raspberry bushes, blueberry bushes, mushrooms, yellow mushrooms, dandelions and thistle to the Cultivator. Each costs 5 of its own resource.");
		PlantRowEnabled = BindSynced("PlantRow", "Enabled", defaultValue: true, "Plants up to five crops in a straight row when using the cultivator.");
		PlantRowSpacing = BindSynced("PlantRow", "PlantSpacing", 1f, "Minimum spacing between plants. The actual spacing automatically increases when the selected plant requires more growing room.");
		PlantRowShowPreview = BindLocal("PlantRow", "ShowPreview", defaultValue: true, "Shows previews for all five planned plant positions.");
		PlantRowConsumeStamina = BindSynced("PlantRow", "ConsumeStamina", defaultValue: true, "Makes additional plants consume stamina.");
		PlantRowExtraStaminaCost = BindSynced("PlantRow", "ExtraPlantStaminaCost", 2f, "Additional stamina consumed for each extra plant after the center plant.");
		PrefabManager.OnVanillaPrefabsAvailable += RegisterPlantableRaspberryBush;
		PrefabManager.OnVanillaPrefabsAvailable += RegisterPlantableBlueberryBush;
		PrefabManager.OnVanillaPrefabsAvailable += RegisterPlantableMushroom;
		PrefabManager.OnVanillaPrefabsAvailable += RegisterPlantableYellowMushroom;
		PrefabManager.OnVanillaPrefabsAvailable += RegisterPlantableDandelion;
		PrefabManager.OnVanillaPrefabsAvailable += RegisterPlantableThistle;
		_harmony = new Harmony("com.jongr.jgqol");
		_harmony.PatchAll();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"JGQoL 0.4.1 loaded.");
	}

	private void OnDestroy()
	{
		PrefabManager.OnVanillaPrefabsAvailable -= RegisterPlantableRaspberryBush;
		PrefabManager.OnVanillaPrefabsAvailable -= RegisterPlantableBlueberryBush;
		PrefabManager.OnVanillaPrefabsAvailable -= RegisterPlantableMushroom;
		PrefabManager.OnVanillaPrefabsAvailable -= RegisterPlantableYellowMushroom;
		PrefabManager.OnVanillaPrefabsAvailable -= RegisterPlantableDandelion;
		PrefabManager.OnVanillaPrefabsAvailable -= RegisterPlantableThistle;
		DestroyPlantRowPreviewGhosts();
		Harmony harmony = _harmony;
		if (harmony != null)
		{
			harmony.UnpatchSelf();
		}
	}

	private ConfigEntry<T> BindSynced<T>(string section, string key, T defaultValue, string description)
	{
		return ConfigFileExtensions.BindConfig<T>(((BaseUnityPlugin)this).Config, section, key, defaultValue, description, true, (int?)null, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null);
	}

	private ConfigEntry<T> BindLocal<T>(string section, string key, T defaultValue, string description)
	{
		return ConfigFileExtensions.BindConfig<T>(((BaseUnityPlugin)this).Config, section, key, defaultValue, description, false, (int?)null, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null);
	}

	private void RegisterPlantableRaspberryBush()
	{
		PrefabManager.OnVanillaPrefabsAvailable -= RegisterPlantableRaspberryBush;
		RegisterPlantableResource("JGQoL_RaspberryBush", "RaspberryBush", "Raspberry", "Raspberry Bush", "Plant a raspberry bush.", convertItemLayer: false);
	}

	private void RegisterPlantableBlueberryBush()
	{
		PrefabManager.OnVanillaPrefabsAvailable -= RegisterPlantableBlueberryBush;
		RegisterPlantableResource("JGQoL_BlueberryBush", "BlueberryBush", "Blueberries", "Blueberry Bush", "Plant a blueberry bush.", convertItemLayer: false);
	}

	private void RegisterPlantableMushroom()
	{
		PrefabManager.OnVanillaPrefabsAvailable -= RegisterPlantableMushroom;
		RegisterPlantableResource("JGQoL_Mushroom", "Pickable_Mushroom", "Mushroom", "Mushroom", "Plant a mushroom.", convertItemLayer: true);
	}

	private void RegisterPlantableYellowMushroom()
	{
		PrefabManager.OnVanillaPrefabsAvailable -= RegisterPlantableYellowMushroom;
		RegisterPlantableResource("JGQoL_YellowMushroom", "Pickable_Mushroom_yellow", "MushroomYellow", "Yellow Mushroom", "Plant a yellow mushroom.", convertItemLayer: true);
	}

	private void RegisterPlantableDandelion()
	{
		PrefabManager.OnVanillaPrefabsAvailable -= RegisterPlantableDandelion;
		RegisterPlantableResource("JGQoL_Dandelion", "Pickable_Dandelion", "Dandelion", "Dandelion", "Plant a dandelion.", convertItemLayer: true);
	}

	private void RegisterPlantableThistle()
	{
		PrefabManager.OnVanillaPrefabsAvailable -= RegisterPlantableThistle;
		RegisterPlantableResource("JGQoL_Thistle", "Pickable_Thistle", "Thistle", "Thistle", "Plant thistle.", convertItemLayer: true);
	}

	private void RegisterPlantableResource(string clonedPrefabName, string sourcePrefabName, string itemPrefabName, string displayName, string description, bool convertItemLayer)
	{
		//IL_0153: Unknown result type (might be due to invalid IL or missing references)
		//IL_0158: Unknown result type (might be due to invalid IL or missing references)
		//IL_0160: Unknown result type (might be due to invalid IL or missing references)
		//IL_0168: Unknown result type (might be due to invalid IL or missing references)
		//IL_0173: Unknown result type (might be due to invalid IL or missing references)
		//IL_017d: Expected O, but got Unknown
		//IL_0183: Unknown result type (might be due to invalid IL or missing references)
		//IL_018d: Expected O, but got Unknown
		//IL_0191: Unknown result type (might be due to invalid IL or missing references)
		//IL_0198: Expected O, but got Unknown
		if (!PlantableResourcesEnabled.Value)
		{
			return;
		}
		GameObject val = PrefabManager.Instance.CreateClonedPrefab(clonedPrefabName, sourcePrefabName);
		if ((Object)(object)val == (Object)null)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)("[PlantableResources] Could not clone " + sourcePrefabName + "."));
			return;
		}
		if (convertItemLayer)
		{
			int num = LayerMask.NameToLayer("item");
			int layer = LayerMask.NameToLayer("Default_small");
			Transform[] componentsInChildren = val.GetComponentsInChildren<Transform>(true);
			foreach (Transform val2 in componentsInChildren)
			{
				if (((Component)val2).gameObject.layer == num)
				{
					((Component)val2).gameObject.layer = layer;
				}
			}
			AddPlantableResourceRemnant(val, itemPrefabName);
		}
		Piece val3 = val.GetComponent<Piece>();
		if ((Object)(object)val3 == (Object)null)
		{
			val3 = val.AddComponent<Piece>();
		}
		val3.m_canBeRemoved = true;
		GameObject prefab = PrefabManager.Instance.GetPrefab(itemPrefabName);
		ItemDrop val4 = (((Object)(object)prefab != (Object)null) ? prefab.GetComponent<ItemDrop>() : null);
		Sprite val5 = null;
		if ((Object)(object)val4 != (Object)null && val4.m_itemData != null && val4.m_itemData.m_shared.m_icons != null && val4.m_itemData.m_shared.m_icons.Length != 0)
		{
			val5 = val4.m_itemData.m_shared.m_icons[0];
		}
		if ((Object)(object)val5 == (Object)null)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)("[PlantableResources] Could not find icon for " + itemPrefabName + "."));
			return;
		}
		PieceConfig val6 = new PieceConfig
		{
			Name = displayName,
			Description = description,
			PieceTable = PieceTables.Cultivator,
			Icon = val5
		};
		val6.AddRequirement(new RequirementConfig(itemPrefabName, 5, 0, false));
		CustomPiece val7 = new CustomPiece(val, false, val6);
		PieceManager.Instance.AddPiece(val7);
	}

	private static void AddPlantableResourceRemnant(GameObject resource, string itemPrefabName)
	{
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: Expected O, but got Unknown
		if (!((Object)(object)resource == (Object)null) && !((Object)(object)resource.transform.Find("_JGQoL_PlantableRemnant") != (Object)null))
		{
			Renderer componentInChildren = resource.GetComponentInChildren<Renderer>(true);
			Material val = (((Object)(object)componentInChildren != (Object)null) ? componentInChildren.sharedMaterial : null);
			GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)2);
			((Object)val2).name = "_JGQoL_PlantableRemnant";
			val2.transform.SetParent(resource.transform, false);
			val2.transform.localScale = new Vector3(0.1f, 0.08f, 0.1f);
			val2.transform.localPosition = new Vector3(0f, 0.08f, 0f);
			val2.transform.localRotation = Quaternion.identity;
			val2.layer = LayerMask.NameToLayer("Default_small");
			Collider component = val2.GetComponent<Collider>();
			if ((Object)(object)component != (Object)null)
			{
				component.enabled = true;
			}
			Renderer component2 = val2.GetComponent<Renderer>();
			if ((Object)(object)component2 != (Object)null && (Object)(object)val != (Object)null)
			{
				Material val3 = new Material(val);
				((Object)val3).name = "JGQoL_" + itemPrefabName + "_RemnantMaterial";
				component2.sharedMaterial = val3;
			}
			if ((Object)(object)val2.GetComponent<PlantableResourceRemnantHover>() == (Object)null)
			{
				val2.AddComponent<PlantableResourceRemnantHover>();
			}
			val2.SetActive(false);
			if ((Object)(object)resource.GetComponent<PlantableResourceRemnant>() == (Object)null)
			{
				resource.AddComponent<PlantableResourceRemnant>();
			}
		}
	}

	private static bool IsSamePickableType(Pickable a, Pickable b)
	{
		if ((Object)(object)a == (Object)null || (Object)(object)b == (Object)null)
		{
			return false;
		}
		if ((Object)(object)a.m_itemPrefab == (Object)null || (Object)(object)b.m_itemPrefab == (Object)null)
		{
			return ((Object)((Component)a).gameObject).name == ((Object)((Component)b).gameObject).name;
		}
		return ((Object)a.m_itemPrefab).name == ((Object)b.m_itemPrefab).name;
	}

	private static string FormatTimeRemaining(double seconds)
	{
		if (seconds < 0.0)
		{
			seconds = 0.0;
		}
		int num = Mathf.CeilToInt((float)seconds);
		int num2 = num / 3600;
		int num3 = num % 3600 / 60;
		int num4 = num % 60;
		if (num2 > 0)
		{
			return $"{num2}h {num3:D2}m {num4:D2}s";
		}
		if (num3 > 0)
		{
			return $"{num3}m {num4:D2}s";
		}
		return $"{num4}s";
	}

	private static bool TryGetCookingSlot(CookingStation station, int slot, out string itemName, out float cookedTime)
	{
		itemName = "";
		cookedTime = 0f;
		MethodInfo methodInfo = AccessTools.Method(typeof(CookingStation), "GetSlot", (Type[])null, (Type[])null);
		if (methodInfo == null)
		{
			return false;
		}
		ParameterInfo[] parameters = methodInfo.GetParameters();
		object[] array = new object[parameters.Length];
		array[0] = slot;
		array[1] = "";
		array[2] = 0f;
		for (int i = 3; i < parameters.Length; i++)
		{
			Type type = parameters[i].ParameterType;
			if (type.IsByRef)
			{
				type = type.GetElementType();
			}
			array[i] = ((type != null && type.IsValueType) ? Activator.CreateInstance(type) : null);
		}
		try
		{
			methodInfo.Invoke(station, array);
		}
		catch
		{
			return false;
		}
		itemName = (array[1] as string) ?? "";
		if (array[2] is float num)
		{
			cookedTime = num;
		}
		return true;
	}

	private static double GetPickableRespawnMinutes(Pickable pickable)
	{
		if ((Object)(object)pickable == (Object)null)
		{
			return 0.0;
		}
		FieldInfo fieldInfo = AccessTools.Field(typeof(Pickable), "m_respawnTimeMinutes");
		if (fieldInfo == null)
		{
			return 0.0;
		}
		object value = fieldInfo.GetValue(pickable);
		if (value == null)
		{
			return 0.0;
		}
		return Convert.ToDouble(value);
	}

	private static List<Container> GetNearbyCraftContainers(Vector3 center)
	{
		//IL_0119: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		List<Container> list = new List<Container>();
		if ((Object)(object)Player.m_localPlayer == (Object)null)
		{
			return list;
		}
		MethodInfo methodInfo = AccessTools.Method(typeof(Container), "CheckAccess", (Type[])null, (Type[])null);
		long playerID = Player.m_localPlayer.GetPlayerID();
		List<Container> list2 = new List<Container>();
		foreach (Container trackedCraftContainer in TrackedCraftContainers)
		{
			if ((Object)(object)trackedCraftContainer == (Object)null)
			{
				list2.Add(trackedCraftContainer);
			}
			else
			{
				if ((Object)(object)trackedCraftContainer.m_nview == (Object)null || !trackedCraftContainer.m_nview.IsValid() || Vector3.Distance(center, ((Component)trackedCraftContainer).transform.position) > ContainerRange.Value || trackedCraftContainer.GetInventory() == null || trackedCraftContainer.IsInUse() || (Object)(object)((Component)trackedCraftContainer).GetComponentInParent<Piece>() == (Object)null)
				{
					continue;
				}
				if (methodInfo != null)
				{
					bool flag = false;
					try
					{
						flag = (bool)methodInfo.Invoke(trackedCraftContainer, new object[1] { playerID });
					}
					catch
					{
						flag = false;
					}
					if (!flag)
					{
						continue;
					}
				}
				if (!trackedCraftContainer.m_checkGuardStone || PrivateArea.CheckAccess(((Component)trackedCraftContainer).transform.position, 0f, false, false))
				{
					list.Add(trackedCraftContainer);
				}
			}
		}
		foreach (Container item in list2)
		{
			TrackedCraftContainers.Remove(item);
		}
		return list;
	}

	private static int CountAvailableResource(Player player, string itemName, int itemQuality = -1)
	{
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)player == (Object)null || string.IsNullOrEmpty(itemName))
		{
			return 0;
		}
		int num = ((Humanoid)player).GetInventory().CountItems(itemName, itemQuality, true);
		foreach (Container nearbyCraftContainer in GetNearbyCraftContainers(((Component)player).transform.position))
		{
			Inventory inventory = nearbyCraftContainer.GetInventory();
			if (inventory != null)
			{
				num += inventory.CountItems(itemName, itemQuality, true);
			}
		}
		return num;
	}

	private static int GetAffordablePlantRowCount(Player player, Piece piece)
	{
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)player == (Object)null || (Object)(object)piece == (Object)null || piece.m_resources == null)
		{
			return 0;
		}
		int num = 5;
		Requirement[] resources = piece.m_resources;
		foreach (Requirement val in resources)
		{
			if (val == null || (Object)(object)val.m_resItem == (Object)null)
			{
				continue;
			}
			int amount = val.GetAmount(0);
			if (amount <= 0)
			{
				continue;
			}
			string name = val.m_resItem.m_itemData.m_shared.m_name;
			int num2 = ((Humanoid)player).GetInventory().CountItems(name, -1, true);
			if (CraftFromContainersEnabled.Value && CraftFromContainersPlanting.Value)
			{
				foreach (Container nearbyCraftContainer in GetNearbyCraftContainers(((Component)player).transform.position))
				{
					Inventory inventory = nearbyCraftContainer.GetInventory();
					if (inventory != null)
					{
						num2 += inventory.CountItems(name, -1, true);
					}
				}
			}
			int num3 = num2 / amount;
			num = Mathf.Min(num, num3);
		}
		return Mathf.Clamp(num, 0, 5);
	}

	private static int RemoveResourceFromContainers(Player player, string itemName, int amount, int itemQuality = -1)
	{
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)player == (Object)null || string.IsNullOrEmpty(itemName) || amount <= 0)
		{
			return 0;
		}
		int num = amount;
		int num2 = 0;
		List<Container> nearbyCraftContainers = GetNearbyCraftContainers(((Component)player).transform.position);
		MethodInfo methodInfo = AccessTools.Method(typeof(Container), "Save", (Type[])null, (Type[])null);
		foreach (Container item in nearbyCraftContainers)
		{
			if (num <= 0)
			{
				break;
			}
			if ((Object)(object)item.m_nview != (Object)null && item.m_nview.IsValid() && !item.m_nview.IsOwner())
			{
				item.m_nview.ClaimOwnership();
			}
			Inventory inventory = item.GetInventory();
			if (inventory == null)
			{
				continue;
			}
			int num3 = inventory.CountItems(itemName, itemQuality, true);
			if (num3 > 0)
			{
				int num4 = Mathf.Min(num3, num);
				inventory.RemoveItem(itemName, num4, itemQuality, true);
				if (methodInfo != null)
				{
					methodInfo.Invoke(item, null);
				}
				num2 += num4;
				num -= num4;
			}
		}
		return num2;
	}

	private static void DisableStartupIntroIfReady()
	{
		if (SkipStartupSequence.Value && (Object)(object)CinematicsManager.s_instance != (Object)null)
		{
			CinematicsManager.s_instance.m_introOnStartup = false;
		}
	}

	private static void DisableFirstStartupMenuIntro(FejdStartup startup)
	{
		if (SkipStartupSequence.Value && !((Object)(object)startup == (Object)null) && !((Object)(object)startup.m_menuAnimator == (Object)null))
		{
			startup.m_menuAnimator.SetBool("FirstStartup", false);
		}
	}

	private static void DisableSceneLoaderLogos(SceneLoader loader)
	{
		if (SkipStartupSequence.Value && !((Object)(object)loader == (Object)null))
		{
			FieldInfo fieldInfo = AccessTools.Field(typeof(SceneLoader), "_showLogos");
			if (fieldInfo != null)
			{
				fieldInfo.SetValue(loader, false);
			}
			HideSceneLoaderObject(loader, "coffeeStainLogo");
			HideSceneLoaderObject(loader, "ironGateLogo");
			HideSceneLoaderObject(loader, "gameLogo");
		}
	}

	private static void HideSceneLoaderObject(SceneLoader loader, string fieldName)
	{
		FieldInfo fieldInfo = AccessTools.Field(typeof(SceneLoader), fieldName);
		if (!(fieldInfo == null))
		{
			object? value = fieldInfo.GetValue(loader);
			GameObject val = (GameObject)((value is GameObject) ? value : null);
			if ((Object)(object)val != (Object)null)
			{
				val.SetActive(false);
			}
		}
	}

	private static void DestroyPlantRowPreviewGhosts()
	{
		for (int i = 0; i < PlantRowPreviewGhosts.Length; i++)
		{
			if ((Object)(object)PlantRowPreviewGhosts[i] != (Object)null)
			{
				Object.Destroy((Object)(object)PlantRowPreviewGhosts[i]);
				PlantRowPreviewGhosts[i] = null;
			}
		}
		_plantRowPreviewSourceName = null;
	}

	private static void SetPlantRowPreviewActive(bool active)
	{
		for (int i = 0; i < PlantRowPreviewGhosts.Length; i++)
		{
			if ((Object)(object)PlantRowPreviewGhosts[i] != (Object)null)
			{
				PlantRowPreviewGhosts[i].SetActive(active);
			}
		}
	}

	private static bool HasPlantRowGrowSpace(Vector3 position, Plant plant)
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)plant == (Object)null)
		{
			return false;
		}
		return Physics.OverlapSphere(position, plant.m_growRadius, PlantRowGrowSpaceMask).Length == 0;
	}

	private static bool EnsurePlantRowPreviewGhosts(Player player, GameObject vanillaGhost)
	{
		if ((Object)(object)player == (Object)null || (Object)(object)vanillaGhost == (Object)null)
		{
			return false;
		}
		PieceTable value = Traverse.Create((object)player).Field("m_buildPieces").GetValue<PieceTable>();
		if ((Object)(object)value == (Object)null)
		{
			return false;
		}
		GameObject selectedPrefab = value.GetSelectedPrefab();
		if ((Object)(object)selectedPrefab == (Object)null)
		{
			return false;
		}
		if ((Object)(object)selectedPrefab.GetComponent<Plant>() == (Object)null)
		{
			return false;
		}
		string name = ((Object)selectedPrefab).name;
		bool flag = _plantRowPreviewSourceName != name;
		for (int i = 0; i < PlantRowPreviewGhosts.Length; i++)
		{
			if ((Object)(object)PlantRowPreviewGhosts[i] == (Object)null)
			{
				flag = true;
				break;
			}
		}
		if (!flag)
		{
			return true;
		}
		DestroyPlantRowPreviewGhosts();
		_plantRowPreviewSourceName = name;
		for (int j = 0; j < PlantRowPreviewGhosts.Length; j++)
		{
			GameObject val = null;
			ZNetView.m_forceDisableInit = true;
			try
			{
				val = Object.Instantiate<GameObject>(selectedPrefab);
			}
			finally
			{
				ZNetView.m_forceDisableInit = false;
			}
			if ((Object)(object)val == (Object)null)
			{
				DestroyPlantRowPreviewGhosts();
				return false;
			}
			((Object)val).name = ((Object)selectedPrefab).name + "_JGQoL_PlantRowPreview";
			int layer = LayerMask.NameToLayer("ghost");
			Transform[] componentsInChildren = val.GetComponentsInChildren<Transform>(true);
			for (int k = 0; k < componentsInChildren.Length; k++)
			{
				((Component)componentsInChildren[k]).gameObject.layer = layer;
			}
			Joint[] componentsInChildren2 = val.GetComponentsInChildren<Joint>(true);
			for (int k = 0; k < componentsInChildren2.Length; k++)
			{
				Object.Destroy((Object)(object)componentsInChildren2[k]);
			}
			Rigidbody[] componentsInChildren3 = val.GetComponentsInChildren<Rigidbody>(true);
			for (int k = 0; k < componentsInChildren3.Length; k++)
			{
				Object.Destroy((Object)(object)componentsInChildren3[k]);
			}
			TerrainModifier[] componentsInChildren4 = val.GetComponentsInChildren<TerrainModifier>(true);
			for (int k = 0; k < componentsInChildren4.Length; k++)
			{
				Object.Destroy((Object)(object)componentsInChildren4[k]);
			}
			GuidePoint[] componentsInChildren5 = val.GetComponentsInChildren<GuidePoint>(true);
			for (int k = 0; k < componentsInChildren5.Length; k++)
			{
				Object.Destroy((Object)(object)componentsInChildren5[k]);
			}
			Light[] componentsInChildren6 = val.GetComponentsInChildren<Light>(true);
			for (int k = 0; k < componentsInChildren6.Length; k++)
			{
				Object.Destroy((Object)(object)componentsInChildren6[k]);
			}
			Transform val2 = val.transform.Find("_GhostOnly");
			if ((Object)(object)val2 != (Object)null)
			{
				((Component)val2).gameObject.SetActive(true);
			}
			PlantRowPreviewGhosts[j] = val;
		}
		return true;
	}

	private static float GetSurfaceMovementSpeedMultiplier(Player player)
	{
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Expected I4, but got Unknown
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		if (!SurfaceMovementSpeedEnabled.Value || (Object)(object)player == (Object)null || !((Character)player).IsOnGround() || ((Character)player).IsSwimming())
		{
			return 1f;
		}
		Collider lastGroundCollider = ((Character)player).GetLastGroundCollider();
		if ((Object)(object)lastGroundCollider == (Object)null)
		{
			return 1f;
		}
		WearNTear componentInParent = ((Component)lastGroundCollider).GetComponentInParent<WearNTear>();
		if ((Object)(object)componentInParent != (Object)null)
		{
			switch ((int)componentInParent.m_materialType)
			{
			case 0:
			case 3:
				return WoodFloorSpeedMultiplier.Value;
			case 1:
			case 4:
			case 5:
			case 6:
				return StoneFloorSpeedMultiplier.Value;
			default:
				return 1f;
			}
		}
		Heightmap component = ((Component)lastGroundCollider).GetComponent<Heightmap>();
		if ((Object)(object)component == (Object)null)
		{
			return 1f;
		}
		Color paintMask = component.GetPaintMask(((Component)player).transform.position);
		if (paintMask.r > 0.5f)
		{
			return PathSpeedMultiplier.Value;
		}
		if (paintMask.b > 0.5f)
		{
			return PathSpeedMultiplier.Value;
		}
		return 1f;
	}

	private static int GetCraftQuantityMaximum()
	{
		if (CraftQuantityMaximum == null)
		{
			return 100;
		}
		return Mathf.Clamp(CraftQuantityMaximum.Value, 1, 100);
	}

	private static void SetCraftQuantityAmount(int amount)
	{
		_craftQuantityAmount = Mathf.Clamp(amount, 1, GetCraftQuantityMaximum());
		if ((Object)(object)_craftQuantityInput != (Object)null)
		{
			_craftQuantityInput.SetTextWithoutNotify(_craftQuantityAmount.ToString());
		}
	}

	private static void OnCraftQuantityChanged(string value)
	{
		if (!string.IsNullOrEmpty(value) && int.TryParse(value, out var result))
		{
			_craftQuantityAmount = Mathf.Clamp(result, 1, GetCraftQuantityMaximum());
		}
	}

	private static void OnCraftQuantityEndEdit(string value)
	{
		if (!int.TryParse(value, out var result))
		{
			result = 1;
		}
		SetCraftQuantityAmount(result);
	}

	private static float GetCraftQuantityDuration(int amount)
	{
		if (amount <= 1)
		{
			return _craftQuantityBaseDuration;
		}
		int num = Mathf.Max(2, _craftQuantityVanillaMultiAmount);
		float num2 = (_craftQuantityBaseMultiDuration - _craftQuantityBaseDuration) / (float)(num - 1);
		if (num2 < 0f)
		{
			num2 = 0f;
		}
		return _craftQuantityBaseDuration + num2 * (float)(amount - 1);
	}

	private static void ApplyCraftQuantity(InventoryGui gui, ref bool touchMultiCrafting)
	{
		if (!((Object)(object)gui == (Object)null) && CraftQuantityEnabled.Value && gui.InCraftTab())
		{
			int num = Mathf.Clamp(_craftQuantityAmount, 1, GetCraftQuantityMaximum());
			if (num != _craftQuantityAmount)
			{
				SetCraftQuantityAmount(num);
			}
			gui.m_multiCraftAmount = num;
			touchMultiCrafting = num > 1;
			if (num > 1)
			{
				gui.m_multiCraftDuration = GetCraftQuantityDuration(num);
			}
			else
			{
				gui.m_multiCraftDuration = _craftQuantityBaseMultiDuration;
			}
		}
	}

	private static void CreateCraftQuantityUI(InventoryGui gui)
	{
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Expected O, but got Unknown
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_0104: Unknown result type (might be due to invalid IL or missing references)
		//IL_010f: Unknown result type (might be due to invalid IL or missing references)
		//IL_011e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0123: Unknown result type (might be due to invalid IL or missing references)
		//IL_0196: Unknown result type (might be due to invalid IL or missing references)
		//IL_015b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0175: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cc: Expected O, but got Unknown
		//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_020c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0222: Unknown result type (might be due to invalid IL or missing references)
		//IL_0251: Unknown result type (might be due to invalid IL or missing references)
		//IL_0256: Unknown result type (might be due to invalid IL or missing references)
		//IL_0269: Unknown result type (might be due to invalid IL or missing references)
		//IL_0270: Unknown result type (might be due to invalid IL or missing references)
		//IL_027b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0286: Unknown result type (might be due to invalid IL or missing references)
		//IL_0290: Unknown result type (might be due to invalid IL or missing references)
		//IL_02db: Unknown result type (might be due to invalid IL or missing references)
		//IL_0326: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)gui == (Object)null || (Object)(object)gui.m_craftButton == (Object)null)
		{
			return;
		}
		if ((Object)(object)_craftQuantityRoot != (Object)null)
		{
			Object.Destroy((Object)(object)_craftQuantityRoot);
		}
		RectTransform component = ((Component)gui.m_craftButton).GetComponent<RectTransform>();
		if (!((Object)(object)component == (Object)null))
		{
			GameObject val = new GameObject("JGQoL_CraftQuantity", new Type[3]
			{
				typeof(RectTransform),
				typeof(Image),
				typeof(TMP_InputField)
			});
			val.transform.SetParent(((Transform)component).parent, false);
			RectTransform component2 = val.GetComponent<RectTransform>();
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor((component.anchorMin.x + component.anchorMax.x) * 0.5f, (component.anchorMin.y + component.anchorMax.y) * 0.5f);
			component2.anchorMin = val2;
			component2.anchorMax = val2;
			component2.pivot = new Vector2(0.5f, 0.5f);
			component2.sizeDelta = new Vector2(55f, 32f);
			component2.anchoredPosition = component.anchoredPosition + new Vector2(-130f, 0f);
			Image component3 = val.GetComponent<Image>();
			Image component4 = ((Component)gui.m_craftButton).GetComponent<Image>();
			if ((Object)(object)component4 != (Object)null)
			{
				component3.sprite = component4.sprite;
				component3.type = component4.type;
				((Graphic)component3).material = ((Graphic)component4).material;
				((Graphic)component3).color = ((Graphic)component4).color;
			}
			else
			{
				((Graphic)component3).color = new Color(0f, 0f, 0f, 0.75f);
			}
			GameObject val3 = new GameObject("Text Area", new Type[2]
			{
				typeof(RectTransform),
				typeof(RectMask2D)
			});
			val3.transform.SetParent(val.transform, false);
			RectTransform component5 = val3.GetComponent<RectTransform>();
			component5.anchorMin = Vector2.zero;
			component5.anchorMax = Vector2.one;
			component5.offsetMin = new Vector2(6f, 2f);
			component5.offsetMax = new Vector2(-6f, -2f);
			GameObject val4 = new GameObject("Text", new Type[2]
			{
				typeof(RectTransform),
				typeof(TextMeshProUGUI)
			});
			val4.transform.SetParent(val3.transform, false);
			RectTransform component6 = val4.GetComponent<RectTransform>();
			component6.anchorMin = Vector2.zero;
			component6.anchorMax = Vector2.one;
			component6.offsetMin = Vector2.zero;
			component6.offsetMax = Vector2.zero;
			TextMeshProUGUI component7 = val4.GetComponent<TextMeshProUGUI>();
			if ((Object)(object)gui.m_recipeName != (Object)null)
			{
				((TMP_Text)component7).font = gui.m_recipeName.font;
			}
			((TMP_Text)component7).fontSize = 18f;
			((TMP_Text)component7).alignment = (TextAlignmentOptions)514;
			((Graphic)component7).color = Color.white;
			((TMP_Text)component7).enableWordWrapping = false;
			TMP_InputField component8 = val.GetComponent<TMP_InputField>();
			component8.textViewport = component5;
			component8.textComponent = (TMP_Text)(object)component7;
			component8.contentType = (ContentType)2;
			component8.lineType = (LineType)0;
			component8.characterLimit = 3;
			((Selectable)component8).targetGraphic = (Graphic)(object)component3;
			((Selectable)component8).colors = ((Selectable)gui.m_craftButton).colors;
			component8.text = "1";
			((UnityEvent<string>)(object)component8.onValueChanged).AddListener((UnityAction<string>)OnCraftQuantityChanged);
			((UnityEvent<string>)(object)component8.onEndEdit).AddListener((UnityAction<string>)OnCraftQuantityEndEdit);
			_craftQuantityRoot = val;
			_craftQuantityInput = component8;
			SetCraftQuantityAmount(1);
			val.SetActive(false);
		}
	}

	private static void ApplyCraftingStationRanges(CraftingStation station)
	{
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)station == (Object)null)
		{
			return;
		}
		station.m_rangeBuild = WorkBenchRange.Value;
		if ((Object)(object)station.m_areaMarker != (Object)null)
		{
			CircleProjector component = station.m_areaMarker.GetComponent<CircleProjector>();
			if ((Object)(object)component != (Object)null)
			{
				component.m_radius = WorkBenchRange.Value;
			}
		}
		Piece componentInParent = ((Component)station).GetComponentInParent<Piece>();
		EffectArea[] array = ((!((Object)(object)componentInParent != (Object)null)) ? ((Component)station).GetComponentsInChildren<EffectArea>(true) : ((Component)componentInParent).GetComponentsInChildren<EffectArea>(true));
		EffectArea[] array2 = array;
		foreach (EffectArea val in array2)
		{
			if ((Object)(object)val == (Object)null || (val.m_type & 4) == 0)
			{
				continue;
			}
			Collider collider = val.m_collider;
			SphereCollider val2 = (SphereCollider)(object)((collider is SphereCollider) ? collider : null);
			if (val2 != null)
			{
				val2.radius = WorkBenchPlayerBase.Value;
				continue;
			}
			CapsuleCollider val3 = (CapsuleCollider)(object)((collider is CapsuleCollider) ? collider : null);
			if (val3 != null)
			{
				val3.radius = WorkBenchPlayerBase.Value;
			}
		}
	}

	private static void ApplyPlayerBaseRange(CraftingStation station)
	{
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)station == (Object)null)
		{
			return;
		}
		Piece componentInParent = ((Component)station).GetComponentInParent<Piece>();
		EffectArea[] array = ((!((Object)(object)componentInParent != (Object)null)) ? ((Component)station).GetComponentsInChildren<EffectArea>(true) : ((Component)componentInParent).GetComponentsInChildren<EffectArea>(true));
		EffectArea[] array2 = array;
		foreach (EffectArea val in array2)
		{
			if ((Object)(object)val == (Object)null || (val.m_type & 4) == 0)
			{
				continue;
			}
			Collider collider = val.m_collider;
			SphereCollider val2 = (SphereCollider)(object)((collider is SphereCollider) ? collider : null);
			if (val2 != null)
			{
				if (!Mathf.Approximately(val2.radius, WorkBenchPlayerBase.Value))
				{
					val2.radius = WorkBenchPlayerBase.Value;
				}
				continue;
			}
			CapsuleCollider val3 = (CapsuleCollider)(object)((collider is CapsuleCollider) ? collider : null);
			if (val3 != null && !Mathf.Approximately(val3.radius, WorkBenchPlayerBase.Value))
			{
				val3.radius = WorkBenchPlayerBase.Value;
			}
		}
	}

	private static bool IsBulkModifierHeld()
	{
		if (!Input.GetKey((KeyCode)304))
		{
			return ZInput.GetButton("JoyAltKeys");
		}
		return true;
	}

	private static string GetBulkActionHint(string actionName)
	{
		string text = (ZInput.IsGamepadActive() ? "$KEY_JoyAltKeys + $KEY_JoyUse" : "Left Shift + $KEY_Use");
		return Localization.instance.Localize("\n[<color=yellow><b>" + text + "</b></color>] " + actionName);
	}

	private static ItemData FindSmelterInput(Smelter smelter, Inventory inventory)
	{
		foreach (ItemConversion item2 in smelter.m_conversion)
		{
			if (item2 != null && !((Object)(object)item2.m_from == (Object)null))
			{
				string name = item2.m_from.m_itemData.m_shared.m_name;
				ItemData item = inventory.GetItem(name, -1, false);
				if (item != null)
				{
					return item;
				}
			}
		}
		return null;
	}
}