Decompiled source of Valharvest v3.1.1

plugins\Valharvest.dll

Decompiled 3 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using HarmonyLib;
using Jotunn;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using SimpleJson;
using UnityEngine;
using UnityEngine.Serialization;
using Valharvest.Configurations;
using Valharvest.Scripts;
using Valharvest.WorldGen;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("Valharvest")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Valharvest")]
[assembly: AssemblyCopyright("Copyright Frenvius 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")]
[assembly: AssemblyFileVersion("0.3.1.1")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.3.1.1")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
public class CustomBeehive : MonoBehaviour, Hoverable, Interactable
{
	public string m_name = "";

	public GameObject m_hideWhenPicked;

	public Transform m_spawnPoint;

	public float m_secPerUnit = 800f;

	public int m_maxHoney = 3;

	public ItemDrop m_honeyItem;

	public EffectList m_spawnEffect = new EffectList();

	private ZNetView m_nview;

	private void Awake()
	{
		m_nview = ((Component)this).GetComponent<ZNetView>();
		if (m_nview.GetZDO() != null)
		{
			HidePrefab();
			if (m_nview.IsOwner() && m_nview.GetZDO().GetLong("lastTime", 0L) == 0L)
			{
				m_nview.GetZDO().Set("lastTime", ZNet.instance.GetTime().Ticks);
			}
			m_nview.Register("Extract", (Action<long>)RPC_Extract);
			((MonoBehaviour)this).InvokeRepeating("UpdateBees", 0f, 10f);
			((MonoBehaviour)this).InvokeRepeating("HidePrefab", 0f, 5f);
		}
	}

	private void HidePrefab()
	{
		if (Object.op_Implicit((Object)(object)m_hideWhenPicked))
		{
			int honeyLevel = GetHoneyLevel();
			m_hideWhenPicked.SetActive(honeyLevel > 0);
		}
	}

	public string GetHoverText()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		if (!PrivateArea.CheckAccess(((Component)this).transform.position, 0f, false, false))
		{
			return Localization.instance.Localize(m_name + "\n$piece_noaccess");
		}
		int honeyLevel = GetHoneyLevel();
		if (honeyLevel > 0)
		{
			return Localization.instance.Localize(m_name + " ( " + m_honeyItem.m_itemData.m_shared.m_name + " x " + honeyLevel + " )\n[<color=yellow><b>$KEY_Use</b></color>] $water_well_extract");
		}
		return Localization.instance.Localize(m_name + " ( $piece_container_empty )\n[<color=yellow><b>$KEY_Use</b></color>] $water_well_check");
	}

	public string GetHoverName()
	{
		return m_name;
	}

	public bool Interact(Humanoid character, bool repeat, bool alt)
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		if (repeat)
		{
			return false;
		}
		if (!PrivateArea.CheckAccess(((Component)this).transform.position, 0f, true, false))
		{
			return true;
		}
		if (GetHoneyLevel() > 0)
		{
			Extract();
		}
		else
		{
			((Character)character).Message((MessageType)2, "$water_well_use", 0, (Sprite)null);
		}
		return true;
	}

	public bool UseItem(Humanoid user, ItemData item)
	{
		return false;
	}

	private void Extract()
	{
		m_nview.InvokeRPC("Extract", Array.Empty<object>());
	}

	private void RPC_Extract(long caller)
	{
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: 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)
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		int honeyLevel = GetHoneyLevel();
		if (honeyLevel > 0)
		{
			if (Object.op_Implicit((Object)(object)m_hideWhenPicked))
			{
				m_hideWhenPicked.SetActive(false);
			}
			m_spawnEffect.Create(m_spawnPoint.position, Quaternion.identity, (Transform)null, 1f, -1);
			for (int i = 0; i < honeyLevel; i++)
			{
				Vector2 val = Random.insideUnitCircle * 0.5f;
				Vector3 val2 = m_spawnPoint.position + new Vector3(val.x, 0.25f * (float)i, val.y);
				Object.Instantiate<ItemDrop>(m_honeyItem, val2, Quaternion.identity);
			}
			ResetLevel();
		}
	}

	private float GetTimeSinceLastUpdate()
	{
		DateTime dateTime = new DateTime(m_nview.GetZDO().GetLong("lastTime", ZNet.instance.GetTime().Ticks));
		DateTime time = ZNet.instance.GetTime();
		TimeSpan timeSpan = time - dateTime;
		m_nview.GetZDO().Set("lastTime", time.Ticks);
		double num = timeSpan.TotalSeconds;
		if (num < 0.0)
		{
			num = 0.0;
		}
		return (float)num;
	}

	private void ResetLevel()
	{
		m_nview.GetZDO().Set("level", 0);
	}

	private void IncreseLevel(int i)
	{
		int honeyLevel = GetHoneyLevel();
		honeyLevel += i;
		honeyLevel = Mathf.Clamp(honeyLevel, 0, m_maxHoney);
		m_nview.GetZDO().Set("level", honeyLevel);
	}

	private int GetHoneyLevel()
	{
		return m_nview.GetZDO().GetInt("level", 0);
	}

	private void UpdateBees()
	{
		if (GetHoneyLevel() > 0 && Object.op_Implicit((Object)(object)m_hideWhenPicked))
		{
			m_hideWhenPicked.SetActive(true);
		}
		if (m_nview.IsOwner())
		{
			float timeSinceLastUpdate = GetTimeSinceLastUpdate();
			float @float = m_nview.GetZDO().GetFloat("product", 0f);
			@float += timeSinceLastUpdate;
			if (@float > m_secPerUnit)
			{
				int i = (int)(@float / m_secPerUnit);
				IncreseLevel(i);
				@float = 0f;
			}
			m_nview.GetZDO().Set("product", @float);
		}
	}
}
namespace Valharvest
{
	public static class Utils
	{
		private const string Name = "name";

		private const string Food = "food";

		private const string Weight = "weight";

		private const string Variants = "variants";

		private const string FoodRegen = "foodRegen";

		private const string FoodStamina = "foodStamina";

		private const string Description = "description";

		private const string MaxStackSize = "maxStackSize";

		private const string FoodBurnTime = "foodBurnTime";

		private const string ConsumeStatusEffect = "consumeStatusEffect";

		public static readonly int MainTex = Shader.PropertyToID("_MainTex");

		public static readonly int Color = Shader.PropertyToID("_Color");

		private static readonly int Cull = Shader.PropertyToID("_Cull");

		private static readonly int Cutoff = Shader.PropertyToID("_Cutoff");

		private static readonly int Height = Shader.PropertyToID("_Height");

		private static readonly int AddSnow = Shader.PropertyToID("_AddSnow");

		private static readonly int AddRain = Shader.PropertyToID("_AddRain");

		private static readonly int CamCull = Shader.PropertyToID("_CamCull");

		private static readonly int Metallic = Shader.PropertyToID("_Metallic");

		private static readonly int SwaySpeed = Shader.PropertyToID("_SwaySpeed");

		private static readonly int MossNormal = Shader.PropertyToID("_MossNormal");

		private static readonly int Glossiness = Shader.PropertyToID("_Glossiness");

		private static readonly int RippleSpeed = Shader.PropertyToID("_RippleSpeed");

		private static readonly int SwayDistance = Shader.PropertyToID("_SwayDistance");

		private static readonly int PushDistance = Shader.PropertyToID("_PushDistance");

		private static readonly int MossTransition = Shader.PropertyToID("_MossTransition");

		private static readonly int RippleDistance = Shader.PropertyToID("_RippleDistance");

		private static readonly int FadeDistanceMin = Shader.PropertyToID("_FadeDistanceMin");

		private static readonly int FadeDistanceMax = Shader.PropertyToID("_FadeDistanceMax");

		private static readonly int RippleDeadzoneMin = Shader.PropertyToID("_RippleDeadzoneMin");

		private static readonly int RippleDeadzoneMax = Shader.PropertyToID("_RippleDeadzoneMax");

		public static void ConfigureMaterial(Material material, Shader shader, JsonObject content, Dictionary<Type, int> typeDict, Dictionary<string, int> getMatItem)
		{
			material.shader = shader;
			foreach (KeyValuePair<string, object> item in content)
			{
				if (!(item.Key == "shader"))
				{
					SetMaterialConfigItems(typeDict, item, material, getMatItem);
				}
			}
		}

		private static void SetMaterialConfigItems(Dictionary<Type, int> typeDict, KeyValuePair<string, object> materialItem, Material material, Dictionary<string, int> getMatItem)
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			switch (typeDict[materialItem.Value.GetType()])
			{
			case 0:
				material.SetFloat(getMatItem[materialItem.Key], float.Parse(materialItem.Value.ToString()));
				break;
			case 1:
			{
				Color val = default(Color);
				ColorUtility.TryParseHtmlString(materialItem.Value.ToString(), ref val);
				material.SetColor(Color, val);
				break;
			}
			case 2:
				material.SetFloat(getMatItem[materialItem.Key], float.Parse(materialItem.Value.ToString()));
				break;
			}
		}

		public static Dictionary<Type, int> GetTypeDict()
		{
			return new Dictionary<Type, int>
			{
				{
					typeof(long),
					0
				},
				{
					typeof(string),
					1
				},
				{
					typeof(double),
					2
				}
			};
		}

		public static Dictionary<string, int> GetMatItem()
		{
			return new Dictionary<string, int>
			{
				{ "glossiness", Glossiness },
				{ "cutoff", Cutoff },
				{ "mossNormal", MossNormal },
				{ "mossTransition", MossTransition },
				{ "addSnow", AddSnow },
				{ "addRain", AddRain },
				{ "height", Height },
				{ "swaySpeed", SwaySpeed },
				{ "metallic", Metallic },
				{ "swayDistance", SwayDistance },
				{ "rippleSpeed", RippleSpeed },
				{ "rippleDistance", RippleDistance },
				{ "rippleDeadzoneMin", RippleDeadzoneMin },
				{ "rippleDeadzoneMax", RippleDeadzoneMax },
				{ "pushDistance", PushDistance },
				{ "camCull", CamCull },
				{ "cull", Cull },
				{ "color", Color },
				{ "fadeDistanceMin", FadeDistanceMin },
				{ "fadeDistanceMax", FadeDistanceMax }
			};
		}

