Decompiled source of ValheimPlayerScaling v1.0.1

plugins/ValheimPlayerScaling.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyVersion("0.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 ValheimPlayerScaling
{
	internal class BodyShape
	{
		internal float Hips = 1f;

		internal float Butt = 1f;

		internal float Waist = 1f;

		internal float Belly = 1f;

		internal float BellyOut;

		internal float Chest = 1f;

		internal float ChestFront = 1f;

		internal float Back = 1f;

		internal float Thigh = 1f;

		internal float Knee = 1f;

		internal float Calf = 1f;

		internal float Ankle = 1f;

		internal float Foot = 1f;

		internal float Shoulder = 1f;

		internal float Biceps = 1f;

		internal float Elbow = 1f;

		internal float ForeArm = 1f;

		internal float Wrist = 1f;

		internal float Hand = 1f;

		internal float FrontLow = 1f;

		internal float FrontHips = 1f;

		private string _key;

		internal bool Neutral
		{
			get
			{
				if (BellyOut == 0f && Hips == 1f && Waist == 1f && Belly == 1f && Chest == 1f && ChestFront == 1f && Back == 1f && Butt == 1f && Thigh == 1f && Knee == 1f && Calf == 1f && Ankle == 1f && Foot == 1f && Shoulder == 1f && Biceps == 1f && Elbow == 1f && ForeArm == 1f && Wrist == 1f && Hand == 1f && FrontLow == 1f)
				{
					return FrontHips == 1f;
				}
				return false;
			}
		}

		internal string Key => _key ?? (_key = string.Join("|", Hips, Butt, Waist, Belly, BellyOut, Chest, ChestFront, Back, Thigh, Knee, Calf, Ankle, Foot, Shoulder, Biceps, Elbow, ForeArm, Wrist, Hand, FrontLow, FrontHips));

		internal static BodyShape From(float weight, float muscle)
		{
			float fat = Mathf.Max(weight, 0f);
			float thin = Mathf.Max(0f - weight, 0f);
			float mus = Mathf.Max(muscle, 0f);
			float weak = Mathf.Max(0f - muscle, 0f);
			return new BodyShape
			{
				Hips = V(1.22f, 0.9f, 1f, 0.97f),
				Butt = V(1.2f, 0.9f, 1.08f, 0.96f),
				Waist = V(1.38f, 0.82f, 0.94f, 0.95f),
				Belly = V(1.5f, 0.86f, 0.92f, 0.96f),
				BellyOut = 0.5f * fat,
				Chest = V(1.18f, 0.88f, 1.1f, 0.92f),
				ChestFront = V(1.32f, 0.9f, 1.28f, 0.93f),
				Back = V(1.14f, 0.9f, 1.2f, 0.93f),
				Thigh = V(1.3f, 0.83f, 1.25f, 0.9f),
				Knee = V(1.12f, 0.9f, 1.05f, 0.95f),
				Calf = V(1.22f, 0.84f, 1.25f, 0.9f),
				Ankle = V(1.08f, 0.9f, 1.03f, 0.96f),
				Foot = V(1.05f, 0.96f, 1f, 1f),
				Shoulder = V(1.12f, 0.9f, 1.32f, 0.9f),
				Biceps = V(1.28f, 0.8f, 1.5f, 0.85f),
				Elbow = V(1.12f, 0.88f, 1.1f, 0.94f),
				ForeArm = V(1.24f, 0.82f, 1.38f, 0.86f),
				Wrist = V(1.1f, 0.88f, 1.06f, 0.94f),
				Hand = V(1.06f, 0.95f, 1.06f, 0.98f),
				FrontLow = V(1.1f, 0.95f, 1f, 1f),
				FrontHips = V(1.16f, 0.95f, 1.02f, 1f)
			};
			float V(float f, float t, float m, float w)
			{
				return 1f + (f - 1f) * fat + (t - 1f) * thin + (m - 1f) * mus + (w - 1f) * weak;
			}
		}
	}
	[DefaultExecutionOrder(-30000)]
	internal class BodyShaper : MonoBehaviour
	{
		private enum Part
		{
			Other,
			Hips,
			Spine,
			Spine1,
			Spine2,
			Neck,
			Head,
			UpperArm,
			ForeArm,
			Hand,
			Thigh,
			Shin,
			Foot
		}

		private class Rig
		{
			internal Mesh Source;

			internal Matrix4x4[] Bind;

			internal Matrix4x4[] BindNew;

			internal Matrix4x4[] BindInv;

			internal Vector3[] J;

			internal Vector3[] D;

			internal Part[] Parts;

			internal int[] Seg;

			internal int[] ChildOf;

			internal Vector3 Up;

			internal Vector3 Lat;

			internal Vector3 Fwd;

			internal Vector3 Center;

			internal float[] KeyH;

			internal float Round;

			internal float Floor;

			internal float[] HalfW;

			internal float[] HalfF;

			internal float[] HalfB;

			internal float BinLo;

			internal float BinHi;

			internal int ArmL = -1;

			internal int ArmR = -1;

			internal float ArmRadius;

			internal float Drop;

			internal int Hips;

			internal int Moved;
		}

		private class Offset
		{
			internal Transform T;

			internal Vector3 Delta;

			internal Vector3 Base;

			internal Vector3 Last = new Vector3(float.NaN, 0f, 0f);
		}

		private const int CacheLimit = 96;

		private static readonly FieldInfo BodyModel = AccessTools.Field(typeof(VisEquipment), "m_bodyModel");

		private static readonly FieldInfo Models = AccessTools.Field(typeof(VisEquipment), "m_models");

		private static readonly Dictionary<string, Mesh> Cache = new Dictionary<string, Mesh>();

		private static readonly HashSet<Mesh> Made = new HashSet<Mesh>();

		private static readonly HashSet<BodyShaper> All = new HashSet<BodyShaper>();

		internal BodyShape Shape;

		private VisEquipment _vis;

		private SkinnedMeshRenderer _body;

		private Rig _rig;

		private readonly List<Offset> _offsets = new List<Offset>();

		private Offset _hips;

		private readonly Dictionary<SkinnedMeshRenderer, Mesh> _orig = new Dictionary<SkinnedMeshRenderer, Mesh>();

		private readonly List<KeyValuePair<object, Mesh>> _models = new List<KeyValuePair<object, Mesh>>();

		private bool _dirty = true;

		private float _timer;

		private static readonly HashSet<BodyShaper> Active = new HashSet<BodyShaper>();

		private static readonly FieldInfo PreSimulation = AccessTools.Field(AccessTools.TypeByName("MagicaCloth2.MagicaManager"), "OnPreSimulation");

		private static readonly Action PushAll = delegate
		{
			foreach (BodyShaper item in Active)
			{
				if ((Object)(object)item != (Object)null)
				{
					item.LateUpdate();
				}
			}
		};

		private static readonly Type MagicaType = AccessTools.TypeByName("MagicaCloth2.MagicaCloth");

		private static readonly FieldInfo ClothColliders = AccessTools.Field(typeof(VisEquipment), "m_clothColliders");

		private static readonly Type ColliderType = AccessTools.TypeByName("MagicaCloth2.ColliderComponent");

		private static readonly FieldInfo ColliderSize = ((ColliderType != null) ? AccessTools.Field(ColliderType, "size") : null);

		private static readonly MethodInfo ColliderUpdate = ((ColliderType != null) ? AccessTools.Method(ColliderType, "UpdateParameters", (Type[])null, (Type[])null) : null);

		private readonly Dictionary<Component, Vector3> _colliderSize = new Dictionary<Component, Vector3>();

		private static readonly FieldInfo ShoulderHash = AccessTools.Field(typeof(VisEquipment), "m_currentShoulderItemHash");

		private const string ProxySuffix = "_VPS_Cape";

		private static readonly FieldInfo BoneMap = AccessTools.Field(typeof(VisEquipment), "m_boneMap");

		private readonly List<Transform> _proxies = new List<Transform>();

		private readonly Dictionary<string, Transform> _mapSwapped = new Dictionary<string, Transform>();

		private static readonly HashSet<string> Noted = new HashSet<string>();

		internal void MarkDirty()
		{
			_dirty = true;
		}

		internal void ApplyNow()
		{
			if (EnsureRig() && _rig != null)
			{
				ApplyMeshes();
				ResizeColliders();
				_dirty = false;
				LateUpdate();
			}
		}

		private void Awake()
		{
			_vis = ((Component)this).GetComponent<VisEquipment>();
			All.Add(this);
		}

		private void OnEnable()
		{
			Active.Add(this);
			if (!(PreSimulation == null))
			{
				Action action = PreSimulation.GetValue(null) as Action;
				if (action == null || Array.IndexOf(action.GetInvocationList(), PushAll) < 0)
				{
					PreSimulation.SetValue(null, (Action)Delegate.Combine(action, PushAll));
				}
			}
		}

		private void OnDisable()
		{
			Active.Remove(this);
		}

		private void Update()
		{
			if (!EnsureRig())
			{
				return;
			}
			_timer -= Time.deltaTime;
			if (_dirty || !(_timer > 0f))
			{
				_dirty = false;
				_timer = 0.5f;
				if (_rig != null)
				{
					ApplyMeshes();
				}
			}
		}

		private bool EnsureRig()
		{
			if (Shape == null || (Object)(object)_vis == (Object)null)
			{
				return false;
			}
			ref SkinnedMeshRenderer body = ref _body;
			object? value = BodyModel.GetValue(_vis);
			body = (SkinnedMeshRenderer)((value is SkinnedMeshRenderer) ? value : null);
			if ((Object)(object)_body == (Object)null)
			{
				return false;
			}
			Mesh sharedMesh = _body.sharedMesh;
			if ((Object)(object)sharedMesh != (Object)null && !Made.Contains(sharedMesh))
			{
				if (_rig == null || (Object)(object)_rig.Source != (Object)(object)sharedMesh)
				{
					foreach (KeyValuePair<SkinnedMeshRenderer, Mesh> item in _orig)
					{
						if ((Object)(object)item.Key != (Object)null && (Object)(object)item.Key != (Object)(object)_body && Made.Contains(item.Key.sharedMesh))
						{
							SetMesh(item.Key, item.Value);
						}
					}
					_orig.Clear();
					RestoreModels();
					RestoreBones();
					_rig = BuildRig(_body, sharedMesh);
					BuildOffsets();
					if (_rig != null && !Shape.Neutral)
					{
						ReattachCape();
					}
				}
				_dirty = true;
			}
			return true;
		}

		private void ReattachCape()
		{
			if (!(ShoulderHash == null) && !((Object)(object)_vis == (Object)null))
			{
				object value = ShoulderHash.GetValue(_vis);
				if (value is int && (int)value != 0)
				{
					ShoulderHash.SetValue(_vis, 0);
				}
			}
		}

		internal void PrepareCloth(GameObject item)
		{
			if (!EnsureRig() || _rig == null)
			{
				return;
			}
			if ((Object)(object)item != (Object)null && !Shape.Neutral && MagicaType != null && (Object)(object)item.GetComponentInChildren(MagicaType, true) != (Object)null)
			{
				SkinnedMeshRenderer[] componentsInChildren = item.GetComponentsInChildren<SkinnedMeshRenderer>(true);
				foreach (SkinnedMeshRenderer r in componentsInChildren)
				{
					ProxyCape(r);
				}
			}
			ResizeColliders();
			LateUpdate();
		}

		private void ResizeColliders()
		{
			//IL_00c8: 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_00d7: 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_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			if (ClothColliders == null || ColliderSize == null || (Object)(object)_vis == (Object)null || !(ClothColliders.GetValue(_vis) is IList list))
			{
				return;
			}
			Transform[] bones = _body.bones;
			Dictionary<Transform, int> dictionary = new Dictionary<Transform, int>();
			for (int i = 0; i < bones.Length; i++)
			{
				if ((Object)(object)bones[i] != (Object)null && !dictionary.ContainsKey(bones[i]))
				{
					dictionary[bones[i]] = i;
				}
			}
			foreach (object item in list)
			{
				Component val = (Component)((item is Component) ? item : null);
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				if (!_colliderSize.TryGetValue(val, out var value))
				{
					value = (Vector3)ColliderSize.GetValue(val);
					_colliderSize[val] = value;
				}
				int num = -1;
				Transform val2 = val.transform;
				while ((Object)(object)val2 != (Object)null && (Object)(object)val2 != (Object)(object)((Component)this).transform)
				{
					if (dictionary.TryGetValue(val2, out var value2))
					{
						num = value2;
						break;
					}
					val2 = val2.parent;
				}
				float num2 = ((num >= 0) ? ColliderFactor(num) : 1f);
				SetCollider(val, new Vector3(value.x * num2, value.y * num2, value.z));
			}
		}

		private void RestoreColliders()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			foreach (KeyValuePair<Component, Vector3> item in _colliderSize)
			{
				if ((Object)(object)item.Key != (Object)null)
				{
					SetCollider(item.Key, item.Value);
				}
			}
			_colliderSize.Clear();
		}

		private static void SetCollider(Component c, Vector3 size)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			if ((Vector3)ColliderSize.GetValue(c) == size)
			{
				return;
			}
			ColliderSize.SetValue(c, size);
			try
			{
				ColliderUpdate?.Invoke(c, null);
			}
			catch
			{
			}
		}

		private float ColliderFactor(int b)
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_0089: 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_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: 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_00c1: 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_00ce: 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_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: 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_00f0: 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_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			Rig rig = _rig;
			BodyShape shape = Shape;
			float num;
			switch (rig.Parts[b])
			{
			case Part.Hips:
			case Part.Spine:
			case Part.Spine1:
			case Part.Spine2:
			{
				float num2 = Vector3.Dot(rig.J[b] - rig.Center, rig.Up);
				HalfSize(num2, out var hw, out var _, out var hb);
				Vector3 val = rig.Center + rig.Up * num2 + rig.Lat * hw;
				Vector3 val2 = rig.Center + rig.Up * num2 - rig.Fwd * hb;
				float num3 = Vector3.Dot(Torso(val, rig.Lat) - val, rig.Lat) / Mathf.Max(hw, 0.0001f);
				float num4 = Vector3.Dot(Torso(val2, -rig.Fwd) - val2, -rig.Fwd) / Mathf.Max(hb, 0.0001f);
				num = 1f + Mathf.Max(num3, num4);
				break;
			}
			case Part.UpperArm:
				num = Mathf.Max(shape.Shoulder, shape.Biceps);
				break;
			case Part.ForeArm:
				num = shape.ForeArm;
				break;
			case Part.Thigh:
				num = Mathf.Max(shape.Thigh, shape.Hips);
				break;
			case Part.Shin:
				num = shape.Calf;
				break;
			default:
				num = 1f;
				break;
			}
			if (!(num > 1f))
			{
				return Mathf.Max(num, 0.85f);
			}
			return num * 1.05f;
		}

		private void ProxyCape(SkinnedMeshRenderer r)
		{
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: 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_00cd: Unknown result type (might be due to invalid IL or missing references)
			Transform[] bones = r.bones;
			if (bones == null)
			{
				return;
			}
			Transform[] bones2 = _body.bones;
			Dictionary<string, int> dictionary = new Dictionary<string, int>();
			for (int i = 0; i < bones2.Length; i++)
			{
				if ((Object)(object)bones2[i] != (Object)null && !dictionary.ContainsKey(((Object)bones2[i]).name))
				{
					dictionary[((Object)bones2[i]).name] = i;
				}
			}
			bool flag = false;
			for (int j = 0; j < bones.Length; j++)
			{
				if (!((Object)(object)bones[j] == (Object)null) && dictionary.TryGetValue(((Object)bones[j]).name, out var value))
				{
					CapeProxy(value, out var scale, out var pivot, out var offset);
					Vector3 val = scale - Vector3.one;
					if (!(((Vector3)(ref val)).sqrMagnitude < 1E-10f) || !(((Vector3)(ref offset)).sqrMagnitude < 1E-12f))
					{
						Transform bone = bones2[value];
						Transform proxy = (bones[j] = MakeProxy(bone, value, scale, pivot, offset));
						flag = true;
						SwapBoneMap(bone, proxy);
					}
				}
			}
			if (flag)
			{
				r.bones = bones;
			}
		}

		private void CapeProxy(int b, out Vector3 scale, out Vector3 pivot, out Vector3 offset)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: 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_00af: 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_00c1: 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_00cd: 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_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: 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_00ec: 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_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_014a: 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_0254: 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_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: 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_027d: 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_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: 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_01cc: 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_02ce: 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_02d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_0340: Unknown result type (might be due to invalid IL or missing references)
			//IL_0346: Unknown result type (might be due to invalid IL or missing references)
			//IL_034b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0351: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f9: 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_0405: Unknown result type (might be due to invalid IL or missing references)
			//IL_040b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0412: 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_041d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0424: Unknown result type (might be due to invalid IL or missing references)
			//IL_0429: Unknown result type (might be due to invalid IL or missing references)
			//IL_042e: Unknown result type (might be due to invalid IL or missing references)
			scale = Vector3.one;
			pivot = Vector3.zero;
			offset = Vector3.zero;
			Rig rig = _rig;
			BodyShape shape = Shape;
			float num = 0.05f * rig.Round;
			Part part = rig.Parts[b];
			string text = (((Object)(object)_body.bones[b] != (Object)null) ? ((Object)_body.bones[b]).name : "");
			float num2 = Vector3.Dot(rig.J[b] - rig.Center, rig.Up);
			HalfSize(num2, out var hw, out var hf, out var hb);
			Vector3 val = rig.Center + rig.Up * num2 - rig.Fwd * hb;
			float num3 = Mathf.Max(0f, Vector3.Dot(Torso(val, -rig.Fwd) - val, -rig.Fwd));
			float num4 = Mathf.Max(0f, shape.Shoulder - 1f) * rig.ArmRadius;
			float num5 = ((rig.ArmL >= 0) ? Mathf.Max(0f, Vector3.Dot(rig.D[rig.ArmL], rig.Lat)) : 0f) + num4 * 2.2f;
			bool num6 = part == Part.UpperArm || part == Part.ForeArm;
			bool flag = text.EndsWith("Shoulder");
			bool flag2 = part == Part.Hips || part == Part.Spine || part == Part.Spine1 || part == Part.Spine2 || part == Part.Neck;
			if (num6)
			{
				if (!(num4 <= 0f) || !(num3 <= 0f))
				{
					float num7 = ((Vector3.Dot(rig.J[b] - rig.Center, rig.Lat) >= 0f) ? 1f : (-1f));
					offset = rig.Lat * (num7 * (num4 * 2.2f + num * 2f)) + rig.Up * (num4 * 1.2f) - rig.Fwd * (Mathf.Max(num3, num4 * 0.8f) + num);
				}
			}
			else if (flag2 || flag)
			{
				Vector3 val2 = rig.Center + rig.Up * num2 + rig.Lat * hw;
				float num8 = Mathf.Max(0f, Vector3.Dot(Torso(val2, rig.Lat) - val2, rig.Lat));
				float num9 = ((rig.ArmL >= 0) ? Vector3.Dot(rig.J[rig.ArmL] - rig.Center, rig.Up) : rig.KeyH[6]);
				float num10 = (flag ? 1f : Mathf.SmoothStep(0f, 1f, 1f - Mathf.Abs(num2 - num9) / Mathf.Max(num9 - rig.KeyH[3], 0.0001f)));
				float num11 = ((rig.ArmL >= 0) ? (Mathf.Abs(Vector3.Dot(rig.J[rig.ArmL] - rig.Center, rig.Lat)) + rig.ArmRadius) : hw);
				float num12 = Mathf.Lerp(hw, num11, num10);
				float num13 = Mathf.Lerp(num8, Mathf.Max(num8, num5), num10);
				float num14 = ((part == Part.Neck || num13 <= 0f) ? 1f : (1f + (num13 * 1.2f + num * 2f) / Mathf.Max(num12, 0.0001f)));
				float num15 = 1f + (num3 + num) / Mathf.Max(hf + hb, 0.0001f);
				if (!(num3 <= 0f) || !(num14 <= 1f))
				{
					scale = new Vector3(num14, 1f, num15);
					pivot = rig.Center + rig.Up * num2 + rig.Fwd * hf;
				}
			}
		}

		private Transform MakeProxy(Transform bone, int bi, Vector3 scale, Vector3 pivot, Vector3 offset)
		{
			//IL_0037: 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_0089: 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)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: 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_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_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: 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_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_010a: 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_011e: 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_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: 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)
			string text = ((Object)bone).name + "_VPS_Cape";
			Transform val = bone.Find(text + "_root");
			if ((Object)(object)val == (Object)null)
			{
				val = new GameObject(text + "_root").transform;
				val.SetParent(bone, false);
			}
			Transform val2 = val.Find(text);
			if ((Object)(object)val2 == (Object)null)
			{
				val2 = new GameObject(text).transform;
				val2.SetParent(val, false);
			}
			Matrix4x4 val3 = _rig.Bind[bi];
			Vector3 val4 = ((Matrix4x4)(ref val3)).MultiplyVector(_rig.Up);
			Vector3 val5 = ((Matrix4x4)(ref val3)).MultiplyVector(_rig.Fwd);
			Quaternion val6 = ((((Vector3)(ref val4)).sqrMagnitude > 1E-12f && ((Vector3)(ref val5)).sqrMagnitude > 1E-12f) ? Quaternion.LookRotation(val5, val4) : Quaternion.identity);
			Vector3 val7 = ((Matrix4x4)(ref val3)).MultiplyPoint3x4(pivot);
			val.localPosition = val7 + ((Matrix4x4)(ref val3)).MultiplyVector(offset);
			val.localRotation = val6;
			val.localScale = scale;
			val2.localRotation = Quaternion.Inverse(val6);
			val2.localPosition = -(Quaternion.Inverse(val6) * val7);
			val2.localScale = Vector3.one;
			if (!_proxies.Contains(val))
			{
				_proxies.Add(val);
			}
			return val2;
		}

		private void SwapBoneMap(Transform bone, Transform proxy)
		{
			if (BoneMap?.GetValue(_vis) is IDictionary<string, Transform> dictionary && dictionary.ContainsKey(((Object)bone).name))
			{
				if (!_mapSwapped.ContainsKey(((Object)bone).name))
				{
					_mapSwapped[((Object)bone).name] = dictionary[((Object)bone).name];
				}
				dictionary[((Object)bone).name] = proxy;
			}
		}

		internal void RestoreBoneMap()
		{
			if (BoneMap?.GetValue(_vis) is IDictionary<string, Transform> dictionary)
			{
				foreach (KeyValuePair<string, Transform> item in _mapSwapped)
				{
					dictionary[item.Key] = item.Value;
				}
			}
			_mapSwapped.Clear();
		}

		private void ResetProxies()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: 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)
			foreach (Transform proxy in _proxies)
			{
				if ((Object)(object)proxy == (Object)null)
				{
					continue;
				}
				proxy.localPosition = Vector3.zero;
				proxy.localRotation = Quaternion.identity;
				proxy.localScale = Vector3.one;
				foreach (Transform item in proxy)
				{
					item.localRotation = Quaternion.identity;
					item.localPosition = Vector3.zero;
				}
			}
			_proxies.Clear();
		}

		private bool UnderCloth(Component r)
		{
			if (MagicaType == null || (Object)(object)r == (Object)null || (Object)(object)_body == (Object)null)
			{
				return false;
			}
			Transform parent = ((Component)_body).transform.parent;
			Transform val = r.transform;
			while ((Object)(object)val.parent != (Object)null && (Object)(object)val.parent != (Object)(object)parent && (Object)(object)val.parent != (Object)(object)((Component)this).transform)
			{
				val = val.parent;
			}
			return (Object)(object)((Component)val).GetComponentInChildren(MagicaType, true) != (Object)null;
		}

		private void LateUpdate()
		{
			//IL_002d: 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_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_00b6: Unknown result type (might be due to invalid IL or missing references)
			if (_rig == null || (Object)(object)_body == (Object)null)
			{
				return;
			}
			foreach (Offset offset in _offsets)
			{
				Push(offset, offset.Delta);
			}
			if (_hips != null && (Object)(object)_hips.T.parent != (Object)null)
			{
				Push(_hips, _hips.T.parent.InverseTransformVector(((Component)_body).transform.TransformVector(-_rig.Up * _rig.Drop)));
			}
		}

		private static void Push(Offset o, Vector3 delta)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: 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_002f: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: 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)
			if ((Object)(object)o.T == (Object)null)
			{
				return;
			}
			Vector3 localPosition = o.T.localPosition;
			if (float.IsNaN(o.Last.x))
			{
				o.Base = localPosition;
			}
			else
			{
				if (localPosition.x != o.Last.x)
				{
					o.Base.x = localPosition.x;
				}
				if (localPosition.y != o.Last.y)
				{
					o.Base.y = localPosition.y;
				}
				if (localPosition.z != o.Last.z)
				{
					o.Base.z = localPosition.z;
				}
			}
			o.T.localPosition = o.Base + delta;
			o.Last = o.T.localPosition;
		}

		private void OnDestroy()
		{
			RestoreColliders();
			RestoreBoneMap();
			ResetProxies();
			All.Remove(this);
			Active.Remove(this);
			RestoreBones();
			if (_rig != null && Shape != null && !Shape.Neutral)
			{
				ReattachCape();
			}
			RestoreModels();
			foreach (KeyValuePair<SkinnedMeshRenderer, Mesh> item in _orig)
			{
				if ((Object)(object)item.Key != (Object)null && Made.Contains(item.Key.sharedMesh))
				{
					SetMesh(item.Key, item.Value, cloth: false);
				}
			}
			_orig.Clear();
		}

		private void RestoreModels()
		{
			foreach (KeyValuePair<object, Mesh> model in _models)
			{
				model.Key.GetType().GetField("m_mesh").SetValue(model.Key, model.Value);
			}
			_models.Clear();
		}

		private void RestoreBones()
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: 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_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_00f7: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val;
			foreach (Offset offset in _offsets)
			{
				if ((Object)(object)offset.T != (Object)null && !float.IsNaN(offset.Last.x))
				{
					val = offset.T.localPosition - offset.Last;
					if (((Vector3)(ref val)).sqrMagnitude < 1E-12f)
					{
						offset.T.localPosition = offset.Base;
					}
				}
			}
			if (_hips != null && (Object)(object)_hips.T != (Object)null && !float.IsNaN(_hips.Last.x))
			{
				val = _hips.T.localPosition - _hips.Last;
				if (((Vector3)(ref val)).sqrMagnitude < 1E-12f)
				{
					_hips.T.localPosition = _hips.Base;
				}
			}
			_offsets.Clear();
			_hips = null;
		}

		private void BuildOffsets()
		{
			//IL_00a1: 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_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: 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)
			if (_rig == null)
			{
				return;
			}
			Transform[] bones = _body.bones;
			Dictionary<Transform, int> dictionary = new Dictionary<Transform, int>();
			for (int i = 0; i < bones.Length; i++)
			{
				if ((Object)(object)bones[i] != (Object)null && !dictionary.ContainsKey(bones[i]))
				{
					dictionary[bones[i]] = i;
				}
			}
			for (int j = 0; j < bones.Length; j++)
			{
				if (!((Object)(object)bones[j] == (Object)null) && !((Object)(object)bones[j].parent == (Object)null) && dictionary.TryGetValue(bones[j].parent, out var value))
				{
					Vector3 delta = ((Matrix4x4)(ref _rig.Bind[value])).MultiplyVector(_rig.D[j] - _rig.D[value]);
					if (((Vector3)(ref delta)).sqrMagnitude > 1E-12f)
					{
						_offsets.Add(new Offset
						{
							T = bones[j],
							Delta = delta
						});
					}
				}
			}
			if (_rig.Hips >= 0 && (Object)(object)bones[_rig.Hips] != (Object)null && Mathf.Abs(_rig.Drop) > 1E-05f)
			{
				Transform parent = bones[_rig.Hips].parent;
				_hips = new Offset
				{
					T = (((Object)(object)parent != (Object)null && (Object)(object)parent != (Object)(object)((Component)this).transform) ? parent : bones[_rig.Hips])
				};
			}
		}

		private void ApplyMeshes()
		{
			bool flag = false;
			SkinnedMeshRenderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<SkinnedMeshRenderer>(true);
			foreach (SkinnedMeshRenderer val in componentsInChildren)
			{
				Mesh sharedMesh = val.sharedMesh;
				if ((Object)(object)sharedMesh == (Object)null || Made.Contains(sharedMesh))
				{
					continue;
				}
				Component component = ((Component)val).GetComponent("Cloth");
				if (((Object)(object)val != (Object)(object)_body && Shape.Neutral) || ((Object)(object)val != (Object)(object)_body && UnderCloth((Component)(object)val)) || !MapBones(val.bones, out var map, out var extra))
				{
					continue;
				}
				bool flag2 = false;
				bool[] array = extra;
				foreach (bool flag3 in array)
				{
					flag2 = flag2 || flag3;
				}
				bool flag4 = (Object)(object)component != (Object)null || flag2;
				string key = ((Object)sharedMesh).GetInstanceID() + "|" + ((Object)_rig.Source).GetInstanceID() + "|" + Shape.Key + (flag4 ? "|capa" : "");
				if (!Cache.TryGetValue(key, out var value))
				{
					value = Deform(sharedMesh, flag4, map, extra);
					Cache[key] = value;
					if ((Object)(object)value != (Object)null)
					{
						Made.Add(value);
						flag = true;
					}
				}
				if (!((Object)(object)value == (Object)null))
				{
					if (!_orig.ContainsKey(val))
					{
						_orig[val] = sharedMesh;
					}
					SetMesh(val, value);
					if ((Object)(object)val == (Object)(object)_body)
					{
						SwapModel(sharedMesh, value);
					}
				}
			}
			if (flag && Cache.Count > 96)
			{
				TrimCache();
			}
		}

		private static void TrimCache()
		{
			HashSet<Mesh> hashSet = new HashSet<Mesh>();
			foreach (BodyShaper item in All)
			{
				if ((Object)(object)item == (Object)null)
				{
					continue;
				}
				SkinnedMeshRenderer[] componentsInChildren = ((Component)item).GetComponentsInChildren<SkinnedMeshRenderer>(true);
				foreach (SkinnedMeshRenderer val in componentsInChildren)
				{
					if ((Object)(object)val != (Object)null && (Object)(object)val.sharedMesh != (Object)null)
					{
						hashSet.Add(val.sharedMesh);
					}
				}
				foreach (KeyValuePair<object, Mesh> model in item._models)
				{
					object? value = model.Key.GetType().GetField("m_mesh").GetValue(model.Key);
					Mesh val2 = (Mesh)((value is Mesh) ? value : null);
					if (val2 != null)
					{
						hashSet.Add(val2);
					}
				}
			}
			List<string> list = new List<string>();
			foreach (KeyValuePair<string, Mesh> item2 in Cache)
			{
				if ((Object)(object)item2.Value == (Object)null || !hashSet.Contains(item2.Value))
				{
					list.Add(item2.Key);
				}
			}
			foreach (string item3 in list)
			{
				Mesh val3 = Cache[item3];
				Cache.Remove(item3);
				if (!((Object)(object)val3 == (Object)null))
				{
					Made.Remove(val3);
					Object.Destroy((Object)(object)val3);
				}
			}
		}

		private void SwapModel(Mesh orig, Mesh made)
		{
			if (!(Models?.GetValue(_vis) is Array array))
			{
				return;
			}
			foreach (object item in array)
			{
				FieldInfo fieldInfo = item?.GetType().GetField("m_mesh");
				if (!(fieldInfo == null))
				{
					object? value = fieldInfo.GetValue(item);
					Mesh val = (Mesh)((value is Mesh) ? value : null);
					if (!((Object)(object)val == (Object)null) && !((Object)(object)val != (Object)(object)orig))
					{
						fieldInfo.SetValue(item, made);
						_models.Add(new KeyValuePair<object, Mesh>(item, orig));
					}
				}
			}
		}

		private static void Note(Mesh m, string why)
		{
			if (Noted.Add(((Object)m).name + why))
			{
				Plugin.Log.LogWarning((object)("[Corpo] '" + ((Object)m).name + "' ficou como era: " + why));
			}
		}

		private bool MapBones(Transform[] rb, out int[] map, out bool[] extra)
		{
			map = null;
			extra = null;
			if (rb == null || rb.Length == 0)
			{
				return false;
			}
			Transform[] bones = _body.bones;
			Dictionary<Transform, int> dictionary = new Dictionary<Transform, int>();
			for (int i = 0; i < bones.Length; i++)
			{
				if ((Object)(object)bones[i] != (Object)null && !dictionary.ContainsKey(bones[i]))
				{
					dictionary[bones[i]] = i;
				}
			}
			map = new int[rb.Length];
			extra = new bool[rb.Length];
			int num = 0;
			for (int j = 0; j < rb.Length; j++)
			{
				if ((Object)(object)rb[j] != (Object)null && dictionary.TryGetValue(rb[j], out var value))
				{
					map[j] = value;
					continue;
				}
				extra[j] = true;
				num++;
				map[j] = -1;
				Transform val = (((Object)(object)rb[j] != (Object)null) ? rb[j].parent : null);
				while ((Object)(object)val != (Object)null)
				{
					if (dictionary.TryGetValue(val, out value))
					{
						map[j] = value;
						break;
					}
					val = val.parent;
				}
				if (map[j] < 0)
				{
					return false;
				}
			}
			return num * 4 <= rb.Length;
		}

		private static void SetMesh(SkinnedMeshRenderer r, Mesh mesh, bool cloth = true)
		{
			Component val = (cloth ? ((Component)r).GetComponent("Cloth") : null);
			if ((Object)(object)val == (Object)null)
			{
				r.sharedMesh = mesh;
				return;
			}
			Type type = ((object)val).GetType();
			List<KeyValuePair<PropertyInfo, object>> list = new List<KeyValuePair<PropertyInfo, object>>();
			PropertyInfo[] properties = type.GetProperties(BindingFlags.Instance | BindingFlags.Public);
			foreach (PropertyInfo propertyInfo in properties)
			{
				if (propertyInfo.CanRead && propertyInfo.CanWrite && !(propertyInfo.DeclaringType != type) && propertyInfo.GetIndexParameters().Length == 0)
				{
					try
					{
						list.Add(new KeyValuePair<PropertyInfo, object>(propertyInfo, propertyInfo.GetValue(val, null)));
					}
					catch
					{
					}
				}
			}
			GameObject gameObject = ((Component)r).gameObject;
			Object.DestroyImmediate((Object)(object)val);
			r.sharedMesh = mesh;
			Component val2 = gameObject.AddComponent(type);
			if ((Object)(object)val2 == (Object)null)
			{
				Plugin.Log.LogWarning((object)("[Corpo] não deu pra refazer o pano de '" + ((Object)mesh).name + "'"));
				return;
			}
			foreach (KeyValuePair<PropertyInfo, object> item in list)
			{
				try
				{
					item.Key.SetValue(val2, item.Value, null);
				}
				catch
				{
				}
			}
		}

		private Vector3 Cape(Vector3 p)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: 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_002c: 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_0054: 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)
			Rig rig = _rig;
			float num = rig.KeyH[6];
			float num2 = Vector3.Dot(p - rig.Center, rig.Up);
			if (num2 >= num)
			{
				return p;
			}
			float num3 = num - rig.Floor;
			float num4 = ((num3 > 0.0001f) ? ((num3 - rig.Drop) / num3) : 1f);
			return p + rig.Up * ((num2 - num) * (num4 - 1f));
		}

		private Mesh Deform(Mesh m, bool cape, int[] map, bool[] extra)
		{
			//IL_00a2: 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_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: 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_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_0290: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_0318: Unknown result type (might be due to invalid IL or missing references)
			//IL_031d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0323: Unknown result type (might be due to invalid IL or missing references)
			//IL_0328: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: 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_0347: Unknown result type (might be due to invalid IL or missing references)
			//IL_0349: Unknown result type (might be due to invalid IL or missing references)
			//IL_034b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0357: Unknown result type (might be due to invalid IL or missing references)
			//IL_036a: Unknown result type (might be due to invalid IL or missing references)
			//IL_036c: Unknown result type (might be due to invalid IL or missing references)
			//IL_036e: Unknown result type (might be due to invalid IL or missing references)
			//IL_037a: Unknown result type (might be due to invalid IL or missing references)
			//IL_037f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0392: 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_03a2: 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_03ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03be: 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_03d4: 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_02a8: 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_0424: Unknown result type (might be due to invalid IL or missing references)
			//IL_0426: Unknown result type (might be due to invalid IL or missing references)
			//IL_040d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0414: Unknown result type (might be due to invalid IL or missing references)
			//IL_0419: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02da: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: 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_02ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_0437: Unknown result type (might be due to invalid IL or missing references)
			//IL_043c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0441: Unknown result type (might be due to invalid IL or missing references)
			//IL_049a: 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_04b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0490: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c2: Unknown result type (might be due to invalid IL or missing references)
			if (!m.isReadable)
			{
				if (cape)
				{
					Note(m, "malha da capa não é legível");
				}
				return null;
			}
			Matrix4x4[] bindposes = m.bindposes;
			if (bindposes == null || bindposes.Length != map.Length)
			{
				Note(m, $"{((bindposes != null) ? bindposes.Length : 0)} poses de osso pra {map.Length} ossos");
				return null;
			}
			Vector3[] vertices = m.vertices;
			Vector3[] normals = m.normals;
			BoneWeight[] boneWeights = m.boneWeights;
			if (boneWeights == null || boneWeights.Length != vertices.Length)
			{
				if (cape)
				{
					Note(m, "capa sem pesos de osso");
				}
				return null;
			}
			for (int i = 0; i < map.Length; i++)
			{
				if (!extra[i] && map[i] == _rig.Moved)
				{
					if (!Close(bindposes[i], _rig.BindNew[map[i]]) || Close(bindposes[i], _rig.Bind[map[i]]))
					{
						break;
					}
					return null;
				}
			}
			float num = 0f;
			float num2 = 0f;
			for (int j = 0; j < boneWeights.Length; j++)
			{
				BoneWeight val = boneWeights[j];
				num += HeadW(map, ((BoneWeight)(ref val)).boneIndex0) * ((BoneWeight)(ref val)).weight0 + HeadW(map, ((BoneWeight)(ref val)).boneIndex1) * ((BoneWeight)(ref val)).weight1 + HeadW(map, ((BoneWeight)(ref val)).boneIndex2) * ((BoneWeight)(ref val)).weight2 + HeadW(map, ((BoneWeight)(ref val)).boneIndex3) * ((BoneWeight)(ref val)).weight3;
				num2 += ((BoneWeight)(ref val)).weight0 + ((BoneWeight)(ref val)).weight1 + ((BoneWeight)(ref val)).weight2 + ((BoneWeight)(ref val)).weight3;
			}
			if (!cape && num2 > 0f && num / num2 > 0.6f)
			{
				return null;
			}
			Matrix4x4[] array = (Matrix4x4[])(object)new Matrix4x4[bindposes.Length];
			bool flag = true;
			for (int k = 0; k < bindposes.Length; k++)
			{
				array[k] = (extra[k] ? Matrix4x4.identity : (_rig.BindInv[map[k]] * bindposes[k]));
				if (!Close(array[k], Matrix4x4.identity))
				{
					flag = false;
				}
			}
			bool flag2 = normals != null && normals.Length == vertices.Length;
			Vector3[] array2 = (Vector3[])(object)new Vector3[vertices.Length];
			Vector3[] array3 = (Vector3[])(object)(flag2 ? new Vector3[vertices.Length] : null);
			Vector3[] array4 = (Vector3[])(object)new Vector3[vertices.Length];
			for (int l = 0; l < vertices.Length; l++)
			{
				BoneWeight bw = boneWeights[l];
				Vector3 val2 = vertices[l];
				Vector3 val3 = (flag2 ? normals[l] : Vector3.zero);
				if (!flag)
				{
					val2 = Skin(array, bw, vertices[l], dir: false);
					if (flag2)
					{
						Vector3 val4 = Skin(array, bw, normals[l], dir: true);
						val3 = ((Vector3)(ref val4)).normalized;
					}
				}
				if (flag2)
				{
					array3[l] = val3;
				}
				array4[l] = val2;
			}
			int[] triangles = m.triangles;
			Vector3[] array5 = SmoothNormals(array4, triangles);
			for (int n = 0; n < vertices.Length; n++)
			{
				BoneWeight val5 = boneWeights[n];
				Vector3 val6 = array4[n];
				Vector3 n2 = array5[n];
				array2[n] = Map(B(map, ((BoneWeight)(ref val5)).boneIndex0), val6, n2) * ((BoneWeight)(ref val5)).weight0 + Map(B(map, ((BoneWeight)(ref val5)).boneIndex1), val6, n2) * ((BoneWeight)(ref val5)).weight1 + Map(B(map, ((BoneWeight)(ref val5)).boneIndex2), val6, n2) * ((BoneWeight)(ref val5)).weight2 + Map(B(map, ((BoneWeight)(ref val5)).boneIndex3), val6, n2) * ((BoneWeight)(ref val5)).weight3;
				float num3 = ((BoneWeight)(ref val5)).weight0 + ((BoneWeight)(ref val5)).weight1 + ((BoneWeight)(ref val5)).weight2 + ((BoneWeight)(ref val5)).weight3;
				if (num3 > 1E-05f)
				{
					ref Vector3 reference = ref array2[n];
					reference /= num3;
				}
				else
				{
					array2[n] = val6;
				}
				if (cape)
				{
					array2[n] = Cape(array2[n]);
				}
			}
			if (flag2)
			{
				BendNormals(array4, array2, triangles, array3);
			}
			Matrix4x4[] array6 = (Matrix4x4[])(object)new Matrix4x4[bindposes.Length];
			for (int num4 = 0; num4 < bindposes.Length; num4++)
			{
				array6[num4] = (extra[num4] ? (bindposes[num4] * Matrix4x4.Translate(-_rig.D[map[num4]])) : _rig.BindNew[map[num4]]);
			}
			Mesh val7 = Object.Instantiate<Mesh>(m);
			((Object)val7).name = ((Object)m).name + "_VPS_Shape";
			val7.vertices = array2;
			if (flag2)
			{
				val7.normals = array3;
			}
			val7.bindposes = array6;
			if (!flag && m.tangents != null && m.tangents.Length == vertices.Length)
			{
				val7.RecalculateTangents();
			}
			val7.RecalculateBounds();
			return val7;
		}

		private static int B(int[] map, int i)
		{
			if (i < 0 || i >= map.Length)
			{
				return -1;
			}
			return map[i];
		}

		private static void BendNormals(Vector3[] before, Vector3[] after, int[] tris, Vector3[] normals)
		{
			//IL_0017: 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_002a: 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_0042: 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_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: 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_0110: 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_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: 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_0164: 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_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: 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_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_01e0: 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_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<Vector3Int, int> dictionary = new Dictionary<Vector3Int, int>();
			int[] array = new int[before.Length];
			Vector3Int key = default(Vector3Int);
			for (int i = 0; i < before.Length; i++)
			{
				Vector3 val = before[i] * 2000f;
				((Vector3Int)(ref key))..ctor(Mathf.RoundToInt(val.x), Mathf.RoundToInt(val.y), Mathf.RoundToInt(val.z));
				if (!dictionary.TryGetValue(key, out var value))
				{
					value = (dictionary[key] = dictionary.Count);
				}
				array[i] = value;
			}
			Vector3[] array2 = (Vector3[])(object)new Vector3[dictionary.Count];
			Vector3[] array3 = (Vector3[])(object)new Vector3[dictionary.Count];
			for (int j = 0; j + 2 < tris.Length; j += 3)
			{
				int num = tris[j];
				int num2 = tris[j + 1];
				int num3 = tris[j + 2];
				Vector3 val2 = Vector3.Cross(before[num2] - before[num], before[num3] - before[num]);
				Vector3 val3 = Vector3.Cross(after[num2] - after[num], after[num3] - after[num]);
				ref Vector3 reference = ref array2[array[num]];
				reference += val2;
				ref Vector3 reference2 = ref array2[array[num2]];
				reference2 += val2;
				ref Vector3 reference3 = ref array2[array[num3]];
				reference3 += val2;
				ref Vector3 reference4 = ref array3[array[num]];
				reference4 += val3;
				ref Vector3 reference5 = ref array3[array[num2]];
				reference5 += val3;
				ref Vector3 reference6 = ref array3[array[num3]];
				reference6 += val3;
			}
			for (int k = 0; k < normals.Length; k++)
			{
				Vector3 val4 = array2[array[k]];
				Vector3 val5 = array3[array[k]];
				if (!(((Vector3)(ref val4)).sqrMagnitude < 1E-20f) && !(((Vector3)(ref val5)).sqrMagnitude < 1E-20f))
				{
					int num4 = k;
					Vector3 val6 = Quaternion.FromToRotation(val4, val5) * normals[k];
					normals[num4] = ((Vector3)(ref val6)).normalized;
				}
			}
		}

		private static Vector3[] SmoothNormals(Vector3[] pos, int[] tris)
		{
			//IL_0017: 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_002a: 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_0042: 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_0068: 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_00b9: 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_00c6: 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_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_00dd: 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_00ef: 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_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_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: 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_0129: 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_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: 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_017e: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<Vector3Int, int> dictionary = new Dictionary<Vector3Int, int>();
			int[] array = new int[pos.Length];
			Vector3Int key = default(Vector3Int);
			for (int i = 0; i < pos.Length; i++)
			{
				Vector3 val = pos[i] * 2000f;
				((Vector3Int)(ref key))..ctor(Mathf.RoundToInt(val.x), Mathf.RoundToInt(val.y), Mathf.RoundToInt(val.z));
				if (!dictionary.TryGetValue(key, out var value))
				{
					value = (dictionary[key] = dictionary.Count);
				}
				array[i] = value;
			}
			Vector3[] array2 = (Vector3[])(object)new Vector3[dictionary.Count];
			for (int j = 0; j + 2 < tris.Length; j += 3)
			{
				int num = tris[j];
				int num2 = tris[j + 1];
				int num3 = tris[j + 2];
				Vector3 val2 = Vector3.Cross(pos[num2] - pos[num], pos[num3] - pos[num]);
				ref Vector3 reference = ref array2[array[num]];
				reference += val2;
				ref Vector3 reference2 = ref array2[array[num2]];
				reference2 += val2;
				ref Vector3 reference3 = ref array2[array[num3]];
				reference3 += val2;
			}
			Vector3[] array3 = (Vector3[])(object)new Vector3[pos.Length];
			for (int k = 0; k < pos.Length; k++)
			{
				Vector3 val3 = array2[array[k]];
				array3[k] = ((((Vector3)(ref val3)).sqrMagnitude > 1E-20f) ? ((Vector3)(ref val3)).normalized : Vector3.zero);
			}
			return array3;
		}

		private float HeadW(int[] map, int i)
		{
			int num = B(map, i);
			if (num < 0 || _rig.Parts[num] != Part.Head)
			{
				return 0f;
			}
			return 1f;
		}

		private static Vector3 Skin(Matrix4x4[] M, BoneWeight bw, Vector3 p, bool dir)
		{
			//IL_0015: 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_005f: 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_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: 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_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: 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_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_0051: Unknown result type (might be due to invalid IL or missing references)
			Func<int, Vector3> func = delegate(int i)
			{
				//IL_000c: 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_0044: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				if (i >= M.Length)
				{
					return p;
				}
				return (!dir) ? ((Matrix4x4)(ref M[i])).MultiplyPoint3x4(p) : ((Matrix4x4)(ref M[i])).MultiplyVector(p);
			};
			float num = ((BoneWeight)(ref bw)).weight0 + ((BoneWeight)(ref bw)).weight1 + ((BoneWeight)(ref bw)).weight2 + ((BoneWeight)(ref bw)).weight3;
			if (num < 1E-05f)
			{
				return p;
			}
			return (func(((BoneWeight)(ref bw)).boneIndex0) * ((BoneWeight)(ref bw)).weight0 + func(((BoneWeight)(ref bw)).boneIndex1) * ((BoneWeight)(ref bw)).weight1 + func(((BoneWeight)(ref bw)).boneIndex2) * ((BoneWeight)(ref bw)).weight2 + func(((BoneWeight)(ref bw)).boneIndex3) * ((BoneWeight)(ref bw)).weight3) / num;
		}

		private static bool Close(Matrix4x4 a, Matrix4x4 b)
		{
			for (int i = 0; i < 16; i++)
			{
				if (Mathf.Abs(((Matrix4x4)(ref a))[i] - ((Matrix4x4)(ref b))[i]) > 0.0001f)
				{
					return false;
				}
			}
			return true;
		}

		private Vector3 Map(int b, Vector3 p)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			return Map(b, p, Vector3.zero);
		}

		private Vector3 Map(int b, Vector3 p, Vector3 n)
		{
			//IL_0016: 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_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_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: 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_00f0: 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_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: 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_0191: Unknown result type (might be due to invalid IL or missing references)
			Rig rig = _rig;
			if (b < 0 || b >= rig.Parts.Length)
			{
				return p;
			}
			BodyShape shape = Shape;
			int num = rig.Seg[b];
			switch (rig.Parts[b])
			{
			case Part.Hips:
			case Part.Spine:
			case Part.Spine1:
			case Part.Spine2:
			case Part.Neck:
				return Torso(p, n);
			case Part.UpperArm:
				return Segment(p, num, rig.ChildOf[num], shape.Shoulder, shape.Biceps, shape.Elbow, 0.4f);
			case Part.ForeArm:
				return Segment(p, num, rig.ChildOf[num], shape.Elbow, shape.ForeArm, shape.Wrist, 0.3f);
			case Part.Thigh:
				return Segment(p, num, rig.ChildOf[num], shape.Hips, shape.Thigh, shape.Knee, 0.4f);
			case Part.Shin:
				return Segment(p, num, rig.ChildOf[num], shape.Knee, shape.Calf, shape.Ankle, 0.35f);
			case Part.Hand:
				return rig.J[num] + rig.D[num] + (p - rig.J[num]) * shape.Hand;
			case Part.Foot:
				return rig.J[num] + rig.D[num] + (p - rig.J[num]) * shape.Foot;
			default:
				return p + rig.D[b];
			}
		}

		private Vector3 Torso(Vector3 p)
		{
			//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)
			return Torso(p, Vector3.zero);
		}

		private Vector3 Torso(Vector3 p, Vector3 n)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: 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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: 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_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_03af: Unknown result type (might be due to invalid IL or missing references)
			//IL_0328: Unknown result type (might be due to invalid IL or missing references)
			//IL_032d: Unknown result type (might be due to invalid IL or missing references)
			//IL_039d: Unknown result type (might be due to invalid IL or missing references)
			//IL_039f: 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_03a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_0334: Unknown result type (might be due to invalid IL or missing references)
			//IL_033b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0341: 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_0357: Unknown result type (might be due to invalid IL or missing references)
			//IL_035c: Unknown result type (might be due to invalid IL or missing references)
			//IL_036d: 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_037e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0388: Unknown result type (might be due to invalid IL or missing references)
			//IL_038d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0392: 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_039b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			Rig rig = _rig;
			BodyShape shape = Shape;
			Vector3 val = p - rig.Center;
			float num = Vector3.Dot(val, rig.Lat);
			float num2 = Vector3.Dot(val, rig.Fwd);
			float num3 = Vector3.Dot(val, rig.Up);
			float[] keyH = rig.KeyH;
			float num4 = Profile(num3, keyH, shape.Hips, shape.Hips, shape.Waist, shape.Waist, (shape.Waist + shape.Chest) * 0.5f, shape.Chest, 1f, 1f);
			float num5 = Profile(num3, keyH, shape.FrontLow, shape.FrontHips, (1f + shape.Belly) * 0.5f, shape.Belly, (shape.Belly + shape.ChestFront) * 0.5f, shape.ChestFront, 1f, 1f);
			float num6 = Profile(num3, keyH, shape.Butt, shape.Butt, shape.Back, shape.Back, shape.Back, shape.Back, 1f, 1f);
			bool flag = ((Vector3)(ref n)).sqrMagnitude > 0.25f;
			float num7 = (flag ? 0.4f : 1f);
			Vector3 val2 = p + rig.Lat * (num * (num4 - 1f) * num7) + rig.Fwd * (num2 * (((num2 > 0f) ? num5 : num6) - 1f) * num7);
			float num8 = 0f;
			float num9 = 0f;
			if (flag)
			{
				num8 = Vector3.Dot(n, rig.Lat);
				num9 = Vector3.Dot(n, rig.Fwd);
				HalfSize(num3, out var hw, out var hf, out var hb);
				float num10 = ((num9 > 0f) ? hf : hb);
				float num11 = ((num9 > 0f) ? num5 : num6);
				val2 += (rig.Lat * (num8 * (num4 - 1f) * hw) + rig.Fwd * (num9 * (num11 - 1f) * num10)) * 0.6f;
			}
			if (shape.BellyOut > 0f)
			{
				float num12 = Mathf.Max(keyH[4] - keyH[1], 0.0001f) * 0.6f;
				float num13 = (num3 - keyH[3]) / num12;
				float num14 = num / (0.75f * rig.Round);
				float num15 = Mathf.SmoothStep(0f, 1f, (num2 + 0.2f * rig.Round) / (0.8f * rig.Round));
				float num16 = shape.BellyOut * rig.Round * Mathf.Exp((0f - num13) * num13) * Mathf.Exp((0f - num14) * num14) * num15;
				Vector3 val3 = rig.Fwd;
				if (flag)
				{
					Vector3 val4 = rig.Lat * num8 + rig.Fwd * Mathf.Max(num9, 0f);
					if (((Vector3)(ref val4)).sqrMagnitude > 1E-06f)
					{
						Vector3 val5 = rig.Fwd * 0.6f + ((Vector3)(ref val4)).normalized * 0.4f;
						val3 = ((Vector3)(ref val5)).normalized;
					}
				}
				val2 += val3 * num16;
			}
			return val2;
		}

		private void HalfSize(float h, out float hw, out float hf, out float hb)
		{
			Rig rig = _rig;
			int num = rig.HalfW.Length;
			float num2 = Mathf.Clamp01((h - rig.BinLo) / Mathf.Max(rig.BinHi - rig.BinLo, 1E-05f)) * (float)(num - 1);
			int num3 = Mathf.Min((int)num2, num - 2);
			float num4 = num2 - (float)num3;
			hw = Mathf.Lerp(rig.HalfW[num3], rig.HalfW[num3 + 1], num4);
			hf = Mathf.Lerp(rig.HalfF[num3], rig.HalfF[num3 + 1], num4);
			hb = Mathf.Lerp(rig.HalfB[num3], rig.HalfB[num3 + 1], num4);
		}

		private static float MeasureArm(Rig g, Vector3[] v, BoneWeight[] w, int arm)
		{
			//IL_0023: 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_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			if (arm < 0 || g.ChildOf[arm] == arm)
			{
				return g.Round * 0.25f;
			}
			Vector3 val = g.J[arm];
			Vector3 val2 = g.J[g.ChildOf[arm]] - val;
			float num = 0f;
			int num2 = 0;
			for (int i = 0; i < v.Length; i++)
			{
				if (((BoneWeight)(ref w[i])).boneIndex0 == arm)
				{
					float num3 = Vector3.Dot(v[i] - val, val2) / Mathf.Max(((Vector3)(ref val2)).sqrMagnitude, 1E-12f);
					if (!(num3 < 0.05f) && !(num3 > 0.35f))
					{
						float num4 = num;
						Vector3 val3 = v[i] - (val + val2 * num3);
						num = num4 + ((Vector3)(ref val3)).magnitude;
						num2++;
					}
				}
			}
			if (num2 <= 0)
			{
				return g.Round * 0.25f;
			}
			return num / (float)num2;
		}

		private static void MeasureTorso(Rig g, Vector3[] v, BoneWeight[] w)
		{
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: 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_00ec: 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_0100: Unknown result type (might be due to invalid IL or missing references)
			g.BinLo = g.KeyH[0];
			g.BinHi = g.KeyH[7];
			g.HalfW = new float[24];
			g.HalfF = new float[24];
			g.HalfB = new float[24];
			bool[] array = new bool[24];
			for (int i = 0; i < v.Length; i++)
			{
				int boneIndex = ((BoneWeight)(ref w[i])).boneIndex0;
				if (boneIndex < 0 || boneIndex >= g.Parts.Length)
				{
					continue;
				}
				Part part = g.Parts[boneIndex];
				if (part == Part.Hips || part == Part.Spine || part == Part.Spine1 || part == Part.Spine2 || part == Part.Neck)
				{
					Vector3 val = v[i] - g.Center;
					int num = Mathf.Clamp(Mathf.RoundToInt((Vector3.Dot(val, g.Up) - g.BinLo) / Mathf.Max(g.BinHi - g.BinLo, 1E-05f) * 23f), 0, 23);
					float num2 = Mathf.Abs(Vector3.Dot(val, g.Lat));
					float num3 = Vector3.Dot(val, g.Fwd);
					g.HalfW[num] = Mathf.Max(g.HalfW[num], num2);
					if (num3 > 0f)
					{
						g.HalfF[num] = Mathf.Max(g.HalfF[num], num3);
					}
					else
					{
						g.HalfB[num] = Mathf.Max(g.HalfB[num], 0f - num3);
					}
					array[num] = true;
				}
			}
			float num4 = g.Round * 0.6f;
			float[][] array2 = new float[3][] { g.HalfW, g.HalfF, g.HalfB };
			foreach (float[] array3 in array2)
			{
				for (int k = 0; k < 24; k++)
				{
					if (!array[k] || !(array3[k] > 0.0001f))
					{
						int num5 = k - 1;
						int l = k + 1;
						while (num5 >= 0 && (!array[num5] || !(array3[num5] > 0.0001f)))
						{
							num5--;
						}
						for (; l < 24 && (!array[l] || !(array3[l] > 0.0001f)); l++)
						{
						}
						array3[k] = ((num5 >= 0 && l < 24) ? ((array3[num5] + array3[l]) * 0.5f) : ((num5 >= 0) ? array3[num5] : ((l < 24) ? array3[l] : num4)));
					}
				}
				float[] array4 = (float[])array3.Clone();
				for (int m = 0; m < 24; m++)
				{
					array3[m] = (array4[Mathf.Max(m - 1, 0)] + array4[m] * 2f + array4[Mathf.Min(m + 1, 23)]) * 0.25f;
				}
			}
		}

		private static float Profile(float h, float[] k, params float[] v)
		{
			if (h <= k[0])
			{
				return v[0];
			}
			for (int i = 1; i < k.Length; i++)
			{
				if (h <= k[i])
				{
					return Mathf.Lerp(v[i - 1], v[i], Mathf.SmoothStep(0f, 1f, (h - k[i - 1]) / Mathf.Max(k[i] - k[i - 1], 1E-05f)));
				}
			}
			return v[^1];
		}

		private Vector3 Segment(Vector3 p, int a, int b, float start, float peak, float end, float at)
		{
			//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_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_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_0032: 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_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_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: 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_004f: 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_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_0072: 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_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_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: 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_00e0: 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_00ec: 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_00f5: 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)
			Rig rig = _rig;
			Vector3 val = rig.J[a];
			Vector3 val2 = rig.J[b];
			Vector3 val3 = val + rig.D[a];
			Vector3 val4 = val2 + rig.D[b];
			Vector3 val5 = val2 - val;
			float num = Vector3.Dot(p - val, val5) / Mathf.Max(((Vector3)(ref val5)).sqrMagnitude, 1E-12f);
			Vector3 val6 = p - (val + val5 * num);
			float num2 = Mathf.Clamp01(num);
			float num3 = ((num2 < at) ? Mathf.Lerp(start, peak, Mathf.SmoothStep(0f, 1f, num2 / at)) : Mathf.Lerp(peak, end, Mathf.SmoothStep(0f, 1f, (num2 - at) / (1f - at))));
			return val3 + (val4 - val3) * num + val6 * num3;
		}

		private Rig BuildRig(SkinnedMeshRenderer body, Mesh src)
		{
			//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_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)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: 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_02ce: 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_02d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0302: Unknown result type (might be due to invalid IL or missing references)
			//IL_0322: Unknown result type (might be due to invalid IL or missing references)
			//IL_0327: Unknown result type (might be due to invalid IL or missing references)
			//IL_0332: Unknown result type (might be due to invalid IL or missing references)
			//IL_0337: Unknown result type (might be due to invalid IL or missing references)
			//IL_033c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0340: Unknown result type (might be due to invalid IL or missing references)
			//IL_0345: Unknown result type (might be due to invalid IL or missing references)
			//IL_0356: Unknown result type (might be due to invalid IL or missing references)
			//IL_0361: Unknown result type (might be due to invalid IL or missing references)
			//IL_0366: 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_038b: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04de: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_07fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0801: Unknown result type (might be due to invalid IL or missing references)
			//IL_0806: Unknown result type (might be due to invalid IL or missing references)
			//IL_0832: Unknown result type (might be due to invalid IL or missing references)
			//IL_0837: Unknown result type (might be due to invalid IL or missing references)
			//IL_0838: Unknown result type (might be due to invalid IL or missing references)
			//IL_083a: Unknown result type (might be due to invalid IL or missing references)
			//IL_083f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0841: Unknown result type (might be due to invalid IL or missing references)
			//IL_0861: Unknown result type (might be due to invalid IL or missing references)
			//IL_0866: Unknown result type (might be due to invalid IL or missing references)
			//IL_0878: Unknown result type (might be due to invalid IL or missing references)
			//IL_087d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0882: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_08b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_08b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_08b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_08bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_08bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0963: Unknown result type (might be due to invalid IL or missing references)
			//IL_0975: Unknown result type (might be due to invalid IL or missing references)
			//IL_097a: Unknown result type (might be due to invalid IL or missing references)
			//IL_098c: Unknown result type (might be due to invalid IL or missing references)
			//IL_099e: Unknown result type (might be due to invalid IL or missing references)
			//IL_09a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_09af: Unknown result type (might be due to invalid IL or missing references)
			//IL_09b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_09c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_09cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_09d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a09: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a1b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a20: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a32: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a44: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a49: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a55: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a5a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a6c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a71: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a76: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ae1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b0a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b1c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b21: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b26: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c7c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c8e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c93: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c98: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c9d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ca2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cde: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ce3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cf1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cf6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d02: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d13: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d18: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d24: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d29: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d3a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d3f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d4b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d50: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d61: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d66: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d72: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d77: Unknown result type (might be due to invalid IL or missing references)
			//IL_0da5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0daa: Unknown resul