Decompiled source of PlantCart v1.0.0

plugins\PlantCart.dll

Decompiled a week ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Jotunn;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using PlantCart.Components;
using PlantCart.Configs;
using PlantCart.Helpers;
using PlantCart.Models;
using PlantCart.Types;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("PlantCart")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PlantCart")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace PlantCart
{
	[BepInPlugin("DeathWizsh.PlantCart", "PlantCart", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	internal class PlantCart : BaseUnityPlugin
	{
		public const string PluginGUID = "DeathWizsh.PlantCart";

		public const string PluginName = "PlantCart";

		public const string PluginVersion = "1.0.0";

		public static PlantCart Instance;

		private AssetBundle assetBundle;

		public CustomPrefabs prefabs = new CustomPrefabs();

		public static string currentTrader;

		public void Awake()
		{
			Instance = this;
			InitAssetBundle();
			PluginConfig.Init();
			PrefabManager.OnVanillaPrefabsAvailable += AddPieces;
		}

		private void AddPieces()
		{
			ItemHelper.CreateMaterial(prefabs.Plow, PluginConfig.rustedPlow);
			prefabs.PlantCart.AddComponent<Planter>();
			PieceHelper.Create(prefabs.PlantCart, PluginConfig.piece1);
			currentTrader = PluginConfig.rustedPlow.trader.Value;
			PrefabManager.Instance.GetPrefab(currentTrader).GetComponent<Trader>().m_items.Add(UpdateHelper.CreateNewTradeItem());
			PrefabManager.OnVanillaPrefabsAvailable -= AddPieces;
		}

		private void InitAssetBundle()
		{
			assetBundle = AssetUtils.LoadAssetBundleFromResources("plantcart_dw");
			prefabs.PlantCart = assetBundle.LoadAsset<GameObject>("PlantCart_PC");
			prefabs.Plow = assetBundle.LoadAsset<GameObject>("Plow_PC");
		}
	}
}
namespace PlantCart.Types
{
	internal class CraftingStationType
	{
		public static string None => "None";

		public static string Disabled => "Disabled";

		public static string Workbench => "Workbench";

		public static string Forge => "Forge";

		public static string Cauldron => "Cauldron";

		public static string Stonecutter => "Stonecutter";

		public static string ArtisanTable => "ArtisanTable";

		public static string BlackForge => "BlackForge";

		public static string GaldrTable => "GaldrTable";
	}
	internal class GlobalKeyType
	{
		public static string DefeatedNothing => "DefeatedNothing";

		public static string DefeatedNoBoss => "DefeatedNoBoss";

		public static string DefeatedEikthyr => "defeated_eikthyr";

		public static string DefeatedElder => "defeated_gdking";

		public static string DefeatedBonemass => "defeated_bonemass";

		public static string DefeatedModer => "defeated_dragon";

		public static string DefeatedYagluth => "defeated_goblinking";

		public static string DefeatedQueen => "defeated_queen";

		public static string DefeatedFader => "defeated_fader";

		public static string KilledBat => "killedBat";

		public static string KilledTroll => "killedtroll";

		public static string killedSurtling => "killed_surtling";
	}
	internal enum RecipeUpdateType
	{
		ENABLE,
		RECIPE,
		CRAFTINGSTATION,
		MINREQUIREDSTATIONLEVEL,
		MINREQUIREDREPAIRLEVEL
	}
	internal class TraderType
	{
		public static string BogWitch => "BogWitch";

		public static string Haldor => "Haldor";

		public static string Hildir => "Hildir";
	}
}
namespace PlantCart.Models
{
	internal class CustomPrefabs
	{
		public GameObject PlantCart;

		public GameObject Plow;
	}
	internal class BuildPieceConfigOptions
	{
		public GameObject prefab;

		public string sectionName;

		public string recipeName;

		public bool enable = true;

		public string name;

		public string? description;

		public string? craftingStation;

		public string recipe;

		public int inventoryColumns = 3;

		public int inventoryRows = 1;

		public BuildPieceConfigOptions(GameObject prefab, string name, string recipe)
		{
			this.prefab = prefab;
			this.name = name;
			sectionName = name.Replace("'", "") ?? "";
			this.recipe = recipe;
			recipeName = "Recipe_" + ((Object)prefab).name;
		}
	}
	internal class MaterialConfigOptions
	{
		public GameObject? prefab;

		public string? sectionName;

		public string? recipeName;

		public bool enable = true;

		public string? name;

		public string? description;

		public string? craftingStation;

		public int minStationLevel = 1;

		public string? recipe;

		public MaterialConfigOptions(GameObject prefab, string name, string recipe)
		{
			this.prefab = prefab;
			this.name = name;
			sectionName = name.Replace("'", "") ?? "";
			this.recipe = recipe;
			recipeName = "Recipe_" + ((Object)prefab).name;
		}
	}
	internal class UpdateItemDataOptions
	{
		public string? name;

		public string? description;

		public bool? teleportable;
	}
	internal class UpdateRecipeOptions
	{
		public string? name;

		public bool? enable;

		public string? craftingStation;

		public string? requirements;

		public int? requiredStationLevel;

		public RecipeUpdateType updateType = RecipeUpdateType.RECIPE;

		public string? upgradeRequirements;

		public int? upgradeMultiplier;
	}
	internal class UpdateTraderOptions
	{
		public int? cost;

		public string? globalKey;

		public int? stack;

		public bool? teleportable;

		public string? trader;
	}
}
namespace PlantCart.Helpers
{
	internal class ItemHelper
	{
		public static void CreateMaterial(GameObject prefab, MaterialConfig config)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			ItemConfig val = new ItemConfig();
			val.Name = config.name.Value;
			val.Description = config.description.Value;
			ItemManager.Instance.AddItem(new CustomItem(prefab, true, val));
		}
	}
	internal class PieceHelper
	{
		public static void Create(GameObject prefab, BuildPieceConfig config)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Expected O, but got Unknown
			try
			{
				PieceConfig val = new PieceConfig();
				val.Enabled = config.enable.Value;
				val.Name = config.name.Value;
				val.Description = config.description.Value;
				val.CraftingStation = config.craftingStation.Value;
				val.PieceTable = PieceTables.Hammer;
				val.Category = PieceCategories.Misc;
				RequirementConfig[] asRequirementConfigArray = RecipeHelper.GetAsRequirementConfigArray(config.recipe.Value, null, null);
				if (asRequirementConfigArray == null || asRequirementConfigArray.Length == 0)
				{
					Logger.LogWarning((object)("Could not resolve recipe for: " + ((Object)prefab).name));
				}
				else
				{
					val.Requirements = asRequirementConfigArray;
				}
				UpdateEnabled(prefab, config.enable.Value);
				UpdateName(prefab, config.name.Value);
				UpdateDescription(prefab, config.name.Value);
				UpdateCraftingStation(prefab, config.craftingStation.Value);
				UpdateRecipe(prefab, config.recipe.Value);
				UpdateInventorySize(prefab, config.inventoryColumns.Value, config.inventoryRows.Value);
				UpdateMass(prefab, config.cartMass.Value);
				PieceManager.Instance.AddPiece(new CustomPiece(prefab, true, val));
			}
			catch (Exception ex)
			{
				Logger.LogError((object)("Could not create build piece: " + ex));
			}
		}

		public static void UpdateEnabled(GameObject prefab, bool value)
		{
			try
			{
				if ((Object)(object)prefab == (Object)null)
				{
					throw new Exception("Prefab is null");
				}
				Piece component = prefab.GetComponent<Piece>();
				if ((Object)(object)component == (Object)null)
				{
					throw new Exception("Could not find Piece component");
				}
				component.m_enabled = value;
			}
			catch (Exception ex)
			{
				Logger.LogError((object)("Could not update piece enabled: " + ex));
			}
		}

		public static void UpdateName(GameObject prefab, string value)
		{
			try
			{
				if ((Object)(object)prefab == (Object)null)
				{
					throw new Exception("Prefab is null");
				}
				Piece component = prefab.GetComponent<Piece>();
				Vagon component2 = prefab.GetComponent<Vagon>();
				if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null)
				{
					throw new Exception("Could not find Piece or Vagon component");
				}
				component.m_name = value;
				component2.m_name = value;
			}
			catch (Exception ex)
			{
				Logger.LogError((object)("Could not update piece name: " + ex));
			}
		}

		public static void UpdateDescription(GameObject prefab, string value)
		{
			try
			{
				if ((Object)(object)prefab == (Object)null)
				{
					throw new Exception("Prefab is null");
				}
				Piece component = prefab.GetComponent<Piece>();
				if ((Object)(object)component == (Object)null)
				{
					throw new Exception("Could not find Piece component");
				}
				component.m_description = value;
			}
			catch (Exception ex)
			{
				Logger.LogError((object)("Could not update piece description: " + ex));
			}
		}

		public static void UpdateCraftingStation(GameObject prefab, string value)
		{
			try
			{
				if ((Object)(object)prefab == (Object)null)
				{
					throw new Exception("Prefab is null");
				}
				Piece component = prefab.GetComponent<Piece>();
				if ((Object)(object)component == (Object)null)
				{
					throw new Exception("Could not find Piece component");
				}
				string internalName = CraftingStations.GetInternalName(value);
				CraftingStation component2 = PrefabManager.Instance.GetPrefab(internalName).GetComponent<CraftingStation>();
				if ((Object)(object)component2 == (Object)null)
				{
					throw new Exception("Could not find CraftingStation component");
				}
				component.m_craftingStation = component2;
			}
			catch (Exception ex)
			{
				Logger.LogError((object)("Could not update piece crafting station: " + ex));
			}
		}

		public static void UpdateRecipe(GameObject prefab, string value)
		{
			try
			{
				if ((Object)(object)prefab == (Object)null)
				{
					throw new Exception("Prefab is null");
				}
				Piece component = prefab.GetComponent<Piece>();
				if ((Object)(object)component == (Object)null)
				{
					throw new Exception("Could not find Piece component");
				}
				Requirement[] asPieceRequirementArray = RecipeHelper.GetAsPieceRequirementArray(value, null, null);
				if (asPieceRequirementArray == null || asPieceRequirementArray.Length == 0)
				{
					Logger.LogWarning((object)("Could not resolve recipe for: " + ((Object)prefab).name));
				}
				else
				{
					component.m_resources = asPieceRequirementArray;
				}
			}
			catch (Exception ex)
			{
				Logger.LogError((object)("Could not update piece recipe: " + ex));
			}
		}

		public static void UpdateInventorySize(GameObject prefab, int width, int height)
		{
			try
			{
				if ((Object)(object)prefab == (Object)null)
				{
					throw new Exception("Prefab is null");
				}
				if (width <= 0 || height <= 0)
				{
					Logger.LogWarning((object)"Container size cannot be smaller then 1x1!");
					return;
				}
				Transform obj = prefab.transform.Find("Container");
				if ((Object)(object)obj == (Object)null)
				{
					throw new Exception("Could not find Container object");
				}
				Container component = ((Component)obj).GetComponent<Container>();
				if ((Object)(object)component == (Object)null)
				{
					throw new Exception("Could not find Container component");
				}
				component.m_width = width;
				component.m_height = height;
			}
			catch (Exception ex)
			{
				Logger.LogError((object)("Could not update inventory size: " + ex));
			}
		}

		public static void UpdateMass(GameObject prefab, float value)
		{
			try
			{
				if ((Object)(object)prefab == (Object)null)
				{
					throw new Exception("Prefab is null");
				}
				Vagon component = prefab.GetComponent<Vagon>();
				if ((Object)(object)component == (Object)null)
				{
					throw new Exception("Could not find Vagon component");
				}
				component.m_baseMass = value;
			}
			catch (Exception ex)
			{
				Logger.LogError((object)("Could not update piece mass: " + ex));
			}
		}
	}
	internal class RecipeHelper
	{
		private static readonly Regex _nukeWhiteSpaceRegex = new Regex("\\s+");

		private static readonly Regex _recipeEntryRegex = new Regex("^([a-zA-Z0-9_]+:[0-9]+)$");

		public static RequirementConfig[]? GetAsRequirementConfigArray(string configRecipe, string? upgradeRecipe, int? multiplier)
		{
			return GetAsRequirementConfigList(configRecipe, upgradeRecipe, multiplier)?.ToArray();
		}

		public static Requirement[]? GetAsPieceRequirementArray(string configRecipe, string? upgradeRecipe, int? multiplier)
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			try
			{
				List<RequirementConfig> asRequirementConfigList = GetAsRequirementConfigList(configRecipe, upgradeRecipe, multiplier);
				List<Requirement> list = new List<Requirement>();
				if (asRequirementConfigList == null)
				{
					return null;
				}
				foreach (RequirementConfig item in asRequirementConfigList)
				{
					GameObject prefab = PrefabManager.Instance.GetPrefab(item.Item);
					if ((Object)(object)prefab == (Object)null)
					{
						throw new Exception("Could not find item, please check config!");
					}
					Requirement val = new Requirement();
					val.m_resItem = prefab.GetComponent<ItemDrop>();
					val.m_amount = item.Amount;
					val.m_recover = item.Recover;
					if (upgradeRecipe != null && multiplier.HasValue)
					{
						val.m_amountPerLevel = item.AmountPerLevel;
					}
					list.Add(val);
				}
				return list.ToArray();
			}
			catch (Exception ex)
			{
				Logger.LogError((object)("Could not convert recipe to Piece.Requirement array: " + ex));
				return null;
			}
		}

		public static List<RequirementConfig>? GetAsRequirementConfigList(string configRecipe, string? upgradeRecipe, int? multiplier)
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Expected O, but got Unknown
			try
			{
				configRecipe = _nukeWhiteSpaceRegex.Replace(configRecipe, "");
				if (upgradeRecipe != null)
				{
					upgradeRecipe = _nukeWhiteSpaceRegex.Replace(upgradeRecipe, "");
				}
				if (!IsConfigRecipeValid(configRecipe, upgradeRecipe))
				{
					Logger.LogWarning((object)"Config is not valid, please check the values");
					return null;
				}
				List<RequirementConfig> list = new List<RequirementConfig>();
				string[] array = configRecipe.Trim().Split(new char[1] { ',' });
				foreach (string obj in array)
				{
					RequirementConfig val = new RequirementConfig();
					string[] array2 = obj.Split(new char[1] { ':' });
					val.Item = array2[0];
					val.Amount = int.Parse(array2[1]);
					val.Recover = true;
					if (upgradeRecipe != null && !Utility.IsNullOrWhiteSpace(upgradeRecipe) && multiplier.HasValue)
					{
						string[] array3 = upgradeRecipe.Trim().Split(new char[1] { ',' });
						for (int j = 0; j < array3.Length; j++)
						{
							string[] array4 = array3[j].Split(new char[1] { ':' });
							if (val.Item == array4[0])
							{
								val.AmountPerLevel = int.Parse(array4[1]) * multiplier.Value;
								break;
							}
						}
					}
					list.Add(val);
				}
				return list;
			}
			catch (Exception ex)
			{
				Logger.LogError((object)("Could not convert recipe to RequirementConfig list: " + ex));
				return null;
			}
		}

		public static bool IsConfigRecipeValid(string configRecipe, string? upgradeRecipe)
		{
			try
			{
				bool result = true;
				string[] array = configRecipe.Split(new char[1] { ',' });
				foreach (string text in array)
				{
					if (!_recipeEntryRegex.IsMatch(text))
					{
						result = false;
						Logger.LogWarning((object)("Cannot resolve " + text + " from the crafting recipe"));
					}
				}
				if (upgradeRecipe == null || Utility.IsNullOrWhiteSpace(upgradeRecipe))
				{
					return result;
				}
				array = upgradeRecipe.Split(new char[1] { ',' });
				foreach (string text2 in array)
				{
					if (!_recipeEntryRegex.IsMatch(text2))
					{
						result = false;
						Logger.LogWarning((object)("Cannot resolve " + text2 + " from the upgrade recipe"));
					}
				}
				return result;
			}
			catch (Exception ex)
			{
				Logger.LogError((object)("Could not validate recipe due to an error: " + ex));
				return false;
			}
		}

		public static void UpdateRecipe(UpdateRecipeOptions options)
		{
			try
			{
				CustomRecipe recipe = ItemManager.Instance.GetRecipe(options.name);
				if (recipe == null)
				{
					throw new Exception("Could not find recipe: " + options.name);
				}
				switch (options.updateType)
				{
				case RecipeUpdateType.ENABLE:
					if (!options.enable.HasValue)
					{
						throw new Exception("Enable is null");
					}
					recipe.Recipe.m_enabled = options.enable.Value;
					break;
				case RecipeUpdateType.RECIPE:
				{
					if (options.requirements == null)
					{
						throw new Exception("Requirements is null");
					}
					Requirement[] asPieceRequirementArray = GetAsPieceRequirementArray(options.requirements, options.upgradeRequirements, options.upgradeMultiplier);
					if (asPieceRequirementArray == null)
					{
						Logger.LogWarning((object)"Cannot update recipe, requirements is null");
					}
					else
					{
						recipe.Recipe.m_resources = asPieceRequirementArray;
					}
					break;
				}
				case RecipeUpdateType.CRAFTINGSTATION:
					if (options.craftingStation == null || options.craftingStation == "")
					{
						throw new Exception("Craftingstation is null or empty string");
					}
					if (options.craftingStation == "None")
					{
						recipe.Recipe.m_craftingStation = null;
						recipe.Recipe.m_enabled = true;
					}
					else if (options.craftingStation == "Disabled")
					{
						recipe.Recipe.m_craftingStation = null;
						recipe.Recipe.m_enabled = false;
					}
					else
					{
						string internalName = CraftingStations.GetInternalName(options.craftingStation);
						recipe.Recipe.m_enabled = true;
						recipe.Recipe.m_craftingStation = PrefabManager.Instance.GetPrefab(internalName).GetComponent<CraftingStation>();
					}
					break;
				case RecipeUpdateType.MINREQUIREDSTATIONLEVEL:
					if (!options.requiredStationLevel.HasValue || options.requiredStationLevel < 1)
					{
						throw new Exception("Required station level is null or lower then 1");
					}
					recipe.Recipe.m_minStationLevel = options.requiredStationLevel.Value;
					break;
				}
			}
			catch (Exception ex)
			{
				Logger.LogError((object)("Could not update recipe: " + ex));
			}
		}
	}
	internal class UpdateHelper
	{
		public static void UpdateItemData(GameObject prefab, UpdateItemDataOptions options)
		{
			if ((Object)(object)prefab == (Object)null)
			{
				throw new Exception("Prefab is null");
			}
			UpdateItemData(prefab.GetComponent<ItemDrop>().m_itemData, options);
		}

		public static void UpdateItemData(ItemData itemData, UpdateItemDataOptions options)
		{
			if (itemData == null)
			{
				throw new Exception("ItemData is null");
			}
			if (options.name != null)
			{
				itemData.m_shared.m_name = options.name;
			}
			if (options.description != null)
			{
				itemData.m_shared.m_description = options.description;
			}
			if (options.teleportable.HasValue)
			{
				itemData.m_shared.m_teleportable = options.teleportable.Value;
			}
		}

		public static void UpdateTrader(UpdateTraderOptions options)
		{
			string oldTraderName = PlantCart.currentTrader;
			bool flag = options.trader != null && options.trader != oldTraderName;
			string newTraderName = (flag ? options.trader : oldTraderName);
			Trader component = ZNetScene.instance.m_prefabs.Find((GameObject item) => ((Object)item).name == oldTraderName).GetComponent<Trader>();
			RemoveTradeItem(component);
			Trader trader = component;
			if (flag)
			{
				trader = ZNetScene.instance.m_prefabs.Find((GameObject item) => ((Object)item).name == newTraderName).GetComponent<Trader>();
			}
			AddTradeItem(trader);
			Trader val = FindLiveTrader(oldTraderName);
			RemoveTradeItem(val);
			AddTradeItem(flag ? FindLiveTrader(newTraderName) : val);
			if (flag)
			{
				PlantCart.currentTrader = newTraderName;
			}
		}

		private static Trader FindLiveTrader(string prefabName)
		{
			if (prefabName == null)
			{
				return null;
			}
			int stableHashCode = StringExtensionMethods.GetStableHashCode(prefabName);
			Trader[] array = Object.FindObjectsByType<Trader>((FindObjectsInactive)0, (FindObjectsSortMode)0);
			foreach (Trader val in array)
			{
				ZNetView component = ((Component)val).GetComponent<ZNetView>();
				ZDO val2 = ((component != null) ? component.GetZDO() : null);
				if (val2 != null && val2.GetPrefab() == stableHashCode)
				{
					return val;
				}
			}
			return null;
		}

		private static TradeItem FindTradeItem(Trader trader)
		{
			return trader?.m_items.Find((TradeItem item) => (Object)(object)item.m_prefab == (Object)(object)PlantCart.Instance.prefabs.Plow.GetComponent<ItemDrop>());
		}

		private static void RemoveTradeItem(Trader trader)
		{
			TradeItem val = FindTradeItem(trader);
			if (val != null)
			{
				trader.m_items.Remove(val);
			}
		}

		private static void AddTradeItem(Trader trader)
		{
			if ((Object)(object)trader != (Object)null)
			{
				trader.m_items.Add(CreateNewTradeItem());
			}
		}

		public static TradeItem CreateNewTradeItem()
		{
			//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_001f: 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_0049: 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_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected O, but got Unknown
			//IL_0075: Expected O, but got Unknown
			return new TradeItem
			{
				m_prefab = PlantCart.Instance.prefabs.Plow.GetComponent<ItemDrop>(),
				m_price = PluginConfig.rustedPlow.cost.Value,
				m_requiredGlobalKey = PluginConfig.rustedPlow.requiredGlobalKey.Value,
				m_stack = PluginConfig.rustedPlow.stack.Value,
				m_tooltip = string.Empty,
				m_buyPlayerEffects = new EffectList()
			};
		}
	}
}
namespace PlantCart.Configs
{
	internal class BuildPieceConfig
	{
		public static string[] craftingStationOptions = new string[9]
		{
			CraftingStationType.None,
			CraftingStationType.Disabled,
			CraftingStationType.Workbench,
			CraftingStationType.Forge,
			CraftingStationType.Stonecutter,
			CraftingStationType.Cauldron,
			CraftingStationType.ArtisanTable,
			CraftingStationType.BlackForge,
			CraftingStationType.GaldrTable
		};