		public static void ChangeItemDrop(CustomItem item, string configObject)
		{
			using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("BoneAppetitBalance.resources");
			if (stream != null)
			{
				JsonObject content = SimpleJson.DeserializeObject<JsonObject>(SimpleJson.DeserializeObject<JsonObject>(new StreamReader(stream).ReadToEnd())[configObject].ToString());
				SharedData shared = item.ItemDrop.m_itemData.m_shared;
				SetItemDropFromContent(content, shared);
			}
		}

		public static void LoadNewFood()
		{
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: 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_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Expected O, but got Unknown
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Expected O, but got Unknown
			using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("newFoodsConfig.resources");
			if (stream == null)
			{
				return;
			}
			foreach (KeyValuePair<string, object> item in SimpleJson.DeserializeObject<JsonObject>(new StreamReader(stream).ReadToEnd()))
			{
				string key = item.Key;
				JsonObject val = SimpleJson.DeserializeObject<JsonObject>(item.Value.ToString());
				RequirementConfig[] requirements = SimpleJson.DeserializeObject<RequirementConfig[]>(val["requirements"].ToString());
				CustomItem val2 = null;
				try
				{
					val2 = new CustomItem(Main.modAssets.LoadAsset<GameObject>(key), true, new ItemConfig
					{
						Name = val["name"].ToString(),
						Enabled = true,
						Amount = Convert.ToInt32(val["amount"].ToString()),
						CraftingStation = val["craftingStation"].ToString(),
						Requirements = requirements
					});
					ChangeFoodDrop(val2, key);
				}
				catch (Exception ex)
				{
					Logger.LogError((object)("Error while loading " + key + ": " + ex.Message));
				}
				finally
				{
					ItemManager.Instance.AddItem(val2);
				}
			}
			PrefabManager.OnVanillaPrefabsAvailable -= LoadNewFood;
		}

		public static void LoadBalancedFood()
		{
			using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("BoneAppetitBalance.resources");
			if (stream == null)
			{
				return;
			}
			foreach (KeyValuePair<string, object> item in SimpleJson.DeserializeObject<JsonObject>(new StreamReader(stream).ReadToEnd()))
			{
				string key = item.Key;
				JsonObject val = SimpleJson.DeserializeObject<JsonObject>(item.Value.ToString());
				RegisterFood(requirements: SimpleJson.DeserializeObject<RequirementConfig[]>(val["requirements"].ToString()), name: key, prefab: key, amount: Convert.ToInt32(val["amount"].ToString()), craftingStation: val["craftingStation"].ToString());
			}
			ItemManager.OnItemsRegisteredFejd -= LoadBalancedFood;
		}

		private static void ChangeFoodDrop(CustomItem item, string configObject)
		{
			using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("newFoodsConfig.resources");
			if (stream != null)
			{
				JsonObject content = SimpleJson.DeserializeObject<JsonObject>(SimpleJson.DeserializeObject<JsonObject>(new StreamReader(stream).ReadToEnd())[configObject].ToString());
				SharedData shared = item.ItemDrop.m_itemData.m_shared;
				SetItemDropFromContent(content, shared);
			}
		}

		private static void SetItemDropFromContent(JsonObject content, SharedData itemDrop)
		{
			if (content["name"] != null)
			{
				itemDrop.m_name = content["name"].ToString();
			}
			if (content["description"] != null)
			{
				itemDrop.m_description = content["description"].ToString();
			}
			if (content["weight"] != null)
			{
				itemDrop.m_weight = float.Parse(content["weight"].ToString());
			}
			if (content["maxStackSize"] != null)
			{
				itemDrop.m_maxStackSize = int.Parse(content["maxStackSize"].ToString());
			}
			if (content["variants"] != null)
			{
				itemDrop.m_variants = int.Parse(content["variants"].ToString());
			}
			if (content["food"] != null)
			{
				itemDrop.m_food = float.Parse(content["food"].ToString());
			}
			if (content["foodStamina"] != null)
			{
				itemDrop.m_foodStamina = float.Parse(content["foodStamina"].ToString());
			}
			if (content["foodBurnTime"] != null)
			{
				itemDrop.m_foodBurnTime = float.Parse(content["foodBurnTime"].ToString()) * 60f;
			}
			if (content["foodRegen"] != null)
			{
				itemDrop.m_foodRegen = float.Parse(content["foodRegen"].ToString());
			}
			if (content["consumeStatusEffect"] != null)
			{
				StatusEffect consumeStatusEffect = Main.modAssets.LoadAsset<StatusEffect>(content["consumeStatusEffect"].ToString());
				itemDrop.m_consumeStatusEffect = consumeStatusEffect;
			}
		}

