Decompiled source of HearthTable v1.9.12

BepInEx/plugins/HearthTable/HearthTable.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Jotunn.Entities;
using Jotunn.Managers;
using Newtonsoft.Json;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace HearthTable;

internal static class CuisineArt
{
	internal sealed class Builder
	{
		private readonly GameObject root;

		private readonly string foodId;

		private readonly Dictionary<string, List<Vector3>> vertices = new Dictionary<string, List<Vector3>>();

		private readonly Dictionary<string, List<Vector2>> uvs = new Dictionary<string, List<Vector2>>();

		private readonly Dictionary<string, List<int>> indices = new Dictionary<string, List<int>>();

		private readonly Dictionary<string, List<Vector3>> organicNormals = new Dictionary<string, List<Vector3>>();

		private readonly Dictionary<string, Material> mats = new Dictionary<string, Material>();

		internal bool IsFood => foodId != null;

		internal Builder(GameObject target, string id = null)
		{
			root = target;
			foodId = id;
		}

		internal void Tri(string material, Vector3 a, Vector3 b, Vector3 c)
		{
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: 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_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: 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_00fa: 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_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0287: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			if (!vertices.ContainsKey(material))
			{
				vertices[material] = new List<Vector3>();
				uvs[material] = new List<Vector2>();
				indices[material] = new List<int>();
				organicNormals[material] = new List<Vector3>();
			}
			int count = vertices[material].Count;
			vertices[material].AddRange((IEnumerable<Vector3>)(object)new Vector3[3] { a, b, c });
			if (IsFood)
			{
				Vector3 val = Vector3.Cross(b - a, c - a);
				Vector3 abs = default(Vector3);
				ref Vector3 reference = ref abs;
				reference = new Vector3(Mathf.Abs(val.x), Mathf.Abs(val.y), Mathf.Abs(val.z));
				Func<Vector3, Vector2> func = (Vector3 p) => (!(abs.y >= abs.x) || !(abs.y >= abs.z)) ? ((!(abs.x >= abs.z)) ? (new Vector2(p.x, p.y) * 3.6f) : (new Vector2(p.z, p.y) * 3.6f)) : (new Vector2(p.x, p.z) * 3.6f);
				uvs[material].AddRange((IEnumerable<Vector2>)(object)new Vector2[3]
				{
					func(a),
					func(b),
					func(c)
				});
			}
			else
			{
				uvs[material].AddRange((IEnumerable<Vector2>)(object)new Vector2[3]
				{
					new Vector2(a.x + a.z, a.y + a.z),
					new Vector2(b.x + b.z, b.y + b.z),
					new Vector2(c.x + c.z, c.y + c.z)
				});
			}
			indices[material].AddRange(new int[3]
			{
				count,
				count + 1,
				count + 2
			});
			organicNormals[material].AddRange((IEnumerable<Vector3>)(object)new Vector3[3]
			{
				Vector3.zero,
				Vector3.zero,
				Vector3.zero
			});
		}

