Decompiled source of HoodwinkSurvivor v1.1.1

plugins/HoodwinkSurvivor/HoodwinkSurvivor.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using EntityStates.BrotherMonster;
using EntityStates.Commando.CommandoWeapon;
using EntityStates.Huntress.HuntressWeapon;
using EntityStates.Missions.BrotherEncounter;
using HG;
using HG.BlendableTypes;
using HarmonyLib;
using HoodwinkSurvivor.Attributes;
using HoodwinkSurvivor.Audio;
using HoodwinkSurvivor.Debugging;
using HoodwinkSurvivor.Recording;
using HoodwinkSurvivor.Skills;
using KinematicCharacterController;
using Microsoft.CodeAnalysis;
using R2API;
using RoR2;
using RoR2.Achievements;
using RoR2.CharacterAI;
using RoR2.ConVar;
using RoR2.ContentManagement;
using RoR2.Projectile;
using RoR2.Skills;
using RoR2.Stats;
using RoR2.SurvivorMannequins;
using RoR2.UI;
using RoR2.UI.LogBook;
using TMPro;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.EventSystems;
using UnityEngine.Networking;
using UnityEngine.Rendering;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("HoodwinkSurvivor")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: AssemblyInformationalVersion("1.1.1")]
[assembly: AssemblyProduct("HoodwinkSurvivor")]
[assembly: AssemblyTitle("HoodwinkSurvivor")]
[assembly: AssemblyVersion("1.1.1.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 HoodwinkSurvivor
{
	public sealed class HoodwinkAcornPassive : MonoBehaviour
	{
		public const float BaseCriticalChance = 25f;

		internal void OnPrimaryHit(DamageInfo hit, HurtBox victim, float baseDamage)
		{
			//IL_0055: 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)
			if (NetworkServer.active && hit != null && hit.crit && !hit.rejected && !(hit.damage <= 0f))
			{
				CharacterBody component = ((Component)this).GetComponent<CharacterBody>();
				if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.healthComponent) && component.healthComponent.alive)
				{
					AcornShot.FireOnCriticalHit(component, victim, hit.position, baseDamage, hit.procChainMask);
				}
			}
		}
	}
	internal static class HoodwinkAerialAssets
	{
		internal const string Prefix = "hoodwink_aerial_v24_";

		internal const string ChargePrefix = "hoodwink_aerial_charge_v104_";

		private const string SkeletonHash = "1b8b3d903acc25a049c4d0b5bace2e2bda8148ec3291b89f06ad2d1f6276be52";

		private const int Bones = 202;

		internal static readonly string[] Keys = new string[7] { "crawl_leadin", "crawl_flight", "upright_takeoff", "upright_up", "upright_down", "upright_land", "native_attack" };

		private static readonly int[] Counts = new int[7] { 133, 241, 51, 121, 121, 73, 58 };

		private static readonly float[] Rates = new float[7] { 120f, 120f, 120f, 120f, 120f, 120f, 30f };

		private static readonly bool[] Loops = new bool[7] { false, true, false, true, true, false, false };

		private static readonly string[] Hashes = new string[7] { "a06b29183a57c267f903f42b40d50a1c2bf990b52270c8ac756d05497fe8b2e6", "fa59068290f7a66b1a349367b0dce7d2f39d4270e27d852d68640d7b9e5e2580", "5a152b2e97f0449baea6e8a2acf69cdc05d073b2fdf533c598e78bd061dc38ad", "fc98f281d1c4115a07ba9852352d76b00cf15d47bd96bc85e393b9bbbd843504", "c3447562ec5c52e2ac872c934ee4b88d92eeef51a8a4f2a2ca5e6b17b3badebc", "cd7969be6ffa60f2c793b91eb8d35868049227dea32d08d41bf32f5da2617d75", "7eefb208565fdd903b9341e2b82850e2439f72885ac1b38e6a0d3c8f364acdce" };

		internal static bool IsAvailable(HoodwinkModel.ModelAsset asset)
		{
			string[] keys = Keys;
			foreach (string text in keys)
			{
				if (!asset.Clips.ContainsKey("hoodwink_aerial_v24_" + text))
				{
					return false;
				}
			}
			return true;
		}

		internal static void Load(HoodwinkModel.ModelAsset asset, string directory)
		{
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0272: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0350: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_035e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			//IL_036c: Unknown result type (might be due to invalid IL or missing references)
			//IL_030f: Unknown result type (might be due to invalid IL or missing references)
			//IL_031d: Unknown result type (might be due to invalid IL or missing references)
			//IL_032b: Unknown result type (might be due to invalid IL or missing references)
			if (IsAvailable(asset))
			{
				LoadCharge(asset, directory);
				HoodwinkAerialTailLayer.Load(asset, directory);
				return;
			}
			if (asset.Bones.Length != 202 || Fingerprint(asset) != "1b8b3d903acc25a049c4d0b5bace2e2bda8148ec3291b89f06ad2d1f6276be52")
			{
				throw new InvalidDataException("Approved aerial poses require the exact ordered 202-bone rest skeleton.");
			}
			ValidateBolt(asset);
			List<HoodwinkModel.Clip> list = new List<HoodwinkModel.Clip>(Keys.Length);
			for (int i = 0; i < Keys.Length; i++)
			{
				byte[] array = File.ReadAllBytes(Path.Combine(directory, "hoodwink_aerial_v24_" + Keys[i] + ".bin"));
				if (Hash(array) != Hashes[i])
				{
					throw new InvalidDataException("Approved aerial source hash differs: " + Keys[i]);
				}
				using BinaryReader binaryReader = new BinaryReader(new MemoryStream(array, writable: false), Encoding.UTF8);
				float num = (float)(Counts[i] - 1) / Rates[i];
				if (Encoding.ASCII.GetString(binaryReader.ReadBytes(4)) != "HWEL" || binaryReader.ReadInt32() != 1 || binaryReader.ReadInt32() != 202 || binaryReader.ReadInt32() != 1 || binaryReader.ReadInt32() != Counts[i] || Number(binaryReader) != Rates[i] || Number(binaryReader) != num || array.Length != 28 + Counts[i] * 202 * 40)
				{
					throw new InvalidDataException("Approved aerial HWEL header or timing differs.");
				}
				HoodwinkModel.Clip clip = new HoodwinkModel.Clip
				{
					Name = "hoodwink_aerial_v24_" + Keys[i],
					Frames = Counts[i],
					Fps = Rates[i],
					Duration = num,
					Loop = Loops[i],
					Samples = new HoodwinkModel.Pose[Counts[i] * 202]
				};
				for (int j = 0; j < clip.Samples.Length; j++)
				{
					HoodwinkModel.Pose pose = new HoodwinkModel.Pose
					{
						Position = new Vector3(Number(binaryReader), Number(binaryReader), Number(binaryReader)),
						Rotation = new Quaternion(Number(binaryReader), Number(binaryReader), Number(binaryReader), Number(binaryReader)),
						Scale = new Vector3(Number(binaryReader), Number(binaryReader), Number(binaryReader))
					};
					if (pose.Scale.x <= 0f || pose.Scale.y <= 0f || pose.Scale.z <= 0f || Mathf.Abs(Quaternion.Dot(pose.Rotation, pose.Rotation) - 1f) > 0.005f)
					{
						throw new InvalidDataException("Invalid approved aerial quaternion or scale.");
					}
					if (((Vector3)(ref pose.Position)).sqrMagnitude > 25f)
					{
						int num2 = j / 202;
						int num3 = j % 202;
						Vector3 position = pose.Position;
						bool num4 = i == 6 && num3 == 175 && num2 >= 12 && num2 <= 26 && position.x >= -0.25f && position.x <= -0.23f && position.y >= -0.001f && position.y <= 0.001f && position.z >= 227f && position.z <= 229f;
						bool flag = i >= 2 && i <= 5 && num3 == 175 && position.x == -0.79870874f && position.y == 1.3446478E-07f && position.z == 91.76425f;
						if (!num4 && !flag)
						{
							throw new InvalidDataException("Aerial position exceeds the native unweighted bolt exception.");
						}
					}
					clip.Samples[j] = pose;
				}
				if (binaryReader.BaseStream.Position != binaryReader.BaseStream.Length)
				{
					throw new InvalidDataException("Trailing aerial bytes.");
				}
				if (clip.Loop)
				{
					for (int k = 0; k < 8080; k++)
					{
						if (array[28 + k] != array[array.Length - 8080 + k])
						{
							throw new InvalidDataException("Approved aerial loop endpoint bytes differ.");
						}
					}
				}
				if (asset.Clips.ContainsKey(clip.Name))
				{
					throw new InvalidDataException("Partial/duplicate aerial bank.");
				}
				if (i == 6)
				{
					if (!asset.Clips.TryGetValue("attack", out HoodwinkModel.Clip value) || value.Frames != 58 || value.Fps != 30f)
					{
						throw new InvalidDataException("Native aerial primary source is unavailable.");
					}
					using MemoryStream memoryStream = new MemoryStream();
					using (BinaryWriter writer = new BinaryWriter(memoryStream, Encoding.UTF8, leaveOpen: true))
					{
						HoodwinkModel.Pose[] samples = value.Samples;
						foreach (HoodwinkModel.Pose p in samples)
						{
							WritePose(writer, p);
						}
					}
					byte[] array2 = new byte[array.Length - 28];
					Array.Copy(array, 28, array2, 0, array2.Length);
					if (Hash(memoryStream.ToArray()) != Hash(array2))
					{
						throw new InvalidDataException("Approved aerial primary is not the exact native source.");
					}
				}
				list.Add(clip);
			}
			foreach (HoodwinkModel.Clip item in list)
			{
				asset.Clips.Add(item.Name, item);
			}
			LoadCharge(asset, directory);
			HoodwinkAerialTailLayer.Load(asset, directory);
			HoodwinkPlugin.Log.LogInfo((object)"Approved V56/V58 aerial poses loaded; V59 transitions use live pose, aim and skill timing.");
		}

		internal static bool IsChargeAvailable(HoodwinkModel.ModelAsset asset)
		{
			if (asset.Clips.ContainsKey("hoodwink_aerial_charge_v104_charge"))
			{
				return asset.Clips.ContainsKey("hoodwink_aerial_charge_v104_release");
			}
			return false;
		}

		private static void LoadCharge(HoodwinkModel.ModelAsset asset, string directory)
		{
			//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_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_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			if (IsChargeAvailable(asset))
			{
				return;
			}
			string[] array = new string[2] { "charge", "release" };
			int[] array2 = new int[2] { 61, 205 };
			float[] array3 = new float[2] { 30f, 120f };
			string[] array4 = new string[2] { "29a73455b8dd2ad2e7f71561f7b80079475301b3e831f493fb2ec835a543db50", "60a2de9f44a251d7362dce52024411328f052edcc289bd4182643b15228284af" };
			List<HoodwinkModel.Clip> list = new List<HoodwinkModel.Clip>(2);
			for (int i = 0; i < array.Length; i++)
			{
				byte[] array5 = File.ReadAllBytes(Path.Combine(directory, "hoodwink_aerial_charge_v104_" + array[i] + ".bin"));
				if (Hash(array5) != array4[i])
				{
					throw new InvalidDataException("Approved air charge source hash differs: " + array[i]);
				}
				using BinaryReader binaryReader = new BinaryReader(new MemoryStream(array5, writable: false), Encoding.UTF8);
				float num = (float)(array2[i] - 1) / array3[i];
				if (Encoding.ASCII.GetString(binaryReader.ReadBytes(4)) != "HWEL" || binaryReader.ReadInt32() != 1 || binaryReader.ReadInt32() != 202 || binaryReader.ReadInt32() != 1 || binaryReader.ReadInt32() != array2[i] || Number(binaryReader) != array3[i] || Number(binaryReader) != num || array5.Length != 28 + array2[i] * 202 * 40)
				{
					throw new InvalidDataException("Approved air charge HWEL header differs.");
				}
				HoodwinkModel.Clip clip = new HoodwinkModel.Clip
				{
					Name = "hoodwink_aerial_charge_v104_" + array[i],
					Frames = array2[i],
					Fps = array3[i],
					Duration = num,
					Loop = (i == 0),
					Samples = new HoodwinkModel.Pose[array2[i] * 202]
				};
				for (int j = 0; j < clip.Samples.Length; j++)
				{
					HoodwinkModel.Pose pose = new HoodwinkModel.Pose
					{
						Position = new Vector3(Number(binaryReader), Number(binaryReader), Number(binaryReader)),
						Rotation = new Quaternion(Number(binaryReader), Number(binaryReader), Number(binaryReader), Number(binaryReader)),
						Scale = new Vector3(Number(binaryReader), Number(binaryReader), Number(binaryReader))
					};
					if (pose.Scale.x <= 0f || pose.Scale.y <= 0f || pose.Scale.z <= 0f || Mathf.Abs(Quaternion.Dot(pose.Rotation, pose.Rotation) - 1f) > 0.005f)
					{
						throw new InvalidDataException("Invalid approved air charge pose.");
					}
					clip.Samples[j] = pose;
				}
				if (clip.Loop)
				{
					for (int k = 0; k < 8080; k++)
					{
						if (array5[28 + k] != array5[array5.Length - 8080 + k])
						{
							throw new InvalidDataException("Approved air charge loop endpoint differs.");
						}
					}
				}
				if (asset.Clips.ContainsKey(clip.Name))
				{
					throw new InvalidDataException("Partial air charge bank.");
				}
				list.Add(clip);
			}
			foreach (HoodwinkModel.Clip item in list)
			{
				asset.Clips.Add(item.Name, item);
			}
		}

		private static float Number(BinaryReader reader)
		{
			float num = reader.ReadSingle();
			if (float.IsNaN(num) || float.IsInfinity(num))
			{
				throw new InvalidDataException("Nonfinite aerial value.");
			}
			return num;
		}

		private static void WritePose(BinaryWriter writer, HoodwinkModel.Pose p)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: 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)
			writer.Write(p.Position.x);
			writer.Write(p.Position.y);
			writer.Write(p.Position.z);
			writer.Write(p.Rotation.x);
			writer.Write(p.Rotation.y);
			writer.Write(p.Rotation.z);
			writer.Write(p.Rotation.w);
			writer.Write(p.Scale.x);
			writer.Write(p.Scale.y);
			writer.Write(p.Scale.z);
		}

		private static string Fingerprint(HoodwinkModel.ModelAsset asset)
		{
			using MemoryStream memoryStream = new MemoryStream();
			using (BinaryWriter binaryWriter = new BinaryWriter(memoryStream, Encoding.UTF8, leaveOpen: true))
			{
				HoodwinkModel.Bone[] bones = asset.Bones;
				foreach (HoodwinkModel.Bone bone in bones)
				{
					byte[] bytes = Encoding.UTF8.GetBytes(bone.Name);
					binaryWriter.Write(bone.Parent);
					binaryWriter.Write(bytes.Length);
					binaryWriter.Write(bytes);
					WritePose(binaryWriter, bone.Rest);
				}
			}
			return Hash(memoryStream.ToArray());
		}

		private static void ValidateBolt(HoodwinkModel.ModelAsset asset)
		{
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			if (asset.Bones[175].Name != "crossbow_bolt_0" || asset.Bones[175].Parent != 174 || asset.Bones[176].Name != "crossbow_bolt_end" || asset.Bones[176].Parent != 175)
			{
				throw new InvalidDataException("Aerial bolt semantics differ.");
			}
			HoodwinkModel.Part[] parts = asset.Parts;
			for (int i = 0; i < parts.Length; i++)
			{
				BoneWeight[] boneWeights = parts[i].Mesh.boneWeights;
				for (int j = 0; j < boneWeights.Length; j++)
				{
					BoneWeight val = boneWeights[j];
					if ((((BoneWeight)(ref val)).weight0 > 0f && (((BoneWeight)(ref val)).boneIndex0 == 175 || ((BoneWeight)(ref val)).boneIndex0 == 176)) || (((BoneWeight)(ref val)).weight1 > 0f && (((BoneWeight)(ref val)).boneIndex1 == 175 || ((BoneWeight)(ref val)).boneIndex1 == 176)) || (((BoneWeight)(ref val)).weight2 > 0f && (((BoneWeight)(ref val)).boneIndex2 == 175 || ((BoneWeight)(ref val)).boneIndex2 == 176)) || (((BoneWeight)(ref val)).weight3 > 0f && (((BoneWeight)(ref val)).boneIndex3 == 175 || ((BoneWeight)(ref val)).boneIndex3 == 176)))
					{
						throw new InvalidDataException("Aerial bolt is unexpectedly weighted to visible geometry.");
					}
				}
			}
		}

		private static string Hash(byte[] bytes)
		{
			using SHA256 sHA = SHA256.Create();
			return BitConverter.ToString(sHA.ComputeHash(bytes)).Replace("-", "").ToLowerInvariant();
		}
	}
	internal sealed class HoodwinkAerialController
	{
		internal struct Frame
		{
			internal float Delta;

			internal float VerticalVelocity;

			internal float NormalizedAttack;

			internal float AttackSpeed;

			internal float ChargeTime;

			internal float ReleaseTime;

			internal float TailTime;

			internal float GroundIdleTime;

			internal bool Grounded;

			internal bool NewJump;

			internal bool PreferUpright;

			internal bool PrimaryActive;

			internal bool AllowLanding;

			internal bool PriorityBlocked;

			internal bool ReturnAllowed;

			internal bool ChargeActive;

			internal bool ReleaseActive;

			internal bool CompactAttack;

			internal Quaternion LocalAim;
		}

		private enum Route
		{
			None,
			CrawlLead,
			Crawl,
			UprightTakeoff,
			Upright,
			Attack,
			Return,
			Landing,
			Charge,
			Release
		}

		private const float CrawlWalkoffStart = 0.5f;

		private const float CrawlWalkoffBlend = 0.28f;

		private readonly HoodwinkModel.ModelAsset asset;

		private readonly HoodwinkModel.Clip lead;

		private readonly HoodwinkModel.Clip flight;

		private readonly HoodwinkModel.Clip takeoff;

		private readonly HoodwinkModel.Clip up;

		private readonly HoodwinkModel.Clip down;

		private readonly HoodwinkModel.Clip land;

		private readonly HoodwinkModel.Clip attack;

		private readonly HoodwinkModel.Clip? charge;

		private readonly HoodwinkModel.Clip? release;

		private readonly HoodwinkAerialTransition transition;

		private readonly HoodwinkAerialTailLayer? tailLayer;

		private readonly HoodwinkModel.Pose[] groundTailTarget;

		private readonly HoodwinkModel.Pose[] target;

		private readonly HoodwinkModel.Pose[] pastTarget;

		private readonly HoodwinkModel.Pose[] lowerScratch;

		private readonly HoodwinkModel.Pose[] nativeScratch;

		private readonly HoodwinkModel.Pose[] compactReady;

		private readonly HoodwinkModel.Pose[] crawlWalkoffSource;

		private readonly Matrix4x4[] crawlWalkoffWorld;

		private readonly Vector3[] crawlWalkoffRotation;

		private readonly Matrix4x4[] nativeWorld;

		private readonly Matrix4x4[] poseWorld;

		private readonly Matrix4x4[] jumpWorld;

		private readonly bool[] upper;

		private readonly Quaternion calibration;

		private readonly Quaternion chargeCalibration;

		private Route route;

		private Frame previousFrame;

		private bool havePreviousFrame;

		private bool crawlWalkoffBlending;

		private float crawlEntryStart;

		private float crawlEntryDuration;

		private float routeTime;

		private float crawlClock;

		private float uprightClock;

		private float previousNormalized;

		private float tailClock;

		internal bool Active => route != Route.None;

		internal bool IsSharpshooter
		{
			get
			{
				if (route != Route.Charge)
				{
					return route == Route.Release;
				}
				return true;
			}
		}

		internal bool SupportsCharge
		{
			get
			{
				if (charge != null)
				{
					return release != null;
				}
				return false;
			}
		}

		internal bool IsUpright
		{
			get
			{
				if (route != Route.UprightTakeoff && route != Route.Upright && route != Route.Attack && route != Route.Return && route != Route.Landing && route != Route.Charge)
				{
					return route == Route.Release;
				}
				return true;
			}
		}

		internal string Phase => route.ToString();

		internal float CrawlPhase => Mathf.Repeat(crawlClock, flight.Duration);

		internal float UprightPhase => Mathf.Repeat(uprightClock, up.Duration);

		internal float TailPhase => tailClock;

		internal HoodwinkAerialController(HoodwinkModel.ModelAsset asset)
		{
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: 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_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02de: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
			this.asset = asset;
			if (!HoodwinkAerialAssets.IsAvailable(asset))
			{
				throw new InvalidOperationException("The approved aerial bank is unavailable.");
			}
			lead = Clip("crawl_leadin");
			flight = Clip("crawl_flight");
			takeoff = Clip("upright_takeoff");
			up = Clip("upright_up");
			down = Clip("upright_down");
			land = Clip("upright_land");
			attack = Clip("native_attack");
			if (HoodwinkAerialAssets.IsChargeAvailable(asset))
			{
				charge = asset.Clips["hoodwink_aerial_charge_v104_charge"];
				release = asset.Clips["hoodwink_aerial_charge_v104_release"];
			}
			int num = asset.Bones.Length;
			target = new HoodwinkModel.Pose[num];
			pastTarget = new HoodwinkModel.Pose[num];
			lowerScratch = new HoodwinkModel.Pose[num];
			nativeScratch = new HoodwinkModel.Pose[num];
			compactReady = new HoodwinkModel.Pose[num];
			crawlWalkoffSource = new HoodwinkModel.Pose[num];
			crawlWalkoffWorld = (Matrix4x4[])(object)new Matrix4x4[num];
			crawlWalkoffRotation = (Vector3[])(object)new Vector3[num];
			groundTailTarget = new HoodwinkModel.Pose[num];
			tailLayer = HoodwinkAerialTailLayer.Create(asset);
			nativeWorld = (Matrix4x4[])(object)new Matrix4x4[num];
			poseWorld = (Matrix4x4[])(object)new Matrix4x4[num];
			jumpWorld = (Matrix4x4[])(object)new Matrix4x4[num];
			upper = new bool[num];
			for (int i = 0; i < num; i++)
			{
				upper[i] = asset.Bones[i].Name.StartsWith("spine_", StringComparison.Ordinal) || i == 174 || i == 200 || (asset.Bones[i].Parent >= 0 && upper[asset.Bones[i].Parent]);
			}
			HoodwinkAerialMath.Sample(attack, 0.2f * attack.Duration, nativeScratch);
			HoodwinkAerialMath.World(asset, nativeScratch, nativeWorld);
			Vector3 val = Vector4.op_Implicit(((Matrix4x4)(ref nativeWorld[176])).GetColumn(3)) - Vector4.op_Implicit(((Matrix4x4)(ref nativeWorld[175])).GetColumn(3));
			calibration = HoodwinkAerialMath.Align(val, Vector3.forward);
			chargeCalibration = Quaternion.identity;
			if (charge != null)
			{
				HoodwinkAerialMath.Sample(charge, 0f, nativeScratch);
				HoodwinkAerialMath.World(asset, nativeScratch, nativeWorld);
				val = Vector4.op_Implicit(((Matrix4x4)(ref nativeWorld[176])).GetColumn(3)) - Vector4.op_Implicit(((Matrix4x4)(ref nativeWorld[175])).GetColumn(3));
				chargeCalibration = HoodwinkAerialMath.Align(val, Vector3.forward);
			}
			transition = new HoodwinkAerialTransition(asset);
		}

		private HoodwinkModel.Clip Clip(string name)
		{
			return asset.Clips["hoodwink_aerial_v24_" + name];
		}

		internal void Reset()
		{
			route = Route.None;
			routeTime = (crawlClock = (uprightClock = (previousNormalized = (tailClock = 0f))));
			havePreviousFrame = (crawlWalkoffBlending = false);
			transition.Reset();
		}

		internal bool TryCompose(Frame frame, HoodwinkModel.Pose[] displayed, HoodwinkModel.Pose[] previousDisplayed, float displayedDelta, HoodwinkModel.Pose[] destination)
		{
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: 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_0152: Unknown result type (might be due to invalid IL or missing references)
			if (displayed.Length != asset.Bones.Length || previousDisplayed.Length != displayed.Length || destination.Length != displayed.Length)
			{
				throw new ArgumentException("Aerial rendered-pose rig differs.");
			}
			float num = (Finite(frame.Delta) ? Mathf.Max(0f, frame.Delta) : 0f);
			frame.AttackSpeed = (Finite(frame.AttackSpeed) ? Mathf.Max(0.1f, frame.AttackSpeed) : 1f);
			frame.NormalizedAttack = (Finite(frame.NormalizedAttack) ? Mathf.Clamp01(frame.NormalizedAttack) : 0f);
			frame.ChargeTime = (Finite(frame.ChargeTime) ? frame.ChargeTime : 0f);
			frame.ReleaseTime = (Finite(frame.ReleaseTime) ? frame.ReleaseTime : 0f);
			frame.GroundIdleTime = (Finite(frame.GroundIdleTime) ? frame.GroundIdleTime : 0f);
			if (!Finite(frame.VerticalVelocity))
			{
				frame.VerticalVelocity = 0f;
			}
			float num2 = Quaternion.Dot(frame.LocalAim, frame.LocalAim);
			frame.LocalAim = ((Finite(num2) && num2 > 1E-06f) ? ((Quaternion)(ref frame.LocalAim)).normalized : Quaternion.identity);
			crawlClock += num;
			uprightClock += num;
			routeTime += num;
			transition.Advance(num);
			tailClock = Mathf.Repeat(tailClock + num, 7.9333334f);
			frame.TailTime = tailClock;
			bool flag = havePreviousFrame && previousFrame.PrimaryActive;
			if (frame.PriorityBlocked)
			{
				Cancel(frame);
				return false;
			}
			if (!frame.Grounded && SupportsCharge && (frame.ChargeActive || frame.ReleaseActive))
			{
				Route route = (frame.ReleaseActive ? Route.Release : Route.Charge);
				if (this.route != route)
				{
					float duration = ((route == Route.Release) ? 0.08f : ((this.route == Route.Crawl || this.route == Route.CrawlLead) ? 0.55f : ((this.route == Route.Attack) ? 0.3f : 0.35f)));
					Begin(route, duration, frame, displayed, previousDisplayed, displayedDelta);
				}
			}
			else if (frame.Grounded)
			{
				if (this.route == Route.UprightTakeoff || this.route == Route.Upright || this.route == Route.Attack || this.route == Route.Return)
				{
					Cancel(frame);
					return false;
				}
				if (!frame.AllowLanding || frame.PrimaryActive || !Active)
				{
					Cancel(frame);
					return false;
				}
				if (this.route != Route.Landing)
				{
					if (!IsUpright)
					{
						Cancel(frame);
						return false;
					}
					Begin(Route.Landing, 0.24f, frame, displayed, previousDisplayed, displayedDelta);
				}
				else if (routeTime >= land.Duration)
				{
					Cancel(frame);
					return false;
				}
			}
			else
			{
				bool flag2 = this.route == Route.Release;
				if (this.route == Route.Charge)
				{
					Begin(Route.Upright, 0.35f, frame, displayed, previousDisplayed, displayedDelta);
				}
				else if (flag2)
				{
					Begin(Route.Upright, 0.45f, frame, displayed, previousDisplayed, displayedDelta);
				}
				if (!Active || this.route == Route.Landing || frame.NewJump)
				{
					bool flag3 = havePreviousFrame && previousFrame.Grounded && !frame.NewJump && !frame.PreferUpright && !frame.PrimaryActive;
					if (frame.NewJump)
					{
						if (frame.PreferUpright)
						{
							uprightClock = 0f - takeoff.Duration;
						}
						else
						{
							crawlClock = 0f - lead.Duration;
						}
					}
					else if (flag3)
					{
						crawlClock = 0.5f - lead.Duration;
					}
					Route next = ((!frame.PreferUpright) ? ((frame.NewJump || flag3) ? Route.CrawlLead : Route.Crawl) : (frame.NewJump ? Route.UprightTakeoff : Route.Upright));
					Begin(next, flag3 ? 0.28f : 0.12f, frame, displayed, previousDisplayed, displayedDelta, flag3 ? 0.5f : 0f);
				}
				if (frame.PrimaryActive)
				{
					bool flag4 = !flag || frame.NormalizedAttack < previousNormalized - 0.005f;
					if (this.route != Route.Attack || flag4)
					{
						Begin(Route.Attack, flag2 ? 0.45f : EntryDuration(frame.AttackSpeed), frame, displayed, previousDisplayed, displayedDelta);
					}
				}
				else
				{
					if (this.route == Route.Attack)
					{
						Begin(Route.Upright, 0.16f, frame, displayed, previousDisplayed, displayedDelta);
					}
					if (frame.ReturnAllowed && (this.route == Route.Upright || this.route == Route.UprightTakeoff))
					{
						Begin(Route.Return, flag2 ? 0.45f : 0.55f, frame, displayed, previousDisplayed, displayedDelta);
					}
					else if (this.route == Route.CrawlLead && routeTime >= lead.Duration)
					{
						this.route = Route.Crawl;
					}
					else if (this.route == Route.UprightTakeoff && routeTime >= takeoff.Duration)
					{
						Begin(Route.Upright, 0.12f, frame, displayed, previousDisplayed, displayedDelta);
					}
					else if (this.route == Route.Return && routeTime >= 0.55f)
					{
						this.route = Route.Crawl;
					}
				}
			}
			Evaluate(this.route, routeTime, crawlClock, uprightClock, frame, target);
			if (crawlWalkoffBlending)
			{
				ComposeCrawlWalkoff(destination);
			}
			else
			{
				transition.Apply(target, destination);
			}
			previousFrame = frame;
			havePreviousFrame = true;
			previousNormalized = frame.NormalizedAttack;
			return true;
		}

		private void Cancel(Frame frame)
		{
			route = Route.None;
			routeTime = 0f;
			crawlWalkoffBlending = false;
			transition.Reset();
			previousFrame = frame;
			havePreviousFrame = true;
			previousNormalized = frame.NormalizedAttack;
		}

		private void Begin(Route next, float duration, Frame frame, HoodwinkModel.Pose[] source, HoodwinkModel.Pose[] previous, float sourceDelta, float startSeconds = 0f)
		{
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			route = next;
			routeTime = startSeconds;
			Evaluate(next, startSeconds, crawlClock, uprightClock, frame, target);
			crawlWalkoffBlending = next == Route.CrawlLead;
			if (crawlWalkoffBlending)
			{
				crawlEntryStart = startSeconds;
				crawlEntryDuration = Mathf.Max(1E-06f, duration);
				Array.Copy(source, crawlWalkoffSource, source.Length);
				HoodwinkAerialMath.World(asset, source, crawlWalkoffWorld);
				HoodwinkAerialMath.World(asset, target, nativeWorld);
				for (int i = 0; i < source.Length; i++)
				{
					crawlWalkoffRotation[i] = HoodwinkAerialMath.Log(Quaternion.Inverse(((Matrix4x4)(ref nativeWorld[i])).rotation) * ((Matrix4x4)(ref crawlWalkoffWorld[i])).rotation);
				}
				transition.Reset();
			}
			else
			{
				Frame frame2 = (havePreviousFrame ? previousFrame : frame);
				frame2.NormalizedAttack = Mathf.Clamp01(frame.NormalizedAttack - Mathf.Max(0f, sourceDelta) * frame.AttackSpeed / 2f);
				frame2.CompactAttack = frame.CompactAttack;
				frame2.ChargeTime = frame.ChargeTime - sourceDelta;
				frame2.ReleaseTime = frame.ReleaseTime - sourceDelta;
				frame2.TailTime = frame.TailTime - sourceDelta;
				frame2.GroundIdleTime = frame.GroundIdleTime - sourceDelta;
				Evaluate(next, startSeconds - sourceDelta, crawlClock - sourceDelta, uprightClock - sourceDelta, frame2, pastTarget);
				transition.Begin(source, previous, target, pastTarget, duration, sourceDelta, next == Route.Attack || next == Route.Charge);
			}
		}

		private void ComposeCrawlWalkoff(HoodwinkModel.Pose[] destination)
		{
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: 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_01d9: 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_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: 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_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: 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_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Clamp01((routeTime - crawlEntryStart) / crawlEntryDuration);
			if (num >= 1f)
			{
				Array.Copy(target, destination, target.Length);
				crawlWalkoffBlending = false;
				return;
			}
			float num2 = num * num * num * (10f - 15f * num + 6f * num * num);
			HoodwinkAerialMath.World(asset, target, nativeWorld);
			for (int i = 0; i < destination.Length; i++)
			{
				HoodwinkModel.Pose pose = HoodwinkAerialMath.Blend(crawlWalkoffSource[i], target[i], num2);
				Quaternion val = ((Matrix4x4)(ref nativeWorld[i])).rotation * HoodwinkAerialMath.Exp(crawlWalkoffRotation[i] * (1f - num2));
				int parent = asset.Bones[i].Parent;
				pose.Rotation = ((parent < 0) ? val : (Quaternion.Inverse(((Matrix4x4)(ref poseWorld[parent])).rotation) * val));
				destination[i] = pose;
				Matrix4x4 val2 = Matrix4x4.TRS(pose.Position, pose.Rotation, pose.Scale);
				poseWorld[i] = ((parent < 0) ? val2 : (poseWorld[parent] * val2));
			}
			Matrix4x4 inverse = ((Matrix4x4)(ref crawlWalkoffWorld[174])).inverse;
			Vector3 val3 = ((Matrix4x4)(ref inverse)).MultiplyPoint3x4(Vector4.op_Implicit(((Matrix4x4)(ref crawlWalkoffWorld[43])).GetColumn(3)));
			inverse = ((Matrix4x4)(ref nativeWorld[174])).inverse;
			Vector3 val4 = ((Matrix4x4)(ref inverse)).MultiplyPoint3x4(Vector4.op_Implicit(((Matrix4x4)(ref nativeWorld[43])).GetColumn(3)));
			Vector3 val5 = Vector3.Lerp(val3, val4, num2);
			Vector3 val6 = Vector4.op_Implicit(((Matrix4x4)(ref poseWorld[43])).GetColumn(3)) - ((Matrix4x4)(ref poseWorld[174])).MultiplyVector(val5);
			int parent2 = asset.Bones[174].Parent;
			ref HoodwinkModel.Pose reference = ref destination[174];
			Vector3 position;
			if (parent2 >= 0)
			{
				inverse = ((Matrix4x4)(ref poseWorld[parent2])).inverse;
				position = ((Matrix4x4)(ref inverse)).MultiplyPoint3x4(val6);
			}
			else
			{
				position = val6;
			}
			reference.Position = position;
		}

		private void Evaluate(Route mode, float seconds, float crawl, float upright, Frame frame, HoodwinkModel.Pose[] destination)
		{
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: 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_0238: Unknown result type (might be due to invalid IL or missing references)
			switch (mode)
			{
			case Route.Charge:
			case Route.Release:
			{
				HoodwinkAerialMath.Sample((mode == Route.Charge) ? charge : release, (mode == Route.Charge) ? frame.ChargeTime : frame.ReleaseTime, destination);
				Array.Copy(destination, nativeScratch, destination.Length);
				HoodwinkAerialMath.World(asset, nativeScratch, nativeWorld);
				ref HoodwinkModel.Pose reference = ref destination[1];
				Matrix4x4 val = Matrix4x4.TRS(destination[0].Position, destination[0].Rotation, destination[0].Scale);
				reference.Rotation = Quaternion.Inverse(((Matrix4x4)(ref val)).rotation) * frame.LocalAim * chargeCalibration * ((Matrix4x4)(ref nativeWorld[1])).rotation;
				HoodwinkAerialMath.World(asset, destination, poseWorld);
				TransferCarrier(174, destination);
				TransferCarrier(200, destination);
				break;
			}
			case Route.CrawlLead:
				HoodwinkAerialMath.Sample(lead, seconds, destination);
				break;
			case Route.Crawl:
			case Route.Return:
				HoodwinkAerialMath.Sample(flight, crawl, destination);
				break;
			case Route.UprightTakeoff:
				HoodwinkAerialMath.Sample(takeoff, seconds, destination);
				break;
			case Route.Landing:
				HoodwinkAerialMath.Sample(land, seconds, destination);
				break;
			default:
			{
				HoodwinkAerialMath.Sample(down, upright, destination);
				HoodwinkAerialMath.Sample(up, upright, lowerScratch);
				float t = Mathf.Clamp01((frame.VerticalVelocity + 8f) / 16f);
				for (int i = 0; i < destination.Length; i++)
				{
					destination[i] = HoodwinkAerialMath.Blend(destination[i], lowerScratch[i], t);
				}
				if (mode == Route.Attack)
				{
					ComposePrimaryUpper(HoodwinkCompactAttack.SourcePhase(frame.NormalizedAttack, frame.CompactAttack), upright, frame.LocalAim, destination);
					float num = HoodwinkCompactAttack.ReadyWeight(frame.NormalizedAttack, frame.CompactAttack);
					if (num > 0f)
					{
						ComposeUpright(upright, frame.VerticalVelocity, compactReady);
						ComposePrimaryUpper(0f, upright, frame.LocalAim, compactReady);
						HoodwinkCompactAttack.BlendUpper(destination, compactReady, upper, num);
					}
				}
				break;
			}
			}
			if (mode == Route.UprightTakeoff || mode == Route.Upright)
			{
				ComposePrimaryUpper(0.2f, upright, Quaternion.identity, destination);
			}
			if (tailLayer != null)
			{
				switch (mode)
				{
				case Route.UprightTakeoff:
				case Route.Upright:
				case Route.Attack:
				case Route.Charge:
				case Route.Release:
					tailLayer.Apply(destination, frame.TailTime);
					break;
				case Route.Landing:
				{
					HoodwinkAerialMath.Sample(asset.Clips["idle"], frame.GroundIdleTime, groundTailTarget);
					float num2 = Mathf.Clamp01(seconds / land.Duration);
					float num3 = num2 * num2 * num2 * (10f - 15f * num2 + 6f * num2 * num2);
					tailLayer.Apply(destination, frame.TailTime, 1f - num3, groundTailTarget);
					break;
				}
				}
			}
		}

		private void ComposeUpright(float upright, float verticalVelocity, HoodwinkModel.Pose[] destination)
		{
			HoodwinkAerialMath.Sample(down, upright, destination);
			HoodwinkAerialMath.Sample(up, upright, lowerScratch);
			float t = Mathf.Clamp01((verticalVelocity + 8f) / 16f);
			for (int i = 0; i < destination.Length; i++)
			{
				destination[i] = HoodwinkAerialMath.Blend(destination[i], lowerScratch[i], t);
			}
		}

		private void ComposePrimaryUpper(float phase, float upright, Quaternion localAim, HoodwinkModel.Pose[] destination)
		{
			//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_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: 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_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: 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)
			Vector3 position = destination[1].Position;
			HoodwinkAerialMath.Sample(attack, phase * attack.Duration, nativeScratch);
			HoodwinkAerialMath.World(asset, nativeScratch, nativeWorld);
			for (int i = 0; i < destination.Length; i++)
			{
				if (upper[i])
				{
					destination[i] = nativeScratch[i];
				}
			}
			destination[1].Position = position;
			ref HoodwinkModel.Pose reference = ref destination[1];
			Matrix4x4 val = Matrix4x4.TRS(destination[0].Position, destination[0].Rotation, destination[0].Scale);
			reference.Rotation = Quaternion.Inverse(((Matrix4x4)(ref val)).rotation) * localAim * calibration * ((Matrix4x4)(ref nativeWorld[1])).rotation;
			HoodwinkAerialMath.World(asset, destination, poseWorld);
			TransferCarrier(174, destination);
			TransferCarrier(200, destination);
			HoodwinkAerialMath.Sample(up, upright, lowerScratch);
			HoodwinkAerialMath.World(asset, lowerScratch, jumpWorld);
			HoodwinkAerialMath.World(asset, destination, poseWorld);
			for (int j = 147; j < 159; j++)
			{
				destination[j].Rotation = ((j == 147 || j == 153) ? (Quaternion.Inverse(((Matrix4x4)(ref poseWorld[asset.Bones[j].Parent])).rotation) * ((Matrix4x4)(ref jumpWorld[j])).rotation) : lowerScratch[j].Rotation);
			}
		}

		private void TransferCarrier(int bone, HoodwinkModel.Pose[] destination)
		{
			//IL_001d: 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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			Matrix4x4 val = ((Matrix4x4)(ref poseWorld[asset.Bones[bone].Parent])).inverse * poseWorld[4] * ((Matrix4x4)(ref nativeWorld[4])).inverse * nativeWorld[bone];
			destination[bone].Position = Vector4.op_Implicit(((Matrix4x4)(ref val)).GetColumn(3));
			destination[bone].Rotation = ((Matrix4x4)(ref val)).rotation;
			destination[bone].Scale = nativeScratch[bone].Scale;
		}

		internal static float EntryDuration(float attackSpeed)
		{
			return Mathf.Min(0.3f, 0.32000002f / Mathf.Max(0.1f, attackSpeed));
		}

		private static bool Finite(float value)
		{
			if (!float.IsNaN(value))
			{
				return !float.IsInfinity(value);
			}
			return false;
		}
	}
	internal sealed class HoodwinkAerialTailLayer
	{
		internal const string FileName = "hoodwink_aerial_mirrored_tail_v106.bin";

		internal const float Duration = 7.9333334f;

		private const int FirstBone = 159;

		private const int TailBones = 7;

		private const int Frames = 953;

		private static readonly Dictionary<HoodwinkModel.ModelAsset, Quaternion[]> Banks = new Dictionary<HoodwinkModel.ModelAsset, Quaternion[]>();

		private readonly HoodwinkModel.ModelAsset asset;

		private readonly Quaternion[] samples;

		private readonly Matrix4x4[] world;

		private readonly Matrix4x4[] exitWorld;

		private HoodwinkAerialTailLayer(HoodwinkModel.ModelAsset asset, Quaternion[] samples)
		{
			this.asset = asset;
			this.samples = samples;
			world = (Matrix4x4[])(object)new Matrix4x4[asset.Bones.Length];
			exitWorld = (Matrix4x4[])(object)new Matrix4x4[asset.Bones.Length];
		}

		internal static HoodwinkAerialTailLayer? Create(HoodwinkModel.ModelAsset asset)
		{
			if (!Banks.TryGetValue(asset, out Quaternion[] value))
			{
				return null;
			}
			return new HoodwinkAerialTailLayer(asset, value);
		}

		internal static void Load(HoodwinkModel.ModelAsset asset, string directory)
		{
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			if (Banks.ContainsKey(asset))
			{
				return;
			}
			if (asset.Bones.Length != 202)
			{
				throw new InvalidDataException("Mirrored tail requires the approved 202-bone skeleton.");
			}
			for (int i = 0; i < 7; i++)
			{
				if (asset.Bones[159 + i].Name != ((i == 6) ? "tail_end" : ("tail_" + i)) || asset.Bones[159 + i].Parent != ((i != 0) ? (159 + i - 1) : 0))
				{
					throw new InvalidDataException("Mirrored tail bone name or parent differs.");
				}
			}
			byte[] array = File.ReadAllBytes(Path.Combine(directory, "hoodwink_aerial_mirrored_tail_v106.bin"));
			using SHA256 sHA = SHA256.Create();
			if (BitConverter.ToString(sHA.ComputeHash(array)).Replace("-", "").ToLowerInvariant() != "06559b7580429fbd8ba61721ce3999d5be6764c73b599ce2eeb24d275a12442b")
			{
				throw new InvalidDataException("Approved mirrored tail source hash differs.");
			}
			using BinaryReader binaryReader = new BinaryReader(new MemoryStream(array, writable: false), Encoding.UTF8);
			if (Encoding.ASCII.GetString(binaryReader.ReadBytes(4)) != "HWTL" || binaryReader.ReadInt32() != 1 || binaryReader.ReadInt32() != 202 || binaryReader.ReadInt32() != 159 || binaryReader.ReadInt32() != 7 || binaryReader.ReadInt32() != 953 || binaryReader.ReadSingle() != 120f || binaryReader.ReadSingle() != 7.9333334f || array.Length != 106768)
			{
				throw new InvalidDataException("Mirrored tail header, frame count or timing differs.");
			}
			Quaternion[] array2 = (Quaternion[])(object)new Quaternion[6671];
			Quaternion val = default(Quaternion);
			for (int j = 0; j < array2.Length; j++)
			{
				((Quaternion)(ref val))..ctor(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle());
				float num = Quaternion.Dot(val, val);
				if (float.IsNaN(num) || float.IsInfinity(num) || Mathf.Abs(num - 1f) > 1E-05f)
				{
					throw new InvalidDataException("Invalid mirrored tail quaternion.");
				}
				array2[j] = val;
			}
			for (int k = 0; k < 112; k++)
			{
				if (array[32 + k] != array[array.Length - 112 + k])
				{
					throw new InvalidDataException("Mirrored tail loop endpoint differs.");
				}
			}
			Banks.Add(asset, array2);
		}

		internal void Apply(HoodwinkModel.Pose[] pose, float clock, float weight = 1f, HoodwinkModel.Pose[]? exitPose = null)
		{
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: 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_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: 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_013d: 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_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			weight = Mathf.Clamp01(weight);
			if (weight <= 0f && exitPose == null)
			{
				return;
			}
			float num = Mathf.Repeat(clock, 7.9333334f) * 120f;
			int num2 = Mathf.Min((int)num, 952);
			int num3 = Mathf.Min(num2 + 1, 952);
			float num4 = num - (float)num2;
			HoodwinkAerialMath.World(asset, pose, world);
			if (exitPose != null)
			{
				HoodwinkAerialMath.World(asset, exitPose, exitWorld);
			}
			for (int i = 0; i < 7; i++)
			{
				int num5 = 159 + i;
				int parent = asset.Bones[num5].Parent;
				Quaternion val = Quaternion.Slerp(samples[num2 * 7 + i], samples[num3 * 7 + i], num4);
				if (exitPose != null)
				{
					val = Quaternion.Slerp(((Matrix4x4)(ref exitWorld[num5])).rotation, val, weight);
				}
				Quaternion val2 = Quaternion.Inverse(((Matrix4x4)(ref world[parent])).rotation) * val;
				HoodwinkModel.Pose pose2 = pose[num5];
				pose2.Rotation = ((exitPose != null) ? val2 : Quaternion.Slerp(pose2.Rotation, val2, weight));
				pose[num5] = pose2;
				world[num5] = world[parent] * Matrix4x4.TRS(pose2.Position, pose2.Rotation, pose2.Scale);
			}
		}
	}
	internal sealed class HoodwinkAerialTransition
	{
		private const int CarryHand = 43;

		private const int Bow = 174;

		private readonly HoodwinkModel.ModelAsset asset;

		private readonly Vector3[] position;

		private readonly Vector3[] positionVelocity;

		private readonly Vector3[] rotation;

		private readonly Vector3[] rotationVelocity;

		private readonly Vector3[] scale;

		private readonly Matrix4x4[] currentWorld;

		private readonly Matrix4x4[] previousWorld;

		private readonly Matrix4x4[] targetWorld;

		private readonly Matrix4x4[] pastTargetWorld;

		private Vector3 handPosition;

		private Vector3 handPositionVelocity;

		private Vector3 handRotation;

		private Vector3 handRotationVelocity;

		private Vector3 entryBowContact;

		private Vector3 entryBowRotation;

		private bool keepBowContact;

		private float duration;

		private float elapsed;

		internal bool Active { get; private set; }

		internal HoodwinkAerialTransition(HoodwinkModel.ModelAsset asset)
		{
			this.asset = asset;
			int num = asset.Bones.Length;
			position = (Vector3[])(object)new Vector3[num];
			positionVelocity = (Vector3[])(object)new Vector3[num];
			rotation = (Vector3[])(object)new Vector3[num];
			rotationVelocity = (Vector3[])(object)new Vector3[num];
			scale = (Vector3[])(object)new Vector3[num];
			currentWorld = (Matrix4x4[])(object)new Matrix4x4[num];
			previousWorld = (Matrix4x4[])(object)new Matrix4x4[num];
			targetWorld = (Matrix4x4[])(object)new Matrix4x4[num];
			pastTargetWorld = (Matrix4x4[])(object)new Matrix4x4[num];
		}

		internal void Reset()
		{
			Active = false;
			elapsed = 0f;
		}

		internal void Begin(HoodwinkModel.Pose[] source, HoodwinkModel.Pose[] previous, HoodwinkModel.Pose[] target, HoodwinkModel.Pose[] pastTarget, float seconds, float sourceDelta, bool keepBowContact = false)
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_0296: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02da: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0302: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: 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_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: 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_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_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0400: Unknown result type (might be due to invalid IL or missing references)
			//IL_0405: Unknown result type (might be due to invalid IL or missing references)
			//IL_0406: Unknown result type (might be due to invalid IL or missing references)
			//IL_0408: Unknown result type (might be due to invalid IL or missing references)
			//IL_040d: Unknown result type (might be due to invalid IL or missing references)
			//IL_040f: Unknown result type (might be due to invalid IL or missing references)
			//IL_033f: Unknown result type (might be due to invalid IL or missing references)
			//IL_034f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0354: Unknown result type (might be due to invalid IL or missing references)
			//IL_0359: Unknown result type (might be due to invalid IL or missing references)
			//IL_0368: Unknown result type (might be due to invalid IL or missing references)
			//IL_0378: Unknown result type (might be due to invalid IL or missing references)
			//IL_037d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0382: Unknown result type (might be due to invalid IL or missing references)
			//IL_0386: Unknown result type (might be due to invalid IL or missing references)
			//IL_038e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0393: Unknown result type (might be due to invalid IL or missing references)
			//IL_039b: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03aa: 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_03bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03db: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f8: 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_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: 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_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: 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)
			duration = Mathf.Max(1E-06f, seconds);
			elapsed = 0f;
			Active = true;
			this.keepBowContact = keepBowContact;
			bool flag = sourceDelta > 1E-06f && sourceDelta < 1f;
			float num = (flag ? (1f / sourceDelta) : 0f);
			for (int i = 0; i < position.Length; i++)
			{
				position[i] = source[i].Position - target[i].Position;
				positionVelocity[i] = (flag ? ((position[i] - (previous[i].Position - pastTarget[i].Position)) * num) : Vector3.zero);
				rotation[i] = HoodwinkAerialMath.Log(Quaternion.Inverse(target[i].Rotation) * source[i].Rotation);
				if (flag)
				{
					Vector3 value = HoodwinkAerialMath.Log(Quaternion.Inverse(pastTarget[i].Rotation) * previous[i].Rotation);
					rotationVelocity[i] = (rotation[i] - HoodwinkAerialMath.Unwrap(value, rotation[i])) * num;
				}
				else
				{
					rotationVelocity[i] = Vector3.zero;
				}
				scale[i] = source[i].Scale - target[i].Scale;
			}
			HoodwinkAerialMath.World(asset, source, currentWorld);
			HoodwinkAerialMath.World(asset, target, targetWorld);
			if (keepBowContact)
			{
				Matrix4x4 inverse = ((Matrix4x4)(ref currentWorld[174])).inverse;
				entryBowContact = ((Matrix4x4)(ref inverse)).MultiplyPoint3x4(Vector4.op_Implicit(((Matrix4x4)(ref currentWorld[43])).GetColumn(3)));
				entryBowRotation = HoodwinkAerialMath.Log(Quaternion.Inverse(((Matrix4x4)(ref targetWorld[174])).rotation) * ((Matrix4x4)(ref currentWorld[174])).rotation);
				return;
			}
			Matrix4x4 val = ((Matrix4x4)(ref currentWorld[43])).inverse * currentWorld[174];
			Matrix4x4 val2 = ((Matrix4x4)(ref targetWorld[43])).inverse * targetWorld[174];
			handPosition = Vector4.op_Implicit(((Matrix4x4)(ref val)).GetColumn(3)) - Vector4.op_Implicit(((Matrix4x4)(ref val2)).GetColumn(3));
			handRotation = HoodwinkAerialMath.Log(Quaternion.Inverse(((Matrix4x4)(ref val2)).rotation) * ((Matrix4x4)(ref val)).rotation);
			if (flag)
			{
				HoodwinkAerialMath.World(asset, previous, previousWorld);
				HoodwinkAerialMath.World(asset, pastTarget, pastTargetWorld);
				Matrix4x4 val3 = ((Matrix4x4)(ref previousWorld[43])).inverse * previousWorld[174];
				Matrix4x4 val4 = ((Matrix4x4)(ref pastTargetWorld[43])).inverse * pastTargetWorld[174];
				handPositionVelocity = (handPosition - (Vector4.op_Implicit(((Matrix4x4)(ref val3)).GetColumn(3)) - Vector4.op_Implicit(((Matrix4x4)(ref val4)).GetColumn(3)))) * num;
				Vector3 value2 = HoodwinkAerialMath.Log(Quaternion.Inverse(((Matrix4x4)(ref val4)).rotation) * ((Matrix4x4)(ref val3)).rotation);
				handRotationVelocity = (handRotation - HoodwinkAerialMath.Unwrap(value2, handRotation)) * num;
			}
			else
			{
				handPositionVelocity = (handRotationVelocity = Vector3.zero);
			}
		}

		internal void Advance(float dt)
		{
			if (Active)
			{
				elapsed += Mathf.Max(0f, dt);
			}
		}

		internal void Apply(HoodwinkModel.Pose[] target, HoodwinkModel.Pose[] destination)
		{
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0304: Unknown result type (might be due to invalid IL or missing references)
			//IL_0309: Unknown result type (might be due to invalid IL or missing references)
			//IL_0318: Unknown result type (might be due to invalid IL or missing references)
			//IL_031d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0322: Unknown result type (might be due to invalid IL or missing references)
			//IL_0327: Unknown result type (might be due to invalid IL or missing references)
			//IL_032b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0333: Unknown result type (might be due to invalid IL or missing references)
			//IL_0338: Unknown result type (might be due to invalid IL or missing references)
			//IL_0347: Unknown result type (might be due to invalid IL or missing references)
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0351: Unknown result type (might be due to invalid IL or missing references)
			//IL_0356: Unknown result type (might be due to invalid IL or missing references)
			//IL_035b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0360: Unknown result type (might be due to invalid IL or missing references)
			//IL_0364: Unknown result type (might be due to invalid IL or missing references)
			//IL_0371: Unknown result type (might be due to invalid IL or missing references)
			//IL_0376: Unknown result type (might be due to invalid IL or missing references)
			//IL_037b: Unknown result type (might be due to invalid IL or missing references)
			//IL_037d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0381: Unknown result type (might be due to invalid IL or missing references)
			//IL_0386: Unknown result type (might be due to invalid IL or missing references)
			//IL_038b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0390: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: 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_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: 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_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: 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_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			if (!Active || elapsed >= duration)
			{
				Array.Copy(target, destination, target.Length);
				Active = false;
				return;
			}
			float num = Mathf.Clamp01(elapsed / duration);
			float num2 = num * num * num;
			float num3 = num2 * num;
			float num4 = num3 * num;
			float num5 = 1f - 10f * num2 + 15f * num3 - 6f * num4;
			float num6 = num - 6f * num2 + 8f * num3 - 3f * num4;
			HoodwinkAerialMath.World(asset, target, targetWorld);
			for (int i = 0; i < target.Length; i++)
			{
				HoodwinkModel.Pose pose = target[i];
				ref Vector3 reference = ref pose.Position;
				reference += num5 * position[i] + duration * num6 * positionVelocity[i];
				pose.Rotation *= HoodwinkAerialMath.Exp(num5 * rotation[i] + duration * num6 * rotationVelocity[i]);
				ref Vector3 reference2 = ref pose.Scale;
				reference2 += num5 * scale[i];
				destination[i] = pose;
			}
			HoodwinkAerialMath.World(asset, destination, currentWorld);
			Matrix4x4 val = currentWorld[asset.Bones[174].Parent];
			if (keepBowContact)
			{
				Matrix4x4 val2 = targetWorld[174];
				Matrix4x4 val3 = ((Matrix4x4)(ref val2)).inverse;
				Vector3 val4 = ((Matrix4x4)(ref val3)).MultiplyPoint3x4(Vector4.op_Implicit(((Matrix4x4)(ref targetWorld[43])).GetColumn(3)));
				Vector3 val5 = Vector3.Lerp(entryBowContact, val4, 1f - num5);
				HoodwinkModel.Pose pose2 = destination[174];
				Quaternion val6 = ((Matrix4x4)(ref val2)).rotation * HoodwinkAerialMath.Exp(num5 * entryBowRotation);
				pose2.Rotation = Quaternion.Inverse(((Matrix4x4)(ref val)).rotation) * val6;
				val3 = ((Matrix4x4)(ref val)).inverse;
				Vector3 val7 = ((Matrix4x4)(ref val3)).MultiplyPoint3x4(Vector4.op_Implicit(((Matrix4x4)(ref currentWorld[43])).GetColumn(3)));
				val3 = Matrix4x4.TRS(Vector3.zero, pose2.Rotation, pose2.Scale);
				pose2.Position = val7 - ((Matrix4x4)(ref val3)).MultiplyVector(val5);
				destination[174] = pose2;
			}
			else
			{
				Matrix4x4 val8 = ((Matrix4x4)(ref targetWorld[43])).inverse * targetWorld[174];
				Vector3 val9 = Vector4.op_Implicit(((Matrix4x4)(ref val8)).GetColumn(3)) + num5 * handPosition + duration * num6 * handPositionVelocity;
				Quaternion val10 = ((Matrix4x4)(ref val8)).rotation * HoodwinkAerialMath.Exp(num5 * handRotation + duration * num6 * handRotationVelocity);
				Matrix4x4 val11 = ((Matrix4x4)(ref val)).inverse * currentWorld[43] * Matrix4x4.TRS(val9, val10, ((Matrix4x4)(ref val8)).lossyScale);
				destination[174].Position = Vector4.op_Implicit(((Matrix4x4)(ref val11)).GetColumn(3));
				destination[174].Rotation = ((Matrix4x4)(ref val11)).rotation;
			}
		}
	}
	internal static class HoodwinkAerialMath
	{
		internal static HoodwinkModel.Pose Blend(HoodwinkModel.Pose a, HoodwinkModel.Pose b, float t)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			return new HoodwinkModel.Pose
			{
				Position = Vector3.Lerp(a.Position, b.Position, t),
				Rotation = Quaternion.Slerp(a.Rotation, b.Rotation, t),
				Scale = Vector3.Lerp(a.Scale, b.Scale, t)
			};
		}

		internal static void Sample(HoodwinkModel.Clip clip, float seconds, HoodwinkModel.Pose[] destination)
		{
			float num = (clip.Loop ? Mathf.Repeat(seconds, clip.Duration) : Mathf.Clamp(seconds, 0f, clip.Duration)) * clip.Fps;
			int num2 = Mathf.Min((int)num, clip.Frames - 1);
			int num3 = Mathf.Min(num2 + 1, clip.Frames - 1);
			float t = num - (float)num2;
			int num4 = destination.Length;
			for (int i = 0; i < num4; i++)
			{
				destination[i] = Blend(clip.Samples[num2 * num4 + i], clip.Samples[num3 * num4 + i], t);
			}
		}

		internal static void World(HoodwinkModel.ModelAsset asset, HoodwinkModel.Pose[] pose, Matrix4x4[] destination)
		{
			//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_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: 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_004a: 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)
			for (int i = 0; i < pose.Length; i++)
			{
				Matrix4x4 val = Matrix4x4.TRS(pose[i].Position, pose[i].Rotation, pose[i].Scale);
				int parent = asset.Bones[i].Parent;
				destination[i] = ((parent < 0) ? val : (destination[parent] * val));
			}
		}

		internal static Vector3 Log(Quaternion value)
		{
			//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_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: 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_001e: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			Quaternion normalized = ((Quaternion)(ref value)).normalized;
			if (normalized.w < 0f)
			{
				((Quaternion)(ref normalized))..ctor(0f - normalized.x, 0f - normalized.y, 0f - normalized.z, 0f - normalized.w);
			}
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(normalized.x, normalized.y, normalized.z);
			float magnitude = ((Vector3)(ref val)).magnitude;
			if (!(magnitude < 1E-07f))
			{
				return val * (2f * Mathf.Atan2(magnitude, normalized.w) / magnitude);
			}
			return val * 2f;
		}

		internal static Quaternion Exp(Vector3 value)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			float magnitude = ((Vector3)(ref value)).magnitude;
			if (!(magnitude < 1E-07f))
			{
				return Quaternion.AngleAxis(magnitude * 57.29578f, value / magnitude);
			}
			Quaternion val = new Quaternion(value.x * 0.5f, value.y * 0.5f, value.z * 0.5f, 1f);
			return ((Quaternion)(ref val)).normalized;
		}

		internal static Vector3 Unwrap(Vector3 value, Vector3 reference)
		{
			//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_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: 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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: 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_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: 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_0078: Unknown result type (might be due to invalid IL or missing references)
			Vector3 normalized = ((Vector3)(ref value)).normalized;
			Vector3 val = value - normalized * (MathF.PI * 2f);
			Vector3 val2 = value + normalized * (MathF.PI * 2f);
			Vector3 val3 = value - reference;
			float sqrMagnitude = ((Vector3)(ref val3)).sqrMagnitude;
			val3 = val - reference;
			if (((Vector3)(ref val3)).sqrMagnitude < sqrMagnitude)
			{
				value = val;
				val3 = val - reference;
				sqrMagnitude = ((Vector3)(ref val3)).sqrMagnitude;
			}
			val3 = val2 - reference;
			if (((Vector3)(ref val3)).sqrMagnitude < sqrMagnitude)
			{
				value = val2;
			}
			return value;
		}

		internal static Quaternion Align(Vector3 from, Vector3 to)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: 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_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: 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_004a: 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_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			((Vector3)(ref from)).Normalize();
			((Vector3)(ref to)).Normalize();
			float num = Vector3.Dot(from, to);
			if (num < -0.999999f)
			{
				Vector3 val = Vector3.Cross(from, Vector3.up);
				if (((Vector3)(ref val)).sqrMagnitude < 1E-06f)
				{
					val = Vector3.Cross(from, Vector3.right);
				}
				return Quaternion.AngleAxis(180f, val);
			}
			Vector3 val2 = Vector3.Cross(from, to);
			Quaternion val3 = new Quaternion(val2.x, val2.y, val2.z, 1f + num);
			return ((Quaternion)(ref val3)).normalized;
		}
	}
	public sealed class HoodwinkCharacterMain : GenericCharacterMain
	{
	}
	internal static class HoodwinkChargeRenderCapture
	{
		[Serializable]
		private sealed class CaptureState
		{
			public string build;

			public string utc;

			public string captureKind;

			public string imagePath;

			public string scope;

			public string materialPhase;

			public string graphicsDeviceType;

			public string globalSkinWeights;

			public int frame;

			public int group;

			public int bodyId;

			public int screenWidth;

			public int screenHeight;

			public int materialFrame;

			public float time;

			public float unscaledTime;

			public float actionTime;

			public bool walk;

			public Vector3 bodyFootPosition;

			public Vector3 motorVelocity;

			public Vector3 aimDirection;

			public TransformState body;

			public TransformState visual;

			public CameraState camera;

			public TransformState[] bones;

			public RendererState[] renderers;

			public RendererState[] renderersAfterRender;
		}

		[Serializable]
		private sealed class TransformState
		{
			public string name;

			public string path;

			public int instanceId;

			public int parentId;

			public bool insideVisual;

			public Vector3 localPosition;

			public Vector3 localScale;

			public Vector3 worldPosition;

			public Vector3 worldScale;

			public Quaternion localRotation;

			public Quaternion worldRotation;

			public float[] localToWorld;
		}

		[Serializable]
		private sealed class CameraState
		{
			public TransformState transform;

			public string name;

			public string cameraType;

			public string targetTexture;

			public int instanceId;

			public int cullingMask;

			public float fieldOfView;

			public float nearClipPlane;

			public float farClipPlane;

			public float aspect;

			public float depth;

			public bool orthographic;

			public Rect pixelRect;

			public float[] worldToCamera;

			public float[] projection;
		}

		[Serializable]
		private sealed class FloatState
		{
			public string name;

			public bool present;

			public float value;
		}

		[Serializable]
		private sealed class ColorState
		{
			public string name;

			public bool present;

			public Color value;
		}

		[Serializable]
		private sealed class PropertyState
		{
			public bool empty;

			public FloatState[] floats;

			public ColorState[] colors;
		}

		[Serializable]
		private sealed class MaterialState
		{
			public int slot;

			public int instanceId;

			public int renderQueue;

			public string name;

			public string shader;

			public string[] shaderKeywords;

			public FloatState[] floats;

			public ColorState[] colors;

			public PropertyState slotPropertyBlock;
		}

		[Serializable]
		private sealed class RendererState
		{
			public int instanceId;

			public int layer;

			public int vertexCount;

			public int subMeshCount;

			public string name;

			public string sharedMesh;

			public string quality;

			public string shadowCastingMode;

			public bool enabled;

			public bool active;

			public bool forceRenderingOff;

			public bool updateWhenOffscreen;

			public Bounds worldBounds;

			public Bounds localBounds;

			public TransformState transform;

			public TransformState rootBone;

			public int[] boneInstanceIds;

			public PropertyState propertyBlock;

			public MaterialState[] materials;
		}

		private sealed class Pending
		{
			internal int Generation;

			internal int Frame;

			internal int Width;

			internal int Height;

			internal HoodwinkAnimationController Controller;

			internal CharacterBody Body;

			internal Camera Camera;

			internal string ImagePath;

			internal string JsonPath;

			internal CaptureState State;

			internal bool MaterialCaptured;
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static CameraCallback <0>__AfterCamera;
		}

		private const string Prefix = "[HW_CHARGE_RENDER] ";

		private static readonly string[] floatProperties = new string[21]
		{
			"_Fade", "_FadeBias", "_DitherOn", "_LimbPrimeMask", "_LimbRemovalOn", "_PrintOn", "_SliceHeight", "_SliceBandHeight", "_SliceAlphaDepth", "_PrintDirection",
			"_EnableCutout", "_Cutoff", "_AlphaClip", "_Cull", "_ZWrite", "_ZTest", "_EliteIndex", "_DecalLayer", "_Depth", "_ExternalAlpha",
			"_FadeCloseOn"
		};

		private static readonly string[] colorProperties = new string[4] { "_Color", "_TintColor", "_FlashColor", "_EmColor" };

		private static readonly HashSet<Texture2D> ownedTextures = new HashSet<Texture2D>();

		private static readonly List<Pending> pendingCaptures = new List<Pending>();

		private static bool armed;

		private static bool capturedStatic;

		private static bool subscribed;

		private static int generation;

		private static int movingCaptures;

		private static float lastMovingTime;

		private static string directory;

		internal static void Arm()
		{
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Expected O, but got Unknown
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Expected O, but got Unknown
			Shutdown();
			try
			{
				string text = DateTime.UtcNow.ToString("yyyyMMdd-HHmmss-fff", CultureInfo.InvariantCulture);
				directory = Path.Combine(Path.GetFullPath(Paths.BepInExRootPath), "HoodwinkDebugCaptures", "charge-" + text + "-" + Guid.NewGuid().ToString("N").Substring(0, 6));
				capturedStatic = false;
				movingCaptures = 0;
				lastMovingTime = float.NegativeInfinity;
				CameraCallback onPostRender = Camera.onPostRender;
				object obj = <>O.<0>__AfterCamera;
				if (obj == null)
				{
					CameraCallback val = Aft