		public ConfigEntry<bool> enable;

		public ConfigEntry<string> name;

		public ConfigEntry<string> description;

		public ConfigEntry<string> craftingStation;

		public ConfigEntry<string> recipe;

		public ConfigEntry<int> inventoryColumns;

		public ConfigEntry<int> inventoryRows;

		public ConfigEntry<float> cartMass;

		public ConfigEntry<float> durabilityLoss;

		private int entryCount = 100;

		public void GenerateConfig(BuildPieceConfigOptions options)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: 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_006d: Expected O, but got Unknown
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			//IL_0077: Expected O, but got Unknown
			//IL_00a5: 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)
			//IL_00c8: 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_00e1: Expected O, but got Unknown
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Expected O, but got Unknown
			//IL_00eb: Expected O, but got Unknown
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Expected O, but got Unknown
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Expected O, but got Unknown
			//IL_015f: Expected O, but got Unknown
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: 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_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Expected O, but got Unknown
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Expected O, but got Unknown
			//IL_01dc: Expected O, but got Unknown
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: 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_0246: Expected O, but got Unknown
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Expected O, but got Unknown
			//IL_0250: Expected O, but got Unknown
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ba: Expected O, but got Unknown
			//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c4: Expected O, but got Unknown
			//IL_02c4: Expected O, but got Unknown
			//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0310: Unknown result type (might be due to invalid IL or missing references)
			//IL_0315: Unknown result type (might be due to invalid IL or missing references)
			//IL_031c: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: Expected O, but got Unknown
			//IL_032e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0338: Expected O, but got Unknown
			//IL_0338: Expected O, but got Unknown
			//IL_0366: Unknown result type (might be due to invalid IL or missing references)
			//IL_037e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0383: Unknown result type (might be due to invalid IL or missing references)
			//IL_038a: Unknown result type (might be due to invalid IL or missing references)
			//IL_039c: Expected O, but got Unknown
			//IL_039c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a6: Expected O, but got Unknown
			//IL_03a6: Expected O, but got Unknown
			//IL_03d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_040a: Expected O, but got Unknown
			//IL_040a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0414: Expected O, but got Unknown
			//IL_0414: Expected O, but got Unknown
			ConfigFile config = ((BaseUnityPlugin)PlantCart.Instance).Config;
			enable = config.Bind<bool>(new ConfigDefinition(options.sectionName, "Enable"), options.enable, new ConfigDescription("Wether the recipe for this piece is enabled", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true,
				Order = HandleOrder()
			} }));
			enable.SettingChanged += delegate
			{
				PieceHelper.UpdateEnabled(options.prefab, enable.Value);
			};
			name = config.Bind<string>(new ConfigDefinition(options.sectionName, "Name"), options.name, new ConfigDescription("The name of this build piece", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true,
				Order = HandleOrder()
			} }));
			name.SettingChanged += delegate
			{
				PieceHelper.UpdateName(options.prefab, name.Value);
			};
			description = config.Bind<string>(new ConfigDefinition(options.sectionName, "Description"), options.description, new ConfigDescription("The description of this build piece", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true,
				Order = HandleOrder()
			} }));
			description.SettingChanged += delegate
			{
				PieceHelper.UpdateDescription(options.prefab, description.Value);
			};
			craftingStation = config.Bind<string>(new ConfigDefinition(options.sectionName, "Crafting station"), options.craftingStation, new ConfigDescription("The crafting station required to place this piece", (AcceptableValueBase)(object)new AcceptableValueList<string>(craftingStationOptions), new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true,
				Order = HandleOrder()
			} }));
			craftingStation.SettingChanged += delegate
			{
				PieceHelper.UpdateCraftingStation(options.prefab, craftingStation.Value);
			};
			recipe = config.Bind<string>(new ConfigDefinition(options.sectionName, "Recipe"), options.recipe, new ConfigDescription("The items required to place this build piece", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true,
				Order = HandleOrder()
			} }));
			recipe.SettingChanged += delegate
			{
				PieceHelper.UpdateRecipe(options.prefab, recipe.Value);
			};
			inventoryColumns = config.Bind<int>(new ConfigDefinition(options.sectionName, "Inventory columns"), options.inventoryColumns, new ConfigDescription("The width (amount of slots) of the inventory", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true,
				Order = HandleOrder()
			} }));
			inventoryColumns.SettingChanged += delegate
			{
				PieceHelper.UpdateInventorySize(options.prefab, inventoryColumns.Value, inventoryRows.Value);
			};
			inventoryRows = config.Bind<int>(new ConfigDefinition(options.sectionName, "Inventory rows"), options.inventoryRows, new ConfigDescription("The height (amount of slots) of the inventory", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true,
				Order = HandleOrder()
			} }));
			inventoryRows.SettingChanged += delegate
			{
				PieceHelper.UpdateInventorySize(options.prefab, inventoryColumns.Value, inventoryRows.Value);
			};
			cartMass = config.Bind<float>(new ConfigDefinition(options.sectionName, "Cart mass"), 300f, new ConfigDescription("The mass of the cart, affects speed and control", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true,
				Order = HandleOrder()
			} }));
			cartMass.SettingChanged += delegate
			{
				PieceHelper.UpdateMass(options.prefab, cartMass.Value);
			};
			durabilityLoss = config.Bind<float>(new ConfigDefinition(options.sectionName, "Durability loss"), 1f, new ConfigDescription("The amount of durability loss the cart takes on planting", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true,
				Order = HandleOrder()
			} }));
		}

		private int HandleOrder()
		{
			entryCount--;
			if (entryCount >= 0)
			{
				return entryCount;
			}
			return 0;
		}
	}
	internal class MaterialConfig
	{
		public static string[] craftingStationOptions = new string[9]
		{
			CraftingStationType.None,
			CraftingStationType.Disabled,
			CraftingStationType.Workbench,
			CraftingStationType.Forge,
			CraftingStationType.Stonecutter,
			CraftingStationType.Cauldron,
			CraftingStationType.ArtisanTable,
			CraftingStationType.BlackForge,
			CraftingStationType.GaldrTable
		};

		public static string[] traderOptions = new string[3]
		{
			TraderType.BogWitch,
			TraderType.Haldor,
			TraderType.Hildir
		};

		public ConfigEntry<string> name;

		public ConfigEntry<string> description;

		public ConfigEntry<string> trader;

		public ConfigEntry<int> cost;

		public ConfigEntry<int> stack;

		public ConfigEntry<bool> teleportable;

		public ConfigEntry<string> requiredGlobalKey;

		private int entryCount = 100;

		public void GenerateConfig(MaterialConfigOptions options)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: 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_006d: Expected O, but got Unknown
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			//IL_0077: Expected O, but got Unknown
			//IL_00a5: 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)
			//IL_00c8: 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_00e1: Expected O, but got Unknown
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Expected O, but got Unknown
			//IL_00eb: Expected O, but got Unknown
			//IL_0119: 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_014b: Expected O, but got Unknown
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Expected O, but got Unknown
			//IL_0155: Expected O, but got Unknown
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: 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_01c2: Expected O, but got Unknown
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Expected O, but got Unknown
			//IL_01cc: Expected O, but got Unknown
			//IL_01fa: 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_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Expected O, but got Unknown
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Expected O, but got Unknown
			//IL_023a: Expected O, but got Unknown
			//IL_0268: 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_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: Expected O, but got Unknown
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Expected O, but got Unknown
			//IL_02a4: Expected O, but got Unknown
			//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0308: Expected O, but got Unknown
			//IL_0308: Unknown result type (might be due to invalid IL or missing references)
			//IL_0312: Expected O, but got Unknown
			//IL_0312: Expected O, but got Unknown
			ConfigFile config = ((BaseUnityPlugin)PlantCart.Instance).Config;
			name = config.Bind<string>(new ConfigDefinition(options.sectionName, "Name"), options.name, new ConfigDescription("The name given to the item", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true,
				Order = HandleOrder()
			} }));
			name.SettingChanged += delegate
			{
				UpdateHelper.UpdateItemData(options.prefab, new UpdateItemDataOptions
				{
					name = name.Value
				});
			};
			description = config.Bind<string>(new ConfigDefinition(options.sectionName, "Description"), options.description, new ConfigDescription("The description given to the item", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true,
				Order = HandleOrder()
			} }));
			description.SettingChanged += delegate
			{
				UpdateHelper.UpdateItemData(options.prefab, new UpdateItemDataOptions
				{
					description = description.Value
				});
			};
			teleportable = config.Bind<bool>(new ConfigDefinition(options.sectionName, "Teleportable"), false, new ConfigDescription("Whether the item is teleportable", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true,
				Order = HandleOrder()
			} }));
			teleportable.SettingChanged += delegate
			{
				UpdateHelper.UpdateItemData(options.prefab, new UpdateItemDataOptions
				{
					teleportable = teleportable.Value
				});
			};
			trader = config.Bind<string>(new ConfigDefinition(options.sectionName, "Trader"), TraderType.Haldor, new ConfigDescription("The trader where this item is available", (AcceptableValueBase)(object)new AcceptableValueList<string>(traderOptions), new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true,
				Order = HandleOrder()
			} }));
			trader.SettingChanged += delegate
			{
				UpdateHelper.UpdateTrader(new UpdateTraderOptions
				{
					trader = trader.Value
				});
			};
			cost = config.Bind<int>(new ConfigDefinition(options.sectionName, "Cost"), 300, new ConfigDescription("The amount this item cost at the trader", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true,
				Order = HandleOrder()
			} }));
			cost.SettingChanged += delegate
			{
				UpdateHelper.UpdateTrader(new UpdateTraderOptions
				{
					cost = cost.Value
				});
			};
			stack = config.Bind<int>(new ConfigDefinition(options.sectionName, "Stack"), 1, new ConfigDescription("The stack size of this item when buying from a trader", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true,
				Order = HandleOrder()
			} }));
			stack.SettingChanged += delegate
			{
				UpdateHelper.UpdateTrader(new UpdateTraderOptions
				{
					stack = stack.Value
				});
			};
			requiredGlobalKey = config.Bind<string>(new ConfigDefinition(options.sectionName, "Global Key"), GlobalKeyType.DefeatedModer, new ConfigDescription("The global key required for this item to show up at trader (boss killed)", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true,
				Order = HandleOrder()
			} }));
			requiredGlobalKey.SettingChanged += delegate
			{
				UpdateHelper.UpdateTrader(new UpdateTraderOptions
				{
					globalKey = requiredGlobalKey.Value
				});
			};
		}

		private int HandleOrder()
		{
			entryCount--;
			if (entryCount >= 0)
			{
				return entryCount;
			}
			return 0;
		}
	}
	internal static class PluginConfig
	{
		private static string piece1Name = "Plant Cart";

		private static string piece1Recipe = "Wood:20, Copper:6, Silver:10, " + ((Object)PlantCart.Instance.prefabs.Plow).name + ":2";

		public static BuildPieceConfig piece1 = new BuildPieceConfig();

		public static string material1Name = "Rusted Plow";

		public static MaterialConfig rustedPlow = new MaterialConfig();

		public static void Init()
		{
			InitPiece1Config();
			InitRustedPlowConfig();
		}

		public static void InitPiece1Config()
		{
			try
			{
				BuildPieceConfigOptions options = new BuildPieceConfigOptions(PlantCart.Instance.prefabs.PlantCart, piece1Name, piece1Recipe)
				{
					description = "Plant crops effortlessly with a cart that sows seeds as you go.",
					craftingStation = CraftingStationType.Workbench
				};
				piece1.GenerateConfig(options);
			}
			catch (Exception ex)
			{
				Logger.LogError((object)("Could not initialise " + piece1Name + " config: " + ex));
			}
		}

		private static void InitRustedPlowConfig()
		{
			try
			{
				MaterialConfigOptions options = new MaterialConfigOptions(PlantCart.Instance.prefabs.Plow, material1Name, null)
				{
					description = "An old rusted plow, maybe it can be restored and used for something?",
					craftingStation = null
				};
				rustedPlow.GenerateConfig(options);
			}
			catch (Exception ex)
			{
				Logger.LogError((object)("Could not initialise " + material1Name + " config: " + ex));
			}
		}
	}
}
namespace PlantCart.Components
{
	public class Planter : MonoBehaviour
	{
		private ZNetView netView;

