Decompiled source of GangBeastsAI v2.5.0

Mods/GangBeastsAI.dll

Decompiled 15 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BoneLib;
using BoneLib.BoneMenu;
using BoneLib.Notifications;
using GangBeastsAI;
using HarmonyLib;
using Il2CppInterop.Runtime.Attributes;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSLZ.Data;
using Il2CppSLZ.Marrow;
using Il2CppSLZ.Marrow.AI;
using Il2CppSLZ.Marrow.Combat;
using Il2CppSLZ.Marrow.Data;
using Il2CppSLZ.Marrow.Interaction;
using Il2CppSLZ.Marrow.Pool;
using Il2CppSLZ.Marrow.PuppetMasta;
using Il2CppSLZ.Marrow.Utilities;
using Il2CppSLZ.Marrow.Warehouse;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(GangBeastsMod), "Gang Beasts AI", "2.5.0", "Gabri", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: MelonColor(255, 235, 64, 52)]
[assembly: MelonOptionalDependencies(new string[] { "RagdollPlayer" })]
[assembly: AssemblyTitle("Gang Beasts AI")]
[assembly: AssemblyDescription("Standalone Gang Beasts active-ragdoll AI brawler mod for BONELAB (PCVR MelonLoader & Quest LemonLoader) with BoneLib menu & RagdollPlayer support.")]
[assembly: AssemblyFileVersion("2.5.0")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.5.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace GangBeastsAI
{
	public static class BeastGrips
	{
		private sealed class HandCollisionPass
		{
			public IntPtr HeldGripPtr;

			public Rigidbody HeldLimbBody;

			public GangBeastBrain HeldBeast;

			public float ReleaseEndTime = -1f;

			public readonly List<Collider> HandSolids = new List<Collider>(12);

			public readonly List<Collider> BeastSolids = new List<Collider>(24);
		}

		public const string GripObjectName = "BeastBoxGrip";

		private const int DefaultInteractableLayer = 15;

		private const float ReleasePassLingerSeconds = 0.25f;

		public const int SolidRayMask = -2081194553;

		private static readonly Dictionary<string, HandPose> _poseCache = new Dictionary<string, HandPose>(StringComparer.OrdinalIgnoreCase);

		private static readonly HashSet<string> _missingPoses = new HashSet<string>(StringComparer.OrdinalIgnoreCase);

		private static readonly Dictionary<IntPtr, GangBeastBrain> _limbRbToBeast = new Dictionary<IntPtr, GangBeastBrain>();

		private static readonly HandCollisionPass[] _passes = new HandCollisionPass[2]
		{
			new HandCollisionPass(),
			new HandCollisionPass()
		};

		private static bool _anyActiveHold;

		public static void RegisterBeastLimb(Rigidbody limbRb, GangBeastBrain beast)
		{
			if ((Object)(object)limbRb != (Object)null && ((Il2CppObjectBase)limbRb).Pointer != IntPtr.Zero && (Object)(object)beast != (Object)null)
			{
				_limbRbToBeast[((Il2CppObjectBase)limbRb).Pointer] = beast;
			}
		}

		public static void UnregisterBeastLimbs(IReadOnlyList<Rigidbody> rigidbodies)
		{
			if (rigidbodies == null)
			{
				return;
			}
			for (int i = 0; i < rigidbodies.Count; i++)
			{
				Rigidbody val = rigidbodies[i];
				if ((Object)(object)val != (Object)null && ((Il2CppObjectBase)val).Pointer != IntPtr.Zero)
				{
					_limbRbToBeast.Remove(((Il2CppObjectBase)val).Pointer);
				}
			}
		}

		public static int GetPrimaryHoldingHandSide(GangBeastBrain beast)
		{
			if (!_anyActiveHold || (Object)(object)beast == (Object)null || ((Il2CppObjectBase)beast).Pointer == IntPtr.Zero)
			{
				return -1;
			}
			bool flag = _passes[0].ReleaseEndTime < 0f && (Object)(object)_passes[0].HeldBeast != (Object)null && ((Il2CppObjectBase)_passes[0].HeldBeast).Pointer == ((Il2CppObjectBase)beast).Pointer;
			bool flag2 = _passes[1].ReleaseEndTime < 0f && (Object)(object)_passes[1].HeldBeast != (Object)null && ((Il2CppObjectBase)_passes[1].HeldBeast).Pointer == ((Il2CppObjectBase)beast).Pointer;
			if (flag && flag2)
			{
				return -1;
			}
			if (flag)
			{
				return 0;
			}
			if (flag2)
			{
				return 1;
			}
			return -1;
		}

		public static int CountPlayerHandsHolding(GangBeastBrain beast, out bool holdingUpperOrTorso)
		{
			bool holdingLegOrFoot;
			return CountPlayerHandsHolding(beast, out holdingUpperOrTorso, out holdingLegOrFoot);
		}

		public static int CountPlayerHandsHolding(GangBeastBrain beast, out bool holdingUpperOrTorso, out bool holdingLegOrFoot)
		{
			holdingUpperOrTorso = false;
			holdingLegOrFoot = false;
			if (!_anyActiveHold || (Object)(object)beast == (Object)null || ((Il2CppObjectBase)beast).Pointer == IntPtr.Zero)
			{
				return 0;
			}
			int num = 0;
			for (int i = 0; i < _passes.Length; i++)
			{
				HandCollisionPass handCollisionPass = _passes[i];
				if (!(handCollisionPass.ReleaseEndTime < 0f) || !((Object)(object)handCollisionPass.HeldBeast != (Object)null) || !(((Il2CppObjectBase)handCollisionPass.HeldBeast).Pointer == ((Il2CppObjectBase)beast).Pointer))
				{
					continue;
				}
				num++;
				if ((Object)(object)handCollisionPass.HeldLimbBody != (Object)null && ((Il2CppObjectBase)handCollisionPass.HeldLimbBody).Pointer != IntPtr.Zero)
				{
					if (beast.IsTorsoOrHeadBody(handCollisionPass.HeldLimbBody))
					{
						holdingUpperOrTorso = true;
					}
					if (beast.IsLegOrFootBody(handCollisionPass.HeldLimbBody))
					{
						holdingLegOrFoot = true;
					}
				}
			}
			return num;
		}

		public static BoxGrip AttachLimbGrip(Rigidbody limbRb, MarrowEntity entity, MarrowBody marrowBody, InteractableHost host, Collider solidCollider, float entityScale, bool highPriority, out Transform gripTransform)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Expected O, but got Unknown
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: 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_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: 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_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0307: Unknown result type (might be due to invalid IL or missing references)
			//IL_0313: Unknown result type (might be due to invalid IL or missing references)
			//IL_031b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0321: 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_033f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0344: Unknown result type (might be due to invalid IL or missing references)
			//IL_0378: Unknown result type (might be due to invalid IL or missing references)
			//IL_037f: Expected O, but got Unknown
			gripTransform = null;
			if ((Object)(object)limbRb == (Object)null || (Object)(object)entity == (Object)null || (Object)(object)marrowBody == (Object)null || (Object)(object)host == (Object)null || (Object)(object)solidCollider == (Object)null)
			{
				return null;
			}
			((MarrowBehaviour)host).marrowEntity = entity;
			host._marrowBody = marrowBody;
			host.ignoreBodyOnGrab = false;
			ComputeColliderLocalBox(solidCollider, out var center, out var size);
			Vector3 val = Vector3.Max(size * 1.32f, new Vector3(0.135f, 0.135f, 0.135f));
			int num = LayerMask.NameToLayer("Interactable");
			if (num < 0)
			{
				num = 15;
			}
			GameObject val2 = new GameObject("BeastBoxGrip");
			val2.SetActive(false);
			val2.layer = num;
			val2.transform.SetParent(((Component)limbRb).transform, false);
			val2.transform.localPosition = center;
			val2.transform.localRotation = Quaternion.identity;
			val2.transform.localScale = Vector3.one;
			BoxCollider val3 = val2.AddComponent<BoxCollider>();
			((Collider)val3).isTrigger = true;
			val3.center = Vector3.zero;
			val3.size = val;
			BoxGrip val4 = val2.AddComponent<BoxGrip>();
			((Grip)val4)._marrowEntity = entity;
			((Grip)val4).targetTransform = val2.transform;
			((Grip)val4).isThrowable = true;
			((Grip)val4).ignoreGripTargetOnAttach = false;
			((Grip)val4).primaryMovementAxis = Vector3.forward;
			((Grip)val4).secondaryMovementAxis = Vector3.up;
			((Grip)val4).gripOptions = (InteractionOptions)9;
			((Grip)val4).priority = (highPriority ? 1.35f : 1f);
			((Grip)val4).minBreakForce = float.PositiveInfinity;
			((Grip)val4).maxBreakForce = float.PositiveInfinity;
			((Grip)val4).defaultGripDistance = float.PositiveInfinity;
			((TargetGrip)val4).rotationLimit = 180f;
			((TargetGrip)val4).rotationPriorityBuffer = 20f;
			((TargetGrip)val4).targetFlipOnPrimaryAxis = true;
			((TargetGrip)val4).targetFlipOnTertiaryAxis = false;
			val4.sandwichSize = 0.12f;
			float num2 = Mathf.Min(val.x, Mathf.Min(val.y, val.z));
			val4.edgePadding = Mathf.Clamp(num2 * 0.25f, 0.01f, 0.03f);
			HandPose val5 = ResolveHandPose("BoxFaceGrip");
			HandPose val6 = ResolveHandPose("BoxEdgeGrip") ?? val5;
			HandPose val7 = ResolveHandPose("BoxCornerGrip") ?? val5;
			HandPose sandwichHandPose = ResolveHandPose("BoxSandwichGrip") ?? val5;
			val4.sandwichHandPose = sandwichHandPose;
			val4.canBeSandwichedGrabbed = false;
			val4.edgeHandPose = val6;
			val4.edgeHandPoseRadius = 0.05f;
			val4.canBeEdgeGrabbed = (Object)(object)val6 != (Object)null;
			val4.cornerHandPose = val7;
			val4.cornerHandPoseRadius = 0.05f;
			val4.canBeCornerGrabbed = (Object)(object)val7 != (Object)null;
			val4.faceHandPose = val5;
			val4.faceHandPoseRadius = 1f;
			val4.canBeFaceGrabbed = true;
			if ((Object)(object)val5 != (Object)null)
			{
				((Grip)val4).handPose = val5;
			}
			val4.enabledFaces = (Faces)(-1);
			val4.enabledEdges = (Edges)(-1);
			val4.enabledCorners = (Corners)(-1);
			val4.forceGrabFace = (Faces)2;
			val4.forceGrabTop = (Faces)4;
			val4._boxCollider = val3;
			val4._boxCenter = Vector3.zero;
			val4._boxSize = val;
			val4._boxExtents = val * 0.5f;
			val4._bounds = new Bounds(Vector3.zero, val * Mathf.Max(0.1f, entityScale));
			((Grip)val4).gripColliders = new Il2CppReferenceArray<Collider>(0L);
			Il2CppReferenceArray<Collider> val8 = new Il2CppReferenceArray<Collider>(1L);
			((Il2CppArrayBase<Collider>)(object)val8)[0] = solidCollider;
			((Grip)val4).additionalGripColliders = val8;
			AnimationCurve val9 = new AnimationCurve();
			val9.AddKey(-180f, 0f);
			val9.AddKey(0f, 0f);
			val9.AddKey(180f, 0f);
			((Grip)val4).handleAmplifyCurve = val9;
			ForcePullGrip obj = val2.AddComponent<ForcePullGrip>();
			obj._grip = (Grip)(object)val4;
			obj.maxSpeed = float.PositiveInfinity;
			val2.SetActive(true);
			gripTransform = val2.transform;
			return val4;
		}

		public static void FinalizeHostGrips(List<(InteractableHost Host, Transform GripTransform)> hostEntries)
		{
			if (hostEntries == null)
			{
				return;
			}
			for (int i = 0; i < hostEntries.Count; i++)
			{
				var (val, val2) = hostEntries[i];
				if ((Object)(object)val == (Object)null || ((Il2CppObjectBase)val).Pointer == IntPtr.Zero || (Object)(object)val2 == (Object)null || ((Il2CppObjectBase)val2).Pointer == IntPtr.Zero)
				{
					continue;
				}
				try
				{
					if (val._grips == null || val._grips.Count == 0)
					{
						val.DecorateHostOnChildGrips(val2);
					}
				}
				catch (Exception ex)
				{
					MelonLogger.Warning("[GangBeastsAI] DecorateHostOnChildGrips warning: " + ex.Message);
				}
			}
		}

		public static void ForceDetachBeastGrips(IReadOnlyList<InteractableHost> hosts)
		{
			if (hosts == null)
			{
				return;
			}
			for (int i = 0; i < hosts.Count; i++)
			{
				InteractableHost val = hosts[i];
				if ((Object)(object)val == (Object)null || ((Il2CppObjectBase)val).Pointer == IntPtr.Zero || val._grips == null)
				{
					continue;
				}
				try
				{
					for (int j = 0; j < val._grips.Count; j++)
					{
						Grip val2 = val._grips[j];
						if ((Object)(object)val2 != (Object)null && ((Il2CppObjectBase)val2).Pointer != IntPtr.Zero && val2.attachedHands != null && val2.attachedHands.Count > 0)
						{
							val2.ForceDetach();
						}
					}
				}
				catch
				{
				}
			}
		}

		private static void ComputeColliderLocalBox(Collider solidCollider, out Vector3 center, out Vector3 size)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			CapsuleCollider val = ((Il2CppObjectBase)solidCollider).TryCast<CapsuleCollider>();
			if ((Object)(object)val != (Object)null)
			{
				center = val.center;
				float radius = val.radius;
				float num = Mathf.Max(val.height * 0.5f, radius);
				Vector3 val2 = default(Vector3);
				((Vector3)(ref val2))..ctor(radius, radius, radius);
				if (val.direction == 0)
				{
					val2.x = num;
				}
				else if (val.direction == 1)
				{
					val2.y = num;
				}
				else
				{
					val2.z = num;
				}
				size = val2 * 2f;
				return;
			}
			SphereCollider val3 = ((Il2CppObjectBase)solidCollider).TryCast<SphereCollider>();
			if ((Object)(object)val3 != (Object)null)
			{
				center = val3.center;
				size = Vector3.one * (val3.radius * 2f);
				return;
			}
			BoxCollider val4 = ((Il2CppObjectBase)solidCollider).TryCast<BoxCollider>();
			if ((Object)(object)val4 != (Object)null)
			{
				center = val4.center;
				size = val4.size;
			}
			else
			{
				center = Vector3.zero;
				size = new Vector3(0.12f, 0.12f, 0.12f);
			}
		}

		public static HandPose ResolveHandPose(string poseName)
		{
			if (_poseCache.TryGetValue(poseName, out var value) && (Object)(object)value != (Object)null && ((Il2CppObjectBase)value).Pointer != IntPtr.Zero)
			{
				return value;
			}
			if (_missingPoses.Contains(poseName))
			{
				return null;
			}
			HandPose val = null;
			try
			{
				Il2CppArrayBase<HandPose> val2 = Resources.FindObjectsOfTypeAll<HandPose>();
				if (val2 != null)
				{
					foreach (HandPose item in val2)
					{
						if ((Object)(object)item != (Object)null && ((Il2CppObjectBase)item).Pointer != IntPtr.Zero && string.Equals(((Object)item).name, poseName, StringComparison.OrdinalIgnoreCase))
						{
							val = item;
							break;
						}
					}
				}
				if ((Object)(object)val == (Object)null)
				{
					val = LoadHandPoseFromDedupedBundle(poseName);
				}
				if ((Object)(object)val == (Object)null)
				{
					Il2CppArrayBase<BoxGrip> val3 = Resources.FindObjectsOfTypeAll<BoxGrip>();
					if (val3 != null)
					{
						foreach (BoxGrip item2 in val3)
						{
							if (!((Object)(object)item2 == (Object)null) && !(((Il2CppObjectBase)item2).Pointer == IntPtr.Zero))
							{
								if (poseName.Contains("Face", StringComparison.OrdinalIgnoreCase) && (Object)(object)item2.faceHandPose != (Object)null)
								{
									val = item2.faceHandPose;
									break;
								}
								if (poseName.Contains("Edge", StringComparison.OrdinalIgnoreCase) && (Object)(object)item2.edgeHandPose != (Object)null)
								{
									val = item2.edgeHandPose;
									break;
								}
								if (poseName.Contains("Corner", StringComparison.OrdinalIgnoreCase) && (Object)(object)item2.cornerHandPose != (Object)null)
								{
									val = item2.cornerHandPose;
									break;
								}
								if (poseName.Contains("Sandwich", StringComparison.OrdinalIgnoreCase) && (Object)(object)item2.sandwichHandPose != (Object)null)
								{
									val = item2.sandwichHandPose;
									break;
								}
							}
						}
					}
				}
				if ((Object)(object)val == (Object)null && (Object)(object)Player.RigManager != (Object)null && (Object)(object)Player.RigManager.worldGrip != (Object)null && (Object)(object)((Grip)Player.RigManager.worldGrip).handPose != (Object)null)
				{
					val = ((Grip)Player.RigManager.worldGrip).handPose;
				}
			}
			catch (Exception ex)
			{
				MelonLogger.Warning("[GangBeastsAI] HandPose '" + poseName + "' lookup warning: " + ex.Message);
			}
			if ((Object)(object)val == (Object)null || ((Il2CppObjectBase)val).Pointer == IntPtr.Zero)
			{
				_missingPoses.Add(poseName);
				return null;
			}
			((Object)val).hideFlags = (HideFlags)32;
			_poseCache[poseName] = val;
			return val;
		}

		private static HandPose LoadHandPoseFromDedupedBundle(string poseName)
		{
			string streamingAssetsPath = Application.streamingAssetsPath;
			if (string.IsNullOrEmpty(streamingAssetsPath))
			{
				return null;
			}
			string[] array = new string[2] { "StandaloneWindows64", "Android" };
			foreach (string path in array)
			{
				string path2 = Path.Combine(streamingAssetsPath, "aa", path, "deduped_assets_handpose");
				if (!Directory.Exists(path2))
				{
					continue;
				}
				string[] files = Directory.GetFiles(path2, poseName.ToLowerInvariant() + "_*.bundle");
				if (files.Length == 0)
				{
					continue;
				}
				AssetBundle val = AssetBundle.LoadFromFile(files[0]);
				if ((Object)(object)val == (Object)null || ((Il2CppObjectBase)val).Pointer == IntPtr.Zero)
				{
					Il2CppReferenceArray<AssetBundle> allLoadedAssetBundles_Native = AssetBundle.GetAllLoadedAssetBundles_Native();
					if (allLoadedAssetBundles_Native == null)
					{
						continue;
					}
					foreach (AssetBundle item in (Il2CppArrayBase<AssetBundle>)(object)allLoadedAssetBundles_Native)
					{
						if ((Object)(object)item == (Object)null || ((Il2CppObjectBase)item).Pointer == IntPtr.Zero || string.IsNullOrEmpty(((Object)item).name) || !((Object)item).name.Contains(poseName, StringComparison.OrdinalIgnoreCase))
						{
							continue;
						}
						foreach (Object item2 in (Il2CppArrayBase<Object>)(object)item.LoadAllAssets())
						{
							HandPose val2 = ((item2 != (Object)null) ? ((Il2CppObjectBase)item2).TryCast<HandPose>() : null);
							if ((Object)(object)val2 != (Object)null && ((Il2CppObjectBase)val2).Pointer != IntPtr.Zero)
							{
								return val2;
							}
						}
					}
					continue;
				}
				try
				{
					foreach (Object item3 in (Il2CppArrayBase<Object>)(object)val.LoadAllAssets())
					{
						HandPose val3 = ((item3 != (Object)null) ? ((Il2CppObjectBase)item3).TryCast<HandPose>() : null);
						if ((Object)(object)val3 != (Object)null && ((Il2CppObjectBase)val3).Pointer != IntPtr.Zero)
						{
							return val3;
						}
					}
				}
				finally
				{
					val.Unload(false);
				}
			}
			return null;
		}

		public static void OnUpdate()
		{
			try
			{
				TrackHand(Player.LeftHand, _passes[0], _passes[1], 0);
				TrackHand(Player.RightHand, _passes[1], _passes[0], 1);
				_anyActiveHold = (_passes[0].ReleaseEndTime < 0f && (Object)(object)_passes[0].HeldBeast != (Object)null) || (_passes[1].ReleaseEndTime < 0f && (Object)(object)_passes[1].HeldBeast != (Object)null);
			}
			catch
			{
			}
		}

		private static void TrackHand(Hand hand, HandCollisionPass pass, HandCollisionPass otherPass, int handSide)
		{
			//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0309: Unknown result type (might be due to invalid IL or missing references)
			//IL_031f: Unknown result type (might be due to invalid IL or missing references)
			//IL_031b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0321: Unknown result type (might be due to invalid IL or missing references)
			//IL_0329: Unknown result type (might be due to invalid IL or missing references)
			//IL_0304: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = (((Object)(object)hand != (Object)null && ((Il2CppObjectBase)hand).Pointer != IntPtr.Zero) ? hand.m_CurrentAttachedGO : null);
			IntPtr intPtr = (((Object)(object)val != (Object)null && ((Il2CppObjectBase)val).Pointer != IntPtr.Zero) ? ((Il2CppObjectBase)val).Pointer : IntPtr.Zero);
			if (intPtr != pass.HeldGripPtr)
			{
				pass.HeldGripPtr = intPtr;
				Rigidbody val2 = (((Object)(object)val != (Object)null && string.Equals(((Object)val).name, "BeastBoxGrip", StringComparison.Ordinal)) ? val.GetComponentInParent<Rigidbody>() : null);
				if ((Object)(object)val2 != (Object)null && ((Il2CppObjectBase)val2).Pointer != IntPtr.Zero && _limbRbToBeast.TryGetValue(((Il2CppObjectBase)val2).Pointer, out var value) && (Object)(object)value != (Object)null && ((Il2CppObjectBase)value).Pointer != IntPtr.Zero)
				{
					EndPass(pass);
					pass.HeldLimbBody = val2;
					pass.HeldBeast = value;
					pass.ReleaseEndTime = -1f;
					if ((Object)(object)hand.rb != (Object)null && ((Il2CppObjectBase)hand.rb).Pointer != IntPtr.Zero)
					{
						foreach (Collider componentsInChild in ((Component)hand.rb).GetComponentsInChildren<Collider>())
						{
							if ((Object)(object)componentsInChild != (Object)null && ((Il2CppObjectBase)componentsInChild).Pointer != IntPtr.Zero && !componentsInChild.isTrigger)
							{
								pass.HandSolids.Add(componentsInChild);
							}
						}
					}
					IReadOnlyList<Collider> solidColliders = value.SolidColliders;
					for (int i = 0; i < solidColliders.Count; i++)
					{
						Collider val3 = solidColliders[i];
						if ((Object)(object)val3 != (Object)null && ((Il2CppObjectBase)val3).Pointer != IntPtr.Zero && !val3.isTrigger)
						{
							pass.BeastSolids.Add(val3);
						}
					}
					SetCollisionIgnore(pass, ignore: true);
					value.OnGrabbedByPlayerVRHand(val2);
				}
				else if ((Object)(object)pass.HeldLimbBody != (Object)null)
				{
					if (pass.ReleaseEndTime < 0f && (Object)(object)pass.HeldBeast != (Object)null && ((Il2CppObjectBase)pass.HeldBeast).Pointer != IntPtr.Zero && (!(otherPass.ReleaseEndTime < 0f) || !((Object)(object)otherPass.HeldBeast != (Object)null) || !(((Il2CppObjectBase)otherPass.HeldBeast).Pointer == ((Il2CppObjectBase)pass.HeldBeast).Pointer)))
					{
						Vector3 val4 = ((((Il2CppObjectBase)pass.HeldLimbBody).Pointer != IntPtr.Zero) ? pass.HeldLimbBody.velocity : Vector3.zero);
						Vector3 val5 = (((Object)(object)hand != (Object)null && ((Il2CppObjectBase)hand).Pointer != IntPtr.Zero && (Object)(object)hand.rb != (Object)null && ((Il2CppObjectBase)hand.rb).Pointer != IntPtr.Zero) ? hand.rb.velocity : Vector3.zero);
						Vector3 releaseVel = ((((Vector3)(ref val5)).sqrMagnitude > ((Vector3)(ref val4)).sqrMagnitude) ? val5 : val4);
						pass.HeldBeast.OnReleasedByPlayerVRHand(releaseVel, handSide);
					}
					pass.ReleaseEndTime = Time.time + 0.25f;
				}
			}
			if (pass.ReleaseEndTime > 0f && Time.time >= pass.ReleaseEndTime)
			{
				EndPass(pass);
			}
		}

		private static void SetCollisionIgnore(HandCollisionPass pass, bool ignore)
		{
			for (int i = 0; i < pass.HandSolids.Count; i++)
			{
				Collider val = pass.HandSolids[i];
				if ((Object)(object)val == (Object)null || ((Il2CppObjectBase)val).Pointer == IntPtr.Zero)
				{
					continue;
				}
				for (int j = 0; j < pass.BeastSolids.Count; j++)
				{
					Collider val2 = pass.BeastSolids[j];
					if ((Object)(object)val2 != (Object)null && ((Il2CppObjectBase)val2).Pointer != IntPtr.Zero)
					{
						Physics.IgnoreCollision(val, val2, ignore);
					}
				}
			}
		}

		private static void EndPass(HandCollisionPass pass)
		{
			if ((Object)(object)pass.HeldLimbBody != (Object)null)
			{
				SetCollisionIgnore(pass, ignore: false);
			}
			pass.HeldLimbBody = null;
			pass.HeldBeast = null;
			pass.ReleaseEndTime = -1f;
			pass.HandSolids.Clear();
			pass.BeastSolids.Clear();
		}

		public static void OnLevelUnloaded()
		{
			_anyActiveHold = false;
			_limbRbToBeast.Clear();
			for (int i = 0; i < _passes.Length; i++)
			{
				HandCollisionPass obj = _passes[i];
				obj.HeldGripPtr = IntPtr.Zero;
				obj.HeldLimbBody = null;
				obj.HeldBeast = null;
				obj.ReleaseEndTime = -1f;
				obj.HandSolids.Clear();
				obj.BeastSolids.Clear();
			}
		}
	}
	public sealed class FemurControl
	{
		private readonly GangBeastBrain _actor;

		private readonly FemurTargeting _targeting;

		private float _fallTimer;

		private float _climbTimer;

		private float _jumpDelay = 0.6f;

		private float _runDelay;

		private float _runTimer;

		private float _leftPunchDelay;

		private float _rightPunchDelay;

		private float _leftArmTimer;

		private float _rightArmTimer;

		private float _headbuttDelay = 2f;

		private float _headActionTimer;

		private float _kickDelay = 2.5f;

		private float _legActionTimer;

		private FemurSide _kickSide = FemurSide.Right;

		private float _liftTimer;

		private float _cheerDurationTimer;

		private float _duckActiveTimer;

		private float _duckCooldownTimer;

		private float _dodgeProbeTimer;

		private float _strafeSign = 1f;

		private float _strafeSwapTimer;

		private float _steerCacheTimer;

		private Vector3 _cachedSteeredDir = Vector3.forward;

		private Vector3 _homeAnchorPos;

		private bool _hasHomeAnchor;

		private Vector3 _wanderGoalPos;

		private float _wanderDecisionTimer;

		private bool _isWandering;

		private float _idleSitTimer;

		public Vector3 RawDirection { get; private set; } = Vector3.forward;

		public Vector3 Direction { get; private set; } = Vector3.forward;

		public bool OnGround { get; private set; }

		public bool Run { get; private set; }

		public bool Lift { get; private set; }

		public bool Duck { get; private set; }

		public bool LeftGrab { get; set; }

		public bool RightGrab { get; set; }

		public bool LeftPunch { get; private set; }

		public bool RightPunch { get; private set; }

		public FemurArmAction LeftArmAction { get; set; }

		public FemurArmAction RightArmAction { get; set; }

		public FemurHeadAction HeadAction { get; set; }

		public FemurLegAction LeftLegAction { get; set; }

		public FemurLegAction RightLegAction { get; set; }

		public float FollowTimer { get; private set; }

		public FemurControl(GangBeastBrain actor, FemurTargeting targeting)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			_actor = actor;
			_targeting = targeting;
			_leftPunchDelay = Random.Range(0.15f, 0.5f);
			_rightPunchDelay = Random.Range(0.55f, 1.05f);
			_wanderDecisionTimer = Random.Range(0.8f, 2.5f);
			_strafeSign = ((Random.value < 0.5f) ? (-1f) : 1f);
			_strafeSwapTimer = Random.Range(1.2f, 2.8f);
			_steerCacheTimer = Random.Range(0f, 0.1f);
		}

		public void TriggerCheer(float duration = 1.15f)
		{
			_cheerDurationTimer = Mathf.Max(_cheerDurationTimer, duration);
		}

		public void ResetVariables()
		{
			Run = false;
			Lift = false;
			Duck = false;
			LeftGrab = false;
			RightGrab = false;
			LeftPunch = false;
			RightPunch = false;
			LeftArmAction = FemurArmAction.Null;
			RightArmAction = FemurArmAction.Null;
			HeadAction = FemurHeadAction.Null;
			LeftLegAction = FemurLegAction.Null;
			RightLegAction = FemurLegAction.Null;
			_leftArmTimer = 0f;
			_rightArmTimer = 0f;
			_headActionTimer = 0f;
			_legActionTimer = 0f;
			_liftTimer = 0f;
			_climbTimer = 0f;
			_cheerDurationTimer = 0f;
			_duckActiveTimer = 0f;
		}

		public void ProcessFixedUpdate(float fdt, in FemurEvaluatedAIProfile profile)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			if (!_hasHomeAnchor)
			{
				_homeAnchorPos = _actor.HipsPosition;
				_wanderGoalPos = _homeAnchorPos;
				_hasHomeAnchor = true;
			}
			if (_actor.State == FemurActorState.Dead || _actor.State == FemurActorState.Unconscious)
			{
				ResetVariables();
				return;
			}
			if (FollowTimer > 0f)
			{
				FollowTimer -= fdt;
			}
			if (_jumpDelay > 0f)
			{
				_jumpDelay -= fdt;
			}
			if (_duckCooldownTimer > 0f)
			{
				_duckCooldownTimer -= fdt;
			}
			if (_steerCacheTimer > 0f)
			{
				_steerCacheTimer -= fdt;
			}
			if (_cheerDurationTimer > 0f)
			{
				_cheerDurationTimer -= fdt;
				if (_targeting.HasTarget && !_targeting.IsTargetUnconscious)
				{
					Vector3 val = _actor.ChestPosition - _targeting.LastKnownTargetPos;
					if (((Vector3)(ref val)).sqrMagnitude <= 20.25f)
					{
						_cheerDurationTimer = 0f;
					}
				}
			}
			GroundCheck();
			FallCheck(fdt);
			ClimbCheck(fdt);
			DuckDodgeCheck(fdt);
			DirectionCheck(fdt, in profile);
			RunCheck(fdt, in profile);
			JumpRunCheck(in profile);
			LiftCheck(fdt, in profile);
			PunchGrabCheck(fdt, in profile);
			HeadbuttCheck(fdt, in profile);
			KickStompCheck(fdt, in profile);
		}

		private void GroundCheck()
		{
			//IL_0018: 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_0049: 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_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			bool flag = _actor.AnyGroundPartTouching();
			if (!flag && _actor.HipsVelocity.y <= 2.2f)
			{
				Vector3 ballPosition = _actor.BallPosition;
				float num = 0.15f * _actor.Scale;
				RaycastHit val = default(RaycastHit);
				if (Physics.SphereCast(ballPosition + Vector3.up * (0.1f * _actor.Scale), num, Vector3.down, ref val, 0.2f * _actor.Scale, -2081194553, (QueryTriggerInteraction)1) && (Object)(object)((RaycastHit)(ref val)).transform != (Object)null && !((RaycastHit)(ref val)).transform.IsChildOf(((Component)_actor).transform) && ((RaycastHit)(ref val)).normal.y >= 0.55f)
				{
					bool flag2 = true;
					if ((Object)(object)((RaycastHit)(ref val)).rigidbody != (Object)null && GangBeastBrain.TryGetBeastByRigidbody(((RaycastHit)(ref val)).rigidbody, out var brain) && ((Object)(object)brain == (Object)null || (!brain.IsGrounded && !brain.IsUnconscious)))
					{
						flag2 = false;
					}
					if (flag2)
					{
						flag = true;
						_actor.NotifySphereCastGroundSupport(((RaycastHit)(ref val)).normal);
					}
				}
			}
			OnGround = flag;
			if (OnGround && (_actor.State == FemurActorState.Fall || _actor.State == FemurActorState.Jump) && _actor.HipsVelocity.y <= 1.8f)
			{
				_fallTimer = 0f;
				GangBeastBrain actor = _actor;
				Vector3 rawDirection = RawDirection;
				actor.SetActorState((((Vector3)(ref rawDirection)).sqrMagnitude > 0.05f) ? FemurActorState.Run : FemurActorState.Stand);
			}
		}

		private void FallCheck(float fdt)
		{
			if (!OnGround)
			{
				_fallTimer += fdt;
				if (_fallTimer >= 0.2f && _actor.State != FemurActorState.Climb)
				{
					_actor.SetActorState(FemurActorState.Fall);
				}
			}
			else
			{
				_fallTimer = 0f;
			}
		}

		private void ClimbCheck(float fdt)
		{
			bool flag = _actor.IsGrabbingStaticWorldLedge();
			if (!OnGround && flag && !Lift && _climbTimer < 2f)
			{
				_climbTimer += fdt;
				_actor.SetActorState(FemurActorState.Climb);
				return;
			}
			if (OnGround || !flag)
			{
				_climbTimer = 0f;
			}
			if (_actor.State == FemurActorState.Climb)
			{
				_actor.SetActorState(OnGround ? FemurActorState.Stand : FemurActorState.Fall);
			}
		}

		private void DuckDodgeCheck(float fdt)
		{
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			if (_duckActiveTimer > 0f)
			{
				_duckActiveTimer -= fdt;
				Duck = _duckActiveTimer > 0f && OnGround && !Lift;
				return;
			}
			Duck = false;
			if (!OnGround || Lift || _duckCooldownTimer > 0f || _targeting.CurrentKind != FemurTargetKind.Player)
			{
				return;
			}
			_dodgeProbeTimer -= fdt;
			if (_dodgeProbeTimer > 0f)
			{
				return;
			}
			_dodgeProbeTimer = 0.05f;
			if (RagdollPlayerBridge.TryGetIncomingPlayerPunch(_actor.HeadPosition, 1.35f * _actor.Scale, out var _))
			{
				float num = ModPreferences.Difficulty.Value switch
				{
					AIDifficultyMode.SillyGoober => 0.12f, 
					AIDifficultyMode.NormalWaves => 0.32f, 
					AIDifficultyMode.RowdyBrawler => 0.58f, 
					AIDifficultyMode.Nightmare => 0.78f, 
					_ => 0.32f, 
				};
				_duckCooldownTimer = Random.Range(1.4f, 2.6f);
				if (Random.value < num)
				{
					_duckActiveTimer = 0.34f;
					Duck = true;
					_leftPunchDelay = Mathf.Min(_leftPunchDelay, 0.1f);
				}
			}
		}

		private void DirectionCheck(float fdt, in FemurEvaluatedAIProfile profile)
		{
			//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_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: 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_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: 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_005c: 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_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: 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)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: 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_064e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_052f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0539: Unknown result type (might be due to invalid IL or missing references)
			//IL_053e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0542: Unknown result type (might be due to invalid IL or missing references)
			//IL_0547: Unknown result type (might be due to invalid IL or missing references)
			//IL_0553: Unknown result type (might be due to invalid IL or missing references)
			//IL_055a: Unknown result type (might be due to invalid IL or missing references)
			//IL_055f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0564: Unknown result type (might be due to invalid IL or missing references)
			//IL_0400: Unknown result type (might be due to invalid IL or missing references)
			//IL_0405: Unknown result type (might be due to invalid IL or missing references)
			//IL_040f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0414: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0602: Unknown result type (might be due to invalid IL or missing references)
			//IL_060b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0610: Unknown result type (might be due to invalid IL or missing references)
			//IL_061e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0623: Unknown result type (might be due to invalid IL or missing references)
			//IL_0627: Unknown result type (might be due to invalid IL or missing references)
			//IL_042f: 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_0434: Unknown result type (might be due to invalid IL or missing references)
			//IL_0439: Unknown result type (might be due to invalid IL or missing references)
			//IL_043b: Unknown result type (might be due to invalid IL or missing references)
			//IL_043c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0441: Unknown result type (might be due to invalid IL or missing references)
			//IL_046c: 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_047d: Unknown result type (might be due to invalid IL or missing references)
			//IL_047e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0481: Unknown result type (might be due to invalid IL or missing references)
			//IL_0486: Unknown result type (might be due to invalid IL or missing references)
			//IL_0489: Unknown result type (might be due to invalid IL or missing references)
			//IL_0492: Unknown result type (might be due to invalid IL or missing references)
			//IL_0497: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_042a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_036c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_0287: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_031b: Unknown result type (might be due to invalid IL or missing references)
			//IL_031c: Unknown result type (might be due to invalid IL or missing references)
			//IL_031f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0324: Unknown result type (might be due to invalid IL or missing references)
			//IL_0327: Unknown result type (might be due to invalid IL or missing references)
			//IL_0330: Unknown result type (might be due to invalid IL or missing references)
			//IL_0335: Unknown result type (might be due to invalid IL or missing references)
			//IL_0343: Unknown result type (might be due to invalid IL or missing references)
			//IL_0348: Unknown result type (might be due to invalid IL or missing references)
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0306: Unknown result type (might be due to invalid IL or missing references)
			//IL_0308: Unknown result type (might be due to invalid IL or missing references)
			//IL_030a: 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_0313: Unknown result type (might be due to invalid IL or missing references)
			//IL_0318: Unknown result type (might be due to invalid IL or missing references)
			//IL_02af: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
			Vector3 hipsPosition = _actor.HipsPosition;
			Vector3 headOrUpperPos;
			if (Lift && _targeting.HasThrowPoint)
			{
				Vector3 val = _targeting.NearestThrowPoint - hipsPosition;
				val.y = 0f;
				float magnitude = ((Vector3)(ref val)).magnitude;
				if (magnitude > 0.45f)
				{
					Vector3 val2 = (RawDirection = GetSteeredDirectionCached(hipsPosition, val / magnitude, checkJumpStep: true));
					headOrUpperPos = Vector3.Slerp(Direction, val2, Mathf.Clamp01(fdt * 10f));
					Direction = ((Vector3)(ref headOrUpperPos)).normalized;
					if (OnGround)
					{
						_actor.SetActorState(FemurActorState.Run);
					}
				}
				else
				{
					RawDirection = _targeting.ThrowOutwardDir;
					Direction = _targeting.ThrowOutwardDir;
					_liftTimer = 0f;
				}
				return;
			}
			if (_targeting.HasTarget && _targeting.TryGetTargetAimData(out var chestOrCenterPos, out headOrUpperPos, out var velocity, out var _))
			{
				_idleSitTimer = 0f;
				_isWandering = false;
				_homeAnchorPos = hipsPosition;
				_strafeSwapTimer -= fdt;
				if (_strafeSwapTimer <= 0f)
				{
					_strafeSign = 0f - _strafeSign;
					_strafeSwapTimer = Random.Range(1.3f, 2.8f);
				}
				Vector3 val3 = chestOrCenterPos + new Vector3(velocity.x, 0f, velocity.z) * 0.1f - hipsPosition;
				Vector3 val4 = default(Vector3);
				((Vector3)(ref val4))..ctor(val3.x, 0f, val3.z);
				float magnitude2 = ((Vector3)(ref val4)).magnitude;
				Vector3 val5 = ((magnitude2 > 0.01f) ? (val4 / magnitude2) : _actor.ForwardFlat);
				bool flag = FollowTimer > 0f || LeftPunch || RightPunch;
				float num = (flag ? (0.48f * _actor.Scale) : (0.58f * _actor.Scale));
				if (_targeting.IsTargetUnconscious)
				{
					num = 0.35f * _actor.Scale;
				}
				headOrUpperPos = Vector3.Slerp(Direction, val5, Mathf.Clamp01(fdt * 14f));
				Direction = ((Vector3)(ref headOrUpperPos)).normalized;
				headOrUpperPos = Direction;
				if (((Vector3)(ref headOrUpperPos)).sqrMagnitude < 0.01f)
				{
					Direction = val5;
				}
				if (magnitude2 > num)
				{
					Vector3 val6 = val5;
					if (!_targeting.IsTargetUnconscious && magnitude2 < 1.65f * _actor.Scale && !flag)
					{
						Vector3 val7 = new Vector3(0f - val5.z, 0f, val5.x) * (_strafeSign * 0.24f);
						headOrUpperPos = val5 + val7;
						val6 = ((Vector3)(ref headOrUpperPos)).normalized;
					}
					Vector3 val8 = ComputeNeighborSeparation(hipsPosition);
					if (((Vector3)(ref val8)).sqrMagnitude > 0.0001f)
					{
						headOrUpperPos = val6 + val8;
						val6 = ((Vector3)(ref headOrUpperPos)).normalized;
					}
					Vector3 steeredDirectionCached2 = GetSteeredDirectionCached(hipsPosition, val6, checkJumpStep: true);
					RawDirection = steeredDirectionCached2;
					headOrUpperPos = Vector3.Slerp(Direction, val5, Mathf.Clamp01(fdt * 12f));
					Direction = ((Vector3)(ref headOrUpperPos)).normalized;
					if (OnGround)
					{
						_actor.SetActorState(FemurActorState.Run);
					}
				}
				else
				{
					RawDirection = Vector3.zero;
					if (OnGround)
					{
						_actor.SetActorState(FemurActorState.Stand);
					}
				}
				return;
			}
			if (_actor.GangId == 2 && (Object)(object)Player.Head != (Object)null && ((Il2CppObjectBase)Player.Head).Pointer != IntPtr.Zero)
			{
				Vector3 val9 = (_homeAnchorPos = (((Object)(object)Player.PhysicsRig != (Object)null && (Object)(object)Player.PhysicsRig.torso != (Object)null && (Object)(object)Player.PhysicsRig.torso.rbPelvis != (Object)null) ? Player.PhysicsRig.torso.rbPelvis.position : (Player.Head.position - Vector3.up * 1.4f))) - hipsPosition;
				val9.y = 0f;
				float sqrMagnitude = ((Vector3)(ref val9)).sqrMagnitude;
				if (sqrMagnitude > 7.84f)
				{
					_idleSitTimer = 0f;
					Vector3 desiredDir = val9 / Mathf.Sqrt(sqrMagnitude);
					Vector3 val10 = (RawDirection = GetSteeredDirectionCached(hipsPosition, desiredDir, checkJumpStep: true));
					headOrUpperPos = Vector3.Slerp(Direction, val10, Mathf.Clamp01(fdt * 9f));
					Direction = ((Vector3)(ref headOrUpperPos)).normalized;
					Run = sqrMagnitude > 25f;
					if (OnGround)
					{
						_actor.SetActorState(FemurActorState.Run);
					}
					return;
				}
			}
			_wanderDecisionTimer -= fdt;
			if (_wanderDecisionTimer <= 0f)
			{
				if (_isWandering)
				{
					_isWandering = false;
					_wanderDecisionTimer = Random.Range(2f, 4.5f);
				}
				else if (Random.value < 0.45f)
				{
					Vector2 val11 = Random.insideUnitCircle * 3.2f;
					_wanderGoalPos = _homeAnchorPos + new Vector3(val11.x, 0f, val11.y);
					_isWandering = true;
					_idleSitTimer = 0f;
					_wanderDecisionTimer = Random.Range(1.6f, 3.2f);
				}
				else
				{
					_wanderDecisionTimer = Random.Range(2.5f, 5f);
				}
			}
			if (_isWandering && _cheerDurationTimer <= 0f)
			{
				Vector3 val12 = _wanderGoalPos - hipsPosition;
				val12.y = 0f;
				float magnitude3 = ((Vector3)(ref val12)).magnitude;
				if (magnitude3 > 0.55f)
				{
					Vector3 val13 = (RawDirection = GetSteeredDirectionCached(hipsPosition, val12 / magnitude3, checkJumpStep: true));
					headOrUpperPos = Vector3.Slerp(Direction, val13, Mathf.Clamp01(fdt * 7f));
					Direction = ((Vector3)(ref headOrUpperPos)).normalized;
					if (OnGround)
					{
						_actor.SetActorState(FemurActorState.Run);
					}
					return;
				}
				_isWandering = false;
			}
			RawDirection = Vector3.zero;
			if (OnGround)
			{
				_idleSitTimer += fdt;
				_actor.SetActorState((_idleSitTimer > 6.5f) ? FemurActorState.Idle : FemurActorState.Stand);
			}
		}

		private Vector3 ComputeNeighborSeparation(Vector3 myPos)
		{
			//IL_0011: 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_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			IReadOnlyList<GangBeastBrain> activeBeasts = GangBeastBrain.ActiveBeasts;
			int count = activeBeasts.Count;
			if (count <= 1)
			{
				return Vector3.zero;
			}
			GangBeastBrain gangBeastBrain = ((_targeting.CurrentKind == FemurTargetKind.Beast) ? _targeting.TargetBeast : null);
			Vector3 result = Vector3.zero;
			for (int i = 0; i < count; i++)
			{
				GangBeastBrain gangBeastBrain2 = activeBeasts[i];
				if (!((Object)(object)gangBeastBrain2 == (Object)null) && !((Object)(object)gangBeastBrain2 == (Object)(object)_actor) && !((Object)(object)gangBeastBrain2 == (Object)(object)gangBeastBrain) && !gangBeastBrain2.IsDead && !gangBeastBrain2.IsUnconscious)
				{
					Vector3 hipsPosition = gangBeastBrain2.HipsPosition;
					float num = myPos.x - hipsPosition.x;
					float num2 = myPos.z - hipsPosition.z;
					float num3 = 0.95f * (_actor.Scale + gangBeastBrain2.Scale) * 0.5f;
					float num4 = num * num + num2 * num2;
					if (num4 > 0.0004f && num4 < num3 * num3 && Mathf.Abs(myPos.y - hipsPosition.y) < 1.4f)
					{
						float num5 = Mathf.Sqrt(num4);
						float num6 = (1f - num5 / num3) * 0.58f;
						result.x += num / num5 * num6;
						result.z += num2 / num5 * num6;
					}
				}
			}
			if (((Vector3)(ref result)).sqrMagnitude > 0.64f)
			{
				result = ((Vector3)(ref result)).normalized * 0.8f;
			}
			return result;
		}

		private Vector3 GetSteeredDirectionCached(Vector3 hipsPos, Vector3 desiredDir, bool checkJumpStep)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			if (_steerCacheTimer > 0f && Vector3.Dot(_cachedSteeredDir, desiredDir) > 0.25f)
			{
				return _cachedSteeredDir;
			}
			_steerCacheTimer = 0.1f;
			_cachedSteeredDir = ApplyObstacleAvoidance(hipsPos, desiredDir, checkJumpStep);
			return _cachedSteeredDir;
		}

		private Vector3 ApplyObstacleAvoidance(Vector3 hipsPos, Vector3 desiredDir, bool checkJumpStep)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: 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_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: 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_00f3: 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_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: 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_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			Vector3 origin = hipsPos - Vector3.up * (0.1f * _actor.Scale);
			Vector3 origin2 = hipsPos + Vector3.up * (0.38f * _actor.Scale);
			float dist = 0.85f * _actor.Scale;
			bool flag = RaycastEnvironment(origin, desiredDir, dist);
			bool flag2 = RaycastEnvironment(origin2, desiredDir, dist);
			if (flag && !flag2 && checkJumpStep && OnGround && _jumpDelay <= 0f)
			{
				Jump();
				return desiredDir;
			}
			if (!flag2 && !flag)
			{
				return desiredDir;
			}
			Vector3 val = Quaternion.Euler(0f, -40f, 0f) * desiredDir;
			Vector3 val2 = Quaternion.Euler(0f, 40f, 0f) * desiredDir;
			if (!RaycastEnvironment(origin2, val, dist))
			{
				return val;
			}
			if (!RaycastEnvironment(origin2, val2, dist))
			{
				return val2;
			}
			Vector3 val3 = Quaternion.Euler(0f, -75f, 0f) * desiredDir;
			Vector3 val4 = Quaternion.Euler(0f, 75f, 0f) * desiredDir;
			if (!RaycastEnvironment(origin2, val3, dist))
			{
				return val3;
			}
			if (!RaycastEnvironment(origin2, val4, dist))
			{
				return val4;
			}
			return -desiredDir;
		}

		private bool RaycastEnvironment(Vector3 origin, Vector3 dir, float dist)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: 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)
			RaycastHit val = default(RaycastHit);
			if (Physics.Raycast(origin, dir, ref val, dist, -2081194553, (QueryTriggerInteraction)1) && (Object)(object)((RaycastHit)(ref val)).transform != (Object)null && !((RaycastHit)(ref val)).transform.IsChildOf(((Component)_actor).transform))
			{
				if ((Object)(object)Player.RigManager != (Object)null && ((RaycastHit)(ref val)).transform.IsChildOf(((Component)Player.RigManager).transform))
				{
					return false;
				}
				if ((Object)(object)((RaycastHit)(ref val)).rigidbody != (Object)null && GangBeastBrain.TryGetBeastByRigidbody(((RaycastHit)(ref val)).rigidbody, out var _))
				{
					return false;
				}
				return ((RaycastHit)(ref val)).normal.y < 0.57f;
			}
			return false;
		}

		private void RunCheck(float fdt, in FemurEvaluatedAIProfile profile)
		{
			//IL_001b: 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_0031: 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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			if (!_targeting.HasTarget)
			{
				Run = false;
				return;
			}
			Vector3 val = _targeting.LastKnownTargetPos - _actor.HipsPosition;
			float num = val.x * val.x + val.z * val.z;
			if (num > profile.PunchFollowDistance * profile.PunchFollowDistance)
			{
				if (_runDelay > 0f)
				{
					_runDelay -= fdt;
					Run = false;
					return;
				}
				Run = true;
				_runTimer += fdt;
				if (_runTimer > 5.5f)
				{
					_runTimer = 0f;
					_runDelay = Random.Range(0.25f, 0.65f);
				}
			}
			else
			{
				float num2 = 1.1f * _actor.Scale;
				Run = num > num2 * num2;
			}
		}

		private void JumpRunCheck(in FemurEvaluatedAIProfile profile)
		{
			//IL_004b: 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_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: 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_0067: 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_0074: 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_008f: Unknown result type (might be due to invalid IL or missing references)
			if (OnGround && _actor.AnyLowerSupportTouching() && !(_jumpDelay > 0f) && _targeting.HasTarget && !_targeting.IsTargetUnconscious && !Lift)
			{
				Vector3 val = _targeting.LastKnownTargetPos - _actor.HipsPosition;
				float num = Mathf.Sqrt(val.x * val.x + val.z * val.z);
				if ((val.y > 0.75f && val.y < 1.9f && num < 2.2f) || (Run && num > 1.8f && num < 2.8f && Random.value < 0.006f))
				{
					Jump();
				}
			}
		}

		public void Jump()
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			if (OnGround && _actor.AnyLowerSupportTouching() && !(_jumpDelay > 0f))
			{
				_jumpDelay = Random.Range(1.4f, 2.6f);
				OnGround = false;
				_actor.SetActorState(FemurActorState.Jump);
				_actor.ExecuteJumpImpulse(Direction);
			}
		}

		private void LiftCheck(float fdt, in FemurEvaluatedAIProfile profile)
		{
			if (_cheerDurationTimer > 0f && !_targeting.HasTarget)
			{
				Lift = false;
				LeftArmAction = FemurArmAction.Cheering;
				RightArmAction = FemurArmAction.Cheering;
				return;
			}
			if (!_actor.HasLeftGrabJoint && !_actor.HasRightGrabJoint)
			{
				Lift = false;
				if (LeftArmAction == FemurArmAction.Cheering)
				{
					LeftArmAction = FemurArmAction.Null;
				}
				if (RightArmAction == FemurArmAction.Cheering)
				{
					RightArmAction = FemurArmAction.Null;
				}
				return;
			}
			GangBeastBrain grabbedBeast = _actor.GetGrabbedBeast();
			if ((Object)(object)grabbedBeast != (Object)null && !grabbedBeast.IsUnconscious)
			{
				ReleaseCarryAndThrow(tossForward: false);
			}
			else if (!_actor.IsGrabbingStaticWorldLedge())
			{
				if (!Lift)
				{
					Lift = true;
					_liftTimer = Random.Range(1.4f, 3f) * profile.LiftTimerModifier;
				}
				LeftArmAction = FemurArmAction.Cheering;
				RightArmAction = FemurArmAction.Cheering;
				_liftTimer -= fdt;
				if (_liftTimer <= 0f)
				{
					ReleaseCarryAndThrow(tossForward: true);
				}
			}
		}

		private void ReleaseCarryAndThrow(bool tossForward)
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			Lift = false;
			LeftGrab = false;
			RightGrab = false;
			LeftArmAction = FemurArmAction.Resetting;
			RightArmAction = FemurArmAction.Resetting;
			_leftArmTimer = 0.2f;
			_rightArmTimer = 0.2f;
			GangBeastBrain actor = _actor;
			Vector3 throwDirection;
			if (!tossForward)
			{
				throwDirection = Vector3.zero;
			}
			else
			{
				Vector3 val = Direction + Vector3.up * 0.45f;
				throwDirection = ((Vector3)(ref val)).normalized;
			}
			actor.ReleaseHandGrabs(throwDirection);
			_targeting.ClearTarget();
		}

		private void PunchGrabCheck(float fdt, in FemurEvaluatedAIProfile profile)
		{
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			//IL_0087: 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_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			if (Lift || (_cheerDurationTimer > 0f && !_targeting.HasTarget))
			{
				return;
			}
			if (!_targeting.HasTarget)
			{
				LeftGrab = false;
				RightGrab = false;
				LeftPunch = false;
				RightPunch = false;
				if (LeftArmAction != FemurArmAction.Null)
				{
					LeftArmAction = FemurArmAction.Null;
				}
				if (RightArmAction != FemurArmAction.Null)
				{
					RightArmAction = FemurArmAction.Null;
				}
				return;
			}
			Vector3 val = _targeting.LastKnownTargetPos - _actor.ChestPosition;
			float num = Mathf.Sqrt(val.x * val.x + val.z * val.z);
			float num2 = Mathf.Abs(val.y);
			if (_targeting.IsTargetUnconscious)
			{
				LeftPunch = false;
				RightPunch = false;
				if (ModPreferences.AllowBeastGrabbing.Value && _targeting.HasThrowPoint && num <= 1.35f * _actor.Scale && num2 <= 1.2f)
				{
					LeftGrab = true;
					RightGrab = true;
					LeftArmAction = FemurArmAction.Grabbing;
					RightArmAction = FemurArmAction.Grabbing;
				}
				else
				{
					LeftGrab = false;
					RightGrab = false;
					LeftArmAction = FemurArmAction.Null;
					RightArmAction = FemurArmAction.Null;
				}
			}
			else
			{
				LeftGrab = false;
				RightGrab = false;
				float num3 = 1.15f * _actor.Scale + profile.PunchReachDistance;
				bool inSwingRange = num <= num3 && num2 <= 1.65f * _actor.Scale;
				bool farOutOfRange = num > num3 * 1.45f;
				UpdateSingleArmPunch(isLeft: true, fdt, inSwingRange, farOutOfRange, RightArmAction, in profile, ref _leftPunchDelay, ref _leftArmTimer, ref _rightPunchDelay);
				UpdateSingleArmPunch(isLeft: false, fdt, inSwingRange, farOutOfRange, LeftArmAction, in profile, ref _rightPunchDelay, ref _rightArmTimer, ref _leftPunchDelay);
			}
		}

		private void UpdateSingleArmPunch(bool isLeft, float fdt, bool inSwingRange, bool farOutOfRange, FemurArmAction otherArmAction, in FemurEvaluatedAIProfile profile, ref float punchDelay, ref float armTimer, ref float otherArmDelay)
		{
			FemurArmAction femurArmAction = (isLeft ? LeftArmAction : RightArmAction);
			if (femurArmAction == FemurArmAction.Grabbing || femurArmAction == FemurArmAction.Cheering)
			{
				femurArmAction = FemurArmAction.Null;
			}
			switch (femurArmAction)
			{
			case FemurArmAction.Null:
				if (punchDelay > 0f)
				{
					punchDelay -= fdt;
				}
				else if (inSwingRange && otherArmAction != FemurArmAction.Punching)
				{
					femurArmAction = FemurArmAction.Readying;
					armTimer = profile.WindupTime;
					FollowTimer = profile.PunchFollowTime;
					otherArmDelay = Mathf.Max(otherArmDelay, profile.WindupTime + 0.14f);
				}
				break;
			case FemurArmAction.Readying:
				if (farOutOfRange)
				{
					femurArmAction = FemurArmAction.Null;
					break;
				}
				armTimer -= fdt;
				if (armTimer <= 0f)
				{
					femurArmAction = FemurArmAction.Punching;
					armTimer = profile.PunchTime;
					if (isLeft)
					{
						LeftPunch = true;
					}
					else
					{
						RightPunch = true;
					}
					_actor.OnSwingStarted((!isLeft) ? FemurSide.Right : FemurSide.Left);
				}
				break;
			case FemurArmAction.Punching:
				armTimer -= fdt;
				if (armTimer <= 0f)
				{
					if (isLeft)
					{
						LeftPunch = false;
					}
					else
					{
						RightPunch = false;
					}
					femurArmAction = FemurArmAction.Resetting;
					armTimer = profile.ResetPunchTime;
				}
				break;
			case FemurArmAction.Resetting:
				armTimer -= fdt;
				if (armTimer <= 0f)
				{
					femurArmAction = FemurArmAction.Null;
					punchDelay = Random.Range(0.48f, 1.25f) * profile.PunchDelayModifier;
				}
				break;
			}
			if (isLeft)
			{
				LeftArmAction = femurArmAction;
			}
			else
			{
				RightArmAction = femurArmAction;
			}
		}

		private void HeadbuttCheck(float fdt, in FemurEvaluatedAIProfile profile)
		{
			//IL_006a: 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_007f: 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_0086: 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_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			if (Lift || !_targeting.HasTarget || _targeting.IsTargetUnconscious)
			{
				HeadAction = FemurHeadAction.Null;
				return;
			}
			switch (HeadAction)
			{
			case FemurHeadAction.Null:
			{
				if (_headbuttDelay > 0f)
				{
					_headbuttDelay -= fdt;
					break;
				}
				Vector3 val = _targeting.LastKnownTargetPos - _actor.ChestPosition;
				if (Mathf.Sqrt(val.x * val.x + val.z * val.z) <= 0.95f * _actor.Scale && Mathf.Abs(val.y) <= 1.3f * _actor.Scale)
				{
					HeadAction = FemurHeadAction.Readying;
					_headActionTimer = 0.2f;
				}
				break;
			}
			case FemurHeadAction.Readying:
				_headActionTimer -= fdt;
				if (_headActionTimer <= 0f)
				{
					HeadAction = FemurHeadAction.Headbutting;
					_headActionTimer = 0.15f;
					_actor.PlayAttackVoiceAndSwing(heavy: true);
				}
				break;
			case FemurHeadAction.Headbutting:
				_headActionTimer -= fdt;
				if (_headActionTimer <= 0f)
				{
					HeadAction = FemurHeadAction.Resetting;
					_headActionTimer = 0.2f;
				}
				break;
			case FemurHeadAction.Resetting:
				_headActionTimer -= fdt;
				if (_headActionTimer <= 0f)
				{
					HeadAction = FemurHeadAction.Null;
					_headbuttDelay = Random.Range(2.4f, 4.5f) * profile.PunchDelayModifier;
				}
				break;
			}
		}

		private void KickStompCheck(float fdt, in FemurEvaluatedAIProfile profile)
		{
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: 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_00b2: 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_010e: Unknown result type (might be due to invalid IL or missing references)
			if (Lift || !_targeting.HasTarget || _targeting.IsTargetUnconscious)
			{
				LeftLegAction = FemurLegAction.Null;
				RightLegAction = FemurLegAction.Null;
				return;
			}
			FemurLegAction femurLegAction = ((_kickSide == FemurSide.Left) ? LeftLegAction : RightLegAction);
			switch (femurLegAction)
			{
			case FemurLegAction.Null:
			{
				if (_kickDelay > 0f)
				{
					_kickDelay -= fdt;
					break;
				}
				Vector3 val = _targeting.LastKnownTargetPos - _actor.HipsPosition;
				float num = Mathf.Sqrt(val.x * val.x + val.z * val.z);
				bool flag = !OnGround && num < 2.2f * _actor.Scale && Mathf.Abs(val.y) < 1.6f;
				bool flag2 = OnGround && num < 1.2f * _actor.Scale && Mathf.Abs(val.y) < 1.3f;
				if (flag || flag2)
				{
					_kickSide = ((!(Random.value < 0.5f)) ? FemurSide.Right : FemurSide.Left);
					femurLegAction = FemurLegAction.Readying;
					_legActionTimer = (flag ? 0.08f : 0.15f);
				}
				break;
			}
			case FemurLegAction.Readying:
				_legActionTimer -= fdt;
				if (_legActionTimer <= 0f)
				{
					femurLegAction = FemurLegAction.Kicking;
					_legActionTimer = 0.16f;
					_actor.PlayAttackVoiceAndSwing(!OnGround);
				}
				break;
			case FemurLegAction.Kicking:
				_legActionTimer -= fdt;
				if (_legActionTimer <= 0f)
				{
					femurLegAction = FemurLegAction.Resetting;
					_legActionTimer = 0.18f;
				}
				break;
			case FemurLegAction.Resetting:
				_legActionTimer -= fdt;
				if (_legActionTimer <= 0f)
				{
					femurLegAction = FemurLegAction.Null;
					_kickDelay = Random.Range(2.4f, 4.4f) * profile.PunchDelayModifier;
				}
				break;
			}
			if (_kickSide == FemurSide.Left)
			{
				LeftLegAction = femurLegAction;
				RightLegAction = FemurLegAction.Null;
			}
			else
			{
				RightLegAction = femurLegAction;
				LeftLegAction = FemurLegAction.Null;
			}
		}
	}
	public sealed class FemurMovement
	{
		private static readonly Vector3 StandSpineTension = new Vector3(0f, 5.5f, 0f);

		private static readonly Vector3 DuckSpineTension = new Vector3(0f, 2.2f, 0f);

		private static readonly Vector3 RunSpineTensionHalf = new Vector3(0f, 5.5f, 0f);

		private static readonly Vector3 StrideHopTension = new Vector3(0f, 2.5f, 0f);

		private readonly GangBeastBrain _actor;

		private readonly FemurControl _control;

		private readonly FemurTargeting _targeting;

		private readonly float _torqueMassRatio;

		private readonly float _wobblePhaseOffset;

		private float _stepTorqueMult = 1f;

		private float _cycleTimer;

		private FemurPose _leftLegPose;

		private FemurPose _rightLegPose = FemurPose.Straight;

		private FemurPose _leftArmPose = FemurPose.Straight;

		private FemurPose _rightArmPose;

		public FemurMovement(GangBeastBrain actor, FemurControl control, FemurTargeting targeting, float torqueMassRatio)
		{
			_actor = actor;
			_control = control;
			_targeting = targeting;
			_torqueMassRatio = torqueMassRatio;
			_wobblePhaseOffset = Random.Range(0f, 6.28f);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		private static void ReadUpAndForward(Transform t, out Vector3 up, out Vector3 forward)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: 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_0023: 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_0031: 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_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: 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_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			Quaternion rotation = t.rotation;
			float num = rotation.x + rotation.x;
			float num2 = rotation.y + rotation.y;
			float num3 = rotation.z + rotation.z;
			float num4 = rotation.x * num;
			float num5 = rotation.y * num2;
			float num6 = rotation.z * num3;
			float num7 = rotation.x * num2;
			float num8 = rotation.x * num3;
			float num9 = rotation.y * num3;
			float num10 = rotation.w * num;
			float num11 = rotation.w * num2;
			float num12 = rotation.w * num3;
			up = new Vector3(num7 - num12, 1f - (num4 + num6), num9 + num10);
			forward = new Vector3(num8 + num11, num9 - num10, 1f - (num4 + num5));
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		private static void ReadBasis(Transform t, out Vector3 right, out Vector3 up, out Vector3 forward)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: 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_0023: 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_0031: 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_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: 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_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			Quaternion rotation = t.rotation;
			float num = rotation.x + rotation.x;
			float num2 = rotation.y + rotation.y;
			float num3 = rotation.z + rotation.z;
			float num4 = rotation.x * num;
			float num5 = rotation.y * num2;
			float num6 = rotation.z * num3;
			float num7 = rotation.x * num2;
			float num8 = rotation.x * num3;
			float num9 = rotation.y * num3;
			float num10 = rotation.w * num;
			float num11 = rotation.w * num2;
			float num12 = rotation.w * num3;
			right = new Vector3(1f - (num5 + num6), num7 + num12, num8 - num11);
			up = new Vector3(num7 - num12, 1f - (num4 + num6), num9 + num10);
			forward = new Vector3(num8 + num11, num9 - num10, 1f - (num4 + num5));
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		private static Vector3 ReadUp(Transform t)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: 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_0023: 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_0031: 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_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: 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_006a: Unknown result type (might be due to invalid IL or missing references)
			Quaternion rotation = t.rotation;
			float num = rotation.x + rotation.x;
			float num2 = rotation.y + rotation.y;
			float num3 = rotation.z + rotation.z;
			return new Vector3(rotation.x * num2 - rotation.w * num3, 1f - (rotation.x * num + rotation.z * num3), rotation.y * num3 + rotation.w * num);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		private static void ApplyInternalImpulseCouple(Rigidbody primary, Rigidbody reaction, Vector3 primaryDeltaVelocity)
		{
			//IL_0013: 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_002d: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: 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)
			if (!((Object)(object)primary == (Object)null) && !((Object)(object)reaction == (Object)null) && !float.IsNaN(primaryDeltaVelocity.x) && !float.IsNaN(primaryDeltaVelocity.y) && !float.IsNaN(primaryDeltaVelocity.z))
			{
				Vector3 val = primaryDeltaVelocity * primary.mass;
				primary.AddForce(val, (ForceMode)1);
				reaction.AddForce(-val, (ForceMode)1);
			}
		}

		public void AlignToVector(Rigidbody part, Vector3 alignmentVector, Vector3 targetVector, float stability, float speed)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: 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_0063: 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_006a: 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_0079: 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_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: 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_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)part == (Object)null) && !(speed <= 0.001f) && !(((Vector3)(ref targetVector)).sqrMagnitude < 0.0001f) && !(((Vector3)(ref alignmentVector)).sqrMagnitude < 0.0001f))
			{
				Vector3 angularVelocity = part.angularVelocity;
				float magnitude = ((Vector3)(ref angularVelocity)).magnitude;
				Vector3 val = Vector3.Cross((magnitude > 0.0001f) ? (Quaternion.AngleAxis(magnitude * 57.29578f * stability / speed, angularVelocity / magnitude) * alignmentVector) : alignmentVector, ((Vector3)(ref targetVector)).normalized * 10f) * (speed * speed * _torqueMassRatio * _stepTorqueMult);
				if (!float.IsNaN(val.x) && !float.IsNaN(val.y) && !float.IsNaN(val.z) && !float.IsInfinity(val.x) && !float.IsInfinity(val.y) && !float.IsInfinity(val.z))
				{
					part.AddTorque(val, (ForceMode)0);
				}
			}
		}

		public void ProcessFixedUpdate(float fdt, float stepTorqueMult, in FemurEvaluatedAIProfile profile, int vrHandsHolding, bool vrHoldingTorsoOrHead, bool vrHoldingLegOrFoot)
		{
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			FemurActorState state = _actor.State;
			if (state != FemurActorState.Dead && state != FemurActorState.Unconscious)
			{
				_stepTorqueMult = stepTorqueMult;
				float dtScale = Mathf.Clamp(fdt / 0.01667f, 0.2f, 2.25f);
				bool flag = vrHandsHolding >= 2 || (vrHandsHolding >= 1 && (vrHoldingTorsoOrHead || vrHoldingLegOrFoot || !_control.OnGround));
				float postureScale = ((vrHandsHolding >= 2) ? 0.22f : ((vrHandsHolding < 1) ? 1f : ((vrHoldingTorsoOrHead || vrHoldingLegOrFoot) ? 0.32f : 0.55f)));
				bool lowerSupportGrounded = _control.OnGround && _actor.AnyLowerSupportTouching() && !flag;
				ReadBasis(_actor.ChestT, out var right, out var up, out var forward);
				switch (state)
				{
				case FemurActorState.Stand:
					Stand(dtScale, postureScale, lowerSupportGrounded, vrHoldingLegOrFoot, right, up, forward);
					break;
				case FemurActorState.Idle:
					IdleSit(dtScale, postureScale, lowerSupportGrounded, up, forward);
					break;
				case FemurActorState.Run:
					Run(fdt, dtScale, postureScale, lowerSupportGrounded, vrHoldingLegOrFoot, right, up, forward, in profile);
					break;
				case FemurActorState.Jump:
				case FemurActorState.Fall:
					AirbornePose(fdt, dtScale, postureScale, vrHandsHolding, vrHoldingLegOrFoot, up, forward);
					break;
				case FemurActorState.Climb:
					Climb(dtScale, up, forward);
					break;
				}
				ProcessArmActions(dtScale, lowerSupportGrounded, right, forward);
				ProcessHeadAction(dtScale);
				ProcessLegActions(dtScale);
			}
		}

		private Vector3 ComputeDesiredUp(Vector3 dir)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: 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_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: 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)
			Vector3 val = Vector3.up;
			Vector3 val2;
			if (_control.Duck)
			{
				val2 = Vector3.up * 0.72f + dir * 0.45f;
				val = ((Vector3)(ref val2)).normalized;
			}
			if (_actor.IsRocked)
			{
				float num = Time.time * 7.5f + _wobblePhaseOffset;
				val2 = val + new Vector3(Mathf.Sin(num) * 0.24f, 0f, Mathf.Cos(num * 1.15f) * 0.24f);
				val = ((Vector3)(ref val2)).normalized;
			}
			return val;
		}

		private void Stand(float dtScale, float postureScale, bool lowerSupportGrounded, bool vrHoldingLegOrFoot, Vector3 chestRight, Vector3 chestUp, Vector3 chestFwd)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: 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_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: 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_01ab: 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_01cf: 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_005f: 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_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_0345: Unknown result type (might be due to invalid IL or missing references)
			//IL_034a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0357: Unknown result type (might be due to invalid IL or missing references)
			//IL_035c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ea: 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_0243: 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_0250: 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_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: 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_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_041f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0421: Unknown result type (might be due to invalid IL or missing references)
			//IL_0446: Unknown result type (might be due to invalid IL or missing references)
			//IL_0448: 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_037c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0381: Unknown result type (might be due to invalid IL or missing references)
			//IL_0387: Unknown result type (might be due to invalid IL or missing references)
			//IL_038c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0396: Unknown result type (might be due to invalid IL or missing references)
			//IL_039b: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03db: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ea: Unknown result type (might be d