		internal void Quad(string m, Vector3 a, Vector3 b, Vector3 c, Vector3 d)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: 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)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			Tri(m, a, b, c);
			Tri(m, a, c, d);
		}

		internal void SurfaceQuad(string m, Vector3 a, Vector3 b, Vector3 c, Vector3 d, Vector3 na, Vector3 nb, Vector3 nc, Vector3 nd)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: 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_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: 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_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			Quad(m, a, b, c, d);
			int num = organicNormals[m].Count - 6;
			Vector3[] array = (Vector3[])(object)new Vector3[6] { na, nb, nc, na, nc, nd };
			for (int i = 0; i < 6; i++)
			{
				organicNormals[m][num + i] = array[i];
			}
		}

		internal void Box(string m, Vector3 center, Vector3 size, float tilt = 0f)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: 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)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			Vector3[] array = (Vector3[])(object)new Vector3[8];
			Quaternion val = Quaternion.Euler(0f, 0f, tilt);
			for (int i = 0; i < 8; i++)
			{
				ref Vector3 reference = ref array[i];
				reference = center + val * Vector3.Scale(size * 0.5f, new Vector3((float)(((i & 1) != 0) ? 1 : (-1)), (float)(((i & 2) != 0) ? 1 : (-1)), (float)(((i & 4) != 0) ? 1 : (-1))));
			}
			int[,] array2 = new int[6, 4]
			{
				{ 0, 4, 6, 2 },
				{ 1, 3, 7, 5 },
				{ 0, 1, 5, 4 },
				{ 2, 6, 7, 3 },
				{ 0, 2, 3, 1 },
				{ 4, 5, 7, 6 }
			};
			for (int j = 0; j < 6; j++)
			{
				Quad(m, array[array2[j, 0]], array[array2[j, 1]], array[array2[j, 2]], array[array2[j, 3]]);
			}
		}

		internal void Lathe(string m, Vector3 center, float[] radii, float[] heights, int segments = 16)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: 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_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			if (segments == 16)
			{
				segments = 24;
			}
			for (int i = 0; i < radii.Length - 1; i++)
			{
				for (int j = 0; j < segments; j++)
				{
					float num = (float)j * (float)Math.PI * 2f / (float)segments;
					float num2 = (float)(j + 1) * (float)Math.PI * 2f / (float)segments;
					Vector3 a = center + new Vector3(Mathf.Cos(num) * radii[i], heights[i], Mathf.Sin(num) * radii[i]);
					Vector3 d = center + new Vector3(Mathf.Cos(num2) * radii[i], heights[i], Mathf.Sin(num2) * radii[i]);
					Vector3 c = center + new Vector3(Mathf.Cos(num2) * radii[i + 1], heights[i + 1], Mathf.Sin(num2) * radii[i + 1]);
					Vector3 b = center + new Vector3(Mathf.Cos(num) * radii[i + 1], heights[i + 1], Mathf.Sin(num) * radii[i + 1]);
					Quad(m, a, b, c, d);
					if (segments >= 20)
					{
						float num3 = radii[i + 1] - radii[i];
						float num4 = heights[i + 1] - heights[i];
						int num5 = vertices[m].Count - 6;
						for (int k = 0; k < 6; k++)
						{
							float num6 = ((k == 2 || k == 4 || k == 5) ? num2 : num);
							List<Vector3> list = organicNormals[m];
							int index = num5 + k;
							Vector3 val = new Vector3(Mathf.Cos(num6) * num4, 0f - num3, Mathf.Sin(num6) * num4);
							list[index] = ((Vector3)(ref val)).normalized;
						}
					}
				}
			}
		}

		internal void Ellipsoid(string m, Vector3 center, Vector3 size, int segments = 10, int rings = 6)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: 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_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_03af: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_035e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0363: Unknown result type (might be due to invalid IL or missing references)
			//IL_0367: Unknown result type (might be due to invalid IL or missing references)
			if (IsFood)
			{
				IngredientShape(this, foodId, m, center, size);
				return;
			}
			segments = Math.Max(12, segments + 4);
			rings = Math.Max(7, rings + 2);
			if (IsFood)
			{
				segments = Math.Min(segments, 18);
				rings = Math.Min(rings, 10);
			}
			if (IsFood && (Flesh(m) || Baked(m) || m.StartsWith("cap_") || m == "berry" || m == "blue"))
			{
				float num = Mathf.Max(size.x, size.z) * 0.026f;
				center += new Vector3(Mathf.Sin(center.z * 93f + center.x * 17f), Mathf.Sin(center.x * 87f + center.z * 53f) * 0.7f, Mathf.Cos(center.x * 71f - center.z * 21f)) * num;
			}
			float[] r = new float[rings + 1];
			float[] h = new float[rings + 1];
			for (int i = 0; i <= rings; i++)
			{
				float num2 = -(float)Math.PI / 2f + (float)Math.PI * (float)i / (float)rings;
				r[i] = Mathf.Cos(num2);
				h[i] = Mathf.Sin(num2);
			}
			for (int j = 0; j < rings; j++)
			{
				for (int k = 0; k < segments; k++)
				{
					float arg = (float)k * (float)Math.PI * 2f / (float)segments;
					float arg2 = (float)(k + 1) * (float)Math.PI * 2f / (float)segments;
					Func<float, int, Vector3> func = delegate(float v, int num5)
					{
						//IL_0026: 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)
						//IL_0036: Unknown result type (might be due to invalid IL or missing references)
						//IL_003b: Unknown result type (might be due to invalid IL or missing references)
						//IL_0040: Unknown result type (might be due to invalid IL or missing references)
						//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
						//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
						//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
						//IL_004e: 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)
						Vector3 val3 = Vector3.Scale(new Vector3(Mathf.Cos(v) * r[num5], h[num5], Mathf.Sin(v) * r[num5]), size * 0.5f);
						if (IsFood)
						{
							val3 *= 1f + OrganicRoughness(m) * (Mathf.PerlinNoise((val3.x + center.x) * 36f + 7f, (val3.z + center.z + val3.y) * 32f + 11f) - 0.5f) * 2f;
						}
						return center + val3;
					};
					Quad(m, func(arg, j), func(arg, j + 1), func(arg2, j + 1), func(arg2, j));
					int num3 = vertices[m].Count - 6;
					for (int num4 = num3; num4 < num3 + 6; num4++)
					{
						Vector3 val = vertices[m][num4] - center;
						List<Vector3> list = organicNormals[m];
						int index = num4;
						Vector3 val2 = new Vector3(val.x / (size.x * size.x), val.y / (size.y * size.y), val.z / (size.z * size.z));
						list[index] = ((Vector3)(ref val2)).normalized;
					}
				}
			}
			if (IsFood)
			{
				AddSurfaceMarks(this, m, center, size);
			}
		}

		internal void Rod(string m, Vector3 a, Vector3 b, float radius, int sides = 8)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: 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_0010: 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_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: 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_0041: 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_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: 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_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: 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_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = b - a;
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			Vector3 val2 = Vector3.Cross(normalized, (Mathf.Abs(normalized.y) > 0.95f) ? Vector3.right : Vector3.up);
			Vector3 val3 = ((Vector3)(ref val2)).normalized * radius;
			Vector3 val4 = Vector3.Cross(normalized, val3);
			for (int i = 0; i < sides; i++)
			{
				float num = (float)i * (float)Math.PI * 2f / (float)sides;
				float num2 = (float)(i + 1) * (float)Math.PI * 2f / (float)sides;
				Vector3 val5 = val3 * Mathf.Cos(num) + val4 * Mathf.Sin(num);
				Vector3 val6 = val3 * Mathf.Cos(num2) + val4 * Mathf.Sin(num2);
				Quad(m, a + val5, b + val5, b + val6, a + val6);
				Tri(m, a, a + val5, a + val6);
				Tri(m, b, b + val6, b + val5);
			}
		}

		internal void Finish(Dictionary<string, Material> palette)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: 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_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Expected O, but got Unknown
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			foreach (KeyValuePair<string, List<Vector3>> vertex in vertices)
			{
				Mesh val = new Mesh();
				((Object)val).name = ((Object)root).name + "_" + vertex.Key;
				val.vertices = vertex.Value.ToArray();
				val.triangles = indices[vertex.Key].ToArray();
				val.uv = uvs[vertex.Key].ToArray();
				val.RecalculateNormals();
				val.RecalculateBounds();
				Vector3[] normals = val.normals;
				List<Vector3> list = organicNormals[vertex.Key];
				for (int i = 0; i < normals.Length; i++)
				{
					if (list[i] != Vector3.zero)
					{
						ref Vector3 reference = ref normals[i];
						reference = list[i];
					}
				}
				val.normals = normals;
				if (IsFood)
				{
					float num = Faceting(vertex.Key);
					for (int j = 0; j < normals.Length; j += 3)
					{
						Vector3 val2 = Vector3.Cross(vertex.Value[j + 1] - vertex.Value[j], vertex.Value[j + 2] - vertex.Value[j]);
						Vector3 normalized = ((Vector3)(ref val2)).normalized;
						for (int k = 0; k < 3; k++)
						{
							if (list[j + k] != Vector3.zero)
							{
								ref Vector3 reference2 = ref normals[j + k];
								Vector3 val3 = Vector3.Lerp(normals[j + k], normalized, num);
								reference2 = ((Vector3)(ref val3)).normalized;
							}
						}
					}
					val.normals = normals;
				}
				GameObject val4 = new GameObject(vertex.Key);
				val4.layer = root.layer;
				val4.transform.SetParent(root.transform, false);
				val4.AddComponent<MeshFilter>().sharedMesh = val;
				((Renderer)val4.AddComponent<MeshRenderer>()).sharedMaterial = (IsFood ? FoodSurface(vertex.Key, palette) : palette[vertex.Key]);
			}
		}
	}

	internal const float AccessoryScale = 1.25f;

	private static readonly Dictionary<string, Material> Materials = new Dictionary<string, Material>();

	private static readonly Dictionary<string, Sprite> Icons = new Dictionary<string, Sprite>();

	internal static readonly Dictionary<string, GameObject> Visuals = new Dictionary<string, GameObject>();

	private static readonly Color[] TierColors = (Color[])(object)new Color[8]
	{
		C("735942"),
		C("45674D"),
		C("686044"),
		C("718494"),
		C("C29A52"),
		C("747CA1"),
		C("995242"),
		C("779CA5")
	};

	private static readonly Dictionary<string, Dictionary<string, int>> ShapeAudit = new Dictionary<string, Dictionary<string, int>>();

	private static readonly Dictionary<string, Material> FoodSurfaces = new Dictionary<string, Material>();

	private static Dictionary<string, Material> AccessoryPalette(string id)
	{
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Expected O, but got Unknown
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Expected O, but got Unknown
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c5: Expected O, but got Unknown
		//IL_0297: Unknown result type (might be due to invalid IL or missing references)
		//IL_029c: Unknown result type (might be due to invalid IL or missing references)
		Dictionary<string, Material> dictionary = Palette((id == "Cool") ? 7 : 0);
		string[] array = new string[7] { "wood", "darkwood", "stone", "cloth", "clay", "glaze", "metal" };
		foreach (string text in array)
		{
			Material val = new Material(dictionary[text]);
			((Object)val).name = "HT_A170_" + text + "_" + id;
			Texture2D val2 = (Texture2D)dictionary[text].mainTexture;
			Color pixel = val2.GetPixel(30, 30);
			Texture2D val3 = new Texture2D(256, 256, (TextureFormat)4, false);
			((Object)val3).name = ((Object)val).name;
			Color[] array2 = (Color[])(object)new Color[65536];
			Random random = new Random(170 + text.Length);
			for (int j = 0; j < 256; j++)
			{
				for (int k = 0; k < 256; k++)
				{
					float num = (float)random.NextDouble();
					float num2 = 0.91f + num * 0.14f;
					switch (text)
					{
					case "wood":
					case "darkwood":
					{
						float num3 = (float)k * 0.19f + Mathf.Sin((float)j * 0.022f) * 2f + Mathf.Sin((float)j * 0.063f) * 0.4f;
						num2 -= 0.2f * Mathf.Pow(Mathf.Abs(Mathf.Sin(num3)), 12f);
						break;
					}
					case "cloth":
						num2 += ((k % 4 == 0 || j % 4 == 0) ? (-0.16f) : 0.035f);
						break;
					case "stone":
						num2 += 0.09f * Mathf.Sin((float)k * 0.065f + (float)j * 0.028f + Mathf.Sin((float)j * 0.075f) * 2f);
						break;
					case "clay":
					case "glaze":
						num2 += 0.045f * Mathf.Sin((float)j * 0.6f);
						break;
					case "metal":
						num2 -= ((num < 0.08f) ? 0.15f : 0f);
						break;
					}
					ref Color reference = ref array2[j * 256 + k];
					reference = new Color(pixel.r * num2, pixel.g * num2, pixel.b * num2, 1f);
				}
			}
			val3.SetPixels(array2);
			val3.Apply();
			((Texture)val3).filterMode = (FilterMode)1;
			((Texture)val3).wrapMode = (TextureWrapMode)0;
			val.mainTexture = (Texture)(object)val3;
			dictionary[text] = val;
		}
		if (id == "Cool")
		{
			CoolingPalette170(dictionary);
		}
		return dictionary;
	}

	private static void AccessoryFilterCloth(Builder b)
	{
		//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_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: 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_0083: 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_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: 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_00f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: Unknown result type (might be due to invalid IL or missing references)
		//IL_010f: Unknown result type (might be due to invalid IL or missing references)
		//IL_011a: Unknown result type (might be due to invalid IL or missing references)
		//IL_012e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0133: Unknown result type (might be due to invalid IL or missing references)
		float[] heights = new float[6] { 0.29f, 0.34f, 0.42f, 0.52f, 0.6f, 0.625f };
		float[] radius = new float[6] { 0.017f, 0.052f, 0.105f, 0.149f, 0.165f, 0.164f };
		Func<int, int, Vector3> func = delegate(int j, int i)
		{
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			float num5 = (float)i * (float)Math.PI / 16f;
			float num6 = Mathf.Sin(num5 * 8f + 0.3f) * 0.008f * (float)j / 5f;
			return new Vector3(Mathf.Cos(num5) * (radius[j] + num6), heights[j] + Mathf.Sin(num5 * 3f) * 0.006f * (float)j / 5f, Mathf.Sin(num5) * (radius[j] + num6));
		};
		for (int num = 0; num < 5; num++)
		{
			for (int num2 = 0; num2 < 32; num2++)
			{
				Vector3 val = func(num, num2);
				Vector3 val2 = func(num + 1, num2 + 1);
				Vector3 val3 = func(num + 1, num2);
				Vector3 val4 = func(num, num2 + 1);
				b.Quad("cloth", val, val3, val2, val4);
				b.Quad("cloth", val4, val2, val3, val);
			}
		}
		for (int num3 = 0; num3 < 32; num3++)
		{
			b.Rod("rope", func(5, num3), func(5, num3 + 1), 0.006f, 5);
		}
		for (int num4 = 1; num4 < 5; num4++)
		{
			b.Rod("rope", func(num4, 8) + new Vector3(0f, 0f, 0.004f), func(num4 + 1, 8) + new Vector3(0f, 0f, 0.004f), 0.0025f, 4);
		}
	}

	private static void AccessoryStoneSlab(Builder b)
	{
		//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_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_00de: 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)
		//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: Unknown result type (might be due to invalid IL or missing references)
		//IL_010f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0196: Unknown result type (might be due to invalid IL or missing references)
		//IL_0198: Unknown result type (might be due to invalid IL or missing references)
		//IL_019a: Unknown result type (might be due to invalid IL or missing references)
		//IL_019c: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01db: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
		Vector2[] array = (Vector2[])(object)new Vector2[8]
		{
			new Vector2(-0.605f, -0.405f),
			new Vector2(0.605f, -0.405f),
			new Vector2(0.635f, -0.375f),
			new Vector2(0.635f, 0.375f),
			new Vector2(0.605f, 0.405f),
			new Vector2(-0.605f, 0.405f),
			new Vector2(-0.635f, 0.375f),
			new Vector2(-0.635f, -0.375f)
		};
		Vector3 val3 = default(Vector3);
		Vector3 val4 = default(Vector3);
		Vector3 val5 = default(Vector3);
		Vector3 val6 = default(Vector3);
		for (int i = 0; i < 8; i++)
		{
			Vector2 val = array[i];
			Vector2 val2 = array[(i + 1) % 8];
			((Vector3)(ref val3))..ctor(val.x, 0.46f, val.y);
			((Vector3)(ref val4))..ctor(val2.x, 0.46f, val2.y);
			((Vector3)(ref val5))..ctor(val.x * 0.97f, 0.58f, val.y * 0.96f);
			((Vector3)(ref val6))..ctor(val2.x * 0.97f, 0.58f, val2.y * 0.96f);
			b.Quad("stone", val3, val5, val6, val4);
			b.Tri("stone", new Vector3(0f, 0.58f, 0f), val6, val5);
			b.Tri("stone", new Vector3(0f, 0.46f, 0f), val3, val4);
		}
	}

	private static void AccessoryDetails(Builder b, string id)
	{
		//IL_0032: 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_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_042d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0441: Unknown result type (might be due to invalid IL or missing references)
		//IL_0469: Unknown result type (might be due to invalid IL or missing references)
		//IL_0481: 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_04c2: 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_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0500: Unknown result type (might be due to invalid IL or missing references)
		//IL_0528: Unknown result type (might be due to invalid IL or missing references)
		//IL_055c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0574: Unknown result type (might be due to invalid IL or missing references)
		//IL_059d: Unknown result type (might be due to invalid IL or missing references)
		//IL_05b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_05f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0605: Unknown result type (might be due to invalid IL or missing references)
		//IL_0634: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_011c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0176: Unknown result type (might be due to invalid IL or missing references)
		//IL_0214: Unknown result type (might be due to invalid IL or missing references)
		//IL_0216: Unknown result type (might be due to invalid IL or missing references)
		//IL_021d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0224: Unknown result type (might be due to invalid IL or missing references)
		//IL_0229: Unknown result type (might be due to invalid IL or missing references)
		//IL_022e: 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_023f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0244: 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_024b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0252: Unknown result type (might be due to invalid IL or missing references)
		//IL_0259: Unknown result type (might be due to invalid IL or missing references)
		//IL_025e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0263: Unknown result type (might be due to invalid IL or missing references)
		//IL_0279: Unknown result type (might be due to invalid IL or missing references)
		//IL_0280: Unknown result type (might be due to invalid IL or missing references)
		//IL_0285: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_034c: 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_0364: 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_037f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0386: Unknown result type (might be due to invalid IL or missing references)
		//IL_038b: 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_03b2: 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_03be: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_03db: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e0: Unknown result type (might be due to invalid IL or missing references)
		if (id == "Ferment")
		{
			for (int i = 0; i < 3; i++)
			{
				b.Box("darkwood", new Vector3(0f, -0.185f, 0.08f + (float)i * 0.13f), new Vector3(1.3f, 0.004f, 0.007f));
			}
			b.Box("wood", new Vector3(0f, -0.1f, 0.025f), new Vector3(1.22f, 0.11f, 0.042f));
			for (int j = -1; j <= 1; j += 2)
			{
				b.Box("metal", new Vector3((float)j * 0.51f, -0.22f, 0.455f), new Vector3(0.066f, 0.078f, 0.014f));
				for (int k = 0; k < 2; k++)
				{
					b.Rod("metal", new Vector3((float)j * 0.51f, -0.23f + (float)k * 0.027f, 0.46f), new Vector3((float)j * 0.51f, -0.23f + (float)k * 0.027f, 0.478f), 0.013f);
				}
			}
			Vector3 val = default(Vector3);
			Vector3 val2 = default(Vector3);
			for (int l = -1; l <= 1; l++)
			{
				float num = ((l == 0) ? 1.15f : 0.95f);
				((Vector3)(ref val))..ctor((float)l * 0.4f, -0.183f, 0.24f);
				b.Lathe("darkwood", val, new float[3]
				{
					0.155f * num,
					0.158f * num,
					0.16f * num
				}, new float[3]
				{
					0.06f * num,
					0.075f * num,
					0.088f * num
				}, 32);
				for (int m = 0; m < 16; m++)
				{
					float num2 = (float)m * (float)Math.PI / 8f;
					((Vector3)(ref val2))..ctor(Mathf.Cos(num2), 0f, Mathf.Sin(num2));
					b.Rod("cloth", val + val2 * 0.115f * num + Vector3.up * 0.312f * num, val + val2 * 0.13f * num + Vector3.up * (0.329f + 0.003f * (float)(m % 3)) * num, 0.0035f * num, 5);
				}
				for (int n = 0; n < 3; n++)
				{
					b.Lathe("rope", val, new float[3]
					{
						0.114f * num,
						0.118f * num,
						0.114f * num
					}, new float[3]
					{
						(0.308f + (float)n * 0.007f) * num,
						(0.311f + (float)n * 0.007f) * num,
						(0.314f + (float)n * 0.007f) * num
					}, 32);
				}
				b.Rod("rope", val + new Vector3(0.025f, 0.32f, 0.117f) * num, val + new Vector3(0.052f, 0.24f, 0.151f) * num, 0.005f, 6);
				b.Rod("rope", val + new Vector3(0.025f, 0.32f, 0.117f) * num, val + new Vector3(-0.006f, 0.255f, 0.159f) * num, 0.005f, 6);
			}
		}
		else
		{
			if (!(id == "Strainer"))
			{
				return;
			}
			for (int num3 = -1; num3 <= 1; num3 += 2)
			{
				b.Box("metal", new Vector3((float)num3 * 0.25f, 0.12f, 0f), new Vector3(0.076f, 0.043f, 0.092f));
				b.Rod("wood", new Vector3((float)num3 * 0.25f, 0.43f, -0.014f), new Vector3((float)num3 * 0.25f, 0.078f, -0.2f), 0.022f, 6);
				b.Rod("metal", new Vector3((float)num3 * 0.25f, 0.71f, 0.039f), new Vector3((float)num3 * 0.25f, 0.71f, 0.06f), 0.015f);
				for (int num4 = 0; num4 < 5; num4++)
				{
					b.Rod("rope", new Vector3((float)num3 * 0.16f - 0.009f + (float)num4 * 0.004f, 0.73f, -0.043f), new Vector3((float)num3 * 0.16f - 0.009f + (float)num4 * 0.004f, 0.79f, 0.014f), 0.003f, 5);
				}
				b.Rod("clay", new Vector3((float)num3 * 0.175f, 0.19f, -0.04f), new Vector3((float)num3 * 0.238f, 0.19f, -0.015f), 0.013f);
				b.Rod("clay", new Vector3((float)num3 * 0.238f, 0.19f, -0.015f), new Vector3((float)num3 * 0.175f, 0.19f, 0.05f), 0.013f);
			}
			for (int num5 = -1; num5 <= 1; num5++)
			{
				b.Box("darkwood", new Vector3((float)num5 * 0.147f, 0.071f, 0f), new Vector3(0.004f, 0.003f, 0.44f));
			}
			b.Lathe("rim", new Vector3(0f, 0.178f, 0f), new float[3] { 0.09f, 0.093f, 0.09f }, new float[3] { 0f, 0.001f, 0.002f }, 32);
		}
	}

	private static void CoolingPalette170(Dictionary<string, Material> p)
	{
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Expected O, but got Unknown
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b8: Expected O, but got Unknown
		//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
		string[] array = new string[5] { "slateA", "slateB", "slateC", "slateEdge", "slateVein" };
		string[] array2 = new string[5] { "607D87", "728B91", "536D78", "3E535E", "99ACAD" };
		for (int i = 0; i < array.Length; i++)
		{
			Material val = new Material(p["stone"]);
			((Object)val).name = "HT_Cool170_" + array[i];
			Color val2 = C(array2[i]);
			Texture2D val3 = new Texture2D(256, 256, (TextureFormat)4, false);
			((Object)val3).name = ((Object)val).name;
			Color[] array3 = (Color[])(object)new Color[65536];
			Random random = new Random(801 + i);
			for (int j = 0; j < 256; j++)
			{
				for (int k = 0; k < 256; k++)
				{
					float num = (float)k * 0.067f + (float)j * 0.021f + Mathf.Sin((float)j * 0.038f) * 2.1f + Mathf.Sin((float)k * 0.018f) * 1.5f;
					float num2 = Mathf.Sin((float)k * 0.081f) * Mathf.Sin((float)j * 0.096f) * 0.075f;
					float num3 = Mathf.Pow(Mathf.Abs(Mathf.Sin(num)), 24f) * 0.1f;
					float num4 = 0.89f + (float)random.NextDouble() * 0.14f + num2 + num3;
					ref Color reference = ref array3[j * 256 + k];
					reference = new Color(val2.r * num4, val2.g * num4, val2.b * num4, 1f);
				}
			}
			val3.SetPixels(array3);
			val3.Apply();
			((Texture)val3).filterMode = (FilterMode)1;
			((Texture)val3).wrapMode = (TextureWrapMode)0;
			val.mainTexture = (Texture)(object)val3;
			p[array[i]] = val;
		}
	}

	private static void SlateBlock170(Builder b, Vector3 center, float width, float depth, float height, int seed, string top)
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e4: 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_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_0118: Unknown result type (might be due to invalid IL or missing references)
		//IL_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0135: Unknown result type (might be due to invalid IL or missing references)
		//IL_013a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0152: Unknown result type (might be due to invalid IL or missing references)
		//IL_0157: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cd: 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_021e: 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_02d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_030d: 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_0325: Unknown result type (might be due to invalid IL or missing references)
		//IL_0271: Unknown result type (might be due to invalid IL or missing references)
		//IL_0282: Unknown result type (might be due to invalid IL or missing references)
		//IL_0293: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0352: Unknown result type (might be due to invalid IL or missing references)
		//IL_037e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0383: Unknown result type (might be due to invalid IL or missing references)
		//IL_0388: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b3: 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)
		Vector2[] array = (Vector2[])(object)new Vector2[12]
		{
			new Vector2(-0.43f, -0.5f),
			new Vector2(0.04f, -0.5f),
			new Vector2(0.43f, -0.5f),
			new Vector2(0.5f, -0.42f),
			new Vector2(0.5f, 0.05f),
			new Vector2(0.5f, 0.42f),
			new Vector2(0.41f, 0.5f),
			new Vector2(-0.05f, 0.5f),
			new Vector2(-0.43f, 0.5f),
			new Vector2(-0.5f, 0.39f),
			new Vector2(-0.5f, -0.08f),
			new Vector2(-0.5f, -0.42f)
		};
		Random random = new Random(seed);
		Vector3[,] array2 = new Vector3[4, 12];
		float[] array3 = new float[4] { 0f, 0.16f, 0.82f, 1f };
		float[] array4 = new float[4] { 0.96f, 1f, 1f, 0.94f };
		for (int i = 0; i < 4; i++)
		{
			for (int j = 0; j < 12; j++)
			{
				float num = (float)random.NextDouble() * 0.014f;
				Vector2 val = array[j];
				ref Vector3 reference = ref array2[i, j];
				reference = center + new Vector3(val.x * width * (array4[i] - num), array3[i] * height + ((i == 3) ? 0f : (((float)random.NextDouble() - 0.5f) * 0.009f)), val.y * depth * (array4[i] - num));
			}
		}
		for (int k = 0; k < 3; k++)
		{
			for (int l = 0; l < 12; l++)
			{
				int num2 = (l + 1) % 12;
				b.Quad((k == 1) ? "slateEdge" : top, array2[k, l], array2[k + 1, l], array2[k + 1, num2], array2[k, num2]);
			}
		}
		for (int m = 0; m < 12; m++)
		{
			int num3 = (m + 1) % 12;
			b.Tri(top, center + Vector3.up * height, array2[3, num3], array2[3, m]);
			b.Tri("slateEdge", center, array2[0, m], array2[0, num3]);
		}
		for (int n = 0; n < 3; n++)
		{
			b.Rod((n == 1) ? "slateVein" : top, center + new Vector3((0f - width) * 0.38f + (float)n * 0.025f, height * (0.25f + (float)n * 0.19f), depth * 0.496f), center + new Vector3(width * (0.23f + (float)n * 0.055f), height * (0.27f + (float)n * 0.19f), depth * 0.496f), 0.0024f, 4);
		}
	}

	private static void CoolingRack170(Builder b)
	{
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: 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_0115: Unknown result type (might be due to invalid IL or missing references)
		//IL_0129: Unknown result type (might be due to invalid IL or missing references)
		//IL_0161: Unknown result type (might be due to invalid IL or missing references)
		//IL_0175: Unknown result type (might be due to invalid IL or missing references)
		//IL_019d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01de: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0229: Unknown result type (might be due to invalid IL or missing references)
		//IL_024b: Unknown result type (might be due to invalid IL or missing references)
		//IL_027f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0297: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0301: Unknown result type (might be due to invalid IL or missing references)
		//IL_0319: Unknown result type (might be due to invalid IL or missing references)
		//IL_0356: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0417: Unknown result type (might be due to invalid IL or missing references)
		//IL_0453: Unknown result type (might be due to invalid IL or missing references)
		//IL_049a: Unknown result type (might be due to invalid IL or missing references)
		//IL_04bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_04e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_04eb: 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_05b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_05c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_05cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0693: Unknown result type (might be due to invalid IL or missing references)
		//IL_0695: Unknown result type (might be due to invalid IL or missing references)
		//IL_0697: Unknown result type (might be due to invalid IL or missing references)
		//IL_0699: Unknown result type (might be due to invalid IL or missing references)
		//IL_06a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_06a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_06aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_06ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_072b: Unknown result type (might be due to invalid IL or missing references)
		//IL_072d: Unknown result type (might be due to invalid IL or missing references)
		//IL_072f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0731: Unknown result type (might be due to invalid IL or missing references)
		//IL_073e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0740: Unknown result type (might be due to invalid IL or missing references)
		//IL_0742: Unknown result type (might be due to invalid IL or missing references)
		//IL_0744: Unknown result type (might be due to invalid IL or missing references)
		//IL_0757: Unknown result type (might be due to invalid IL or missing references)
		//IL_0759: Unknown result type (might be due to invalid IL or missing references)
		//IL_075b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0765: Unknown result type (might be due to invalid IL or missing references)
		//IL_076a: Unknown result type (might be due to invalid IL or missing references)
		for (int i = -1; i <= 1; i += 2)
		{
			for (int j = -1; j <= 1; j += 2)
			{
				b.Box("darkwood", new Vector3((float)i * 0.49f, 0.23f, (float)j * 0.27f), new Vector3(0.135f, 0.46f, 0.135f));
				b.Box("metal", new Vector3((float)i * 0.49f, 0.055f, (float)j * 0.27f), new Vector3(0.145f, 0.052f, 0.145f));
			}
		}
		for (int k = 0; k < 5; k++)
		{
			b.Box((k % 2 == 0) ? "wood" : "darkwood", new Vector3(-0.43f + (float)k * 0.215f, 0.132f, 0f), new Vector3(0.208f, 0.056f, 0.64f));
		}
		for (int l = -1; l <= 1; l += 2)
		{
			b.Box("wood", new Vector3(0f, 0.416f, (float)l * 0.31f), new Vector3(1.15f, 0.105f, 0.085f));
		}
		for (int m = -1; m <= 1; m += 2)
		{
			b.Box("wood", new Vector3((float)m * 0.49f, 0.416f, 0f), new Vector3(0.1f, 0.105f, 0.61f));
			b.Rod("darkwood", new Vector3((float)m * 0.49f, 0.16f, -0.24f), new Vector3((float)m * 0.49f, 0.37f, 0.24f), 0.032f, 4);
			b.Box("metal", new Vector3((float)m * 0.49f, 0.42f, 0.358f), new Vector3(0.19f, 0.1f, 0.015f));
			for (int n = -1; n <= 1; n += 2)
			{
				b.Rod("metal", new Vector3((float)m * 0.49f + (float)n * 0.058f, 0.42f, 0.361f), new Vector3((float)m * 0.49f + (float)n * 0.058f, 0.42f, 0.38f), 0.013f);
			}
			b.Rod("metal", new Vector3((float)m * 0.57f, 0.43f, -0.1f), new Vector3((float)m * 0.68f, 0.405f, -0.1f), 0.015f);
			b.Rod("metal", new Vector3((float)m * 0.68f, 0.405f, -0.1f), new Vector3((float)m * 0.68f, 0.405f, 0.1f), 0.017f);
			b.Rod("metal", new Vector3((float)m * 0.68f, 0.405f, 0.1f), new Vector3((float)m * 0.57f, 0.43f, 0.1f), 0.015f);
		}
		for (int num = 0; num < 3; num++)
		{
			SlateBlock170(b, new Vector3(-0.422f + (float)num * 0.422f, 0.465f, 0f), 0.414f, 0.81f, 0.155f, 71 + num, (new string[3] { "slateA", "slateB", "slateC" })[num]);
		}
		SlateBlock170(b, new Vector3(0.25f, 0.161f, 0.075f), 0.39f, 0.38f, 0.057f, 88, "slateB");
		SlateBlock170(b, new Vector3(0.23f, 0.219f, 0.063f), 0.36f, 0.34f, 0.054f, 89, "slateA");
		SlateBlock170(b, new Vector3(0.27f, 0.274f, 0.058f), 0.32f, 0.3f, 0.048f, 90, "slateC");
		Vector3 val = default(Vector3);
		((Vector3)(ref val))..ctor(-0.29f, 0.164f, 0.08f);
		b.Lathe("darkwood", val, new float[5] { 0.11f, 0.145f, 0.145f, 0.128f, 0.1f }, new float[5] { 0f, 0.18f, 0.19f, 0.185f, 0.025f }, 20);
		for (int num2 = 0; num2 < 20; num2++)
		{
			float num3 = (float)num2 * (float)Math.PI / 10f;
			b.Rod("wood", val + new Vector3(Mathf.Cos(num3) * 0.11f, 0.015f, Mathf.Sin(num3) * 0.11f), val + new Vector3(Mathf.Cos(num3) * 0.145f, 0.18f, Mathf.Sin(num3) * 0.145f), 0.006f, 5);
		}
		for (int num4 = 0; num4 < 2; num4++)
		{
			b.Lathe("metal", val, new float[3]
			{
				0.12f + (float)num4 * 0.021f,
				0.122f + (float)num4 * 0.021f,
				0.12f + (float)num4 * 0.021f
			}, new float[3]
			{
				0.035f + (float)num4 * 0.115f,
				0.047f + (float)num4 * 0.115f,
				0.059f + (float)num4 * 0.115f
			}, 24);
		}
		SlateBlock170(b, val + new Vector3(0f, 0.065f, 0f), 0.15f, 0.14f, 0.065f, 91, "slateC");
		Vector3 val2 = default(Vector3);
		Vector3 val3 = default(Vector3);
		Vector3 val4 = default(Vector3);
		Vector3 val5 = default(Vector3);
		Vector3 val6 = default(Vector3);
		Vector3 val7 = default(Vector3);
		for (int num5 = 0; num5 < 14; num5++)
		{
			float num6 = 0.27f + (float)num5 * 0.019f;
			float num7 = Mathf.Sin((float)num5 * 1.9f) * 0.006f;
			((Vector3)(ref val2))..ctor(num6, 0.626f + num7, 0.18f);
			((Vector3)(ref val3))..ctor(num6 + 0.019f, 0.626f + Mathf.Sin((float)(num5 + 1) * 1.9f) * 0.006f, 0.18f);
			((Vector3)(ref val4))..ctor(num6 + 0.019f, 0.626f, 0.406f);
			((Vector3)(ref val5))..ctor(num6, 0.626f, 0.406f);
			b.Quad("cloth", val2, val5, val4, val3);
			b.Quad("cloth", val3, val4, val5, val2);
			((Vector3)(ref val6))..ctor(num6, 0.5f + Mathf.Sin((float)num5 * 0.8f) * 0.006f, 0.416f + num7);
			((Vector3)(ref val7))..ctor(num6 + 0.019f, 0.5f + Mathf.Sin((float)(num5 + 1) * 0.8f) * 0.006f, 0.416f + Mathf.Sin((float)(num5 + 1) * 1.9f) * 0.006f);
			b.Quad("cloth", val5, val6, val7, val4);
			b.Quad("cloth", val4, val7, val6, val5);
			if (num5 % 2 == 0)
			{
				b.Rod("rope", val6, val6 - Vector3.up * 0.017f, 0.0018f, 4);
			}
		}
	}

	private static Color C(string s)
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		Color result = default(Color);
		ColorUtility.TryParseHtmlString("#" + s, ref result);
		return result;
	}

	private static Material Mat(string key, string hex, bool grain = false)
	{
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Expected O, but got Unknown
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Expected O, but got Unknown
		//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_0165: Unknown result type (might be due to invalid IL or missing references)
		//IL_016a: Unknown result type (might be due to invalid IL or missing references)
		if (Materials.TryGetValue(key, out var value))
		{
			return value;
		}
		GameObject prefab = PrefabManager.Instance.GetPrefab("wood_beam");
		WearNTear wear = prefab.GetComponent<WearNTear>();
		Material sharedMaterial = ((Renderer)prefab.GetComponentsInChildren<MeshRenderer>(true).First((MeshRenderer r) => (Object)(object)r != (Object)(object)wear.m_snow && (Object)(object)r != (Object)(object)wear.m_snowWorn && (Object)(object)r != (Object)(object)wear.m_snowBroken && ((Object)((Renderer)r).sharedMaterial.shader).name != "Valheim/Snow Mesh")).sharedMaterial;
		value = new Material(sharedMaterial);
		((Object)value).name = "HT_Art_" + key;
		if (!value.HasProperty("_MainTex"))
		{
			throw new Exception("Audited wood shader lacks albedo property");
		}
		Color val = C(hex);
		Texture2D val2 = new Texture2D(128, 128, (TextureFormat)4, false);
		((Object)val2).name = "HT_" + key + "_Albedo";
		Color[] array = (Color[])(object)new Color[16384];
		Random random = new Random(734 + key.Length);
		for (int num = 0; num < 128; num++)
		{
			for (int num2 = 0; num2 < 128; num2++)
			{
				float num3 = 0.87f + (float)random.NextDouble() * 0.16f;
				if (grain)
				{
					num3 -= 0.1f * Mathf.Abs(Mathf.Sin((float)num2 * 0.35f + Mathf.Sin((float)num * 0.085f) * 0.6f));
				}
				ref Color reference = ref array[num * 128 + num2];
				reference = new Color(val.r * num3, val.g * num3, val.b * num3, 1f);
			}
		}
		val2.SetPixels(array);
		val2.Apply();
		((Texture)val2).filterMode = (FilterMode)0;
		((Texture)val2).wrapMode = (TextureWrapMode)0;
		value.mainTexture = (Texture)(object)val2;
		if (value.HasProperty("_Color"))
		{
			value.SetColor("_Color", Color.white);
		}
		if (value.HasProperty("_BumpMap"))
		{
			value.SetTexture("_BumpMap", (Texture)null);
		}
		if (value.HasProperty("_Glossiness"))
		{
			value.SetFloat("_Glossiness", 0.06f);
		}
		if (value.HasProperty("_Metallic"))
		{
			value.SetFloat("_Metallic", 0f);
		}
		Materials[key] = value;
		return value;
	}

	private static Dictionary<string, Material> Palette(int tier)
	{
		//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
		Dictionary<string, Material> dictionary = new Dictionary<string, Material>();
		dictionary.Add("wood", Mat("wood", "765237", grain: true));
		dictionary.Add("darkwood", Mat("darkwood", "493325", grain: true));
		dictionary.Add("clay", Mat("clay", "AF6D46"));
		dictionary.Add("rim", Mat("rim", "DEC28B"));
		dictionary.Add("rope", Mat("rope", "B19A70"));
		dictionary.Add("cloth", Mat("cloth", "D3C9A3"));
		dictionary.Add("metal", Mat("metal", "43474B"));
		dictionary.Add("stone", Mat("stone", "61737B"));
		dictionary.Add("glaze", Mat("glaze" + tier, ColorUtility.ToHtmlStringRGB(TierColors[tier])));
		dictionary.Add("meat", Mat("meat", "84432D"));
		dictionary.Add("char", Mat("char", "402820"));
		dictionary.Add("orange", Mat("orange", "D98A32"));
		dictionary.Add("green", Mat("green", "577739"));
		dictionary.Add("leaf", Mat("leaf", "7F963F"));
		dictionary.Add("white", Mat("white", "E6D5A4"));
		dictionary.Add("berry", Mat("berry", "933B42"));
		dictionary.Add("blue", Mat("blue", "4E526F"));
		dictionary.Add("purple", Mat("purple", "956AAB"));
		dictionary.Add("gold", Mat("gold", "D8A139"));
		dictionary.Add("broth", Mat("broth", "A2662F"));
		dictionary.Add("pale", Mat("pale", "C8AA68"));
		return dictionary;
	}

	private static void Bowl(Builder b, Vector3 p, float radius, float height, string material = "clay", int segments = 16)
	{
		//IL_0003: 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)
		b.Lathe(material, p, new float[8]
		{
			0f,
			radius * 0.5f,
			radius * 0.8f,
			radius,
			radius,
			radius * 0.91f,
			radius * 0.68f,
			0f
		}, new float[8]
		{
			0f,
			0f,
			height * 0.32f,
			height * 0.92f,
			height,
			height * 0.88f,
			height * 0.2f,
			height * 0.2f
		}, segments);
		b.Lathe("rim", p, new float[4]
		{
			radius * 0.99f,
			radius * 1.035f,
			radius * 1.035f,
			radius * 0.96f
		}, new float[4]
		{
			height * 0.87f,
			height * 0.89f,
			height,
			height
		}, segments);
	}

	private static void Jar(Builder b, Vector3 p, float scale, string body)
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0123: Unknown result type (might be due to invalid IL or missing references)
		//IL_0133: Unknown result type (might be due to invalid IL or missing references)
		//IL_013e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0143: Unknown result type (might be due to invalid IL or missing references)
		//IL_0157: Unknown result type (might be due to invalid IL or missing references)
		//IL_0162: Unknown result type (might be due to invalid IL or missing references)
		//IL_0177: Unknown result type (might be due to invalid IL or missing references)
		//IL_0187: Unknown result type (might be due to invalid IL or missing references)
		//IL_0192: 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_01ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
		b.Lathe(body, p, new float[8] { 0f, 0.11f, 0.15f, 0.17f, 0.16f, 0.105f, 0.105f, 0f }.Select((float v) => v * scale).ToArray(), new float[8] { 0f, 0f, 0.05f, 0.18f, 0.26f, 0.3f, 0.34f, 0.34f }.Select((float v) => v * scale).ToArray());
		b.Lathe("cloth", p, new float[4] { 0.108f, 0.135f, 0.112f, 0f }.Select((float v) => v * scale).ToArray(), new float[4] { 0.305f, 0.329f, 0.35f, 0.35f }.Select((float v) => v * scale).ToArray());
		b.Lathe("rope", p, new float[3] { 0.113f, 0.114f, 0.113f }.Select((float v) => v * scale).ToArray(), new float[3] { 0.31f, 0.32f, 0.33f }.Select((float v) => v * scale).ToArray());
		b.Box("cloth", p + new Vector3(0f, 0.16f, 0.164f) * scale, new Vector3(0.105f, 0.1f, 0.012f) * scale);
		b.Box("glaze", p + new Vector3(0f, 0.16f, 0.174f) * scale, new Vector3(0.016f, 0.06f, 0.006f) * scale);
	}

	internal static GameObject AccessoryModel(GameObject root, string id)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_050b: Unknown result type (might be due to invalid IL or missing references)
		//IL_051f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0225: Unknown result type (might be due to invalid IL or missing references)
		//IL_0239: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_0112: Unknown result type (might be due to invalid IL or missing references)
		//IL_0129: Unknown result type (might be due to invalid IL or missing references)
		//IL_0542: Unknown result type (might be due to invalid IL or missing references)
		//IL_0556: 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_027d: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0304: Unknown result type (might be due to invalid IL or missing references)
		//IL_0324: 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_015b: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Unknown result type (might be due to invalid IL or missing references)
		//IL_01af: Unknown result type (might be due to invalid IL or missing references)
		//IL_05d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_05e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_03bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0404: 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_0434: Unknown result type (might be due to invalid IL or missing references)
		//IL_0448: Unknown result type (might be due to invalid IL or missing references)
		//IL_0608: Unknown result type (might be due to invalid IL or missing references)
		//IL_0612: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_058d: Unknown result type (might be due to invalid IL or missing references)
		//IL_05a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_046b: Unknown result type (might be due to invalid IL or missing references)
		//IL_047f: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_04d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_04e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0633: Unknown result type (might be due to invalid IL or missing references)
		//IL_063d: Unknown result type (might be due to invalid IL or missing references)
		//IL_064a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0654: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("ReplaceableVisual");
		val.layer = root.layer;
		val.transform.SetParent(root.transform, false);
		Builder builder = new Builder(val);
		if (id == "Ferment")
		{
			builder.Box("wood", new Vector3(0f, -0.22f, 0.23f), new Vector3(1.34f, 0.065f, 0.45f));
			for (int i = -1; i <= 1; i += 2)
			{
				builder.Box("darkwood", new Vector3((float)i * 0.51f, -0.15f, 0.025f), new Vector3(0.095f, 0.5f, 0.05f));
				builder.Rod("wood", new Vector3((float)i * 0.51f, -0.36f, 0.045f), new Vector3((float)i * 0.51f, -0.25f, 0.38f), 0.045f, 4);
				builder.Rod("metal", new Vector3((float)i * 0.51f, 0.02f, 0.046f), new Vector3((float)i * 0.51f, 0.02f, 0.067f), 0.021f);
			}
			for (int j = -1; j <= 1; j++)
			{
				Jar(builder, new Vector3((float)j * 0.4f, -0.183f, 0.24f), (j == 0) ? 1.15f : 0.95f, (j == 0) ? "glaze" : "clay");
			}
			Collider(root, new Vector3(0f, -0.22f, 0.23f), new Vector3(1.34f, 0.075f, 0.45f));
			for (int k = -1; k <= 1; k++)
			{
				Collider(root, new Vector3((float)k * 0.4f, -0.01f, 0.24f), new Vector3(0.34f, 0.39f, 0.34f));
			}
		}
		else if (id == "Strainer")
		{
			builder.Box("wood", new Vector3(0f, 0.035f, 0f), new Vector3(0.6f, 0.07f, 0.47f));
			for (int l = -1; l <= 1; l += 2)
			{
				builder.Box("darkwood", new Vector3((float)l * 0.25f, 0.4f, 0f), new Vector3(0.065f, 0.75f, 0.08f));
				builder.Rod("wood", new Vector3((float)l * 0.25f, 0.18f, 0f), new Vector3((float)l * 0.14f, 0.06f, 0f), 0.026f, 4);
			}
			builder.Rod("wood", new Vector3(-0.3f, 0.75f, 0f), new Vector3(0.3f, 0.75f, 0f), 0.037f);
			Bowl(builder, new Vector3(0f, 0.073f, 0f), 0.205f, 0.13f, "glaze");
			builder.Lathe("broth", new Vector3(0f, 0.17f, 0f), new float[4] { 0f, 0.173f, 0.173f, 0f }, new float[4] { 0f, 0f, 0.008f, 0.008f });
			AccessoryFilterCloth(builder);
			for (int m = -1; m <= 1; m += 2)
			{
				builder.Rod("rope", new Vector3((float)m * 0.16f, 0.61f, 0f), new Vector3((float)m * 0.16f, 0.76f, 0f), 0.008f, 6);
			}
			builder.Ellipsoid("gold", new Vector3(0f, 0.26f, 0f), new Vector3(0.018f, 0.027f, 0.018f), 6, 4);
			Collider(root, new Vector3(0f, 0.04f, 0f), new Vector3(0.6f, 0.08f, 0.47f));
			for (int n = -1; n <= 1; n += 2)
			{
				Collider(root, new Vector3((float)n * 0.25f, 0.41f, 0f), new Vector3(0.075f, 0.75f, 0.1f));
			}
			Collider(root, new Vector3(0f, 0.48f, 0f), new Vector3(0.34f, 0.3f, 0.34f));
			Collider(root, new Vector3(0f, 0.75f, 0f), new Vector3(0.65f, 0.075f, 0.09f));
		}
		else
		{
			CoolingRack170(builder);
			Collider(root, new Vector3(0f, 0.54f, 0f), new Vector3(1.27f, 0.2f, 0.81f));
			for (int num = -1; num <= 1; num += 2)
			{
				Collider(root, new Vector3((float)num * 0.64f, 0.405f, 0f), new Vector3(0.14f, 0.045f, 0.24f));
			}
			for (int num2 = -1; num2 <= 1; num2 += 2)
			{
				for (int num3 = -1; num3 <= 1; num3 += 2)
				{
					Collider(root, new Vector3((float)num2 * 0.49f, 0.23f, (float)num3 * 0.27f), new Vector3(0.13f, 0.46f, 0.13f));
				}
			}
			Collider(root, new Vector3(0f, 0.13f, 0f), new Vector3(1.12f, 0.055f, 0.66f));
		}
		AccessoryDetails(builder, id);
		builder.Finish(AccessoryPalette(id));
		val.transform.localScale = Vector3.one * 1.25f;
		BoxCollider[] components = root.GetComponents<BoxCollider>();
		foreach (BoxCollider val2 in components)
		{
			val2.center *= 1.25f;
			val2.size *= 1.25f;
		}
		Visuals["HT_A_" + id] = val;
		return val;
	}

	private static void Collider(GameObject root, Vector3 p, Vector3 s)
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		BoxCollider val = root.AddComponent<BoxCollider>();
		val.center = p;
		val.size = s;
	}

	internal static GameObject FoodModel(GameObject root, Dish dish)
	{
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: 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_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: Expected O, but got Unknown
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Expected O, but got Unknown
		//IL_038f: Unknown result type (might be due to invalid IL or missing references)
		//IL_029a: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b2: 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_0330: Unknown result type (might be due to invalid IL or missing references)
		//IL_026a: Unknown result type (might be due to invalid IL or missing references)
		//IL_027e: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_0300: Unknown result type (might be due to invalid IL or missing references)
		Renderer[] componentsInChildren = root.GetComponentsInChildren<Renderer>(true);
		foreach (Renderer val in componentsInChildren)
		{
			val.enabled = false;
		}
		LODGroup[] componentsInChildren2 = root.GetComponentsInChildren<LODGroup>(true);
		foreach (LODGroup val2 in componentsInChildren2)
		{
			Object.DestroyImmediate((Object)(object)val2);
		}
		Transform val3 = root.transform.Find("attach");
		if (!Object.op_Implicit((Object)(object)val3))
		{
			GameObject val4 = new GameObject("attach");
			val4.transform.SetParent(root.transform, false);
			val3 = val4.transform;
		}
		val3.localPosition = Vector3.zero;
		val3.localRotation = Quaternion.identity;
		val3.localScale = Vector3.one;
		GameObject val5 = new GameObject("HT_OriginalModel");
		val5.layer = root.layer;
		val5.transform.SetParent(val3, false);
		Collider[] componentsInChildren3 = root.GetComponentsInChildren<Collider>(true);
		foreach (Collider val6 in componentsInChildren3)
		{
			val6.enabled = false;
		}
		if (dish.id.StartsWith("HT_U_", StringComparison.Ordinal))
		{
			return RawOvenModel(root, val5, dish);
		}
		bool flag = dish.id.StartsWith("HT_F_");
		Builder builder = new Builder(val5, flag ? dish.id : null);
		int num = (flag ? (int.Parse(dish.id.Substring(5)) - 1) : 0);
		int tier = ((!flag) ? Mathf.Clamp(dish.level - 1, 0, 7) : ((num >= 48) ? dish.tier : (num / 6)));
		if (!flag)
		{
			int num2 = Array.FindIndex(Plugin.Data.intermediates, (Dish x) => x.id == dish.id);
			if (dish.id == "HT_M_Dough" || dish.id == "HT_M_Oat")
			{
				for (int num3 = 0; num3 < 3; num3++)
				{
					builder.Ellipsoid((dish.id == "HT_M_Oat") ? "gold" : "pale", new Vector3((float)(num3 - 1) * 0.072f, 0.07f, (float)(num3 % 2) * 0.02f), new Vector3(0.105f, 0.09f, 0.13f));
				}
			}
			else
			{
				Jar(builder, Vector3.zero, 0.62f, (num2 % 2 == 0) ? "clay" : "glaze");
				builder.Ellipsoid((num2 % 3 == 0) ? "green" : ((num2 % 3 == 1) ? "gold" : "berry"), new Vector3(0f, 0.1f, 0.11f), new Vector3(0.04f, 0.032f, 0.012f), 8, 4);
			}
			Collider(root, new Vector3(0f, 0.11f, 0f), new Vector3(0.29f, 0.22f, 0.24f));
			builder.Finish(Palette(tier));
			Visuals[dish.id] = val5;
			return val5;
		}
		if (IndividualFood(builder, num + 1))
		{
			Collider(root, new Vector3(0f, (num + 1 == 62) ? 0.12f : 0.09f, 0f), new Vector3(0.46f, (num + 1 == 62) ? 0.26f : 0.24f, 0.4f));
			builder.Finish(RefinedPalette(tier));
			Visuals[dish.id] = val5;
			return val5;
		}
		throw new InvalidOperationException("Missing authored food model: " + dish.id);
	}

	private static void Disc(Builder b, string material, Vector3 p, float radius, float height)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		b.Lathe(material, p, new float[5]
		{
			0f,
			radius * 0.9f,
			radius,
			radius * 0.9f,
			0f
		}, new float[5]
		{
			0f,
			0f,
			height * 0.5f,
			height,
			height
		}, 20);
	}

	private static void Herbs(Builder b, Vector3 p)
	{
		//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_0209: Unknown result type (might be due to invalid IL or missing references)
		//IL_020e: 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_0234: Unknown result type (might be due to invalid IL or missing references)
		//IL_0248: Unknown result type (might be due to invalid IL or missing references)
		//IL_024d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0252: Unknown result type (might be due to invalid IL or missing references)
		//IL_0266: Unknown result type (might be due to invalid IL or missing references)
		//IL_026b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: 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_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00da: 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)
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: 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_0104: Unknown result type (might be due to invalid IL or missing references)
		//IL_010c: Unknown result type (might be due to invalid IL or missing references)
		//IL_010e: 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_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_011f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0121: Unknown result type (might be due to invalid IL or missing references)
		//IL_012e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0130: Unknown result type (might be due to invalid IL or missing references)
		//IL_0132: Unknown result type (might be due to invalid IL or missing references)
		//IL_013f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0141: Unknown result type (might be due to invalid IL or missing references)
		//IL_0143: Unknown result type (might be due to invalid IL or missing references)
		//IL_0150: Unknown result type (might be due to invalid IL or missing references)
		//IL_0152: Unknown result type (might be due to invalid IL or missing references)
		//IL_0154: Unknown result type (might be due to invalid IL or missing references)
		//IL_0161: Unknown result type (might be due to invalid IL or missing references)
		//IL_0163: Unknown result type (might be due to invalid IL or missing references)
		//IL_0165: Unknown result type (might be due to invalid IL or missing references)
		//IL_0172: Unknown result type (might be due to invalid IL or missing references)
		//IL_0174: Unknown result type (might be due to invalid IL or missing references)
		//IL_017e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0183: Unknown result type (might be due to invalid IL or missing references)
		//IL_0188: Unknown result type (might be due to invalid IL or missing references)
		//IL_018a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0194: Unknown result type (might be due to invalid IL or missing references)
		//IL_0199: Unknown result type (might be due to invalid IL or missing references)
		//IL_01af: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
		if (b.IsFood)
		{
			Vector3 val = default(Vector3);
			Vector3 val2 = default(Vector3);
			for (int i = 0; i < 5; i++)
			{
				float num = (float)i * 0.95f - 0.6f;
				((Vector3)(ref val))..ctor(Mathf.Sin(num), 0f, Mathf.Cos(num));
				((Vector3)(ref val2))..ctor(val.z, 0f, 0f - val.x);
				Vector3 val3 = p - val * 0.014f;
				Vector3 val4 = p + val * (0.034f + (float)(i % 2) * 0.009f) + Vector3.up * (0.007f + (float)i * 0.002f);
				Vector3 val5 = Vector3.Lerp(val3, val4, 0.52f) + Vector3.up * 0.009f;
				Vector3 val6 = Vector3.Lerp(val3, val4, 0.5f) - val2 * 0.012f;
				Vector3 val7 = Vector3.Lerp(val3, val4, 0.5f) + val2 * 0.012f;
				b.Tri("leaf", val3, val6, val5);
				b.Tri("leaf", val6, val4, val5);
				b.Tri("green", val3, val5, val7);
				b.Tri("green", val5, val4, val7);
				b.Tri("leaf", val3, val4, val6);
				b.Tri("green", val3, val7, val4);
				b.Rod("leaf", val3 + Vector3.up * 0.001f, val5 + Vector3.up * 0.001f, 0.0012f, 5);
				b.Rod("leaf", val5 + Vector3.up * 0.001f, val4, 0.001f, 5);
			}
		}
		else
		{
			for (int j = -1; j <= 1; j++)
			{
				b.Ellipsoid("leaf", p + new Vector3((float)j * 0.018f, 0f, (float)Mathf.Abs(j) * 0.012f), new Vector3(0.026f, 0.008f, 0.057f), 6, 3);
				b.Rod("green", p + new Vector3((float)j * 0.017f, 0.005f, -0.008f), p + new Vector3((float)j * 0.017f, 0.005f, 0.035f), 0.002f, 4);
			}
		}
	}

	internal static void Export(string folder, string id, GameObject visual)
	{
		//IL_00b1: 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_0113: Unknown result type (might be due to invalid IL or missing references)
		//IL_0118: Unknown result type (might be due to invalid IL or missing references)
		//IL_0168: Unknown result type (might be due to invalid IL or missing references)
		//IL_016d: Unknown result type (might be due to invalid IL or missing references)
		Directory.CreateDirectory(folder);
		StringBuilder stringBuilder = new StringBuilder("mtllib " + id + ".mtl\n");
		StringBuilder stringBuilder2 = new StringBuilder();
		int num = 1;
		MeshFilter[] componentsInChildren = visual.GetComponentsInChildren<MeshFilter>();
		foreach (MeshFilter val in componentsInChildren)
		{
			Mesh sharedMesh = val.sharedMesh;
			Material sharedMaterial = ((Renderer)((Component)val).GetComponent<MeshRenderer>()).sharedMaterial;
			string name = ((Object)sharedMaterial).name;
			stringBuilder.Append("g " + ((Object)val).name + "\nusemtl " + name + "\n");
			Vector3[] vertices = sharedMesh.vertices;
			for (int j = 0; j < vertices.Length; j++)
			{
				Vector3 val2 = vertices[j];
				stringBuilder.AppendFormat(CultureInfo.InvariantCulture, "v {0} {1} {2}\n", val2.x, val2.y, 0f - val2.z);
			}
			Vector2[] uv = sharedMesh.uv;
			for (int k = 0; k < uv.Length; k++)
			{
				Vector2 val3 = uv[k];
				stringBuilder.AppendFormat(CultureInfo.InvariantCulture, "vt {0} {1}\n", val3.x, val3.y);
			}
			Vector3[] normals = sharedMesh.normals;
			for (int l = 0; l < normals.Length; l++)
			{
				Vector3 val4 = normals[l];
				stringBuilder.AppendFormat(CultureInfo.InvariantCulture, "vn {0} {1} {2}\n", val4.x, val4.y, 0f - val4.z);
			}
			int[] triangles = sharedMesh.triangles;
			for (int m = 0; m < triangles.Length; m += 3)
			{
				int num2 = num + triangles[m];
				int num3 = num + triangles[m + 2];
				int num4 = num + triangles[m + 1];
				stringBuilder.AppendFormat("f {0}/{0}/{0} {1}/{1}/{1} {2}/{2}/{2}\n", num2, num3, num4);
			}
			num += sharedMesh.vertexCount;
			stringBuilder2.Append("newmtl " + name + "\nKd 1 1 1\nmap_Kd " + name + ".png\n\n");
			Texture mainTexture = sharedMaterial.mainTexture;
			Texture2D val5 = (Texture2D)(object)((mainTexture is Texture2D) ? mainTexture : null);
			if (Object.op_Implicit((Object)(object)val5))
			{
				File.WriteAllBytes(Path.Combine(folder, name + ".png"), ImageConversion.EncodeToPNG(val5));
			}
		}
		File.WriteAllText(Path.Combine(folder, id + ".obj"), stringBuilder.ToString());
		File.WriteAllText(Path.Combine(folder, id + ".mtl"), stringBuilder2.ToString());
		if (id.StartsWith("HT_F_"))
		{
			File.WriteAllText(Path.Combine(folder, id + "-shapes.json"), JsonConvert.SerializeObject((object)(ShapeAudit.ContainsKey(id) ? ShapeAudit[id] : new Dictionary<string, int>()), (Formatting)1));
		}
	}

	internal static Sprite Icon(string id)
	{
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Expected O, but got Unknown
		//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
		if (Icons.TryGetValue(id, out var value))
		{
			return value;
		}
		using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("HearthTable.icons." + id + ".png");
		if (stream == null)
		{
			return null;
		}
		byte[] array = new byte[stream.Length];
		int num;
		for (int i = 0; i < array.Length; i += num)
		{
			num = stream.Read(array, i, array.Length - i);
			if (num == 0)
			{
				throw new EndOfStreamException();
			}
		}
		bool flag = id == "HT_Hearty";
		Texture2D val = new Texture2D(2, 2, (TextureFormat)4, flag);
		((Object)val).name = id + "_icon";
		if (!ImageConversion.LoadImage(val, array))
		{
			throw new Exception("Invalid icon " + id);
		}
		if (flag)
		{
			val.Apply(true, false);
			((Texture)val).filterMode = (FilterMode)2;
			((Texture)val).wrapMode = (TextureWrapMode)1;
		}
		value = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f);
		((Object)value).name = id + "_icon";
		Icons[id] = value;
		return value;
	}

	internal static Texture2D RenderTransparent(Camera camera, int size)
	{
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Expected O, but got Unknown
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Expected O, but got Unknown
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: 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_0086: 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_0167: Unknown result type (might be due to invalid IL or missing references)
		//IL_0173: Unknown result type (might be due to invalid IL or missing references)
		RenderTexture active = RenderTexture.active;
		RenderTexture val = (camera.targetTexture = new RenderTexture(size, size, 24));
		Texture2D val3 = new Texture2D(size, size, (TextureFormat)4, false);
		camera.backgroundColor = Color.black;
		camera.Render();
		RenderTexture.active = val;
		val3.ReadPixels(new Rect(0f, 0f, (float)size, (float)size), 0, 0);
		val3.Apply();
		Color[] pixels = val3.GetPixels();
		camera.backgroundColor = Color.white;
		camera.Render();
		RenderTexture.active = val;
		val3.ReadPixels(new Rect(0f, 0f, (float)size, (float)size), 0, 0);
		val3.Apply();
		Color[] pixels2 = val3.GetPixels();
		for (int i = 0; i < pixels.Length; i++)
		{
			float num = 1f - Mathf.Clamp01(Mathf.Max(new float[3]
			{
				pixels2[i].r - pixels[i].r,
				pixels2[i].g - pixels[i].g,
				pixels2[i].b - pixels[i].b
			}));
			ref Color reference = ref pixels[i];
			reference = (Color)((num < 0.01f) ? Color.clear : new Color(pixels[i].r / num, pixels[i].g / num, pixels[i].b / num, num));
		}
		val3.SetPixels(pixels);
		val3.Apply();
		camera.targetTexture = null;
		RenderTexture.active = active;
		val.Release();
		Object.DestroyImmediate((Object)(object)val);
		return val3;
	}

	private static Material ClearHoney154(string key, Dictionary<string, Material> palette)
	{
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Expected O, but got Unknown
		//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0245: Unknown result type (might be due to invalid IL or missing references)
		//IL_024c: Expected O, but got Unknown
		//IL_0379: Unknown result type (might be due to invalid IL or missing references)
		//IL_0384: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0302: Unknown result type (might be due to invalid IL or missing references)
		//IL_032b: Unknown result type (might be due to invalid IL or missing references)
		//IL_032d: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
		if (FoodSurfaces.TryGetValue(key, out var value))
		{
			return value;
		}
		Material val = (from r in ((Component)PrefabManager.Instance.GetPrefab("Bread").transform.Find("attach")).GetComponentsInChildren<MeshRenderer>(true)
			select ((Renderer)r).sharedMaterial).First((Material candidate) => ((Object)candidate.shader).name == "Standard");
		Material val2 = new Material(val);
		((Object)val2).name = "HT_Clear_" + key;
		string[] array = new string[6] { "_Mode", "_SrcBlend", "_DstBlend", "_ZWrite", "_Glossiness", "_Color" };
		foreach (string text in array)
		{
			if (!val2.HasProperty(text))
			{
				throw new Exception("Actual Standard material lacks " + text);
			}
		}
		val2.SetFloat("_Mode", 3f);
		val2.SetInt("_SrcBlend", 1);
		val2.SetInt("_DstBlend", 10);
		val2.SetInt("_ZWrite", 0);
		val2.DisableKeyword("_ALPHATEST_ON");
		val2.DisableKeyword("_ALPHABLEND_ON");
		val2.EnableKeyword("_ALPHAPREMULTIPLY_ON");
		val2.SetOverrideTag("RenderType", "Transparent");
		val2.renderQueue = ((key == "honeyGleam154") ? 3001 : 3000);
		val2.SetFloat("_Metallic", 0f);
		val2.SetFloat("_Glossiness", (key == "honeyPool154") ? 0.78f : 0.69f);
		val2.SetColor("_Color", Color.white);
		val2.SetTexture("_BumpMap", (Texture)null);
		val2.SetTexture("_MetallicGlossMap", (Texture)null);
		float num2 = key switch
		{
			"honeyEdge154" => 0.27f, 
			"honeyPool154" => 0.68f, 
			"honeyDense154" => 0.63f, 
			"honeyGleam154" => 0.72f, 
			_ => 0.39f, 
		};
		Texture2D val3 = new Texture2D(64, 64, (TextureFormat)4, false);
		((Object)val3).name = ((Object)val2).name + "_Albedo";
		Color[] array2 = (Color[])(object)new Color[4096];
		for (int num3 = 0; num3 < 64; num3++)
		{
			for (int num4 = 0; num4 < 64; num4++)
			{
				float num5 = Mathf.PerlinNoise((float)num4 * 0.055f + 8f, (float)num3 * 0.065f + 31f);
				Color val4 = ((key == "honeyGleam154") ? C("FFE9B5") : ((key == "honeyDense154") ? Color.Lerp(C("914307"), C("CB7914"), num5) : Color.Lerp(C("A05A0B"), C("E3A42A"), num5)));
				val4.a = num2 * (0.93f + num5 * 0.14f);
				array2[num3 * 64 + num4] = val4;
			}
		}
		val3.SetPixels(array2);
		val3.Apply();
		((Texture)val3).filterMode = (FilterMode)1;
		((Texture)val3).wrapMode = (TextureWrapMode)0;
		val2.mainTexture = (Texture)(object)val3;
		val2.mainTextureScale = Vector2.one;
		val2.mainTextureOffset = Vector2.zero;
		FoodSurfaces[key] = val2;
		return val2;
	}

	private static void DetailedGrain(Builder b, Vector3 p, float angle, float s)
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_00