Decompiled source of HoodwinkSurvivor v1.0.0

plugins/HoodwinkSurvivor/HoodwinkSurvivor.dll

Decompiled 4 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.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 BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using EntityStates.Commando.CommandoWeapon;
using EntityStates.Huntress.HuntressWeapon;
using HG.BlendableTypes;
using HarmonyLib;
using HoodwinkSurvivor.Audio;
using HoodwinkSurvivor.Debugging;
using HoodwinkSurvivor.Skills;
using KinematicCharacterController;
using Microsoft.CodeAnalysis;
using R2API;
using RoR2;
using RoR2.CharacterAI;
using RoR2.ConVar;
using RoR2.ContentManagement;
using RoR2.Projectile;
using RoR2.Skills;
using RoR2.SurvivorMannequins;
using RoR2.UI;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.EventSystems;
using UnityEngine.Networking;
using UnityEngine.Rendering;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.SceneManagement;

[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.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("HoodwinkSurvivor")]
[assembly: AssemblyTitle("HoodwinkSurvivor")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.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_";

		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", "702daa477347dcecd1cb143cd16819e232c105f5d7a1ff161d67285fd9bbdf05", "b96c617b21961cc36428c6ad494c664168999cd9515843ba3eae84198bc54752", "c163c7100cf883ba14e86a977828a539838e2376271559c2fe6921c8112efd56", "8b1ebb8d7574407326e09d5ec204fd06ada5956d975c756a6945dca464768a44", "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_01d2: 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_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: 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_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: 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_0301: 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)
			if (IsAvailable(asset))
			{
				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;
						if (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)
						{
							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);
			}
			HoodwinkPlugin.Log.LogInfo((object)"Approved V56/V58 aerial poses loaded; V59 transitions use live pose, aim and skill timing.");
		}

		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 bool Grounded;

			internal bool NewJump;

			internal bool PreferUpright;

			internal bool PrimaryActive;

			internal bool AllowLanding;

			internal bool PriorityBlocked;

			internal bool ReturnAllowed;

			internal Quaternion LocalAim;
		}

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

		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 HoodwinkAerialTransition transition;

		private readonly HoodwinkModel.Pose[] target;

		private readonly HoodwinkModel.Pose[] pastTarget;

		private readonly HoodwinkModel.Pose[] lowerScratch;

		private readonly HoodwinkModel.Pose[] nativeScratch;

		private readonly Matrix4x4[] nativeWorld;

		private readonly Matrix4x4[] poseWorld;

		private readonly bool[] upper;

		private readonly Quaternion calibration;

		private Route route;

		private Frame previousFrame;

		private bool havePreviousFrame;

		private float routeTime;

		private float crawlClock;

		private float uprightClock;

		private float previousNormalized;

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

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

		internal string Phase => route.ToString();

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

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

		internal HoodwinkAerialController(HoodwinkModel.ModelAsset asset)
		{
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: 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_01d8: 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");
			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];
			nativeWorld = (Matrix4x4[])(object)new Matrix4x4[num];
			poseWorld = (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);
			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 = 0f)));
			havePreviousFrame = false;
			transition.Reset();
		}

		internal bool TryCompose(Frame frame, HoodwinkModel.Pose[] displayed, HoodwinkModel.Pose[] previousDisplayed, float displayedDelta, HoodwinkModel.Pose[] destination)
		{
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: 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_00ef: 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);
			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);
			bool flag = havePreviousFrame && previousFrame.PrimaryActive;
			if (frame.PriorityBlocked)
			{
				Cancel(frame);
				return false;
			}
			if (frame.Grounded)
			{
				if (!frame.AllowLanding || frame.PrimaryActive || !Active)
				{
					Cancel(frame);
					return false;
				}
				if (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
			{
				if (!Active || route == Route.Landing || frame.NewJump)
				{
					if (frame.NewJump)
					{
						if (frame.PreferUpright)
						{
							uprightClock = 0f - takeoff.Duration;
						}
						else
						{
							crawlClock = 0f - lead.Duration;
						}
					}
					Route next = ((!frame.PreferUpright) ? (frame.NewJump ? Route.CrawlLead : Route.Crawl) : (frame.NewJump ? Route.UprightTakeoff : Route.Upright));
					Begin(next, 0.12f, frame, displayed, previousDisplayed, displayedDelta);
				}
				if (frame.PrimaryActive)
				{
					bool flag2 = !flag || frame.NormalizedAttack < previousNormalized - 0.005f;
					if (route != Route.Attack || flag2)
					{
						Begin(Route.Attack, EntryDuration(frame.AttackSpeed), frame, displayed, previousDisplayed, displayedDelta);
					}
				}
				else
				{
					if (route == Route.Attack)
					{
						Begin(Route.Upright, 0.16f, frame, displayed, previousDisplayed, displayedDelta);
					}
					if (frame.ReturnAllowed && (route == Route.Upright || route == Route.UprightTakeoff))
					{
						Begin(Route.Return, 0.55f, frame, displayed, previousDisplayed, displayedDelta);
					}
					else if (route == Route.CrawlLead && routeTime >= lead.Duration)
					{
						route = Route.Crawl;
					}
					else if (route == Route.UprightTakeoff && routeTime >= takeoff.Duration)
					{
						Begin(Route.Upright, 0.12f, frame, displayed, previousDisplayed, displayedDelta);
					}
					else if (route == Route.Return && routeTime >= 0.55f)
					{
						route = Route.Crawl;
					}
				}
			}
			Evaluate(route, routeTime, crawlClock, uprightClock, frame, target);
			transition.Apply(target, destination);
			previousFrame = frame;
			havePreviousFrame = true;
			previousNormalized = frame.NormalizedAttack;
			return true;
		}

		private void Cancel(Frame frame)
		{
			route = Route.None;
			routeTime = 0f;
			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)
		{
			route = next;
			routeTime = 0f;
			Evaluate(next, 0f, crawlClock, uprightClock, frame, target);
			Frame frame2 = (havePreviousFrame ? previousFrame : frame);
			frame2.NormalizedAttack = Mathf.Clamp01(frame.NormalizedAttack - Mathf.Max(0f, sourceDelta) * frame.AttackSpeed / 2f);
			Evaluate(next, 0f - sourceDelta, crawlClock - sourceDelta, uprightClock - sourceDelta, frame2, pastTarget);
			transition.Begin(source, previous, target, pastTarget, duration, sourceDelta);
		}

		private void Evaluate(Route mode, float seconds, float crawl, float upright, Frame frame, HoodwinkModel.Pose[] destination)
		{
			//IL_00c9: 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_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: 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_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			switch (mode)
			{
			case Route.CrawlLead:
				HoodwinkAerialMath.Sample(lead, seconds, destination);
				return;
			case Route.Crawl:
			case Route.Return:
				HoodwinkAerialMath.Sample(flight, crawl, destination);
				return;
			case Route.UprightTakeoff:
				HoodwinkAerialMath.Sample(takeoff, seconds, destination);
				return;
			case Route.Landing:
				HoodwinkAerialMath.Sample(land, seconds, destination);
				return;
			}
			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)
			{
				return;
			}
			Vector3 position = destination[1].Position;
			HoodwinkAerialMath.Sample(attack, frame.NormalizedAttack * attack.Duration, nativeScratch);
			HoodwinkAerialMath.World(asset, nativeScratch, nativeWorld);
			for (int j = 0; j < destination.Length; j++)
			{
				if (upper[j])
				{
					destination[j] = nativeScratch[j];
				}
			}
			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) * frame.LocalAim * calibration * ((Matrix4x4)(ref nativeWorld[1])).rotation;
			HoodwinkAerialMath.World(asset, destination, poseWorld);
			TransferCarrier(174, destination);
			TransferCarrier(200, destination);
		}

		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 HoodwinkAerialTransition
	{
		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 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)
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: 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_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: 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_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: 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_026b: 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_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_037e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0380: Unknown result type (might be due to invalid IL or missing references)
			//IL_0385: Unknown result type (might be due to invalid IL or missing references)
			//IL_0387: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: 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_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0306: Unknown result type (might be due to invalid IL or missing references)
			//IL_030b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0313: 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_0328: Unknown result type (might be due to invalid IL or missing references)
			//IL_032d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0334: Unknown result type (might be due to invalid IL or missing references)
			//IL_0339: Unknown result type (might be due to invalid IL or missing references)
			//IL_0340: Unknown result type (might be due to invalid IL or missing references)
			//IL_0345: Unknown result type (might be due to invalid IL or missing references)
			//IL_034a: Unknown result type (might be due to invalid IL or missing references)
			//IL_034f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0353: Unknown result type (might be due to invalid IL or missing references)
			//IL_0358: 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_0365: Unknown result type (might be due to invalid IL or missing references)
			//IL_036b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0370: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: 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_015e: 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_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			duration = Mathf.Max(1E-06f, seconds);
			elapsed = 0f;
			Active = true;
			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);
			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_00a2: 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_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: 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_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_014b: 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_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: 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_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02af: 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);
			Matrix4x4 val = ((Matrix4x4)(ref targetWorld[43])).inverse * targetWorld[174];
			Vector3 val2 = Vector4.op_Implicit(((Matrix4x4)(ref val)).GetColumn(3)) + num5 * handPosition + duration * num6 * handPositionVelocity;
			Quaternion val3 = ((Matrix4x4)(ref val)).rotation * HoodwinkAerialMath.Exp(num5 * handRotation + duration * num6 * handRotationVelocity);
			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 val4 = ((Matrix4x4)(ref currentWorld[asset.Bones[174].Parent])).inverse * currentWorld[43] * Matrix4x4.TRS(val2, val3, ((Matrix4x4)(ref val)).lossyScale);
			destination[174].Position = Vector4.op_Implicit(((Matrix4x4)(ref val4)).GetColumn(3));
			destination[174].Rotation = ((Matrix4x4)(ref val4)).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 = AfterCamera;
					<>O.<0>__AfterCamera = val;
					obj = (object)val;
				}
				Camera.onPostRender = (CameraCallback)Delegate.Combine((Delegate?)(object)onPostRender, (Delegate?)obj);
				subscribed = true;
				armed = true;
				Info("armed; maximum 1 static and 3 moving frames: " + directory);
			}
			catch (Exception error)
			{
				Shutdown();
				Error("arm", error);
			}
		}

		internal static void TryCapture(HoodwinkAnimationController controller, CharacterBody body, Camera camera, bool walk, float actionTime, int group)
		{
			try
			{
				if (!armed || !HoodwinkDebugSpawnGuard.Active || !Object.op_Implicit((Object)(object)controller) || !Object.op_Implicit((Object)(object)body) || !Object.op_Implicit((Object)(object)camera) || !((Behaviour)controller).isActiveAndEnabled || !((Component)body).gameObject.activeInHierarchy)
				{
					return;
				}
				if (walk)
				{
					if (movingCaptures >= 3 || actionTime < 0.6f || Time.unscaledTime - lastMovingTime < 0.7f)
					{
						return;
					}
				}
				else if (capturedStatic || actionTime < 0.5f)
				{
					return;
				}
				if (walk)
				{
					movingCaptures++;
					lastMovingTime = Time.unscaledTime;
				}
				else
				{
					capturedStatic = true;
				}
				int frameCount = Time.frameCount;
				string text = (walk ? ("moving-" + movingCaptures) : "static");
				string text2 = text + "-g" + group + "-f" + frameCount;
				Directory.CreateDirectory(directory);
				string imagePath = Path.Combine(directory, text2 + ".png");
				string text3 = Path.Combine(directory, text2 + ".json");
				CaptureState captureState = Snapshot(controller, body, camera, walk, actionTime, group, text, imagePath);
				File.WriteAllText(text3, JsonUtility.ToJson((object)captureState, true), new UTF8Encoding(encoderShouldEmitUTF8Identifier: false));
				Pending pending = new Pending
				{
					Generation = generation,
					Frame = frameCount,
					Width = captureState.screenWidth,
					Height = captureState.screenHeight,
					Controller = controller,
					Body = body,
					Camera = camera,
					ImagePath = imagePath,
					JsonPath = text3,
					State = captureState
				};
				pendingCaptures.Add(pending);
				try
				{
					((MonoBehaviour)controller).StartCoroutine(CaptureAtEndOfFrame(pending));
				}
				catch
				{
					pendingCaptures.Remove(pending);
					throw;
				}
				Info("preCull metadata: " + text3);
			}
			catch (Exception error)
			{
				Error("preCull", error);
			}
		}

		private static void AfterCamera(Camera camera)
		{
			try
			{
				if (!armed || !HoodwinkDebugSpawnGuard.Active || !Object.op_Implicit((Object)(object)camera))
				{
					return;
				}
				foreach (Pending pendingCapture in pendingCaptures)
				{
					if (!pendingCapture.MaterialCaptured && !((Object)(object)pendingCapture.Camera != (Object)(object)camera) && CanFinish(pendingCapture))
					{
						pendingCapture.State.renderersAfterRender = Snapshot(pendingCapture.Controller, pendingCapture.Body, camera, pendingCapture.State.walk, pendingCapture.State.actionTime, pendingCapture.State.group, pendingCapture.State.captureKind, pendingCapture.ImagePath).renderers;
						pendingCapture.State.materialFrame = Time.frameCount;
						pendingCapture.State.materialPhase = "Camera.onPostRender, after native scene-camera pre-render material updates";
						pendingCapture.MaterialCaptured = true;
						File.WriteAllText(pendingCapture.JsonPath, JsonUtility.ToJson((object)pendingCapture.State, true), new UTF8Encoding(encoderShouldEmitUTF8Identifier: false));
						Info("same-frame postRender materials: " + pendingCapture.JsonPath);
					}
				}
			}
			catch (Exception error)
			{
				Error("postRender materials", error);
			}
		}

		private static IEnumerator CaptureAtEndOfFrame(Pending pending)
		{
			yield return (object)new WaitForEndOfFrame();
			if (!CanFinish(pending))
			{
				pendingCaptures.Remove(pending);
				yield break;
			}
			Texture2D val = null;
			RenderTexture active = null;
			bool flag = false;
			try
			{
				if (pending.Width <= 0 || pending.Height <= 0)
				{
					throw new InvalidOperationException("Invalid game framebuffer size.");
				}
				active = RenderTexture.active;
				flag = true;
				RenderTexture.active = null;
				val = new Texture2D(pending.Width, pending.Height, (TextureFormat)3, false)
				{
					name = "Hoodwink owned one-frame debug readback",
					hideFlags = (HideFlags)61
				};
				ownedTextures.Add(val);
				val.ReadPixels(new Rect(0f, 0f, (float)pending.Width, (float)pending.Height), 0, 0, false);
				val.Apply(false, false);
				byte[] array = ImageConversion.EncodeToPNG(val);
				if (array == null || array.Length == 0)
				{
					throw new InvalidOperationException("Game framebuffer PNG encoding returned no data.");
				}
				File.WriteAllBytes(pending.ImagePath, array);
				Info("same-frame image: " + pending.ImagePath);
				if (capturedStatic && movingCaptures >= 3)
				{
					armed = false;
					Unsubscribe();
				}
			}
			catch (Exception error)
			{
				Error("endOfFrame", error);
			}
			finally
			{
				if (flag)
				{
					try
					{
						RenderTexture.active = active;
					}
					catch (Exception error2)
					{
						Error("restore read target", error2);
					}
				}
				try
				{
					if (Object.op_Implicit((Object)(object)val) && ownedTextures.Remove(val))
					{
						Object.Destroy((Object)(object)val);
					}
				}
				catch (Exception error3)
				{
					Error("release frame readback", error3);
				}
				pendingCaptures.Remove(pending);
			}
		}

		private static bool CanFinish(Pending pending)
		{
			try
			{
				return armed && pending.Generation == generation && HoodwinkDebugSpawnGuard.Active && Object.op_Implicit((Object)(object)pending.Controller) && ((Behaviour)pending.Controller).isActiveAndEnabled && Object.op_Implicit((Object)(object)pending.Body) && ((Component)pending.Body).gameObject.activeInHierarchy && Object.op_Implicit((Object)(object)pending.Camera) && Time.frameCount == pending.Frame && Screen.width == pending.Width && Screen.height == pending.Height;
			}
			catch (Exception error)
			{
				Error("endOfFrame guard", error);
				return false;
			}
		}

		private static CaptureState Snapshot(HoodwinkAnimationController controller, CharacterBody body, Camera camera, bool walk, float actionTime, int group, string kind, string imagePath)
		{
			//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_036b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0370: Unknown result type (might be due to invalid IL or missing references)
			//IL_0390: Unknown result type (might be due to invalid IL or missing references)
			//IL_0383: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Expected O, but got Unknown
			//IL_0395: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Expected O, but got Unknown
			//IL_03bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0404: Unknown result type (might be due to invalid IL or missing references)
			//IL_0499: Unknown result type (might be due to invalid IL or missing references)
			//IL_049e: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: 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_0204: Unknown result type (might be due to invalid IL or missing references)
			Transform transform = ((Component)controller).transform;
			SkinnedMeshRenderer[] componentsInChildren = ((Component)transform).GetComponentsInChildren<SkinnedMeshRenderer>(true);
			List<TransformState> list = new List<TransformState>();
			HashSet<Transform> hashSet = new HashSet<Transform>();
			List<RendererState> list2 = new List<RendererState>();
			SkinnedMeshRenderer[] array = componentsInChildren;
			foreach (SkinnedMeshRenderer val in array)
			{
				Transform[] bones = val.bones;
				int[] array2 = new int[bones.Length];
				for (int j = 0; j < bones.Length; j++)
				{
					Transform val2 = bones[j];
					array2[j] = (Object.op_Implicit((Object)(object)val2) ? ((Object)val2).GetInstanceID() : 0);
					if (Object.op_Implicit((Object)(object)val2) && hashSet.Add(val2))
					{
						list.Add(TransformInfo(val2, transform));
					}
				}
				MaterialPropertyBlock val3 = new MaterialPropertyBlock();
				((Renderer)val).GetPropertyBlock(val3);
				Material[] sharedMaterials = ((Renderer)val).sharedMaterials;
				MaterialState[] array3 = new MaterialState[sharedMaterials.Length];
				for (int k = 0; k < sharedMaterials.Length; k++)
				{
					MaterialPropertyBlock val4 = new MaterialPropertyBlock();
					((Renderer)val).GetPropertyBlock(val4, k);
					array3[k] = MaterialInfo(sharedMaterials[k], k, val4);
				}
				Mesh sharedMesh = val.sharedMesh;
				list2.Add(new RendererState
				{
					instanceId = ((Object)val).GetInstanceID(),
					name = ((Object)val).name,
					layer = ((Component)val).gameObject.layer,
					vertexCount = (Object.op_Implicit((Object)(object)sharedMesh) ? sharedMesh.vertexCount : 0),
					subMeshCount = (Object.op_Implicit((Object)(object)sharedMesh) ? sharedMesh.subMeshCount : 0),
					sharedMesh = (Object.op_Implicit((Object)(object)sharedMesh) ? ((Object)sharedMesh).name : "missing"),
					quality = ((object)val.quality/*cast due to .constrained prefix*/).ToString(),
					shadowCastingMode = ((object)((Renderer)val).shadowCastingMode/*cast due to .constrained prefix*/).ToString(),
					enabled = ((Renderer)val).enabled,
					active = ((Component)val).gameObject.activeInHierarchy,
					forceRenderingOff = ((Renderer)val).forceRenderingOff,
					updateWhenOffscreen = val.updateWhenOffscreen,
					worldBounds = ((Renderer)val).bounds,
					localBounds = ((Renderer)val).localBounds,
					transform = TransformInfo(((Component)val).transform, transform),
					rootBone = TransformInfo(val.rootBone, transform),
					boneInstanceIds = array2,
					propertyBlock = BlockInfo(val3),
					materials = array3
				});
			}
			return new CaptureState
			{
				build = typeof(HoodwinkChargeRenderCapture).Module.ModuleVersionId.ToString(),
				utc = DateTime.UtcNow.ToString("O", CultureInfo.InvariantCulture),
				captureKind = kind,
				imagePath = imagePath,
				scope = "Pre-cull bones/aim/camera and initial renderers; renderersAfterRender observes this scene camera's post-render materials, after native material updates. The unchanged on-screen framebuffer is read at the end of the same frame. Missing property-block values are not material overrides.",
				materialPhase = "PreCull only; no paired postRender material snapshot yet",
				materialFrame = -1,
				graphicsDeviceType = ((object)SystemInfo.graphicsDeviceType/*cast due to .constrained prefix*/).ToString(),
				globalSkinWeights = ((object)QualitySettings.skinWeights/*cast due to .constrained prefix*/).ToString(),
				frame = Time.frameCount,
				group = group,
				bodyId = ((Object)body).GetInstanceID(),
				time = Time.time,
				unscaledTime = Time.unscaledTime,
				actionTime = actionTime,
				walk = walk,
				screenWidth = Screen.width,
				screenHeight = Screen.height,
				bodyFootPosition = body.footPosition,
				motorVelocity = (Object.op_Implicit((Object)(object)body.characterMotor) ? body.characterMotor.velocity : Vector3.zero),
				aimDirection = (Object.op_Implicit((Object)(object)body.inputBank) ? body.inputBank.aimDirection : transform.forward),
				body = TransformInfo(((Component)body).transform, transform),
				visual = TransformInfo(transform, transform),
				camera = new CameraState
				{
					name = ((Object)camera).name,
					instanceId = ((Object)camera).GetInstanceID(),
					cameraType = ((object)camera.cameraType/*cast due to .constrained prefix*/).ToString(),
					targetTexture = (Object.op_Implicit((Object)(object)camera.targetTexture) ? ((Object)camera.targetTexture).name : "screen"),
					transform = TransformInfo(((Component)camera).transform, transform),
					fieldOfView = camera.fieldOfView,
					nearClipPlane = camera.nearClipPlane,
					farClipPlane = camera.farClipPlane,
					aspect = camera.aspect,
					depth = camera.depth,
					orthographic = camera.orthographic,
					pixelRect = camera.pixelRect,
					cullingMask = camera.cullingMask,
					worldToCamera = MatrixValues(camera.worldToCameraMatrix),
					projection = MatrixValues(camera.projectionMatrix)
				},
				bones = list.ToArray(),
				renderers = list2.ToArray()
			};
		}

		private static MaterialState MaterialInfo(Material material, int slot, MaterialPropertyBlock block)
		{
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: 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)
			MaterialState materialState = new MaterialState
			{
				slot = slot,
				name = (Object.op_Implicit((Object)(object)material) ? ((Object)material).name : "missing"),
				instanceId = (Object.op_Implicit((Object)(object)material) ? ((Object)material).GetInstanceID() : 0),
				renderQueue = (Object.op_Implicit((Object)(object)material) ? material.renderQueue : (-1)),
				shader = ((Object.op_Implicit((Object)(object)material) && Object.op_Implicit((Object)(object)material.shader)) ? ((Object)material.shader).name : "missing"),
				shaderKeywords = (Object.op_Implicit((Object)(object)material) ? material.shaderKeywords : Array.Empty<string>()),
				slotPropertyBlock = BlockInfo(block),
				floats = new FloatState[floatProperties.Length],
				colors = new ColorState[colorProperties.Length]
			};
			for (int i = 0; i < floatProperties.Length; i++)
			{
				string text = floatProperties[i];
				bool flag = Object.op_Implicit((Object)(object)material) && material.HasProperty(text);
				materialState.floats[i] = new FloatState
				{
					name = text,
					present = flag,
					value = (flag ? material.GetFloat(text) : 0f)
				};
			}
			for (int j = 0; j < colorProperties.Length; j++)
			{
				string text2 = colorProperties[j];
				bool flag2 = Object.op_Implicit((Object)(object)material) && material.HasProperty(text2);
				materialState.colors[j] = new ColorState
				{
					name = text2,
					present = flag2,
					value = (Color)(flag2 ? material.GetColor(text2) : default(Color))
				};
			}
			return materialState;
		}

		private static PropertyState BlockInfo(MaterialPropertyBlock block)
		{
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			PropertyState propertyState = new PropertyState
			{
				empty = block.isEmpty,
				floats = new FloatState[floatProperties.Length],
				colors = new ColorState[colorProperties.Length]
			};
			for (int i = 0; i < floatProperties.Length; i++)
			{
				string text = floatProperties[i];
				int num = Shader.PropertyToID(text);
				propertyState.floats[i] = new FloatState
				{
					name = text,
					present = block.HasFloat(num),
					value = block.GetFloat(num)
				};
			}
			for (int j = 0; j < colorProperties.Length; j++)
			{
				string text2 = colorProperties[j];
				int num2 = Shader.PropertyToID(text2);
				propertyState.colors[j] = new ColorState
				{
					name = text2,
					present = block.HasColor(num2),
					value = block.GetColor(num2)
				};
			}
			return propertyState;
		}

		private static TransformState TransformInfo(Transform value, Transform visual)
		{
			//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_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)value))
			{
				return new TransformState
				{
					name = "missing",
					path = "missing"
				};
			}
			List<string> list = new List<string>();
			Transform val = value;
			int num = 0;
			while (Object.op_Implicit((Object)(object)val) && num < 64)
			{
				list.Add(((Object)val).name);
				if ((Object)(object)val == (Object)(object)visual)
				{
					break;
				}
				num++;
				val = val.parent;
			}
			list.Reverse();
			return new TransformState
			{
				name = ((Object)value).name,
				path = string.Join("/", list),
				instanceId = ((Object)value).GetInstanceID(),
				parentId = (Object.op_Implicit((Object)(object)value.parent) ? ((Object)value.parent).GetInstanceID() : 0),
				insideVisual = ((Object)(object)value == (Object)(object)visual || value.IsChildOf(visual)),
				localPosition = value.localPosition,
				localRotation = value.localRotation,
				localScale = value.localScale,
				worldPosition = value.position,
				worldRotation = value.rotation,
				worldScale = value.lossyScale,
				localToWorld = MatrixValues(value.localToWorldMatrix)
			};
		}

		private static float[] MatrixValues(Matrix4x4 matrix)
		{
			float[] array = new float[16];
			for (int i = 0; i < 4; i++)
			{
				for (int j = 0; j < 4; j++)
				{
					array[i * 4 + j] = ((Matrix4x4)(ref matrix))[i, j];
				}
			}
			return array;
		}

		internal static void Shutdown()
		{
			armed = false;
			generation++;
			Unsubscribe();
			pendingCaptures.Clear();
			foreach (Texture2D ownedTexture in ownedTextures)
			{
				try
				{
					if (Object.op_Implicit((Object)(object)ownedTexture))
					{
						Object.Destroy((Object)(object)ownedTexture);
					}
				}
				catch (Exception error)
				{
					Error("release readback", error);
				}
			}
			ownedTextures.Clear();
			directory = null;
		}

		private static void Unsubscribe()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			if (!subscribed)
			{
				return;
			}
			try
			{
				CameraCallback onPostRender = Camera.onPostRender;
				object obj = <>O.<0>__AfterCamera;
				if (obj == null)
				{
					CameraCallback val = AfterCamera;
					<>O.<0>__AfterCamera = val;
					obj = (object)val;
				}
				Camera.onPostRender = (CameraCallback)Delegate.Remove((Delegate?)(object)onPostRender, (Delegate?)obj);
			}
			catch (Exception error)
			{
				Error("unsubscribe postRender", error);
			}
			subscribed = false;
		}

		private static void Info(string message)
		{
			try
			{
				HoodwinkPlugin.Log.LogInfo((object)("[HW_CHARGE_RENDER] " + message));
			}
			catch
			{
			}
		}

		private static void Error(string stage, Exception error)
		{
			try
			{
				HoodwinkPlugin.Log.LogWarning((object)("[HW_CHARGE_RENDER] " + stage + ": " + error.GetType().Name + ": " + error.Message));
			}
			catch
			{
			}
		}
	}
	internal static class HoodwinkChargeRuntimeProbe
	{
		private sealed class Part
		{
			internal SkinnedMeshRenderer Renderer;

			internal Mesh Baked;

			internal readonly List<Vector3> Points = new List<Vector3>();

			internal bool[] Low;

			internal bool[] Left;

			internal bool[] Right;
		}

		private sealed class Session
		{
			internal HoodwinkAnimationController Controller;

			internal CharacterBody Body;

			internal EntityStateMachine BodyMachine;

			internal EntityStateMachine WeaponMachine;

			internal Part[] Parts;

			internal int PendingFrame = -1;

			internal int PendingGroup;

			internal string Skill;

			internal string Source;

			internal bool Walk;

			internal bool Moving;

			internal bool Airborne;

			internal float ActionTime;

			internal float ActionDuration;

			internal float WalkPhase;

			internal string WalkDirection;
		}

		[Serializable]
		private sealed class Header
		{
			public string eventName;

			public string build = Build;

			public string detail;

			public int maximumGroups = 48;

			public int groupsCaptured = groups;

			public int frame = Time.frameCount;

			public float intervalSeconds = 0.2f;
		}

		[Serializable]
		private sealed class Frame
		{
			public string phase;

			public string build = Build;

			public string skill;

			public string bodyState;

			public string weaponState;

			public string poseSource;

			public string camera;

			public int group;

			public int frame;

			public int bodyId;

			public int worldMask;

			public float time;

			public float unscaledTime;

			public float capsuleHeight;

			public float capsuleYOffset;

			public float actionTime;

			public float actionDuration;

			public float walkPhase;

			public string walkDirection;

			public bool walkActive;

			public bool moving;

			public bool airborne;

			public bool authoritative;

			public bool motorAuthority;

			public bool grounded;

			public bool stable;

			public bool motorEnabled;

			public Vector3 velocity;

			public Vector3 footPosition;

			public Vector3 groundingPoint;

			public Vector3 groundingNormal;

			public string groundingCollider;

			public int groundingLayer;

			public TransformState[] hierarchy;

			public PartState[] parts;
		}

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

			public string name;

			public int instanceId;

			public Vector3 position;

			public Vector3 localPosition;

			public Vector3 scale;

			public Quaternion rotation;
		}

		[Serializable]
		private sealed class RayState
		{
			public bool hit;

			public string collider;

			public int layer;

			public Vector3 origin;

			public Vector3 point;

			public Vector3 normal;

			public float distance;

			public float surfaceGapY;
		}

		[Serializable]
		private sealed class Minimum
		{
			public bool valid;

			public Vector3 worldPoint;

			public float relativeToFootY;

			public RayState worldRay;

			public RayState nativeColliderRay;
		}

		[Serializable]
		private sealed class PartState
		{
			public string renderer;

			public string sharedMesh;

			public string bakeMode = "BakeMesh(useScale=false), renderer.TransformPoint";

			public int rendererId;

			public int vertexCount;

			public bool rendererEnabled;

			public bool active;

			public bool forceRenderingOff;

			public TransformState rendererTransform;

			public TransformState rootBoneTransform;

			public Minimum all;

			public Minimum lowRestY;

			public Minimum leftFoot;

			public Minimum rightFoot;
		}

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

		private const string Prefix = "[HW_CHARGE_PROBE] ";

		private const int MaximumGroups = 48;

		private const float Interval = 0.2f;

		private static readonly string Build = typeof(HoodwinkChargeRuntimeProbe).Module.ModuleVersionId.ToString();

		private static Session session;

		private static bool ready;

		private static bool subscribed;

		private static bool finished;

		private static bool manuallyArmed;

		private static int groups;

		private static int failures;

		private static float nextSample;

		internal static void AfterPose(HoodwinkAnimationController controller, CharacterBody body, string skill, bool chargeWalkActive, bool moving, bool airborne, string source, float actionTime = 0f, float actionDuration = 0f, float walkPhase = 0f, string walkDirection = "")
		{
			//IL_0319: Unknown result type (might be due to invalid IL or missing references)
			//IL_0323: Expected O, but got Unknown
			//IL_0309: Unknown result type (might be due to invalid IL or missing references)
			//IL_030e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0314: Expected O, but got Unknown
			try
			{
				if (!manuallyArmed || !HoodwinkDebugSpawnGuard.Active)
				{
					return;
				}
				if (!ready)
				{
					ready = true;
					Emit(new Header
					{
						eventName = "Ready",
						detail = "read-only; local authoritative player; real skill input only"
					});
				}
				if (finished || !Object.op_Implicit((Object)(object)controller) || !Object.op_Implicit((Object)(object)body) || Time.timeScale <= 0f)
				{
					return;
				}
				LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
				if (firstLocalUser == null || (Object)(object)firstLocalUser.cachedBody != (Object)(object)body || !Util.HasEffectiveAuthority(((Component)body).gameObject))
				{
					return;
				}
				if (HoodwinkChargeRuntimeProbe.session == null || (Object)(object)HoodwinkChargeRuntimeProbe.session.Body != (Object)(object)body || (Object)(object)HoodwinkChargeRuntimeProbe.session.Controller != (Object)(object)controller)
				{
					ReleaseSession();
					HoodwinkChargeRuntimeProbe.session = Bind(controller, body);
					Header header = new Header();
					header.eventName = "Bound";
					header.detail = "body=" + ((Object)body).name + "#" + ((Object)body).GetInstanceID() + "; visual=" + ((Object)controller).name + "#" + ((Object)controller).GetInstanceID() + "; parts=" + HoodwinkChargeRuntimeProbe.session.Parts.Length;
					Emit(header);
				}
				Session session = HoodwinkChargeRuntimeProbe.session;
				if (session.PendingFrame >= 0 && session.PendingFrame < Time.frameCount)
				{
					Header header = new Header();
					header.eventName = "PreCullMissed";
					header.detail = "group=" + session.PendingGroup + "; poseFrame=" + session.PendingFrame + "; no matching local scene camera callback";
					Emit(header);
					session.PendingFrame = -1;
				}
				if (groups >= 48 && session.PendingFrame < 0)
				{
					Emit(new Header
					{
						eventName = "Complete",
						detail = "sample budget exhausted; final camera callback missing"
					});
					Shutdown();
					return;
				}
				bool flag = Object.op_Implicit((Object)(object)session.WeaponMachine) && session.WeaponMachine.state is Sharpshooter;
				if ((skill != "charge" && !flag) || Time.unscaledTime < nextSample || groups >= 48)
				{
					return;
				}
				session.Skill = skill;
				session.Source = source;
				session.Walk = chargeWalkActive;
				session.Moving = moving;
				session.Airborne = airborne;
				session.ActionTime = actionTime;
				session.ActionDuration = actionDuration;
				session.WalkPhase = walkPhase;
				session.WalkDirection = walkDirection;
				session.PendingFrame = Time.frameCount;
				session.PendingGroup = ++groups;
				nextSample = Time.unscaledTime + 0.2f;
				if (!subscribed)
				{
					CameraCallback onPreCull = Camera.onPreCull;
					object obj = <>O.<0>__BeforeCamera;
					if (obj == null)
					{
						CameraCallback val = BeforeCamera;
						<>O.<0>__BeforeCamera = val;
						obj = (object)val;
					}
					Camera.onPreCull = (CameraCallback)Delegate.Combine((Delegate?)(object)onPreCull, (Delegate?)obj);
					subscribed = true;
				}
				Emit(Capture(session, "afterPose", null));
			}
			catch (Exception error)
			{
				Fail(error);
			}
		}

		private static void BeforeCamera(Camera camera)
		{
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Invalid comparison between Unknown and I4
			try
			{
				Session session = HoodwinkChargeRuntimeProbe.session;
				if (!manuallyArmed || !HoodwinkDebugSpawnGuard.Active || finished || session == null || session.PendingFrame != Time.frameCount || !Object.op_Implicit((Object)(object)camera))
				{
					return;
				}
				LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
				CameraRigController val = ((firstLocalUser == null) ? null : firstLocalUser.cameraRigController);
				if (!Object.op_Implicit((Object)(object)val) || (Object)(object)camera != (Object)(object)val.sceneCam || (int)camera.cameraType != 1)
				{
					return;
				}
				session.PendingFrame = -1;
				if (Object.op_Implicit((Object)(object)session.Body) && !((Object)(object)firstLocalUser.cachedBody != (Object)(object)session.Body))
				{
					Emit(Capture(session, "preCull", camera));
					HoodwinkChargeRenderCapture.TryCapture(session.Controller, session.Body, camera, session.Walk, session.ActionTime, session.PendingGroup);
					if (groups >= 48)
					{
						Emit(new Header
						{
							eventName = "Complete",
							detail = "sample budget exhausted; no more BakeMesh work"
						});
						Shutdown();
					}
				}
			}
			catch (Exception error)
			{
				Fail(error);
			}
		}

		private static Session Bind(HoodwinkAnimationController controller, CharacterBody body)
		{
			//IL_00c9: 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_00de: Expected O, but got Unknown
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: 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)
			Session session = new Session
			{
				Controller = controller,
				Body = body,
				BodyMachine = EntityStateMachine.FindByCustomName(((Component)body).gameObject, "Body"),
				WeaponMachine = EntityStateMachine.FindByCustomName(((Component)body).gameObject, "Weapon")
			};
			List<Part> list = new List<Part>();
			try
			{
				SkinnedMeshRenderer[] componentsInChildren = ((Component)controller).GetComponentsInChildren<SkinnedMeshRenderer>(true);
				foreach (SkinnedMeshRenderer val in componentsInChildren)
				{
					if (!Object.op_Implicit((Object)(object)val.sharedMesh))
					{
						continue;
					}
					string name = ((Object)val.sharedMesh).name;
					if (name.IndexOf("hoodwink_base_body", StringComparison.OrdinalIgnoreCase) < 0 && name.IndexOf("armor", StringComparison.OrdinalIgnoreCase) < 0)
					{
						continue;
					}
					Mesh sharedMesh = val.sharedMesh;
					Vector3[] vertices = sharedMesh.vertices;
					BoneWeight[] boneWeights = sharedMesh.boneWeights;
					Transform[] bones = val.bones;
					Part part = new Part
					{
						Renderer = val,
						Baked = new Mesh
						{
							name = "Hoodwink read-only charge snapshot"
						},
						Low = new bool[vertices.Length],
						Left = new bool[vertices.Length],
						Right = new bool[vertices.Length]
					};
					for (int j = 0; j < vertices.Length; j++)
					{
						part.Low[j] = vertices[j].y <= 0.65f;
						if (j < boneWeights.Length)
						{
							BoneWeight weight = boneWeights[j];
							part.Left[j] = Influence(bones, weight, "_L") > 0.8f;
							part.Right[j] = Influence(bones, weight, "_R") > 0.8f;
						}
					}
					list.Add(part);
				}
			}
			catch
			{
				foreach (Part item in list)
				{
					if (Object.op_Implicit((Object)(object)item.Baked))
					{
						Object.Destroy((Object)(object)item.Baked);
					}
				}
				throw;
			}
			session.Parts = list.ToArray();
			return session;
		}

		private static float Influence(Transform[] bones, BoneWeight weight, string side)
		{
			return Weight(bones, ((BoneWeight)(ref weight)).boneIndex0, ((BoneWeight)(ref weight)).weight0, side) + Weight(bones, ((BoneWeight)(ref weight)).boneIndex1, ((BoneWeight)(ref weight)).weight1, side) + Weight(bones, ((BoneWeight)(ref weight)).boneIndex2, ((BoneWeight)(ref weight)).weight2, side) + Weight(bones, ((BoneWeight)(ref weight)).boneIndex3, ((BoneWeight)(ref weight)).weight3, side);
		}

		private static float Weight(Transform[] bones, int index, float weight, string side)
		{
			if (!(weight > 0f) || index < 0 || index >= bones.Length || !Object.op_Implicit((Object)(object)bones[index]) || (!(((Object)bones[index]).name == "ankle" + side) && !(((Object)bones[index]).name == "ball" + side)))
			{
				return 0f;
			}
			return weight;
		}

		private static Frame Capture(Session current, string phase, Camera camera)
		{
			//IL_006c: 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_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: 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_01c9: 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_0337: Unknown result type (might be due to invalid IL or missing references)
			//IL_033c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0341: Unknown result type (might be due to invalid IL or missing references)
			//IL_0345: Unknown result type (might be due to invalid IL or missing references)
			//IL_0367: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0389: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ab: Unknown result type (mi