		private static void RegisterFood(string name, string prefab, int amount, string craftingStation, RequirementConfig[] requirements)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected O, but got Unknown
			CustomItem item = ItemManager.Instance.GetItem(prefab);
			ItemManager.Instance.RemoveRecipe("Recipe_" + prefab);
			try
			{
				CustomRecipe val = new CustomRecipe(new RecipeConfig
				{
					Item = prefab,
					Amount = amount,
					CraftingStation = craftingStation,
					Requirements = requirements
				});
				ChangeItemDrop(item, prefab);
				ItemManager.Instance.AddRecipe(val);
			}
			catch (Exception ex)
			{
				Logger.LogError((object)("Error while loading " + name + ": " + ex.Message));
			}
		}

		public static string ReadEmbeddedFile(string embeddedName)
		{
			using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(embeddedName);
			if (stream == null)
			{
				return null;
			}
			return new StreamReader(stream).ReadToEnd();
		}

		public static void LoadEmbeddedAssembly(string assemblyName)
		{
			Stream manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(assemblyName);
			if (manifestResourceStream == null)
			{
				Logger.LogError((object)("Could not load embedded assembly: " + assemblyName));
				return;
			}
			using (manifestResourceStream)
			{
				byte[] array = new byte[manifestResourceStream.Length];
				manifestResourceStream.Read(array, 0, array.Length);
				Assembly.Load(array);
			}
		}
	}
	[BepInPlugin("com.frenvius.Valharvest", "Valharvest", "3.1.1")]
	[BepInDependency("com.jotunn.jotunn", "2.7.0")]
	[BepInDependency("com.rockerkitten.boneappetit", "3.0.2")]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public class Main : BaseUnityPlugin
	{
		public const string ModGuid = "com.frenvius.Valharvest";

		public const string ModName = "Valharvest";

		public const string Version = "3.1.1";

		public static AssetBundle modAssets;

		public static EffectList loxMilkSfx;

		public static EffectList boneMealVfx;

		public static Texture2D newEggTexture;

		public static Texture2D pizzaPlateTexture;

		public static Sprite newEggSprite;

		public static Sprite pizzaSprite;

		public static bool IsFarmingModInstalled;

		public static KeyboardShortcut MassPlantShortcut;

		public GameObject greydwarfFab;

		public GameObject trollFab;

		public GameObject goblinFab;

		public GameObject draugrFab;

		public GameObject greydwarfBruteFab;

		public GameObject draugrEliteFab;

		public GameObject seagullFab;

		private Harmony _h;

		public void Awake()
		{
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Expected O, but got Unknown
			CreateConfigValues();
			AssetLoad();
			Loaders.LoadItems();
			Loaders.LoadPieces();
			PrefabManager.OnVanillaPrefabsAvailable += Utils.LoadNewFood;
			PrefabManager.OnVanillaPrefabsAvailable += LoadSounds;
			PrefabManager.OnVanillaPrefabsAvailable += PlantUtils.AddCustomPlantsPrefab;
			ItemManager.OnItemsRegisteredFejd += Utils.LoadBalancedFood;
			ItemManager.OnItemsRegisteredFejd += LoadBalance;
			PrefabManager.OnVanillaPrefabsAvailable += Plants.AddCustomPlants;
			PrefabManager.OnVanillaPrefabsAvailable += CustomDrops;
			PrefabManager.OnVanillaPrefabsAvailable += CheckIfFarmingModInstalled;
			PrefabManager.OnVanillaPrefabsAvailable += HandlePrefabComponent.ZNetViewAwakePatch;
			PrefabManager.OnPrefabsRegistered += CustomFeed;
			PrefabManager.OnPrefabsRegistered += ConsumableItemExtractor.GenerateConsumableItemList;
			if (Valharvest.Configurations.Valharvest.DropEnabled.Value)
			{
				PrefabManager.OnVanillaPrefabsAvailable += NewDrops;
			}
			_h = new Harmony("mod.valharvest");
			_h.PatchAll();
		}

		private void OnDestroy()
		{
			Logger.LogInfo((object)"Valharvest: OnDestroy");
			_h.UnpatchSelf();
		}

		private static void CheckIfFarmingModInstalled()
		{
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			Chainloader.Start();
			using (IEnumerator<KeyValuePair<string, PluginInfo>> enumerator = Chainloader.PluginInfos.Where((KeyValuePair<string, PluginInfo> plugin) => plugin.Value.Metadata.GUID == "org.bepinex.plugins.farming").GetEnumerator())
			{
				if (enumerator.MoveNext())
				{
					_ = enumerator.Current;
					IsFarmingModInstalled = true;
				}
			}
			if (IsFarmingModInstalled)
			{
				ConfigFile config = Chainloader.PluginInfos["org.bepinex.plugins.farming"].Instance.Config;
				foreach (ConfigDefinition key in config.Keys)
				{
					if (((object)key).ToString().Contains("Toggle Mass Plant"))
					{
						ConfigEntryBase val = config[key];
						KeyCode val2 = (KeyCode)Enum.Parse(typeof(KeyCode), val.BoxedValue.ToString());
						MassPlantShortcut = new KeyboardShortcut(val2, Array.Empty<KeyCode>());
					}
				}
			}
			PrefabManager.OnVanillaPrefabsAvailable -= CheckIfFarmingModInstalled;
		}

		public void CreateConfigValues()
		{
			((BaseUnityPlugin)this).Config.SaveOnConfigSet = true;
			new Valharvest.Configurations.Valharvest(((BaseUnityPlugin)this).Config);
		}

		public void LoadBalance()
		{
			try
			{
				BoneAppetitBalance.SeagullEgg();
				BoneAppetitBalance.Kabob();
				BoneAppetitBalance.Pizza();
			}
			catch (Exception ex)
			{
				Logger.LogError((object)("Error while running OnItemsRegistered: " + ex.Message));
			}
			finally
			{
				Logger.LogInfo((object)"Load Complete.");
				ItemManager.OnItemsRegistered -= LoadBalance;
			}
		}

		public void AssetLoad()
		{
			modAssets = AssetUtils.LoadAssetBundleFromResources("valharvest", Assembly.GetExecutingAssembly());
			newEggTexture = modAssets.LoadAsset<Texture2D>("egg");
			newEggSprite = modAssets.LoadAsset<Sprite>("eggsprite");
			pizzaPlateTexture = modAssets.LoadAsset<Texture2D>("pizza_plate");
			pizzaSprite = modAssets.LoadAsset<Sprite>("pizzaSprite");
			Logger.LogInfo((object)"Preparing the plants...");
		}

		public void LoadSounds()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Expected O, but got Unknown
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Expected O, but got Unknown
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Expected O, but got Unknown
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Expected O, but got Unknown
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Expected O, but got Unknown
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Expected O, but got Unknown
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: 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_00f0: Expected O, but got Unknown
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: 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_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Expected O, but got Unknown
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Expected O, but got Unknown
			GameObject val = modAssets.LoadAsset<GameObject>("sfx_pours_milk");
			PrefabManager.Instance.AddPrefab(new CustomPrefab(val, true));
			GameObject val2 = modAssets.LoadAsset<GameObject>("sfx_lox_pet_milk");
			PrefabManager.Instance.AddPrefab(new CustomPrefab(val2, true));
			GameObject val3 = modAssets.LoadAsset<GameObject>("sfx_lox_pet");
			PrefabManager.Instance.AddPrefab(new CustomPrefab(val3, true));
			GameObject val4 = modAssets.LoadAsset<GameObject>("vfx_bone_meal");
			PrefabManager.Instance.AddPrefab(new CustomPrefab(val4, true));
			EffectList val5 = new EffectList();
			val5.m_effectPrefabs = (EffectData[])(object)new EffectData[2]
			{
				new EffectData
				{
					m_prefab = val2,
					m_enabled = true
				},
				new EffectData
				{
					m_prefab = val,
					m_enabled = true
				}
			};
			loxMilkSfx = val5;
			val5 = new EffectList();
			val5.m_effectPrefabs = (EffectData[])(object)new EffectData[1]
			{
				new EffectData
				{
					m_prefab = val4,
					m_enabled = true
				}
			};
			boneMealVfx = val5;
			PrefabManager.OnVanillaPrefabsAvailable -= LoadSounds;
			CookingConversionConfig val6 = new CookingConversionConfig
			{
				FromItem = "apple",
				ToItem = "baked_apple",
				CookTime = 5f,
				Station = "piece_cookingstation"
			};
			ItemManager.Instance.AddItemConversion(new CustomItemConversion((ConversionConfig)(object)val6));
		}

		public void NewDrops()
		{
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Expected O, but got Unknown
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Expected O, but got Unknown
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: 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_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Expected O, but got Unknown
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: 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_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Expected O, but got Unknown
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Expected O, but got Unknown
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: 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_0292: Expected O, but got Unknown
			greydwarfFab = PrefabManager.Instance.GetPrefab("Greydwarf");
			trollFab = PrefabManager.Instance.GetPrefab("Troll");
			goblinFab = PrefabManager.Instance.GetPrefab("Goblin");
			draugrFab = PrefabManager.Instance.GetPrefab("Draugr");
			greydwarfBruteFab = PrefabManager.Instance.GetPrefab("Greydwarf_Elite");
			draugrEliteFab = PrefabManager.Instance.GetPrefab("Draugr_Elite");
			GameObject prefab = PrefabManager.Instance.GetPrefab("pepper");
			GameObject prefab2 = PrefabManager.Instance.GetPrefab("tomato");
			GameObject prefab3 = PrefabManager.Instance.GetPrefab("garlic");
			GameObject prefab4 = PrefabManager.Instance.GetPrefab("rice");
			GameObject prefab5 = PrefabManager.Instance.GetPrefab("potato");
			GameObject prefab6 = PrefabManager.Instance.GetPrefab("pumpkin");
			greydwarfFab.GetComponent<CharacterDrop>().m_drops.Add(new Drop
			{
				m_prefab = prefab,
				m_amountMin = 1,
				m_amountMax = 2,
				m_chance = 0.4f,
				m_levelMultiplier = true,
				m_onePerPlayer = false
			});
			trollFab.GetComponent<CharacterDrop>().m_drops.Add(new Drop
			{
				m_prefab = prefab3,
				m_amountMin = 1,
				m_amountMax = 3,
				m_chance = 0.4f,
				m_levelMultiplier = true,
				m_onePerPlayer = false
			});
			goblinFab.GetComponent<CharacterDrop>().m_drops.Add(new Drop
			{
				m_prefab = prefab4,
				m_amountMin = 1,
				m_amountMax = 1,
				m_chance = 0.4f,
				m_levelMultiplier = true,
				m_onePerPlayer = false
			});
			draugrFab.GetComponent<CharacterDrop>().m_drops.Add(new Drop
			{
				m_prefab = prefab2,
				m_amountMin = 1,
				m_amountMax = 1,
				m_chance = 0.4f,
				m_levelMultiplier = true,
				m_onePerPlayer = false
			});
			greydwarfBruteFab.GetComponent<CharacterDrop>().m_drops.Add(new Drop
			{
				m_prefab = prefab5,
				m_amountMin = 1,
				m_amountMax = 1,
				m_chance = 0.4f,
				m_levelMultiplier = true,
				m_onePerPlayer = false
			});
			draugrEliteFab.GetComponent<CharacterDrop>().m_drops.Add(new Drop
			{
				m_prefab = prefab6,
				m_amountMin = 1,
				m_amountMax = 1,
				m_chance = 0.4f,
				m_levelMultiplier = true,
				m_onePerPlayer = false
			});
			PrefabManager.OnVanillaPrefabsAvailable -= NewDrops;
		}

		public void CustomDrops()
		{
			PrefabManager.OnVanillaPrefabsAvailable -= CustomDrops;
		}

		public void AddConsumableItemsToCreature(string[] items, string creature)
		{
			MonsterAI component = PrefabManager.Instance.GetPrefab(creature).GetComponent<MonsterAI>();
			foreach (string text in items)
			{
				GameObject prefab = PrefabManager.Instance.GetPrefab(text);
				component.m_consumeItems.Add(prefab.GetComponent<ItemDrop>());
			}
		}

		public void CustomFeed()
		{
			string[] items = new string[3] { "apple", "tomato", "potato" };
			AddConsumableItemsToCreature(items, "Boar");
			string[] items2 = new string[1] { "rk_pork" };
			AddConsumableItemsToCreature(items2, "Wolf");
			PrefabManager.OnVanillaPrefabsAvailable -= CustomFeed;
		}
	}
}
namespace Valharvest.WorldGen
{
	public static class Plants
	{
		private const string Min = "min";

		private const string Max = "max";

		private const string Biome = "biome";

		private const string InForest = "inForest";

		private const string BiomeArea = "biomeArea";

		private const string GroupRadius = "groupRadius";

		private const string GroupSizeMin = "groupSizeMin";

		private const string GroupSizeMax = "groupSizeMax";

		private const string MinAltitude = "minAltitude";

		private const string MaxAltitude = "maxAltitude";

		private const string ForestThresholdMin = "forestThresholdMin";

		private const string ForestThresholdMax = "forestThresholdMax";

		private const Biome Swamp = 2;

		private const Biome Plains = 16;

		private const Biome Meadows = 1;

		private const Biome Mountain = 4;

		private const Biome Mistlands = 512;

		private const Biome BlackForest = 8;

		private const BiomeArea Edge = 1;

		private const BiomeArea Median = 2;

		private const BiomeArea Everything = 3;

		public static void AddCustomPlants()
		{
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Expected O, but got Unknown
			string text = Utils.ReadEmbeddedFile("plantsLocations.resources");
			if (text == null)
			{
				return;
			}
			foreach (KeyValuePair<string, object> item in SimpleJson.DeserializeObject<JsonObject>(text))
			{
				GameObject val = PrefabManager.Instance.CreateClonedPrefab(item.Key + "_wild", item.Key);
				JsonObject content = SimpleJson.DeserializeObject<JsonObject>(item.Value.ToString());
				try
				{
					ZoneManager.Instance.AddCustomVegetation(new CustomVegetation(val, true, GetVegetationConfig(content)));
				}
				catch (Exception ex)
				{
					Logger.LogError((object)("Error while loading " + item.Key + ": " + ex.Message));
				}
				finally
				{
					PrefabManager.OnVanillaPrefabsAvailable -= AddCustomPlants;
				}
			}
		}

		private static VegetationConfig GetVegetationConfig(JsonObject content)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			VegetationConfig val = new VegetationConfig();
			Dictionary<string, Biome> biome = GetBiome();
			Dictionary<string, BiomeArea> biomeArea = GetBiomeArea();
			if (content["min"] != null)
			{
				val.Min = float.Parse(content["min"].ToString());
			}
			if (content["max"] != null)
			{
				val.Max = float.Parse(content["max"].ToString());
			}
			if (content["groupSizeMin"] != null)
			{
				val.GroupSizeMin = int.Parse(content["groupSizeMin"].ToString());
			}
			if (content["groupSizeMax"] != null)
			{
				val.GroupSizeMax = int.Parse(content["groupSizeMax"].ToString());
			}
			if (content["groupRadius"] != null)
			{
				val.GroupRadius = float.Parse(content["groupRadius"].ToString());
			}
			if (content["minAltitude"] != null)
			{
				val.MinAltitude = float.Parse(content["minAltitude"].ToString());
			}
			if (content["maxAltitude"] != null)
			{
				val.MaxAltitude = float.Parse(content["maxAltitude"].ToString());
			}
			if (content["biome"] != null)
			{
				val.Biome = biome[content["biome"].ToString()];
			}
			if (content["biomeArea"] != null)
			{
				val.BiomeArea = biomeArea[content["biomeArea"].ToString()];
			}
			if (content["inForest"] != null)
			{
				val.InForest = Convert.ToBoolean(content["inForest"].ToString());
			}
			if (content["forestThresholdMin"] != null)
			{
				val.ForestThresholdMin = float.Parse(content["forestThresholdMin"].ToString());
			}
			if (content["forestThresholdMax"] != null)
			{
				val.ForestThresholdMax = float.Parse(content["forestThresholdMax"].ToString());
			}
			return val;
		}

