Decompiled source of Plant Craft Cook RootsAndRemedies v1.1.0

RootAndRemedies.dll

Decompiled 6 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using HarmonyLib;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[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("RootAndRemedies")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.13.0.0")]
[assembly: AssemblyInformationalVersion("0.13.0")]
[assembly: AssemblyProduct("RootAndRemedies")]
[assembly: AssemblyTitle("RootAndRemedies")]
[assembly: AssemblyVersion("0.13.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 RootsAndRemedies.Foods
{
	internal static class AdminGate
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static CoroutineHandler <0>__OnServer;

			public static CoroutineHandler <1>__OnClient;
		}

		private static CustomRPC rpc;

		private static bool? answer;

		private static float answered = -1000f;

		private static float asked = -1000f;

		private static ZNet owner;

		internal static void Init()
		{
			//IL_001a: 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_0025: Expected O, but got Unknown
			//IL_0035: 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_0040: Expected O, but got Unknown
			NetworkManager instance = NetworkManager.Instance;
			object obj = <>O.<0>__OnServer;
			if (obj == null)
			{
				CoroutineHandler val = OnServer;
				<>O.<0>__OnServer = val;
				obj = (object)val;
			}
			object obj2 = <>O.<1>__OnClient;
			if (obj2 == null)
			{
				CoroutineHandler val2 = OnClient;
				<>O.<1>__OnClient = val2;
				obj2 = (object)val2;
			}
			rpc = instance.AddRPC("RnR_AdminCheck", (CoroutineHandler)obj, (CoroutineHandler)obj2);
		}

		private static string Digits(string text)
		{
			text = (text ?? "").Trim();
			int length = text.Length;
			int num = length;
			while (num > 0 && char.IsDigit(text[num - 1]))
			{
				num--;
			}
			return text.Substring(num, length - num);
		}

		private static IEnumerable<string> Files()
		{
			string text = null;
			try
			{
				text = Utils.GetSaveDataPath((FileSource)2);
			}
			catch (Exception)
			{
			}
			if (!string.IsNullOrEmpty(text))
			{
				yield return Path.Combine(text, "admin.txt");
			}
			yield return Path.Combine(Paths.ConfigPath, "admin.txt");
		}

		private static HashSet<string> Ids()
		{
			HashSet<string> hashSet = new HashSet<string>();
			foreach (string item in Files())
			{
				try
				{
					if (!File.Exists(item))
					{
						continue;
					}
					string[] array = File.ReadAllLines(item);
					for (int i = 0; i < array.Length; i++)
					{
						string text = array[i].Trim();
						if (text.Length != 0 && !text.StartsWith("#"))
						{
							string text2 = Digits(text);
							if (text2.Length > 0)
							{
								hashSet.Add(text2);
							}
						}
					}
				}
				catch (Exception ex)
				{
					Plugin.Instance.LoggerGarden("admin.txt could not be read: " + ex.Message);
				}
			}
			return hashSet;
		}

		private static IEnumerator OnServer(long sender, ZPackage pkg)
		{
			ZNet instance = ZNet.instance;
			ZNetPeer val = ((instance != null) ? instance.GetPeer(sender) : null);
			bool flag = val != null && val.m_socket != null && Ids().Contains(Digits(val.m_socket.GetHostName()));
			ZPackage val2 = new ZPackage();
			val2.Write(flag);
			rpc.SendPackage(sender, val2);
			yield break;
		}

		private static IEnumerator OnClient(long sender, ZPackage pkg)
		{
			answer = pkg.ReadBool();
			answered = Time.time;
			yield break;
		}

		internal static bool Allowed(Terminal terminal)
		{
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Expected O, but got Unknown
			if ((Object)(object)ZNet.instance == (Object)null)
			{
				terminal.AddString("Enter a world first.");
				return false;
			}
			if ((Object)(object)owner != (Object)(object)ZNet.instance)
			{
				owner = ZNet.instance;
				answer = null;
			}
			if (ZNet.instance.IsServer())
			{
				return true;
			}
			if (answer == true && Time.time - answered < 60f)
			{
				return true;
			}
			if (Time.time - asked > 3f && ZNet.instance.GetServerPeer() != null)
			{
				asked = Time.time;
				rpc.SendPackage(ZNet.instance.GetServerPeer().m_uid, new ZPackage());
			}
			terminal.AddString((answer == false && Time.time - answered < 60f) ? "Only admins listed in admin.txt may use the rnr commands." : "Checking the admin list... try again in a second.");
			return false;
		}
	}
	public sealed class RnrPickTuning : MonoBehaviour
	{
		public string Kind;

		private void Awake()
		{
			Pickable component = ((Component)this).GetComponent<Pickable>();
			Plugin instance = Plugin.Instance;
			if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)instance))
			{
				switch (Kind)
				{
				case "flower":
					component.m_amount = instance.FlowersPerPick.Value;
					component.m_respawnTimeMinutes = instance.FlowerRegrowMinutes.Value;
					break;
				case "oyster":
					component.m_respawnTimeMinutes = instance.OysterRegrowMinutes.Value;
					break;
				case "rosemary":
					component.m_respawnTimeMinutes = instance.RosemaryRegrowMinutes.Value;
					break;
				}
			}
		}

		private void Start()
		{
			Pickable component = ((Component)this).GetComponent<Pickable>();
			if (Object.op_Implicit((Object)(object)component))
			{
				((MonoBehaviour)component).CancelInvoke("UpdateRespawn");
				((MonoBehaviour)component).InvokeRepeating("UpdateRespawn", Random.Range(0.2f, 1f), 1f);
			}
		}
	}
	internal static class DumpTools
	{
		private static class Screen_
		{
			internal static int W => Screen.width;

			internal static int H => Screen.height;
		}

		private const int MaxFiles = 600;

		internal const string Help = "rnr paste <name>|clear | rnr copyarea <name> <x> <y> <z> [radius] [filter] | rnr dumpnear [radius] [filter] | rnr dumploc <location> | rnr dumpsprites ui | status | items [filter] | sprites <filter> | questitems | screen [seconds]";

		private static readonly List<GameObject> Pasted = new List<GameObject>();

		private static string Root => Path.Combine(Paths.BepInExRootPath, "RnR-dump");

		internal static bool Command(string[] a, Terminal t)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Invalid comparison between Unknown and I4
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Invalid comparison between Unknown and I4
			//IL_033e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0344: Invalid comparison between Unknown and I4
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			if (a.Length != 0 && a[0] == "dumploc")
			{
				if ((int)SystemInfo.graphicsDeviceType == 4)
				{
					t.AddString("No graphics device (dedicated server): nothing to dump.");
					return true;
				}
				if (a.Length < 2)
				{
					t.AddString("rnr dumploc <location>   e.g. rnr dumploc GoblinCamp2");
					return true;
				}
				try
				{
					Location_(t, a[1]);
				}
				catch (Exception ex)
				{
					t.AddString("Dump failed: " + ex.Message);
					Plugin.Instance.LoggerGarden("dumploc: " + ex);
				}
				return true;
			}
			if (a.Length != 0 && a[0] == "paste")
			{
				if (a.Length < 2)
				{
					t.AddString("rnr paste <name> [distance, default 8]   places a saved copy (RnR-dump/copy-<name>.txt) in front of you;  rnr paste clear  removes the pasted copies");
					return true;
				}
				float result = 8f;
				if (a.Length > 2 && !float.TryParse(a[2], NumberStyles.Float, CultureInfo.InvariantCulture, out result))
				{
					result = 8f;
				}
				try
				{
					Paste(t, a[1], Mathf.Clamp(result, 2f, 60f));
				}
				catch (Exception ex2)
				{
					ZNetView.m_forceDisableInit = false;
					t.AddString("Paste failed: " + ex2.Message);
					Plugin.Instance.LoggerGarden("paste: " + ex2);
				}
				return true;
			}
			if (a.Length != 0 && a[0] == "copyarea")
			{
				CultureInfo invariantCulture = CultureInfo.InvariantCulture;
				if (a.Length < 5 || !float.TryParse(a[2].Replace(',', '.'), NumberStyles.Float, invariantCulture, out var result2) || !float.TryParse(a[3].Replace(',', '.'), NumberStyles.Float, invariantCulture, out var result3) || !float.TryParse(a[4].Replace(',', '.'), NumberStyles.Float, invariantCulture, out var result4))
				{
					t.AddString("rnr copyarea <name> <x> <y> <z> [radius 3-60, default 15] [name filter]   (the coordinates are the 'pos' of the console or the map: x east-west, y height, z north-south)");
					return true;
				}
				float result5 = 15f;
				if (a.Length > 5 && !float.TryParse(a[5].Replace(',', '.'), NumberStyles.Float, invariantCulture, out result5))
				{
					t.AddString("radius must be a number");
					return true;
				}
				try
				{
					CopyArea(t, a[1], new Vector3(result2, result3, result4), Mathf.Clamp(result5, 3f, 60f), (a.Length > 6) ? a[6] : "");
				}
				catch (Exception ex3)
				{
					t.AddString("Copy failed: " + ex3.Message);
					Plugin.Instance.LoggerGarden("copyarea: " + ex3);
				}
				return true;
			}
			if (a.Length != 0 && a[0] == "dumpnear")
			{
				if ((int)SystemInfo.graphicsDeviceType == 4)
				{
					t.AddString("No graphics device (dedicated server): nothing to dump.");
					return true;
				}
				float result6 = 45f;
				if (a.Length > 1 && !float.TryParse(a[1], out result6))
				{
					t.AddString("rnr dumpnear [radius 5-120]   (stand in the camp; default 45 m)");
					return true;
				}
				try
				{
					Near(t, Mathf.Clamp(result6, 5f, 120f), (a.Length > 2) ? a[2] : "goblin");
				}
				catch (Exception ex4)
				{
					t.AddString("Dump failed: " + ex4.Message);
					Plugin.Instance.LoggerGarden("dumpnear: " + ex4);
				}
				return true;
			}
			if (a.Length == 0 || a[0] != "dumpsprites")
			{
				return false;
			}
			if ((int)SystemInfo.graphicsDeviceType == 4)
			{
				t.AddString("No graphics device (dedicated server): nothing to dump.");
				return true;
			}
			string text = ((a.Length > 1) ? a[1].ToLowerInvariant() : "");
			string text2 = ((a.Length > 2) ? a[2] : "");
			try
			{
				switch (text)
				{
				case "ui":
					Ui(t);
					break;
				case "status":
					Status(t);
					break;
				case "items":
					Items(t, text2);
					break;
				case "sprites":
					if (text2.Length == 0)
					{
						t.AddString("rnr dumpsprites sprites <filter>");
					}
					else
					{
						Sprites(t, text2);
					}
					break;
				case "screen":
				{
					Screen(t, (a.Length > 2 && float.TryParse(a[2], out var result7)) ? Mathf.Clamp(result7, 0f, 60f) : 5f);
					break;
				}
				default:
					t.AddString("rnr paste <name>|clear | rnr copyarea <name> <x> <y> <z> [radius] [filter] | rnr dumpnear [radius] [filter] | rnr dumploc <location> | rnr dumpsprites ui | status | items [filter] | sprites <filter> | questitems | screen [seconds]");
					break;
				}
			}
			catch (Exception ex5)
			{
				t.AddString("Dump failed: " + ex5.Message);
				Plugin.Instance.LoggerGarden("dumpsprites: " + ex5);
			}
			return true;
		}

		private static string Folder(string name)
		{
			string text = Path.Combine(Root, name);
			Directory.CreateDirectory(text);
			return text;
		}

		private static string Safe(string s)
		{
			char[] invalidFileNameChars = Path.GetInvalidFileNameChars();
			foreach (char oldChar in invalidFileNameChars)
			{
				s = s.Replace(oldChar, '_');
			}
			if (s.Length <= 80)
			{
				return s;
			}
			return s.Substring(0, 80);
		}

		private static bool Save(Sprite s, string folder, HashSet<string> used)
		{
			//IL_001a: 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_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Expected O, but got Unknown
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)s == (Object)null || (Object)(object)s.texture == (Object)null)
			{
				return false;
			}
			Rect textureRect = s.textureRect;
			int num = (int)((Rect)(ref textureRect)).width;
			int num2 = (int)((Rect)(ref textureRect)).height;
			if (num < 2 || num2 < 2 || num > 4096 || num2 > 4096)
			{
				return false;
			}
			string text = Safe(((Object)s).name);
			string text2 = text;
			int num3 = 1;
			while (!used.Add(text2))
			{
				text2 = text + "_" + num3++;
			}
			Texture2D texture = s.texture;
			RenderTexture temporary = RenderTexture.GetTemporary(((Texture)texture).width, ((Texture)texture).height, 0, (RenderTextureFormat)0, (RenderTextureReadWrite)2);
			RenderTexture active = RenderTexture.active;
			try
			{
				Graphics.Blit((Texture)(object)texture, temporary);
				RenderTexture.active = temporary;
				Texture2D val = new Texture2D(num, num2, (TextureFormat)4, false);
				val.ReadPixels(new Rect(((Rect)(ref textureRect)).x, ((Rect)(ref textureRect)).y, (float)num, (float)num2), 0, 0);
				val.Apply();
				File.WriteAllBytes(Path.Combine(folder, text2 + ".png"), ImageConversion.EncodeToPNG(val));
				Object.Destroy((Object)(object)val);
				return true;
			}
			finally
			{
				RenderTexture.active = active;
				RenderTexture.ReleaseTemporary(temporary);
			}
		}

		private static int SaveAll(IEnumerable<Sprite> sprites, string folder)
		{
			HashSet<string> used = new HashSet<string>();
			int num = 0;
			foreach (Sprite item in from x in sprites
				where (Object)(object)x != (Object)null
				group x by ((Object)x).GetInstanceID() into g
				select g.First())
			{
				if (num >= 600)
				{
					break;
				}
				try
				{
					if (Save(item, folder, used))
					{
						num++;
					}
				}
				catch (Exception ex)
				{
					Plugin.Instance.LoggerGarden("dumpsprites " + ((Object)item).name + ": " + ex.Message);
				}
			}
			return num;
		}

		private static string PathOf(Transform t)
		{
			string text = ((Object)t).name;
			Transform parent = t.parent;
			while ((Object)(object)parent != (Object)null)
			{
				text = ((Object)parent).name + "/" + text;
				parent = parent.parent;
			}
			return text;
		}

		private static void Ui(Terminal t)
		{
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_0297: Unknown result type (might be due to invalid IL or missing references)
			string text = Folder("ui");
			StringBuilder stringBuilder = new StringBuilder();
			List<Sprite> list = new List<Sprite>();
			SortedDictionary<string, int> sortedDictionary = new SortedDictionary<string, int>();
			List<Canvas> list2 = Resources.FindObjectsOfTypeAll<Canvas>().Where(delegate(Canvas c)
			{
				//IL_000e: 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)
				if (c.isRootCanvas)
				{
					Scene scene = ((Component)c).gameObject.scene;
					return ((Scene)(ref scene)).IsValid();
				}
				return false;
			}).ToList();
			stringBuilder.AppendLine("Root canvases: " + list2.Count + "  (screen " + Screen_.W + "x" + Screen_.H + ")");
			int num = 0;
			foreach (Canvas item in list2)
			{
				stringBuilder.AppendLine().AppendLine("== CANVAS " + ((Object)item).name + " mode " + ((object)item.renderMode/*cast due to .constrained prefix*/).ToString() + " scale " + item.scaleFactor + " active=" + ((Component)item).gameObject.activeInHierarchy);
				Graphic[] componentsInChildren = ((Component)item).GetComponentsInChildren<Graphic>(true);
				foreach (Graphic val in componentsInChildren)
				{
					if (num++ > 8000)
					{
						break;
					}
					RectTransform rectTransform = val.rectTransform;
					StringBuilder stringBuilder2 = stringBuilder.Append(((Component)val).gameObject.activeInHierarchy ? "  " : "  (off) ").Append(PathOf(((Component)val).transform)).Append(" [")
						.Append(((object)val).GetType().Name)
						.Append("] size ");
					Rect rect = rectTransform.rect;
					StringBuilder stringBuilder3 = stringBuilder2.Append(Mathf.Round(((Rect)(ref rect)).width)).Append('x');
					rect = rectTransform.rect;
					stringBuilder3.Append(Mathf.Round(((Rect)(ref rect)).height)).Append(" color ").Append(ColorUtility.ToHtmlStringRGBA(val.color));
					Image val2 = (Image)(object)((val is Image) ? val : null);
					if (val2 != null && (Object)(object)val2.sprite != (Object)null)
					{
						stringBuilder.Append(" sprite ").Append(((Object)val2.sprite).name).Append(" ")
							.Append(val2.type)
							.Append(" border ")
							.Append(val2.sprite.border);
						list.Add(val2.sprite);
					}
					else
					{
						TMP_Text val3 = (TMP_Text)(object)((val is TMP_Text) ? val : null);
						if (val3 != null)
						{
							stringBuilder.Append(" font ").Append(Object.op_Implicit((Object)(object)val3.font) ? ((Object)val3.font).name : "?").Append(" size ")
								.Append(val3.fontSize)
								.Append(" text \"")
								.Append((val3.text ?? "").Replace("\n", " ").Replace("\r", ""))
								.Append('"');
							sortedDictionary[Object.op_Implicit((Object)(object)val3.font) ? ((Object)val3.font).name : "?"] = (sortedDictionary.TryGetValue(Object.op_Implicit((Object)(object)val3.font) ? ((Object)val3.font).name : "?", out var value) ? value : 0) + 1;
						}
						else
						{
							Text val4 = (Text)(object)((val is Text) ? val : null);
							if (val4 != null)
							{
								stringBuilder.Append(" font ").Append(Object.op_Implicit((Object)(object)val4.font) ? ((Object)val4.font).name : "?").Append(" size ")
									.Append(val4.fontSize)
									.Append(" text \"")
									.Append((val4.text ?? "").Replace("\n", " ").Replace("\r", ""))
									.Append('"');
								sortedDictionary[Object.op_Implicit((Object)(object)val4.font) ? ((Object)val4.font).name : "?"] = (sortedDictionary.TryGetValue(Object.op_Implicit((Object)(object)val4.font) ? ((Object)val4.font).name : "?", out var value2) ? value2 : 0) + 1;
							}
						}
					}
					stringBuilder.AppendLine();
				}
			}
			stringBuilder.AppendLine().AppendLine("== FONTS");
			foreach (KeyValuePair<string, int> item2 in sortedDictionary)
			{
				stringBuilder.AppendLine("  " + item2.Key + " x" + item2.Value);
			}
			File.WriteAllText(Path.Combine(Root, "ui-hierarchy.txt"), stringBuilder.ToString());
			int num3 = SaveAll(list, text);
			t.AddString("UI dump: hierarchy in " + Path.Combine(Root, "ui-hierarchy.txt") + ", " + num3 + " sprites in " + text);
		}

		private static void Status(Terminal t)
		{
			if (!Object.op_Implicit((Object)(object)ObjectDB.instance))
			{
				t.AddString("Enter a world first.");
				return;
			}
			t.AddString("Status effect icons: " + SaveAll(from s in ObjectDB.instance.m_StatusEffects
				where (Object)(object)s != (Object)null
				select s.m_icon, Folder("status")) + " in " + Folder("status"));
		}

		private static void Items(Terminal t, string filter)
		{
			if (!Object.op_Implicit((Object)(object)ObjectDB.instance))
			{
				t.AddString("Enter a world first.");
				return;
			}
			List<Sprite> list = new List<Sprite>();
			foreach (GameObject item in ObjectDB.instance.m_items)
			{
				ItemDrop val = (Object.op_Implicit((Object)(object)item) ? item.GetComponent<ItemDrop>() : null);
				if (!((Object)(object)val == (Object)null) && val.m_itemData.m_shared.m_icons != null && val.m_itemData.m_shared.m_icons.Length != 0 && (filter.Length <= 0 || ((Object)item).name.IndexOf(filter, StringComparison.OrdinalIgnoreCase) >= 0))
				{
					Sprite val2 = val.m_itemData.m_shared.m_icons[0];
					if (!((Object)(object)val2 == (Object)null))
					{
						list.Add(val2);
					}
				}
			}
			int num = SaveAll(list, Folder("items"));
			t.AddString("Item icons: " + num + " in " + Folder("items") + ((list.Count > 600) ? (" (limited to " + 600 + "; use a filter)") : ""));
		}

		private static void Sprites(Terminal t, string filter)
		{
			List<Sprite> list = (from s in Resources.FindObjectsOfTypeAll<Sprite>()
				where Object.op_Implicit((Object)(object)s) && ((Object)s).name.IndexOf(filter, StringComparison.OrdinalIgnoreCase) >= 0
				select s).ToList();
			int num = SaveAll(list, Folder("sprites_" + Safe(filter)));
			t.AddString("Sprites matching '" + filter + "': " + list.Count + " found, " + num + " saved in " + Folder("sprites_" + Safe(filter)));
		}

		private static Bounds MeshBounds(Renderer r)
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: 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_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: 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_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			Mesh val = null;
			if (r is MeshRenderer)
			{
				MeshFilter component = ((Component)r).GetComponent<MeshFilter>();
				val = (Object.op_Implicit((Object)(object)component) ? component.sharedMesh : null);
			}
			else
			{
				SkinnedMeshRenderer val2 = (SkinnedMeshRenderer)(object)((r is SkinnedMeshRenderer) ? r : null);
				if (val2 != null)
				{
					val = val2.sharedMesh;
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				return new Bounds(((Component)r).transform.position, Vector3.zero);
			}
			Bounds bounds = val.bounds;
			bool flag = true;
			Bounds result = default(Bounds);
			for (int i = 0; i < 8; i++)
			{
				Vector3 val3 = ((Bounds)(ref bounds)).center + Vector3.Scale(((Bounds)(ref bounds)).extents, new Vector3(((i & 1) == 0) ? (-1f) : 1f, ((i & 2) == 0) ? (-1f) : 1f, ((i & 4) == 0) ? (-1f) : 1f));
				Vector3 val4 = ((Component)r).transform.TransformPoint(val3);
				if (flag)
				{
					((Bounds)(ref result))..ctor(val4, Vector3.zero);
					flag = false;
				}
				else
				{
					((Bounds)(ref result)).Encapsulate(val4);
				}
			}
			return result;
		}

		private static void Location_(Terminal t, string name)
		{
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0317: 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_0339: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_07eb: Expected O, but got Unknown
			//IL_0801: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_085b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0864: Unknown result type (might be due to invalid IL or missing references)
			//IL_0877: Unknown result type (might be due to invalid IL or missing references)
			//IL_087c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0592: Unknown result type (might be due to invalid IL or missing references)
			//IL_0597: 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_05c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0610: Unknown result type (might be due to invalid IL or missing references)
			//IL_0615: Unknown result type (might be due to invalid IL or missing references)
			//IL_063c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0641: Unknown result type (might be due to invalid IL or missing references)
			//IL_0668: Unknown result type (might be due to invalid IL or missing references)
			//IL_066d: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0704: Unknown result type (might be due to invalid IL or missing references)
			ZoneSystem instance = ZoneSystem.instance;
			if ((Object)(object)instance == (Object)null)
			{
				t.AddString("Enter a world first.");
				return;
			}
			ZoneLocation val = ((IEnumerable<ZoneLocation>)instance.m_locations).FirstOrDefault((Func<ZoneLocation, bool>)((ZoneLocation l) => l != null && l.m_prefab.IsValid && l.m_prefab.Name.Equals(name, StringComparison.OrdinalIgnoreCase)));
			if (val == null)
			{
				t.AddString("No location '" + name + "'. Similar: " + string.Join(", ", (from l in instance.m_locations
					where l != null && l.m_prefab.IsValid && l.m_prefab.Name.IndexOf((name.Length > 4) ? name.Substring(0, 4) : name, StringComparison.OrdinalIgnoreCase) >= 0
					select l.m_prefab.Name).Take(12)));
				return;
			}
			val.m_prefab.Load();
			GameObject prefab = val.m_prefab.Asset;
			if ((Object)(object)prefab == (Object)null)
			{
				t.AddString("Could not load " + name + ".");
				return;
			}
			Directory.CreateDirectory(Root);
			string text = Folder("clusters_" + Safe(name));
			StringBuilder sb = new StringBuilder();
			sb.AppendLine("Location " + ((Object)prefab).name + "  exterior radius " + (Object.op_Implicit((Object)(object)prefab.GetComponent<Location>()) ? prefab.GetComponent<Location>().m_exteriorRadius : 0f));
			Walk(prefab.transform, 0);
			File.WriteAllText(Path.Combine(Root, "loc-" + Safe(name) + ".txt"), sb.ToString());
			HashSet<Renderer> skip = new HashSet<Renderer>();
			LODGroup[] componentsInChildren = prefab.GetComponentsInChildren<LODGroup>(true);
			for (int num = 0; num < componentsInChildren.Length; num++)
			{
				LOD[] lODs = componentsInChildren[num].GetLODs();
				for (int num2 = 1; num2 < lODs.Length; num2++)
				{
					Renderer[] renderers = lODs[num2].renderers;
					foreach (Renderer val2 in renderers)
					{
						if (Object.op_Implicit((Object)(object)val2))
						{
							skip.Add(val2);
						}
					}
				}
			}
			var items = (from r in prefab.GetComponentsInChildren<Renderer>(true)
				where Object.op_Implicit((Object)(object)r) && !skip.Contains(r) && (r is MeshRenderer || r is SkinnedMeshRenderer)
				select new
				{
					r = r,
					b = MeshBounds(r)
				}).Where(x =>
			{
				//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_0009: Unknown result type (might be due to invalid IL or missing references)
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				Bounds b2 = x.b;
				Vector3 size = ((Bounds)(ref b2)).size;
				return ((Vector3)(ref size)).sqrMagnitude > 0f;
			}).ToList();
			if (items.Count == 0)
			{
				Rooms_(t, prefab, name, text);
				return;
			}
			int[] parent = Enumerable.Range(0, items.Count).ToArray();
			for (int num4 = 0; num4 < items.Count; num4++)
			{
				for (int num5 = num4 + 1; num5 < items.Count; num5++)
				{
					Bounds b = items[num4].b;
					((Bounds)(ref b)).Expand(0.5f);
					if (((Bounds)(ref b)).Intersects(items[num5].b))
					{
						int num6 = Find(num4);
						int num7 = Find(num5);
						if (num6 != num7)
						{
							parent[num6] = num7;
						}
					}
				}
			}
			List<List<int>> list = (from g in Enumerable.Range(0, items.Count).GroupBy(Find)
				select g.ToList() into g
				where g.Count >= 2
				select g).OrderBy(delegate(List<int> g)
			{
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: 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)
				Bounds b2 = items[g[0]].b;
				return ((Bounds)(ref b2)).center.x;
			}).ToList();
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.AppendLine("clusters of " + name + " (" + items.Count + " meshes): N  centre(x,y,z)  size(w,h,d)  meshes  names");
			List<Texture2D> list2 = new List<Texture2D>();
			for (int num8 = 0; num8 < list.Count && num8 < 48; num8++)
			{
				List<int> list3 = list[num8];
				Bounds all = items[list3[0]].b;
				foreach (int item in list3)
				{
					((Bounds)(ref all)).Encapsulate(items[item].b);
				}
				IEnumerable<string> values = from g in (from i in list3
						group i by (!Object.op_Implicit((Object)(object)((Component)items[i].r).transform.parent) || !((Object)(object)((Component)items[i].r).transform.parent != (Object)(object)prefab.transform)) ? ((Object)items[i].r).name : ((Object)((Component)items[i].r).transform.parent).name into g
						orderby g.Count() descending
						select g).Take(5)
					select g.Key + "x" + g.Count();
				stringBuilder.AppendLine(num8 + "  (" + ((Bounds)(ref all)).center.x.ToString("F1") + "," + ((Bounds)(ref all)).center.y.ToString("F1") + "," + ((Bounds)(ref all)).center.z.ToString("F1") + ")  (" + ((Bounds)(ref all)).size.x.ToString("F1") + "," + ((Bounds)(ref all)).size.y.ToString("F1") + "," + ((Bounds)(ref all)).size.z.ToString("F1") + ")  " + list3.Count + "  " + string.Join(", ", values));
				List<Renderer> members = list3.Select((int i) => items[i].r).ToList();
				Vector3 centre = ((Bounds)(ref all)).center;
				Texture2D val3 = IconRender.RenderIcon(delegate(GameObject g)
				{
					//IL_005a: 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_0071: Unknown result type (might be due to invalid IL or missing references)
					//IL_007d: Unknown result type (might be due to invalid IL or missing references)
					//IL_0093: Unknown result type (might be due to invalid IL or missing references)
					//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
					//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
					//IL_00b7: 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_00cd: Unknown result type (might be due to invalid IL or missing references)
					//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
					//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
					foreach (Renderer item2 in members)
					{
						Mesh val5 = ((!(item2 is MeshRenderer)) ? ((SkinnedMeshRenderer)((item2 is SkinnedMeshRenderer) ? item2 : null)).sharedMesh : (Object.op_Implicit((Object)(object)((Component)item2).GetComponent<MeshFilter>()) ? ((Component)item2).GetComponent<MeshFilter>().sharedMesh : null));
						if (Object.op_Implicit((Object)(object)val5))
						{
							GameObject val6 = new GameObject("m");
							val6.transform.SetParent(g.transform, false);
							val6.transform.position = ((Component)item2).transform.position - new Vector3(centre.x, ((Bounds)(ref all)).min.y, centre.z);
							val6.transform.rotation = ((Component)item2).transform.rotation;
							val6.transform.localScale = ((Component)item2).transform.lossyScale;
							val6.AddComponent<MeshFilter>().sharedMesh = val5;
							((Renderer)val6.AddComponent<MeshRenderer>()).sharedMaterials = item2.sharedMaterials;
						}
					}
				}, 25f, 22f, 192);
				if (!((Object)(object)val3 == (Object)null))
				{
					File.WriteAllBytes(Path.Combine(text, num8.ToString("00") + ".png"), ImageConversion.EncodeToPNG(val3));
					list2.Add(val3);
				}
			}
			File.WriteAllText(Path.Combine(Root, "loc-" + Safe(name) + "-clusters.txt"), stringBuilder.ToString());
			if (list2.Count > 0)
			{
				int num9 = 6;
				int num10 = (list2.Count + num9 - 1) / num9;
				Texture2D val4 = new Texture2D(num9 * 192, num10 * 192, (TextureFormat)4, false);
				val4.SetPixels(Enumerable.Repeat<Color>(new Color(0.18f, 0.2f, 0.22f, 1f), num9 * 192 * num10 * 192).ToArray());
				for (int num11 = 0; num11 < list2.Count; num11++)
				{
					Color[] pixels = list2[num11].GetPixels();
					for (int num12 = 0; num12 < pixels.Length; num12++)
					{
						pixels[num12] = Color.Lerp(new Color(0.18f, 0.2f, 0.22f, 1f), pixels[num12], pixels[num12].a);
					}
					val4.SetPixels(num11 % num9 * 192, (num10 - 1 - num11 / num9) * 192, 192, 192, pixels);
				}
				val4.Apply();
				File.WriteAllBytes(Path.Combine(text, "sheet.png"), ImageConversion.EncodeToPNG(val4));
				Object.Destroy((Object)(object)val4);
			}
			t.AddString("Location " + name + ": " + list.Count + " clusters -> " + text + " (sheet.png, one picture per number); tree in loc-" + Safe(name) + ".txt, list in loc-" + Safe(name) + "-clusters.txt");
			int Find(int i)
			{
				while (parent[i] != i)
				{
					parent[i] = parent[parent[i]];
					i = parent[i];
				}
				return i;
			}
			void Walk(Transform tr, int depth)
			{
				//IL_003d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0042: 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_0064: 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_0166: Expected O, but got Unknown
				int num13 = ((Component)tr).GetComponents<Renderer>().Length;
				int num14 = ((Component)tr).GetComponents<Collider>().Length;
				StringBuilder stringBuilder2 = sb.Append(new string(' ', depth * 2)).Append(((Object)tr).name).Append("  pos ");
				Vector3 val5 = tr.localPosition;
				StringBuilder stringBuilder3 = stringBuilder2.Append(((Vector3)(ref val5)).ToString("F1")).Append(" scale ");
				val5 = tr.localScale;
				stringBuilder3.Append(((Vector3)(ref val5)).ToString("F1")).Append((num13 > 0) ? ("  R" + num13) : "").Append((num14 > 0) ? ("  C" + num14) : "")
					.Append(Object.op_Implicit((Object)(object)((Component)tr).GetComponent<ZNetView>()) ? "  NET" : "")
					.Append(Object.op_Implicit((Object)(object)((Component)tr).GetComponent<WearNTear>()) ? "  WEAR" : "")
					.Append(Object.op_Implicit((Object)(object)((Component)tr).GetComponent<Piece>()) ? "  PIECE" : "")
					.Append((tr.childCount > 0) ? ("  (" + tr.childCount + " children)") : "")
					.AppendLine();
				if (depth < 5)
				{
					foreach (Transform item3 in tr)
					{
						Transform tr2 = item3;
						Walk(tr2, depth + 1);
					}
				}
			}
		}

		private static void Rooms_(Terminal t, GameObject prefab, string name, string folder)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cd: Expected O, but got Unknown
			//IL_05e3: 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_063d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0646: Unknown result type (might be due to invalid IL or missing references)
			//IL_0659: Unknown result type (might be due to invalid IL or missing references)
			//IL_065e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04be: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c6: Unknown result type (might be due to invalid IL or missing references)
			DungeonGenerator componentInChildren = prefab.GetComponentInChildren<DungeonGenerator>(true);
			if ((Object)(object)componentInChildren == (Object)null)
			{
				t.AddString(name + " has no meshes and no dungeon generator: nothing to show.");
				return;
			}
			Theme theme = componentInChildren.m_themes;
			List<RoomData> list = DungeonDB.GetRooms().Where(delegate(RoomData r)
			{
				//IL_0004: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				//IL_0018: Invalid comparison between Unknown and I4
				if (r != null)
				{
					_ = r.m_prefab;
					return (r.m_theme & theme) > 0;
				}
				return false;
			}).ToList();
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.AppendLine("rooms of " + name + " (generator theme " + ((object)Unsafe.As<Theme, Theme>(ref theme)/*cast due to .constrained prefix*/).ToString() + ", " + list.Count + " rooms, places " + componentInChildren.m_minRooms + "-" + componentInChildren.m_maxRooms + "): N  prefab  size(cells)  weight  flags  meshes  colliders  net  wear  top parts");
			List<Texture2D> list2 = new List<Texture2D>();
			int num = 0;
			foreach (RoomData item in list)
			{
				try
				{
					item.m_prefab.Load();
				}
				catch (Exception)
				{
					continue;
				}
				GameObject asset = item.m_prefab.Asset;
				if ((Object)(object)asset == (Object)null)
				{
					continue;
				}
				Room component = asset.GetComponent<Room>();
				HashSet<Renderer> skip = new HashSet<Renderer>();
				LODGroup[] componentsInChildren = asset.GetComponentsInChildren<LODGroup>(true);
				for (int num2 = 0; num2 < componentsInChildren.Length; num2++)
				{
					LOD[] lODs = componentsInChildren[num2].GetLODs();
					for (int num3 = 1; num3 < lODs.Length; num3++)
					{
						Renderer[] renderers = lODs[num3].renderers;
						foreach (Renderer val in renderers)
						{
							if (Object.op_Implicit((Object)(object)val))
							{
								skip.Add(val);
							}
						}
					}
				}
				List<Renderer> members = (from r in asset.GetComponentsInChildren<Renderer>(true)
					where Object.op_Implicit((Object)(object)r) && !skip.Contains(r) && (r is MeshRenderer || r is SkinnedMeshRenderer)
					select r).ToList();
				Bounds val2 = default(Bounds);
				bool flag = false;
				foreach (Renderer item2 in members)
				{
					Bounds val3 = MeshBounds(item2);
					Vector3 size = ((Bounds)(ref val3)).size;
					if (!(((Vector3)(ref size)).sqrMagnitude <= 0f))
					{
						if (!flag)
						{
							val2 = val3;
							flag = true;
						}
						else
						{
							((Bounds)(ref val2)).Encapsulate(val3);
						}
					}
				}
				IEnumerable<string> values = from g in (from Transform c in (IEnumerable)asset.transform
						select ((Object)c).name into x
						group x by x into g
						orderby g.Count() descending
						select g).Take(6)
					select g.Key + "x" + g.Count();
				string text = (((Object)(object)component == (Object)null) ? "" : ((component.m_entrance ? "entrance " : "") + (component.m_endCap ? "endcap " : "") + (component.m_divider ? "divider " : "") + (component.m_perimeter ? "perimeter " : "")));
				stringBuilder.AppendLine(num + "  " + ((Object)asset).name + "  " + (((Object)(object)component != (Object)null) ? ((object)Unsafe.As<Vector3Int, Vector3Int>(ref component.m_size)/*cast due to .constrained prefix*/).ToString() : "?") + "  " + (((Object)(object)component != (Object)null) ? component.m_weight : 0f) + "  " + text + " " + members.Count + "  " + asset.GetComponentsInChildren<Collider>(true).Length + "  " + asset.GetComponentsInChildren<ZNetView>(true).Length + "  " + asset.GetComponentsInChildren<WearNTear>(true).Length + "  " + string.Join(", ", values));
				if (flag)
				{
					Vector3 centre = ((Bounds)(ref val2)).center;
					float low = ((Bounds)(ref val2)).min.y;
					Texture2D val4 = IconRender.RenderIcon(delegate(GameObject g)
					{
						//IL_005f: Unknown result type (might be due to invalid IL or missing references)
						//IL_0064: Unknown result type (might be due to invalid IL or missing references)
						//IL_0076: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
						//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
						//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
						//IL_00be: Unknown result type (might be due to invalid IL or missing references)
						//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
						//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
						//IL_00de: Unknown result type (might be due to invalid IL or missing references)
						foreach (Renderer item3 in members)
						{
							Mesh val6 = ((!(item3 is MeshRenderer)) ? ((SkinnedMeshRenderer)((item3 is SkinnedMeshRenderer) ? item3 : null)).sharedMesh : (Object.op_Implicit((Object)(object)((Component)item3).GetComponent<MeshFilter>()) ? ((Component)item3).GetComponent<MeshFilter>().sharedMesh : null));
							if (Object.op_Implicit((Object)(object)val6))
							{
								GameObject val7 = new GameObject("m");
								val7.transform.SetParent(g.transform, false);
								val7.transform.position = ((Component)item3).transform.position - new Vector3(centre.x, low, centre.z);
								val7.transform.rotation = ((Component)item3).transform.rotation;
								val7.transform.localScale = ((Component)item3).transform.lossyScale;
								val7.AddComponent<MeshFilter>().sharedMesh = val6;
								((Renderer)val7.AddComponent<MeshRenderer>()).sharedMaterials = item3.sharedMaterials;
							}
						}
					}, 35f, 25f, 192);
					if ((Object)(object)val4 != (Object)null)
					{
						Directory.CreateDirectory(Path.Combine(folder, "rooms"));
						File.WriteAllBytes(Path.Combine(folder, "rooms", num.ToString("00") + ".png"), ImageConversion.EncodeToPNG(val4));
						list2.Add(val4);
					}
				}
				num++;
			}
			File.WriteAllText(Path.Combine(Root, "loc-" + Safe(name) + "-rooms.txt"), stringBuilder.ToString());
			if (list2.Count > 0)
			{
				int num5 = 6;
				int num6 = (list2.Count + num5 - 1) / num5;
				Texture2D val5 = new Texture2D(num5 * 192, num6 * 192, (TextureFormat)4, false);
				val5.SetPixels(Enumerable.Repeat<Color>(new Color(0.18f, 0.2f, 0.22f, 1f), num5 * 192 * num6 * 192).ToArray());
				for (int num7 = 0; num7 < list2.Count; num7++)
				{
					Color[] pixels = list2[num7].GetPixels();
					for (int num8 = 0; num8 < pixels.Length; num8++)
					{
						pixels[num8] = Color.Lerp(new Color(0.18f, 0.2f, 0.22f, 1f), pixels[num8], pixels[num8].a);
					}
					val5.SetPixels(num7 % num5 * 192, (num6 - 1 - num7 / num5) * 192, 192, 192, pixels);
				}
				val5.Apply();
				File.WriteAllBytes(Path.Combine(folder, "sheet.png"), ImageConversion.EncodeToPNG(val5));
				Object.Destroy((Object)(object)val5);
			}
			t.AddString(name + " is built from " + list.Count + " rooms (" + ((object)Unsafe.As<Theme, Theme>(ref theme)/*cast due to .constrained prefix*/).ToString() + "): pictures in " + Path.Combine(folder, "rooms") + " and sheet.png; list in loc-" + Safe(name) + "-rooms.txt");
		}

		private static void Near(Terminal t, float radius, string filter)
		{
			//IL_0035: 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_0191: 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_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02de: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0309: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f5: Expected O, but got Unknown
			//IL_080b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0477: Unknown result type (might be due to invalid IL or missing references)
			//IL_047c: Unknown result type (might be due to invalid IL or missing references)
			//IL_04aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0879: Unknown result type (might be due to invalid IL or missing references)
			//IL_0882: Unknown result type (might be due to invalid IL or missing references)
			//IL_0895: Unknown result type (might be due to invalid IL or missing references)
			//IL_089a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0513: Unknown result type (might be due to invalid IL or missing references)
			//IL_0518: Unknown result type (might be due to invalid IL or missing references)
			//IL_0538: Unknown result type (might be due to invalid IL or missing references)
			//IL_053d: 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_0585: Unknown result type (might be due to invalid IL or missing references)
			//IL_058b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0590: Unknown result type (might be due to invalid IL or missing references)
			//IL_0595: 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_05c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05de: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_061a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0621: Unknown result type (might be due to invalid IL or missing references)
			//IL_0626: Unknown result type (might be due to invalid IL or missing references)
			//IL_062b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0674: Unknown result type (might be due to invalid IL or missing references)
			//IL_0679: 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_069e: Unknown result type (might be due to invalid IL or missing references)
			Player localPlayer = Player.m_localPlayer;
			if (!Object.op_Implicit((Object)(object)localPlayer))
			{
				t.AddString("Enter a world first.");
				return;
			}
			Vector3 origin = ((Component)localPlayer).transform.position;
			List<ZNetView> list = (from val6 in Object.FindObjectsOfType<ZNetView>()
				where Object.op_Implicit((Object)(object)val6) && val6.GetZDO() != null && !Object.op_Implicit((Object)(object)((Component)val6).GetComponent<Character>()) && !Object.op_Implicit((Object)(object)((Component)val6).GetComponent<Player>()) && Vector2.Distance(new Vector2(((Component)val6).transform.position.x, ((Component)val6).transform.position.z), new Vector2(origin.x, origin.z)) <= radius
				select val6).ToList();
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.AppendLine("Networked objects within " + radius + " m of " + ((Vector3)(ref origin)).ToString("F0") + ": " + list.Count);
			Vector3 val2;
			foreach (IGrouping<string, ZNetView> item in from val6 in list
				group val6 by Utils.GetPrefabName(((Component)val6).gameObject) into g
				orderby g.Count() descending
				select g)
			{
				ZNetView val = item.OrderBy(delegate(ZNetView val7)
				{
					//IL_0006: 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_0011: Unknown result type (might be due to invalid IL or missing references)
					//IL_0016: Unknown result type (might be due to invalid IL or missing references)
					Vector3 val6 = ((Component)val7).transform.position - origin;
					return ((Vector3)(ref val6)).sqrMagnitude;
				}).First();
				string[] obj = new string[10]
				{
					"  ",
					item.Key,
					" x",
					item.Count().ToString(),
					"  nearest ",
					null,
					null,
					null,
					null,
					null
				};
				val2 = ((Component)val).transform.position - origin;
				obj[5] = ((Vector3)(ref val2)).ToString("F1");
				obj[6] = (Object.op_Implicit((Object)(object)((Component)val).GetComponent<WearNTear>()) ? "  WEAR" : "");
				obj[7] = (Object.op_Implicit((Object)(object)((Component)val).GetComponent<Piece>()) ? "  PIECE" : "");
				obj[8] = "  colliders ";
				obj[9] = ((Component)val).GetComponentsInChildren<Collider>(true).Length.ToString();
				stringBuilder.AppendLine(string.Concat(obj));
			}
			List<ZNetView> list2 = list.Where((ZNetView val6) => Utils.GetPrefabName(((Component)val6).gameObject).IndexOf(filter, StringComparison.OrdinalIgnoreCase) >= 0).ToList();
			var data = (from x in list2.Select(delegate(ZNetView v2)
				{
					List<Renderer> list6 = new List<Renderer>();
					Bounds? b = BoundsOf(v2, list6);
					return new
					{
						v = v2,
						rs = list6,
						b = b
					};
				})
				where x.b.HasValue
				select x).ToList();
			int[] parent = Enumerable.Range(0, data.Count).ToArray();
			for (int num = 0; num < data.Count; num++)
			{
				for (int num2 = num + 1; num2 < data.Count; num2++)
				{
					Bounds value = data[num].b.Value;
					((Bounds)(ref value)).Expand(0.6f);
					if (((Bounds)(ref value)).Intersects(data[num2].b.Value))
					{
						int num3 = Find(num);
						int num4 = Find(num2);
						if (num3 != num4)
						{
							parent[num3] = num4;
						}
					}
				}
			}
			List<List<int>> list3 = (from g in Enumerable.Range(0, data.Count).GroupBy(Find)
				select g.ToList()).OrderBy(delegate(List<int> g)
			{
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: 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_002c: Unknown result type (might be due to invalid IL or missing references)
				Vector3 val6 = ((Component)data[g[0]].v).transform.position - origin;
				return ((Vector3)(ref val6)).sqrMagnitude;
			}).ToList();
			string text = Folder("near");
			List<Texture2D> list4 = new List<Texture2D>();
			stringBuilder.AppendLine().AppendLine("Buildings made of '" + filter + "' objects (" + list2.Count + " objects, " + list3.Count + " groups); members: prefab  position  rotation(euler)  scale  relative to the centre of the group, floor level 0");
			for (int num5 = 0; num5 < list3.Count && num5 < 40; num5++)
			{
				List<int> list5 = list3[num5];
				Bounds value2 = data[list5[0]].b.Value;
				foreach (int item2 in list5)
				{
					((Bounds)(ref value2)).Encapsulate(data[item2].b.Value);
				}
				StringBuilder stringBuilder2 = stringBuilder.AppendLine();
				string[] obj2 = new string[13]
				{
					"[",
					num5.ToString(),
					"] ",
					list5.Count.ToString(),
					" objects, size (",
					null,
					null,
					null,
					null,
					null,
					null,
					null,
					null
				};
				val2 = ((Bounds)(ref value2)).size;
				obj2[5] = val2.x.ToString("F1");
				obj2[6] = ",";
				val2 = ((Bounds)(ref value2)).size;
				obj2[7] = val2.y.ToString("F1");
				obj2[8] = ",";
				val2 = ((Bounds)(ref value2)).size;
				obj2[9] = val2.z.ToString("F1");
				obj2[10] = "), ";
				val2 = ((Bounds)(ref value2)).center - origin;
				obj2[11] = ((Vector3)(ref val2)).ToString("F0");
				obj2[12] = " from you";
				stringBuilder2.AppendLine(string.Concat(obj2));
				Vector3 centre = new Vector3(((Bounds)(ref value2)).center.x, ((Bounds)(ref value2)).min.y, ((Bounds)(ref value2)).center.z);
				foreach (int item3 in list5)
				{
					ZNetView v = data[item3].v;
					Vector3 val3 = ((Component)v).transform.position - centre;
					string[] obj3 = new string[9]
					{
						"   ",
						Utils.GetPrefabName(((Component)v).gameObject),
						"  ",
						((Vector3)(ref val3)).ToString("F2"),
						"  ",
						null,
						null,
						null,
						null
					};
					val2 = ((Component)v).transform.eulerAngles;
					obj3[5] = ((Vector3)(ref val2)).ToString("F1");
					obj3[6] = "  ";
					val2 = ((Component)v).transform.lossyScale;
					obj3[7] = ((Vector3)(ref val2)).ToString("F2");
					obj3[8] = (Object.op_Implicit((Object)(object)((Component)v).GetComponent<WearNTear>()) ? "  WEAR" : "");
					stringBuilder.AppendLine(string.Concat(obj3));
				}
				List<Renderer> members = list5.SelectMany((int i) => data[i].rs).ToList();
				Texture2D val4 = IconRender.RenderIcon(delegate(GameObject g)
				{
					//IL_005a: 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_0071: Unknown result type (might be due to invalid IL or missing references)
					//IL_007d: Unknown result type (might be due to invalid IL or missing references)
					//IL_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_0092: 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_00a8: 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_00be: Unknown result type (might be due to invalid IL or missing references)
					foreach (Renderer item4 in members)
					{
						Mesh val6 = ((!(item4 is MeshRenderer)) ? ((SkinnedMeshRenderer)((item4 is SkinnedMeshRenderer) ? item4 : null)).sharedMesh : (Object.op_Implicit((Object)(object)((Component)item4).GetComponent<MeshFilter>()) ? ((Component)item4).GetComponent<MeshFilter>().sharedMesh : null));
						if (Object.op_Implicit((Object)(object)val6))
						{
							GameObject val7 = new GameObject("m");
							val7.transform.SetParent(g.transform, false);
							val7.transform.position = ((Component)item4).transform.position - centre;
							val7.transform.rotation = ((Component)item4).transform.rotation;
							val7.transform.localScale = ((Component)item4).transform.lossyScale;
							val7.AddComponent<MeshFilter>().sharedMesh = val6;
							((Renderer)val7.AddComponent<MeshRenderer>()).sharedMaterials = item4.sharedMaterials;
						}
					}
				}, 25f, 22f, 192);
				if ((Object)(object)val4 != (Object)null)
				{
					File.WriteAllBytes(Path.Combine(text, num5.ToString("00") + ".png"), ImageConversion.EncodeToPNG(val4));
					list4.Add(val4);
				}
				else
				{
					list4.Add(null);
				}
			}
			File.WriteAllText(Path.Combine(Root, "near.txt"), stringBuilder.ToString());
			int num6 = 6;
			int num7 = Math.Max(1, (list4.Count + num6 - 1) / num6);
			Texture2D val5 = new Texture2D(num6 * 192, num7 * 192, (TextureFormat)4, false);
			val5.SetPixels(Enumerable.Repeat<Color>(new Color(0.18f, 0.2f, 0.22f, 1f), num6 * 192 * num7 * 192).ToArray());
			for (int num8 = 0; num8 < list4.Count; num8++)
			{
				if (!((Object)(object)list4[num8] == (Object)null))
				{
					Color[] pixels = list4[num8].GetPixels();
					for (int num9 = 0; num9 < pixels.Length; num9++)
					{
						pixels[num9] = Color.Lerp(new Color(0.18f, 0.2f, 0.22f, 1f), pixels[num9], pixels[num9].a);
					}
					val5.SetPixels(num8 % num6 * 192, (num7 - 1 - num8 / num6) * 192, 192, 192, pixels);
				}
			}
			val5.Apply();
			File.WriteAllBytes(Path.Combine(text, "sheet.png"), ImageConversion.EncodeToPNG(val5));
			Object.Destroy((Object)(object)val5);
			t.AddString("Near " + radius + " m: " + list.Count + " objects, " + list3.Count + " '" + filter + "' groups -> " + Path.Combine(Root, "near.txt") + " and " + text + "\\sheet.png");
			static Bounds? BoundsOf(ZNetView val6, List<Renderer> rends)
			{
				//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f6: 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_00ff: Unknown result type (might be due to invalid IL or missing references)
				//IL_0108: Unknown result type (might be due to invalid IL or missing references)
				//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
				HashSet<Renderer> hashSet = new HashSet<Renderer>();
				LODGroup[] componentsInChildren = ((Component)val6).GetComponentsInChildren<LODGroup>(true);
				Renderer[] renderers;
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					LOD[] lODs = componentsInChildren[i].GetLODs();
					for (int j = 1; j < lODs.Length; j++)
					{
						renderers = lODs[j].renderers;
						foreach (Renderer val7 in renderers)
						{
							if (Object.op_Implicit((Object)(object)val7))
							{
								hashSet.Add(val7);
							}
						}
					}
				}
				Bounds? result = null;
				renderers = ((Component)val6).GetComponentsInChildren<Renderer>(true);
				foreach (Renderer val8 in renderers)
				{
					if (Object.op_Implicit((Object)(object)val8) && !hashSet.Contains(val8) && (val8 is MeshRenderer || val8 is SkinnedMeshRenderer))
					{
						rends.Add(val8);
						Bounds val9 = MeshBounds(val8);
						Vector3 size = ((Bounds)(ref val9)).size;
						if (!(((Vector3)(ref size)).sqrMagnitude <= 0f))
						{
							if (!result.HasValue)
							{
								result = val9;
							}
							else
							{
								Bounds value3 = result.Value;
								((Bounds)(ref value3)).Encapsulate(val9);
								result = value3;
							}
						}
					}
				}
				return result;
			}
			int Find(int i)
			{
				while (parent[i] != i)
				{
					parent[i] = parent[parent[i]];
					i = parent[i];
				}
				return i;
			}
		}

		private static void CopyArea(Terminal t, string name, Vector3 centre, float radius, string filter)
		{
			//IL_0038: 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_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: 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_007c: 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_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: 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_034f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0354: Unknown result type (might be due to invalid IL or missing references)
			//IL_0355: Unknown result type (might be due to invalid IL or missing references)
			//IL_035a: Unknown result type (might be due to invalid IL or missing references)
			//IL_035d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0362: Unknown result type (might be due to invalid IL or missing references)
			//IL_0369: Unknown result type (might be due to invalid IL or missing references)
			//IL_036e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0373: Unknown result type (might be due to invalid IL or missing references)
			//IL_0375: Unknown result type (might be due to invalid IL or missing references)
			//IL_0377: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e6: 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_0418: Unknown result type (might be due to invalid IL or missing references)
			//IL_0431: Unknown result type (might be due to invalid IL or missing references)
			//IL_044a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0463: Unknown result type (might be due to invalid IL or missing references)
			//IL_047c: 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_0388: Unknown result type (might be due to invalid IL or missing references)
			if (ZDOMan.instance == null || (Object)(object)ZNetScene.instance == (Object)null || (Object)(object)ZoneSystem.instance == (Object)null)
			{
				t.AddString("Enter a world first.");
				return;
			}
			List<ZDO> list = new List<ZDO>();
			ZDOMan.instance.FindSectorObjects(ZoneSystem.GetZone(centre), new SimulationDistance(2, 0, true), list, (List<ZDO>)null);
			List<(string, ZDO)> list2 = new List<(string, ZDO)>();
			SortedDictionary<string, int> sortedDictionary = new SortedDictionary<string, int>();
			foreach (ZDO item3 in list)
			{
				Vector3 val = item3.GetPosition() - centre;
				Vector2 val2 = new Vector2(val.x, val.z);
				if (((Vector2)(ref val2)).magnitude > radius || Mathf.Abs(val.y) > radius)
				{
					continue;
				}
				GameObject prefab = ZNetScene.instance.GetPrefab(item3.GetPrefab());
				if (!((Object)(object)prefab == (Object)null))
				{
					string name2 = ((Object)prefab).name;
					if (Object.op_Implicit((Object)(object)prefab.GetComponent<Character>()) || Object.op_Implicit((Object)(object)prefab.GetComponent<ItemDrop>()) || Object.op_Implicit((Object)(object)prefab.GetComponent<Pickable>()) || Object.op_Implicit((Object)(object)prefab.GetComponent<TreeBase>()) || Object.op_Implicit((Object)(object)prefab.GetComponent<TreeLog>()) || Object.op_Implicit((Object)(object)prefab.GetComponent<LocationProxy>()) || name2.StartsWith("_") || (filter.Length > 0 && name2.IndexOf(filter, StringComparison.OrdinalIgnoreCase) < 0))
					{
						sortedDictionary[name2] = (sortedDictionary.TryGetValue(name2, out var value) ? value : 0) + 1;
					}
					else
					{
						list2.Add((name2, item3));
					}
				}
			}
			if (list2.Count == 0)
			{
				t.AddString("No saved objects within " + radius + " m of " + ((Vector3)(ref centre)).ToString("F0") + ((sortedDictionary.Count > 0) ? (" (skipped: " + string.Join(", ", sortedDictionary.Keys.Take(8)) + ")") : "") + ". Check the coordinates or enlarge the radius.");
				return;
			}
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.AppendLine("# copy " + name + "  centre " + centre.x.ToString("F2", CultureInfo.InvariantCulture) + " " + centre.y.ToString("F2", CultureInfo.InvariantCulture) + " " + centre.z.ToString("F2", CultureInfo.InvariantCulture) + "  radius " + radius + "  parts " + list2.Count);
			stringBuilder.AppendLine("# prefab<TAB>x y z (relative to the centre)<TAB>rotation x y z w<TAB>scale x y z");
			foreach (var item4 in from x in list2
				orderby x.prefab, x.zdo.GetPosition().x
				select x)
			{
				string item = item4.Item1;
				ZDO item2 = item4.Item2;
				Vector3 val3 = item2.GetPosition() - centre;
				Quaternion rotation = item2.GetRotation();
				Vector3 val4 = item2.GetVec3(ZDOVars.s_scaleHash, Vector3.one);
				if (val4 == Vector3.zero)
				{
					val4 = Vector3.one;
				}
				stringBuilder.AppendLine(item + "\t" + F(val3.x) + " " + F(val3.y) + " " + F(val3.z) + "\t" + F(rotation.x) + " " + F(rotation.y) + " " + F(rotation.z) + " " + F(rotation.w) + "\t" + F(val4.x) + " " + F(val4.y) + " " + F(val4.z));
			}
			Directory.CreateDirectory(Root);
			string text = Path.Combine(Root, "copy-" + Safe(name) + ".txt");
			File.WriteAllText(text, stringBuilder.ToString());
			string text2 = string.Join(", ", from g in (from x in list2
					group x by x.prefab into g
					orderby g.Count() descending
					select g).Take(10)
				select g.Key + " x" + g.Count());
			t.AddString("Saved " + list2.Count + " objects to " + text + ": " + text2 + ((sortedDictionary.Count > 0) ? ("  (left out: creatures, items, plants, trees: " + sortedDictionary.Values.Sum() + ")") : ""));
			static string F(float v)
			{
				return v.ToString("0.###", CultureInfo.InvariantCulture);
			}
		}

		private static void Paste(Terminal t, string name, float distance)
		{
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: 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_0120: 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_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Expected O, but got Unknown
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: 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_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: Unknown result type (might be due to invalid IL or missing references)
			//IL_0373: Unknown result type (might be due to invalid IL or missing references)
			//IL_0378: Unknown result type (might be due to invalid IL or missing references)
			//IL_037c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0381: Unknown result type (might be due to invalid IL or missing references)
			//IL_03df: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_040c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0411: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b0: 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_039c: Unknown result type (might be due to invalid IL or missing references)
			if (name == "clear")
			{
				foreach (GameObject item in Pasted)
				{
					if (Object.op_Implicit((Object)(object)item))
					{
						Object.Destroy((Object)(object)item);
					}
				}
				t.AddString("Removed " + Pasted.Count + " pasted copies.");
				Pasted.Clear();
				return;
			}
			Player localPlayer = Player.m_localPlayer;
			if (!Object.op_Implicit((Object)(object)localPlayer) || !Object.op_Implicit((Object)(object)ZNetScene.instance))
			{
				t.AddString("Enter a world first.");
				return;
			}
			string text = Path.Combine(Root, "copy-" + Safe(name) + ".txt");
			if (!File.Exists(text))
			{
				t.AddString("No " + text + " (rnr copyarea first).");
				return;
			}
			CultureInfo ci = CultureInfo.InvariantCulture;
			Vector3 forward = ((Component)localPlayer).transform.forward;
			forward.y = 0f;
			((Vector3)(ref forward)).Normalize();
			Vector3 val = ((Component)localPlayer).transform.position + forward * distance;
			val.y = ZoneSystem.instance.GetGroundHeight(val);
			GameObject val2 = new GameObject("RnR paste " + name);
			val2.transform.position = val;
			val2.transform.rotation = Quaternion.LookRotation(-forward);
			int num = 0;
			int num2 = 0;
			HashSet<string> hashSet = new HashSet<string>();
			ZNetView.m_forceDisableInit = true;
			try
			{
				string[] array = File.ReadAllLines(text);
				foreach (string text2 in array)
				{
					if (text2.Length == 0 || text2[0] == '#')
					{
						continue;
					}
					string[] array2 = text2.Split('\t');
					if (array2.Length >= 5)
					{
						GameObject prefab = ZNetScene.instance.GetPrefab(array2[0]);
						if ((Object)(object)prefab == (Object)null)
						{
							num2++;
							hashSet.Add(array2[0]);
							continue;
						}
						float[] array3 = N(array2[1]);
						float[] array4 = N(array2[2]);
						float[] array5 = N(array2[3]);
						GameObject obj = Object.Instantiate<GameObject>(prefab, val2.transform, false);
						obj.transform.localPosition = new Vector3(array3[0], array3[1], array3[2]);
						obj.transform.localRotation = new Quaternion(array4[0], array4[1], array4[2], array4[3]);
						obj.transform.localScale = new Vector3(array5[0], array5[1], array5[2]);
						num++;
					}
				}
			}
			finally
			{
				ZNetView.m_forceDisableInit = false;
			}
			WearNTear[] componentsInChildren = val2.GetComponentsInChildren<WearNTear>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren[i]);
			}
			Destructible[] componentsInChildren2 = val2.GetComponentsInChildren<Destructible>(true);
			for (int i = 0; i < componentsInChildren2.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren2[i]);
			}
			Piece[] componentsInChildren3 = val2.GetComponentsInChildren<Piece>(true);
			for (int i = 0; i < componentsInChildren3.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren3[i]);
			}
			ZNetView[] componentsInChildren4 = val2.GetComponentsInChildren<ZNetView>(true);
			for (int i = 0; i < componentsInChildren4.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren4[i]);
			}
			Bounds? val3 = null;
			Renderer[] componentsInChildren5 = val2.GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val4 in componentsInChildren5)
			{
				if (val4 is ParticleSystemRenderer)
				{
					continue;
				}
				Bounds val5 = MeshBounds(val4);
				Vector3 size = ((Bounds)(ref val5)).size;
				if (!(((Vector3)(ref size)).sqrMagnitude <= 0f))
				{
					if (!val3.HasValue)
					{
						val3 = val5;
						continue;
					}
					Bounds value = val3.Value;
					((Bounds)(ref value)).Encapsulate(val5);
					val3 = value;
				}
			}
			if (val3.HasValue)
			{
				Transform transform = val2.transform;
				Vector3 position = transform.position;
				Vector3 up = Vector3.up;
				float y = val.y;
				Bounds value2 = val3.Value;
				transform.position = position + up * (y - ((Bounds)(ref value2)).min.y + 0.02f);
			}
			Pasted.Add(val2);
			t.AddString("Pasted " + name + ": " + num + " parts, " + distance.ToString("0") + " m in front of you" + ((num2 > 0) ? ("; unknown prefabs left out: " + string.Join(", ", hashSet)) : "") + ".  rnr paste clear removes it.");
			float[] N(string s)
			{
				return (from x in s.Split(' ')
					select float.Parse(x, ci)).ToArray();
			}
		}

		private static void Screen(Terminal t, float seconds)
		{
			string text = Path.Combine(Root, "screen-" + DateTime.Now.ToString("HHmmss") + ".png");
			Directory.CreateDirectory(Root);
			((MonoBehaviour)Plugin.Instance).StartCoroutine(Shoot(text, seconds));
			t.AddString("Screenshot in " + seconds.ToString("0") + " s: close the console and open what you want to see. File: " + text);
		}

		private static IEnumerator Shoot(string file, float seconds)
		{
			yield return (object)new WaitForSeconds(seconds);
			yield return (object)new WaitForEndOfFrame();
			Texture2D val = new Texture2D(Screen.width, Screen.height, (TextureFormat)3, false);
			val.ReadPixels(new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), 0, 0);
			val.Apply();
			File.WriteAllBytes(file, ImageConversion.EncodeToPNG(val));
			Object.Destroy((Object)(object)val);
			Plugin.Instance.LoggerGarden("Screenshot saved: " + file);
		}
	}
	internal static class FoodCatalog
	{
		internal static readonly FoodDefinition[] All = new FoodDefinition[49]
		{
			new FoodDefinition("F01", "Smoked Boar Jerky", "BoarJerky", "RNR_F01_SmokedBoarJerky", "attack stamina", "Attack stamina cost −1%"),
			new FoodDefinition("F02", "Smoked Minced Meat Sauce", "MinceMeatSauce", "RNR_F02_SmokedMincedMeatSauce", "attack stamina", "Attack stamina cost −1%"),
			new FoodDefinition("F03", "Dried Queen's Jam", "QueensJam", "RNR_F03_DriedQueensJam", "run stamina", "Run stamina cost −1%"),
			new FoodDefinition("F04", "Dried Carrot Soup", "CarrotSoup", "RNR_F04_DriedCarrotSoup", "jump stamina", "Jump stamina cost −1%"),
			new FoodDefinition("F05", "Smoked Deer Stew", "DeerStew", "RNR_F05_SmokedDeerStew", "block stamina", "Block stamina cost −1%"),
			new FoodDefinition("F06", "Dried Muckshake", "ShocklateSmoothie", "RNR_F06_DriedMuckshake", "jump stamina", "Jump stamina cost −1%"),
			new FoodDefinition("F07", "Smoked Turnip Stew", "TurnipStew", "RNR_F07_SmokedTurnipStew", "block stamina", "Block stamina cost −1%"),
			new FoodDefinition("F08", "Smoked Sausages", "Sausages", "RNR_F08_SmokedSausages", "attack stamina", "Attack stamina cost −1%"),
			new FoodDefinition("F09", "Smoked Black Soup", "BlackSoup", "RNR_F09_SmokedBlackSoup", "block stamina", "Block stamina cost −1%"),
			new FoodDefinition("F13", "Smoked Serpent Stew", "SerpentStew", "RNR_F13_SmokedSerpentStew", "block stamina", "Block stamina cost −1%"),
			new FoodDefinition("F15", "Smoked Wolf Jerky", "WolfJerky", "RNR_F15_SmokedWolfJerky", "run stamina", "Run stamina cost −1%"),
			new FoodDefinition("F16", "Smoked Wolf Skewer", "WolfMeatSkewer", "RNR_F16_SmokedWolfMeatSkewer", "attack stamina", "Attack stamina cost −1%"),
			new FoodDefinition("F17", "Smoked Eyescream", "Eyescream", "RNR_F17_SmokedEyescream", "eitr cost", "Eitr cost when casting −1%"),
			new FoodDefinition("F19", "Smoked Fish Wraps", "FishWraps", "RNR_F19_SmokedFishWraps", "run stamina", "Run stamina cost −1%"),
			new FoodDefinition("F20", "Smoked Lox Meat Pie", "LoxPie", "RNR_F20_SmokedLoxPie", "block stamina", "Block stamina cost −1%"),
			new FoodDefinition("F21", "Smoked Blood Pudding", "BloodPudding", "RNR_F21_SmokedBloodPudding", "jump stamina", "Jump stamina cost −1%"),
			new FoodDefinition("F23", "Smoked Meat Platter", "MeatPlatter", "RNR_F23_SmokedMeatPlatter", "attack stamina", "Attack stamina cost −1%"),
			new FoodDefinition("F24", "Smoked Honey-Glazed Chicken", "HoneyGlazedChicken", "RNR_F24_SmokedHoneyGlazedChicken", "dodge stamina", "Dodge stamina cost −1%"),
			new FoodDefinition("F25", "Smoked Misthare Supreme", "MisthareSupreme", "RNR_F25_SmokedMisthareSupreme", "dodge stamina", "Dodge stamina cost −1%"),
			new FoodDefinition("F26", "Dried Salad", "Salad", "RNR_F26_DriedSalad", "run stamina", "Run stamina cost −1%"),
			new FoodDefinition("F27", "Smoked Mushroom Omelette", "MushroomOmelette", "RNR_F27_SmokedMushroomOmelette", "jump stamina", "Jump stamina cost −1%"),
			new FoodDefinition("F28", "Smoked Fish 'n' Bread", "FishAndBread", "RNR_F28_SmokedFishAndBread", "run stamina", "Run stamina cost −1%"),
			new FoodDefinition("F29", "Smoked Stuffed Mushroom", "MagicallyStuffedShroom", "RNR_F29_SmokedStuffedMushroom", "eitr cost", "Eitr cost when casting −1%"),
			new FoodDefinition("F30", "Dried Yggdrasil Porridge", "YggdrasilPorridge", "RNR_F30_DriedYggdrasilPorridge", "eitr cost", "Eitr cost when casting −1%"),
			new FoodDefinition("F31", "Smoked Seeker Aspic", "SeekerAspic", "RNR_F31_SmokedSeekerAspic", "eitr cost", "Eitr cost when casting −1%"),
			new FoodDefinition("F33", "Smoked Fiery Svinstew", "FierySvinstew", "RNR_F33_SmokedFierySvinstew", "block stamina", "Block stamina cost −1%"),
			new FoodDefinition("F34", "Smoked Mashed Meat", "MashedMeat", "RNR_F34_SmokedMashedMeat", "attack stamina", "Attack stamina cost −1%"),
			new FoodDefinition("F35", "Smoked Piquant Pie", "PiquantPie", "RNR_F35_SmokedPiquantPie", "dodge stamina", "Dodge stamina cost −1%"),
			new FoodDefinition("F36", "Dried Spicy Marmalade", "SpicyMarmalade", "RNR_F36_DriedSpicyMarmalade", "run stamina", "Run stamina cost −1%"),
			new FoodDefinition("F37", "Dried Scorching Medley", "ScorchingMedley", "RNR_F37_DriedScorchingMedley", "jump stamina", "Jump stamina cost −1%"),
			new FoodDefinition("F38", "Smoked Roasted Crust Pie", "RoastedCrustPie", "RNR_F38_SmokedRoastedCrustPie", "jump stamina", "Jump stamina cost −1%"),
			new FoodDefinition("F39", "Dried Sizzling Berry Broth", "SizzlingBerryBroth", "RNR_F39_DriedSizzlingBerryBroth", "eitr cost", "Eitr cost when casting −1%"),
			new FoodDefinition("F40", "Dried Sparkling Shroomshake", "SparklingShroomshake", "RNR_F40_DriedSparklingShroomshake", "eitr cost", "Eitr cost when casting −1%"),
			new FoodDefinition("F41", "Dried Marinated Greens", "MarinatedGreens", "RNR_F41_DriedMarinatedGreens", "dodge stamina", "Dodge stamina cost −1%"),
			new FoodDefinition("F43", "Smoked Seal Blubber", "CookedSealBlubber", "RNR_F43_SmokedCookedSealBlubber", "block stamina", "Block stamina cost −1%"),
			new FoodDefinition("F44", "Smoked Moose Meat", "CookedMooseMeat", "RNR_F44_SmokedCookedMooseMeat", "attack stamina", "Attack stamina cost −1%"),
			new FoodDefinition("F45", "Dried Kale Chips", "KaleChips", "RNR_F45_DriedKaleChips", "jump stamina", "Jump stamina cost −1%"),
			new FoodDefinition("F46", "Dried Baked Poteitr", "BakedPoteitr", "RNR_F46_DriedBakedPoteitr", "stamina regeneration", "Stamina regeneration +1%"),
			new FoodDefinition("F47", "Dried Oat Milk", "OatMilk", "RNR_F47_DriedOatMilk", "stamina regeneration", "Stamina regeneration +1%"),
			new FoodDefinition("F48", "Dried Lingonberry Juice", "Lingondricka", "RNR_F48_DriedLingondricka", "run stamina", "Run stamina cost −1%"),
			new FoodDefinition("F49", "Twice-Smoked Moose Meat", "SmokedMooseMeat", "RNR_F49_SmokedSmokedMooseMeat", "attack stamina", "Attack stamina cost −1%"),
			new FoodDefinition("F50", "Twice-Smoked Fish", "SmokedFish", "RNR_F50_SmokedSmokedFish", "dodge stamina", "Dodge stamina cost −1%"),
			new FoodDefinition("F51", "Smoked Meatballs and Poteitr", "MeatballsMashedPoteitr", "RNR_F51_SmokedMeatballsMashedPoteitr", "block stamina", "Block stamina cost −1%"),
			new FoodDefinition("F52", "Smoked Meat in Bread", "MooseKebab", "RNR_F52_SmokedMooseKebab", "run stamina", "Run stamina cost −1%"),
			new FoodDefinition("F53", "Smoked Fish Soup", "FishSoup", "RNR_F53_SmokedFishSoup", "dodge stamina", "Dodge stamina cost −1%"),
			new FoodDefinition("F54", "Smoked Seal Meat Soup", "SealSoup", "RNR_F54_SmokedSealSoup", "block stamina", "Block stamina cost −1%"),
			new FoodDefinition("F55", "Dried Oatmeal", "OatmealLingonberryJam", "RNR_F55_DriedOatmealLingonberryJam", "stamina regeneration", "Stamina regeneration +1%"),
			new FoodDefinition("F56", "Smoked Pancakes", "Pancakes", "RNR_F56_SmokedPancakes", "eitr cost", "Eitr cost when casting −1%"),
			new FoodDefinition("F57", "Smoked Oven Pancake", "OvenPancake", "RNR_F57_SmokedOvenPancake", "jump stamina", "Jump stamina cost −1%")
		};
	}
	internal sealed class FoodDefinition
	{
		internal readonly string Id;

		internal readonly string Name;

		internal readonly string Source;

		internal readonly string Prefab;

		internal readonly string Effect;

		internal readonly string Attribute;

		internal readonly int Tier;

		internal readonly FoodDefinition Base;

		internal float BaseDuration;

		internal string BaseName;

		internal bool Smoked => Base.Name.StartsWith("Smoked");

		internal FoodDefinition(string id, string name, string source, string prefab, string effect, string attribute)
		{
			Id = id;
			Name = name;
			Source = source;
			Prefab = prefab;
			Effect = effect;
			Attribute = attribute;
			Tier = 1;
			Base = this;
		}

		private FoodDefinition(FoodDefinition b, int tier)
		{
			Id = b.Id;
			Name = b.Name + " [" + FoodRules.TierLabel(tier) + "]";
			Source = b.Source;
			Prefab = b.Prefab + "_T" + tier;
			Effect = b.Effect;
			Attribute = b.Attribute;
			Tier = tier;
			Base = b;
		}

		internal FoodDefinition WithTier(int tier)
		{
			if (tier > 1)
			{
				return new FoodDefinition(Base, tier);
			}
			return Base;
		}
	}
	internal static class FoodRules
	{
		internal static float ExtraSeconds(int tier)
		{
			return (float)(4 + Math.Max(1, Math.Min(3, tier))) * 60f;
		}

		internal static float Percent(int tier)
		{
			if (tier > 1)
			{
				return 0.02f;
			}
			return 0.01f;
		}

		internal static int HealthTick(int tier)
		{
			return Math.Max(1, Math.Min(3, tier));
		}

		internal static string TierLabel(int tier)
		{
			if (tier > 1)
			{
				if (tier != 2)
				{
					return "Best";
				}
				return "Fine";
			}
			return "Poor";
		}

		internal static float Percent(IEnumerable<KeyValuePair<string, int>> sourceTiers)
		{
			Dictionary<string, int> dictionary = new Dictionary<string, int>();
			foreach (KeyValuePair<string, int> sourceTier in sourceTiers)
			{
				if (!dictionary.TryGetValue(sourceTier.Key, out var value) || sourceTier.Value > value)
				{
					dictionary[sourceTier.Key] = sourceTier.Value;
				}
			}
			return dictionary.Values.OrderByDescending((int t) => t).Take(3).Sum((int t) => Percent(t));
		}

		internal static float Reduce(float current, float basis, float percent)
		{
			return Math.Max(0f, current - basis * Math.Max(0f, percent));
		}

		internal static float Multiplier(float percent, bool increase = false)
		{
			return 1f + (increase ? 1f : (-1f)) * Math.Max(0f, percent);
		}

		internal static string Attribute(string attribute, int tier)
		{
			return Regex.Replace(attribute, "1%", Math.Round(Percent(tier) * 100f) + "%");
		}

		internal static string Tooltip(string text, string duration, string attribute, int tier = 1)
		{
			string mark = "<color=#FF0000>+" + (4 + Math.Max(1, Math.Min(3, tier))) + "min</color>";
			if (text.Contains(mark))
			{
				return text;
			}
			return Regex.Replace(text, "(\\$item_food_duration:\\s*<color=orange>)[^<]*(</color>)", (Match m) => m.Groups[1].Value + duration + m.Groups[2].Value + " " + mark + "\n<color=#FF0000>" + Attribute(attribute, tier) + "</color>");
		}
	}
	internal sealed class FoodCommandRequest
	{
		internal bool Valid;

		internal string Action;

		internal string Id;

		internal int Amount = 1;

		internal int Tier = 1;

		internal static FoodCommandRequest Parse(string[] args)
		{
			FoodCommandRequest result = new FoodCommandRequest();
			if (args.Length == 0)
			{
				return result;
			}
			result.Action = args[0].ToLowerInvariant();
			if (result.Action == "list" || result.Action == "status")
			{
				result.Valid = args.Length == 1;
				return result;
			}
			if (result.Action != "spawn")
			{
				return result;
			}
			int num = 1;
			if (num < args.Length && args[num].Equals("food", StringComparison.OrdinalIgnoreCase))
			{
				num++;
			}
			if (num < args.Length && args[num].StartsWith("F", StringComparison.OrdinalIgnoreCase))
			{
				result.Id = args[num++].ToUpperInvariant();
				if (!FoodCatalog.All.Any((FoodDefinition d) => d.Id == result.Id))
				{
					return result;
				}
			}
			if (num < args.Length && (!int.TryParse(args[num++], out result.Amount) || result.Amount < 1 || result.Amount > 20))
			{
				return result;
			}
			if (num < args.Length && (!int.TryParse(args[num++], out result.Tier) || result.Tier < 1 || result.Tier > 3))
			{
				return result;
			}
			result.Valid = num == args.Length;
			return result;
		}
	}
	internal static class GardenObjects
	{
		internal static readonly Dictionary<string, GameObject> Items = new Dictionary<string, GameObject>();

		internal static int Pieces;

		internal static readonly string[] Ids = new string[12]
		{
			"MosquitoNet", "RosemaryRoot", "LiveFlytrap", "OysterMushroom", "OysterMycelium", "Clay", "Fly", "RosemaryLeaves", "Kaolin", "FishBile",
			"SunflowerOil", "PressCrank"
		};

		internal static readonly string[] Names = new string[12]
		{
			"Mosquito Net", "Rosemary Root", "Live Flytrap", "Oyster Mushroom", "Oyster Mushroom Mycelium", "Clay", "Fly", "Rosemary Sprigs", "Kaolin", "Fish Bile",
			"Sunflower Oil", "Press Crank"
		};

		internal static readonly string[] Descriptions = new string[12]
		{
			"A knotted rope net, the heart of a mosquito trap. Carry it to a stand of fine wood.", "A tangle of fragrant rosemary roots with soil still clinging to them. Plant three in a planter.", "A carnivorous plant with a hungry grip. It even bites fingers!", "A pale, silvery oyster mushroom with a mild, earthy smell. A gentle remedy for weary bodies.", "A mushroom with fine white threads at the base. Press it into a log to start a new colony.", "Sticky grey clay. Shape it, fire it and it keeps its form for good.", "A fat, buzzing fly caught in a flytrap. Its wings still twitch. Potion makers will pay for these.", "Fresh sprigs of rosemary. Sharp, resinous and good for the lungs.", "Soft, snow-white china clay boiled out of ordinary stone. Pure enough to fire into porcelain.", "A bitter green bile scraped from fish. Brewers stir it into potions that fight poison.",
			"Golden oil pressed from sunflower seeds. Smooth, mild and perfect for mellowing a potion.", "A heavy wooden bar for turning the screw of a press. Without it a screw press is just a pile of timber."
		};

		internal static void Register(Action<string> error)
		{
			for (int i = 0; i < Ids.Length; i++)
			{
				try
				{
					Item(i);
				}
				catch (Exception ex)
				{
					error("Garden item " + Ids[i] + ": " + ex);
				}
			}
			for (int j = 0; j < 8; j++)
			{
				try
				{
					Piece(j);
				}
				catch (Exception ex2)
				{
					error("Garden piece " + j + ": " + ex2);
				}
			}
			try
			{
				Potions.Register(error);
			}
			catch (Exception ex3)
			{
				error("Improved potions: " + ex3);
			}
			Plugin.Instance.LoggerGarden("R&R garden pieces: " + Pieces + "/8; items " + Items.Count + "/" + Ids.Length);
		}

		private static Sprite Icon(string name, Sprite fallback)
		{
			//IL_004c: 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_0058: Expected O, but got Unknown
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected O, but got Unknown
			using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("RNR.Garden." + name + ".png");
			if (stream == null)
			{
				throw new Exception("Missing icon " + name);
			}
			byte[] array = new byte[stream.Length];
			stream.Read(array, 0, array.Length);
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
			ImageConversion.LoadImage(val, array);
			((Texture)val).filterMode = (FilterMode)0;
			return IconSizing.Fit(val, fallback, 0.94f);
		}

		private static void Item(int i)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Expected O, but got Unknown
			//IL_00b6: 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_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Expected O, but got Unknown
			GameObject prefab = PrefabManager.Instance.GetPrefab("Carrot");
			GameObject val = PrefabManager.Instance.CreateClonedPrefab("RNR_" + Ids[i], prefab);
			SharedData val2 = new SharedData();
			FieldInfo[] fields = typeof(SharedData).GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (FieldInfo fieldInfo in fields)
			{
				fieldInfo.SetValue(val2, fieldInfo.GetValue(prefab.GetComponent<ItemDrop>().m_itemData.m_shared));
			}
			val.GetComponent<ItemDrop>().m_itemData = new ItemData
			{
				m_shared = val2,
				m_dropPrefab = val
			};
			val2.m_name = Names[i];
			val2.m_description = Descriptions[i];
			val2.m_itemType = (ItemType)1;
			val2.m_food = 0f;
			val2.m_foodStamina = 0f;
			val2.m_foodEitr = 0f;
			val2.m_foodBurnTime = 0f;
			val2.m_buildPieces = null;
			val2.m_appendToolTip = null;
			val2.m_maxStackSize = 50;
			val2.m_weight = 0.1f;
			val2.m_icons = (Sprite[])(object)new Sprite[1] { Icon(Ids[i], val2.m_icons[0]) };
			PlantModels.HideOriginal(val);
			if (Ids[i] == "PressCrank")
			{
				GardenVisual.PlaceModel(val, "crank", 1f, Vector3.zero, Vector3.zero);
			}
			else
			{
				GardenVisual.Item(val, i);
			}
			if (!ItemManager.Instance.AddItem(new CustomItem(val, false)))
			{
				throw new Exception("Registration rejected");
			}
			Items.Add(Ids[i], val);
		}

		private static RequirementConfig Req(string id, int amount)
		{
			//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 = id,
				Amount = amount,
				Recover = true
			};
		}

		private static void Free(Piece piece)
		{
			piece.m_groundOnly = false;
			piece.m_groundPiece = false;
			piece.m_notOnWood = false;
			piece.m_notOnFloor = false;
			piece.m_notOnTiltingSurface = false;
			piece.m_cultivatedGroundOnly = false;
			piece.m_spaceRequirement = 0f;
			piece.m_noClipping = false;
		}

		private static void PiecePan()
		{
			//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_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: 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_00dc: 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_00fa: Expected O, but got Unknown
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Expected O, but got Unknown
			GameObject val = PrefabManager.Instance.CreateClonedPrefab("RNR_SaltPan", "piece_oven");
			Free(val.GetComponent<Piece>());
			GardenVisual.Piece(val, 6);
			Processing.Configure(val, smoke: false, "Clay Salt Pan", pan: true);
			GameObject val2 = new GameObject("snap");
			val2.transform.SetParent(val.transform, false);
			val2.tag = "snappoint";
			Sprite icon = Icon("SaltPan", PrefabManager.Instance.GetPrefab("Stone").GetComponent<ItemDrop>().m_itemData.m_shared.m_icons[0]);
			RequirementConfig[] requirements = (RequirementConfig[])(object)new RequirementConfig[2]
			{
				Req("Stone", 20),
				Req("RNR_Clay", 1)
			};
			if (!PieceManager.Instance.AddPiece(new CustomPiece(val, true, new PieceConfig
			{
				Name = "Clay Salt Pan",
				Description = "Boils stone down to Kaolin. Put stones in from the top and burn any wood below. Four stones make one Kaolin, which drops in front of the pan.",
				PieceTable = "Hammer",
				Category = "R&R",
				Icon = icon,
				Requirements = requirements
			})))
			{
				throw new Exception("Piece registration rejected");
			}
			Pieces++;
		}

		private static void PiecePress()
		{
			//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_00d7: 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_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Expected O, but got Unknown
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Expected O, but got Unknown
			GameObject val = PrefabManager.Instance.CreateClonedPrefab("RNR_ScrewPress", "cauldron_ext5_mortarandpestle");
			PlantModels.HideOriginal(val);
			GardenVisual.Piece(val, 7);
			CraftingStation component = PrefabManager.Instance.GetPrefab("piece_preptable").GetComponent<CraftingStation>();
			val.GetComponent<StationExtension>().m_craftingStation = component;
			val.GetComponent<Piece>().m_craftingStation = component;
			Sprite icon = Icon("ScrewPress", PrefabManager.Instance.GetPrefab("Stone").GetComponent<ItemDrop>().m_itemData.m_shared.m_icons[0]);
			RequirementConfig[] requirements = (RequirementConfig[])(object)new RequirementConfig[4]
			{
				Req("FineWood", 10),
				Req("BronzeNails", 5),
				Req("Stone", 5),
				Req("RNR_PressCrank", 1)
			};
			if (!PieceManager.Instance.AddPiece(new CustomPiece(val, true, new PieceConfig
			{
				Name = "Screw Press",
				Description = "An addition to the Food Preparation Table. Unlocks pressing Sunflower Oil from Sunflower Heads and Fish Bile from fish and serpent meat.",
				PieceTable = "Hammer",
				Category = "R&R",
				Icon = icon,
				Requirements = requirements
			})))
			{
				throw new Exception("Piece registration rejected");
			}
			Pieces++;
			Recipes();
		}

		private static void Recipes()
		{
			Add("RNR_Recipe_SunflowerOil", "RNR_SunflowerOil", 1, "RNR_SunflowerHead", 1);
			SortedDictionary<int, List<string>> sortedDictionary = new SortedDictionary<int, List<string>>();
			string[] array = new string[12]
			{
				"Fish1", "Fish2", "Fish3", "Fish4_cave", "Fish5", "Fish6", "Fish7", "Fish8", "Fish9", "Fish10",
				"Fish11", "Fish12"
			};
			foreach (string text in array)
			{
				GameObject prefab = PrefabManager.Instance.GetPrefab(text);
				if (Object.op_Implicit((Object)(object)prefab))
				{
					string name = prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_name;
					string text2 = Localization.instance.Localize(name);
					int key = Potions.BileYield(text2);
					Plugin.Instance.LoggerGarden("R&R fish bile: " + text + " (" + text2 + ") -> " + key);
					if (!sortedDictionary.TryGetValue(key, out var value))
					{
						value = (sortedDictionary[key] = new List<string>());
					}
					value.Add(text);
				}
			}
			array = new string[2] { "SerpentMeat", "BoneMawSerpentMeat" };
			foreach (string item in array)
			{
				if (!sortedDictionary.TryGetValue(5, out var value2))
				{
					value2 = (sortedDictionary[5] = new List<string>());
				}
				value2.Add(item);
			}
			foreach (KeyValuePair<int, List<string>> item2 in sortedDictionary)
			{
				AddAny("RNR_Recipe_FishBile_x" + item2.Key, "RNR_FishBile", item2.Key, item2.Value.ToArray(), 1);
			}
			static void Add(string name2, string item2, int amount, string material, int count)
			{
				AddAny(name2, item2, amount, new string[1] { material }, count);
			}
			static void AddAny(string text3, string item2, int amount, string[] materials, int count)
			{
				//IL_000e: 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_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_003a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0046: Unknown result type (might be due to invalid IL or missing references)
				//IL_0064: Expected O, but got Unknown
				//IL_006a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0074: Expected O, but