		public Transform cartTransform;

		private Vector3 lastPosition;

		public float distanceThreshold = 1.1f;

		private List<string> m_allowedList = new List<string>();

		private Dictionary<string, string> m_plantDict = new Dictionary<string, string>();

		public void Awake()
		{
			//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)
			netView = ((Component)this).gameObject.GetComponent<ZNetView>();
			cartTransform = ((Component)this).transform;
			lastPosition = cartTransform.position;
			m_allowedList.Add("carrot");
			m_allowedList.Add("turnip");
			m_allowedList.Add("onion");
			m_allowedList.Add("barley");
			m_allowedList.Add("flax");
			m_allowedList.Add("magecap");
			m_allowedList.Add("jotunpuffs");
			m_plantDict.Add("$item_carrotseeds", "sapling_carrot");
			m_plantDict.Add("$item_carrot", "sapling_seedcarrot");
			m_plantDict.Add("$item_turnipseeds", "sapling_turnip");
			m_plantDict.Add("$item_turnip", "sapling_seedturnip");
			m_plantDict.Add("$item_onionseeds", "sapling_onion");
			m_plantDict.Add("$item_onion", "sapling_seedonion");
			m_plantDict.Add("$item_barley", "sapling_barley");
			m_plantDict.Add("$item_flax", "sapling_flax");
			m_plantDict.Add("$item_magecap", "sapling_magecap");
			m_plantDict.Add("$item_jotunpuffs", "sapling_jotunpuffs");
		}