		private static Dictionary<string, Biome> GetBiome()
		{
			return new Dictionary<string, Biome>
			{
				{
					"swamp",
					(Biome)2
				},
				{
					"plains",
					(Biome)16
				},
				{
					"meadows",
					(Biome)1
				},
				{
					"mountain",
					(Biome)4
				},
				{
					"mistlands",
					(Biome)512
				},
				{
					"black_forest",
					(Biome)8
				}
			};
		}

		private static Dictionary<string, BiomeArea> GetBiomeArea()
		{
			return new Dictionary<string, BiomeArea>
			{
				{
					"edge",
					(BiomeArea)1
				},
				{
					"median",
					(BiomeArea)2
				},
				{
					"everything",
					(BiomeArea)3
				}
			};
		}
	}
	public static class PlantUtils
	{
		public static void AddCustomPlantsPrefab()
		{
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Expected O, but got Unknown
			string text = Utils.ReadEmbeddedFile("plants.resources");
			if (text == null)
			{
				return;
			}
			foreach (KeyValuePair<string, object> item in SimpleJson.DeserializeObject<JsonObject>(text))
			{
				Dictionary<string, AssetBundle> assetBundle = Loaders.GetAssetBundle();
				JsonObject val = SimpleJson.DeserializeObject<JsonObject>(item.Value.ToString());
				string key = val["assetBundle"].ToString();
				object obj = val["dropConfig"];
				object obj2 = val["respawnConfig"];
				Dictionary<string, ConfigEntry<int>> dropConfigs = Valharvest.Configurations.Valharvest.GetDropConfigs();
				Dictionary<string, ConfigEntry<int>> respawnTimeConfigs = Valharvest.Configurations.Valharvest.GetRespawnTimeConfigs();
				GameObject val2 = assetBundle[key].LoadAsset<GameObject>(item.Key);
				LoadPlantMaterials(val2, val);
				try
				{
					if (obj != null)
					{
						ConfigEntry<int> val3 = dropConfigs[obj.ToString()];
						val2.GetComponent<Pickable>().m_amount = val3.Value;
					}
					if (obj2 != null)
					{
						ConfigEntry<int> val4 = respawnTimeConfigs[obj2.ToString()];
						val2.GetComponent<Pickable>().m_respawnTimeMinutes = val4.Value * 60;
					}
					if (val["crafting"] != null)
					{
						CustomPiece val5 = Loaders.CreatePieceRecipe(val2, val);
						PieceManager.Instance.AddPiece(val5);
					}
					else
					{
						PrefabManager.Instance.AddPrefab(new CustomPrefab(val2, true));
					}
				}
				catch (Exception ex)
				{
					Logger.LogError((object)("Error while loading " + item.Key + ": " + ex.Message));
				}
				finally
				{
					PrefabManager.OnVanillaPrefabsAvailable -= AddCustomPlantsPrefab;
				}
			}
		}

		private static void LoadPlantMaterials(GameObject plantPrefab, JsonObject plantObject)
		{
			JsonObject val = SimpleJson.DeserializeObject<JsonObject>(plantObject["materials"].ToString());
			foreach (Renderer renderer in ShaderHelper.GetRenderers(plantPrefab))
			{
				Material[] materials = renderer.materials;
				foreach (Material val2 in materials)
				{
					string name = ((Object)val2).name;
					string text = name.Substring(0, name.Length - " (Instance)".Length);
					if (val.ContainsKey(text) && !string.IsNullOrEmpty(val[text].ToString()))
					{
						Dictionary<Type, int> typeDict = Utils.GetTypeDict();
						Dictionary<string, int> matItem = Utils.GetMatItem();
						JsonObject val3 = SimpleJson.DeserializeObject<JsonObject>(val[text].ToString());
						Shader prefab = Cache.GetPrefab<Shader>(val3["shader"].ToString());
						Texture mainTexture = val2.mainTexture;
						Utils.ConfigureMaterial(val2, prefab, val3, typeDict, matItem);
						val2.SetTexture(Utils.MainTex, mainTexture);
					}
				}
			}
		}
	}
}
namespace Valharvest.Scripts
{
	[HarmonyPatch]
	public static class HandlePrefabComponent
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(MonsterAI), "Awake")]
		public static void MonsterAIAwakePatch(MonsterAI __instance)
		{
			if (((Object)((Component)__instance).gameObject).name.Contains("Lox"))
			{
				((Component)__instance).gameObject.AddComponent<MilkLox>();
			}
		}

		public static void ZNetViewAwakePatch()
		{
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Expected O, but got Unknown
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Expected O, but got Unknown
			GameObject prefab = PrefabManager.Instance.GetPrefab("water_well");
			if (!Object.op_Implicit((Object)(object)prefab))
			{
				return;
			}
			Transform val = prefab.gameObject.transform.Find("water");
			Transform val2 = prefab.gameObject.transform.Find("spawnpoint");
			if ((Object)(object)val != (Object)null && (Object)(object)val2 != (Object)null)
			{
				CustomBeehive customBeehive = prefab.gameObject.AddComponent<CustomBeehive>();
				customBeehive.m_hideWhenPicked = ((Component)val).gameObject;
				customBeehive.m_spawnPoint = val2;
				customBeehive.m_honeyItem = PrefabManager.Instance.GetPrefab("water_bucket").GetComponent<ItemDrop>();
				EffectList val3 = new EffectList();
				if (val3.m_effectPrefabs.Length == 0)
				{
					val3.m_effectPrefabs = (EffectData[])(object)new EffectData[1];
				}
				val3.m_effectPrefabs[0] = new EffectData
				{
					m_prefab = PrefabManager.Instance.GetPrefab("sfx_ship_waterimpact"),
					m_enabled = true
				};
				customBeehive.m_spawnEffect = val3;
			}
		}
	}
	public static class BoneAppetitBalance
	{
		public static void SeagullEgg()
		{
			try
			{
				foreach (Material item in from rend in ShaderHelper.GetRenderers(PrefabManager.Instance.GetPrefab("rk_egg"))
					from mat in rend.materials
					where mat.HasProperty("_MainTex")
					select mat)
				{
					item.SetTexture(Utils.MainTex, (Texture)(object)Main.newEggTexture);
				}
				ItemDrop itemDrop = ItemManager.Instance.GetItem("rk_egg").ItemDrop;
				itemDrop.m_itemData.m_shared.m_description = "A small egg.";
				itemDrop.m_itemData.m_shared.m_icons[0] = Main.newEggSprite;
			}
			catch (Exception ex)
			{
				Logger.LogError((object)("Error while loading SeagullEgg: " + ex.Message));
			}
			finally
			{
				Logger.LogInfo((object)"SeagullEgg Loaded.");
			}
		}

		public static void Kabob()
		{
			CustomItem item = ItemManager.Instance.GetItem("rk_kabob");
			if (Valharvest.Configurations.Valharvest.KabobName.Value)
			{
				item.ItemDrop.m_itemData.m_shared.m_name = "Kebab";
			}
		}

		public static void Pizza()
		{
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			CustomItem item = ItemManager.Instance.GetItem("rk_pizza");
			Color val = default(Color);
			Color val2 = default(Color);
			foreach (Renderer renderer in ShaderHelper.GetRenderers(PrefabManager.Instance.GetPrefab("rk_pizza")))
			{
				string name = ((Object)renderer).name;
				if (!(name == "pizza"))
				{
					if (name == "Tarelka001")
					{
						Material[] materials = renderer.materials;
						foreach (Material obj in materials)
						{
							ColorUtility.TryParseHtmlString("#855B41", ref val);
							obj.SetTexture(Utils.MainTex, (Texture)(object)Main.pizzaPlateTexture);
							obj.SetColor(Utils.Color, val);
						}
					}
				}
				else
				{
					Material[] materials = renderer.materials;
					foreach (Material obj2 in materials)
					{
						ColorUtility.TryParseHtmlString("#FFFFFF", ref val2);
						obj2.SetColor(Utils.Color, val2);
					}
				}
			}
			item.ItemDrop.m_itemData.m_shared.m_icons[0] = Main.pizzaSprite;
		}
	}
	public static class ConsumableItemExtractor
	{
		[Serializable]
		private class ItemData
		{
			public string Name;

			public string Description;
		}

		public static void GenerateConsumableItemList()
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Expected O, but got Unknown
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Expected I4, but got Unknown
			Logger.LogInfo((object)"Extracting consumable items...");
			if (!Object.op_Implicit((Object)(object)ObjectDB.instance))
			{
				return;
			}
			List<ItemDrop> allItems = ObjectDB.instance.GetAllItems((ItemType)1, "");
			List<ItemDrop> allItems2 = ObjectDB.instance.GetAllItems((ItemType)2, "");
			JsonArray val = new JsonArray();
			allItems.AddRange(allItems2);
			Logger.LogInfo((object)("Found " + allItems.Count + " items."));
			foreach (ItemDrop item in allItems)
			{
				JsonObject val2 = new JsonObject();
				val2.Add("var_name", (object)item.m_itemData.m_shared.m_name);
				val2.Add("raw_name", (object)Localization.instance.Localize(item.m_itemData.m_shared.m_name));
				val2.Add("true_name", (object)((Object)((Component)item).gameObject).name);
				JsonObject val3 = new JsonObject();
				Sprite[] icons = item.m_itemData.m_shared.m_icons;
				foreach (Sprite val4 in icons)
				{
					val3.Add("raw_name", (object)((Object)val4).name);
					val3.Add("var_name", (object)item.m_itemData.m_shared.m_name);
					val3.Add("item_type_name", (object)((object)(ItemType)(ref item.m_itemData.m_shared.m_itemType)).ToString());
					val3.Add("item_type", (object)(int)item.m_itemData.m_shared.m_itemType);
					val3.Add("description", (object)Localization.instance.Localize(item.m_itemData.m_shared.m_description));
					val3.Add("prefab_name", (object)((Object)((Component)item).gameObject).name);
					val3.Add("food", (object)item.m_itemData.m_shared.m_food.ToString());
					val3.Add("food_burn_time", (object)item.m_itemData.m_shared.m_foodBurnTime.ToString());
					val3.Add("food_regen", (object)item.m_itemData.m_shared.m_foodRegen.ToString());
					val3.Add("food_stamina", (object)item.m_itemData.m_shared.m_foodStamina.ToString());
					val3.Add("weight", (object)item.m_itemData.m_shared.m_weight.ToString());
				}
				val2.Add("shared_data", (object)val3);
				((List<object>)(object)val).Add((object)val2);
			}
			File.WriteAllText("itemdrops.json", ((object)val).ToString());
			Logger.LogInfo((object)"Finished extracting consumable items.");
		}

		private static bool IsConsumable(ItemDrop item)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Invalid comparison between Unknown and I4
			return (int)item.m_itemData.m_shared.m_itemType == 2;
		}
	}
	public class CultivatedGround : Heightmap
	{
		private void Awake()
		{
		}

		private void Update()
		{
		}

		private void OnEnable()
		{
			Regenerate();
		}

		private void Regenerate()
		{
			Generate();
		}

		private void Generate()
		{
			Initialize();
		}

		public void Initialize()
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Expected O, but got Unknown
			int num = base.m_width + 1;
			int num2 = num * num;
			if (base.m_heights.Count != num2)
			{
				base.m_heights.Clear();
				for (int i = 0; i < num2; i++)
				{
					base.m_heights.Add(0f);
				}
				base.m_paintMask = new Texture2D(base.m_width, base.m_width)
				{
					wrapMode = (TextureWrapMode)1
				};
			}
		}
	}
	[HarmonyPatch]
	public class EggAndFeatherDrop
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(TreeBase), "SpawnLog")]
		public static void TreeBaseSpawnLog_Patch(TreeBase __instance)
		{
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: 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)
			string name = ((Object)__instance.m_logPrefab).name;
			if (((IList)new string[6] { "PineTree_log", "PineTree_logOLD", "FirTree_log", "beech_log", "Birch_log", "Oak_log" }).Contains((object?)name) && Random.value < 0.15f)
			{
				GameObject prefab = ZNetScene.instance.GetPrefab("Feathers");
				GameObject prefab2 = ZNetScene.instance.GetPrefab("rk_egg");
				int num = Random.Range(1, 8);
				int num2 = Random.Range(1, 3);
				for (int i = 0; i < num; i++)
				{
					Object.Instantiate<GameObject>(prefab, ((Component)__instance).transform.position, Quaternion.identity);
				}
				for (int j = 0; j < num2; j++)
				{
					Object.Instantiate<GameObject>(prefab2, ((Component)__instance).transform.position, Quaternion.identity);
				}
			}
		}
	}
	public class FixPlantHealth : SlowUpdate
	{
		public override void SUpdate()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			Plant component = ((Component)this).GetComponent<Plant>();
			Vector3 position = ((Component)this).transform.position;
			if (component.m_nview.IsValid() && !((double)Time.time - (double)component.m_updateTime < 10.0) && RaisedBed.CheckIfItemBellowIsCultivatedGround(position))
			{
				component.m_biome = (Biome)895;
				component.m_growRadius = 0.4f;
			}
		}
	}
	public class InteractFertilizer : MonoBehaviour, Interactable
	{
		private ZNetView _nview;

		private void Awake()
		{
			_nview = ((Component)this).gameObject.GetComponent<ZNetView>();
		}

		public bool Interact(Humanoid user, bool hold, bool alt)
		{
			return false;
		}

		public bool UseItem(Humanoid user, ItemData item)
		{
			Inventory inventory = ((Humanoid)Player.m_localPlayer).GetInventory();
			Plant component = ((Component)this).gameObject.GetComponent<Plant>();
			if (!SetPlantTime(component, item))
			{
				return false;
			}
			inventory.RemoveOneItem(item);
			GrowPlant(component);
			return true;
		}

		private bool SetPlantTime(Plant plant, ItemData item)
		{
			bool num = ((Object)item.m_dropPrefab).name == "bonemeal";
			bool flag = ((Object)item.m_dropPrefab).name == "water_bucket";
			double num2 = plant.m_growTime;
			int num3 = (num ? 5 : 2);
			if (!num && !flag)
			{
				return false;
			}
			long @long = _nview.GetZDO().GetLong("plantTime", ZNet.instance.GetTime().Ticks);
			long num4 = (long)(num2 * 10000000.0 / (double)num3);
			long num5 = @long - num4;
			if (num5 < 0)
			{
				num5 = 0L;
			}
			_nview.GetZDO().Set("plantTime", num5);
			SendPlantEffect(plant);
			return true;
		}

		private static void SendPlantEffect(Plant plant)
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			float num = Random.Range((float)((double)plant.m_minScale * 0.5), (float)((double)plant.m_maxScale * 0.5));
			Quaternion val = Quaternion.Euler(0f, Random.Range(0f, 360f), 0f);
			Main.boneMealVfx.Create(((Component)plant).transform.position, val, (Transform)null, num, -1);
		}

		public void GrowPlant(Plant plant)
		{
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Invalid comparison between Unknown and I4
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Invalid comparison between Unknown and I4
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Invalid comparison between Unknown and I4
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Invalid comparison between Unknown and I4
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Invalid comparison between Unknown and I4
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Invalid comparison between Unknown and I4
			if (plant.m_nview.IsValid())
			{
				plant.m_updateTime = Time.time;
				double num = plant.TimeSincePlanted();
				float growTime = plant.GetGrowTime();
				if (Object.op_Implicit((Object)(object)plant.m_healthyGrown))
				{
					bool flag = num > (double)growTime * 0.5;
					plant.m_healthy.SetActive(!flag && (int)plant.m_status == 0);
					plant.m_unhealthy.SetActive(!flag && (int)plant.m_status > 0);
					plant.m_healthyGrown.SetActive(flag && (int)plant.m_status == 0);
					plant.m_unhealthyGrown.SetActive(flag && (int)plant.m_status > 0);
				}
				else
				{
					plant.m_healthy.SetActive((int)plant.m_status == 0);
					plant.m_unhealthy.SetActive((int)plant.m_status > 0);
				}
				if (plant.m_nview.IsOwner() && !(num <= (double)growTime))
				{
					plant.Grow();
				}
			}
		}
	}
	public static class Loaders
	{
		public static void LoadItems()
		{
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			string text = Utils.ReadEmbeddedFile("items.resources");
			if (text == null)
			{
				return;
			}
			foreach (KeyValuePair<string, object> item in SimpleJson.DeserializeObject<JsonObject>(text))
			{
				Dictionary<string, AssetBundle> assetBundle = GetAssetBundle();
				JsonObject val = SimpleJson.DeserializeObject<JsonObject>(item.Value.ToString());
				GameObject val2 = assetBundle[val["assetBundle"].ToString()].LoadAsset<GameObject>(item.Key);
				try
				{
					CustomItem val3 = (CustomItem)((val["crafting"] != null) ? ((object)CreateItemRecipe(val2, val)) : ((object)new CustomItem(val2, true)));
					SharedData shared = val3.ItemDrop.m_itemData.m_shared;
					SetItemDrop(val, shared);
					ItemManager.Instance.AddItem(val3);
				}
				catch (Exception ex)
				{
					Logger.LogError((object)("Error while loading " + item.Key + ": " + ex.Message));
				}
			}
		}

		public static void LoadPieces()
		{
			string text = Utils.ReadEmbeddedFile("pieces.resources");
			if (text == null)
			{
				return;
			}
			foreach (KeyValuePair<string, object> item in SimpleJson.DeserializeObject<JsonObject>(text))
			{
				string key = item.Key;
				if ((!(key == "piece_cooking_pot") && !(key == "piece_prep_table")) || 1 == 0)
				{
					Dictionary<string, AssetBundle> assetBundle = GetAssetBundle();
					JsonObject val = SimpleJson.DeserializeObject<JsonObject>(item.Value.ToString());
					GameObject piecePrefab = assetBundle[val["assetBundle"].ToString()].LoadAsset<GameObject>(item.Key);
					try
					{
						CustomPiece val2 = CreatePieceRecipe(piecePrefab, val);
						Piece piece = val2.Piece;
						SetPieceInfo(val, piece);
						PieceManager.Instance.AddPiece(val2);
					}
					catch (Exception ex)
					{
						Logger.LogError((object)("Error while loading " + item.Key + ": " + ex.Message));
					}
				}
			}
			Logger.LogInfo((object)"Loaded pieces");
		}

		public static Dictionary<string, AssetBundle> GetAssetBundle()
		{
			return new Dictionary<string, AssetBundle> { 
			{
				"valharvest",
				Main.modAssets
			} };
		}

		public static void SetItemDrop(JsonObject content, SharedData itemDrop)
		{
			if (content["name"] != null)
			{
				itemDrop.m_name = content["name"].ToString();
			}
			if (content["description"] != null)
			{
				itemDrop.m_description = content["description"].ToString();
			}
		}

		public static void SetPieceInfo(JsonObject content, Piece piece)
		{
			if (content["name"] != null)
			{
				piece.m_name = content["name"].ToString();
			}
			if (content["description"] != null)
			{
				piece.m_description = content["description"].ToString();
			}
		}

		public static CustomItem CreateItemRecipe(GameObject itemPrefab, JsonObject itemObject)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Expected O, but got Unknown
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Expected O, but got Unknown
			JsonObject val = SimpleJson.DeserializeObject<JsonObject>(itemObject["crafting"].ToString());
			RequirementConfig[] requirements = SimpleJson.DeserializeObject<RequirementConfig[]>(val["requirements"].ToString());
			return new CustomItem(itemPrefab, true, new ItemConfig
			{
				Name = itemObject["name"].ToString(),
				Enabled = true,
				Amount = Convert.ToInt32(val["amount"].ToString()),
				CraftingStation = val["craftingStation"].ToString(),
				Requirements = requirements
			});
		}

		public static CustomPiece CreatePieceRecipe(GameObject piecePrefab, JsonObject pieceObject)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: 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)
			//IL_00a5: Expected O, but got Unknown
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Expected O, but got Unknown
			JsonObject val = SimpleJson.DeserializeObject<JsonObject>(pieceObject["crafting"].ToString());
			RequirementConfig[] requirements = SimpleJson.DeserializeObject<RequirementConfig[]>(val["requirements"].ToString());
			return new CustomPiece(piecePrefab, true, new PieceConfig
			{
				Name = pieceObject["name"].ToString(),
				Enabled = true,
				AllowedInDungeons = (bool)val["allowedInDungeons"],
				PieceTable = val["pieceTable"].ToString(),
				CraftingStation = val["craftingStation"]?.ToString(),
				Requirements = requirements
			});
		}
	}
	[HarmonyPatch(typeof(Tameable), "Interact")]
	public static class InteractPatch
	{
		public static bool Prefix(Tameable __instance, ref bool __runOriginal)
		{
			if (!((((Object)((Component)__instance).gameObject).name == "Lox(Clone)") | ((Object)((Component)__instance).gameObject).name.Contains("Lox")))
			{
				return __runOriginal = true;
			}
			if (!Input.GetKey((KeyCode)308))
			{
				return __runOriginal = true;
			}
			__runOriginal = false;
			if (!__instance.m_nview.IsValid())
			{
				return false;
			}
			MilkLox component = ((Component)__instance).gameObject.GetComponent<MilkLox>();
			if (component.GetMilkLevel() <= 0)
			{
				return __runOriginal = true;
			}
			CheckAbleToAddItem(component, component.loxPoint);
			return true;
		}

		private static void CheckAbleToAddItem(MilkLox loxComponent, Transform loxPoint)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			Inventory inventory = ((Humanoid)Player.m_localPlayer).m_inventory;
			int milkLevel = loxComponent.GetMilkLevel();
			if (milkLevel <= 0)
			{
				return;
			}
			if (inventory.HaveEmptySlot())
			{
				if (GetItemOnInventory("$empty_bottle_name") != null)
				{
					loxComponent.SpawnEffect.Create(loxPoint.position, Quaternion.identity, (Transform)null, 1f, -1);
					AddItemToPlayer(loxComponent, milkLevel);
				}
				else
				{
					((Character)Player.m_localPlayer).Message((MessageType)2, "$piece_itemstand_missingitem", 0, (Sprite)null);
				}
			}
			else
			{
				((Character)Player.m_localPlayer).Message((MessageType)2, "$msg_noroom", 0, (Sprite)null);
			}
		}

		public static ItemData GetItemOnInventory(string name)
		{
			return ((IEnumerable<ItemData>)((Humanoid)Player.m_localPlayer).m_inventory.m_inventory).FirstOrDefault((Func<ItemData, bool>)((ItemData item) => item.m_shared.m_name == name));
		}

		private static void AddItemToPlayer(MilkLox loxComponent, int milkLevel)
		{
			Inventory inventory = ((Humanoid)Player.m_localPlayer).m_inventory;
			ItemData itemOnInventory = GetItemOnInventory("$empty_bottle_name");
			int num = 0;
			for (int i = 0; i < milkLevel; i++)
			{
				if (inventory.HaveEmptySlot())
				{
					if (itemOnInventory == null)
					{
						((Character)Player.m_localPlayer).Message((MessageType)2, "$piece_itemstand_missingitem", 0, (Sprite)null);
						break;
					}
					if (inventory.RemoveOneItem(itemOnInventory))
					{
						loxComponent.nview.InvokeRPC("ExtractMilk", Array.Empty<object>());
						num++;
					}
				}
				else
				{
					((Character)Player.m_localPlayer).Message((MessageType)2, "$msg_noroom", 0, (Sprite)null);
				}
			}
			loxComponent.nview.InvokeRPC("ResetLevel", new object[1] { num });
		}
	}
	[HarmonyPatch(typeof(Tameable), "GetHoverText")]
	public static class HoverTextPatch
	{
		public static void Postfix(ref string __result, Tameable __instance)
		{
			if (((Character)((Component)__instance).gameObject.GetComponent<Humanoid>()).IsTamed() && ((((Object)((Component)__instance).gameObject).name == "Lox(Clone)") | ((Object)((Component)__instance).gameObject).name.Contains("Lox")))
			{
				int milkLevel = ((Component)__instance).gameObject.GetComponent<MilkLox>().GetMilkLevel();
				if (milkLevel > 0)
				{
					__result += Localization.instance.Localize("\n\nLox Milk ( $milk_bottle_name x " + milkLevel + " )\n[<b><color=yellow>L-Alt + $KEY_Use</color></b>] $lox_milk_extract");
				}
				else
				{
					__result += Localization.instance.Localize("\n\nLox Milk ( $piece_container_empty )");
				}
			}
		}
	}
	public class MilkLox : MonoBehaviour
	{
		private const int MaxMilk = 3;

		private const float SecPerUnit = 800f;

		public Transform loxPoint;

		[FormerlySerializedAs("_nview")]
		public ZNetView nview;

		private readonly CustomItem _milkBottleFab = ItemManager.Instance.GetItem("milk_bottle");

		public readonly EffectList SpawnEffect = Main.loxMilkSfx;

		private void Awake()
		{
			nview = ((Component)this).GetComponent<ZNetView>();
			loxPoint = ((Component)this).transform;
			if (nview.GetZDO() != null)
			{
				if (nview.IsOwner() && nview.GetZDO().GetLong("lastMilkTime", 0L) == 0L)
				{
					nview.GetZDO().Set("lastMilkTime", ZNet.instance.GetTime().Ticks);
				}
				nview.Register("ExtractMilk", (Action<long>)RPC_ExtractMilk);
				nview.Register<int>("ResetLevel", (Action<long, int>)RPC_ResetLevel);
				((MonoBehaviour)this).InvokeRepeating("UpdateMilk", 0f, 10f);
			}
		}

		private void RPC_ExtractMilk(long caller)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			if (nview.IsOwner())
			{
				Vector2 val = Random.insideUnitCircle * 0.5f;
				Vector3 val2 = loxPoint.position + new Vector3(val.x, 0.25f, val.y);
				Object.Instantiate<ItemDrop>(_milkBottleFab.ItemDrop, val2, Quaternion.identity);
			}
		}

		private void RPC_ResetLevel(long caller, int level)
		{
			if (nview.IsOwner())
			{
				int milkLevel = GetMilkLevel();
				nview.GetZDO().Set("milkLevel", milkLevel - level);
			}
		}

		private float GetTimeSinceLastUpdate()
		{
			DateTime dateTime = new DateTime(nview.GetZDO().GetLong("lastMilkTime", ZNet.instance.GetTime().Ticks));
			DateTime time = ZNet.instance.GetTime();
			TimeSpan timeSpan = time - dateTime;
			nview.GetZDO().Set("lastMilkTime", time.Ticks);
			double num = timeSpan.TotalSeconds;
			if (num < 0.0)
			{
				num = 0.0;
			}
			return (float)num;
		}

		private void IncreaseLevel(int i)
		{
			int milkLevel = GetMilkLevel();
			milkLevel += i;
			milkLevel = Mathf.Clamp(milkLevel, 0, 3);
			nview.GetZDO().Set("milkLevel", milkLevel);
		}

		public int GetMilkLevel()
		{
			return nview.GetZDO().GetInt("milkLevel", 0);
		}

		public void UpdateMilk()
		{
			if (nview.IsOwner())
			{
				float timeSinceLastUpdate = GetTimeSinceLastUpdate();
				float @float = nview.GetZDO().GetFloat("product", 0f);
				@float += timeSinceLastUpdate;
				if (@float > 800f)
				{
					int i = (int)(@float / 800f);
					IncreaseLevel(i);
					@float = 0f;
				}
				nview.GetZDO().Set("product", @float);
			}
		}
	}
	[HarmonyPatch]
	public static class PlantProgress
	{
		[HarmonyPatch(typeof(Pickable), "SetPicked")]
		public static class FixPickableTime
		{
			public class PickState
			{
				public bool picked;

				public long picked_time;
			}

			[HarmonyPrefix]
			public static void Prefix(bool picked, ZNetView ___m_nview, bool ___m_picked, ref PickState __state)
			{
				__state = new PickState
				{
					picked_time = ___m_nview.GetZDO().GetLong("picked_time", 0L),
					picked = ___m_picked
				};
			}

			[HarmonyPostfix]
			public static void Postfix(bool picked, ZNetView ___m_nview, bool ___m_picked, ref PickState __state)
			{
				if (__state.picked == ___m_picked)
				{
					___m_nview.GetZDO().Set("picked_time", __state.picked_time);
				}
			}
		}

		private static readonly List<string> PickableList = new List<string> { "RaspberryBush(Clone)", "BlueberryBush(Clone)", "CloudberryBush(Clone)", "apple_tree(Clone)" };

		private static string GetColour(double percentage)
		{
			if (percentage >= 25.0)
			{
				if (percentage <= 49.0)
				{
					return "orange";
				}
				if (percentage >= 50.0)
				{
					if (percentage <= 74.0)
					{
						return "yellow";
					}
					if (percentage >= 75.0 && percentage <= 100.0)
					{
						return "green";
					}
				}
			}
			return "red";
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Plant), "GetHoverText")]
		public static string PlantGetHoverText_Patch(string __result, Plant __instance)
		{
			if ((Object)(object)__instance == (Object)null)
			{
				return __result;
			}
			if (!Valharvest.Configurations.Valharvest.PlantProgressEnabled.Value)
			{
				return __result;
			}
			double num = Mathf.Floor((float)__instance.TimeSincePlanted() / __instance.GetGrowTime() * 100f);
			string colour = GetColour(num);
			string text = decimal.Round((decimal)num, 2, MidpointRounding.AwayFromZero).ToString(CultureInfo.InvariantCulture);
			string text2 = "<color=" + colour + ">" + text + "%</color>";
			return __result.Replace(" )", ", " + text2 + " )");
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Pickable), "GetHoverText")]
		public static string BerryBushPickable_Patch(string __result, Pickable __instance)
		{
			if (!PickableList.Contains(((Object)__instance).name))
			{
				return __result;
			}
			if (!Valharvest.Configurations.Valharvest.PickableProgressEnabled.Value)
			{
				return __result;
			}
			DateTime dateTime = new DateTime(__instance.m_nview.GetZDO().GetLong("picked_time", 0L));
			double num = (ZNet.instance.GetTime() - dateTime).TotalMinutes / (double)__instance.m_respawnTimeMinutes * 100.0;
			if (num > 99.98999786376953)
			{
				return __result;
			}
			string colour = GetColour(num);
			string text = decimal.Round((decimal)num, 2).ToString(CultureInfo.InvariantCulture);
			string text2 = "<color=" + colour + ">" + text + "%</color>";
			return __result + " " + Localization.instance.Localize(__instance.GetHoverName()) + " ( " + text2 + " )";
		}
	}
	[HarmonyPatch]
	public class RaisedBed
	{
		private static readonly string[] PlantsArray = new string[15]
		{
			"Pickable_Barley", "Pickable_Carrot", "Pickable_Dandelion", "Pickable_Flax", "Pickable_Mushroom", "Pickable_Mushroom_blue", "Pickable_Mushroom_yellow", "Pickable_Onion", "Pickable_SeedCarrot", "Pickable_SeedOnion",
			"Pickable_SeedTurnip", "Pickable_Thistle", "Pickable_Turnip", "Pickable_Mushroom_Magecap", "Pickable_Mushroom_JotunPuffs"
		};

		private static readonly Collider[] pieceColliders = (Collider[])(object)new Collider[2000];

		private static bool massPlanting = true;

		private static readonly List<Piece> m_tempPieces = new List<Piece>();

		private static readonly List<Transform> m_tempSnapPoints1 = new List<Transform>();

		private static readonly List<Transform> m_tempSnapPoints2 = new List<Transform>();

		[HarmonyPostfix]
		[HarmonyPriority(0)]
		[HarmonyAfter(new string[] { "mod.valheim_plus", "org.bepinex.plugins.farming", "com.odinplusqol.mod", "BepIn.Sarcen.Fa    rmGrid", "Harmony.Sarcen.FarmGrid", "infinity_hammer", "org.bepinex.plugins.conversionsizespeed" })]
		[HarmonyPatch(typeof(Player), "UpdatePlacementGhost")]
		private static void UpdatePlacementGrid(Player __instance, bool flashGuardStone)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: 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_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			GameObject placementGhost = __instance.m_placementGhost;
			if ((Object)(object)placementGhost == (Object)null)
			{
				return;
			}
			Plant component = placementGhost.GetComponent<Plant>();
			Piece component2 = placementGhost.GetComponent<Piece>();
			if ((Object)(object)component == (Object)null)
			{
				return;
			}
			if (Main.IsFarmingModInstalled)
			{
				KeyboardShortcut massPlantShortcut = Main.MassPlantShortcut;
				if (((KeyboardShortcut)(ref massPlantShortcut)).IsDown())
				{
					massPlanting = !massPlanting;
				}
			}
			if (!IsPlantPlantable((Component)(object)component))
			{
				return;
			}
			float cultivatedGroundHeight = GetCultivatedGroundHeight((Component)(object)component, __instance);
			Vector3 position = placementGhost.transform.position;
			component2.SetInvalidPlacementHeightlight(false);
			__instance.m_placementStatus = (PlacementStatus)0;
			if (Main.IsFarmingModInstalled)
			{
				KeyboardShortcut massPlantShortcut2 = Main.MassPlantShortcut;
				if (massPlanting)
				{
					component2.SetInvalidPlacementHeightlight(true);
					__instance.m_placementStatus = (PlacementStatus)1;
					string text = Localization.instance.Localize("$msg_TurnMassPlantingOff");
					((Character)__instance).Message((MessageType)2, text + ((object)(KeyboardShortcut)(ref massPlantShortcut2)).ToString() + " key", 0, (Sprite)null);
				}
			}
			Vector3 position2 = default(Vector3);
			((Vector3)(ref position2))..ctor(position.x, cultivatedGroundHeight, position.z);
			placementGhost.transform.position = position2;
			if (GetClosestSnapPoints((Component)(object)placementGhost.transform, 0.5f, out var a, out var b, __instance, ((Component)component).transform))
			{
				Vector3 position3 = b.position - (a.position - placementGhost.transform.position);
				if (!IsPlantOverlapping((Component)(object)component))
				{
					placementGhost.transform.position = position3;
					return;
				}
				component2.SetInvalidPlacementHeightlight(true);
				__instance.m_placementStatus = (PlacementStatus)1;
			}
		}

		private static bool GetClosestSnapPoints(Component ghost, float maxSnapDistance, out Transform a, out Transform b, Player player, Transform plant)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			m_tempSnapPoints1.Clear();
			m_tempSnapPoints1.Add(plant);
			m_tempSnapPoints2.Clear();
			m_tempPieces.Clear();
			GetSnapPoints(ghost.transform.position, 10f, m_tempSnapPoints2, m_tempPieces);
			float num = 9999999f;
			a = null;
			b = null;
			Transform val = default(Transform);
			float num2 = default(float);
			foreach (Transform item in m_tempSnapPoints1)
			{
				if (player.FindClosestSnappoint(item.position, m_tempSnapPoints2, maxSnapDistance, ref val, ref num2) && num2 < num)
				{
					num = num2;
					a = item;
					b = val;
				}
			}
			return (Object)(object)a != (Object)null;
		}

		private static bool IsPlantOverlapping(Component plant)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			Bounds bounds = plant.GetComponent<Collider>().bounds;
			int num = Physics.OverlapSphereNonAlloc(((Bounds)(ref bounds)).center, 0.2f, pieceColliders);
			for (int i = 0; i < num; i++)
			{
				Collider val = pieceColliders[i];
				if (!((Object)(object)val == (Object)null) && !(((Object)val).name == ((Object)plant).name) && !((Object)(object)((Component)val).gameObject.GetComponent<Plant>() == (Object)null))
				{
					return true;
				}
			}
			return false;
		}

		private static void GetSnapPoints(Vector3 point, float radius, ICollection<Transform> points, ICollection<Piece> pieces)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			if (Piece.s_pieceRayMask == 0)
			{
				Piece.s_pieceRayMask = LayerMask.GetMask(new string[2] { "piece", "piece_nonsolid" });
			}
			int num = Physics.OverlapSphereNonAlloc(point, radius, pieceColliders, Piece.s_pieceRayMask);
			for (int i = 0; i < num; i++)
			{
				Piece componentInParent = ((Component)pieceColliders[i]).GetComponentInParent<Piece>();
				if (!((Object)(object)componentInParent == (Object)null) && ((Object)componentInParent).name.Contains("cultivatedGround"))
				{
					GetSnapPoints(points, (Component)(object)componentInParent);
					pieces.Add(componentInParent);
				}
			}
		}

		private static void GetSnapPoints(ICollection<Transform> points, Component piece)
		{
			for (int i = 0; i < piece.transform.childCount; i++)
			{
				Transform child = piece.transform.GetChild(i);
				if (((Object)child).name.Contains("_snapplant"))
				{
					points.Add(child);
				}
			}
		}

		private static float GetCultivatedGroundHeight(Component plant, Player player)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: 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_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: 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)
			Vector3 position = plant.transform.position;
			Piece hoveringPiece = player.m_hoveringPiece;
			if ((Object)(object)hoveringPiece == (Object)null)
			{
				return position.y;
			}
			if (((Object)hoveringPiece).name.Contains("cultivatedGround"))
			{
				return ((Component)((Component)hoveringPiece).GetComponentInChildren<Collider>()).transform.position.y;
			}
			Vector3 position2 = ((Component)hoveringPiece).transform.position;
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(position2.x, position2.y + 3f, position2.z);
			RaycastHit val2 = ((IEnumerable<RaycastHit>)(from x in Physics.RaycastAll(new Ray(val, Vector3.down))
				orderby Vector3.Distance(((RaycastHit)(ref x)).point, position)
				select x)).FirstOrDefault((Func<RaycastHit, bool>)((RaycastHit x) => ((Object)((Component)((RaycastHit)(ref x)).collider).gameObject).name == "Cultivated_ground_piece"));
			if (!((Object)(object)((RaycastHit)(ref val2)).collider == (Object)null))
			{
				return ((RaycastHit)(ref val2)).point.y;
			}
			return position.y;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Piece), "Awake")]
		private static void SetFakeComponent(Piece __instance)
		{
			Collider[] componentsInChildren = ((Component)((Component)__instance).transform).GetComponentsInChildren<Collider>();
			foreach (Collider val in componentsInChildren)
			{
				if (((Object)((Component)val).gameObject).name == "Cultivated_ground_piece")
				{
					((Component)val).gameObject.AddComponent<CultivatedGround>();
				}
			}
		}

		[HarmonyPostfix]
		[HarmonyPriority(0)]
		[HarmonyPatch(typeof(Heightmap), "IsCultivated")]
		private static bool PatchIsCultivated(bool __result, Vector3 worldPos)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			Plant.m_roofMask = 0;
			Plant.m_spaceMask = 0;
			if (!CheckIfItemBellowIsCultivatedGround(worldPos))
			{
				return __result;
			}
			Plant.m_roofMask = LayerMask.GetMask(new string[1] { "" });
			Plant.m_spaceMask = LayerMask.GetMask(new string[2] { "Default", "piece_nonsolid" });
			return true;
		}

		private static bool IsPlantPlantable(Component plant)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = plant.transform.position;
			return CheckIfItemBellowIsCultivatedGround(new Vector3(position.x, position.y + 1f, position.z));
		}

		public static bool CheckIfItemBellowIsCultivatedGround(Vector3 position)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			int mask = LayerMask.GetMask(new string[1] { "piece" });
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(position.x, position.y + 100f, position.z);
			return Physics.RaycastAll(new Ray(val, Vector3.down), 1000f, mask).Any((RaycastHit hit) => ((Object)((Component)((RaycastHit)(ref hit)).collider).gameObject).name == "Cultivated_ground_piece");
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Pickable), "Awake")]
		public static void FixPlantPhysics(Pickable __instance)
		{
			if (PlantsArray.Any(((Object)__instance).name.Contains))
			{
				StaticPhysics component = ((Component)__instance).gameObject.GetComponent<StaticPhysics>();
				if ((Object)(object)component != (Object)null)
				{
					component.m_checkSolids = true;
				}
			}
		}

		[HarmonyPrefix]
		[HarmonyPriority(0)]
		[HarmonyAfter(new string[] { "mod.valheim_plus", "org.bepinex.plugins.farming", "com.odinplusqol.mod", "BepIn.Sarcen.FarmGrid", "Harmony.Sarcen.FarmGrid" })]
		[HarmonyPatch(typeof(Plant), "Awake")]
		public static void FixPlantHealth(Plant __instance)
		{
			((Component)__instance).gameObject.AddComponent<FixPlantHealth>();
		}
	}
	[HarmonyPatch]
	public static class ReturnEmptyBottle
	{
		[HarmonyPatch(typeof(Player), "ConsumeResources")]
		private static class ConsumeResourcesPatch
		{
			private static bool Prefix(Player __instance, IEnumerable<Requirement> requirements, int qualityLevel)
			{
				foreach (Requirement requirement in requirements)
				{
					if (!Object.op_Implicit((Object)(object)requirement.m_resItem))
					{
						continue;
					}
					int amount = requirement.GetAmount(qualityLevel);
					if (amount > 0 && !(requirement.m_resItem.m_itemData.m_shared.m_name != "$milk_bottle_name"))
					{
						Inventory inventory = ((Humanoid)__instance).GetInventory();
						ItemData itemOnInventory = InteractPatch.GetItemOnInventory("$empty_bottle_name");
						if (inventory.HaveEmptySlot())
						{
							AddEmptyMilkBottle(__instance, qualityLevel, inventory, amount);
							return true;
						}
						if (itemOnInventory != null && inventory.CanAddItem(itemOnInventory, amount))
						{
							AddEmptyMilkBottle(__instance, qualityLevel, inventory, amount);
							return true;
						}
						((Character)__instance).Message((MessageType)2, "$msg_noroom", 0, (Sprite)null);
						return true;
					}
				}
				return true;
			}

			private static void AddEmptyMilkBottle(Player instance, int qualityLevel, Inventory inventory, int totalRequirement)
			{
				inventory.AddItem("empty_bottle", totalRequirement, qualityLevel, 0, 0L, instance.GetPlayerName(), false);
			}
		}

		[HarmonyPatch(typeof(Player), "RemovePiece")]
		private static class RemovePiecePatch
		{
			public static bool Prefix(Player __instance, ref bool __runOriginal)
			{
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0019: Unknown result type (might be due to invalid IL or missing references)
				//IL_0034: Unknown result type (might be due to invalid IL or missing references)
				//IL_003f: Unknown result type (might be due to invalid IL or missing references)
				RaycastHit val = default(RaycastHit);
				if (!Physics.Raycast(((Component)GameCamera.instance).transform.position, ((Component)GameCamera.instance).transform.forward, ref val, 50f, __instance.m_removeRayMask) || !(Vector3.Distance(((RaycastHit)(ref val)).point, ((Character)__instance).m_eye.position) < __instance.m_maxPlaceDistance))
				{
					return __runOriginal;
				}
				Piece componentInParent = ((Component)((RaycastHit)(ref val)).collider).GetComponentInParent<Piece>();
				if ((Object)(object)componentInParent == (Object)null || componentInParent.m_name != "$piece_milk_can_name")
				{
					return __runOriginal;
				}
				Requirement[] resources = componentInParent.m_resources;
				foreach (Requirement val2 in resources)
				{
					if (Object.op_Implicit((Object)(object)val2.m_resItem) && !(val2.m_resItem.m_itemData.m_shared.m_name != "$milk_bottle_name"))
					{
						Inventory inventory = ((Humanoid)__instance).GetInventory();
						ItemData itemOnInventory = InteractPatch.GetItemOnInventory("$empty_bottle_name");
						if (itemOnInventory == null)
						{
							((Character)__instance).Message((MessageType)2, "$msg_donthaveany $empty_bottle_name", 0, (Sprite)null);
							__runOriginal = false;
							return false;
						}
						int amount = val2.GetAmount(0);
						int num = inventory.CountItems(itemOnInventory.m_shared.m_name, -1, true);
						if (num < amount)
						{
							((Character)__instance).Message((MessageType)2, $"$enough_empty_bottle. Need {amount - num} more.", 0, (Sprite)null);
							__runOriginal = false;
							return false;
						}
						inventory.RemoveItem(itemOnInventory.m_shared.m_name, amount, -1, true);
					}
				}
				return __runOriginal = true;
			}
		}
	}
	[HarmonyPatch]
	public static class SaltDrop
	{
		[HarmonyPatch(typeof(DropOnDestroyed), "OnDestroyed")]
		public static class DropOnDestroyedOnDestroyedPatch
		{
			[HarmonyPrefix]
			private static void Prefix(ref DropOnDestroyed __instance)
			{
				_dropTableObject = ((Object)((Component)__instance).gameObject).name;
			}

			[HarmonyPostfix]
			private static void Postfix(ref DropOnDestroyed __instance)
			{
				_dropTableObject = "";
			}
		}

		private static string _dropTableObject = "";

		[HarmonyPostfix]
		[HarmonyPatch(typeof(DropTable), "GetDropList", new Type[] { })]
		public static void DropTableGetDropList_Patch(ref List<GameObject> __result)
		{
			if ((Environment.StackTrace.Contains("MineRock") || (Environment.StackTrace.Contains("DropOnDestroyed") && _dropTableObject.Contains("Rock"))) && (double)Random.value < (double)Valharvest.Configurations.Valharvest.SaltDropPercentage.Value / 100.0)
			{
				GameObject prefab = ZNetScene.instance.GetPrefab("salt");
				__result.Add(prefab);
			}
		}
	}
	[HarmonyPatch]
	public class UseFertilizer
	{
		private static readonly string[] PickableArray = new string[2] { "Thistle", "apple" };

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Plant), "Awake")]
		public static void AddPlantFertilizer(Plant __instance)
		{
			((Component)__instance).gameObject.AddComponent<InteractFertilizer>();
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Pickable), "UseItem")]
		private static bool AddThistleFertilizer(Pickable __instance, ref bool __result, Humanoid user, ItemData item)
		{
			__result = true;
			if (!PickableArray.Any(((Object)__instance).name.Contains))
			{
				return true;
			}
			if (!IsPickablePickable(__instance))
			{
				return true;
			}
			Inventory inventory = ((Humanoid)Player.m_localPlayer).GetInventory();
			if (!SetPickableTime(__instance, item))
			{
				return false;
			}
			inventory.RemoveOneItem(item);
			GrowPickable(__instance);
			return false;
		}

		private static bool SetPickableTime(Pickable pickable, ItemData item)
		{
			ZNetView nview = pickable.m_nview;
			bool num = ((Object)item.m_dropPrefab).name == "bonemeal";
			bool flag = ((Object)item.m_dropPrefab).name == "water_bucket";
			double num2 = pickable.m_respawnTimeMinutes;
			int num3 = (num ? 8 : 4);
			if (!num && !flag)
			{
				return false;
			}
			long @long = nview.GetZDO().GetLong(ZDOVars.s_pickedTime, ZNet.instance.GetTime().Ticks);
			long num4 = (long)(num2 * 60.0 * 10000000.0 / (double)num3);
			long num5 = @long - num4;
			if (num5 < 0)
			{
				num5 = 0L;
			}
			nview.GetZDO().Set("picked_time", num5);
			SendPickableEffect(pickable);
			return true;
		}

		private static void SendPickableEffect(Pickable pickable)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			float num = Random.Range(0.5f, 0.5f);
			Quaternion val = Quaternion.Euler(0f, Random.Range(0f, 360f), 0f);
			Main.boneMealVfx.Create(((Component)pickable).transform.position, val, (Transform)null, num, -1);
		}

		private static bool IsPickablePickable(Pickable pickable)
		{
			ZNetView nview = pickable.m_nview;
			if (!nview.IsValid())
			{
				return false;
			}
			DateTime dateTime = new DateTime(nview.GetZDO().GetLong(ZDOVars.s_pickedTime, 0L));
			return (ZNet.instance.GetTime() - dateTime).TotalMinutes <= (double)pickable.m_respawnTimeMinutes;
		}

		private static void GrowPickable(Pickable pickable)
		{
			if (!IsPickablePickable(pickable))
			{
				pickable.SetPicked(false);
			}
		}
	}
	public static class Vector3Ext
	{
		public static Vector3 xz(this Vector3 v)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3(v.x, 0f, v.z);
		}
	}
}
namespace Valharvest.Configurations
{
	public class Valharvest
	{
		public static ConfigEntry<bool> KabobName;

