Decompiled source of DistractionDanceWeapons v1.0.0

plugins/DistractionDanceWeapons.dll

Decompiled 14 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using REPOLib.Modules;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("DistractionDanceWeapons")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("DistractionDanceWeapons")]
[assembly: AssemblyTitle("DistractionDanceWeapons")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[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 DistractionGrenade
{
	[DefaultExecutionOrder(30001)]
	public class DanceCamera : MonoBehaviour
	{
		private double startTime;

		private float duration;

		private float loopLength = 3.713f;

		private Vector3 lastWrittenPos;

		private Quaternion lastWrittenRot;

		private Vector3 basePos;

		private Quaternion baseRot;

		private bool initialised;

		public static void Begin(float duration, double startTime)
		{
			if (Plugin.CameraMotion.Value <= 0f)
			{
				return;
			}
			Camera val = (((Object)(object)GameDirector.instance != (Object)null) ? GameDirector.instance.MainCamera : Camera.main);
			if (!((Object)(object)val == (Object)null))
			{
				DanceCamera danceCamera = ((Component)val).GetComponent<DanceCamera>();
				if ((Object)(object)danceCamera == (Object)null)
				{
					danceCamera = ((Component)val).gameObject.AddComponent<DanceCamera>();
				}
				danceCamera.startTime = startTime;
				danceCamera.duration = duration;
				if ((Object)(object)Plugin.DanceClip != (Object)null)
				{
					danceCamera.loopLength = Plugin.DanceClip.length;
				}
			}
		}

		private void LateUpdate()
		{
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: 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_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: 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_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: 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_0200: 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_0209: 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_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			double num = DanceNet.Now - startTime;
			if (num >= (double)duration)
			{
				Restore();
				Object.Destroy((Object)(object)this);
				return;
			}
			float num2 = loopLength / 2f;
			float num3 = (float)(((num + (double)(Plugin.ClipOffsetBeats.Value * (num2 / 4f))) % (double)num2 + (double)num2) % (double)num2 / (double)num2) * 55f;
			int f0 = Mathf.FloorToInt(num3) % 55;
			int f1 = (f0 + 1) % 55;
			float ft = num3 - Mathf.Floor(num3);
			float num4 = Mathf.Clamp(Plugin.CameraMotion.Value, 0f, 2f);
			float num5 = Mathf.Clamp01((float)num / 0.5f) * Mathf.Clamp01((duration - (float)num) / 0.5f);
			num4 *= num5;
			float num6 = Ch(17) * 0.6f * num4;
			float num7 = Ch(18) * 0.8f * num4;
			float num8 = Ch(16) * 0.5f * num4;
			float num9 = Ch(19) * 0.25f * num4;
			float num10 = Ch(20) * 0.6f * num4;
			Transform transform = ((Component)this).transform;
			Vector3 localPosition = transform.localPosition;
			Quaternion localRotation = transform.localRotation;
			if (!initialised || localPosition != lastWrittenPos)
			{
				basePos = localPosition;
			}
			if (!initialised || localRotation != lastWrittenRot)
			{
				baseRot = localRotation;
			}
			initialised = true;
			Vector3 val = (((Object)(object)transform.parent != (Object)null) ? transform.parent.InverseTransformDirection(transform.right) : transform.right);
			Vector3 val2 = (((Object)(object)transform.parent != (Object)null) ? transform.parent.InverseTransformDirection(Vector3.up) : Vector3.up);
			transform.localPosition = basePos + val * num6 + val2 * num7;
			transform.localRotation = baseRot * Quaternion.Euler(0f - num9, num8, num10);
			lastWrittenPos = transform.localPosition;
			lastWrittenRot = transform.localRotation;
			float Ch(int ch)
			{
				return Mathf.Lerp(DanceData.Frames[f0 * 21 + ch], DanceData.Frames[f1 * 21 + ch], ft);
			}
		}

		private void Restore()
		{
			//IL_000f: 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_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: 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)
			if (initialised)
			{
				if (((Component)this).transform.localPosition == lastWrittenPos)
				{
					((Component)this).transform.localPosition = basePos;
				}
				if (((Component)this).transform.localRotation == lastWrittenRot)
				{
					((Component)this).transform.localRotation = baseRot;
				}
			}
		}

		private void OnDestroy()
		{
			Restore();
		}
	}
	internal static class DanceData
	{
		public const int FrameCount = 55;

		public const int Channels = 21;

		public static readonly float[] Frames = new float[1155]
		{
			0.224f, -0.71f, 0.668f, 0.58f, -0.125f, -0.589f, 0.799f, 0.677f, -0.151f, -0.988f,
			0.002f, 1f, 0.103f, -0.994f, 0.026f, 0.988f, 1.861f, -0.042f, -0.039f, 24.04f,
			-1.276f, 0.033f, -0.752f, 0.659f, 0.573f, 0.117f, -0.629f, 0.769f, 0.608f, -0.176f,
			-0.984f, 0.015f, 0.975f, 0.08f, -0.997f, 0.011f, 0.985f, -1.091f, -0.013f, -0.07f,
			27.424f, -0.052f, -0.223f, -0.752f, 0.621f, 0.58f, 0.328f, -0.571f, 0.753f, 0.611f,
			-0.194f, -0.981f, -0.004f, 0.964f, 0.058f, -0.998f, -0.018f, 0.972f, -2.434f, 0.02f,
			-0.086f, 24.204f, -0.508f, -0.463f, -0.693f, 0.553f, 0.596f, 0.554f, -0.414f, 0.723f,
			0.605f, -0.2f, -0.98f, -0.021f, 0.957f, 0.035f, -0.998f, -0.053f, 0.974f, -4.605f,
			0.053f, -0.081f, 20.348f, -0.456f, -0.672f, -0.588f, 0.45f, 0.623f, 0.664f, -0.293f,
			0.688f, 0.614f, -0.186f, -0.981f, -0.047f, 0.941f, 0.018f, -0.996f, -0.088f, 0.989f,
			-6.134f, 0.083f, -0.062f, 15.02f, 1.108f, -0.79f, -0.468f, 0.396f, 0.648f, 0.712f,
			-0.177f, 0.68f, 0.615f, -0.154f, -0.986f, -0.07f, 0.902f, 0.024f, -0.992f, -0.121f,
			1f, -7.368f, 0.108f, -0.035f, 11.772f, 2.116f, -0.821f, -0.408f, 0.4f, 0.665f,
			0.719f, -0.131f, 0.682f, 0.624f, -0.12f, -0.989f, -0.082f, 0.831f, 0.064f, -0.986f,
			-0.155f, 1f, -8.627f, 0.123f, -0.005f, 9.188f, 3.112f, -0.826f, -0.344f, 0.447f,
			0.651f, 0.748f, -0.055f, 0.662f, 0.605f, -0.082f, -0.995f, -0.057f, 0.782f, 0.111f,
			-0.98f, -0.165f, 1f, -10.667f, 0.131f, 0.022f, 7.328f, 3.86f, -0.842f, -0.239f,
			0.483f, 0.601f, 0.743f, -0.029f, 0.669f, 0.59f, -0.063f, -0.998f, -0.03f, 0.761f,
			0.148f, -0.976f, -0.162f, 1f, -11.057f, 0.135f, 0.042f, 7.008f, 3.128f, -0.834f,
			-0.167f, 0.527f, 0.553f, 0.719f, -0.009f, 0.694f, 0.56f, -0.071f, -0.997f, 0.001f,
			0.762f, 0.161f, -0.975f, -0.154f, 1f, -11.437f, 0.134f, 0.053f, 7.616f, 1.452f,
			-0.791f, -0.111f, 0.601f, 0.503f, 0.622f, 0.046f, 0.781f, 0.506f, -0.084f, -0.996f,
			0.03f, 0.78f, 0.17f, -0.975f, -0.144f, 1f, -11.666f, 0.128f, 0.056f, 8.124f,
			-0.34f, -0.685f, -0.053f, 0.727f, 0.465f, 0.317f, 0.156f, 0.935f, 0.44f, -0.068f,
			-0.997f, 0.045f, 0.816f, 0.193f, -0.972f, -0.137f, 1f, -12.826f, 0.118f, 0.047f,
			10.724f, -3.18f, -0.398f, 0.115f, 0.91f, 0.4f, -0.185f, 0.331f, 0.925f, 0.411f,
			-0.061f, -0.993f, 0.098f, 0.897f, 0.189f, -0.977f, -0.101f, 1f, -18.087f, 0.099f,
			0.026f, 15.064f, -5.896f, 0.046f, 0.378f, 0.925f, 0.349f, -0.74f, 0.302f, 0.6f,
			0.639f, -0.093f, -0.989f, 0.113f, 0.96f, 0.164f, -0.985f, -0.054f, 1f, -16.653f,
			0.062f, -0.008f, 19.74f, -7.184f, 0.017f, 0.59f, 0.807f, 0.339f, -0.675f, 0.455f,
			0.582f, 0.649f, -0.145f, -0.983f, 0.109f, 0.949f, 0.125f, -0.992f, -0.013f, 1f,
			-12.214f, 0.013f, -0.042f, 25.296f, -6.756f, 0.003f, 0.719f, 0.694f, 0.324f, -0.572f,
			0.58f, 0.58f, 0.611f, -0.163f, -0.981f, 0.101f, 0.953f, 0.11f, -0.994f, 0.02f,
			1f, -8.361f, -0.03f, -0.061f, 21.824f, -2.968f, -0.271f, 0.732f, 0.625f, 0.345f,
			-0.42f, 0.673f, 0.608f, 0.553f, -0.151f, -0.984f, 0.099f, 0.981f, 0.12f, -0.992f,
			0.041f, 1f, -6.032f, -0.061f, -0.06f, 18.084f, -1.92f, -0.433f, 0.663f, 0.611f,
			0.371f, -0.287f, 0.677f, 0.678f, 0.517f, -0.132f, -0.986f, 0.098f, 0.997f, 0.135f,
			-0.99f, 0.052f, 1f, -4.88f, -0.087f, -0.046f, 12.3f, -1.392f, -0.549f, 0.534f,
			0.643f, 0.386f, -0.139f, 0.601f, 0.787f, 0.484f, -0.111f, -0.989f, 0.095f, 1f,
			0.127f, -0.99f, 0.064f, 0.99f, -3.79f, -0.109f, -0.025f, 8.752f, -1.756f, -0.651f,
			0.382f, 0.656f, 0.396f, -0.01f, 0.469f, 0.883f, 0.468f, -0.107f, -0.99f, 0.09f,
			1f, 0.102f, -0.992f, 0.078f, 0.965f, -2.222f, -0.124f, -0.002f, 8.956f, -3.14f,
			-0.703f, 0.221f, 0.676f, 0.425f, 0.131f, 0.278f, 0.952f, 0.472f, -0.135f, -0.988f,
			0.075f, 1f, 0.058f, -0.995f, 0.078f, 0.924f, -1.833f, -0.131f, 0.018f, 8.584f,
			-4.552f, -0.747f, -0.014f, 0.665f, 0.483f, 0.21f, 0.048f, 0.977f, 0.499f, -0.173f,
			-0.984f, 0.048f, 1f, 0.03f, -0.997f, 0.073f, 0.856f, -0.986f, -0.134f, 0.035f,
			8.364f, -5.572f, -0.743f, -0.25f, 0.62f, 0.561f, 0.22f, -0.186f, 0.958f, 0.551f,
			-0.185f, -0.983f, 0.006f, 1f, 0.031f, -0.998f, 0.056f, 0.788f, 0.367f, -0.131f,
			0.049f, 8.632f, -6.072f, -0.695f, -0.452f, 0.559f, 0.639f, 0.174f, -0.384f, 0.907f,
			0.631f, -0.178f, -0.983f, -0.045f, 1f, 0.059f, -0.998f, 0.038f, 0.748f, 2.468f,
			-0.122f, 0.057f, 9.248f, -6.268f, -0.615f, -0.613f, 0.496f, 0.708f, 0.096f, -0.552f,
			0.828f, 0.698f, -0.178f, -0.981f, -0.075f, 1f, 0.077f, -0.997f, 0.032f, 0.731f,
			3.891f, -0.108f, 0.056f, 10.704f, -6.096f, -0.502f, -0.731f, 0.463f, 0.772f, 0.059f,
			-0.703f, 0.709f, 0.744f, -0.183f, -0.98f, -0.077f, 1f, 0.097f, -0.995f, 0.015f,
			0.734f, 2.835f, -0.09f, 0.043f, 12.608f, -5.504f, -0.429f, -0.774f, 0.467f, 0.754f,
			0.225f, -0.748f, 0.624f, 0.721f, -0.157f, -0.986f, -0.05f, 1f, 0.144f, -0.989f,
			-0.013f, 0.76f, 0.516f, -0.061f, 0.015f, 16.424f, -4.436f, -0.393f, -0.772f, 0.5f,
			0.665f, 0.413f, -0.707f, 0.574f, 0.658f, -0.134f, -0.991f, -0.019f, 1f, 0.157f,
			-0.987f, -0.039f, 0.828f, -1.994f, -0.023f, -0.027f, 20.4f, -3.344f, -0.42f, -0.743f,
			0.521f, 0.568f, 0.512f, -0.667f, 0.541f, 0.566f, -0.154f, -0.988f, 0.005f, 0.997f,
			0.114f, -0.992f, -0.053f, 0.914f, -5.51f, 0.016f, -0.064f, 24.548f, -2.708f, -0.484f,
			-0.74f, 0.468f, 0.475f, 0.683f, -0.568f, 0.458f, 0.449f, -0.177f, -0.984f, 0.014f,
			0.971f, 0.081f, -0.994f, -0.07f, 0.967f, -8.292f, 0.053f, -0.08f, 24.52f, -2.448f,
			-0.512f, -0.786f, 0.347f, 0.411f, 0.843f, -0.434f, 0.318f, 0.357f, -0.188f, -0.982f,
			0.03f, 0.955f, 0.054f, -0.996f, -0.073f, 0.978f, -10.358f, 0.084f, -0.071f, 19.112f,
			-1.56f, -0.598f, -0.78f, 0.187f, 0.354f, 0.936f, -0.289f, 0.199f, 0.305f, -0.175f,
			-0.984f, 0.044f, 0.934f, 0.041f, -0.997f, -0.071f, 0.999f, -11.789f, 0.109f, -0.047f,
			15.28f, 0.34f, -0.684f, -0.73f, 0.02f, 0.319f, 0.967f, -0.235f, 0.098f, 0.284f,
			-0.141f, -0.988f, 0.057f, 0.895f, 0.056f, -0.996f, -0.07f, 1f, -12.927f, 0.132f,
			-0.015f, 11.592f, 2.408f, -0.707f, -0.698f, -0.117f, 0.306f, 0.974f, -0.225f, -0.011f,
			0.277f, -0.084f, -0.995f, 0.06f, 0.828f, 0.101f, -0.992f, -0.077f, 1f, -13.428f,
			0.144f, 0.018f, 8.66f, 4.112f, -0.716f, -0.653f, -0.246f, 0.292f, 0.965f, -0.253f,
			-0.074f, 0.281f, -0.043f, -0.997f, 0.066f, 0.766f, 0.144f, -0.985f, -0.092f, 1f,
			-13.505f, 0.149f, 0.043f, 7.156f, 5.14f, -0.708f, -0.625f, -0.33f, 0.281f, 0.951f,
			-0.284f, -0.119f, 0.295f, -0.045f, -0.996f, 0.082f, 0.736f, 0.16f, -0.982f, -0.102f,
			1f, -13.461f, 0.148f, 0.058f, 7.032f, 5.588f, -0.673f, -0.653f, -0.348f, 0.278f,
			0.941f, -0.309f, -0.137f, 0.315f, -0.066f, -0.992f, 0.103f, 0.729f, 0.157f, -0.982f,
			-0.107f, 1f, -13.387f, 0.142f, 0.063f, 9.144f, 5.532f, -0.653f, -0.74f, -0.161f,
			0.3f, 0.894f, -0.446f, -0.03f, 0.372f, -0.074f, -0.991f, 0.111f, 0.739f, 0.162f,
			-0.981f, -0.105f, 1f, -12.821f, 0.133f, 0.058f, 12.22f, 5.24f, -0.522f, -0.809f,
			0.271f, 0.403f, 0.694f, -0.698f, 0.177f, 0.49f, -0.078f, -0.992f, 0.101f, 0.758f,
			0.168f, -0.981f, -0.095f, 1f, -11.465f, 0.118f, 0.044f, 15.716f, 4.748f, -0.266f,
			-0.841f, 0.472f, 0.616f, 0.456f, -0.808f, 0.373f, 0.694f, -0.083f, -0.994f, 0.071f,
			0.786f, 0.171f, -0.982f, -0.079f, 1f, -8.654f, 0.093f, 0.018f, 17.804f, 4.704f,
			-0.035f, -0.832f, 0.554f, 0.748f, 0.227f, -0.783f, 0.58f, 0.796f, -0.087f, -0.996f,
			0.029f, 0.845f, 0.174f, -0.984f, -0.045f, 1f, -4.586f, 0.061f, -0.018f, 15.652f,
			5.26f, 0.173f, -0.768f, 0.617f, 0.718f, -0.023f, -0.702f, 0.711f, 0.84f, -0.082f,
			-0.996f, 0.025f, 0.906f, 0.176f, -0.984f, 0.02f, 0.987f, 0.482f, 0.024f, -0.06f,
			20.332f, 4.028f, 0.424f, -0.632f, 0.649f, 0.61f, -0.253f, -0.609f, 0.752f, 0.813f,
			-0.078f, -0.996f, 0.035f, 0.943f, 0.171f, -0.982f, 0.078f, 0.966f, 5.944f, -0.012f,
			-0.086f, 22.78f, 2.7f, 0.655f, -0.444f, 0.611f, 0.586f, -0.44f, -0.527f, 0.727f,
			0.763f, -0.081f, -0.996f, 0.025f, 0.964f, 0.157f, -0.982f, 0.103f, 0.957f, 10.158f,
			-0.043f, -0.087f, 18.044f, 0.704f, 0.806f, -0.335f, 0.488f, 0.586f, -0.585f, -0.435f,
			0.684f, 0.691f, -0.072f, -0.997f, 0.02f, 0.979f, 0.154f, -0.981f, 0.119f, 0.953f,
			12.68f, -0.07f, -0.074f, 14.984f, -0.664f, 0.899f, -0.238f, 0.368f, 0.56f, -0.687f,
			-0.348f, 0.638f, 0.635f, -0.061f, -0.998f, 0.026f, 0.996f, 0.138f, -0.982f, 0.132f,
			0.945f, 14.182f, -0.093f, -0.05f, 12.808f, -1.632f, 0.945f, -0.165f, 0.283f, 0.527f,
			-0.772f, -0.246f, 0.587f, 0.581f, -0.057f, -0.998f, 0.03f, 1f, 0.117f, -0.983f,
			0.144f, 0.928f, 15.369f, -0.108f, -0.023f, 12.224f, -2.24f, 0.959f, -0.146f, 0.242f,
			0.52f, -0.814f, -0.178f, 0.553f, 0.545f, -0.082f, -0.996f, 0.034f, 1f, 0.075f,
			-0.985f, 0.156f, 0.896f, 16.103f, -0.118f, 0.003f, 12.692f, -3.04f, 0.967f, -0.161f,
			0.2f, 0.508f, -0.83f, -0.16f, 0.534f, 0.516f, -0.118f, -0.992f, 0.035f, 1f,
			0.039f, -0.984f, 0.174f, 0.851f, 16.366f, -0.122f, 0.025f, 12.408f, -3.816f, 0.971f,
			-0.187f, 0.151f, 0.492f, -0.851f, -0.134f, 0.507f, 0.491f, -0.132f, -0.99f, 0.041f,
			1f, 0.045f, -0.979f, 0.198f, 0.805f, 16.151f, -0.121f, 0.042f, 11.76f, -4.02f,
			0.968f, -0.218f, 0.126f, 0.475f, -0.855f, -0.145f, 0.498f, 0.487f, -0.127f, -0.991f,
			0.05f, 1f, 0.076f, -0.972f, 0.223f, 0.776f, 15.423f, -0.114f, 0.053f, 12.4f,
			-4f, 0.957f, -0.231f, 0.174f, 0.459f, -0.835f, -0.156f, 0.528f, 0.491f, -0.137f,
			-0.989f, 0.051f, 1f, 0.089f, -0.97f, 0.228f, 0.768f, 14.026f, -0.108f, 0.056f,
			13.768f, -3.692f, 0.917f, -0.268f, 0.295f, 0.458f, -0.772f, -0.205f, 0.601f, 0.504f,
			-0.15f, -0.988f, 0.045f, 1f, 0.101f, -0.973f, 0.208f, 0.779f, 11.753f, -0.099f,
			0.05f, 17.016f, -3.068f, 0.764f, -0.396f, 0.51f, 0.462f, -0.572f, -0.399f, 0.717f,
			0.573f, -0.152f, -0.988f, 0.022f, 1f, 0.125f, -0.982f, 0.139f, 0.814f, 8.563f,
			-0.084f, 0.033f, 21.104f, -2.364f, 0.544f, -0.541f, 0.642f, 0.502f, -0.336f, -0.537f,
			0.774f, 0.654f, -0.151f, -0.988f, 0.003f, 1f, 0.122f, -0.99f, 0.064f, 0.881f,
			4.922f, -0.064f, 0.004f, 21.66f, -1.78f
		};
	}
	[DefaultExecutionOrder(30000)]
	public class DanceDriver : MonoBehaviour
	{
		internal enum Part
		{
			None,
			ArmL,
			ArmR,
			LegL,
			LegR,
			Spine,
			Head
		}

		private class Bone
		{
			public Transform t;

			public Transform end;

			public Transform endT;

			public Vector3 endLocal;

			public Bone joint;

			public bool planted;

			public bool hasBind;

			public Vector3 bindPos;

			public Quaternion bindRot;

			public Transform bindMeshRoot;

			public Matrix4x4 bindWorld;

			public Part part;

			public int depth;

			public Quaternion baseRot;

			public Quaternion lastWritten;

			public Vector3 basePos;

			public Vector3 lastWrittenPos;

			public bool hasPos;

			public bool initialised;
		}

		private class RestNode
		{
			public Transform t;

			public Vector3 pos;

			public Vector3 startPos;

			public Quaternion rot;

			public Quaternion startRot;
		}

		private class Attachment
		{
			public Transform piece;

			public Transform anchor;

			public Vector3 localPos;

			public Vector3 basePos;

			public Quaternion localRot;

			public Quaternion baseRot;
		}

		private static readonly Regex ArmRx = new Regex("arm|hand|shoulder|elbow|wrist|finger|claw|paw(?!n)|(?<!s)wing", RegexOptions.IgnoreCase);

		private static readonly Regex LegRx = new Regex("leg|foot|feet|thigh|knee|shin|calf|toe|ankle|hip\\.|hip_", RegexOptions.IgnoreCase);

		private static readonly Regex SpineRx = new Regex("spine|pelvis|hips|torso|chest|body|belly|waist", RegexOptions.IgnoreCase);

		private static readonly Regex FrontRx = new Regex("front|fore", RegexOptions.IgnoreCase);

		private static readonly Regex HeldRx = new Regex("gun|weapon|rifle|shotgun|pistol|knife|axe|sword|scythe|hammer|spear|staff|club|bat\b|wand|lantern|torch|flashlight|shield", RegexOptions.IgnoreCase);

		private static readonly Regex HeadRx = new Regex("head|neck|skull|jaw|face", RegexOptions.IgnoreCase);

		private static readonly Regex LeftRx = new Regex("(^|[^a-z])(l|left|lft)([^a-z]|$)", RegexOptions.IgnoreCase);

		private static readonly Regex RightRx = new Regex("(^|[^a-z])(r|right|rgt)([^a-z]|$)", RegexOptions.IgnoreCase);

		private static readonly Regex SkipRx = new Regex("(^|[^a-z])(ik|fx)([^a-z]|$)|target|pole|aim|look", RegexOptions.IgnoreCase);

		private static readonly Regex HardSkipRx = new Regex("camera|light|particle|trail|collider|trigger|audio|sound|beam|orb|spawn|debug|vacuum|teleport|effect|spark|smoke|dust|reference|marker", RegexOptions.IgnoreCase);

		private readonly List<Bone> bones = new List<Bone>();

		private float heldFloor = float.NaN;

		private readonly Dictionary<Transform, Vector3> startLocalPos = new Dictionary<Transform, Vector3>();

		private bool reportedMovers;

		private readonly List<KeyValuePair<HurtCollider, bool>> disarmed = new List<KeyValuePair<HurtCollider, bool>>();

		private double lastHold = -1.0;

		private readonly List<RestNode> prefabRest = new List<RestNode>();

		private readonly List<Attachment> attachments = new List<Attachment>();

		private Transform root;

		private Bone fallbackBody;

		private float duration;

		private double startTime;

		private Enemy enemy;

		private PlayerAvatar player;

		private AudioSource music;

		private float loopLength = 3.713f;

		private float scale = 1f;

		private bool active;

		private int bindCount;

		private bool resetChecked;

		private bool resetAllowed = true;

		private Bounds restBounds;

		private Rigidbody frozenBody;

		private bool bodyWasKinematic;

		private Transform prefabRootCached;

		private bool prefabRootLooked;

		public static DanceDriver Begin(GameObject target, float duration, double startTime, Enemy enemy, PlayerAvatar player)
		{
			if ((Object)(object)target == (Object)null)
			{
				return null;
			}
			DanceDriver danceDriver = target.GetComponent<DanceDriver>();
			if ((Object)(object)danceDriver == (Object)null)
			{
				danceDriver = target.AddComponent<DanceDriver>();
			}
			danceDriver.Setup(duration, startTime, enemy, player);
			return danceDriver;
		}

		private void Setup(float duration, double startTime, Enemy enemy, PlayerAvatar player)
		{
			this.duration = duration;
			this.startTime = startTime;
			this.enemy = enemy;
			this.player = player;
			root = ((Component)this).transform;
			if (!active)
			{
				DiscoverBones();
				SetupAudio();
				FreezePhysics();
				Disarm();
				if ((Object)(object)((Component)this).GetComponent<DanceEarlyReset>() == (Object)null)
				{
					((Component)this).gameObject.AddComponent<DanceEarlyReset>().driver = this;
				}
				active = true;
			}
			else if ((Object)(object)music != (Object)null && !music.isPlaying)
			{
				music.Play();
			}
		}

		private void DiscoverBones()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: 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_00bf: 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_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0787: Unknown result type (might be due to invalid IL or missing references)
			//IL_078c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e0f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ca3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0caa: Expected O, but got Unknown
			//IL_05f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0800: Unknown result type (might be due to invalid IL or missing references)
			//IL_0809: Unknown result type (might be due to invalid IL or missing references)
			//IL_08aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_08af: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_08cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_06dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f01: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f06: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f0b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f13: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f18: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f1f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f24: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f29: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f31: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f36: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f3e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f43: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_071d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0722: Unknown result type (might be due to invalid IL or missing references)
			//IL_0727: Unknown result type (might be due to invalid IL or missing references)
			//IL_09ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_09bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_097d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0987: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b7e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b80: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b4a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b4f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a72: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a77: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a8f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a96: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aba: Unknown result type (might be due to invalid IL or missing references)
			//IL_0abf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ac4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ac9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0acd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0acf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ad9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0af6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0af8: Unknown result type (might be due to invalid IL or missing references)
			bones.Clear();
			fallbackBody = null;
			Bounds bounds = default(Bounds);
			((Bounds)(ref bounds))..ctor(root.position, Vector3.one * 0.5f);
			bool flag = false;
			Renderer[] componentsInChildren = ((Component)root).GetComponentsInChildren<Renderer>();
			foreach (Renderer val in componentsInChildren)
			{
				if (!(val is ParticleSystemRenderer) && !(val is TrailRenderer) && !(val is LineRenderer) && val.enabled)
				{
					if (!flag)
					{
						bounds = val.bounds;
						flag = true;
					}
					else
					{
						((Bounds)(ref bounds)).Encapsulate(val.bounds);
					}
				}
			}
			scale = Mathf.Clamp(((Bounds)(ref bounds)).size.y, 0.3f, 6f);
			restBounds = bounds;
			EnemyOverrides.Override obj = EnemyOverrides.For(enemy);
			Transform[] componentsInChildren2 = ((Component)root).GetComponentsInChildren<Transform>(true);
			foreach (Transform val2 in componentsInChildren2)
			{
				if ((Object)(object)val2 == (Object)(object)root || Already(val2) || (Object)(object)((Component)val2).GetComponent<Rigidbody>() != (Object)null || (Object)(object)((Component)val2).GetComponent<Joint>() != (Object)null)
				{
					continue;
				}
				string name = ((Object)val2).name;
				if (obj != null)
				{
					if (obj.Skips(val2, root))
					{
						continue;
					}
					Part part = obj.Forced(name);
					if (part != Part.None)
					{
						Add(val2, part, -1);
						continue;
					}
				}
				if (name.IndexOf("armature", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("grabber", StringComparison.OrdinalIgnoreCase) >= 0 || ((Object)(object)player != (Object)null && (!name.StartsWith("ANIM ", StringComparison.Ordinal) || name.IndexOf("SCALE", StringComparison.OrdinalIgnoreCase) >= 0)) || HardSkipRx.IsMatch(name) || (SkipRx.IsMatch(name) && !ArmRx.IsMatch(name) && !LegRx.IsMatch(name)))
				{
					continue;
				}
				Part part2 = Part.None;
				if (ArmRx.IsMatch(name))
				{
					if (HoldsBothSides(val2, ArmRx))
					{
						continue;
					}
					part2 = (Side(val2, name) ? Part.ArmL : Part.ArmR);
				}
				else if (LegRx.IsMatch(name))
				{
					if (HoldsBothSides(val2, LegRx))
					{
						continue;
					}
					part2 = (Side(val2, name) ? Part.LegL : Part.LegR);
				}
				else if (HeadRx.IsMatch(name))
				{
					part2 = Part.Head;
				}
				else if (SpineRx.IsMatch(name))
				{
					part2 = Part.Spine;
				}
				if (part2 != Part.None)
				{
					Add(val2, part2, -1);
				}
			}
			bool flag2 = false;
			bool flag3 = false;
			foreach (Bone bone3 in bones)
			{
				if (bone3.part == Part.ArmL || bone3.part == Part.ArmR)
				{
					flag2 = true;
				}
				else if ((bone3.part == Part.LegL || bone3.part == Part.LegR) && FrontRx.IsMatch(((Object)bone3.t).name))
				{
					flag3 = true;
				}
			}
			if (!flag2 && flag3)
			{
				foreach (Bone bone4 in bones)
				{
					if ((bone4.part == Part.LegL || bone4.part == Part.LegR) && FrontRx.IsMatch(((Object)bone4.t).name))
					{
						bone4.part = ((bone4.part == Part.LegL) ? Part.ArmL : Part.ArmR);
					}
				}
			}
			GeometricPass();
			RerootDetachedLimbs();
			foreach (Bone bone5 in bones)
			{
				if (bone5.depth >= 0)
				{
					continue;
				}
				int num = 0;
				Transform parent = bone5.t.parent;
				while ((Object)(object)parent != (Object)null && (Object)(object)parent != (Object)(object)root)
				{
					Bone bone = Find(parent);
					if (bone != null && bone.part == bone5.part)
					{
						num++;
					}
					parent = parent.parent;
				}
				bone5.depth = num;
			}
			foreach (Bone bone6 in bones)
			{
				Bone bone2 = bone6;
				if (bone2.depth != 0 || !IsLimb(bone2.part))
				{
					continue;
				}
				Vector3 rootPos = bone2.t.position;
				List<Bone> joints = new List<Bone>();
				foreach (Bone bone7 in bones)
				{
					if (bone7 != bone2 && bone7.part == bone2.part && bone7.t.IsChildOf(bone2.t) && HasMeshOutside(bone2.t, bone7.t))
					{
						joints.Add(bone7);
					}
				}
				float best = 0.02f * scale;
				float bestBalance = float.MaxValue;
				bone2.endT = null;
				bone2.joint = null;
				componentsInChildren2 = ((Component)bone2.t).GetComponentsInChildren<Transform>(false);
				foreach (Transform val3 in componentsInChildren2)
				{
					if (!((Object)(object)val3 == (Object)(object)bone2.t) && !HardSkipRx.IsMatch(((Object)val3).name) && !SkipRx.IsMatch(((Object)val3).name) && !UnderHeld(val3, bone2.t))
					{
						Consider(val3, Vector3.zero);
					}
				}
				MeshFilter[] componentsInChildren3 = ((Component)bone2.t).GetComponentsInChildren<MeshFilter>(false);
				foreach (MeshFilter val4 in componentsInChildren3)
				{
					if ((Object)(object)val4.sharedMesh == (Object)null)
					{
						continue;
					}
					Renderer component = ((Component)val4).GetComponent<Renderer>();
					if (!((Object)(object)component == (Object)null) && component.enabled && !SkipRx.IsMatch(((Object)((Component)val4).transform).name) && !HardSkipRx.IsMatch(((Object)((Component)val4).transform).name) && ((Object)((Component)val4).transform).name.IndexOf("map", StringComparison.OrdinalIgnoreCase) < 0 && !UnderHeld(((Component)val4).transform, bone2.t))
					{
						Bounds bounds2 = val4.sharedMesh.bounds;
						for (int j = 0; j < 8; j++)
						{
							Consider(((Component)val4).transform, ((Bounds)(ref bounds2)).center + Vector3.Scale(((Bounds)(ref bounds2)).extents, new Vector3((float)((j & 1) * 2 - 1), (float)(((j >> 1) & 1) * 2 - 1), (float)(((j >> 2) & 1) * 2 - 1))));
						}
					}
				}
				bone2.end = bone2.endT;
				if ((Object)(object)bone2.endT == (Object)null)
				{
					continue;
				}
				Vector3 val5 = EndPos(bone2);
				Bone joint = null;
				int num2 = int.MaxValue;
				foreach (Bone item in joints)
				{
					if ((Object)(object)bone2.endT == (Object)(object)item.t || !bone2.endT.IsChildOf(item.t))
					{
						continue;
					}
					float num3 = Vector3.Distance(item.t.position, rootPos);
					float num4 = Vector3.Distance(val5, item.t.position);
					float num5 = num3 + num4;
					if (!(num3 < 0.15f * num5) && !(num4 < 0.15f * num5))
					{
						int num6 = HierarchyDepth(item.t);
						if (num6 < num2)
						{
							num2 = num6;
							joint = item;
						}
					}
				}
				bone2.joint = joint;
				if (bone2.part != Part.LegL && bone2.part != Part.LegR)
				{
					continue;
				}
				Vector3 position = PrefabTwin(bone2.t).position;
				Vector3 val6 = PrefabTwin(bone2.endT).TransformPoint(bone2.endLocal);
				float num7 = Vector3.Distance(val6, position);
				if (!(val6.y > position.y + 0.2f * num7))
				{
					continue;
				}
				Transform val7 = null;
				float num8 = float.NegativeInfinity;
				componentsInChildren2 = ((Component)bone2.t).GetComponentsInChildren<Transform>(false);
				foreach (Transform val8 in componentsInChildren2)
				{
					if (!((Object)(object)val8 == (Object)(object)bone2.t) && !HardSkipRx.IsMatch(((Object)val8).name) && !SkipRx.IsMatch(((Object)val8).name) && !UnderHeld(val8, bone2.t))
					{
						float num9 = PrefabTwin(val8).position.y - position.y;
						if (num9 > num8)
						{
							num8 = num9;
							val7 = val8;
						}
					}
				}
				float num10 = float.NegativeInfinity;
				Transform val9 = null;
				Vector3 endLocal = Vector3.zero;
				componentsInChildren3 = ((Component)bone2.t).GetComponentsInChildren<MeshFilter>(false);
				foreach (MeshFilter val10 in componentsInChildren3)
				{
					if ((Object)(object)val10.sharedMesh == (Object)null || UnderHeld(((Component)val10).transform, bone2.t))
					{
						continue;
					}
					Renderer component2 = ((Component)val10).GetComponent<Renderer>();
					if ((Object)(object)component2 == (Object)null || !component2.enabled || HardSkipRx.IsMatch(((Object)((Component)val10).transform).name) || SkipRx.IsMatch(((Object)((Component)val10).transform).name))
					{
						continue;
					}
					Bounds bounds3 = val10.sharedMesh.bounds;
					Transform val11 = PrefabTwin(((Component)val10).transform);
					for (int k = 0; k < 8; k++)
					{
						Vector3 val12 = ((Bounds)(ref bounds3)).center + Vector3.Scale(((Bounds)(ref bounds3)).extents, new Vector3((float)((k & 1) * 2 - 1), (float)(((k >> 1) & 1) * 2 - 1), (float)(((k >> 2) & 1) * 2 - 1)));
						float num11 = val11.TransformPoint(val12).y - position.y;
						if (num11 > num10)
						{
							num10 = num11;
							val9 = ((Component)val10).transform;
							endLocal = val12;
						}
					}
				}
				if ((Object)(object)val7 != (Object)null && num8 >= 0.6f * num10 && num8 > 0.01f)
				{
					bone2.endT = val7;
					bone2.endLocal = Vector3.zero;
				}
				else if ((Object)(object)val9 != (Object)null && num10 > 0.01f)
				{
					bone2.endT = val9;
					bone2.endLocal = endLocal;
				}
				bone2.end = bone2.endT;
				bone2.planted = true;
				bone2.joint = null;
				bone2.hasPos = true;
				void Consider(Transform endT, Vector3 val20)
				{
					//IL_0001: Unknown result type (might be due to invalid IL or missing references)
					//IL_0002: Unknown result type (might be due to invalid IL or missing references)
					//IL_0007: Unknown result type (might be due to invalid IL or missing references)
					//IL_0008: Unknown result type (might be due to invalid IL or missing references)
					//IL_000a: Unknown result type (might be due to invalid IL or missing references)
					//IL_0048: Unknown result type (might be due to invalid IL or missing references)
					//IL_0049: Unknown result type (might be due to invalid IL or missing references)
					//IL_009b: Unknown result type (might be due to invalid IL or missing references)
					//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
					//IL_00ad: 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_013c: Unknown result type (might be due to invalid IL or missing references)
					//IL_013d: Unknown result type (might be due to invalid IL or missing references)
					Vector3 val19 = endT.TransformPoint(val20);
					float num14 = Vector3.Distance(val19, rootPos);
					if (num14 > best + 0.0001f)
					{
						best = num14;
						bestBalance = float.MaxValue;
						bone2.endT = endT;
						bone2.endLocal = val20;
						bone2.joint = null;
					}
					foreach (Bone item2 in joints)
					{
						if (!((Object)(object)endT == (Object)(object)item2.t) && endT.IsChildOf(item2.t))
						{
							float num15 = Vector3.Distance(item2.t.position, rootPos);
							float num16 = Vector3.Distance(val19, item2.t.position);
							float num17 = num15 + num16;
							if (!(num15 < 0.15f * num17) && !(num16 < 0.15f * num17))
							{
								float num18 = Mathf.Abs(num15 - num16);
								if (num17 > best + 0.0001f || (Mathf.Abs(num17 - best) <= 0.0001f && num18 < bestBalance))
								{
									best = num17;
									bestBalance = num18;
									bone2.endT = endT;
									bone2.endLocal = val20;
									bone2.joint = item2;
								}
							}
						}
					}
				}
			}
			if ((Object)(object)enemy != (Object)null)
			{
				PromoteBodyRoot();
			}
			bones.Sort((Bone a, Bone b) => HierarchyDepth(a.t).CompareTo(HierarchyDepth(b.t)));
			bool flag4 = false;
			foreach (Bone bone8 in bones)
			{
				if (bone8.part == Part.ArmL || bone8.part == Part.ArmR || bone8.part == Part.LegL || bone8.part == Part.LegR)
				{
					flag4 = true;
				}
			}
			if (!flag4)
			{
				Transform val13 = null;
				int num12 = 0;
				foreach (Transform item3 in root)
				{
					Transform val14 = item3;
					if ((Object)(object)((Component)val14).GetComponent<Rigidbody>() != (Object)null)
					{
						continue;
					}
					int num13 = 0;
					componentsInChildren = ((Component)val14).GetComponentsInChildren<Renderer>();
					foreach (Renderer val15 in componentsInChildren)
					{
						if (val15.enabled && (val15 is MeshRenderer || val15 is SkinnedMeshRenderer))
						{
							num13++;
						}
					}
					if (num13 != 0)
					{
						if ((Object)(object)((Component)val14).GetComponentInChildren<Animator>(true) != (Object)null || (Object)(object)((Component)val14).GetComponentInChildren<Animation>(true) != (Object)null)
						{
							num13 += 1000;
						}
						if (num13 > num12)
						{
							num12 = num13;
							val13 = val14;
						}
					}
				}
				if ((Object)(object)val13 == (Object)null && (Object)(object)((Component)root).GetComponent<Rigidbody>() == (Object)null)
				{
					val13 = root;
				}
				if ((Object)(object)val13 != (Object)null)
				{
					fallbackBody = new Bone
					{
						t = val13,
						part = Part.Spine,
						depth = 0,
						hasPos = true
					};
					if (Find(val13) == null)
					{
						bones.Add(fallbackBody);
					}
				}
			}
			if (Plugin.DebugLogBones.Value)
			{
				startLocalPos.Clear();
				componentsInChildren2 = ((Component)root).GetComponentsInChildren<Transform>(true);
				foreach (Transform val16 in componentsInChildren2)
				{
					startLocalPos[val16] = val16.localPosition;
				}
			}
			prefabRest.Clear();
			if ((Object)(object)enemy != (Object)null && Plugin.RigidRestPose.Value && bindCount == 0)
			{
				CollectPrefabRest();
			}
			attachments.Clear();
			if (obj != null && obj.Attach.Count > 0)
			{
				componentsInChildren2 = ((Component)root).GetComponentsInChildren<Transform>(true);
				foreach (Transform val17 in componentsInChildren2)
				{
					string text = obj.AnchorFor(((Object)val17).name);
					if (text != null)
					{
						Transform val18 = EnemyOverrides.FindNamed(root, text);
						if (!((Object)(object)val18 == (Object)null) && !((Object)(object)val18 == (Object)(object)val17) && !val17.IsChildOf(val18))
						{
							attachments.Add(new Attachment
							{
								piece = val17,
								anchor = val18,
								localPos = val18.InverseTransformPoint(val17.position),
								localRot = Quaternion.Inverse(val18.rotation) * val17.rotation,
								basePos = val17.localPosition,
								baseRot = val17.localRotation
							});
						}
					}
				}
			}
			if (!Plugin.DebugLogBones.Value)
			{
				return;
			}
			string text2 = ((!((Object)(object)enemy != (Object)null)) ? (((Object)(object)player != (Object)null) ? "player" : ((Object)root).name) : (enemy.EnemyParent?.enemyName ?? ((Object)enemy).name));
			if ((Object)(object)enemy != (Object)null)
			{
				text2 = text2 + " [" + EnemyOverrides.Key(enemy) + ((obj != null) ? ", override" : "") + "] root=" + ((Object)root).name;
			}
			Plugin.Log.LogDebug((object)$"[Dance] {text2}: {bones.Count} bones, limbs={flag4}, height={scale:F2}");
			foreach (Bone bone9 in bones)
			{
				string text3 = "";
				if (bone9.depth == 0 && IsLimb(bone9.part))
				{
					text3 = (((Object)(object)bone9.endT == (Object)null) ? "  NO END" : ("  end=" + ((Object)bone9.endT).name + ((bone9.joint != null) ? (" joint=" + ((Object)bone9.joint.t).name) : "") + (bone9.planted ? " PLANTED" : "")));
				}
				Plugin.Log.LogDebug((object)$"[Dance]   {bone9.part} d{bone9.depth}  {Path(bone9.t)}{text3}");
			}
		}

		private void GeometricPass()
		{
			//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)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: 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_00e0: 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_0100: 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_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_039a: Unknown result type (might be due to invalid IL or missing references)
			//IL_039f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0335: 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_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_047a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0481: Unknown result type (might be due to invalid IL or missing references)
			//IL_0486: Unknown result type (might be due to invalid IL or missing references)
			//IL_045e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0463: Unknown result type (might be due to invalid IL or missing references)
			//IL_0465: Unknown result type (might be due to invalid IL or missing references)
			//IL_046c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0471: Unknown result type (might be due to invalid IL or missing references)
			//IL_048b: 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_0495: 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_049e: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a5: 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_02eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_050f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0511: Unknown result type (might be due to invalid IL or missing references)
			//IL_0518: Unknown result type (might be due to invalid IL or missing references)
			//IL_051a: Unknown result type (might be due to invalid IL or missing references)
			//IL_051f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0549: Unknown result type (might be due to invalid IL or missing references)
			//IL_054e: Unknown result type (might be due to invalid IL or missing references)
			SkinnedMeshRenderer[] componentsInChildren = ((Component)root).GetComponentsInChildren<SkinnedMeshRenderer>(true);
			foreach (SkinnedMeshRenderer val in componentsInChildren)
			{
				if ((Object)(object)val.sharedMesh == (Object)null || val.bones == null)
				{
					continue;
				}
				Matrix4x4[] bindposes = val.sharedMesh.bindposes;
				Transform[] array = val.bones;
				int num = Mathf.Min(bindposes.Length, array.Length);
				if (num < 4)
				{
					continue;
				}
				Dictionary<Transform, Vector3> dictionary = new Dictionary<Transform, Vector3>();
				Dictionary<Transform, Matrix4x4> dictionary2 = new Dictionary<Transform, Matrix4x4>();
				float num2 = float.PositiveInfinity;
				float num3 = float.NegativeInfinity;
				float num4 = 0f;
				for (int j = 0; j < num; j++)
				{
					if (!((Object)(object)array[j] == (Object)null) && !dictionary.ContainsKey(array[j]))
					{
						Matrix4x4 inverse = ((Matrix4x4)(ref bindposes[j])).inverse;
						Vector3 val2 = Vector4.op_Implicit(((Matrix4x4)(ref inverse)).GetColumn(3));
						dictionary[array[j]] = val2;
						dictionary2[array[j]] = inverse;
						num2 = Mathf.Min(num2, val2.y);
						num3 = Mathf.Max(num3, val2.y);
						num4 += val2.x;
					}
				}
				float num5 = num3 - num2;
				if (dictionary.Count < 4 || num5 <= 0.001f)
				{
					continue;
				}
				float num6 = num4 / (float)dictionary.Count;
				float num7 = 0.03f * num5;
				float num8 = 0f;
				int num9 = 0;
				foreach (KeyValuePair<Transform, Vector3> item in dictionary)
				{
					if (Mathf.Abs(item.Value.x - num6) <= num7)
					{
						num8 += item.Value.y;
						num9++;
					}
				}
				num8 = ((num9 > 0) ? (num8 / (float)num9) : (num2 + 0.5f * num5));
				foreach (KeyValuePair<Transform, Vector3> item2 in dictionary)
				{
					Transform key = item2.Key;
					if ((Object)(object)key == (Object)(object)root || Already(key) || (Object)(object)((Component)key).GetComponent<Rigidbody>() != (Object)null || (Object)(object)((Component)key).GetComponent<Joint>() != (Object)null || ((Object)key).name.IndexOf("armature", StringComparison.OrdinalIgnoreCase) >= 0)
					{
						continue;
					}
					Transform val3 = null;
					Transform val4 = key;
					while ((Object)(object)val4 != (Object)null && dictionary.ContainsKey(val4))
					{
						if (Mathf.Abs(dictionary[val4].x - num6) > num7)
						{
							val3 = val4;
						}
						val4 = val4.parent;
					}
					Part part;
					if ((Object)(object)val3 == (Object)null)
					{
						float y = item2.Value.y;
						if (y > num2 + 0.8f * num5)
						{
							bool flag = false;
							Transform[] componentsInChildren2 = ((Component)key).GetComponentsInChildren<Transform>(true);
							foreach (Transform val5 in componentsInChildren2)
							{
								if ((Object)(object)val5 != (Object)(object)key && dictionary.TryGetValue(val5, out var value) && Mathf.Abs(value.x - num6) > num7)
								{
									flag = true;
									break;
								}
							}
							part = (flag ? Part.Spine : Part.Head);
						}
						else
						{
							if (!(y > num2 + 0.25f * num5))
							{
								continue;
							}
							part = Part.Spine;
						}
					}
					else
					{
						bool flag2 = dictionary[val3].x < num6;
						part = ((!(dictionary[val3].y > num8)) ? (flag2 ? Part.LegL : Part.LegR) : (flag2 ? Part.ArmL : Part.ArmR));
					}
					Add(key, part, -1);
				}
				Matrix4x4 localToWorldMatrix = ((Component)val).transform.localToWorldMatrix;
				foreach (KeyValuePair<Transform, Matrix4x4> item3 in dictionary2)
				{
					Transform key2 = item3.Key;
					if ((Object)(object)key2 == (Object)(object)root || (Object)(object)key2.parent == (Object)null || (Object)(object)((Component)key2).GetComponent<Rigidbody>() != (Object)null || (Object)(object)((Component)key2).GetComponent<Joint>() != (Object)null)
					{
						continue;
					}
					Bone bone = Find(key2);
					if (bone == null)
					{
						bone = new Bone
						{
							t = key2,
							part = Part.None,
							depth = 0
						};
						bones.Add(bone);
					}
					Matrix4x4 value2;
					bool flag3 = dictionary2.TryGetValue(key2.parent, out value2);
					Matrix4x4 val6 = (flag3 ? (((Matrix4x4)(ref value2)).inverse * item3.Value) : (key2.parent.worldToLocalMatrix * localToWorldMatrix * item3.Value));
					Vector3 val7 = Vector4.op_Implicit(((Matrix4x4)(ref val6)).GetColumn(3));
					Quaternion rotation = ((Matrix4x4)(ref val6)).rotation;
					if (!Finite(val7) || !Finite(rotation) || Mathf.Abs(((Matrix4x4)(ref val6)).determinant) < 1E-09f || ((Matrix4x4)(ref val6)).determinant < 0f)
					{
						if (Plugin.DebugLogBones.Value)
						{
							Plugin.Log.LogWarning((object)$"[Dance] no usable bind pose for {((Object)key2).name} (det {((Matrix4x4)(ref val6)).determinant:G3})");
						}
						continue;
					}
					bone.bindPos = val7;
					bone.bindRot = Quaternion.Normalize(rotation);
					bone.hasBind = true;
					bone.hasPos = true;
					if (!flag3)
					{
						bone.bindMeshRoot = ((Component)val).transform;
						bone.bindWorld = item3.Value;
					}
					bindCount++;
				}
			}
		}

		private static bool IsLimb(Part p)
		{
			if (p != Part.ArmL && p != Part.ArmR && p != Part.LegL)
			{
				return p == Part.LegR;
			}
			return true;
		}

		private static Vector3 EndPos(Bone b)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			return b.endT.TransformPoint(b.endLocal);
		}

		private static Vector3 FootPos(Bone b)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			if (!b.planted)
			{
				return EndPos(b);
			}
			return b.t.position;
		}

		private static Vector3 TwoBone(Bone root, Vector3 dir, float reach, Vector3 pole, float blend, Vector3 up, Vector3 fwd)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: 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_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: 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_00e1: 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_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: 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_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: 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_019d: 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_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: 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_01f1: 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_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: 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_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: 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)
			//IL_0236: 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_012d: 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_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = root.t.position;
			Vector3 position2 = root.joint.t.position;
			Vector3 val = EndPos(root);
			float num = Vector3.Distance(position2, position);
			float num2 = Vector3.Distance(val, position2);
			float num3 = num + num2;
			if (num < 0.05f * num3 || num2 < 0.05f * num3)
			{
				Vector3 val2 = val - position;
				if (((Vector3)(ref val2)).sqrMagnitude > 1E-08f)
				{
					root.t.rotation = Quaternion.Slerp(Quaternion.identity, Quaternion.FromToRotation(((Vector3)(ref val2)).normalized, dir), blend) * root.t.rotation;
				}
				return position + dir * num3;
			}
			float num4 = Mathf.Clamp(reach * num3, Mathf.Abs(num - num2) + 0.0001f, num3 - 0.0001f);
			Vector3 val3 = position + dir * num4;
			Vector3 val4 = (val3 - position) / num4;
			Vector3 val5 = pole - Vector3.Dot(pole, val4) * val4;
			if (((Vector3)(ref val5)).sqrMagnitude < 1E-06f)
			{
				val5 = Vector3.Cross(val4, up);
			}
			if (((Vector3)(ref val5)).sqrMagnitude < 1E-06f)
			{
				val5 = Vector3.Cross(val4, fwd);
			}
			((Vector3)(ref val5)).Normalize();
			float num5 = Mathf.Clamp((num * num + num4 * num4 - num2 * num2) / (2f * num * num4), -1f, 1f);
			float num6 = Mathf.Sqrt(1f - num5 * num5);
			Vector3 val6 = position + val4 * (num * num5) + val5 * (num * num6);
			Quaternion val7 = Quaternion.FromToRotation(position2 - position, val6 - position);
			root.t.rotation = Quaternion.Slerp(Quaternion.identity, val7, blend) * root.t.rotation;
			Vector3 position3 = root.joint.t.position;
			Quaternion val8 = Quaternion.FromToRotation(EndPos(root) - position3, val3 - position3);
			root.joint.t.rotation = Quaternion.Slerp(Quaternion.identity, val8, blend) * root.joint.t.rotation;
			return val3;
		}

		private static bool Finite(Vector3 v)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: 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_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			if (!float.IsNaN(v.x) && !float.IsNaN(v.y) && !float.IsNaN(v.z) && !float.IsInfinity(v.x) && !float.IsInfinity(v.y))
			{
				return !float.IsInfinity(v.z);
			}
			return false;
		}

		private static bool Finite(Quaternion q)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: 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_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			if (!float.IsNaN(q.x) && !float.IsNaN(q.y) && !float.IsNaN(q.z) && !float.IsNaN(q.w))
			{
				return Mathf.Abs(q.x * q.x + q.y * q.y + q.z * q.z + q.w * q.w) > 1E-06f;
			}
			return false;
		}

		private Bounds VisibleBounds()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: 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_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			Bounds bounds = default(Bounds);
			((Bounds)(ref bounds))..ctor(root.position, Vector3.zero);
			bool flag = false;
			Renderer[] componentsInChildren = ((Component)root).GetComponentsInChildren<Renderer>();
			foreach (Renderer val in componentsInChildren)
			{
				if (!(val is ParticleSystemRenderer) && !(val is TrailRenderer) && !(val is LineRenderer) && val.enabled)
				{
					if (!flag)
					{
						bounds = val.bounds;
						flag = true;
					}
					else
					{
						((Bounds)(ref bounds)).Encapsulate(val.bounds);
					}
				}
			}
			return bounds;
		}

		private static int HierarchyDepth(Transform t)
		{
			int num = 0;
			while ((Object)(object)t != (Object)null && (Object)(object)t.parent != (Object)null)
			{
				num++;
				t = t.parent;
			}
			return num;
		}

		private static Transform Farthest(Transform t)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			Transform result = null;
			float num = 0f;
			Vector3 position = t.position;
			Transform[] componentsInChildren = ((Component)t).GetComponentsInChildren<Transform>(false);
			foreach (Transform val in componentsInChildren)
			{
				if (!((Object)(object)val == (Object)(object)t) && !HardSkipRx.IsMatch(((Object)val).name) && !SkipRx.IsMatch(((Object)val).name))
				{
					float num2 = Vector3.Distance(val.position, position);
					if (num2 > num)
					{
						num = num2;
						result = val;
					}
				}
			}
			return result;
		}

		private void Add(Transform t, Part part, int depth)
		{
			if (!Already(t))
			{
				bones.Add(new Bone
				{
					t = t,
					part = part,
					depth = depth,
					hasPos = (part == Part.Spine)
				});
			}
		}

		private bool Already(Transform t)
		{
			return Find(t) != null;
		}

		private Bone Find(Transform t)
		{
			foreach (Bone bone in bones)
			{
				if ((Object)(object)bone.t == (Object)(object)t)
				{
					return bone;
				}
			}
			return null;
		}

		private static bool HoldsBothSides(Transform t, Regex limb)
		{
			bool flag = false;
			bool flag2 = false;
			Transform[] componentsInChildren = ((Component)t).GetComponentsInChildren<Transform>(false);
			foreach (Transform val in componentsInChildren)
			{
				if (!((Object)(object)val == (Object)(object)t) && limb.IsMatch(((Object)val).name))
				{
					if (LeftRx.IsMatch(((Object)val).name))
					{
						flag = true;
					}
					if (RightRx.IsMatch(((Object)val).name))
					{
						flag2 = true;
					}
					if (flag && flag2)
					{
						return true;
					}
				}
			}
			return false;
		}

		private bool Side(Transform t, string name)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			bool flag = LeftRx.IsMatch(name);
			bool flag2 = RightRx.IsMatch(name);
			if (flag && !flag2)
			{
				return true;
			}
			if (flag2 && !flag)
			{
				return false;
			}
			return root.InverseTransformPoint(t.position).x < 0f;
		}

		private static string Path(Transform t)
		{
			string text = ((Object)t).name;
			int num = 0;
			while ((Object)(object)t.parent != (Object)null && num++ < 12)
			{
				t = t.parent;
				text = ((Object)t).name + "/" + text;
			}
			return text;
		}

		private void FreezePhysics()
		{
			//IL_0089: 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)
			if (!((Object)(object)enemy == (Object)null) && Plugin.FreezePhysics.Value && enemy.HasRigidbody && !((Object)(object)enemy.Rigidbody == (Object)null) && !((Object)(object)enemy.Rigidbody.rb == (Object)null))
			{
				frozenBody = enemy.Rigidbody.rb;
				bodyWasKinematic = frozenBody.isKinematic;
				if (!bodyWasKinematic)
				{
					frozenBody.linearVelocity = Vector3.zero;
					frozenBody.angularVelocity = Vector3.zero;
					frozenBody.isKinematic = true;
				}
			}
		}

		private void Disarm()
		{
			disarmed.Clear();
			if (!((Object)(object)enemy == (Object)null))
			{
				HurtCollider[] componentsInChildren = ((Component)(((Object)(object)enemy.EnemyParent != (Object)null) ? ((Component)enemy.EnemyParent).transform : ((Component)enemy).transform.root)).GetComponentsInChildren<HurtCollider>(true);
				foreach (HurtCollider val in componentsInChildren)
				{
					disarmed.Add(new KeyValuePair<HurtCollider, bool>(val, val.playerLogic));
					val.playerLogic = false;
				}
			}
		}

		private void Rearm()
		{
			foreach (KeyValuePair<HurtCollider, bool> item in disarmed)
			{
				if ((Object)(object)item.Key != (Object)null)
				{
					item.Key.playerLogic = item.Value;
				}
			}
			disarmed.Clear();
		}

		private void HoldEachFrame(double elapsed)
		{
			if ((Object)(object)enemy == (Object)null || !SemiFunc.IsMasterClientOrSingleplayer() || (elapsed - lastHold < 0.5 && lastHold >= 0.0))
			{
				return;
			}
			lastHold = elapsed;
			float num = (float)((double)duration - elapsed) + 0.5f;
			if (num <= 0f)
			{
				return;
			}
			if (enemy.HasStateStunned && (Object)(object)enemy.StateStunned != (Object)null)
			{
				enemy.StateStunned.Set(num);
				if (enemy.StateStunned.stunTimer < num)
				{
					enemy.StateStunned.stunTimer = num;
				}
			}
			else
			{
				enemy.Freeze(num);
			}
			if (enemy.HasNavMeshAgent && (Object)(object)enemy.NavMeshAgent != (Object)null)
			{
				enemy.NavMeshAgent.Stop(0.2f);
			}
		}

		private void ThawPhysics()
		{
			if ((Object)(object)frozenBody != (Object)null)
			{
				frozenBody.isKinematic = bodyWasKinematic;
				frozenBody = null;
			}
		}

		internal void RestoreBase()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			foreach (Bone bone in bones)
			{
				if (!((Object)(object)bone.t == (Object)null) && bone.initialised)
				{
					if (bone.t.localRotation == bone.lastWritten)
					{
						bone.t.localRotation = bone.baseRot;
					}
					if (bone.hasPos && bone.t.localPosition == bone.lastWrittenPos)
					{
						bone.t.localPosition = bone.basePos;
					}
				}
			}
		}

		private void PromoteBodyRoot()
		{
			List<Bone> list = new List<Bone>();
			List<Bone> list2 = new List<Bone>();
			foreach (Bone bone2 in bones)
			{
				if (bone2.depth == 0 && !((Object)(object)bone2.t == (Object)null))
				{
					if (bone2.part == Part.Spine)
					{
						list.Add(bone2);
					}
					else if (bone2.part == Part.Head || (IsLimb(bone2.part) && (Object)(object)bone2.endT != (Object)null && (Object)(object)bone2.endT != (Object)(object)bone2.t))
					{
						list2.Add(bone2);
					}
				}
			}
			if (list.Count == 0 || list2.Count == 0)
			{
				return;
			}
			bool flag = false;
			foreach (Bone item in list2)
			{
				bool flag2 = false;
				foreach (Bone item2 in list)
				{
					if (item.t.IsChildOf(item2.t))
					{
						flag2 = true;
						break;
					}
				}
				if (!flag2)
				{
					flag = true;
					break;
				}
			}
			if (!flag)
			{
				return;
			}
			Transform val = list[0].t;
			foreach (Bone item3 in list)
			{
				val = CommonAncestor(val, item3.t);
			}
			foreach (Bone item4 in list2)
			{
				val = CommonAncestor(val, item4.t);
			}
			if ((Object)(object)val == (Object)null || (!((Object)(object)val == (Object)(object)root) && !val.IsChildOf(root)) || (Object)(object)((Component)val).GetComponent<Rigidbody>() != (Object)null)
			{
				return;
			}
			foreach (Bone item5 in list)
			{
				item5.depth = 1;
			}
			Bone bone = Find(val);
			if (bone != null)
			{
				bone.part = Part.Spine;
				bone.depth = 0;
				bone.hasPos = true;
			}
			else
			{
				bones.Add(new Bone
				{
					t = val,
					part = Part.Spine,
					depth = 0,
					hasPos = true
				});
			}
			if (Plugin.DebugLogBones.Value)
			{
				Plugin.Log.LogDebug((object)("[Dance] body root promoted to " + ((Object)val).name + " (limbs or head were outside the spine)"));
			}
		}

		private Transform PrefabTwin(Transform t)
		{
			if ((Object)(object)t == (Object)null || (Object)(object)enemy == (Object)null)
			{
				return t;
			}
			Transform val = FindPrefabRoot();
			if ((Object)(object)val == (Object)null)
			{
				return t;
			}
			Transform val2 = Twin(root, t, val);
			if (!((Object)(object)val2 != (Object)null))
			{
				return t;
			}
			return val2;
		}

		private Transform FindPrefabRoot()
		{
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)prefabRootCached != (Object)null)
			{
				return prefabRootCached;
			}
			if (prefabRootLooked)
			{
				return null;
			}
			prefabRootLooked = true;
			Transform top = (((Object)(object)enemy.EnemyParent != (Object)null) ? ((Component)enemy.EnemyParent).transform : ((Component)enemy).transform.root);
			string text = EnemyOverrides.Key(enemy);
			GameObject val = null;
			EnemyParent[] array = Resources.FindObjectsOfTypeAll<EnemyParent>();
			foreach (EnemyParent val2 in array)
			{
				if ((Object)(object)val2 == (Object)null)
				{
					continue;
				}
				Scene scene = ((Component)val2).gameObject.scene;
				if (!((Scene)(ref scene)).IsValid())
				{
					string name = ((Object)((Component)val2).gameObject).name;
					if (name == text || name == "Enemy - " + text)
					{
						val = ((Component)val2).gameObject;
						break;
					}
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				if (Plugin.DebugLogBones.Value)
				{
					Plugin.Log.LogDebug((object)("[Dance] no prefab asset found for " + text + "; measuring on the live pose."));
				}
				return null;
			}
			prefabRootCached = Twin(top, root, val.transform);
			return prefabRootCached;
		}

		private void CollectPrefabRest()
		{
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			Transform val = FindPrefabRoot();
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			GameObject gameObject = ((Component)val.root).gameObject;
			HashSet<Transform> hashSet = new HashSet<Transform>();
			foreach (Bone bone in bones)
			{
				if (!((Object)(object)bone.t == (Object)null) && (bone.part == Part.Spine || bone.part == Part.Head))
				{
					Transform val2 = bone.t;
					while ((Object)(object)val2 != (Object)null && (Object)(object)val2 != (Object)(object)root)
					{
						hashSet.Add(val2);
						val2 = val2.parent;
					}
				}
			}
			Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren<Transform>(true);
			foreach (Transform val3 in componentsInChildren)
			{
				if ((Object)(object)val3 == (Object)(object)root || HardSkipRx.IsMatch(((Object)val3).name) || (Object)(object)((Component)val3).GetComponent<Rigidbody>() != (Object)null || (Object)(object)((Component)val3).GetComponent<Joint>() != (Object)null)
				{
					continue;
				}
				bool flag = ((Object)val3).name.IndexOf("code", StringComparison.OrdinalIgnoreCase) >= 0 || ((Object)val3).name.IndexOf("aim", StringComparison.OrdinalIgnoreCase) >= 0;
				if (hashSet.Contains(val3) || flag)
				{
					Transform val4 = Twin(root, val3, val);
					if (!((Object)(object)val4 == (Object)null))
					{
						prefabRest.Add(new RestNode
						{
							t = val3,
							pos = val3.localPosition,
							rot = val4.localRotation,
							startPos = val3.localPosition,
							startRot = val3.localRotation
						});
					}
				}
			}
			if (Plugin.DebugLogBones.Value)
			{
				Plugin.Log.LogDebug((object)$"[Dance] prefab rest pose: {prefabRest.Count} nodes from \"{((Object)gameObject).name}\".");
			}
		}

		private static Transform Twin(Transform top, Transform t, Transform otherTop)
		{
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Expected O, but got Unknown
			List<Transform> list = new List<Transform>();
			Transform val = t;
			while ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)top)
			{
				list.Add(val);
				val = val.parent;
			}
			if (list.Count > 0 && (Object)(object)list[list.Count - 1].parent != (Object)(object)top)
			{
				return null;
			}
			list.Reverse();
			Transform val2 = otherTop;
			foreach (Transform item in list)
			{
				int siblingIndex = item.GetSiblingIndex();
				Transform val3 = ((siblingIndex < val2.childCount && ((Object)val2.GetChild(siblingIndex)).name == ((Object)item).name) ? val2.GetChild(siblingIndex) : null);
				if ((Object)(object)val3 == (Object)null)
				{
					foreach (Transform item2 in val2)
					{
						Transform val4 = item2;
						if (((Object)val4).name == ((Object)item).name)
						{
							val3 = val4;
							break;
						}
					}
				}
				if ((Object)(object)val3 == (Object)null)
				{
					return null;
				}
				val2 = val3;
			}
			return val2;
		}

		private void RerootDetachedLimbs()
		{
			//IL_0119: 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_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			Transform prefabRoot = (((Object)(object)enemy != (Object)null) ? FindPrefabRoot() : null);
			List<Bone> list = new List<Bone>();
			foreach (Bone bone3 in bones)
			{
				if (!IsLimb(bone3.part))
				{
					continue;
				}
				bool flag = false;
				Transform parent = bone3.t.parent;
				while ((Object)(object)parent != (Object)null && (Object)(object)parent != (Object)(object)root)
				{
					Bone bone = Find(parent);
					if (bone != null && bone.part == bone3.part)
					{
						flag = true;
						break;
					}
					parent = parent.parent;
				}
				if (!flag)
				{
					list.Add(bone3);
				}
			}
			foreach (Bone item in list)
			{
				Transform val = P(item.t);
				List<Vector3> list2 = MeshCorners(val);
				if (list2.Count == 0)
				{
					continue;
				}
				float num = 0f;
				foreach (Vector3 item2 in list2)
				{
					num = Mathf.Max(num, Vector3.Distance(item2, val.position));
				}
				Transform val2 = FirstMeshNode(val);
				if ((Object)(object)val2 == (Object)null)
				{
					continue;
				}
				float num2 = float.MaxValue;
				foreach (Vector3 item3 in MeshCorners(val2, selfOnly: true))
				{
					num2 = Mathf.Min(num2, Vector3.Distance(item3, val.position));
				}
				if (num < 0.0001f || num2 <= 0.25f * num)
				{
					continue;
				}
				Bone bone2 = null;
				int num3 = int.MaxValue;
				foreach (Bone bone4 in bones)
				{
					if (bone4 == item || bone4.part != item.part || !bone4.t.IsChildOf(item.t))
					{
						continue;
					}
					Transform val3 = P(bone4.t);
					List<Vector3> list3 = MeshCorners(val3);
					if (list3.Count == 0)
					{
						continue;
					}
					float num4 = float.MaxValue;
					foreach (Vector3 item4 in list3)
					{
						num4 = Mathf.Min(num4, Vector3.Distance(item4, val3.position));
					}
					if (!(num4 > 0.25f * num))
					{
						int num5 = HierarchyDepth(bone4.t);
						if (num5 < num3)
						{
							num3 = num5;
							bone2 = bone4;
						}
					}
				}
				if (bone2 != null)
				{
					bones.Remove(item);
					if (Plugin.DebugLogBones.Value)
					{
						Plugin.Log.LogInfo((object)$"[Dance] limb re-rooted: {((Object)item.t).name} is {num2:F2} m from its mesh, driving {((Object)bone2.t).name} instead");
					}
				}
			}
			Transform P(Transform t)
			{
				if ((Object)(object)prefabRoot == (Object)null)
				{
					return t;
				}
				Transform val4 = Twin(root, t, prefabRoot);
				if (!((Object)(object)val4 != (Object)null))
				{
					return t;
				}
				return val4;
			}
		}

		private static bool UnderHeld(Transform t, Transform limb)
		{
			Transform val = t;
			while ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)limb)
			{
				if (HeldRx.IsMatch(((Object)val).name))
				{
					return true;
				}
				val = val.parent;
			}
			return false;
		}

		private static Transform FirstMeshNode(Transform t)
		{
			Transform result = null;
			int num = int.MaxValue;
			MeshFilter[] componentsInChildren = ((Component)t).GetComponentsInChildren<MeshFilter>(false);
			foreach (MeshFilter val in componentsInChildren)
			{
				if ((Object)(object)val.sharedMesh == (Object)null)
				{
					continue;
				}
				Renderer component = ((Component)val).GetComponent<Renderer>();
				if (!((Object)(object)component == (Object)null) && component.enabled && !HardSkipRx.IsMatch(((Object)((Component)val).transform).name) && !SkipRx.IsMatch(((Object)((Component)val).transform).name) && !UnderHeld(((Component)val).transform, t))
				{
					int num2 = HierarchyDepth(((Component)val).transform);
					if (num2 < num)
					{
						num = num2;
						result = ((Component)val).transform;
					}
				}
			}
			return result;
		}

		private static List<Vector3> MeshCorners(Transform t, bool selfOnly = false)
		{
			//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_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00f6: Unknown result type (might be due to invalid IL or missing references)
			List<Vector3> list = new List<Vector3>();
			MeshFilter[] componentsInChildren = ((Component)t).GetComponentsInChildren<MeshFilter>(false);
			foreach (MeshFilter val in componentsInChildren)
			{
				if ((selfOnly && (Object)(object)((Component)val).transform != (Object)(object)t) || (Object)(object)val.sharedMesh == (Object)null || UnderHeld(((Component)val).transform, t))
				{
					continue;
				}
				Renderer component = ((Component)val).GetComponent<Renderer>();
				if (!((Object)(object)component == (Object)null) && component.enabled && !HardSkipRx.IsMatch(((Object)((Component)val).transform).name) && !SkipRx.IsMatch(((Object)((Component)val).transform).name))
				{
					Bounds bounds = val.sharedMesh.bounds;
					for (int j = 0; j < 8; j++)
					{
						list.Add(((Component)val).transform.TransformPoint(((Bounds)(ref bounds)).center + Vector3.Scale(((Bounds)(ref bounds)).extents, new Vector3((float)((j & 1) * 2 - 1), (float)(((j >> 1) & 1) * 2 - 1), (float)(((j >> 2) & 1) * 2 - 1)))));
					}
				}
			}
			return list;
		}

		private static bool HasMeshOutside(Transform limb, Transform joint)
		{
			bool flag = false;
			Renderer[] componentsInChildren = ((Component)limb).GetComponentsInChildren<Renderer>(false);
			foreach (Renderer val in componentsInChildren)
			{
				if (val.enabled && (val is MeshRenderer || val is SkinnedMeshRenderer))
				{
					flag = true;
					if (!((Component)val).transform.IsChildOf(joint))
					{
						return true;
					}
				}
			}
			return !flag;
		}

		private static Transform CommonAncestor(Transform a, Transform b)
		{
			Transform val = a;
			while ((Object)(object)val != (Object)null)
			{
				if (b.IsChildOf(val))
				{
					return val;
				}
				val = val.parent;
			}
			return null;
		}

		private void SetupAudio()
		{
			if (!((Object)(object)Plugin.DanceClip == (Object)null))
			{
				loopLength = Plugin.DanceClip.length;
				music = ((Component)this).gameObject.AddComponent<AudioSource>();
				music.clip = Plugin.DanceClip;
				music.loop = true;
				music.spatialBlend = 1f;
				music.rolloffMode = (AudioRolloffMode)0;
				music.minDistance = 2f;
				music.maxDistance = 30f;
				music.dopplerLevel = 0f;
				music.volume = Mathf.Clamp01(Plugin.Volume.Value);
				music.playOnAwake = false;
				if ((Object)(object)AudioManager.instance != (Object)null)
				{
					music.outputAudioMixerGroup = AudioManager.instance.SoundMasterGroup;
				}
				float num = (float)((DanceNet.Now - startTime) % (double)loopLength);
				music.time = Mathf.Clamp(num, 0f, loopLength - 0.01f);
				music.Play();
			}
		}

		private void LateUpdate()
		{
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: 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_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: 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_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_044a: Unknown result type (might be due to invalid IL or missing references)
			//IL_044f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0453: Unknown result type (might be due to invalid IL or missing references)
			//IL_0463: Unknown result type (might be due to invalid IL or missing references)
			//IL_047c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0487: Unknown result type (might be due to invalid IL or missing references)
			//IL_0495: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_040a: Unknown result type (might be due to invalid IL or missing references)
			//IL_071b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0596: Unknown result type (might be due to invalid IL or missing references)
			//IL_0389: Unknown result type (might be due to invalid IL or missing references)
			//IL_0395: Unknown result type (might be due to invalid IL or missing references)
			//IL_039a: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a6: 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_03b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_03be: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ab6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0abb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0972: Unknown result type (might be due to invalid IL or missing references)
			//IL_0977: Unknown result type (might be due to invalid IL or missing references)
			//IL_0986: Unknown result type (might be due to invalid IL or missing references)
			//IL_098b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0990: Unknown result type (might be due to invalid IL or missing references)
			//IL_099c: Unknown result type (might be due to invalid IL or missing references)
			//IL_09a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_09b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_09b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_09c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_09c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_09cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_071d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0717: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d5a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d5f: 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_0d7e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d83: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ad2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ad7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a74: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a79: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a88: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a8d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a92: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a9e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aa3: Unknown result type (might be due to invalid IL or missing references)
			//IL_09f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_09f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a02: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a07: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a19: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a1f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a26: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a2d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a33: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a3a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a41: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a46: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a4b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0713: Unknown result type (might be due to invalid IL or missing references)
			//IL_070f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c88: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c8f: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03db: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b96: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b9c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ba3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ba8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bbb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bc0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0605: Unknown result type (might be due to invalid IL or missing references)
			//IL_078d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0792: Unknown result type (might be due to invalid IL or missing references)
			//IL_0780: Unknown result type (might be due to invalid IL or missing references)
			//IL_0785: Unknown result type (might be due to invalid IL or missing references)
			//IL_07a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_07a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_07bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0799: Unknown result type (might be due to invalid IL or missing references)
			//IL_07db: Unknown result type (might be due to invalid IL or missing references)
			//IL_07eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_07fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0800: Unknown result type (might be due to invalid IL or missing references)
			//IL_0802: Unknown result type (might be due to invalid IL or missing references)
			//IL_080b: Unknown result type (might be due to invalid IL or missing references)
			//IL_080d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0811: Unknown result type (might be due to invalid IL or missing references)
			//IL_0818: Unknown result type (might be due to invalid IL or missing references)
			//IL_081d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0822: Unknown result type (might be due to invalid IL or missing references)
			//IL_0824: Unknown result type (might be due to invalid IL or missing references)
			//IL_0826: Unknown result type (might be due to invalid IL or missing references)
			//IL_0828: Unknown result type (might be due to invalid IL or missing references)
			//IL_082d: Unknown result type (might be due to invalid IL or missing references)
			//IL_082f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0831: Unknown result type (might be due to invalid IL or missing references)
			//IL_0833: 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_08e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_08f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_08f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_08c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_08c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0894: Unknown result type (might be due to invalid IL or missing references)
			//IL_0899: Unknown result type (might be due to invalid IL or missing references)
			//IL_089d: Unknown result type (might be due to invalid IL or missing references)
			//IL_08a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_08a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_090d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0912: Unknown result type (might be due to invalid IL or missing references)
			//IL_0914: Unknown result type (might be due to invalid IL or missing references)
			//IL_0919: Unknown result type (might be due to invalid IL or missing references)
			//IL_0922: Unknown result type (might be due to invalid IL or missing references)
			//IL_0927: Unknown result type (might be due to invalid IL or missing references)
			//IL_092b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0937: Unknown result type (might be due to invalid IL or missing references)
			//IL_093c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0856: Unknown result type (might be due to invalid IL or missing references)
			//IL_0858: Unknown result type (might be due to invalid IL or missing references)
			//IL_085a: Unknown result type (might be due to invalid IL or missing references)
			//IL_085f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0868: Unknown result type (might be due to invalid IL or missing references)
			//IL_086d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0871: 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)
			if (!active)
			{
				re