Decompiled source of BigTiddyTrolls v2.0.0

BigTiddyTrolls.dll

Decompiled 3 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("TrollChests")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+1de1cf287554d79b0172d91a9eebd1413e43138a")]
[assembly: AssemblyProduct("TrollChests")]
[assembly: AssemblyTitle("TrollChests")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace TrollChests
{
	public class BodyMap
	{
		public struct Weights
		{
			public int B0;

			public int B1;

			public int B2;

			public int B3;

			public float W0;

			public float W1;

			public float W2;

			public float W3;
		}

		public struct Hit
		{
			public int Tri;

			public float A;

			public float B;

			public float C;

			public bool Ok;
		}

		private readonly Vector3[] pts;

		private readonly Vector3[] nrm;

		private readonly Vector2[] uv;

		private readonly Weights[] weights;

		private readonly int[] tris;

		private readonly int[] cellTri;

		private readonly Vector2[] cellBary;

		private readonly float[] cellZ;

		private readonly int nx;

		private readonly int ny;

		private readonly float x0;

		private readonly float y0;

		private readonly float cell;

		public int FallbackBone = -1;

		public bool HasUV => uv != null;

		public BodyMap(Vector3[] pts, Vector3[] normals, Vector2[] uv, Weights[] weights, int[] tris, float cellSize)
		{
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: 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_00a6: 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)
			this.pts = pts;
			nrm = ((normals != null && normals.Length == pts.Length) ? normals : null);
			this.uv = ((uv != null && uv.Length == pts.Length) ? uv : null);
			this.weights = ((weights != null && weights.Length == pts.Length) ? weights : null);
			this.tris = tris;
			float num = float.MaxValue;
			float num2 = float.MinValue;
			float num3 = float.MaxValue;
			float num4 = float.MinValue;
			foreach (Vector3 val in pts)
			{
				num = Mathf.Min(num, val.x);
				num2 = Mathf.Max(num2, val.x);
				num3 = Mathf.Min(num3, val.y);
				num4 = Mathf.Max(num4, val.y);
			}
			cell = cellSize;
			x0 = num - cell;
			y0 = num3 - cell;
			nx = Mathf.CeilToInt((num2 - num) / cell) + 3;
			ny = Mathf.CeilToInt((num4 - num3) / cell) + 3;
			cellTri = new int[nx * ny];
			cellBary = (Vector2[])(object)new Vector2[nx * ny];
			cellZ = new float[nx * ny];
			for (int j = 0; j < cellTri.Length; j++)
			{
				cellTri[j] = -1;
				cellZ[j] = float.MinValue;
			}
			for (int k = 0; k + 2 < tris.Length; k += 3)
			{
				Raster(k);
			}
		}

		private void Raster(int t)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: 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_004d: 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_005b: 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_0068: 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_0087: 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_0093: 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_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: 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_01b7: 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_01cf: 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_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: 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_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: 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)
			Vector3 val = pts[tris[t]];
			Vector3 val2 = pts[tris[t + 1]];
			Vector3 val3 = pts[tris[t + 2]];
			float num = (val2.x - val.x) * (val3.y - val.y) - (val2.y - val.y) * (val3.x - val.x);
			if (Mathf.Abs(num) < 1E-09f)
			{
				return;
			}
			int num2 = Mathf.Max(0, Mathf.CeilToInt((Mathf.Min(val.x, Mathf.Min(val2.x, val3.x)) - x0) / cell));
			int num3 = Mathf.Min(nx - 1, Mathf.FloorToInt((Mathf.Max(val.x, Mathf.Max(val2.x, val3.x)) - x0) / cell));
			int num4 = Mathf.Max(0, Mathf.CeilToInt((Mathf.Min(val.y, Mathf.Min(val2.y, val3.y)) - y0) / cell));
			int num5 = Mathf.Min(ny - 1, Mathf.FloorToInt((Mathf.Max(val.y, Mathf.Max(val2.y, val3.y)) - y0) / cell));
			for (int i = num4; i <= num5; i++)
			{
				float num6 = y0 + (float)i * cell;
				for (int j = num2; j <= num3; j++)
				{
					float num7 = x0 + (float)j * cell;
					float num8 = ((val2.x - num7) * (val3.y - num6) - (val2.y - num6) * (val3.x - num7)) / num;
					float num9 = ((val3.x - num7) * (val.y - num6) - (val3.y - num6) * (val.x - num7)) / num;
					float num10 = 1f - num8 - num9;
					if (!(num8 < -0.0001f) && !(num9 < -0.0001f) && !(num10 < -0.0001f))
					{
						float num11 = num8 * val.z + num9 * val2.z + num10 * val3.z;
						int num12 = i * nx + j;
						if (!(num11 <= cellZ[num12]))
						{
							cellZ[num12] = num11;
							cellTri[num12] = t;
							cellBary[num12] = new Vector2(num8, num9);
						}
					}
				}
			}
		}

		public Hit At(float x, float y)
		{
			//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_00d3: 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_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: 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_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: 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_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: 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_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			int num = Mathf.RoundToInt((x - x0) / cell);
			int num2 = Mathf.RoundToInt((y - y0) / cell);
			for (int i = 0; i <= 3; i++)
			{
				for (int j = -i; j <= i; j++)
				{
					for (int k = -i; k <= i; k++)
					{
						if (Mathf.Max(Mathf.Abs(k), Mathf.Abs(j)) != i)
						{
							continue;
						}
						int num3 = num + k;
						int num4 = num2 + j;
						if (num3 < 0 || num4 < 0 || num3 >= nx || num4 >= ny)
						{
							continue;
						}
						int num5 = cellTri[num4 * nx + num3];
						if (num5 >= 0)
						{
							Vector3 val = pts[tris[num5]];
							Vector3 val2 = pts[tris[num5 + 1]];
							Vector3 val3 = pts[tris[num5 + 2]];
							float num6 = (val2.x - val.x) * (val3.y - val.y) - (val2.y - val.y) * (val3.x - val.x);
							float num7 = ((val2.x - x) * (val3.y - y) - (val2.y - y) * (val3.x - x)) / num6;
							float num8 = ((val3.x - x) * (val.y - y) - (val3.y - y) * (val.x - x)) / num6;
							if (i > 0)
							{
								Vector2 val4 = cellBary[num4 * nx + num3];
								num7 = val4.x;
								num8 = val4.y;
							}
							float num9 = 1f - num7 - num8;
							num7 = Mathf.Max(0f, num7);
							num8 = Mathf.Max(0f, num8);
							num9 = Mathf.Max(0f, num9);
							float num10 = num7 + num8 + num9;
							return new Hit
							{
								Tri = num5,
								A = num7 / num10,
								B = num8 / num10,
								C = num9 / num10,
								Ok = true
							};
						}
					}
				}
			}
			return default(Hit);
		}

		public bool Covered(float x, float y)
		{
			int num = Mathf.RoundToInt((x - x0) / cell);
			int num2 = Mathf.RoundToInt((y - y0) / cell);
			if (num >= 0 && num2 >= 0 && num < nx && num2 < ny)
			{
				return cellTri[num2 * nx + num] >= 0;
			}
			return false;
		}

		public float Height(float x, float y)
		{
			Hit hit = At(x, y);
			if (!hit.Ok)
			{
				return float.NaN;
			}
			return hit.A * pts[tris[hit.Tri]].z + hit.B * pts[tris[hit.Tri + 1]].z + hit.C * pts[tris[hit.Tri + 2]].z;
		}

		public float SmoothHeight(float x, float y, float radius)
		{
			float num = 0f;
			float num2 = 0f;
			for (int i = 0; i < 9; i++)
			{
				float num3 = (float)i * (float)Math.PI * 2f / 8f;
				float num4 = ((i == 0) ? 0f : radius);
				float num5 = Height(x + Mathf.Cos(num3) * num4, y + Mathf.Sin(num3) * num4);
				if (!float.IsNaN(num5))
				{
					float num6 = ((i == 0) ? 2f : 1f);
					num += num5 * num6;
					num2 += num6;
				}
			}
			if (!(num2 > 0f))
			{
				return float.NaN;
			}
			return num / num2;
		}

		public Vector3 Point(Hit h)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			return h.A * pts[tris[h.Tri]] + h.B * pts[tris[h.Tri + 1]] + h.C * pts[tris[h.Tri + 2]];
		}

		public Vector3 Normal(Hit h)
		{
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_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_0101: Unknown result type (might be due to invalid IL or missing references)
			//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_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: 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_005c: 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_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_0068: 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_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_007e: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val4;
			if (nrm == null)
			{
				Vector3 val = pts[tris[h.Tri]];
				Vector3 val2 = pts[tris[h.Tri + 1]];
				Vector3 val3 = pts[tris[h.Tri + 2]];
				val4 = Vector3.Cross(val2 - val, val3 - val);
				Vector3 normalized = ((Vector3)(ref val4)).normalized;
				if (!(normalized.z < 0f))
				{
					return normalized;
				}
				return -normalized;
			}
			val4 = h.A * nrm[tris[h.Tri]] + h.B * nrm[tris[h.Tri + 1]] + h.C * nrm[tris[h.Tri + 2]];
			return ((Vector3)(ref val4)).normalized;
		}

		public Vector2 UV(Hit h)
		{
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: 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_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: 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)
			if (uv != null)
			{
				return h.A * uv[tris[h.Tri]] + h.B * uv[tris[h.Tri + 1]] + h.C * uv[tris[h.Tri + 2]];
			}
			return Vector2.zero;
		}

		public void AddWeights(Hit h, float scale, Dictionary<int, float> into)
		{
			if (weights == null)
			{
				Add(into, FallbackBone, scale);
				return;
			}
			Corner(weights[tris[h.Tri]], h.A * scale, into);
			Corner(weights[tris[h.Tri + 1]], h.B * scale, into);
			Corner(weights[tris[h.Tri + 2]], h.C * scale, into);
		}

		private static void Corner(Weights w, float s, Dictionary<int, float> into)
		{
			if (!(s <= 0f))
			{
				if (w.W0 > 0f)
				{
					Add(into, w.B0, w.W0 * s);
				}
				if (w.W1 > 0f)
				{
					Add(into, w.B1, w.W1 * s);
				}
				if (w.W2 > 0f)
				{
					Add(into, w.B2, w.W2 * s);
				}
				if (w.W3 > 0f)
				{
					Add(into, w.B3, w.W3 * s);
				}
			}
		}

		private static void Add(Dictionary<int, float> d, int bone, float w)
		{
			d.TryGetValue(bone, out var value);
			d[bone] = value + w;
		}

		public bool FitIslandUV(float cx, float cy, float r, out Vector3 mu, out Vector3 mv)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: 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_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: 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_0278: 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_0297: 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_03eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0403: Unknown result type (might be due to invalid IL or missing references)
			//IL_032c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0331: Unknown result type (might be due to invalid IL or missing references)
			//IL_0333: Unknown result type (might be due to invalid IL or missing references)
			//IL_0338: Unknown result type (might be due to invalid IL or missing references)
			mu = (mv = Vector3.zero);
			if (uv == null)
			{
				return false;
			}
			int num = Mathf.RoundToInt((cx - x0) / cell);
			int num2 = Mathf.RoundToInt((cy - y0) / cell);
			if (num < 0 || num2 < 0 || num >= nx || num2 >= ny || cellTri[num2 * nx + num] < 0)
			{
				return false;
			}
			Func<int, Vector2> func = delegate(int k)
			{
				//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_0020: Unknown result type (might be due to invalid IL or missing references)
				//IL_003e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0043: Unknown result type (might be due to invalid IL or missing references)
				//IL_0048: Unknown result type (might be due to invalid IL or missing references)
				//IL_0068: Unknown result type (might be due to invalid IL or missing references)
				//IL_006d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0072: Unknown result type (might be due to invalid IL or missing references)
				//IL_007c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0083: 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_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)
				int num19 = cellTri[k];
				Vector2 val3 = cellBary[k];
				return val3.x * uv[tris[num19]] + val3.y * uv[tris[num19 + 1]] + (1f - val3.x - val3.y) * uv[tris[num19 + 2]];
			};
			HashSet<int> hashSet = new HashSet<int>();
			Queue<int> queue = new Queue<int>();
			queue.Enqueue(num2 * nx + num);
			hashSet.Add(num2 * nx + num);
			double sxx = 0.0;
			double sxy = 0.0;
			double sx = 0.0;
			double syy = 0.0;
			double sy = 0.0;
			double n = 0.0;
			double num3 = 0.0;
			double num4 = 0.0;
			double num5 = 0.0;
			double num6 = 0.0;
			double num7 = 0.0;
			double num8 = 0.0;
			int num9 = Mathf.CeilToInt(r / cell);
			int[] array = new int[4] { 1, -1, 0, 0 };
			int[] array2 = new int[4] { 0, 0, 1, -1 };
			while (queue.Count > 0)
			{
				int num10 = queue.Dequeue();
				int num11 = num10 % nx;
				int num12 = num10 / nx;
				Vector2 val = func(num10);
				double num13 = x0 + (float)num11 * cell;
				double num14 = y0 + (float)num12 * cell;
				sxx += num13 * num13;
				sxy += num13 * num14;
				sx += num13;
				syy += num14 * num14;
				sy += num14;
				n++;
				num3 += num13 * (double)val.x;
				num4 += num14 * (double)val.x;
				num5 += (double)val.x;
				num6 += num13 * (double)val.y;
				num7 += num14 * (double)val.y;
				num8 += (double)val.y;
				for (int num15 = 0; num15 < 4; num15++)
				{
					int num16 = num11 + array[num15];
					int num17 = num12 + array2[num15];
					int num18 = num17 * nx + num16;
					if (num16 >= 0 && num17 >= 0 && num16 < nx && num17 < ny && !hashSet.Contains(num18) && cellTri[num18] >= 0 && (num16 - num) * (num16 - num) + (num17 - num2) * (num17 - num2) <= num9 * num9)
					{
						Vector2 val2 = func(num18) - val;
						if (!(((Vector2)(ref val2)).sqrMagnitude > 0.0009f))
						{
							hashSet.Add(num18);
							queue.Enqueue(num18);
						}
					}
				}
			}
			if (n < 6.0)
			{
				return false;
			}
			double det = Det(sxx, sxy, sx, sxy, syy, sy, sx, sy, n);
			if (Math.Abs(det) < 1E-12)
			{
				return false;
			}
			mu = Solve(num3, num4, num5);
			mv = Solve(num6, num7, num8);
			return true;
			Vector3 Solve(double b0, double b1, double b2)
			{
				//IL_009c: Unknown result type (might be due to invalid IL or missing references)
				return new Vector3((float)(Det(b0, sxy, sx, b1, syy, sy, b2, sy, n) / det), (float)(Det(sxx, b0, sx, sxy, b1, sy, sx, b2, n) / det), (float)(Det(sxx, sxy, b0, sxy, syy, b1, sx, sy, b2) / det));
			}
		}

		private static double Det(double a, double b, double c, double d, double e, double f, double g, double h, double i)
		{
			return a * (e * i - f * h) - b * (d * i - f * g) + c * (d * h - e * g);
		}
	}
	public enum Outfit
	{
		Bikini,
		HalterTop
	}
	public class ChestBuilder
	{
		public struct Settings
		{
			public float Size;

			public float Projection;

			public float Sag;

			public float Up;

			public float Forward;

			public float Spacing;

			public Outfit Outfit;
		}

		public class Result
		{
			public readonly List<Vector3> Verts = new List<Vector3>();

			public readonly List<Vector3> Normals = new List<Vector3>();

			public readonly List<Vector2> UV = new List<Vector2>();

			public readonly List<Dictionary<int, float>> Weights = new List<Dictionary<int, float>>();

			public readonly List<int> Skin = new List<int>();

			public readonly List<int> Fabric = new List<int>();

			public readonly Vector3[] PivotPos = (Vector3[])(object)new Vector3[2];

			public readonly Vector3[] TipPos = (Vector3[])(object)new Vector3[2];

			public float Width;
		}

		private struct Dome
		{
			public int Side;

			public Vector3 M;

			public float R;

			public float Depth;

			public float WallZ;

			public Vector3 N;

			public Vector3 X;

			public Vector3 Y;

			public bool UvAffine;

			public Vector3 Mu;

			public Vector3 Mv;
		}

		public const int PivotL = -1;

		public const int TipL = -2;

		public const int PivotR = -3;

		public const int TipR = -4;

		private const int Seg = 40;

		private const int RingsIn = 9;

		private const int RingsOut = 21;

		private readonly BodyMap body;

		private readonly Settings set;

		private readonly Result res = new Result();

		private static readonly Vector2[] Cup = MakeCup();

		public static int Pivot(int side)
		{
			if (side >= 0)
			{
				return -3;
			}
			return -1;
		}

		public static int Tip(int side)
		{
			if (side >= 0)
			{
				return -4;
			}
			return -2;
		}

		public static Result Build(BodyMap body, Settings s)
		{
			return new ChestBuilder(body, s).Run();
		}

		private ChestBuilder(BodyMap body, Settings s)
		{
			this.body = body;
			set = s;
		}

		private Result Run()
		{
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: 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_00e5: 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_00f0: 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_0100: 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_010a: 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_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: 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_0166: 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_0184: 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_0192: 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_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: 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_0156: 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_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			float size = set.Size;
			res.Width = size;
			Vector2 val = default(Vector2);
			for (int i = 0; i < 2; i++)
			{
				Dome d = new Dome
				{
					Side = ((i != 0) ? 1 : (-1))
				};
				d.R = 0.5f * size;
				d.Depth = d.R * set.Projection / 0.6f;
				((Vector2)(ref val))..ctor((float)d.Side * (0.92f * d.R + set.Spacing), set.Up - set.Sag * 0.3f * d.R);
				Vector3 val2 = Forward(val) + Vector3.right * ((float)d.Side * 0.2f);
				d.N = ((Vector3)(ref val2)).normalized;
				val2 = Vector3.up - d.N * Vector3.Dot(Vector3.up, d.N);
				d.Y = ((Vector3)(ref val2)).normalized;
				d.X = Vector3.Cross(d.Y, d.N);
				if (Vector3.Dot(d.X, Vector3.right * (float)d.Side) < 0f)
				{
					d.X = -d.X;
				}
				float num = (d.WallZ = SkinZ(val.x, val.y));
				d.M = new Vector3(val.x, val.y, num) + d.N * (0.3f * d.Depth + set.Forward);
				if (body.HasUV)
				{
					d.UvAffine = body.FitIslandUV(val.x, val.y, 1.2f * size, out d.Mu, out d.Mv);
				}
				BuildDome(d, i);
			}
			return res;
		}

		private Vector3 Forward(Vector2 c)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0064: 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_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: 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_008a: 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_0093: Unknown result type (might be due to invalid IL or missing references)
			float num = 0.35f * set.Size;
			float num2 = SkinZ(c.x, c.y + num) - SkinZ(c.x, c.y - num);
			Vector3 val = new Vector3(0f, -0.5f * num2 / (2f * num), 1f);
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			float num3 = Vector3.Angle(normalized, Vector3.forward);
			if (num3 > 15f)
			{
				val = Vector3.Lerp(Vector3.forward, normalized, 15f / num3);
				normalized = ((Vector3)(ref val)).normalized;
			}
			return normalized;
		}

		private float SkinZ(float x, float y)
		{
			float num = body.SmoothHeight(x, y, 0.1f * set.Size);
			if (!float.IsNaN(num))
			{
				return num;
			}
			return 0f;
		}

		private static float Smooth(float t)
		{
			t = Mathf.Clamp01(t);
			return t * t * (3f - 2f * t);
		}

		private static Vector3 Dir(float rho, float cosT, float sinT)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			float num = rho * (float)Math.PI;
			float num2 = Mathf.Sin(num);
			return new Vector3(num2 * cosT, num2 * sinT, Mathf.Cos(num));
		}

		private Vector3 Ball(Dome d, float rho, float cosT, float sinT)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: 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_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: 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: 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_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: 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_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: 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_0191: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = Dir(rho, cosT, sinT);
			if (val.y <= 0f)
			{
				return Lower(d, val);
			}
			float y = val.y;
			float num = Mathf.Sqrt(val.x * val.x + val.z * val.z);
			float num2 = ((num > 1E-05f) ? (val.x / num) : 0f);
			float num3 = ((num > 1E-05f) ? (val.z / num) : 1f);
			Vector3 val2 = Lower(d, new Vector3(num2, 0f, num3));
			float num4 = val2.z - SkinZ(val2.x, val2.y);
			Vector3 val3 = d.M + d.X * (d.R * num2 * (1f - 0.45f * y * y)) + d.Y * (1.35f * d.R * y * (1f - 0.4f * num2 * num2));
			val3.y += (val2.y - d.M.y) * (1f - y);
			float z = SkinZ(val3.x, val3.y) + num4 * Mathf.Pow(1f - y * y, 1.3f) - 0.02f * set.Size * y;
			val3.z = z;
			return Vector3.Lerp(Lower(d, val), val3, Smooth(y / 0.6f));
		}

		private Vector3 Lower(Dome d, Vector3 u)
		{
			//IL_0020: 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_002e: 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_003f: 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_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: 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_00d2: 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_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_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: 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_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			float num = 0.9599311f * set.Sag;
			float num2 = Mathf.Cos(num);
			float num3 = Mathf.Sin(num);
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(u.x, u.y * num2 - u.z * num3, u.y * num3 + u.z * num2);
			float num4 = Mathf.Max(0f, 0f - val.y);
			float num5 = d.R * val.x * (1f + 0.15f * num4);
			if (val.x > 0f)
			{
				num5 *= 1f + 0.12f * num4;
			}
			float num6 = d.R * val.y * (1f + 0.15f * set.Sag);
			float num7 = d.Depth * val.z;
			return d.M + d.X * num5 + d.Y * num6 + d.N * num7;
		}

		private Vector3 Surface(Dome d, float rho, float cosT, float sinT)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: 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_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: 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)
			Vector3 val = Ball(d, rho, cosT, sinT);
			float num = 0.004f * set.Size;
			if (val.x * (float)d.Side < num)
			{
				val.x = (float)d.Side * num;
			}
			float num2 = body.Height(val.x, val.y);
			float num3 = Smooth((0f - sinT) * Mathf.Sin(rho * (float)Math.PI) * 2f);
			if (num3 > 0f && !float.IsNaN(num2))
			{
				num2 = Mathf.Lerp(num2, SkinZ(val.x, val.y), num3);
			}
			if (!float.IsNaN(num2))
			{
				float num4 = val.z - num2;
				float num5 = -0.015f * set.Size;
				float num6 = d.R * Mathf.Lerp(0.1f, 0.25f, Smooth(sinT * Mathf.Sin(rho * (float)Math.PI) * 0.8f + 0.5f));
				num6 = Mathf.Lerp(num6, 0.01f * d.R, num3);
				val.z = num2 + 0.5f * (num4 + num5 + Mathf.Sqrt((num4 - num5) * (num4 - num5) + num6 * num6)) - 0.5f * num6 * Fade(num4 - num5, num6);
			}
			return val;
		}

		private static float Fade(float t, float k)
		{
			return Smooth((0f - t) / (1.5f * k));
		}

		private float Above(Vector3 p)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			float num = body.Height(p.x, p.y);
			if (!float.IsNaN(num))
			{
				return p.z - num;
			}
			return 10f * set.Size;
		}

		private float OutfitEdge(Dome d, float cosT, float sinT)
		{
			//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)
			if (set.Outfit == Outfit.Bikini)
			{
				return 0.32f * RayToPolygon(cosT, sinT, Cup);
			}
			Vector2 a = default(Vector2);
			((Vector2)(ref a))..ctor(-1.1f, -0.25f);
			Vector2 b = default(Vector2);
			((Vector2)(ref b))..ctor(0.45f, 1.1f);
			float num = RayToLine(cosT, sinT, a, b);
			return 0.6f * Mathf.Min(1f, num);
		}

		private static Vector2[] MakeCup()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: 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_0070: 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_0078: 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_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: 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)
			List<Vector2> list = new List<Vector2>((IEnumerable<Vector2>)(object)new Vector2[3]
			{
				new Vector2(0f, 0.5f),
				new Vector2(-0.5f, -0.25f),
				new Vector2(0.5f, -0.25f)
			});
			for (int i = 0; i < 3; i++)
			{
				List<Vector2> list2 = new List<Vector2>();
				for (int j = 0; j < list.Count; j++)
				{
					Vector2 val = list[j];
					Vector2 val2 = list[(j + 1) % list.Count];
					list2.Add(Vector2.Lerp(val, val2, 0.25f));
					list2.Add(Vector2.Lerp(val, val2, 0.75f));
				}
				list = list2;
			}
			return list.ToArray();
		}

		private static float RayToPolygon(float u, float v, Vector2[] poly)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			float num = 1f;
			for (int i = 0; i < poly.Length; i++)
			{
				float num2 = RayToLine(u, v, poly[i], poly[(i + 1) % poly.Length], segment: true);
				if (num2 < num)
				{
					num = num2;
				}
			}
			return num;
		}

		private static float RayToLine(float u, float v, Vector2 a, Vector2 b, bool segment = false)
		{
			//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_0009: 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_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: 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_0053: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = b - a;
			float num = u * val.y - v * val.x;
			if (Mathf.Abs(num) < 1E-06f)
			{
				return 10f;
			}
			float num2 = (a.x * val.y - a.y * val.x) / num;
			float num3 = (a.x * v - a.y * u) / num;
			if (num2 <= 0f || (segment && (num3 < -0.0001f || num3 > 1.0001f)))
			{
				return 10f;
			}
			return num2;
		}

		private void BuildDome(Dome d, int k)
		{
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0336: Unknown result type (might be due to invalid IL or missing references)
			//IL_033a: Unknown result type (might be due to invalid IL or missing references)
			//IL_032f: Unknown result type (might be due to invalid IL or missing references)
			//IL_033f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0347: 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_0376: Unknown result type (might be due to invalid IL or missing references)
			//IL_037d: Unknown result type (might be due to invalid IL or missing references)
			//IL_039a: Unknown result type (might be due to invalid IL or missing references)
			//IL_039d: 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)
			//IL_03bd: Unknown result type (might be due to invalid IL or missing references)
			int baseIndex = res.Verts.Count;
			int rings = 30;
			float[] array = new float[40];
			float[] array2 = new float[40];
			float[] array3 = new float[40];
			for (int i = 0; i < 40; i++)
			{
				float num = (float)Math.PI * 2f * (float)i / 40f;
				array[i] = Mathf.Cos(num);
				array2[i] = Mathf.Sin(num);
				array3[i] = Mathf.Clamp(OutfitEdge(d, array[i], array2[i]), 0.05f, 0.9f);
			}
			float[] array4 = new float[40];
			for (int j = 0; j < 40; j++)
			{
				array4[j] = 0.25f * array3[(j + 40 - 1) % 40] + 0.5f * array3[j] + 0.25f * array3[(j + 1) % 40];
			}
			array3 = array4;
			AddVertex(d, 0f, 1f, 0f);
			for (int l = 1; l < rings; l++)
			{
				for (int m = 0; m < 40; m++)
				{
					AddVertex(d, Rho(l, array3[m]), array[m], array2[m]);
				}
			}
			AddVertex(d, 1f, 1f, 0f);
			int back = res.Verts.Count - 1;
			for (int n = 0; n < rings; n++)
			{
				List<int> l2 = ((n < 9) ? res.Fabric : res.Skin);
				for (int num2 = 0; num2 < 40; num2++)
				{
					if (n == 0)
					{
						Tri(l2, Idx(0, 0), Idx(1, num2), Idx(1, num2 + 1));
					}
					else if (n == rings - 1)
					{
						Tri(l2, Idx(n, num2), Idx(rings, 0), Idx(n, num2 + 1));
					}
					else
					{
						Quad(l2, Idx(n, num2), Idx(n + 1, num2), Idx(n + 1, num2 + 1), Idx(n, num2 + 1));
					}
				}
			}
			Orient(baseIndex);
			Vector3 val = Vector3.zero;
			float num3 = 0f;
			for (int num4 = baseIndex; num4 < res.Verts.Count; num4++)
			{
				res.Weights[num4].TryGetValue(Pivot(d.Side), out var value);
				res.Weights[num4].TryGetValue(Tip(d.Side), out var value2);
				float num5 = value + value2;
				val += res.Verts[num4] * num5;
				num3 += num5;
			}
			res.TipPos[k] = ((num3 > 0f) ? (val / num3) : d.M);
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor(d.M.x, d.M.y + 1.1f * d.R, 0f);
			val2.z = SkinZ(val2.x, val2.y);
			res.PivotPos[k] = val2 - d.N * (0.15f * set.Size);
			Normals(baseIndex);
			Strings(d);
			int Idx(int num6, int num7)
			{
				if (num6 != 0)
				{
					if (num6 != rings)
					{
						return baseIndex + 1 + (num6 - 1) * 40 + num7 % 40;
					}
					return back;
				}
				return baseIndex;
			}
		}

		private float Rho(int i, float edge)
		{
			if (i <= 9)
			{
				return edge * (float)i / 9f;
			}
			return Mathf.Lerp(edge, 1f, (float)(i - 9) / 21f);
		}

		private void Orient(int from)
		{
			//IL_007b: 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_0092: 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_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)
			float num = 0f;
			List<int>[] array = new List<int>[2] { res.Skin, res.Fabric };
			foreach (List<int> list in array)
			{
				for (int j = 0; j + 2 < list.Count; j += 3)
				{
					int num2 = list[j];
					int num3 = list[j + 1];
					int num4 = list[j + 2];
					if (num2 == from || num3 == from || num4 == from)
					{
						num += Vector3.Cross(res.Verts[num3] - res.Verts[num2], res.Verts[num4] - res.Verts[num2]).z;
					}
				}
			}
			if (num >= 0f)
			{
				return;
			}
			array = new List<int>[2] { res.Skin, res.Fabric };
			foreach (List<int> list2 in array)
			{
				for (int k = 0; k + 2 < list2.Count; k += 3)
				{
					if (list2[k] >= from)
					{
						int value = list2[k + 1];
						list2[k + 1] = list2[k + 2];
						list2[k + 2] = value;
					}
				}
			}
		}

		private void AddVertex(Dome d, float rho, float cosT, float sinT)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: 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_0057: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = Surface(d, rho, cosT, sinT);
			res.Verts.Add(val);
			res.Normals.Add(Vector3.zero);
			res.UV.Add(SkinUV(d, val));
			res.Weights.Add(DomeWeights(d, val, sinT * Mathf.Sin(rho * (float)Math.PI)));
		}

		private Dictionary<int, float> DomeWeights(Dome d, Vector3 p, float up)
		{
			//IL_0001: 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_0076: 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)
			float num = Smooth(Above(p) / (0.55f * d.R));
			num *= 1f - 0.35f * Smooth(up * 1.5f);
			float num2 = Smooth((0f - up) * 1.6f + 0.1f);
			Dictionary<int, float> dictionary = new Dictionary<int, float>();
			BodyMap.Hit h = body.At(p.x, p.y);
			if (!h.Ok)
			{
				h = body.At(d.M.x, d.M.y);
			}
			if (h.Ok)
			{
				body.AddWeights(h, 1f - num, dictionary);
			}
			else
			{
				num = 1f;
			}
			Add(dictionary, Pivot(d.Side), num * (1f - num2));
			Add(dictionary, Tip(d.Side), num * num2);
			return dictionary;
		}

		private static void Add(Dictionary<int, float> d, int bone, float w)
		{
			if (!(w <= 0f))
			{
				d.TryGetValue(bone, out var value);
				d[bone] = value + w;
			}
		}

		private Vector2 SkinUV(Dome d, Vector3 p)
		{
			//IL_0019: 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_000d: 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_0033: 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_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: 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_0075: 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_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_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_0095: 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_00a3: 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_00b5: 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_00ca: 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_00dc: 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_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: 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_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: 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)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			if (!body.HasUV)
			{
				return Vector2.zero;
			}
			BodyMap.Hit h = body.At(p.x, p.y);
			Vector2 val = (h.Ok ? body.UV(h) : Vector2.zero);
			if (!d.UvAffine)
			{
				return val;
			}
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor(d.M.x, d.M.y);
			Vector2 val3 = val2 + (new Vector2(p.x, p.y) - val2) * 0.5f;
			Vector2 val4 = default(Vector2);
			((Vector2)(ref val4))..ctor(d.Mu.x * val3.x + d.Mu.y * val3.y + d.Mu.z, d.Mv.x * val3.x + d.Mv.y * val3.y + d.Mv.z);
			Vector2 val5 = default(Vector2);
			((Vector2)(ref val5))..ctor(d.Mu.x * p.x + d.Mu.y * p.y + d.Mu.z, d.Mv.x * p.x + d.Mv.y * p.y + d.Mv.z);
			if (h.Ok)
			{
				Vector2 val6 = val - val5;
				if (!(((Vector2)(ref val6)).sqrMagnitude > 0.0009f))
				{
					return Vector2.Lerp(val, val4, Smooth(Above(p) / (0.25f * d.R)));
				}
			}
			return val4;
		}

		private void Normals(int from)
		{
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: 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_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: 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_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: 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_019a: 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_01a3: 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)
			Vector3[] acc = (Vector3[])(object)new Vector3[res.Verts.Count - from];
			Face(res.Skin);
			Face(res.Fabric);
			float num = 0.5f * set.Size;
			float num2 = 0f;
			float num3 = float.MinValue;
			for (int i = from; i < res.Verts.Count; i++)
			{
				if (res.Verts[i].z > num3)
				{
					num3 = res.Verts[i].z;
					num2 = res.Verts[i].y;
				}
			}
			for (int j = from; j < res.Verts.Count; j++)
			{
				Vector3 normalized = ((Vector3)(ref acc[j - from])).normalized;
				Vector3 val = res.Verts[j];
				BodyMap.Hit h = body.At(val.x, val.y);
				if (h.Ok && val.y > num2)
				{
					float num4 = 1f - (1f - Smooth(Above(val) / (0.35f * num))) * Smooth((val.y - num2) / (0.5f * num));
					Vector3 val2 = Vector3.Lerp(body.Normal(h), normalized, num4);
					normalized = ((Vector3)(ref val2)).normalized;
				}
				res.Normals[j] = normalized;
			}
			void Face(List<int> list)
			{
				//IL_0053: Unknown result type (might be due to invalid IL or missing references)
				//IL_0064: Unknown result type (might be due to invalid IL or missing references)
				//IL_0069: Unknown result type (might be due to invalid IL or missing references)
				//IL_007a: 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_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_00b0: 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_00b7: 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_00d5: 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_00dc: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_0101: Unknown result type (might be due to invalid IL or missing references)
				//IL_0106: Unknown result type (might be due to invalid IL or missing references)
				for (int k = 0; k + 2 < list.Count; k += 3)
				{
					int num5 = list[k];
					int num6 = list[k + 1];
					int num7 = list[k + 2];
					if (num5 >= from && num6 >= from && num7 >= from)
					{
						Vector3 val3 = Vector3.Cross(res.Verts[num6] - res.Verts[num5], res.Verts[num7] - res.Verts[num5]);
						ref Vector3 reference = ref acc[num5 - from];
						reference += val3;
						ref Vector3 reference2 = ref acc[num6 - from];
						reference2 += val3;
						ref Vector3 reference3 = ref acc[num7 - from];
						reference3 += val3;
					}
				}
			}
		}

		private static void Tri(List<int> l, int a, int b, int c)
		{
			l.Add(a);
			l.Add(c);
			l.Add(b);
		}

		private static void Quad(List<int> l, int a, int b, int c, int d2)
		{
			Tri(l, a, b, c);
			Tri(l, a, c, d2);
		}

		private void Strings(Dome d)
		{
			//IL_00fc: 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_004e: 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_008c: 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_00ae: 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_00cd: 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)
			float width = ((set.Outfit == Outfit.Bikini) ? 0.022f : 0.06f) * set.Size;
			float size = set.Size;
			if (set.Outfit == Outfit.Bikini)
			{
				Ribbon(d, ParamDir(0f, 1f), new Vector2((float)d.Side * 0.3f * size, set.Up + 0.8f * size), width);
				Ribbon(d, ParamDir(-1f, 0.1f), new Vector2(0f, d.M.y + 0.1f * d.R), width);
				Ribbon(d, ParamDir(1f, 0.05f), SideOfBody(d, d.M.y + 0.1f * d.R), width);
			}
			else
			{
				Ribbon(d, ParamDir(0.42f, 0.9f), new Vector2((float)d.Side * 0.3f * size, set.Up + 0.8f * size), width);
			}
		}

		private static Vector2 ParamDir(float u, float v)
		{
			//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_000a: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = new Vector2(u, v);
			return ((Vector2)(ref val)).normalized;
		}

		private Vector2 SideOfBody(Dome d, float y)
		{
			//IL_0001: 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)
			float num = d.M.x;
			for (float num2 = 0.05f * set.Size; Mathf.Abs(num) < 6f * set.Size && body.Covered(num + (float)d.Side * num2, y); num += (float)d.Side * num2)
			{
			}
			return new Vector2(num - (float)d.Side * 0.05f * set.Size, y);
		}

		private void Ribbon(Dome d, Vector2 dir, Vector2 target, float width)
		{
			//IL_0024: 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_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_006a: 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_0072: 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_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: 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_0114: 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_0117: 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_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_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: 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_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_0296: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: 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_02c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: 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_02f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_030f: 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_0387: Unknown result type (might be due to invalid IL or missing references)
			//IL_0399: Unknown result type (might be due to invalid IL or missing references)
			//IL_039e: 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_03c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d6: Unknown result type (might be due to invalid IL or missing references)
			float num = 0.006f * set.Size;
			List<Vector3> list = new List<Vector3>();
			List<Vector3> list2 = new List<Vector3>();
			List<Dictionary<int, float>> list3 = new List<Dictionary<int, float>>();
			float x = dir.x;
			float y = dir.y;
			for (float num2 = Mathf.Max(0.05f, OutfitEdge(d, x, y) * 0.97f); num2 < 0.95f; num2 += 0.025f)
			{
				Vector3 val = Surface(d, num2, x, y);
				Vector3 val2 = SurfaceNormal(d, num2, x, y);
				list.Add(val + val2 * num);
				list2.Add(val2);
				list3.Add(DomeWeights(d, val, y * Mathf.Sin(num2 * (float)Math.PI)));
				if (Above(val) < 0.02f * set.Size)
				{
					break;
				}
			}
			if (list.Count == 0)
			{
				return;
			}
			Vector2 val3 = default(Vector2);
			((Vector2)(ref val3))..ctor(list[list.Count - 1].x, list[list.Count - 1].y);
			Vector2 val4 = target - val3;
			float magnitude = ((Vector2)(ref val4)).magnitude;
			int num3 = Mathf.Max(1, Mathf.CeilToInt(magnitude / (0.08f * set.Size)));
			for (int i = 1; i <= num3; i++)
			{
				Vector2 val5 = Vector2.Lerp(val3, target, (float)i / (float)num3);
				BodyMap.Hit h = body.At(val5.x, val5.y);
				if (!h.Ok)
				{
					break;
				}
				Vector3 val6 = body.Point(h);
				val6.x = val5.x;
				val6.y = val5.y;
				val6.z = body.Height(val5.x, val5.y);
				Vector3 val7 = body.Normal(h);
				list.Add(val6 + val7 * num);
				list2.Add(val7);
				Dictionary<int, float> dictionary = new Dictionary<int, float>();
				body.AddWeights(h, 1f, dictionary);
				list3.Add(dictionary);
			}
			if (list.Count < 2)
			{
				return;
			}
			int count = res.Verts.Count;
			for (int j = 0; j < list.Count; j++)
			{
				Vector3 val8 = list[Mathf.Min(j + 1, list.Count - 1)] - list[Mathf.Max(j - 1, 0)];
				Vector3 normalized = ((Vector3)(ref val8)).normalized;
				val8 = Vector3.Cross(list2[j], normalized);
				Vector3 val9 = ((Vector3)(ref val8)).normalized * (0.5f * width);
				Vector3[] array = (Vector3[])(object)new Vector3[2]
				{
					-val9,
					val9
				};
				foreach (Vector3 val10 in array)
				{
					res.Verts.Add(list[j] + val10);
					res.Normals.Add(list2[j]);
					res.UV.Add(Vector2.zero);
					res.Weights.Add(list3[j]);
				}
			}
			for (int l = 0; l + 1 < list.Count; l++)
			{
				int num4 = count + 2 * l;
				if (Vector3.Dot(Vector3.Cross(res.Verts[num4 + 2] - res.Verts[num4], res.Verts[num4 + 1] - res.Verts[num4]), list2[l]) >= 0f)
				{
					Tri(num4, num4 + 2, num4 + 1);
					Tri(num4 + 1, num4 + 2, num4 + 3);
				}
				else
				{
					Tri(num4, num4 + 1, num4 + 2);
					Tri(num4 + 1, num4 + 3, num4 + 2);
				}
			}
			void Tri(int a, int b, int c)
			{
				res.Fabric.Add(a);
				res.Fabric.Add(b);
				res.Fabric.Add(c);
			}
		}

		private Vector3 SurfaceNormal(Dome d, float rho, float cosT, float sinT)
		{
			//IL_001f: 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_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_0066: 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_0091: 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_0097: 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_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: 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_00b1: 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_00b7: 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_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Atan2(sinT, cosT);
			Vector3 val = Surface(d, Mathf.Max(0f, rho - 0.01f), cosT, sinT);
			Vector3 val2 = Surface(d, Mathf.Min(1f, rho + 0.01f), cosT, sinT);
			Vector3 val3 = Surface(d, Mathf.Max(rho, 0.02f), Mathf.Cos(num - 0.04f), Mathf.Sin(num - 0.04f));
			Vector3 val4 = Vector3.Cross(Surface(d, Mathf.Max(rho, 0.02f), Mathf.Cos(num + 0.04f), Mathf.Sin(num + 0.04f)) - val3, val2 - val);
			Vector3 normalized = ((Vector3)(ref val4)).normalized;
			if (!(Vector3.Dot(normalized, val - d.M) < 0f))
			{
				return normalized;
			}
			return -normalized;
		}
	}
	public class JiggleSim
	{
		public struct Params
		{
			public float Stiffness;

			public float Damping;

			public float Gravity;

			public float Exaggeration;
		}

		public struct Capsule
		{
			public Vector3 A;

			public Vector3 B;

			public float R;
		}

		private class Side
		{
			public Vector3 Pos;

			public Vector3 Vel;

			public Vector3 PrevAnchor;

			public Vector3 AnchorVel;

			public Vector3 LowPos;

			public Vector3 LowVel;

			public Vector3 MassAccel;
		}

		private readonly Side[] sides = new Side[2]
		{
			new Side(),
			new Side()
		};

		private Vector3 prevOrigin;

		private Vector3 originVel;

		private Vector3 prevOriginVel;

		private Vector3 frameAccel;

		private bool primed;

		public readonly Vector3[] Offset = (Vector3[])(object)new Vector3[2];

		public readonly Vector3[] Low = (Vector3[])(object)new Vector3[2];

		public void Reset()
		{
			primed = false;
		}

		public void Step(float dt, Matrix4x4 rigToWorld, Matrix4x4 worldToRig, Vector3 origin, Vector3[] tipRest, float W, Params p, Capsule[] caps, int capCount)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: 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_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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_00a5: 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_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_00ce: 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_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: 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_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: 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_0078: 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_007b: 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_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_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: 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_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: 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_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: 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_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: 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_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: 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_01df: 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_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: 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_02a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02da: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ee: 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_02f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0303: Unknown result type (might be due to invalid IL or missing references)
			//IL_0308: 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_0314: Unknown result type (might be due to invalid IL or missing references)
			//IL_031b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0320: 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_0552: Unknown result type (might be due to invalid IL or missing references)
			//IL_0557: Unknown result type (might be due to invalid IL or missing references)
			//IL_0559: Unknown result type (might be due to invalid IL or missing references)
			//IL_055e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0563: Unknown result type (might be due to invalid IL or missing references)
			//IL_0574: Unknown result type (might be due to invalid IL or missing references)
			//IL_0579: Unknown result type (might be due to invalid IL or missing references)
			//IL_057e: 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_036b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0370: Unknown result type (might be due to invalid IL or missing references)
			//IL_0375: Unknown result type (might be due to invalid IL or missing references)
			//IL_0377: Unknown result type (might be due to invalid IL or missing references)
			//IL_037c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0381: Unknown result type (might be due to invalid IL or missing references)
			//IL_0385: Unknown result type (might be due to invalid IL or missing references)
			//IL_038f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0394: Unknown result type (might be due to invalid IL or missing references)
			//IL_0396: Unknown result type (might be due to invalid IL or missing references)
			//IL_0398: Unknown result type (might be due to invalid IL or missing references)
			//IL_0339: Unknown result type (might be due to invalid IL or missing references)
			//IL_033e: Unknown result type (might be due to invalid IL or missing references)
			//IL_034a: Unknown result type (might be due to invalid IL or missing references)
			//IL_034f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0354: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0402: 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_0409: Unknown result type (might be due to invalid IL or missing references)
			//IL_040e: 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_041e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0423: Unknown result type (might be due to invalid IL or missing references)
			//IL_0425: Unknown result type (might be due to invalid IL or missing references)
			//IL_042c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0433: Unknown result type (might be due to invalid IL or missing references)
			//IL_0438: Unknown result type (might be due to invalid IL or missing references)
			//IL_0440: 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_046e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0477: Unknown result type (might be due to invalid IL or missing references)
			//IL_047c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0481: Unknown result type (might be due to invalid IL or missing references)
			//IL_0488: Unknown result type (might be due to invalid IL or missing references)
			//IL_048d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0492: Unknown result type (might be due to invalid IL or missing references)
			//IL_0498: Unknown result type (might be due to invalid IL or missing references)
			//IL_049d: 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_04a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ba: 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_03c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0506: 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_03e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0520: Unknown result type (might be due to invalid IL or missing references)
			//IL_0525: Unknown result type (might be due to invalid IL or missing references)
			//IL_0529: Unknown result type (might be due to invalid IL or missing references)
			//IL_052e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0533: Unknown result type (might be due to invalid IL or missing references)
			dt = Mathf.Min(dt, 0.05f);
			if (dt <= 0f)
			{
				return;
			}
			Vector3 val = ((Matrix4x4)(ref rigToWorld)).MultiplyVector(Vector3.right);
			float magnitude = ((Vector3)(ref val)).magnitude;
			int num = Mathf.Clamp(Mathf.CeilToInt(dt * 120f), 1, 6);
			int num2;
			if (primed)
			{
				val = origin - prevOrigin;
				num2 = ((((Vector3)(ref val)).sqrMagnitude > 25f * magnitude * magnitude) ? 1 : 0);
			}
			else
			{
				num2 = 1;
			}
			bool flag = (byte)num2 != 0;
			if (flag)
			{
				val = (frameAccel = Vector3.zero);
				val = (originVel = (prevOriginVel = val));
			}
			else
			{
				originVel = Vector3.Lerp(originVel, (origin - prevOrigin) / dt, 1f - Mathf.Exp((0f - dt) / 0.03f));
				Vector3 val2 = Vector3.ClampMagnitude((originVel - prevOriginVel) / dt, 100f);
				frameAccel = Vector3.Lerp(frameAccel, val2, 1f - Mathf.Exp((0f - dt) / 0.06f));
			}
			prevOrigin = origin;
			prevOriginVel = originVel;
			Vector3 val3 = default(Vector3);
			((Vector3)(ref val3))..ctor(0f, -9.81f * p.Gravity, 0f);
			Vector3 val4 = val3 - Vector3.ClampMagnitude((p.Exaggeration - 1f) * frameAccel, 20f);
			for (int i = 0; i < 2; i++)
			{
				Side side = sides[i];
				Vector3 val5 = ((Matrix4x4)(ref rigToWorld)).MultiplyPoint3x4(tipRest[i]);
				if (flag)
				{
					val = (side.Pos = (side.PrevAnchor = val5));
					val = (side.MassAccel = Vector3.zero);
					val = (side.LowVel = val);
					val = (side.LowPos = val);
					val = (side.Vel = (side.AnchorVel = val));
				}
				side.AnchorVel = Vector3.Lerp(side.AnchorVel, (val5 - side.PrevAnchor) / dt, 1f - Mathf.Exp((0f - dt) / 0.03f));
				side.PrevAnchor = val5;
				float num3 = dt / (float)num;
				float num4 = W * magnitude;
				float stiffness = p.Stiffness;
				float damping = p.Damping;
				float num5 = 1f / (0.04f * num4 * num4);
				float num6 = stiffness * 2.5f;
				float num7 = 0.12f * num4;
				float num8 = 1f - Mathf.Exp((0f - num3) / 0.03f);
				float num9 = 1.5f * num4;
				for (int j = 0; j < num; j++)
				{
					Vector3 vel = side.Vel;
					Vector3 val6 = side.Pos - val5;
					Vector3 val7 = (0f - stiffness) * (1f + ((Vector3)(ref val6)).sqrMagnitude * num5) * val6 - damping * (side.Vel - side.AnchorVel) + val4;
					side.Vel += val7 * num3;
					Vector3 val8 = side.Vel - side.AnchorVel;
					if (((Vector3)(ref val8)).sqrMagnitude > num9 * num9)
					{
						side.Vel = side.AnchorVel + val8 * (num9 / ((Vector3)(ref val8)).magnitude);
					}
					Vector3 val9 = ((Matrix4x4)(ref worldToRig)).MultiplyVector(side.Pos + side.Vel * num3 - val5);
					Vector3 val10 = Constrain(i, val9, W, tipRest, caps, capCount);
					if (val10 != val9)
					{
						val = ((Matrix4x4)(ref rigToWorld)).MultiplyVector(val10 - val9);
						Vector3 normalized = ((Vector3)(ref val)).normalized;
						float num10 = Vector3.Dot(side.Vel - side.AnchorVel, normalized);
						if (num10 < 0f)
						{
							side.Vel -= normalized * num10;
						}
					}
					side.Pos = val5 + ((Matrix4x4)(ref rigToWorld)).MultiplyVector(val10);
					side.MassAccel = Vector3.Lerp(side.MassAccel, (side.Vel - vel) / num3, num8);
					side.LowVel += ((0f - num6) * (1f + ((Vector3)(ref side.LowPos)).sqrMagnitude / (0.25f * num7 * num7)) * side.LowPos - damping * side.LowVel - side.MassAccel + val3 * 0.3f) * num3;
					side.LowPos += side.LowVel * num3;
					if (((Vector3)(ref side.LowPos)).sqrMagnitude > num7 * num7)
					{
						Vector3 normalized2 = ((Vector3)(ref side.LowPos)).normalized;
						side.LowPos = normalized2 * num7;
						float num11 = Vector3.Dot(side.LowVel, normalized2);
						if (num11 > 0f)
						{
							side.LowVel -= normalized2 * num11;
						}
					}
				}
				Offset[i] = ((Matrix4x4)(ref worldToRig)).MultiplyVector(side.Pos - val5);
				Low[i] = ((Matrix4x4)(ref worldToRig)).MultiplyVector(side.LowPos);
			}
			primed = true;
		}

		private static Vector3 Constrain(int k, Vector3 d, float W, Vector3[] tipRest, Capsule[] caps, int capCount)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: 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)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: 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_006a: 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_0081: 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_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00e7: 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_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: 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)
			d = Vector3.ClampMagnitude(d, 0.35f * W);
			if (d.z < -0.12f * W)
			{
				d.z = -0.12f * W;
			}
			float num = ((k == 0) ? 1f : (-1f));
			if (d.x * num > 0.06f * W)
			{
				d.x = num * 0.06f * W;
			}
			Vector3 val = tipRest[k] + d;
			float num2 = 0.38f * W;
			for (int i = 0; i < capCount; i++)
			{
				Capsule cap = caps[i];
				Vector3 val2 = Closest(cap, val);
				Vector3 val3 = val - val2;
				float magnitude = ((Vector3)(ref val3)).magnitude;
				float num3 = cap.R + num2;
				if (magnitude < num3 && magnitude > 1E-05f)
				{
					float num4 = Mathf.Min(num3 - magnitude, 0.3f * W);
					d += val3 / magnitude * num4;
				}
			}
			return Vector3.ClampMagnitude(d, 0.4f * W);
		}

		private static Vector3 Closest(Capsule cap, Vector3 x)
		{
			//IL_0001: 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_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0019: Unknown result type (might be due to invalid IL or missing references)
			//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_0025: 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)