		public static ConfigEntry<bool> DropEnabled;

		public static ConfigEntry<int> AppleRespawnTime;

		public static ConfigEntry<int> AppleDropAmount;

		public static ConfigEntry<int> SaltDropPercentage;

		public static ConfigEntry<bool> PlantProgressEnabled;

		public static ConfigEntry<bool> PickableProgressEnabled;

		public ConfigEntry<int> GarlicChance;

		public ConfigEntry<int> PepperChance;

		public ConfigEntry<int> RiceChance;

		public static Dictionary<string, ConfigEntry<int>> GetDropConfigs()
		{
			return new Dictionary<string, ConfigEntry<int>> { { "AppleDropAmount", AppleDropAmount } };
		}

		public static Dictionary<string, ConfigEntry<int>> GetRespawnTimeConfigs()
		{
			return new Dictionary<string, ConfigEntry<int>> { { "AppleRespawnTime", AppleRespawnTime } };
		}

		internal Valharvest(ConfigFile config)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Expected O, but got Unknown
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			//IL_008c: 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: Expected O, but got Unknown
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Expected O, but got Unknown
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Expected O, but got Unknown
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Expected O, but got Unknown
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Expected O, but got Unknown
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Expected O, but got Unknown
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Expected O, but got Unknown
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Expected O, but got Unknown
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Expected O, but got Unknown
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Expected O, but got Unknown
			KabobName = config.Bind<bool>("Kabob", "Enable", true, new ConfigDescription("Change Kabob name to Kebab", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			DropEnabled = config.Bind<bool>("Vegetables Drop", "Enable", false, new ConfigDescription("Keep vegetables in monster drops", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			PlantProgressEnabled = config.Bind<bool>("Plant Progress", "EnableOnPlants", true, new ConfigDescription("Enable showing plant growth progress on plants", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			PickableProgressEnabled = config.Bind<bool>("Plant Progress", "EnableOnPickable", true, new ConfigDescription("Enable showing plant growth progress on pickable", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			AppleDropAmount = config.Bind<int>("Drop Amount", "AppleQuantity", 1, new ConfigDescription("Amount of drop Apple from apple tree", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			AppleRespawnTime = config.Bind<int>("Respawn Time", "AppleRespawnTime", 5, new ConfigDescription("Time in hours for apple tree to respawn apples", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			SaltDropPercentage = config.Bind<int>("Salt", "Enable", 35, new ConfigDescription("Chance of drop Salt", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
		}
	}
}