Decompiled source of Hollow Saint v1.3.2

plugins/HollowSaint/HollowSaint.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using HG.BlendableTypes;
using HollowSaint.FoundationKit;
using HollowSaint.FoundationKit.ArcBolt;
using HollowSaint.FoundationKit.ArcStep;
using HollowSaint.FoundationKit.ChargedStorm;
using HollowSaint.FoundationKit.Gaze;
using HollowSaint.FoundationKit.Gaze.Fx;
using HollowSaint.FoundationKit.HollowedOrb;
using HollowSaint.FoundationKit.OpenCircuit;
using HollowSaint.FoundationKit.OpenCircuit.Fx;
using HollowSaint.FoundationKit.SpearDischarge;
using HollowSaint.FoundationKit.Storm;
using HollowSaint.FoundationKit.Stormspear;
using HollowSaint.FoundationKit.Stormspear.Fx;
using HollowSaint.FoundationKit.Thundercloud;
using HollowSaint.FoundationKit.Vfx;
using KinematicCharacterController;
using Microsoft.CodeAnalysis;
using On.RoR2;
using R2API;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.Achievements;
using RoR2.CameraModes;
using RoR2.CharacterAI;
using RoR2.ContentManagement;
using RoR2.ExpansionManagement;
using RoR2.Networking;
using RoR2.Orbs;
using RoR2.Projectile;
using RoR2.Skills;
using RoR2.UI;
using RoR2BepInExPack.GameAssetPathsBetter;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;
using UnityEngine.Rendering;
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("HollowSaint")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.3.2.0")]
[assembly: AssemblyInformationalVersion("1.3.2+60b0cf3a00f8f799af7062d92fffa36d743321b5")]
[assembly: AssemblyProduct("HollowSaint")]
[assembly: AssemblyTitle("HollowSaint")]
[assembly: AssemblyVersion("1.3.2.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace HollowSaint
{
	[DefaultExecutionOrder(99)]
	[DisallowMultipleComponent]
	public sealed class FoundationAimPose : MonoBehaviour
	{
		public static bool Enabled = true;

		private const float MaxPitch = 66f;

		private const float MaxYaw = 60f;

		private static readonly float[] PitchShare = new float[4]
		{
			7f / 33f,
			5f / 33f,
			0.27272728f,
			0.36363637f
		};

		private static readonly float[] YawShare = new float[4] { 0.15f, 0.2f, 0.3f, 0.35f };

		private CharacterBody body;

		private FoundationPresentation presentation;

		private readonly Transform[] bones = (Transform[])(object)new Transform[4];

		private readonly Quaternion[] saved = (Quaternion[])(object)new Quaternion[4];

		private readonly Quaternion[] applied = (Quaternion[])(object)new Quaternion[4];

		private bool hasSaved;

		private bool hasApplied;

		private float pitch;

		private float yaw;

		private float torsoWeight;

		private void Start()
		{
			body = ((Component)this).GetComponentInParent<CharacterBody>();
			presentation = ((Component)this).GetComponent<FoundationPresentation>();
			Transform[] componentsInChildren = ((Component)this).GetComponentsInChildren<Transform>(true);
			foreach (Transform val in componentsInChildren)
			{
				if (((Object)val).name == "spine")
				{
					bones[0] = val;
				}
				else if (((Object)val).name == "chest")
				{
					bones[1] = val;
				}
				else if (((Object)val).name == "neck")
				{
					bones[2] = val;
				}
				else if (((Object)val).name == "head")
				{
					bones[3] = val;
				}
			}
			if (!Object.op_Implicit((Object)(object)body) || !Object.op_Implicit((Object)(object)bones[0]) || !Object.op_Implicit((Object)(object)bones[1]) || !Object.op_Implicit((Object)(object)bones[2]) || !Object.op_Implicit((Object)(object)bones[3]))
			{
				((Behaviour)this).enabled = false;
			}
		}

		private void Update()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			if (hasSaved)
			{
				for (int i = 0; i < 4; i++)
				{
					bones[i].localRotation = saved[i];
				}
				hasSaved = false;
			}
		}

		private void LateUpdate()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: 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_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: 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_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: 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_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_030f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0311: 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_0332: Unknown result type (might be due to invalid IL or missing references)
			//IL_0337: Unknown result type (might be due to invalid IL or missing references)
			//IL_0342: Unknown result type (might be due to invalid IL or missing references)
			//IL_034d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0352: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			float deltaTime = Time.deltaTime;
			if (deltaTime <= 0f)
			{
				if (hasApplied)
				{
					for (int i = 0; i < 4; i++)
					{
						saved[i] = bones[i].localRotation;
						bones[i].localRotation = applied[i];
					}
					hasSaved = true;
				}
				return;
			}
			if (!Enabled || !Object.op_Implicit((Object)(object)presentation) || !presentation.IsPresentingAlive || !Object.op_Implicit((Object)(object)body.inputBank))
			{
				pitch = (yaw = 0f);
				hasApplied = false;
				return;
			}
			Vector3 aimDirection = body.inputBank.aimDirection;
			if (((Vector3)(ref aimDirection)).sqrMagnitude < 0.0001f || float.IsNaN(((Vector3)(ref aimDirection)).sqrMagnitude))
			{
				return;
			}
			((Vector3)(ref aimDirection)).Normalize();
			Vector3 val = (Object.op_Implicit((Object)(object)body.characterDirection) ? body.characterDirection.forward : ((Component)this).transform.forward);
			val.y = 0f;
			if (!(((Vector3)(ref val)).sqrMagnitude < 0.0001f))
			{
				((Vector3)(ref val)).Normalize();
				float num = Mathf.Clamp(Mathf.Asin(Mathf.Clamp(aimDirection.y, -1f, 1f)) * 57.29578f, -66f, 66f);
				Vector3 val2 = default(Vector3);
				((Vector3)(ref val2))..ctor(aimDirection.x, 0f, aimDirection.z);
				float num2 = ((((Vector3)(ref val2)).sqrMagnitude > 0.0001f) ? Mathf.Clamp(Vector3.SignedAngle(val, val2, Vector3.up), -60f, 60f) : 0f);
				float num3 = 1f - Mathf.Exp(-14f * Mathf.Min(deltaTime, 0.1f));
				pitch = Mathf.Lerp(pitch, num, num3);
				yaw = Mathf.Lerp(yaw, num2, num3);
				float num4 = ((!body.outOfCombat || body.inputBank.skill1.down || body.inputBank.skill2.down || body.inputBank.skill4.down) ? 1f : 0.35f);
				if (body.isSprinting)
				{
					num4 *= 0.5f;
				}
				torsoWeight = Mathf.MoveTowards(torsoWeight, num4, deltaTime / 0.25f);
				for (int j = 0; j < 4; j++)
				{
					saved[j] = bones[j].localRotation;
				}
				hasSaved = true;
				Vector3 val3 = Vector3.Cross(Vector3.up, val);
				for (int k = 0; k < 4; k++)
				{
					float num5 = ((k < 2) ? torsoWeight : Mathf.Max(torsoWeight, 0.8f));
					Quaternion val4 = Quaternion.AngleAxis((0f - pitch) * PitchShare[k] * num5, val3) * Quaternion.AngleAxis(yaw * YawShare[k] * num5, Vector3.up);
					bones[k].rotation = val4 * bones[k].rotation;
				}
				for (int l = 0; l < 4; l++)
				{
					applied[l] = bones[l].localRotation;
				}
				hasApplied = true;
			}
		}

		private void OnDisable()
		{
			Update();
			hasApplied = false;
		}
	}
	internal static class FoundationAnimRules
	{
		internal const float GestureMoveSpeed = 1.2f;

		internal const float RunStopMinSpeed = 3.5f;

		internal const float RunStopMinForward = 0.7f;

		internal const float RecentSpeedDecay = 20f;

		internal const float FidgetMinSeconds = 8f;

		internal const float FidgetMaxSeconds = 15f;

		internal static bool IsAscending(float verticalSpeed)
		{
			return verticalSpeed > 0.5f;
		}

		internal static bool UseArmsLayer(float planarSpeed, bool grounded)
		{
			if (grounded)
			{
				return planarSpeed > 1.2f;
			}
			return true;
		}

		internal static float TrackRecentSpeed(float recent, float speed, float deltaTime)
		{
			return Math.Max(speed, recent - 20f * Math.Max(0f, deltaTime));
		}

		internal static bool ShouldRunStop(float recentSpeed, float forwardFraction)
		{
			if (recentSpeed >= 3.5f)
			{
				return forwardFraction >= 0.7f;
			}
			return false;
		}

		internal static bool RunStopOnRightFoot(float locomotionPhase)
		{
			float num = locomotionPhase - (float)Math.Floor(locomotionPhase);
			if (num >= 0.25f)
			{
				return num < 0.75f;
			}
			return false;
		}

		internal static int PickFidget(int count, int previous, float roll)
		{
			if (count <= 0)
			{
				return -1;
			}
			if (count == 1)
			{
				return 0;
			}
			int num;
			int num2;
			if (previous >= 0)
			{
				num = ((previous < count) ? 1 : 0);
				if (num != 0)
				{
					num2 = count - 1;
					goto IL_0020;
				}
			}
			else
			{
				num = 0;
			}
			num2 = count;
			goto IL_0020;
			IL_0020:
			int num3 = num2;
			int num4 = Math.Min(num3 - 1, Math.Max(0, (int)(roll * (float)num3)));
			if (num != 0 && num4 >= previous)
			{
				num4++;
			}
			return num4;
		}
	}
	internal sealed class FoundationIdleFidgetTimer
	{
		private readonly Func<float, float, float> range;

		private float remaining = -1f;

		internal float Remaining => remaining;

		internal bool Armed => remaining >= 0f;

		internal FoundationIdleFidgetTimer(Func<float, float, float> range)
		{
			this.range = range;
		}

		internal void Cancel()
		{
			remaining = -1f;
		}

		internal bool Tick(bool eligible, float deltaTime)
		{
			if (!eligible)
			{
				remaining = -1f;
				return false;
			}
			if (remaining < 0f)
			{
				float val = range(8f, 15f);
				remaining = Math.Max(8f, Math.Min(15f, val));
				return false;
			}
			remaining -= Math.Max(0f, deltaTime);
			if (remaining > 0f)
			{
				return false;
			}
			remaining = -1f;
			return true;
		}
	}
	internal struct ArmSpring
	{
		public float X;

		public float V;
	}
	internal struct ArmMotion
	{
		public float ForwardAccel;

		public float RightAccel;

		public float YawRate;

		public float Speed;

		public float Glide;

		public bool Airborne;

		public float VerticalSpeed;
	}
	internal sealed class ArmChain
	{
		public const int Levels = 4;

		public readonly ArmSpring[] Swing = new ArmSpring[4];

		public readonly ArmSpring[] Spread = new ArmSpring[4];

		public void Reset()
		{
			for (int i = 0; i < 4; i++)
			{
				Swing[i] = default(ArmSpring);
				Spread[i] = default(ArmSpring);
			}
		}

		public float LocalSwing(int level, float followThrough)
		{
			return FoundationArmLifeMath.Clamp((level == 0) ? Swing[0].X : ((Swing[level].X - Swing[level - 1].X) * followThrough), 0f - FoundationArmLifeMath.LocalLimit(level), FoundationArmLifeMath.LocalLimit(level));
		}

		public float LocalSpread(int level, float followThrough)
		{
			return FoundationArmLifeMath.Clamp((level == 0) ? Spread[0].X : ((Spread[level].X - Spread[level - 1].X) * followThrough), 0f - FoundationArmLifeMath.LocalLimit(level), FoundationArmLifeMath.LocalLimit(level));
		}
	}
	internal static class FoundationArmLifeMath
	{
		internal const float MaxStep = 0.1f;

		internal const float SubStep = 1f / 120f;

		internal const float MaxVelocity = 400f;

		internal const float TargetLimit = 12f;

		internal const float HardLimit = 18f;

		internal const float AccelClamp = 30f;

		internal const float YawClamp = 540f;

		private static readonly float[] Hz = new float[4] { 1.8f, 2.8f, 3.4f, 4.4f };

		private static readonly float[] Zeta = new float[4] { 0.5f, 0.5f, 0.45f, 0.4f };

		private static readonly float[] Reach = new float[4] { 1f, 1.15f, 1.1f, 1.05f };

		private static readonly float[] Local = new float[4] { 14f, 8f, 8f, 6f };

		internal const float AccelSwing = 0.35f;

		internal const float AccelSpread = 0.3f;

		internal const float YawSwing = 0.012f;

		internal const float YawFling = 3f;

		internal const float SpeedTrail = 4f;

		internal const float GlideTrail = 3f;

		internal const float AirLift = 4f;

		internal const float AirLiftFast = 2f;

		internal const float AirSwing = -1.5f;

		internal const float LandKickPerMps = 7f;

		internal const float LandMaxFall = 25f;

		internal const float TakeoffKickPerMps = 3f;

		internal const float TakeoffMaxSpeed = 20f;

		internal const float SwayDegrees = 1.6f;

		internal const float CastShare = 0.25f;

		internal const float CastFadeOut = 0.08f;

		internal const float CastFadeIn = 0.2f;

		internal static readonly string[] OneHandedGestures = new string[4] { "Arc Bolt left", "Arc Bolt right", "Conduit Spear", "Conduit Spear recover" };

		internal static float LocalLimit(int level)
		{
			return Local[level];
		}

		internal static float Clamp(float v, float lo, float hi)
		{
			if (!(v < lo))
			{
				if (!(v > hi))
				{
					return v;
				}
				return hi;
			}
			return lo;
		}

		internal static float Clamp01(float v)
		{
			return Clamp(v, 0f, 1f);
		}

		internal static float ClampDt(float dt)
		{
			if (float.IsNaN(dt) || dt <= 0f)
			{
				return 0f;
			}
			if (!(dt > 0.1f))
			{
				return dt;
			}
			return 0.1f;
		}

		internal static float Filter(float current, float target, float rate, float dt)
		{
			return current + (target - current) * (1f - (float)Math.Exp((0f - rate) * dt));
		}

		internal static float Soft(float x, float limit)
		{
			return limit * (float)Math.Tanh(x / limit);
		}

		internal static void StepSpring(ref ArmSpring s, float target, float hz, float zeta, float dt)
		{
			dt = ClampDt(dt);
			if (float.IsNaN(target) || float.IsInfinity(target))
			{
				target = 0f;
			}
			if (float.IsNaN(s.X) || float.IsNaN(s.V))
			{
				s.X = 0f;
				s.V = 0f;
			}
			float num = MathF.PI * 2f * hz;
			float num2 = num * num;
			float num3 = 2f * zeta * num;
			while (dt > 0f)
			{
				float num4 = ((dt > 1f / 120f) ? (1f / 120f) : dt);
				dt -= num4;
				s.V += (num2 * (target - s.X) - num3 * s.V) * num4;
				s.V = Clamp(s.V, -400f, 400f);
				s.X += s.V * num4;
				if (s.X > 18f)
				{
					s.X = 18f;
					if (s.V > 0f)
					{
						s.V = 0f;
					}
				}
				else if (s.X < -18f)
				{
					s.X = -18f;
					if (s.V < 0f)
					{
						s.V = 0f;
					}
				}
			}
		}

		internal static void Targets(ArmMotion m, float side, float reaction, float air, out float swing, out float spread)
		{
			float num = Clamp(m.ForwardAccel, -30f, 30f);
			float num2 = Clamp(m.RightAccel, -30f, 30f);
			float num3 = Clamp(m.YawRate, -540f, 540f);
			float num4 = Clamp01((m.Speed - 2f) / 10f);
			float num5 = -0.35f * num + side * 0.012f * num3 - 4f * num4 - 3f * Clamp01(m.Glide);
			float num6 = (0f - side) * 0.3f * num2 + 3f * Math.Abs(num3) / 540f;
			num5 *= reaction;
			num6 *= reaction;
			if (m.Airborne)
			{
				num6 += (4f + 2f * Clamp01(Math.Abs(m.VerticalSpeed) / 15f)) * air;
				num5 += -1.5f * air;
			}
			swing = Soft(num5, 12f);
			spread = Soft(num6, 12f);
		}

		internal static void Sway(float time, float seed, float amount, out float swing, out float spread)
		{
			double num = time;
			double num2 = 0.6 * Math.Sin(Math.PI * 2.0 * num / 5.3 + (double)seed) + 0.4 * Math.Sin(Math.PI * 2.0 * num / 3.1 + 1.7 * (double)seed);
			double num3 = 0.6 * Math.Sin(Math.PI * 2.0 * num / 6.7 + 2.3 * (double)seed) + 0.4 * Math.Sin(Math.PI * 2.0 * num / 4.3 + 0.9 * (double)seed);
			swing = (float)(num2 * 1.600000023841858 * (double)amount);
			spread = (float)(num3 * 1.600000023841858 * 0.75 * (double)amount);
		}

		internal static void StepChain(ArmChain c, float swingTarget, float spreadTarget, float dt)
		{
			StepSpring(ref c.Swing[0], swingTarget, Hz[0], Zeta[0], dt);
			StepSpring(ref c.Spread[0], spreadTarget, Hz[0], Zeta[0], dt);
			for (int i = 1; i < 4; i++)
			{
				StepSpring(ref c.Swing[i], c.Swing[i - 1].X * Reach[i], Hz[i], Zeta[i], dt);
				StepSpring(ref c.Spread[i], c.Spread[i - 1].X * Reach[i], Hz[i], Zeta[i], dt);
			}
		}

		internal static void Kick(ArmChain c, float swingVelocity, float spreadVelocity)
		{
			c.Swing[0].V = Clamp(c.Swing[0].V + swingVelocity, -400f, 400f);
			c.Spread[0].V = Clamp(c.Spread[0].V + spreadVelocity, -400f, 400f);
		}

		internal static float LandingKick(float fallSpeed, float amount)
		{
			return -7f * Clamp(fallSpeed, 0f, 25f) * amount;
		}

		internal static float TakeoffKick(float upSpeed, float amount)
		{
			return -3f * Clamp(upSpeed, 0f, 20f) * amount;
		}

		internal static float CastWeight(float current, bool casting, float dt)
		{
			dt = ClampDt(dt);
			if (casting)
			{
				return Math.Max(0.25f, current - dt * 0.75f / 0.08f);
			}
			return Math.Min(1f, current + dt * 0.75f / 0.2f);
		}

		internal static int CastingArm(string state)
		{
			switch (state)
			{
			case "Arc Bolt left":
				return -1;
			case "Arc Bolt right":
			case "Conduit Spear":
			case "Conduit Spear recover":
				return 1;
			default:
				return 0;
			}
		}
	}
	[DefaultExecutionOrder(101)]
	[DisallowMultipleComponent]
	public sealed class FoundationArmPose : MonoBehaviour
	{
		private sealed class Arm
		{
			public Transform shoulder;

			public Transform upperarm;

			public Transform forearm;

			public Transform hand;

			public readonly Transform[,] fingers = new Transform[4, 3];

			public readonly float[] fingerSeed = new float[4];

			public readonly Quaternion[,] fingerLife = new Quaternion[4, 3];

			public float wristSeed;

			public float swaySeed;

			public float curlSign = 1f;

			public float fallbackSide;

			public readonly ArmChain chain = new ArmChain();

			public float cast = 1f;

			public float fingersWeight = 1f;

			public Transform[] pinBones;

			public Quaternion[] pinPose;

			public float pin;
		}

		public static bool LifeEnabled = true;

		public static float LifeIntensity = 1f;

		public static float ReactionIntensity = 1f;

		public static float AirIntensity = 1f;

		public static float IdleSwayIntensity = 1f;

		public static float FollowThrough = 1f;

		private const float FadeSeconds = 0.15f;

		private const float BreathHz = 0.25f;

		private const float FingerCurlDegrees = 6f;

		private const float WristSwayDegrees = 3.6f;

		private const float DashReaction = 0.5f;

		private const float TeleportSpeed = 80f;

		private static readonly string[] FingerNames = new string[4] { "index", "middle", "ring", "little" };

		private static readonly float[] SegmentShare = new float[3] { 0.45f, 0.35f, 0.2f };

		private static readonly int EmptyHash = Animator.StringToHash("Empty");

		private static Dictionary<int, int> oneHanded;

		private FoundationPresentation presentation;

		private CharacterBody body;

		private Animator animator;

		private Transform chest;

		private Transform pelvis;

		private readonly Arm left = new Arm();

		private readonly Arm right = new Arm();

		private Transform[] saved;

		private Quaternion[] savedRotations;

		private bool hasSaved;

		private int upperBodyLayer = -1;

		private int upperArmsLayer = -1;

		private int overlayLayer = -1;

		private float weight;

		private float breathPhase;

		private bool sampled;

		private bool wasAirborne;

		private Vector3 lastPosition;

		private Vector3 filteredVelocity;

		private Vector3 previousFiltered;

		private Vector3 accel;

		private Vector3 previousForward;

		private float yawRate;

		private float airTime;

		private float fallSpeed;

		private const float PinInFallback = 0.1f;

		private const float PinOut = 0.12f;

		private FoundationLayerWeights layerWeights;

		private bool weightsResolved;

		private bool pinCaptured;

		private AnimationClip castClip;

		private AnimationClip holdClip;

		private bool clipsResolved;

		private Transform[] sampleBones;

		private Vector3[] samplePos;

		private Vector3[] sampleScale;

		private Quaternion[] sampleRot;

		private static readonly int CastArmsHash = Animator.StringToHash("Open Circuit arms");

		private static readonly int HoldArmsHash = Animator.StringToHash("Open Circuit arms hold");

		internal static bool DebugCompare;

		internal float DebugSampleError = -1f;

		internal int DebugPinArm;

		internal bool DebugPinSampled;

		private SpearCarry carryCache;

		private Quaternion[] appliedRotations;

		private bool hasApplied;

		internal bool LeftCasting { get; private set; }

		internal bool RightCasting { get; private set; }

		internal float DebugPinLeft => left.pin;

		internal float DebugPinRight => right.pin;

		private void Start()
		{
			presentation = ((Component)this).GetComponent<FoundationPresentation>();
			body = ((Component)this).GetComponentInParent<CharacterBody>();
			animator = ((Component)this).GetComponent<Animator>();
			Transform[] componentsInChildren = ((Component)this).GetComponentsInChildren<Transform>(true);
			foreach (Transform val in componentsInChildren)
			{
				string name = ((Object)val).name;
				if (name == "chest")
				{
					chest = val;
				}
				else if (name == "pelvis")
				{
					pelvis = val;
				}
				else
				{
					if (name.Length < 3 || name[1] != ' ' || (name[0] != 'L' && name[0] != 'R'))
					{
						continue;
					}
					Arm arm = ((name[0] == 'L') ? left : right);
					string text = name.Substring(2);
					switch (text)
					{
					case "shoulder":
						arm.shoulder = val;
						continue;
					case "upperarm":
						arm.upperarm = val;
						continue;
					case "forearm":
						arm.forearm = val;
						continue;
					case "hand":
						arm.hand = val;
						continue;
					}
					int num = text.IndexOf('.');
					if (num > 0 && num + 2 == text.Length)
					{
						int num2 = Array.IndexOf(FingerNames, text.Substring(0, num));
						int num3 = text[num + 1] - 49;
						if (num2 >= 0 && num3 >= 0 && num3 < 3)
						{
							arm.fingers[num2, num3] = val;
						}
					}
				}
			}
			if (!Object.op_Implicit((Object)(object)body) || !Valid(left) || !Valid(right))
			{
				if (Object.op_Implicit((Object)(object)body))
				{
					Plugin.Log.LogWarning("HOLLOW_SAINT_ARM_POSE missing a required arm bone; arm life disabled.");
				}
				((Behaviour)this).enabled = false;
				return;
			}
			float num4 = (float)(((Object)this).GetInstanceID() & 0x3FF) * 0.37f;
			for (int j = 0; j < 4; j++)
			{
				left.fingerSeed[j] = num4 + 11.3f * (float)j;
				right.fingerSeed[j] = num4 + 57.9f + 13.7f * (float)j;
			}
			left.wristSeed = num4 + 101.1f;
			right.wristSeed = num4 + 203.7f;
			left.swaySeed = num4 * 0.11f;
			right.swaySeed = num4 * 0.11f + 2.4f;
			breathPhase = num4;
			left.curlSign = 1f;
			right.curlSign = -1f;
			left.fallbackSide = -1f;
			right.fallbackSide = 1f;
			ClearFingerLife(left);
			ClearFingerLife(right);
			List<Transform> list = new List<Transform>();
			if (Object.op_Implicit((Object)(object)chest))
			{
				list.Add(chest);
			}
			Collect(left, list);
			Collect(right, list);
			List<Transform> list2 = new List<Transform>();
			Collect(left, list2);
			left.pinBones = list2.ToArray();
			list2.Clear();
			Collect(right, list2);
			right.pinBones = list2.ToArray();
			left.pinPose = (Quaternion[])(object)new Quaternion[left.pinBones.Length];
			right.pinPose = (Quaternion[])(object)new Quaternion[right.pinBones.Length];
			saved = list.ToArray();
			savedRotations = (Quaternion[])(object)new Quaternion[saved.Length];
			if (Object.op_Implicit((Object)(object)animator))
			{
				upperBodyLayer = animator.GetLayerIndex("UpperBody");
				upperArmsLayer = animator.GetLayerIndex("UpperArms");
				overlayLayer = animator.GetLayerIndex("Overlay");
			}
			if (oneHanded == null)
			{
				oneHanded = new Dictionary<int, int>();
				string[] oneHandedGestures = FoundationArmLifeMath.OneHandedGestures;
				foreach (string text2 in oneHandedGestures)
				{
					oneHanded[Animator.StringToHash(text2)] = FoundationArmLifeMath.CastingArm(text2);
				}
			}
		}

		private static bool Valid(Arm a)
		{
			if (Object.op_Implicit((Object)(object)a.shoulder) && Object.op_Implicit((Object)(object)a.upperarm) && Object.op_Implicit((Object)(object)a.forearm))
			{
				return Object.op_Implicit((Object)(object)a.hand);
			}
			return false;
		}

		private static void Collect(Arm a, List<Transform> list)
		{
			list.Add(a.shoulder);
			list.Add(a.upperarm);
			list.Add(a.forearm);
			list.Add(a.hand);
			for (int i = 0; i < 4; i++)
			{
				for (int j = 0; j < 3; j++)
				{
					if (Object.op_Implicit((Object)(object)a.fingers[i, j]))
					{
						list.Add(a.fingers[i, j]);
					}
				}
			}
		}

		private static void ClearFingerLife(Arm a)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < 4; i++)
			{
				for (int j = 0; j < 3; j++)
				{
					a.fingerLife[i, j] = Quaternion.identity;
				}
			}
		}

		private void Update()
		{
			Restore();
		}

		private void LateUpdate()
		{
			TickPose(Time.deltaTime, Time.time);
		}

		internal void TickPose(float rawDt, float time)
		{
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: 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_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: 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_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0413: Unknown result type (might be due to invalid IL or missing references)
			//IL_0415: Unknown result type (might be due to invalid IL or missing references)
			//IL_0416: Unknown result type (might be due to invalid IL or missing references)
			//IL_036e: Unknown result type (might be due to invalid IL or missing references)
			//IL_036f: Unknown result type (might be due to invalid IL or missing references)
			//IL_037a: Unknown result type (might be due to invalid IL or missing references)
			//IL_037f: Unknown result type (might be due to invalid IL or missing references)
			if (rawDt <= 0f || float.IsNaN(rawDt) || float.IsInfinity(rawDt))
			{
				HoldLastPose();
				return;
			}
			float num = FoundationArmLifeMath.ClampDt(rawDt);
			if (!Object.op_Implicit((Object)(object)body) || !Object.op_Implicit((Object)(object)presentation) || !presentation.IsPresentingAlive)
			{
				ResetMotion();
				weight = 0f;
				hasApplied = false;
				return;
			}
			Vector3 up = Vector3.up;
			Vector3 val = Vector3.ProjectOnPlane(((Component)this).transform.forward, up);
			if (((Vector3)(ref val)).sqrMagnitude < 0.0001f)
			{
				val = ((((Vector3)(ref previousForward)).sqrMagnitude > 0.5f) ? previousForward : Vector3.forward);
			}
			((Vector3)(ref val)).Normalize();
			Vector3 val2 = Vector3.Cross(up, val);
			ArmMotion m = SampleMotion(rawDt, num, val, val2);
			float num2 = ((LifeEnabled && LifeIntensity > 0.001f) ? 1f : 0f);
			weight = Mathf.MoveTowards(weight, num2, num / 0.15f);
			if (weight < 0.001f)
			{
				left.chain.Reset();
				right.chain.Reset();
				ClearFingerLife(left);
				ClearFingerLife(right);
				for (int i = 0; i < saved.Length; i++)
				{
					savedRotations[i] = saved[i].localRotation;
				}
				hasSaved = true;
				PinHeldArm(num);
				SpearCarry.ApplyAim(body, time, rawDt);
				RecordApplied();
				return;
			}
			float num3 = Mathf.SmoothStep(0f, 1f, weight);
			int num4 = CastingMask();
			LeftCasting = (num4 & 1) != 0;
			RightCasting = (num4 & 2) != 0;
			left.cast = FoundationArmLifeMath.CastWeight(left.cast, (num4 & 1) != 0, num);
			right.cast = FoundationArmLifeMath.CastWeight(right.cast, (num4 & 2) != 0, num);
			Vector3 root = (Object.op_Implicit((Object)(object)pelvis) ? pelvis.position : ((Component)this).transform.position);
			float reaction = LifeIntensity * ReactionIntensity * (ArcStepState.IsBodyDashing(body) ? 0.5f : 1f);
			float air = LifeIntensity * AirIntensity;
			float sway = LifeIntensity * IdleSwayIntensity;
			StepArm(left, m, root, val2, reaction, air, sway, time, num);
			StepArm(right, m, root, val2, reaction, air, sway, time, num);
			for (int j = 0; j < saved.Length; j++)
			{
				savedRotations[j] = saved[j].localRotation;
			}
			hasSaved = true;
			PinHeldArm(num);
			breathPhase += num * 0.25f * MathF.PI * 2f;
			float num5 = Mathf.Sin(breathPhase);
			float num6 = num3 * LifeIntensity;
			if (Object.op_Implicit((Object)(object)chest))
			{
				chest.rotation = Quaternion.AngleAxis(-0.9f * num5 * num6 * Mathf.Min(left.cast, right.cast), val2) * chest.rotation;
			}
			Breathe(left, num5, num6 * left.cast);
			Breathe(right, num5, num6 * right.cast);
			ApplyArm(left, time, num3 * left.cast, num6 * left.cast, root, val, val2, num);
			ApplyArm(right, time, num3 * right.cast, num6 * right.cast, root, val, val2, num);
			SpearCarry.ApplyAim(body, time, rawDt);
			RecordApplied();
		}

		private ArmMotion SampleMotion(float rawDt, float dt, Vector3 forward, Vector3 side)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: 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_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0310: Unknown result type (might be due to invalid IL or missing references)
			//IL_0315: Unknown result type (might be due to invalid IL or missing references)
			//IL_0323: Unknown result type (might be due to invalid IL or missing references)
			//IL_0328: Unknown result type (might be due to invalid IL or missing references)
			//IL_0359: Unknown result type (might be due to invalid IL or missing references)
			//IL_035e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = ((Component)body).transform.position;
			Vector3 val = ((!body.hasEffectiveAuthority || !Object.op_Implicit((Object)(object)body.characterMotor)) ? (sampled ? ((position - lastPosition) / rawDt) : Vector3.zero) : body.characterMotor.velocity);
			lastPosition = position;
			bool flag = !presentation.GroundedForPresentation;
			if (float.IsNaN(((Vector3)(ref val)).sqrMagnitude) || float.IsInfinity(((Vector3)(ref val)).sqrMagnitude) || ((Vector3)(ref val)).sqrMagnitude > 6400f)
			{
				sampled = false;
				val = Vector3.zero;
				left.chain.Reset();
				right.chain.Reset();
			}
			if (!sampled)
			{
				filteredVelocity = (previousFiltered = val);
				accel = Vector3.zero;
				yawRate = 0f;
				previousForward = forward;
				wasAirborne = flag;
				airTime = (fallSpeed = 0f);
				sampled = true;
			}
			else
			{
				filteredVelocity = Vector3.Lerp(filteredVelocity, val, 1f - Mathf.Exp(-14f * dt));
				Vector3 val2 = (filteredVelocity - previousFiltered) / rawDt;
				previousFiltered = filteredVelocity;
				float num = 1f - Mathf.Exp(-10f * dt);
				accel = Vector3.Lerp(accel, Vector3.ClampMagnitude(val2, 30f), num);
				float num2 = Mathf.Clamp(Vector3.SignedAngle(previousForward, forward, Vector3.up) / rawDt, -720f, 720f);
				yawRate = Mathf.Lerp(yawRate, num2, num);
				previousForward = forward;
				float amount = LifeIntensity * AirIntensity;
				if (flag)
				{
					if (!wasAirborne && val.y > 4f)
					{
						float spreadVelocity = FoundationArmLifeMath.TakeoffKick(val.y, amount);
						FoundationArmLifeMath.Kick(left.chain, 0f, spreadVelocity);
						FoundationArmLifeMath.Kick(right.chain, 0f, spreadVelocity);
					}
					airTime += rawDt;
					fallSpeed = Mathf.Max(fallSpeed - 40f * dt, 0f - val.y);
				}
				else
				{
					if (wasAirborne && airTime > 0.12f && fallSpeed > 1f)
					{
						float num3 = FoundationArmLifeMath.LandingKick(fallSpeed, amount);
						FoundationArmLifeMath.Kick(left.chain, num3 * 0.3f, num3);
						FoundationArmLifeMath.Kick(right.chain, num3 * 0.3f, num3);
					}
					airTime = (fallSpeed = 0f);
				}
				wasAirborne = flag;
			}
			ArmMotion result = new ArmMotion
			{
				ForwardAccel = Vector3.Dot(accel, forward),
				RightAccel = Vector3.Dot(accel, side),
				YawRate = yawRate
			};
			Vector2 val3 = new Vector2(filteredVelocity.x, filteredVelocity.z);
			result.Speed = ((Vector2)(ref val3)).magnitude;
			result.Glide = presentation.GlideWeight;
			result.Airborne = flag;
			result.VerticalSpeed = filteredVelocity.y;
			return result;
		}

		private void StepArm(Arm a, ArmMotion m, Vector3 root, Vector3 side, float reaction, float air, float sway, float t, float dt)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			float num = Vector3.Dot(a.upperarm.position - root, side);
			float num2 = ((Mathf.Abs(num) > 0.02f) ? Mathf.Sign(num) : a.fallbackSide);
			FoundationArmLifeMath.Targets(m, num2, reaction, air, out var swing, out var spread);
			FoundationArmLifeMath.Sway(t, a.swaySeed, sway, out var swing2, out var spread2);
			FoundationArmLifeMath.StepChain(a.chain, swing + swing2, spread + spread2, dt);
			a.fallbackSide = num2;
		}

		private void PinHeldArm(float dt)
		{
			DebugPinArm = 0;
			DebugPinSampled = false;
			DebugSampleError = -1f;
			if (!weightsResolved)
			{
				layerWeights = ((Component)this).GetComponent<FoundationLayerWeights>();
				weightsResolved = true;
			}
			if (!Object.op_Implicit((Object)(object)layerWeights))
			{
				return;
			}
			int holdHash;
			float holdTime;
			int num = (DebugPinArm = layerWeights.PinTarget(out holdHash, out holdTime));
			if (num == 0)
			{
				if (layerWeights.HoldSteady(out holdHash, out holdTime))
				{
					if (DebugCompare)
					{
						DebugSampleError = SampleError(holdHash, holdTime);
					}
					Capture(left);
					Capture(right);
					pinCaptured = true;
				}
				else if (!layerWeights.HoldPresent())
				{
					pinCaptured = false;
				}
				if (left.pin > 0f)
				{
					Pin(left, held: false, instant: false, dt);
				}
				if (right.pin > 0f)
				{
					Pin(right, held: false, instant: false, dt);
				}
			}
			else
			{
				Arm a = ((num > 0) ? left : right);
				Arm arm = ((num > 0) ? right : left);
				bool flag = (DebugPinSampled = SampleHold(holdHash, holdTime, a));
				Pin(a, flag || pinCaptured, flag, dt);
				if (arm.pin > 0f)
				{
					Pin(arm, held: false, instant: false, dt);
				}
			}
		}

		private static void Capture(Arm a)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < a.pinBones.Length; i++)
			{
				a.pinPose[i] = a.pinBones[i].localRotation;
			}
		}

		private void ResolveClips()
		{
			clipsResolved = true;
			RuntimeAnimatorController val = (Object.op_Implicit((Object)(object)animator) ? animator.runtimeAnimatorController : null);
			if (!Object.op_Implicit((Object)(object)val) || animator.isHuman)
			{
				return;
			}
			AnimationClip[] animationClips = val.animationClips;
			foreach (AnimationClip val2 in animationClips)
			{
				if (Object.op_Implicit((Object)(object)val2))
				{
					string text = ((Object)val2).name.Replace('_', ' ');
					if (text == "Open Circuit arms")
					{
						castClip = val2;
					}
					else if (text == "Open Circuit arms hold")
					{
						holdClip = val2;
					}
				}
			}
			sampleBones = ((Component)this).GetComponentsInChildren<Transform>(true);
			samplePos = (Vector3[])(object)new Vector3[sampleBones.Length];
			sampleScale = (Vector3[])(object)new Vector3[sampleBones.Length];
			sampleRot = (Quaternion[])(object)new Quaternion[sampleBones.Length];
		}

		private bool SampleHold(int holdHash, float holdTime, Arm a)
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			if (!clipsResolved)
			{
				ResolveClips();
			}
			AnimationClip val = ((holdHash == HoldArmsHash) ? holdClip : ((holdHash == CastArmsHash) ? castClip : null));
			if (!Object.op_Implicit((Object)(object)val))
			{
				return false;
			}
			for (int i = 0; i < sampleBones.Length; i++)
			{
				Transform val2 = sampleBones[i];
				if (Object.op_Implicit((Object)(object)val2))
				{
					samplePos[i] = val2.localPosition;
					sampleRot[i] = val2.localRotation;
					sampleScale[i] = val2.localScale;
				}
			}
			val.SampleAnimation(((Component)this).gameObject, Mathf.Clamp01(holdTime) * val.length);
			for (int j = 0; j < a.pinBones.Length; j++)
			{
				a.pinPose[j] = a.pinBones[j].localRotation;
			}
			for (int k = 0; k < sampleBones.Length; k++)
			{
				Transform val3 = sampleBones[k];
				if (Object.op_Implicit((Object)(object)val3))
				{
					val3.localPosition = samplePos[k];
					val3.localRotation = sampleRot[k];
					val3.localScale = sampleScale[k];
				}
			}
			return true;
		}

		private float SampleError(int holdHash, float holdTime)
		{
			//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)
			if (!SampleHold(holdHash, holdTime, left))
			{
				return -1f;
			}
			float num = 0f;
			for (int i = 0; i < left.pinBones.Length; i++)
			{
				num = Mathf.Max(num, Quaternion.Angle(left.pinBones[i].localRotation, left.pinPose[i]));
			}
			return num;
		}

		private static void Pin(Arm a, bool held, bool instant, float dt)
		{
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			a.pin = ((held && instant) ? 1f : Mathf.MoveTowards(a.pin, held ? 1f : 0f, dt / (held ? 0.1f : 0.12f)));
			if (!(a.pin <= 0f))
			{
				float num = Mathf.SmoothStep(0f, 1f, a.pin);
				for (int i = 0; i < a.pinBones.Length; i++)
				{
					a.pinBones[i].localRotation = Quaternion.Slerp(a.pinBones[i].localRotation, a.pinPose[i], num);
				}
			}
		}

		private SpearCarry Carry()
		{
			if (!Object.op_Implicit((Object)(object)carryCache) && Object.op_Implicit((Object)(object)body))
			{
				carryCache = ((Component)body).GetComponent<SpearCarry>();
			}
			return carryCache;
		}

		private int CastingMask()
		{
			if (!Object.op_Implicit((Object)(object)animator))
			{
				return 0;
			}
			SpearCarry spearCarry = Carry();
			return LayerMask(upperBodyLayer) | LayerMask(upperArmsLayer) | LayerMask(overlayLayer) | ((Object.op_Implicit((Object)(object)spearCarry) && spearCarry.Casting) ? (spearCarry.Left ? 1 : 2) : 0);
		}

		private int LayerMask(int layer)
		{
			//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_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			if (KitAnim.LayerIdle(animator, layer))
			{
				return 0;
			}
			AnimatorStateInfo val = animator.GetCurrentAnimatorStateInfo(layer);
			int num = HashMask(((AnimatorStateInfo)(ref val)).shortNameHash);
			if (animator.IsInTransition(layer))
			{
				int num2 = num;
				val = animator.GetNextAnimatorStateInfo(layer);
				num = num2 | HashMask(((AnimatorStateInfo)(ref val)).shortNameHash);
			}
			return num;
		}

		private static int HashMask(int hash)
		{
			if (hash == EmptyHash)
			{
				return 0;
			}
			if (oneHanded != null && oneHanded.TryGetValue(hash, out var value) && value != 0)
			{
				if (value >= 0)
				{
					return 2;
				}
				return 1;
			}
			return 3;
		}

		private static void Breathe(Arm a, float breath, float w)
		{
			//IL_0006: 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_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: 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_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: 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_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = Vector3.ProjectOnPlane(a.upperarm.position - a.shoulder.position, Vector3.up);
			if (!(((Vector3)(ref val)).sqrMagnitude < 1E-06f))
			{
				Vector3 val2 = Vector3.Cross(((Vector3)(ref val)).normalized, Vector3.up);
				float num = 1.2f * breath * w;
				a.shoulder.rotation = Quaternion.AngleAxis(num, val2) * a.shoulder.rotation;
				a.upperarm.rotation = Quaternion.AngleAxis((0f - num) * 0.8f, val2) * a.upperarm.rotation;
			}
		}

		private static void Bend(Transform bone, Vector3 dir, float swing, float spread, Vector3 forward, Vector3 outwardUp)
		{
			//IL_0016: 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_0029: 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_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			if (((Vector3)(ref dir)).sqrMagnitude < 1E-06f)
			{
				return;
			}
			((Vector3)(ref dir)).Normalize();
			Quaternion val = Quaternion.identity;
			if (Mathf.Abs(swing) > 0.01f)
			{
				Vector3 val2 = Vector3.Cross(dir, forward);
				float magnitude = ((Vector3)(ref val2)).magnitude;
				if (magnitude > 0.05f)
				{
					val = Quaternion.AngleAxis(swing * magnitude, val2 / magnitude) * val;
				}
			}
			if (Mathf.Abs(spread) > 0.01f)
			{
				Vector3 val3 = Vector3.Cross(dir, outwardUp);
				float magnitude2 = ((Vector3)(ref val3)).magnitude;
				if (magnitude2 > 0.05f)
				{
					val = Quaternion.AngleAxis(spread * magnitude2, val3 / magnitude2) * val;
				}
			}
			bone.rotation = val * bone.rotation;
		}

		private void ApplyArm(Arm a, float t, float react, float noise, Vector3 root, Vector3 forward, Vector3 side, float dt)
		{
			//IL_0014: 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_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_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: 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_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0297: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: 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_02cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02de: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0300: 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_0314: Unknown result type (might be due to invalid IL or missing references)
			//IL_0319: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_040d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0412: Unknown result type (might be due to invalid IL or missing references)
			ArmChain chain = a.chain;
			float followThrough = FollowThrough;
			float fallbackSide = a.fallbackSide;
			Vector3 val = side * fallbackSide + Vector3.up * 0.6f;
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			Bend(a.upperarm, a.forearm.position - a.upperarm.position, chain.LocalSwing(0, followThrough) * react, chain.LocalSpread(0, followThrough) * react, forward, normalized);
			Bend(a.forearm, a.hand.position - a.forearm.position, chain.LocalSwing(1, followThrough) * react, chain.LocalSpread(1, followThrough) * react, forward, normalized);
			Transform val2 = (Object.op_Implicit((Object)(object)a.fingers[1, 0]) ? a.fingers[1, 0] : a.fingers[0, 0]);
			Vector3 val3 = (Object.op_Implicit((Object)(object)val2) ? (val2.position - a.hand.position) : (a.hand.position - a.forearm.position));
			if (((Vector3)(ref val3)).sqrMagnitude < 1E-06f)
			{
				return;
			}
			((Vector3)(ref val3)).Normalize();
			Vector3 val4 = AcrossKnuckles(a, val3);
			float num = (Mathf.PerlinNoise(a.wristSeed, t * 0.23f) - 0.5f) * 2f * 3.6f;
			float num2 = (Mathf.PerlinNoise(a.wristSeed + 7.7f, t * 0.19f) - 0.5f) * 2f * 3.6f * 0.6f;
			a.hand.rotation = Quaternion.AngleAxis(num * noise, val4) * Quaternion.AngleAxis(num2 * noise, Vector3.Cross(val3, val4)) * a.hand.rotation;
			Bend(a.hand, val3, chain.LocalSwing(2, followThrough) * react, chain.LocalSpread(2, followThrough) * react, forward, normalized);
			SpearCarry spearCarry = Carry();
			if (Object.op_Implicit((Object)(object)spearCarry) && spearCarry.Gripping && a == (spearCarry.Left ? left : right))
			{
				a.fingersWeight = 0f;
				ClearFingerLife(a);
				return;
			}
			a.fingersWeight = Mathf.MoveTowards(a.fingersWeight, 1f, dt / 0.2f);
			float num3 = Mathf.SmoothStep(0f, 1f, a.fingersWeight);
			react *= num3;
			noise *= num3;
			val3 = (Object.op_Implicit((Object)(object)val2) ? (val2.position - a.hand.position) : val3);
			if (((Vector3)(ref val3)).sqrMagnitude < 1E-06f)
			{
				return;
			}
			((Vector3)(ref val3)).Normalize();
			val4 = AcrossKnuckles(a, val3);
			UpdateCurlSign(a, val4);
			Vector3 val5 = val4 * a.curlSign;
			float num4 = Vector3.Dot(Vector3.Cross(val3, forward) * (chain.LocalSwing(3, followThrough) * react) + Vector3.Cross(val3, normalized) * (chain.LocalSpread(3, followThrough) * react), val5);
			if (num4 > 0f)
			{
				num4 *= 0.5f;
			}
			float num5 = 1f - Mathf.Exp(-32f * dt);
			for (int i = 0; i < 4; i++)
			{
				float num6 = ((Mathf.PerlinNoise(a.fingerSeed[i], t * (0.3f + 0.05f * (float)i)) - 0.5f) * 2f * 6f + 1f) * noise + num4;
				for (int j = 0; j < 3; j++)
				{
					Transform val6 = a.fingers[i, j];
					if (Object.op_Implicit((Object)(object)val6))
					{
						Quaternion val7 = Quaternion.AngleAxis(num6 * SegmentShare[j] * 2f, val6.InverseTransformDirection(val5));
						a.fingerLife[i, j] = Quaternion.Slerp(a.fingerLife[i, j], val7, num5);
						val6.localRotation *= a.fingerLife[i, j];
					}
				}
			}
		}

		private static Vector3 AcrossKnuckles(Arm a, Vector3 handDir)
		{
			//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_0032: 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_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_0045: 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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: 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)
			Transform val = a.fingers[0, 0];
			Transform val2 = a.fingers[3, 0];
			Vector3 val3 = ((Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val2)) ? (val.position - val2.position) : Vector3.Cross(handDir, Vector3.up));
			val3 = Vector3.ProjectOnPlane(val3, handDir);
			if (!(((Vector3)(ref val3)).sqrMagnitude > 1E-07f))
			{
				Vector3 val4 = Vector3.Cross(handDir, Vector3.forward);
				return ((Vector3)(ref val4)).normalized;
			}
			return ((Vector3)(ref val3)).normalized;
		}

		private static void UpdateCurlSign(Arm a, Vector3 across)
		{
			//IL_0052: 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_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			float num = 0f;
			for (int i = 0; i < 4; i++)
			{
				Transform val = a.fingers[i, 0];
				Transform val2 = a.fingers[i, 1];
				Transform val3 = a.fingers[i, 2];
				if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val2) && Object.op_Implicit((Object)(object)val3))
				{
					Vector3 val4 = val2.position - val.position;
					Vector3 val5 = val3.position - val2.position;
					num += Vector3.Dot(Vector3.Cross(((Vector3)(ref val4)).normalized, ((Vector3)(ref val5)).normalized), across);
				}
			}
			if (Mathf.Abs(num) > 0.15f)
			{
				a.curlSign = Mathf.Sign(num);
			}
		}

		private void ResetMotion()
		{
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			sampled = false;
			left.chain.Reset();
			right.chain.Reset();
			ClearFingerLife(left);
			ClearFingerLife(right);
			left.cast = (right.cast = 1f);
			left.pin = (right.pin = 0f);
			pinCaptured = false;
			accel = Vector3.zero;
			yawRate = (airTime = (fallSpeed = 0f));
		}

		private void RecordApplied()
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			if (appliedRotations == null || appliedRotations.Length != saved.Length)
			{
				appliedRotations = (Quaternion[])(object)new Quaternion[saved.Length];
			}
			for (int i = 0; i < saved.Length; i++)
			{
				if (Object.op_Implicit((Object)(object)saved[i]))
				{
					appliedRotations[i] = saved[i].localRotation;
				}
			}
			hasApplied = true;
		}

		private void HoldLastPose()
		{
			//IL_0033: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			if (!hasApplied || saved == null)
			{
				return;
			}
			for (int i = 0; i < saved.Length; i++)
			{
				if (Object.op_Implicit((Object)(object)saved[i]))
				{
					savedRotations[i] = saved[i].localRotation;
					saved[i].localRotation = appliedRotations[i];
				}
			}
			hasSaved = true;
		}

		private void Restore()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			if (!hasSaved)
			{
				return;
			}
			for (int i = 0; i < saved.Length; i++)
			{
				if (Object.op_Implicit((Object)(object)saved[i]))
				{
					saved[i].localRotation = savedRotations[i];
				}
			}
			hasSaved = false;
		}

		private void OnDisable()
		{
			Restore();
			weight = 0f;
			ResetMotion();
		}
	}
	[DefaultExecutionOrder(-50)]
	[DisallowMultipleComponent]
	public sealed class FoundationLayerWeights : MonoBehaviour
	{
		private static readonly string[] Layers = new string[4] { "UpperBody", "Overlay", "UpperArms", "SpearCarry" };

		private const float FadeIn = 0.1f;

		private const float FadeOut = 0.2f;

		private static readonly int EmptyHash = Animator.StringToHash("Empty");

		private static readonly int RateHash = Animator.StringToHash("attackSpeed");

		private Animator animator;

		private int[] indices;

		private const float BoltStreamGraceSeconds = 0.12f;

		private int streamLayer = -1;

		private float streamUntil;

		private static readonly int CastArmsHash = Animator.StringToHash("Open Circuit arms");

		private static readonly int HoldArmsHash = Animator.StringToHash("Open Circuit arms hold");

		private static readonly int BoltRightHash = Animator.StringToHash("Arc Bolt right");

		private static readonly int BoltLeftHash = Animator.StringToHash("Arc Bolt left");

		private const float ResumeAt = 0.7f;

		private const float ResumeFade = 0.15f;

		private const float CastResumeCap = 0.9f;

		private int upperIdx = -1;

		private int armsIdx = -1;

		private int memoLayer = -1;

		private int memoHold;

		private int memoArm;

		private float memoHoldTime;

		private float memoHoldPeriod;

		private float memoHoldSpeed;

		private float memoStartedAt;

		private int resumeLayer = -1;

		private int resumeHold;

		private int resumeArm;

		private float resumeHoldTime;

		private int rateLayer = -1;

		private float rateValue;

		private float rateAt;

		private CharacterBody body;

		private EntityStateMachine crown;

		private bool crownResolved;

		private StoredChargeChargeFx ownerFx;

		internal string DebugLastResume = "";

		public static bool Managed(string layer)
		{
			for (int i = 0; i < Layers.Length; i++)
			{
				if (Layers[i] == layer)
				{
					return true;
				}
			}
			return false;
		}

		internal void Bind(CharacterBody owner)
		{
			if (Object.op_Implicit((Object)(object)owner) && !((Object)(object)owner == (Object)(object)body))
			{
				body = owner;
				crown = null;
				crownResolved = false;
				ownerFx = null;
			}
		}

		private void Start()
		{
			animator = ((Component)this).GetComponent<Animator>();
			if (!Object.op_Implicit((Object)(object)animator))
			{
				((Behaviour)this).enabled = false;
				return;
			}
			indices = new int[Layers.Length];
			for (int i = 0; i < Layers.Length; i++)
			{
				indices[i] = animator.GetLayerIndex(Layers[i]);
				if (indices[i] >= 0)
				{
					animator.SetLayerWeight(indices[i], 0f);
				}
			}
			upperIdx = animator.GetLayerIndex("UpperBody");
			armsIdx = animator.GetLayerIndex("UpperArms");
			if (!Object.op_Implicit((Object)(object)body))
			{
				body = ((Component)this).GetComponentInParent<CharacterBody>();
			}
		}

		private void Update()
		{
			if (!Object.op_Implicit((Object)(object)animator) || !((Behaviour)animator).isActiveAndEnabled)
			{
				return;
			}
			ApplyDeferredRate();
			TickBoltOverHold();
			float deltaTime = Time.deltaTime;
			for (int i = 0; i < indices.Length; i++)
			{
				int num = indices[i];
				if (num >= 0)
				{
					bool flag = Active(num) || BoltStreamGrace(num);
					float layerWeight = animator.GetLayerWeight(num);
					float num2 = (flag ? 1f : 0f);
					if (!(deltaTime <= 0f))
					{
						layerWeight = Mathf.MoveTowards(layerWeight, num2, deltaTime / (flag ? 0.1f : 0.2f));
						animator.SetLayerWeight(num, layerWeight);
					}
				}
			}
		}

		private bool Active(int layer)
		{
			//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_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)
			int num = KitAnim.PendingState(animator, layer);
			if (num != 0)
			{
				return num != EmptyHash;
			}
			AnimatorStateInfo currentAnimatorStateInfo = animator.GetCurrentAnimatorStateInfo(layer);
			if (animator.IsInTransition(layer))
			{
				AnimatorStateInfo nextAnimatorStateInfo = animator.GetNextAnimatorStateInfo(layer);
				return ((AnimatorStateInfo)(ref nextAnimatorStateInfo)).shortNameHash != EmptyHash;
			}
			return ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).shortNameHash != EmptyHash;
		}

		internal void NoteBolt(CharacterBody owner, string layerName, float duration)
		{
			Bind(owner);
			if (Object.op_Implicit((Object)(object)animator) && !string.IsNullOrEmpty(layerName))
			{
				streamLayer = animator.GetLayerIndex(layerName);
				streamUntil = Time.time + Mathf.Max(0.05f, duration) + 0.12f;
			}
		}

		private bool BoltStreamGrace(int layer)
		{
			if (layer != streamLayer)
			{
				return false;
			}
			if (Time.time > streamUntil)
			{
				streamLayer = -1;
				return false;
			}
			InputBankTest val = (Object.op_Implicit((Object)(object)body) ? body.inputBank : null);
			if (!Object.op_Implicit((Object)(object)val) || !val.skill1.down)
			{
				return false;
			}
			int num = Requested(layer);
			if (num != EmptyHash)
			{
				return IsBolt(num);
			}
			return true;
		}

		private static bool IsCrownHold(int hash)
		{
			if (hash != CastArmsHash)
			{
				return hash == HoldArmsHash;
			}
			return true;
		}

		private static bool IsBolt(int hash)
		{
			if (hash != BoltRightHash)
			{
				return hash == BoltLeftHash;
			}
			return true;
		}

		private static string HoldName(int hash)
		{
			if (hash != HoldArmsHash)
			{
				return "Open Circuit arms";
			}
			return "Open Circuit arms hold";
		}

		private int Requested(int layer)
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			if (layer < 0)
			{
				return EmptyHash;
			}
			int num = KitAnim.PendingState(animator, layer);
			if (num != 0)
			{
				return num;
			}
			AnimatorStateInfo val;
			if (!animator.IsInTransition(layer))
			{
				val = animator.GetCurrentAnimatorStateInfo(layer);
				return ((AnimatorStateInfo)(ref val)).shortNameHash;
			}
			val = animator.GetNextAnimatorStateInfo(layer);
			return ((AnimatorStateInfo)(ref val)).shortNameHash;
		}

		private bool HoldOwnerAlive(bool search)
		{
			if (!Object.op_Implicit((Object)(object)body))
			{
				return false;
			}
			if (!crownResolved)
			{
				crownResolved = true;
				crown = EntityStateMachine.FindByCustomName(((Component)body).gameObject, "Crown");
			}
			if (Object.op_Implicit((Object)(object)crown) && crown.state is GazeState)
			{
				return true;
			}
			if ((Object)(object)ownerFx != (Object)null)
			{
				return true;
			}
			if (!search)
			{
				return false;
			}
			ownerFx = ((Component)body).GetComponentInChildren<StoredChargeChargeFx>();
			return (Object)(object)ownerFx != (Object)null;
		}

		private int HoldLayer(int layer, ref int hold)
		{
			if (layer < 0)
			{
				return -1;
			}
			int num = Requested(layer);
			if (IsCrownHold(num))
			{
				hold = num;
				return layer;
			}
			if (memoLayer >= 0 && IsBolt(num))
			{
				return layer;
			}
			return -1;
		}

		private float HoldTimeNow(int layer)
		{
			//IL_0047: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			if (KitAnim.PendingState(animator, layer) != 0)
			{
				if (layer != resumeLayer)
				{
					return 0f;
				}
				return resumeHoldTime;
			}
			AnimatorStateInfo val = (animator.IsInTransition(layer) ? animator.GetNextAnimatorStateInfo(layer) : animator.GetCurrentAnimatorStateInfo(layer));
			return ((AnimatorStateInfo)(ref val)).normalizedTime;
		}

		internal bool TryPlayBoltOverHold(CharacterBody owner, string state, float duration, out string layerName)
		{
			layerName = null;
			Bind(owner);
			if (!Object.op_Implicit((Object)(object)animator) || !((Behaviour)this).isActiveAndEnabled || upperIdx < 0)
			{
				return false;
			}
			int hold = 0;
			int num = HoldLayer(armsIdx, ref hold);
			if (num < 0)
			{
				num = HoldLayer(upperIdx, ref hold);
			}
			if (num < 0 || !HoldOwnerAlive(search: true))
			{
				return false;
			}
			string text = ((num == armsIdx) ? "UpperArms" : "UpperBody");
			if (!KitAnim.HasState(animator, text, state))
			{
				return false;
			}
			if (hold != 0)
			{
				memoHold = hold;
				memoHoldTime = HoldTimeNow(num);
				memoHoldSpeed = ((rateLayer == num) ? rateValue : animator.GetFloat(RateHash));
				float num2 = KitAnim.ClipLength(animator, HoldName(hold));
				float num3 = ((hold == HoldArmsHash) ? 1f : Mathf.Max(0.05f, memoHoldSpeed));
				memoHoldPeriod = ((num2 > 0.01f) ? (num2 / num3) : 1f);
				memoStartedAt = Time.time;
			}
			rateLayer = -1;
			resumeLayer = -1;
			if (!KitAnim.Play(animator, text, state, duration))
			{
				return false;
			}
			memoLayer = num;
			memoArm = ((Animator.StringToHash(state) != BoltLeftHash) ? 1 : (-1));
			layerName = text;
			return true;
		}

		private void TickBoltOverHold()
		{
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			if (memoLayer < 0)
			{
				return;
			}
			int num = Requested(memoLayer);
			if (!IsBolt(num))
			{
				int num2 = ((memoLayer == upperIdx) ? armsIdx : upperIdx);
				if (num == EmptyHash && num2 >= 0 && IsBolt(Requested(num2)))
				{
					memoLayer = num2;
					num = Requested(num2);
				}
				else if (num != EmptyHash)
				{
					memoLayer = -1;
					return;
				}
			}
			if (!HoldOwnerAlive(search: false))
			{
				memoLayer = -1;
				return;
			}
			int num3 = KitAnim.PendingState(animator, memoLayer);
			if (num3 == EmptyHash)
			{
				memoLayer = -1;
			}
			else
			{
				if (num3 != 0)
				{
					return;
				}
				if (IsBolt(num))
				{
					if (animator.IsInTransition(memoLayer))
					{
						return;
					}
					AnimatorStateInfo currentAnimatorStateInfo = animator.GetCurrentAnimatorStateInfo(memoLayer);
					if (((AnimatorStateInfo)(ref currentAnimatorStateInfo)).normalizedTime < 0.7f)
					{
						return;
					}
				}
				Resume();
			}
		}

		private void Resume()
		{
			float num = memoHoldTime + (Time.time - memoStartedAt) / memoHoldPeriod;
			num = ((memoHold == HoldArmsHash) ? Mathf.Repeat(num, 1f) : Mathf.Min(num, 0.9f));
			float num2 = KitAnim.ClipLength(animator, HoldName(memoHold));
			float normalizedTime = num;
			if (memoHold == CastArmsHash && num2 > 0.01f)
			{
				float num3 = animator.GetFloat(RateHash);
				normalizedTime = Mathf.Max(0f, num - Mathf.Max(0f, num3 - memoHoldSpeed) * 0.15f / num2);
				rateLayer = memoLayer;
				rateValue = memoHoldSpeed;
				rateAt = Time.time + 0.15f;
			}
			KitAnim.ResumeHold(animator, memoLayer, memoHold, normalizedTime, num2, 0.15f);
			resumeLayer = memoLayer;
			resumeHold = memoHold;
			resumeArm = memoArm;
			resumeHoldTime = normalizedTime;
			DebugLastResume = "at=" + num.ToString("0.000") + " target=" + normalizedTime.ToString("0.000") + " clip=" + num2.ToString("0.000") + " rate=" + memoHoldSpeed.ToString("0.000") + " boltRate=" + animator.GetFloat(RateHash).ToString("0.000");
			memoLayer = -1;
		}

		private void ApplyDeferredRate()
		{
			if (rateLayer >= 0)
			{
				if (Requested(rateLayer) != CastArmsHash)
				{
					rateLayer = -1;
				}
				else if ((KitAnim.PendingState(animator, rateLayer) == 0 && !animator.IsInTransition(rateLayer)) || !(Time.time < rateAt))
				{
					animator.SetFloat(RateHash, rateValue);
					rateLayer = -1;
				}
			}
		}

		internal bool BoltOverHoldActive(string layer)
		{
			if (!Object.op_Implicit((Object)(object)animator) || memoLayer < 0)
			{
				return false;
			}
			int layerIndex = animator.GetLayerIndex(layer);
			if (layerIndex < 0 || !IsBolt(Requested(layerIndex)))
			{
				return false;
			}
			if (layerIndex == memoLayer)
			{
				return true;
			}
			if (Requested(memoLayer) == EmptyHash)
			{
				if (layerIndex != upperIdx)
				{
					return layerIndex == armsIdx;
				}
				return true;
			}
			return false;
		}

		internal int PinTarget(out int holdHash, out float holdTime)
		{
			//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)
			holdHash = 0;
			holdTime = 0f;
			if (!Object.op_Implicit((Object)(object)animator))
			{
				return 0;
			}
			if (memoLayer >= 0)
			{
				int num = Requested(memoLayer);
				if (num == EmptyHash)
				{
					int num2 = ((memoLayer == upperIdx) ? armsIdx : upperIdx);
					if (num2 >= 0 && IsBolt(Requested(num2)))
					{
						memoLayer = num2;
						num = Requested(num2);
					}
				}
				bool flag = num == EmptyHash && KitAnim.PendingState(animator, memoLayer) == 0;
				if (!IsBolt(num) && !flag)
				{
					memoLayer = -1;
					return 0;
				}
				holdHash = memoHold;
				float num3 = memoHoldTime + (Time.time - memoStartedAt) / memoHoldPeriod;
				holdTime = ((memoHold == HoldArmsHash) ? Mathf.Repeat(num3, 1f) : Mathf.Min(num3, 0.9f));
				if (num != BoltLeftHash)
				{
					if (num != BoltRightHash)
					{
						return memoArm;
					}
					return 1;
				}
				return -1;
			}
			if (resumeLayer < 0)
			{
				return 0;
			}
			int num4 = Requested(resumeLayer);
			int num5 = KitAnim.PendingState(animator, resumeLayer);
			if (!IsCrownHold(num4) || (num5 == 0 && !animator.IsInTransition(resumeLayer)))
			{
				resumeLayer = -1;
				return 0;
			}
			holdHash = num4;
			float normalizedTime;
			if (num5 == 0)
			{
				AnimatorStateInfo nextAnimatorStateInfo = animator.GetNextAnimatorStateInfo(resumeLayer);
				normalizedTime = ((AnimatorStateInfo)(ref nextAnimatorStateInfo)).normalizedTime;
			}
			else
			{
				normalizedTime = resumeHoldTime;
			}
			holdTime = normalizedTime;
			if (holdHash == HoldArmsHash)
			{
				holdTime = Mathf.Repeat(holdTime, 1f);
			}
			return resumeArm;
		}

		internal bool HoldSteady(out int holdHash, out float holdTime)
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			holdHash = 0;
			holdTime = 0f;
			if (memoLayer >= 0 || !Object.op_Implicit((Object)(object)animator))
			{
				return false;
			}
			int num = (Steady(upperIdx) ? upperIdx : (Steady(armsIdx) ? armsIdx : (-1)));
			if (num < 0)
			{
				return false;
			}
			AnimatorStateInfo currentAnimatorStateInfo = animator.GetCurrentAnimatorStateInfo(num);
			holdHash = ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).shortNameHash;
			holdTime = ((holdHash == HoldArmsHash) ? Mathf.Repeat(((AnimatorStateInfo)(ref currentAnimatorStateInfo)).normalizedTime, 1f) : ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).normalizedTime);
			return true;
		}

		internal bool HoldPresent()
		{
			if (!Object.op_Implicit((Object)(object)animator))
			{
				return false;
			}
			if (memoLayer < 0 && resumeLayer < 0 && !IsCrownHold(Requested(upperIdx)))
			{
				return IsCrownHold(Requested(armsIdx));
			}
			return true;
		}

		private bool Steady(int layer)
		{
			//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)
			if (layer < 0 || KitAnim.PendingState(animator, layer) != 0 || animator.IsInTransition(layer))
			{
				return false;
			}
			AnimatorStateInfo currentAnimatorStateInfo = animator.GetCurrentAnimatorStateInfo(layer);
			if (IsCrownHold(((AnimatorStateInfo)(ref currentAnimatorStateInfo)).shortNameHash))
			{
				return animator.GetLayerWeight(layer) > 0.95f;
			}
			return false;
		}

		internal string DebugState()
		{
			if (!Object.op_Implicit((Object)(object)animator))
			{
				return "no-animator";
			}
			return "memo=" + ((memoLayer >= 0) ? (memoLayer + "/" + StateName(memoHold) + " t0=" + memoHoldTime.ToString("0.000") + " period=" + memoHoldPeriod.ToString("0.00") + " arm=" + memoArm) : "-") + " resume=" + ((resumeLayer >= 0) ? (resumeLayer + "/" + StateName(resumeHold) + " arm=" + resumeArm) : "-") + " pendingRate=" + ((rateLayer >= 0) ? rateValue.ToString("0.000") : "-") + " rate=" + animator.GetFloat(RateHash).ToString("0.000") + " owner=" + HoldOwnerAlive(search: false) + " body=" + ((Object)(object)body != (Object)null) + " parentBody=" + ((Object)(object)((Component)this).GetComponentInParent<CharacterBody>() != (Object)null) + " | up " + LayerDesc(upperIdx) + " | arms " + LayerDesc(armsIdx);
		}

		private string LayerDesc(int layer)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: 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)
			if (layer < 0)
			{
				return "none";
			}
			AnimatorStateInfo currentAnimatorStateInfo = animator.GetCurrentAnimatorStateInfo(layer);
			string text = StateName(((AnimatorStateInfo)(ref currentAnimatorStateInfo)).shortNameHash) + "@" + ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).normalizedTime.ToString("0.000") + " len=" + ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).length.ToString("0.000") + " spd=" + ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).speed.ToString("0.00") + "x" + ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).speedMultiplier.ToString("0.00");
			if (animator.IsInTransition(layer))
			{
				AnimatorStateInfo nextAnimatorStateInfo = animator.GetNextAnimatorStateInfo(layer);
				string[] obj = new string[7]
				{
					text,
					" -> ",
					StateName(((AnimatorStateInfo)(ref nextAnimatorStateInfo)).shortNameHash),
					"@",
					((AnimatorStateInfo)(ref nextAnimatorStateInfo)).normalizedTime.ToString("0.000"),
					" tr=",
					null
				};
				AnimatorTransitionInfo animatorTransitionInfo = animator.GetAnimatorTransitionInfo(layer);
				obj[6] = ((AnimatorTransitionInfo)(ref animatorTransitionInfo)).normalizedTime.ToString("0.00");
				text = string.Concat(obj);
			}
			int num = KitAnim.PendingState(animator, layer);
			if (num != 0)
			{
				text = text + " pend=" + StateName(num);
			}
			return text + " w=" + animator.GetLayerWeight(layer).ToString("0.00");
		}

		private static string StateName(int hash)
		{
			if (hash == EmptyHash)
			{
				return "Empty";
			}
			if (hash == CastArmsHash)
			{
				return "Cast";
			}
			if (hash == HoldArmsHash)
			{
				return "Hold";
			}
			if (hash == BoltLeftHash)
			{
				return "BoltL";
			}
			if (hash == BoltRightHash)
			{
				return "BoltR";
			}
			return hash.ToString();
		}

		private void OnDisable()
		{
			memoLayer = (resumeLayer = (rateLayer = (streamLayer = -1)));
		}
	}
	internal static class FoundationLocomotionMath
	{
		internal readonly struct Sample
		{
			internal readonly float Gait;

			internal readonly float Rate;

			internal readonly float Duration;

			internal readonly float ReferenceSpeed;

			internal Sample(float gait, float rate, float duration, float referenceSpeed)
			{
				Gait = gait;
				Rate = rate;
				Duration = duration;
				ReferenceSpeed = referenceSpeed;
			}
		}

		internal const float WalkDuration = 1.0833334f;

		internal const float RunDuration = 2f / 3f;

		private static readonly float[] WalkSpeeds = new float[8] { 1.5f, 1.05f, 0.6f, 0.8f, 1f, 0.8f, 0.6f, 1.05f };

		private static readonly float[] RunSpeeds = new float[8] { 6f, 4.7f, 3.4f, 3.825f, 4.25f, 3.825f, 3.4f, 4.7f };

		internal static Sample Evaluate(float right, float forward, float actualSpeed)
		{
			float num = (float)(Math.Atan2(right, forward) * 4.0 / Math.PI);
			if (num < 0f)
			{
				num += 8f;
			}
			int num2 = (int)Math.Floor(num) % 8;
			int num3 = (num2 + 1) % 8;
			float num4 = num - (float)Math.Floor(num);
			float num5 = (float)Math.Cos((double)num4 * Math.PI / 4.0);
			float num6 = (float)Math.Cos((double)(1f - num4) * Math.PI / 4.0);
			float num7 = WalkSpeeds[num2] * (1f - num4) * num5 + WalkSpeeds[num3] * num4 * num6;
			float num8 = RunSpeeds[num2] * (1f - num4) * num5 + RunSpeeds[num3] * num4 * num6;
			float num9 = Math.Max(0f, actualSpeed);
			float num10 = Clamp((num9 - num7) / (num8 - num7), 0f, 1f);
			float num11 = Lerp(1.0833334f, 2f / 3f, num10);
			float num12 = Lerp(num7 * 1.0833334f, num8 * (2f / 3f), num10) / num11;
			return new Sample(num10, num9 / num12, num11, num12);
		}

		internal static float MovingEntryPhase(string previous, float retainedPhase)
		{
			if (previous == "Run start")
			{
				return 0.5f;
			}
			if (previous == "Glide exit")
			{
				return 0f;
			}
			return retainedPhase - (float)Math.Floor(retainedPhase);
		}

		internal static bool TryGetAuthoredStride(string clipName, out float right, out float forward, out float duration)
		{
			right = (forward = (duration = 0f));
			bool flag = clipName.StartsWith("Walk ", StringComparison.Ordinal);
			bool flag2 = clipName.StartsWith("Run ", StringComparison.Ordinal);
			if (!flag && !flag2)
			{
				return false;
			}
			int num;
			switch (clipName.Substring(flag ? 5 : 4))
			{
			case "forward":
				num = 0;
				break;
			case "forward right":
				num = 1;
				break;
			case "right":
				num = 2;
				break;
			case "backward right":
				num = 3;
				break;
			case "backward":
				num = 4;
				break;
			case "backward left":
				num = 5;
				break;
			case "left":
				num = 6;
				break;
			case "forward left":
				num = 7;
				break;
			default:
				return false;
			}
			duration = (flag ? 1.0833334f : (2f / 3f));
			float num2 = (flag ? WalkSpeeds[num] : RunSpeeds[num]) * duration;
			right = (float)Math.Sin((double)num * Math.PI / 4.0) * num2;
			forward = (float)Math.Cos((double)num * Math.PI / 4.0) * num2;
			return true;
		}

		private static float Lerp(float a, float b, float t)
		{
			return a + (b - a) * t;
		}

		private static float Clamp(float v, float lo, float hi)
		{
			return Math.Max(lo, Math.Min(hi, v));
		}
	}
	internal sealed class FoundationFootContactClock
	{
		private bool initialized;

		private int halfCycle;

		internal void Reset()
		{
			initialized = false;
		}

		internal bool Advance(float normalizedTime)
		{
			int num = (int)Math.Floor(normalizedTime * 2f + 1E-05f);
			bool result = initialized && num > halfCycle && num - halfCycle <= 2;
			halfCycle = num;
			initialized = true;
			return result;
		}
	}
	[DefaultExecutionOrder(100)]
	[DisallowMultipleComponent]
	public sealed class FoundationMotionPose : MonoBehaviour
	{
		private FoundationPresentation presentation;

		private CharacterBody body;

		private Animator animator;

		private SpearCarry carry;

		private int upperLayer = -1;

		private int armsLayer = -1;

		private int overlayLayer = -1;

		private Transform pelvis;

		private Transform spine;

		private Transform head;

		private Transform thighL;

		private Transform thighR;

		private Transform shinL;

		private Transform shinR;

		private Transform footL;

		private Transform footR;

		private readonly Dictionary<Transform, Quaternion> restore = new Dictionary<Transform, Quaternion>();

		private Vector3 previousVelocity;

		private Vector3 previousForward;

		private Vector3 previousFacing;

		private Vector3 leanVector;

		private Vector3 torsoLean;

		private float pitch;

		private float bank;

		private float acceleration;

		private float torsoBank;

		private float gestureWeight = 1f;

		private float glidePoseWeight;

		private bool sampled;

		private readonly Dictionary<Transform, Quaternion> applied = new Dictionary<Transform, Quaternion>();

		private float kick;

		private float kickVelocity;

		private float lastHealth = -1f;

		private const float KickStiffness = 170f;

		private const float KickDamping = 22f;

		private void Start()
		{
			presentation = ((Component)this).GetComponent<FoundationPresentation>();
			body = ((Component)this).GetComponentInParent<CharacterBody>();
			animator = ((Component)this).GetComponent<Animator>();
			if (Object.op_Implicit((Object)(object)animator))
			{
				upperLayer = animator.GetLayerIndex("UpperBody");
				armsLayer = animator.GetLayerIndex("UpperArms");
				overlayLayer = animator.GetLayerIndex("Overlay");
			}
			Transform[] componentsInChildren = ((Component)this).GetComponentsInChildren<Transform>(true);
			foreach (Transform val in componentsInChildren)
			{
				switch (((Object)val).name)
				{
				case "pelvis":
					pelvis = val;
					break;
				case "spine":
					spine = val;
					break;
				case "head":
					head = val;
					break;
				case "L thigh":
					thighL = val;
					break;
				case "R thigh":
					thighR = val;
					break;
				case "L shin":
					shinL = val;
					break;
				case "R shin":
					shinR = val;
					break;
				case "L foot":
					footL = val;
					break;
				case "R foot":
					footR = val;
					break;
				}
			}
			if (!Object.op_Implicit((Object)(object)body) || !Object.op_Implicit((Object)(object)pelvis) || !Object.op_Implicit((Object)(object)spine) || !Object.op_Implicit((Object)(object)head) || !Object.op_Implicit((Object)(object)thighL) || !Object.op_Implicit((Object)(object)thighR) || !Object.op_Implicit((Object)(object)shinL) || !Object.op_Implicit((Object)(object)shinR) || !Object.op_Implicit((Object)(object)footL) || !Object.op_Implicit((Object)(object)footR))
			{
				if (Object.op_Implicit((Object)(object)body))
				{
					Plugin.Log.LogWarning("HOLLOW_SAINT_MOTION_POSE missing a required posture bone; accents disabled.");
				}
				((Behaviour)this).enabled = false;
			}
		}

		private void Update()
		{
			Restore();
		}

		private void LateUpdate()
		{
			TickPose(Time.deltaTime);
		}

		internal void TickPose(float rawDt)
		{
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: 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_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: 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_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: 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_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: 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_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: 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_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: 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_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0320: Unknown result type (might be due to invalid IL or missing references)
			//IL_0325: Unknown result type (might be due to invalid IL or missing references)
			//IL_032d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0332: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03da: Unknown result type (might be due to invalid IL or missing references)
			//IL_03df: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0400: Unknown result type (might be due to invalid IL or missing references)
			//IL_040b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0410: Unknown result type (might be due to invalid IL or missing references)
			//IL_0430: Unknown result type (might be due to invalid IL or missing references)
			//IL_0432: Unknown result type (might be due to invalid IL or missing references)
			//IL_043d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0442: Unknown result type (might be due to invalid IL or missing references)
			//IL_0452: Unknown result type (might be due to invalid IL or missing references)
			//IL_045d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0462: Unknown result type (might be due to invalid IL or missing references)
			//IL_0467: Unknown result type (might be due to invalid IL or missing references)
			//IL_046c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0471: Unknown result type (might be due to invalid IL or missing references)
			//IL_0475: Unknown result type (might be due to invalid IL or missing references)
			//IL_047a: Unknown result type (might be due to invalid IL or missing references)
			//IL_048e: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0500: Unknown result type (might be due to