		public bool IsValidPlantPoint(RaycastHit raycast)
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)((RaycastHit)(ref raycast)).collider == (Object)null || (Object)(object)((Component)((RaycastHit)(ref raycast)).collider).gameObject == (Object)null || !((Object)((Component)((RaycastHit)(ref raycast)).collider).gameObject).name.Equals("terrain", StringComparison.OrdinalIgnoreCase))
			{
				return false;
			}
			Heightmap component = ((Component)((RaycastHit)(ref raycast)).collider).gameObject.GetComponent<Heightmap>();
			if ((Object)(object)component == (Object)null || !component.IsCultivated(((RaycastHit)(ref raycast)).point))
			{
				return false;
			}
			return true;
		}

		public void Update()
		{
			//IL_0013: 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_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_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: 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_00a5: 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_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: 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_00c7: 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)
			//IL_00d1: 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_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_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: 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_011a: 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_0134: 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_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: 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)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (netView.m_ghost || !(Vector3.Distance(lastPosition, cartTransform.position) >= distanceThreshold))
				{
					return;
				}
				lastPosition = cartTransform.position;
				RaycastHit raycast = default(RaycastHit);
				RaycastHit raycast2 = default(RaycastHit);
				RaycastHit raycast3 = default(RaycastHit);
				Vector3 val5 = default(Vector3);
				float y = default(float);
				foreach (Transform item in new List<Transform>
				{
					((Component)this).transform.Find("PlantPointLeft"),
					((Component)this).transform.Find("PlantPointRight")
				})
				{
					Vector3 val = item.position + item.up * 0.4f;
					Vector3 val2 = val + item.forward * -0.55f;
					Vector3 val3 = val + item.forward * 0.55f;
					Physics.Raycast(val, Vector3.down, ref raycast, 1f);
					Physics.Raycast(val2, Vector3.down, ref raycast2, 1f);
					Physics.Raycast(val3, Vector3.down, ref raycast3, 1f);
					if (!IsValidPlantPoint(raycast) || !IsValidPlantPoint(raycast2) || !IsValidPlantPoint(raycast3) || Physics.OverlapSphere(((RaycastHit)(ref raycast)).point, 0.5f, LayerMask.GetMask(new string[1] { "piece_nonsolid" })).Length != 0)
					{
						continue;
					}
					Inventory inventory = ((Component)((Component)this).transform.Find("Container")).GetComponent<Container>().GetInventory();
					List<ItemData> allItemsInGridOrder = inventory.GetAllItemsInGridOrder();
					allItemsInGridOrder.Reverse();
					List<ItemData> list = allItemsInGridOrder.Where((ItemData item) => m_allowedList.Any((string other) => item.m_shared.m_name.Contains(other))).ToList();
					if (list.Count == 0)
					{
						continue;
					}
					ItemData val4 = list.First();
					if (val4 == null)
					{
						continue;
					}
					string valueSafe = GeneralExtensions.GetValueSafe<string, string>(m_plantDict, val4.m_shared.m_name);
					if (valueSafe != null && !(valueSafe == ""))
					{
						((Vector3)(ref val5))..ctor(item.position.x, item.position.y, item.position.z);
						if (ZoneSystem.instance.FindFloor(val5, ref y))
						{
							val5.y = y;
						}
						Object.Instantiate<GameObject>(PrefabManager.Instance.GetPrefab(valueSafe), val5, item.rotation).GetComponent<Piece>().m_placeEffect.Create(val5, item.rotation, (Transform)null, 1f, -1, default(ZDOID));
						inventory.RemoveOneItem(val4);
						if (PluginConfig.piece1.durabilityLoss.Value > 0f)
						{
							((Component)this).gameObject.GetComponent<WearNTear>().ApplyDamage(PluginConfig.piece1.durabilityLoss.Value, (HitData)null);
						}
					}
				}
			}
			catch (Exception ex)
			{
				Logger.LogError((object)("Something went wrong in Planter update: " + ex));
			}
		}
	}
}