Decompiled source of ValheimCoffee v0.4.0

BepInEx/plugins/ValheimCoffee/ValheimCoffee.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ValheimCoffee")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.4.0.0")]
[assembly: AssemblyInformationalVersion("0.4.0")]
[assembly: AssemblyProduct("ValheimCoffee")]
[assembly: AssemblyTitle("ValheimCoffee")]
[assembly: AssemblyVersion("0.4.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ValheimCoffee
{
	internal static class BeverageEffects
	{
		[HarmonyPatch(typeof(Player), "ConsumeItem")]
		private static class WarmAfterDrinking
		{
			private static void Postfix(Player __instance, ItemData item, bool __result)
			{
				if (__result)
				{
					CoffeeTier coffeeTier = CoffeeTiers.Find(item?.m_shared?.m_consumeStatusEffect);
					if (coffeeTier != null && coffeeTier.Rank >= 2)
					{
						((Character)__instance).GetSEMan().AddStatusEffect(StringExtensionMethods.GetStableHashCode("VC_CoffeeWarmth"), true, 0, 0f, (short)(-1));
					}
				}
			}
		}

		[HarmonyPatch(typeof(Player), "GetTotalFoodValue")]
		private static class StoutMaxStats
		{
			private static void Postfix(Player __instance, ref float hp, ref float stamina)
			{
				if (((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("VC_StoutEffect")))
				{
					hp += 10f;
					stamina += 20f;
				}
			}
		}

		[HarmonyPatch(typeof(Player), "UpdateEnvStatusEffects")]
		private static class NightColdOnly
		{
			private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> source)
			{
				MethodInfo original = AccessTools.Method(typeof(EnvMan), "IsCold", (Type[])null, (Type[])null);
				MethodInfo replacement = AccessTools.Method(typeof(BeverageEffects), "IsColdForPlayer", (Type[])null, (Type[])null);
				int replaced = 0;
				foreach (CodeInstruction item in source)
				{
					if (CodeInstructionExtensions.Calls(item, original))
					{
						CodeInstruction val = new CodeInstruction(OpCodes.Ldarg_0, (object)null);
						CodeInstructionExtensions.MoveLabelsTo(item, val);
						CodeInstructionExtensions.MoveBlocksTo(item, val);
						yield return val;
						yield return new CodeInstruction(OpCodes.Call, (object)replacement);
						replaced++;
					}
					else
					{
						yield return item;
					}
				}
				if (replaced != 1)
				{
					throw new InvalidOperationException("Coffee warmth: expected exactly one EnvMan.IsCold call, found " + replaced);
				}
			}
		}

		internal const string StoutEffect = "VC_StoutEffect";

		internal const string WarmthEffect = "VC_CoffeeWarmth";

		internal static bool IsStout(ItemData item)
		{
			object obj;
			if (item == null)
			{
				obj = null;
			}
			else
			{
				SharedData shared = item.m_shared;
				if (shared == null)
				{
					obj = null;
				}
				else
				{
					StatusEffect consumeStatusEffect = shared.m_consumeStatusEffect;
					obj = ((consumeStatusEffect != null) ? ((Object)consumeStatusEffect).name : null);
				}
			}
			return (string?)obj == "VC_StoutEffect";
		}

		internal static void RegisterWarmth(Sprite icon)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			StatusEffect val = ScriptableObject.CreateInstance<StatusEffect>();
			((Object)val).name = "VC_CoffeeWarmth";
			val.m_name = "$vc_warmth";
			val.m_tooltip = "$vc_warmth_desc";
			val.m_ttl = 600f;
			val.m_icon = icon;
			if (!ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(val, false)))
			{
				throw new InvalidOperationException("Cannot register coffee warmth");
			}
		}

		internal static bool IsColdForPlayer(Player player)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: 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)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Invalid comparison between Unknown and I4
			bool flag = EnvMan.IsCold();
			if (!flag || (Object)(object)player == (Object)null)
			{
				return flag;
			}
			Biome currentBiome = player.GetCurrentBiome();
			EnvMan instance = EnvMan.instance;
			EnvSetup val = ((instance != null) ? instance.GetCurrentEnvironment() : null);
			if (val == null)
			{
				return flag;
			}
			if (!ColdProtectionRules.Protects(((Character)player).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("VC_CoffeeWarmth")), EnvMan.IsNight(), EnvMan.IsFreezing(), (currentBiome & 0x44) > 0, val.m_isCold, val.m_isColdAtNight, val.m_isFreezing || val.m_isFreezingAtNight, val.m_snowBuildup > 0f))
			{
				return flag;
			}
			return false;
		}
	}
	internal sealed class CoffeeTier
	{
		internal readonly int Rank;

		internal readonly int RegenPercent;

		internal readonly string ItemId;

		internal readonly string EffectId;

		internal readonly string StationId;

		internal readonly string DisplayName;

		internal float RegenMultiplier => 1f + (float)RegenPercent / 100f;

		internal string Description => "$vc_tier" + Rank + "_desc";

		internal CoffeeTier(int rank, int percent, string item, string effect, string station, string displayName)
		{
			Rank = rank;
			RegenPercent = percent;
			ItemId = item;
			EffectId = effect;
			StationId = station;
			DisplayName = displayName;
		}
	}
	internal static class CoffeeTiers
	{
		[HarmonyPatch(typeof(Player), "CanConsumeItem")]
		private static class CanDrinkCoffee
		{
			private static bool Prefix(Player __instance, ItemData item, bool checkWorldLevel, ref bool __result)
			{
				//IL_0036: Unknown result type (might be due to invalid IL or missing references)
				//IL_003c: Invalid comparison between Unknown and I4
				CoffeeTier coffeeTier = Find(item?.m_shared?.m_consumeStatusEffect);
				bool flag = BeverageEffects.IsStout(item);
				if (coffeeTier == null && !flag)
				{
					return true;
				}
				__result = false;
				if ((int)item.m_shared.m_itemType != 2)
				{
					return false;
				}
				if (checkWorldLevel && Game.m_worldLevel > 0 && item.m_worldLevel < Game.m_worldLevel)
				{
					((Character)__instance).Message((MessageType)2, "$vc_world_level", 0, (Sprite)null, false);
					return false;
				}
				if (item.m_shared.m_food > 0f && !__instance.CanEat(item, true))
				{
					return false;
				}
				if (flag)
				{
					ItemData currentWeapon = ((Humanoid)__instance).GetCurrentWeapon();
					object obj;
					if (currentWeapon == null)
					{
						obj = null;
					}
					else
					{
						GameObject dropPrefab = currentWeapon.m_dropPrefab;
						obj = ((dropPrefab != null) ? ((Object)dropPrefab).name : null);
					}
					if ((string?)obj != "Tankard")
					{
						((Character)__instance).Message((MessageType)2, "$vc_equip_tankard", 0, (Sprite)null, false);
						return false;
					}
					__result = true;
					return false;
				}
				CoffeeTier coffeeTier2 = Strongest(((Character)__instance).GetSEMan());
				if (coffeeTier2 != null && coffeeTier2.Rank > coffeeTier.Rank)
				{
					((Character)__instance).Message((MessageType)2, "$vc_lower_tier", 0, (Sprite)null, false);
					return false;
				}
				__result = true;
				return false;
			}
		}

		[HarmonyPatch]
		private static class KeepOneCoffeeEffect
		{
			private static MethodBase TargetMethod()
			{
				return AccessTools.GetDeclaredMethods(typeof(SEMan)).Single((MethodInfo method) => method.Name == "AddStatusEffect" && method.GetParameters().Length != 0 && method.GetParameters()[0].ParameterType == typeof(StatusEffect));
			}

			private static bool Prefix(SEMan __instance, StatusEffect statusEffect, ref StatusEffect __result)
			{
				CoffeeTier coffeeTier = Find(statusEffect);
				if (coffeeTier == null)
				{
					return true;
				}
				CoffeeTier coffeeTier2 = Strongest(__instance);
				if (coffeeTier2 == null || coffeeTier2.Rank <= coffeeTier.Rank)
				{
					return true;
				}
				__result = null;
				return false;
			}

			private static void Postfix(SEMan __instance, StatusEffect statusEffect, StatusEffect __result)
			{
				if (Find(statusEffect) == null || (Object)(object)__result == (Object)null)
				{
					return;
				}
				StatusEffect[] array = __instance.GetStatusEffects().ToArray();
				foreach (StatusEffect val in array)
				{
					if (Find(val) != null && (Object)(object)val != (Object)(object)__result)
					{
						__instance.RemoveStatusEffect(val, true);
					}
				}
			}
		}

		internal const float DurationSeconds = 1800f;

		internal const string Category = "VC_Coffee";

		internal static readonly CoffeeTier[] All = new CoffeeTier[3]
		{
			new CoffeeTier(1, 25, "VC_CoffeeFiltered", "VC_CoffeeFilteredEffect", "VC_CoffeeFilter", "$vc_filtered"),
			new CoffeeTier(2, 50, "VC_CoffeeFrenchPress", "VC_CoffeeEffect", "VC_FrenchPress", "$vc_french"),
			new CoffeeTier(3, 75, "VC_CoffeeEspresso", "VC_CoffeeEspressoEffect", "VC_EspressoPress", "$vc_espresso")
		};

		internal static CoffeeTier Find(StatusEffect effect)
		{
			if (!((Object)(object)effect == (Object)null))
			{
				return All.FirstOrDefault((CoffeeTier tier) => tier.EffectId == ((Object)effect).name);
			}
			return null;
		}

		internal static CoffeeTier Strongest(SEMan manager)
		{
			return (from tier in manager.GetStatusEffects().Select(Find)
				where tier != null
				orderby tier.Rank descending
				select tier).FirstOrDefault();
		}
	}
	internal static class ColdProtectionRules
	{
		internal static bool Protects(bool hasWarmth, bool isNight, bool isFreezing, bool snowBiome, bool alwaysCold, bool coldAtNight, bool freezingEnvironment, bool snowWeather)
		{
			if (hasWarmth && isNight && !isFreezing && !snowBiome && !alwaysCold && coldAtNight && !freezingEnvironment)
			{
				return !snowWeather;
			}
			return false;
		}
	}
	internal static class Localizations
	{
		internal static void Register()
		{
			CustomLocalization localization = LocalizationManager.Instance.GetLocalization();
			string text = "English";
			localization.AddTranslation(ref text, new Dictionary<string, string>
			{
				{ "vc_seed", "Coffee Seed" },
				{ "vc_seed_desc", "A coffee seed for planting with the cultivator. Sold by Haldor." },
				{ "vc_raw", "Coffee" },
				{ "vc_raw_desc", "Freshly harvested coffee. Dry it on the Grain Dryer or separate seeds at a workbench." },
				{ "vc_dry", "Dried Coffee" },
				{ "vc_dry_desc", "Dried coffee, ready to grind and brew. Does not grant a bonus on its own." },
				{ "vc_paper", "Filter Paper" },
				{ "vc_paper_desc", "Plant-fiber filter made from dandelion. Dry 1 Dandelion on the Grain Dryer for 30 seconds. Used for filtered coffee." },
				{ "vc_cup", "Cup" },
				{ "vc_cup_desc", "A wooden cup. Required to brew all three coffees." },
				{ "vc_grinder", "Coffee Grinder" },
				{ "vc_grinder_desc", "A manual stone grinder for dried coffee." },
				{ "vc_press", "French Press" },
				{ "vc_press_desc", "An iron and wood press. Requires a nearby fire." },
				{ "vc_filter", "Coffee Filter" },
				{ "vc_filter_desc", "A filter on a wooden stand. Each brew uses ground coffee and a plant-fiber filter. Requires a nearby fire." },
				{ "vc_espresso_press", "Espresso Press" },
				{ "vc_espresso_press_desc", "A manual lever press with a metal boiler. Requires a nearby fire." },
				{ "vc_ground", "Ground Coffee" },
				{ "vc_ground_desc", "Ground coffee. Brew it at the Coffee Filter, French Press or Espresso Press." },
				{ "vc_plant_desc", "Coffee. Plant in cultivated soil in the Meadows or Black Forest. Harvest: 3 beans." },
				{ "vc_dryer", "Grain Dryer" },
				{ "vc_dryer_desc", "Over a lit fire: Coffee dries in 60 seconds; Dandelion becomes Filter Paper in 30 seconds." },
				{ "vc_dryer_add", "Add Coffee or Dandelion" },
				{ "vc_dryer_empty", "You need Coffee or Dandelion to use the dryer." },
				{ "vc_dryer_ready", "Ready to collect" },
				{ "vc_stout", "Coffee Stout" },
				{ "vc_stout_effect_desc", "+10 max health, +20 max stamina and +30% stamina regeneration for 30 minutes. Does not occupy a food slot." },
				{ "vc_stout_drink_hint", " Equip the wooden tankard to drink." },
				{ "vc_wort", "Coffee Stout Base" },
				{ "vc_wort_desc", "4 Ground Coffee, 6 Barley and 4 Honey. Ferment to make 6 Coffee Stouts. Drink with a wooden tankard." },
				{ "vc_filtered", "Filtered Coffee" },
				{ "vc_french", "French Press Coffee" },
				{ "vc_espresso", "Espresso" },
				{ "vc_world_level", "This drink belongs to an earlier world level." },
				{ "vc_equip_tankard", "Equip the wooden tankard to drink the stout." },
				{ "vc_lower_tier", "You already have a higher-tier coffee active." },
				{ "vc_warmth", "Coffee Warmth" },
				{ "vc_warmth_desc", "Protection against nighttime cold for 10 minutes. Does not protect against snow or freezing." },
				{ "vc_wild", "Wild Coffee" },
				{ "vc_tier1_desc", "Tier 1: +25% stamina regeneration for 30 minutes. Only one coffee bonus at a time." },
				{ "vc_tier2_desc", "Tier 2: +50% stamina regeneration for 30 minutes. Only one coffee bonus at a time. Protects against nighttime cold for 10 minutes; does not protect against snow." },
				{ "vc_tier3_desc", "Tier 3: +75% stamina regeneration for 30 minutes. Only one coffee bonus at a time. Protects against nighttime cold for 10 minutes; does not protect against snow." }
			});
			text = "Portuguese_Brazilian";
			localization.AddTranslation(ref text, new Dictionary<string, string>
			{
				{ "vc_seed", "Semente de café" },
				{ "vc_seed_desc", "Semente de café para plantar com o cultivador. Vendida por Haldor." },
				{ "vc_raw", "Café" },
				{ "vc_raw_desc", "Café recém-colhido. Seque no Secador de grãos ou separe sementes na bancada." },
				{ "vc_dry", "Café seco" },
				{ "vc_dry_desc", "Café seco, pronto para moer e preparar. Não concede o bônus sozinho." },
				{ "vc_paper", "Filtro de papel" },
				{ "vc_paper_desc", "Filtro de fibra vegetal de dente-de-leão. Seque 1 dente-de-leão no Secador de grãos por 30 segundos. Usado no coador." },
				{ "vc_cup", "Xícara" },
				{ "vc_cup_desc", "Xícara de madeira. Necessária para preparar os três cafés." },
				{ "vc_grinder", "Moinho de café" },
				{ "vc_grinder_desc", "Moinho manual de pedra para café seco." },
				{ "vc_press", "Prensa francesa" },
				{ "vc_press_desc", "Prensa de ferro e madeira. Precisa de fogo próximo." },
				{ "vc_filter", "Coador de café" },
				{ "vc_filter_desc", "Coador em suporte de madeira. Cada bebida usa café moído e um papel vegetal. Precisa de fogo próximo." },
				{ "vc_espresso_press", "Prensa de espresso" },
				{ "vc_espresso_press_desc", "Prensa manual de alavanca com caldeira de metal. Precisa de fogo próximo." },
				{ "vc_ground", "Café moído" },
				{ "vc_ground_desc", "Café moído. Prepare no Coador de café, na Prensa francesa ou na Prensa de espresso." },
				{ "vc_plant_desc", "Café. Solo cultivado nos Prados ou Floresta Negra. Colheita: 3 grãos." },
				{ "vc_dryer", "Secador de grãos" },
				{ "vc_dryer_desc", "Sobre fogo aceso: café seca em 60 segundos; dente-de-leão vira filtro de papel em 30 segundos." },
				{ "vc_dryer_add", "Adicionar café ou dente-de-leão" },
				{ "vc_dryer_empty", "Você precisa de café ou dente-de-leão para usar o secador." },
				{ "vc_dryer_ready", "Pronto para recolher" },
				{ "vc_stout", "Stout de café" },
				{ "vc_stout_effect_desc", "+10 de vida máxima, +20 de stamina máxima e +30% de regeneração de stamina por 30 minutos. Não ocupa espaço de comida." },
				{ "vc_stout_drink_hint", " Equipe a caneca de madeira para beber." },
				{ "vc_wort", "Mosto de stout de café" },
				{ "vc_wort_desc", "4 cafés moídos, 6 cevadas e 4 méis. Fermente para obter 6 doses de stout de café. Use a caneca de madeira para beber." },
				{ "vc_filtered", "Café coado" },
				{ "vc_french", "Café na prensa" },
				{ "vc_espresso", "Espresso" },
				{ "vc_world_level", "Esta bebida pertence a um nível de mundo anterior." },
				{ "vc_equip_tankard", "Equipe a caneca de madeira para beber a stout." },
				{ "vc_lower_tier", "Você já tem um café de nível superior ativo." },
				{ "vc_warmth", "Café quentinho" },
				{ "vc_warmth_desc", "Proteção contra o frio noturno por 10 minutos. Não protege contra neve ou congelamento." },
				{ "vc_wild", "Café selvagem" },
				{ "vc_tier1_desc", "Nível 1: +25% de regeneração de stamina por 30 minutos. Apenas um bônus de café por vez." },
				{ "vc_tier2_desc", "Nível 2: +50% de regeneração de stamina por 30 minutos. Apenas um bônus de café por vez. Protege do frio da noite por 10 minutos; não protege da neve." },
				{ "vc_tier3_desc", "Nível 3: +75% de regeneração de stamina por 30 minutos. Apenas um bônus de café por vez. Protege do frio da noite por 10 minutos; não protege da neve." }
			});
		}
	}
	[BepInPlugin("kalel.valheimcoffee", "Valheim Coffee", "0.4.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public sealed class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(Trader), "GetAvailableItems")]
		private static class HaldorSeeds
		{
			private static void Postfix(Trader __instance, ref List<TradeItem> __result)
			{
				//IL_005d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0062: Unknown result type (might be due to invalid IL or missing references)
				//IL_006e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0075: Unknown result type (might be due to invalid IL or missing references)
				//IL_0082: Expected O, but got Unknown
				if (((Object)__instance).name.IndexOf("Haldor", StringComparison.OrdinalIgnoreCase) < 0 || __result == null)
				{
					return;
				}
				GameObject prefab = PrefabManager.Instance.GetPrefab("VC_CoffeeSeed");
				if (!((Object)(object)prefab == (Object)null))
				{
					ItemDrop item = prefab.GetComponent<ItemDrop>();
					if (!__result.Exists((TradeItem entry) => (Object)(object)entry.m_prefab == (Object)(object)item))
					{
						__result.Add(new TradeItem
						{
							m_prefab = item,
							m_stack = 1,
							m_price = 10
						});
					}
				}
			}
		}

		public const string Guid = "kalel.valheimcoffee";

		public const string Seed = "VC_CoffeeSeed";

		public const string Raw = "VC_CoffeeRaw";

		public const string Dry = "VC_CoffeeDried";

		public const string Ground = "VC_CoffeeGround";

		public const string Paper = "VC_FilterPaper";

		public const string Cup = "VC_CoffeeCup";

		public const string StoutBase = "VC_CoffeeStoutBase";

		public const string Stout = "VC_CoffeeStout";

		public const string Press = "VC_FrenchPress";

		public const string Filter = "VC_CoffeeFilter";

		public const string Espresso = "VC_EspressoPress";

		public const string Grinder = "VC_CoffeeGrinder";

		public const string Effect = "VC_CoffeeEffect";

		internal static Plugin Instance;

		private Harmony harmony;

		private void Awake()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			Instance = this;
			Localizations.Register();
			harmony = new Harmony("kalel.valheimcoffee");
			harmony.PatchAll();
			PrefabManager.OnVanillaPrefabsAvailable += Register;
		}

		private void OnDestroy()
		{
			PrefabManager.OnVanillaPrefabsAvailable -= Register;
			Harmony obj = harmony;
			if (obj != null)
			{
				obj.UnpatchSelf();
			}
		}

		private void Register()
		{
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Expected O, but got Unknown
			//IL_036b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0372: Expected O, but got Unknown
			//IL_0444: Unknown result type (might be due to invalid IL or missing references)
			//IL_044e: Expected O, but got Unknown
			PrefabManager.OnVanillaPrefabsAvailable -= Register;
			try
			{
				string[] array = new string[16]
				{
					"Barley", "CarrotSeeds", "MeadTasty", "Pickable_Barley", "sapling_carrot", "piece_cookingstation", "piece_workbench", "Wood", "Iron", "Stone",
					"LeatherScraps", "Dandelion", "Tankard", "MeadBaseTasty", "fermenter", "piece_cauldron"
				};
				for (int i = 0; i < array.Length; i++)
				{
					RequirePrefab(array[i]);
				}
				CustomItem val = Item("VC_CoffeeSeed", "CarrotSeeds", "$vc_seed", "$vc_seed_desc", null);
				CustomItem val2 = Item("VC_CoffeeRaw", "Barley", "$vc_raw", "$vc_raw_desc", null);
				CustomItem val3 = Item("VC_CoffeeDried", "Barley", "$vc_dry", "$vc_dry_desc", null);
				Visuals.Beans(val.ItemPrefab, 0);
				Visuals.Beans(val2.ItemPrefab, 1);
				Visuals.Beans(val3.ItemPrefab, 2);
				SetIcon(val);
				SetIcon(val2);
				SetIcon(val3);
				CustomItem val4 = Item("VC_FilterPaper", "LeatherScraps", "$vc_paper", "$vc_paper_desc", null);
				val4.ItemDrop.m_itemData.m_shared.m_weight = 0.01f;
				Visuals.Paper(val4.ItemPrefab);
				SetIcon(val4);
				ItemConfig val5 = new ItemConfig();
				val5.CraftingStation = "piece_workbench";
				val5.Requirements = (RequirementConfig[])(object)new RequirementConfig[1] { Req("Wood", 2) };
				CustomItem val6 = Item("VC_CoffeeCup", "Wood", "$vc_cup", "$vc_cup_desc", val5);
				val6.ItemDrop.m_itemData.m_shared.m_weight = 0.1f;
				Visuals.Cup(val6.ItemPrefab, 0);
				SetIcon(val6);
				AddPlant(val.ItemDrop.m_itemData.m_shared.m_icons[0]);
				AddDryer(val2.ItemDrop, val3.ItemDrop, val4.ItemDrop);
				AddStation("VC_CoffeeGrinder", "$vc_grinder", "$vc_grinder_desc", 0, (RequirementConfig[])(object)new RequirementConfig[3]
				{
					Req("Wood", 10),
					Req("Stone", 10),
					Req("Bronze", 2)
				}, needsFire: false);
				AddStation("VC_FrenchPress", "$vc_press", "$vc_press_desc", 1, (RequirementConfig[])(object)new RequirementConfig[3]
				{
					Req("FineWood", 10),
					Req("Iron", 4),
					Req("Bronze", 2)
				}, needsFire: true);
				AddStation("VC_CoffeeFilter", "$vc_filter", "$vc_filter_desc", 2, (RequirementConfig[])(object)new RequirementConfig[3]
				{
					Req("Wood", 10),
					Req("LeatherScraps", 4),
					Req("Iron", 2)
				}, needsFire: true);
				AddStation("VC_EspressoPress", "$vc_espresso_press", "$vc_espresso_press_desc", 3, (RequirementConfig[])(object)new RequirementConfig[3]
				{
					Req("FineWood", 15),
					Req("Iron", 10),
					Req("Bronze", 6)
				}, needsFire: true);
				val5 = new ItemConfig();
				val5.CraftingStation = "VC_CoffeeGrinder";
				val5.Requirements = (RequirementConfig[])(object)new RequirementConfig[1] { Req("VC_CoffeeDried", 1) };
				CustomItem obj = Item("VC_CoffeeGround", "Barley", "$vc_ground", "$vc_ground_desc", val5);
				Visuals.Beans(obj.ItemPrefab, 3);
				SetIcon(obj);
				CoffeeTier[] all = CoffeeTiers.All;
				foreach (CoffeeTier coffeeTier in all)
				{
					SE_Stats val7 = ScriptableObject.CreateInstance<SE_Stats>();
					((Object)val7).name = coffeeTier.EffectId;
					((StatusEffect)val7).m_name = coffeeTier.DisplayName;
					((StatusEffect)val7).m_category = "VC_Coffee";
					((StatusEffect)val7).m_tooltip = coffeeTier.Description;
					((StatusEffect)val7).m_ttl = 1800f;
					val7.m_staminaRegenMultiplier = coffeeTier.RegenMultiplier;
					((StatusEffect)val7).m_icon = val3.ItemDrop.m_itemData.m_shared.m_icons[0];
					if (!ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)val7, false)))
					{
						throw new InvalidOperationException("Cannot register " + coffeeTier.EffectId);
					}
					AddDrink(coffeeTier, (StatusEffect)(object)val7);
				}
				AddSeedRecipe(val.ItemDrop);
				AddStout();
				BeverageEffects.RegisterWarmth(val6.ItemDrop.m_itemData.m_shared.m_icons[0]);
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Coffee 0.4.0: cups, stout, wild coffee and nighttime warmth registered. Experimental build; see TESTING.md.");
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Coffee initialization failed. Do not save a world with missing content. " + ex));
				throw;
			}
		}

		private static RequirementConfig Req(string item, int count)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: 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_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			return new RequirementConfig
			{
				Item = item,
				Amount = count,
				Recover = true
			};
		}

		internal static GameObject RequirePrefab(string name)
		{
			return PrefabManager.Instance.GetPrefab(name) ?? throw new InvalidOperationException("Missing vanilla prefab: " + name);
		}

		private static CustomItem Item(string id, string original, string name, string description, ItemConfig config)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			//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_0073: Unknown result type (might be due to invalid IL or missing references)
			config = (ItemConfig)(((object)config) ?? ((object)new ItemConfig
			{
				Enabled = false
			}));
			config.Name = name;
			config.Description = description;
			config.StackSize = 50;
			config.Weight = 0.1f;
			CustomItem val = new CustomItem(id, original, config);
			if (!ItemManager.Instance.AddItem(val))
			{
				throw new InvalidOperationException("Cannot register " + id);
			}
			SharedData shared = val.ItemDrop.m_itemData.m_shared;
			shared.m_itemType = (ItemType)1;
			shared.m_food = 0f;
			shared.m_foodStamina = 0f;
			shared.m_consumeStatusEffect = null;
			return val;
		}

		private static void SetIcon(CustomItem item)
		{
			Sprite val = Visuals.Icon(item.ItemPrefab, itemIcon: true);
			if ((Object)(object)val != (Object)null)
			{
				item.ItemDrop.m_itemData.m_shared.m_icons = (Sprite[])(object)new Sprite[1] { val };
			}
		}

		private static void AddPlant(Sprite icon)
		{
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Expected O, but got Unknown
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Expected O, but got Unknown
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Expected O, but got Unknown
			GameObject val = PrefabManager.Instance.CreateClonedPrefab("VC_CoffeePlantMature", "Pickable_Barley");
			Pickable component = val.GetComponent<Pickable>();
			Fields.Set(component, "m_itemPrefab", RequirePrefab("VC_CoffeeRaw"));
			Fields.Set(component, "m_amount", 3);
			Fields.Set(component, "m_respawnTimeMinutes", 0f);
			Fields.Set(component, "m_overrideName", "$vc_raw");
			Fields.Set(component, "m_extraDrops", (object)new DropTable());
			Visuals.CoffeePlant(val);
			PrefabManager.Instance.AddPrefab(new CustomPrefab(val, false));
			WildCoffee.Register(val);
			PieceConfig val2 = new PieceConfig();
			val2.Name = "$vc_raw";
			val2.Description = "$vc_plant_desc";
			val2.PieceTable = "Cultivator";
			val2.Icon = Visuals.Icon(val) ?? icon;
			val2.Requirements = (RequirementConfig[])(object)new RequirementConfig[1] { Req("VC_CoffeeSeed", 1) };
			PieceConfig val3 = val2;
			val3.Requirements[0].Recover = false;
			CustomPiece val4 = new CustomPiece("VC_CoffeePlant", "sapling_carrot", val3);
			Plant component2 = val4.PiecePrefab.GetComponent<Plant>();
			Fields.Set(component2, "m_name", "$vc_raw");
			Fields.Set(component2, "m_grownPrefabs", new GameObject[1] { val });
			Fields.Set(component2, "m_growTime", 3600f);
			Fields.Set(component2, "m_growTimeMax", 4800f);
			Fields.Set(component2, "m_growRadius", 0.8f);
			Fields.Set(component2, "m_minScale", 0.95f);
			Fields.Set(component2, "m_maxScale", 1.05f);
			Fields.Set(component2, "m_biome", (object)(Biome)9);
			Fields.Set(component2, "m_needCultivatedGround", true);
			PieceManager.Instance.AddPiece(val4);
		}

		private static void AddDryer(ItemDrop raw, ItemDrop dry, ItemDrop paper)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Expected O, but got Unknown
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: 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_0122: Expected O, but got Unknown
			//IL_0123: 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_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_0154: Expected O, but got Unknown
			PieceConfig val = new PieceConfig();
			val.Name = "$vc_dryer";
			val.Description = "$vc_dryer_desc";
			val.PieceTable = "Hammer";
			val.Category = "Crafting";
			val.CraftingStation = "piece_workbench";
			val.Requirements = (RequirementConfig[])(object)new RequirementConfig[2]
			{
				Req("Wood", 8),
				Req("Bronze", 2)
			};
			CustomPiece val2 = new CustomPiece("VC_GrainDryer", "piece_cookingstation", val);
			CookingStation component = val2.PiecePrefab.GetComponent<CookingStation>();
			Fields.Set(component, "m_name", "$vc_dryer");
			Fields.Set(component, "m_requireFire", true);
			Fields.Set(component, "m_canOvercookItems", false);
			Fields.Set(component, "m_canGiveBonusYield", false);
			Fields.Set(component, "m_addItemTooltip", "$vc_dryer_add");
			Fields.Set(component, "m_noCookableItemsMessage", "$vc_dryer_empty");
			Fields.Set(component, "m_fullyCookedTooltip", "$vc_dryer_ready");
			Fields.Set(component, "m_conversion", new List<ItemConversion>
			{
				new ItemConversion
				{
					m_from = raw,
					m_to = dry,
					m_cookTime = 60f
				},
				new ItemConversion
				{
					m_from = RequirePrefab("Dandelion").GetComponent<ItemDrop>(),
					m_to = paper,
					m_cookTime = 30f
				}
			});
			Visuals.Dryer(val2.PiecePrefab);
			Sprite val3 = Visuals.Icon(val2.PiecePrefab);
			if ((Object)(object)val3 != (Object)null)
			{
				val2.Piece.m_icon = val3;
			}
			PieceManager.Instance.AddPiece(val2);
		}

		private static void AddStation(string id, string name, string desc, int visual, RequirementConfig[] requirements, bool needsFire)
		{
			//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_0012: 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_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: 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_0047: Expected O, but got Unknown
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			CustomPiece val = new CustomPiece(id, "piece_workbench", new PieceConfig
			{
				Name = name,
				Description = desc,
				PieceTable = "Hammer",
				Category = "Crafting",
				CraftingStation = "piece_workbench",
				Requirements = requirements
			});
			CraftingStation component = val.PiecePrefab.GetComponent<CraftingStation>();
			Fields.Set(component, "m_name", name);
			Fields.Set(component, "m_craftRequireRoof", false);
			Fields.Set(component, "m_craftRequireFire", needsFire);
			Fields.Set(component, "m_showBasicRecipies", false);
			Fields.Set(component, "m_useDistance", 3f);
			Fields.Set(component, "m_canRepair", false);
			Visuals.Station(val.PiecePrefab, visual);
			Sprite val2 = Visuals.Icon(val.PiecePrefab);
			if ((Object)(object)val2 != (Object)null)
			{
				val.Piece.m_icon = val2;
			}
			PieceManager.Instance.AddPiece(val);
		}

		private static void AddDrink(CoffeeTier tier, StatusEffect effect)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Expected O, but got Unknown
			string itemId = tier.ItemId;
			ItemConfig val = new ItemConfig();
			val.Name = tier.DisplayName;
			val.Description = tier.Description;
			val.CraftingStation = tier.StationId;
			val.Amount = 1;
			val.StackSize = 20;
			val.Weight = 0.2f;
			val.Requirements = (RequirementConfig[])(object)((!(tier.StationId == "VC_CoffeeFilter")) ? new RequirementConfig[2]
			{
				Req("VC_CoffeeGround", 1),
				Req("VC_CoffeeCup", 1)
			} : new RequirementConfig[3]
			{
				Req("VC_CoffeeGround", 1),
				Req("VC_FilterPaper", 1),
				Req("VC_CoffeeCup", 1)
			});
			CustomItem val2 = new CustomItem(itemId, "MeadTasty", val);
			SharedData shared = val2.ItemDrop.m_itemData.m_shared;
			shared.m_consumeStatusEffect = effect;
			shared.m_food = 0f;
			shared.m_foodStamina = 0f;
			Visuals.Cup(val2.ItemPrefab, tier.Rank);
			SetIcon(val2);
			effect.m_icon = shared.m_icons[0];
			if (!ItemManager.Instance.AddItem(val2))
			{
				throw new InvalidOperationException("Cannot register " + tier.ItemId);
			}
		}

		private static void AddStout()
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: 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_0097: Expected O, but got Unknown
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Expected O, but got Unknown
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Expected O, but got Unknown
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Expected O, but got Unknown
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Expected O, but got Unknown
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Expected O, but got Unknown
			SE_Stats val = ScriptableObject.CreateInstance<SE_Stats>();
			((Object)val).name = "VC_StoutEffect";
			((StatusEffect)val).m_name = "$vc_stout";
			((StatusEffect)val).m_category = "VC_Stout";
			((StatusEffect)val).m_ttl = 1800f;
			val.m_staminaRegenMultiplier = 1.3f;
			((StatusEffect)val).m_tooltip = "$vc_stout_effect_desc";
			CustomItem val2 = new CustomItem("VC_CoffeeStout", "MeadTasty", new ItemConfig
			{
				Name = "$vc_stout",
				Description = ((StatusEffect)val).m_tooltip + "$vc_stout_drink_hint",
				Enabled = false,
				StackSize = 20,
				Weight = 0.3f
			});
			SharedData shared = val2.ItemDrop.m_itemData.m_shared;
			shared.m_itemType = (ItemType)2;
			shared.m_food = 0f;
			shared.m_foodStamina = 0f;
			shared.m_foodEitr = 0f;
			shared.m_consumeStatusEffect = (StatusEffect)(object)val;
			shared.m_ammoType = RequirePrefab("Tankard").GetComponent<ItemDrop>().m_itemData.m_shared.m_ammoType;
			Visuals.StoutTankard(val2.ItemPrefab);
			SetIcon(val2);
			((StatusEffect)val).m_icon = shared.m_icons[0];
			if (!ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)val, false)) || !ItemManager.Instance.AddItem(val2))
			{
				throw new InvalidOperationException("Cannot register coffee stout");
			}
			ItemConfig val3 = new ItemConfig();
			val3.CraftingStation = "piece_cauldron";
			val3.Requirements = (RequirementConfig[])(object)new RequirementConfig[3]
			{
				Req("VC_CoffeeGround", 4),
				Req("Barley", 6),
				Req("Honey", 4)
			};
			SetIcon(Item("VC_CoffeeStoutBase", "MeadBaseTasty", "$vc_wort", "$vc_wort_desc", val3));
			if (!ItemManager.Instance.AddItemConversion(new CustomItemConversion((ConversionConfig)new FermenterConversionConfig
			{
				Station = "fermenter",
				FromItem = "VC_CoffeeStoutBase",
				ToItem = "VC_CoffeeStout",
				ProducedItems = 6
			})))
			{
				throw new InvalidOperationException("Cannot register stout fermentation");
			}
		}

		private static void AddSeedRecipe(ItemDrop seed)
		{
			//IL_004b: 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_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: 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
			Recipe val = ScriptableObject.CreateInstance<Recipe>();
			((Object)val).name = "Recipe_VC_SeparateSeeds";
			val.m_item = seed;
			val.m_amount = 2;
			val.m_enabled = true;
			val.m_minStationLevel = 1;
			val.m_craftingStation = RequirePrefab("piece_workbench").GetComponent<CraftingStation>();
			val.m_resources = (Requirement[])(object)new Requirement[1]
			{
				new Requirement
				{
					m_resItem = RequirePrefab("VC_CoffeeRaw").GetComponent<ItemDrop>(),
					m_amount = 1
				}
			};
			ItemManager.Instance.AddRecipe(new CustomRecipe(val, false, false));
		}
	}
	internal static class Fields
	{
		internal static void Set(object target, string name, object value)
		{
			if (target == null)
			{
				throw new ArgumentNullException("target", name);
			}
			FieldInfo fieldInfo = AccessTools.Field(target.GetType(), name);
			if (fieldInfo == null)
			{
				throw new MissingFieldException(target.GetType().FullName, name);
			}
			if (fieldInfo.FieldType == typeof(GameObject))
			{
				Component val = (Component)((value is Component) ? value : null);
				if (val != null)
				{
					value = val.gameObject;
					goto IL_0091;
				}
			}
			if (typeof(Component).IsAssignableFrom(fieldInfo.FieldType))
			{
				GameObject val2 = (GameObject)((value is GameObject) ? value : null);
				if (val2 != null)
				{
					value = val2.GetComponent(fieldInfo.FieldType);
				}
			}
			goto IL_0091;
			IL_0091:
			fieldInfo.SetValue(target, value);
		}
	}
	internal static class Visuals
	{
		private static Mesh beanMesh;

		internal static Sprite Icon(GameObject prefab, bool itemIcon = false)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: 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_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Expected O, but got Unknown
			if ((int)SystemInfo.graphicsDeviceType == 4)
			{
				return null;
			}
			Transform val = ((IEnumerable<Transform>)prefab.GetComponentsInChildren<Transform>(true)).FirstOrDefault((Func<Transform, bool>)((Transform t) => ((Object)t).name == "CoffeeVisual"));
			return RenderManager.Instance.Render(new RenderRequest(((Object)(object)val != (Object)null) ? ((Component)val).gameObject : prefab)
			{
				Rotation = RenderManager.IsometricRotation,
				Width = (itemIcon ? 256 : 128),
				Height = (itemIcon ? 256 : 128),
				DistanceMultiplier = (itemIcon ? 1.15f : 1f),
				UseCache = false
			});
		}

		private static Material NativeMaterial(string prefab, Color tint)
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected O, but got Unknown
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			Material? obj = Plugin.RequirePrefab(prefab).GetComponentsInChildren<MeshRenderer>(true).SelectMany((MeshRenderer r) => ((Renderer)r).sharedMaterials)
				.FirstOrDefault((Func<Material, bool>)((Material m) => (Object)(object)m != (Object)null));
			if ((Object)(object)obj == (Object)null)
			{
				throw new InvalidOperationException("No mesh material in " + prefab);
			}
			Material val = new Material(obj);
			if (val.HasProperty("_Color"))
			{
				val.SetColor("_Color", tint);
			}
			return val;
		}

		internal static void Tint(GameObject root, Color tint)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			MeshRenderer[] componentsInChildren = root.GetComponentsInChildren<MeshRenderer>(true);
			foreach (MeshRenderer obj in componentsInChildren)
			{
				((Renderer)obj).sharedMaterials = ((IEnumerable<Material>)((Renderer)obj).sharedMaterials).Select((Func<Material, Material>)delegate(Material source)
				{
					//IL_000c: Unknown result type (might be due to invalid IL or missing references)
					//IL_0012: Expected O, but got Unknown
					//IL_0026: Unknown result type (might be due to invalid IL or missing references)
					if ((Object)(object)source == (Object)null)
					{
						return (Material)null;
					}
					Material val = new Material(source);
					if (val.HasProperty("_Color"))
					{
						val.SetColor("_Color", tint);
					}
					return val;
				}).ToArray();
			}
		}

		private static Material PlainMaterial(string original, Color tint)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			Material obj = NativeMaterial(original, tint);
			obj.mainTexture = (Texture)(object)Texture2D.whiteTexture;
			return obj;
		}

		internal static void Cup(GameObject prefab, int kind)
		{
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: 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_00dd: 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_0100: 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_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			Transform parent = VisualRoot(prefab);
			bool flag = kind == 3;
			float num = (flag ? 0.13f : ((kind == 2) ? 0.22f : 0.2f));
			float num2 = (flag ? 0.17f : ((kind == 2) ? 0.25f : 0.23f));
			Material material = PlainMaterial("Wood", (kind == 2) ? new Color(0.43f, 0.27f, 0.14f) : new Color(0.72f, 0.53f, 0.3f));
			Material material2 = PlainMaterial(flag ? "Bronze" : "Iron", (Color)(flag ? new Color(0.8f, 0.6f, 0.3f) : Color.gray));
			Material val = PlainMaterial("Wood", flag ? new Color(0.48f, 0.27f, 0.1f) : new Color(0.1f, 0.045f, 0.015f));
			Frustum(parent, "CarvedCup", new Vector3(0f, num / 2f, 0f), num2 * 0.37f, num2 / 2f, num, material);
			Cylinder(parent, "CupInterior", new Vector3(0f, num + 0.001f, 0f), num2 * 0.84f, 0.002f, (kind == 0) ? PlainMaterial("Wood", new Color(0.22f, 0.12f, 0.055f)) : val);
			for (int i = 0; i < 5; i++)
			{
				float num3 = (-75f + (float)i * 37.5f) * (MathF.PI / 180f);
				Shape(parent, "CupHandle", (PrimitiveType)3, new Vector3(num2 * 0.43f + Mathf.Cos(num3) * num * 0.35f, num * 0.54f + Mathf.Sin(num3) * num * 0.32f, 0f), new Vector3(0.027f, num * 0.26f, 0.025f), material).localRotation = Quaternion.Euler(0f, 0f, num3 * 57.29578f);
			}
			if (kind == 2 || flag)
			{
				Cylinder(parent, "MetalFoot", new Vector3(0f, 0.022f, 0f), num2 * 0.8f, 0.025f, material2);
			}
			if (flag)
			{
				Cylinder(parent, "WoodenSaucer", new Vector3(0f, -0.01f, 0f), num2 * 1.55f, 0.018f, material);
				Material material3 = PlainMaterial("Wood", new Color(0.8f, 0.56f, 0.26f));
				for (int j = 0; j < 7; j++)
				{
					float num4 = (float)j * 2.399963f;
					Shape(parent, "Crema", (PrimitiveType)0, new Vector3(Mathf.Cos(num4) * 0.035f, num + 0.003f, Mathf.Sin(num4) * 0.035f), new Vector3(0.022f, 0.0015f, 0.018f), material3);
				}
			}
		}

		internal static void StoutTankard(GameObject prefab)
		{
			//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_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: 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_0176: 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_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			Transform val = VisualRoot(prefab);
			Transform obj = Plugin.RequirePrefab("Tankard").transform.Find("attach");
			if ((Object)(object)obj == (Object)null)
			{
				throw new InvalidOperationException("Tankard attach model was not found");
			}
			GameObject val2 = Object.Instantiate<GameObject>(((Component)obj).gameObject, val, false);
			((Object)val2).name = "VanillaWoodenTankard";
			Component[] componentsInChildren = val2.GetComponentsInChildren<Component>(true);
			foreach (Component val3 in componentsInChildren)
			{
				if (!(val3 is Transform) && !(val3 is MeshFilter) && !(val3 is MeshRenderer) && !(val3 is SkinnedMeshRenderer) && !(val3 is LODGroup))
				{
					Object.DestroyImmediate((Object)(object)val3);
				}
			}
			val2.SetActive(true);
			Bounds val4 = LocalBounds(val2);
			float num = Mathf.Min(((Bounds)(ref val4)).size.x, ((Bounds)(ref val4)).size.z) * 0.72f;
			Vector3 center = ((Bounds)(ref val4)).center;
			center.y = ((Bounds)(ref val4)).max.y - ((Bounds)(ref val4)).size.y * 0.1f;
			Material material = PlainMaterial("Wood", new Color(0.035f, 0.015f, 0.008f));
			Material material2 = PlainMaterial("Wood", new Color(0.76f, 0.58f, 0.37f));
			Cylinder(val2.transform, "DarkStout", center, num, ((Bounds)(ref val4)).size.y * 0.06f, material);
			center.y += ((Bounds)(ref val4)).size.y * 0.045f;
			Cylinder(val2.transform, "StoutFoam", center, num * 0.96f, ((Bounds)(ref val4)).size.y * 0.035f, material2);
			for (int j = 0; j < 19; j++)
			{
				float num2 = (float)j * 2.399963f;
				float num3 = num * 0.085f * Mathf.Sqrt((float)j);
				Pebble(val2.transform, "FoamBubble", center + new Vector3(Mathf.Cos(num2) * num3, ((Bounds)(ref val4)).size.y * 0.022f, Mathf.Sin(num2) * num3), new Vector3(num * 0.14f, ((Bounds)(ref val4)).size.y * 0.022f, num * 0.13f), material2);
			}
		}

		private static Transform VisualRoot(GameObject prefab)
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			LODGroup[] componentsInChildren = prefab.GetComponentsInChildren<LODGroup>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				componentsInChildren[i].enabled = false;
			}
			Renderer[] componentsInChildren2 = prefab.GetComponentsInChildren<Renderer>(true);
			for (int i = 0; i < componentsInChildren2.Length; i++)
			{
				componentsInChildren2[i].enabled = false;
			}
			Transform transform = new GameObject("CoffeeVisual").transform;
			transform.SetParent(prefab.transform.Find("attach") ?? prefab.transform, false);
			return transform;
		}

		private static Transform Pebble(Transform parent, string name, Vector3 position, Vector3 scale, Material material)
		{
			//IL_0158: 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_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: 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_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)beanMesh == (Object)null)
			{
				List<Vector3> list = new List<Vector3>();
				List<int> list2 = new List<int>();
				for (int i = 0; i < 6; i++)
				{
					for (int j = 0; j < 10; j++)
					{
						Vector3[] array = (Vector3[])(object)new Vector3[4];
						for (int k = 0; k < 4; k++)
						{
							float num = MathF.PI * (float)(i + ((k >= 2) ? 1 : 0)) / 6f;
							float num2 = MathF.PI * 2f * (float)(j + ((k == 1 || k == 2) ? 1 : 0)) / 10f;
							array[k] = new Vector3(Mathf.Sin(num) * Mathf.Cos(num2), Mathf.Cos(num), Mathf.Sin(num) * Mathf.Sin(num2)) * 0.5f;
						}
						int[] array2 = new int[6] { 0, 1, 2, 0, 2, 3 };
						foreach (int num3 in array2)
						{
							list2.Add(list.Count);
							list.Add(array[num3]);
						}
					}
				}
				beanMesh = new Mesh
				{
					name = "VC_FacetedBean",
					vertices = list.ToArray(),
					triangles = list2.ToArray()
				};
				beanMesh.RecalculateNormals();
				beanMesh.RecalculateBounds();
			}
			GameObject val = new GameObject(name);
			val.transform.SetParent(parent, false);
			val.transform.localPosition = position;
			val.transform.localScale = scale;
			val.layer = ((Component)parent).gameObject.layer;
			val.AddComponent<MeshFilter>().sharedMesh = beanMesh;
			((Renderer)val.AddComponent<MeshRenderer>()).sharedMaterial = material;
			return val.transform;
		}

		private static void Bean(Transform parent, Vector3 position, Quaternion rotation, float size, Material body, Material groove)
		{
			//IL_0005: 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_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: 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_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			Transform transform = new GameObject("CoffeeBean").transform;
			transform.SetParent(parent, false);
			transform.localPosition = position;
			transform.localRotation = rotation;
			transform.localScale = Vector3.one * size;
			((Component)transform).gameObject.layer = ((Component)parent).gameObject.layer;
			Pebble(transform, "BeanBody", Vector3.zero, new Vector3(0.76f, 0.48f, 1.12f), body);
			for (int i = 0; i < 5; i++)
			{
				float num = (float)(i - 2) * 0.15f;
				Pebble(transform, "BeanSeam", new Vector3(Mathf.Sin((float)i * 1.1f) * 0.025f, 0.241f - Mathf.Abs(num) * 0.14f, num), new Vector3(0.048f, 0.022f, 0.19f), groove);
			}
		}

		internal static void Beans(GameObject prefab, int stage)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: 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)
			//IL_003e: 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)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: 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)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: 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_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			Transform parent = VisualRoot(prefab);
			Color[] array = (Color[])(object)new Color[4]
			{
				new Color(0.56f, 0.39f, 0.2f),
				new Color(0.48f, 0.24f, 0.1f),
				new Color(0.25f, 0.105f, 0.045f),
				new Color(0.18f, 0.075f, 0.03f)
			};
			Material val = PlainMaterial("Wood", array[stage]);
			Material groove = PlainMaterial("Wood", new Color(0.065f, 0.025f, 0.009f));
			if (stage == 3)
			{
				for (int i = 0; i < 32; i++)
				{
					float num = (float)i * 2.399963f;
					float num2 = 0.014f * Mathf.Sqrt((float)i);
					Pebble(parent, "CoffeeGround", new Vector3(Mathf.Cos(num) * num2, 0.016f + (1f - num2 / 0.09f) * 0.028f, Mathf.Sin(num) * num2), new Vector3(0.033f, 0.021f, 0.03f), val);
				}
			}
			else
			{
				Bean(parent, new Vector3(-0.042f, 0.025f, 0f), Quaternion.Euler(0f, -22f, 0f), 0.1f, val, groove);
				Bean(parent, new Vector3(0.043f, 0.026f, 0.015f), Quaternion.Euler(0f, 24f, 0f), 0.1f, val, groove);
			}
		}

		private static void FilterModel(Transform parent)
		{
			//IL_0014: 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_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			Material material = PlainMaterial("LeatherScraps", new Color(0.84f, 0.8f, 0.68f));
			Material material2 = PlainMaterial("Wood", new Color(0.3f, 0.14f, 0.065f));
			Frustum(parent, "ClothFilter", new Vector3(0f, 0.1f, 0f), 0.025f, 0.13f, 0.2f, material, capped: false);
			for (int i = 0; i < 12; i++)
			{
				float num = (float)i * MathF.PI * 2f / 12f;
				Shape(parent, "WoodenFilterRim", (PrimitiveType)3, new Vector3(Mathf.Cos(num) * 0.132f, 0.2f, Mathf.Sin(num) * 0.132f), new Vector3(0.075f, 0.018f, 0.018f), material2).localRotation = Quaternion.Euler(0f, (0f - num) * 57.29578f + 90f, 0f);
			}
			Shape(parent, "FilterHandle", (PrimitiveType)3, new Vector3(0.19f, 0.2f, 0f), new Vector3(0.13f, 0.018f, 0.025f), material2);
		}

		internal static void Paper(GameObject prefab)
		{
			FilterModel(VisualRoot(prefab));
		}

		private static Bounds LocalBounds(GameObject prefab)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			Bounds result = default(Bounds);
			bool flag = false;
			MeshFilter[] componentsInChildren = prefab.GetComponentsInChildren<MeshFilter>(true);
			foreach (MeshFilter val in componentsInChildren)
			{
				if ((Object)(object)val.sharedMesh == (Object)null)
				{
					continue;
				}
				Bounds bounds = val.sharedMesh.bounds;
				for (int j = -1; j <= 1; j += 2)
				{
					for (int k = -1; k <= 1; k += 2)
					{
						for (int l = -1; l <= 1; l += 2)
						{
							Vector3 val2 = prefab.transform.InverseTransformPoint(((Component)val).transform.TransformPoint(((Bounds)(ref bounds)).center + Vector3.Scale(((Bounds)(ref bounds)).extents, new Vector3((float)j, (float)k, (float)l))));
							if (!flag)
							{
								((Bounds)(ref result))..ctor(val2, Vector3.zero);
								flag = true;
							}
							else
							{
								((Bounds)(ref result)).Encapsulate(val2);
							}
						}
					}
				}
			}
			return result;
		}

		internal static void CoffeePlant(GameObject prefab)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: 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_0077: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: 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_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			Bounds val = LocalBounds(prefab);
			Pickable component = prefab.GetComponent<Pickable>();
			object? obj = AccessTools.Field(typeof(Pickable), "m_hideWhenPicked")?.GetValue(component);
			GameObject val2 = (GameObject)((obj is GameObject) ? obj : null);
			Transform transform = new GameObject("CoffeeBeanClusters").transform;
			transform.SetParent(((Object)(object)val2 != (Object)null) ? val2.transform : prefab.transform, false);
			Material body = PlainMaterial("Wood", new Color(0.36f, 0.16f, 0.06f));
			Material groove = PlainMaterial("Wood", new Color(0.065f, 0.025f, 0.009f));
			float num = Mathf.Max(((Bounds)(ref val)).size.y, 0.5f);
			float num2 = Mathf.Min(Mathf.Max(((Bounds)(ref val)).size.x, ((Bounds)(ref val)).size.z) * 0.22f, num * 0.16f);
			for (int i = 0; i < 15; i++)
			{
				float num3 = (float)i * 2.399963f;
				Vector3 val3 = ((Bounds)(ref val)).center + new Vector3(Mathf.Cos(num3) * num2, num * (0.05f + (float)(i % 3) * 0.1f), Mathf.Sin(num3) * num2);
				Vector3 position = transform.InverseTransformPoint(prefab.transform.TransformPoint(val3));
				Bean(transform, position, Quaternion.Euler(65f, (float)(i * 47), 0f), Mathf.Min(num * 0.065f, 0.1f), body, groove);
			}
		}

		internal static void Dryer(GameObject prefab)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			Material material = NativeMaterial("Wood", new Color(0.48f, 0.32f, 0.19f));
			for (int i = -1; i <= 1; i += 2)
			{
				for (int j = 0; j < 5; j++)
				{
					Shape(prefab.transform, "DryingSlat", (PrimitiveType)3, new Vector3((float)i * 0.28f, 0.65f, (float)(j - 2) * 0.075f), new Vector3(0.42f, 0.022f, 0.045f), material);
				}
			}
		}

		internal static void Station(GameObject prefab, int kind)
		{
			//IL_001b: 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_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: 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_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_035e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0372: Unknown result type (might be due to invalid IL or missing references)
			//IL_0394: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03db: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0434: Unknown result type (might be due to invalid IL or missing references)
			//IL_0456: Unknown result type (might be due to invalid IL or missing references)
			//IL_046a: Unknown result type (might be due to invalid IL or missing references)
			//IL_048b: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0311: Unknown result type (might be due to invalid IL or missing references)
			//IL_0325: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_05dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0608: Unknown result type (might be due to invalid IL or missing references)
			//IL_0633: Unknown result type (might be due to invalid IL or missing references)
			//IL_0647: Unknown result type (might be due to invalid IL or missing references)
			//IL_0665: Unknown result type (might be due to invalid IL or missing references)
			//IL_0685: Unknown result type (might be due to invalid IL or missing references)
			//IL_0699: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_06da: Unknown result type (might be due to invalid IL or missing references)
			//IL_06fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0727: Unknown result type (might be due to invalid IL or missing references)
			//IL_073b: Unknown result type (might be due to invalid IL or missing references)
			//IL_075c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0787: Unknown result type (might be due to invalid IL or missing references)
			//IL_055e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0563: Unknown result type (might be due to invalid IL or missing references)
			//IL_056d: Unknown result type (might be due to invalid IL or missing references)
			Transform val = VisualRoot(prefab);
			Material material = NativeMaterial("Wood", new Color(0.53f, 0.37f, 0.23f));
			Material material2 = NativeMaterial("Iron", new Color(0.4f, 0.4f, 0.37f));
			Material material3 = NativeMaterial("Stone", new Color(0.58f, 0.57f, 0.53f));
			NativeMaterial("LeatherScraps", new Color(0.65f, 0.47f, 0.27f));
			Shape(val, "TableTop", (PrimitiveType)3, new Vector3(0f, 0.75f, 0f), new Vector3(1f, 0.09f, 0.65f), material);
			for (int i = -1; i <= 1; i += 2)
			{
				for (int j = -1; j <= 1; j += 2)
				{
					Shape(val, "Leg", (PrimitiveType)3, new Vector3((float)i * 0.4f, 0.35f, (float)j * 0.22f), new Vector3(0.1f, 0.7f, 0.1f), material);
				}
			}
			switch (kind)
			{
			case 0:
				Cylinder(val, "LowerMillstone", new Vector3(0f, 0.88f, 0f), 0.45f, 0.12f, material3);
				Cylinder(val, "UpperMillstone", new Vector3(0f, 1f, 0f), 0.41f, 0.1f, material3);
				Cylinder(val, "Axle", new Vector3(0f, 1.11f, 0f), 0.05f, 0.18f, material2);
				Shape(val, "Crank", (PrimitiveType)3, new Vector3(0.14f, 1.2f, 0f), new Vector3(0.3f, 0.04f, 0.06f), material2);
				Cylinder(val, "Grip", new Vector3(0.27f, 1.25f, 0f), 0.055f, 0.15f, material);
				break;
			case 1:
			{
				Cylinder(val, "PressVessel", new Vector3(0f, 1.02f, 0f), 0.3f, 0.42f, material2);
				Cylinder(val, "Lid", new Vector3(0f, 1.25f, 0f), 0.34f, 0.035f, material2);
				Cylinder(val, "PlungerRod", new Vector3(0f, 1.36f, 0f), 0.025f, 0.22f, material2);
				Shape(val, "PlungerKnob", (PrimitiveType)0, new Vector3(0f, 1.48f, 0f), Vector3.one * 0.075f, material);
				Shape(val, "Handle", (PrimitiveType)3, new Vector3(0.23f, 1.04f, 0f), new Vector3(0.055f, 0.27f, 0.07f), material);
				for (int m = -1; m <= 1; m += 2)
				{
					Shape(val, "HandleBracket", (PrimitiveType)3, new Vector3(0.18f, 1.04f + (float)m * 0.12f, 0f), new Vector3(0.12f, 0.03f, 0.04f), material2);
				}
				break;
			}
			case 2:
			{
				Shape(val, "FilterPost", (PrimitiveType)3, new Vector3(-0.25f, 1.08f, 0f), new Vector3(0.055f, 0.58f, 0.07f), material);
				Shape(val, "FilterArm", (PrimitiveType)3, new Vector3(-0.03f, 1.35f, 0f), new Vector3(0.49f, 0.055f, 0.07f), material);
				Transform transform = new GameObject("FilterAssembly").transform;
				transform.SetParent(val, false);
				transform.localPosition = new Vector3(0.1f, 1.05f, 0f);
				FilterModel(transform);
				Cylinder(val, "ReceivingCup", new Vector3(0.1f, 0.88f, 0f), 0.18f, 0.15f, material2);
				break;
			}
			case 3:
			{
				Material material4 = NativeMaterial("Bronze", new Color(0.67f, 0.43f, 0.2f));
				Shape(val, "EspressoBase", (PrimitiveType)3, new Vector3(0f, 0.82f, 0f), new Vector3(0.8f, 0.07f, 0.46f), material2);
				Cylinder(val, "RivetedBoiler", new Vector3(-0.21f, 1.1f, 0.03f), 0.3f, 0.48f, material4);
				Cylinder(val, "BoilerLid", new Vector3(-0.21f, 1.36f, 0.03f), 0.34f, 0.035f, material2);
				Cylinder(val, "LidKnob", new Vector3(-0.21f, 1.41f, 0.03f), 0.065f, 0.07f, material);
				float[] array = new float[2] { 0.91f, 1.28f };
				foreach (float num in array)
				{
					for (int l = 0; l < 8; l++)
					{
						float num2 = (float)l * MathF.PI / 4f;
						Shape(val, "BoilerRivet", (PrimitiveType)0, new Vector3(-0.21f + Mathf.Cos(num2) * 0.151f, num, 0.03f + Mathf.Sin(num2) * 0.151f), Vector3.one * 0.025f, material2);
					}
				}
				Shape(val, "PistonSupport", (PrimitiveType)3, new Vector3(0.18f, 1.1f, 0.13f), new Vector3(0.06f, 0.51f, 0.07f), material2);
				Cylinder(val, "PressureChamber", new Vector3(0.18f, 1.2f, -0.06f), 0.15f, 0.25f, material4);
				Cylinder(val, "PistonShaft", new Vector3(0.18f, 1.41f, -0.06f), 0.025f, 0.18f, material2);
				Transform val2 = Shape(val, "ManualLever", (PrimitiveType)3, new Vector3(0.28f, 1.51f, -0.06f), new Vector3(0.45f, 0.04f, 0.045f), material2);
				val2.localRotation = Quaternion.Euler(0f, 0f, 22f);
				Shape(val, "WoodenLeverGrip", (PrimitiveType)3, new Vector3(0.49f, 1.59f, -0.06f), new Vector3(0.14f, 0.065f, 0.07f), material).localRotation = val2.localRotation;
				Shape(val, "HotWaterPipe", (PrimitiveType)3, new Vector3(-0.015f, 1.2f, -0.06f), new Vector3(0.27f, 0.04f, 0.04f), material4);
				Cylinder(val, "CoffeeBasket", new Vector3(0.18f, 1.06f, -0.06f), 0.19f, 0.055f, material2);
				Shape(val, "BasketHandle", (PrimitiveType)3, new Vector3(0.34f, 1.06f, -0.06f), new Vector3(0.2f, 0.04f, 0.045f), material);
				Cylinder(val, "CoffeeSpout", new Vector3(0.18f, 1f, -0.06f), 0.025f, 0.07f, material4);
				Cylinder(val, "EspressoCup", new Vector3(0.18f, 0.9f, -0.06f), 0.13f, 0.09f, material2);
				break;
			}
			}
			Collider[] componentsInChildren = prefab.GetComponentsInChildren<Collider>(true);
			foreach (Collider val3 in componentsInChildren)
			{
				if (!val3.isTrigger)
				{
					val3.enabled = false;
				}
			}
			BoxCollider obj = prefab.AddComponent<BoxCollider>();
			obj.center = new Vector3(0f, 0.65f, 0f);
			obj.size = new Vector3(1f, 1.3f, 0.65f);
		}

		private static Transform Shape(Transform parent, string name, PrimitiveType type, Vector3 position, Vector3 scale, Material material)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = GameObject.CreatePrimitive(type);
			((Object)obj).name = name;
			obj.transform.SetParent(parent, false);
			obj.transform.localPosition = position;
			obj.transform.localScale = scale;
			Object.DestroyImmediate((Object)(object)obj.GetComponent<Collider>());
			((Renderer)obj.GetComponent<MeshRenderer>()).sharedMaterial = material;
			obj.layer = ((Component)parent).gameObject.layer;
			return obj.transform;
		}

		private static void Cylinder(Transform parent, string name, Vector3 position, float diameter, float height, Material material)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			Frustum(parent, name, position, diameter / 2f, diameter / 2f, height, material);
		}

		private static void Frustum(Transform parent, string name, Vector3 position, float bottomRadius, float topRadius, float height, Material material, bool capped = true)
		{
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: 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_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: 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_015f: 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_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: Expected O, but got Unknown
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_0296: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02af: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: 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_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: 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_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: 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_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			Vector3[] array = (Vector3[])(object)new Vector3[96];
			Vector2[] array2 = (Vector2[])(object)new Vector2[array.Length];
			int[] array3 = new int[array.Length];
			Vector3 val = default(Vector3);
			Vector3 val2 = default(Vector3);
			Vector3 val3 = default(Vector3);
			Vector3 val4 = default(Vector3);
			for (int i = 0; i < 8; i++)
			{
				float num = (float)i * MathF.PI * 2f / 8f;
				float num2 = (float)(i + 1) * MathF.PI * 2f / 8f;
				((Vector3)(ref val))..ctor(Mathf.Cos(num) * bottomRadius, (0f - height) / 2f, Mathf.Sin(num) * bottomRadius);
				((Vector3)(ref val2))..ctor(Mathf.Cos(num2) * bottomRadius, (0f - height) / 2f, Mathf.Sin(num2) * bottomRadius);
				((Vector3)(ref val3))..ctor(Mathf.Cos(num) * topRadius, height / 2f, Mathf.Sin(num) * topRadius);
				((Vector3)(ref val4))..ctor(Mathf.Cos(num2) * topRadius, height / 2f, Mathf.Sin(num2) * topRadius);
				Vector3[] array4 = (Vector3[])(object)new Vector3[12]
				{
					val,
					val3,
					val4,
					val,
					val4,
					val2,
					new Vector3(0f, height / 2f, 0f),
					val4,
					val3,
					new Vector3(0f, (0f - height) / 2f, 0f),
					val,
					val2
				};
				if (!capped)
				{
					array4 = (Vector3[])(object)new Vector3[12]
					{
						val, val3, val4, val, val4, val2, val4, val3, val, val2,
						val4, val
					};
				}
				for (int j = 0; j < 12; j++)
				{
					int num3 = i * 12 + j;
					array[num3] = array4[j];
					array3[num3] = num3;
					array2[num3] = new Vector2((float)(j % 3) * 0.5f, (float)(j % 2));
				}
			}
			Mesh val5 = new Mesh
			{
				name = "VC_" + name,
				vertices = array,
				triangles = array3,
				uv = array2
			};
			val5.RecalculateNormals();
			val5.RecalculateBounds();
			GameObject val6 = new GameObject(name);
			val6.transform.SetParent(parent, false);
			val6.transform.localPosition = position;
			val6.layer = ((Component)parent).gameObject.layer;
			val6.AddComponent<MeshFilter>().sharedMesh = val5;
			((Renderer)val6.AddComponent<MeshRenderer>()).sharedMaterial = material;
		}
	}
	internal static class WildCoffee
	{
		internal const string PrefabId = "VC_WildCoffee";

		internal static void Register(GameObject cultivatedMature)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: 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_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: 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_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Expected O, but got Unknown
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Expected O, but got Unknown
			GameObject val = PrefabManager.Instance.CreateClonedPrefab("VC_WildCoffee", cultivatedMature);
			Pickable component = val.GetComponent<Pickable>();
			Fields.Set(component, "m_overrideName", "$vc_wild");
			Fields.Set(component, "m_respawnTimeMinutes", 0f);
			VegetationConfig val2 = new VegetationConfig
			{
				Biome = (Biome)9,
				Min = 0f,
				Max = 0.15f,
				GroupSizeMin = 1,
				GroupSizeMax = 1,
				MinAltitude = 2f,
				MaxAltitude = 90f,
				MaxTilt = 30f,
				ScaleMin = 1f,
				ScaleMax = 1f,
				BlockCheck = true,
				ForcePlacement = false,
				InForest = false,
				GroupRadius = 0f
			};
			if (!ZoneManager.Instance.AddCustomVegetation(new CustomVegetation(val, false, val2)))
			{
				throw new InvalidOperationException("Cannot register wild coffee vegetation");
			}
		}
	}
}