Decompiled source of Gaunt v1.3.0

Gaunt.dll

Decompiled 5 days ago
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace Gaunt;

public class GauntAI : EnemyAI
{
	internal const int StateStalking = 0;

	internal const int StatePeekLeft = 1;

	internal const int StatePeekRight = 2;

	internal const int StateHunting = 3;

	internal const int StateRetreating = 4;

	internal const int StateStriking = 5;

	internal const float LungeDelay = 0.75f;

	internal const float StrikeHitTime = 0.34f;

	internal const float StrikeDuration = 0.9f;

	private const float StrikeStartRange = 2.3f;

	private const float StrikeReach = 3.1f;

	private const float StrikeCooldown = 1.2f;

	private const float MinWatchDistance = 5f;

	private const float PreferredWatchDistance = 11f;

	private const float RoamSpeed = 3f;

	private const float RetreatSpeed = 10f;

	private const float SightConeDegrees = 70f;

	private const float SightProximity = 4f;

	private const float ChaseLeadSeconds = 0.35f;

	private GauntModel model;

	private int lastSeenState = -1;

	private float localStateStart;

	private float nextFearCheck;

	private bool localLunging;

	private bool strikeLanded;

	private int state;

	private float stateStart;

	private float huntStart;

	private float nextStrike;

	private float[] spotTimers = new float[0];

	private float[] sightTimers = new float[0];

	private Vector3 lastTargetPosition;

	private Vector3 targetVelocity;

	private float nextTargetPick;

	private float cooldownUntil;

	private float retreatUntil;

	private bool hasHideSpot;

	private Vector3 hideSpot;

	private Vector3 targetPositionAtSpot;

	private Vector3 lastSpot;

	private float spotChosenAt;

	private float nextSpotSearch;

	private float peekEndTime;

	private float peekLostSince = -1f;

	private NavMeshPath scratchPath;

	private static int Mask => StartOfRound.Instance.collidersAndRoomMaskAndDefault;

	public override void Start()
	{
		//IL_0115: Unknown result type (might be due to invalid IL or missing references)
		//IL_011f: Expected O, but got Unknown
		model = GauntModel.Build(((Component)this).transform);
		base.eye = model.Eye;
		base.creatureSFX = CreateAudioSource("GauntSteps", 0.3f, 2.5f, 45f);
		base.creatureVoice = CreateAudioSource("GauntVoice", 2.3f, 5f, 70f);
		((Component)base.creatureSFX).gameObject.AddComponent<AudioReverbFilter>().reverbPreset = (AudioReverbPreset)13;
		model.SetAudio(base.creatureSFX, base.creatureVoice);
		base.enemyBehaviourStates = (EnemyBehaviourState[])(object)new EnemyBehaviourState[6]
		{
			MakeState("Stalking"),
			MakeState("PeekLeft"),
			MakeState("PeekRight"),
			MakeState("Hunting"),
			MakeState("Retreating"),
			MakeState("Striking")
		};
		base.openDoorSpeedMultiplier = base.enemyType.doorSpeedMultiplier;
		CreateScanNode();
		((EnemyAI)this).Start();
		base.AIIntervalTime = 0.2f;
		scratchPath = new NavMeshPath();
		cooldownUntil = Time.time + 5f;
		Plugin.Log.LogInfo((object)"A Gaunt has appeared in the facility.");
	}

	public override void Update()
	{
		((EnemyAI)this).Update();
		int currentBehaviourStateIndex = base.currentBehaviourStateIndex;
		if (currentBehaviourStateIndex != lastSeenState)
		{
			OnStateChangedLocally(lastSeenState, currentBehaviourStateIndex);
			lastSeenState = currentBehaviourStateIndex;
		}
		bool flag = base.stunNormalizedTimer > 0f;
		float num = Time.time - localStateStart;
		if (localLunging && (currentBehaviourStateIndex != 3 || num >= 0.75f))
		{
			localLunging = false;
		}
		if (currentBehaviourStateIndex == 5 && !strikeLanded && num >= 0.34f && !flag)
		{
			strikeLanded = true;
			LandStrike();
		}
		if ((Object)(object)model != (Object)null)
		{
			model.Animate(currentBehaviourStateIndex, num, localLunging, flag);
		}
		LocalFear();
		if (((NetworkBehaviour)this).IsOwner && !base.isEnemyDead && !flag)
		{
			FaceTargetIfStill();
		}
	}

	private void OnStateChangedLocally(int previous, int current)
	{
		//IL_006d: 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)
		localStateStart = Time.time;
		strikeLanded = false;
		if ((Object)(object)model == (Object)null)
		{
			return;
		}
		switch (current)
		{
		case 5:
			model.Swipe();
			break;
		case 3:
			if (previous != 5)
			{
				localLunging = true;
				model.Screech();
				PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
				if ((Object)(object)localPlayerController != (Object)null && !localPlayerController.isPlayerDead && Vector3.Distance(((Component)localPlayerController).transform.position, ((Component)this).transform.position) < 25f)
				{
					localPlayerController.JumpToFearLevel(1f, true);
				}
				break;
			}
			goto default;
		default:
			if (current == 1 || current == 2)
			{
				model.Crack();
			}
			break;
		}
	}

	private void LocalFear()
	{
		//IL_0059: 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_0087: Unknown result type (might be due to invalid IL or missing references)
		if (!(Time.time < nextFearCheck) && !((Object)(object)base.eye == (Object)null))
		{
			nextFearCheck = Time.time + 0.25f;
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			if (!((Object)(object)localPlayerController == (Object)null) && !localPlayerController.isPlayerDead && localPlayerController.isInsideFactory && localPlayerController.HasLineOfSightToPosition(base.eye.position, 35f, 30, -1f, Mask))
			{
				bool flag = Vector3.Distance(((Component)localPlayerController).transform.position, ((Component)this).transform.position) < 12f;
				localPlayerController.JumpToFearLevel(flag ? 0.9f : 0.6f, true);
			}
		}
	}

	private void FaceTargetIfStill()
	{
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
		if ((state == 1 || state == 2 || (state == 0 && hasHideSpot && ArrivedAtSpot()) || (state == 3 && Time.time - huntStart < 0.75f) || state == 5) && !((Object)(object)base.targetPlayer == (Object)null))
		{
			Vector3 val = ((Component)base.targetPlayer).transform.position - ((Component)this).transform.position;
			val.y = 0f;
			if (!(((Vector3)(ref val)).sqrMagnitude < 0.01f))
			{
				Quaternion val2 = Quaternion.LookRotation(val);
				((Component)this).transform.rotation = Quaternion.RotateTowards(((Component)this).transform.rotation, val2, 140f * Time.deltaTime);
			}
		}
	}

	public override void DoAIInterval()
	{
		((EnemyAI)this).DoAIInterval();
		if (base.isEnemyDead || StartOfRound.Instance.allPlayersDead)
		{
			return;
		}
		if (base.stunNormalizedTimer > 0f)
		{
			base.agent.speed = 0f;
			return;
		}
		bool flag = state == 3 || state == 5;
		base.agent.autoBraking = !flag;
		base.openDoorSpeedMultiplier = base.enemyType.doorSpeedMultiplier * (flag ? 2f : 1f);
		switch (state)
		{
		case 0:
			StalkTick();
			break;
		case 1:
		case 2:
			PeekTick();
			break;
		case 3:
			HuntTick();
			break;
		case 4:
			RetreatTick();
			break;
		case 5:
			StrikeTick();
			break;
		}
	}

	private void StalkTick()
	{
		//IL_0143: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01db: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0199: Unknown result type (might be due to invalid IL or missing references)
		//IL_015f: Unknown result type (might be due to invalid IL or missing references)
		//IL_016f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0205: Unknown result type (might be due to invalid IL or missing references)
		//IL_020a: Unknown result type (might be due to invalid IL or missing references)
		//IL_020c: 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)
		base.agent.updateRotation = true;
		if (Time.time < cooldownUntil)
		{
			base.agent.speed = 3f;
			Roam();
			CheckSpotted();
			return;
		}
		if (!IsValidTarget(base.targetPlayer) || Time.time >= nextTargetPick)
		{
			PlayerControllerB val = PickTarget();
			if ((Object)(object)val != (Object)(object)base.targetPlayer)
			{
				hasHideSpot = false;
			}
			base.targetPlayer = val;
			nextTargetPick = Time.time + 45f;
		}
		if ((Object)(object)base.targetPlayer == (Object)null)
		{
			base.agent.speed = 3f;
			Roam();
			return;
		}
		StopRoaming();
		base.agent.speed = Plugin.StalkSpeed.Value;
		base.agent.acceleration = 14f;
		if (CheckSpotted() || CheckSighted())
		{
			return;
		}
		if (Time.time >= nextSpotSearch && (!hasHideSpot || SpotIsStale()))
		{
			hasHideSpot = FindHideSpot();
			nextSpotSearch = Time.time + (hasHideSpot ? 2.5f : 1f);
		}
		if (!hasHideSpot)
		{
			Transform val2 = ((EnemyAI)this).ChooseClosestNodeToPosition(((Component)base.targetPlayer).transform.position, true, 0);
			if ((Object)(object)val2 != (Object)null && FlatDistance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position) > 11f)
			{
				((EnemyAI)this).SetDestinationToPosition(val2.position, false);
			}
			return;
		}
		if (!ArrivedAtSpot())
		{
			((EnemyAI)this).SetDestinationToPosition(hideSpot, false);
			if (Time.time - spotChosenAt > 15f)
			{
				hasHideSpot = false;
			}
			return;
		}
		StopMoving();
		Vector3 position = ((Component)base.targetPlayer.gameplayCamera).transform.position;
		int num = PeekSide(((Component)this).transform.position, position);
		if (num == 0)
		{
			hasHideSpot = false;
		}
		else if (!IsLookingToward(base.targetPlayer, PeekHeadPosition(((Component)this).transform.position, position, num), 40f) || !(Time.time - spotChosenAt < 20f))
		{
			peekEndTime = Time.time + Random.Range(6f, 14f);
			peekLostSince = -1f;
			SetState((num < 0) ? 1 : 2);
		}
	}

	private void PeekTick()
	{
		//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_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: 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)
		base.agent.speed = 0f;
		base.agent.updateRotation = false;
		if (!IsValidTarget(base.targetPlayer))
		{
			BackToStalking();
		}
		else if (!CheckSpotted() && !CheckSighted())
		{
			int side = ((state != 1) ? 1 : (-1));
			Vector3 position = ((Component)base.targetPlayer.gameplayCamera).transform.position;
			if (HeadHasView(((Component)this).transform.position, position, side) && FlatDistance(((Component)this).transform.position, position) < Plugin.WatchDistance.Value + 6f)
			{
				peekLostSince = -1f;
			}
			else if (peekLostSince < 0f)
			{
				peekLostSince = Time.time;
			}
			else if (Time.time - peekLostSince > 1.2f)
			{
				BackToStalking();
				return;
			}
			if (Time.time >= peekEndTime)
			{
				BackToStalking();
			}
		}
	}

	private void HuntTick()
	{
		//IL_0020: 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_0092: 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)
		base.agent.updateRotation = true;
		if (!IsValidTarget(base.targetPlayer))
		{
			StartRetreat(((Component)this).transform.position);
			return;
		}
		float num = Time.time - huntStart;
		if (num < 0.75f)
		{
			base.agent.speed = 0f;
			return;
		}
		base.agent.speed = Plugin.HuntSpeed.Value;
		base.agent.acceleration = 40f;
		ChaseTarget();
		float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position);
		if (num2 < 2.3f * GauntModel.Scale / 0.85f && Time.time >= nextStrike)
		{
			SetState(5);
			return;
		}
		bool flag = num > Plugin.MaxChaseSeconds.Value;
		bool flag2 = num2 > 50f;
		bool flag3 = num > 1.75f && !IsAlone(base.targetPlayer);
		if (flag || flag2 || flag3)
		{
			StartRetreat(((Component)base.targetPlayer).transform.position);
		}
	}

	private void StrikeTick()
	{
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		base.agent.updateRotation = false;
		base.agent.speed = 2.5f;
		if (IsValidTarget(base.targetPlayer))
		{
			ChaseTarget();
		}
		if (!(Time.time - stateStart < 0.9f))
		{
			nextStrike = Time.time + 1.2f;
			if (IsValidTarget(base.targetPlayer))
			{
				SetState(3);
			}
			else
			{
				StartRetreat(((Component)this).transform.position);
			}
		}
	}

	private void LandStrike()
	{
		//IL_0033: 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_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: 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_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_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
		PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
		if ((Object)(object)localPlayerController == (Object)null || localPlayerController.isPlayerDead || !localPlayerController.isPlayerControlled || !localPlayerController.isInsideFactory)
		{
			return;
		}
		Vector3 val = ((Component)localPlayerController).transform.position - ((Component)this).transform.position;
		if (!(Mathf.Abs(val.y) > 2.5f))
		{
			val.y = 0f;
			float num = 3.1f * GauntModel.Scale / 0.85f;
			if (!(((Vector3)(ref val)).magnitude > num) && !(Vector3.Angle(((Component)this).transform.forward, val) > 75f))
			{
				Vector3 val2 = (((Vector3)(ref val)).normalized + Vector3.up * 0.4f) * 12f;
				localPlayerController.DamagePlayer(Plugin.StrikeDamage.Value, true, true, (CauseOfDeath)6, 0, false, val2);
			}
		}
	}

	private void RetreatTick()
	{
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		base.agent.updateRotation = true;
		base.agent.speed = 10f;
		base.agent.acceleration = 30f;
		if ((base.moveTowardsDestination && Vector3.Distance(((Component)this).transform.position, base.destination) < 1.5f) || Time.time >= retreatUntil)
		{
			cooldownUntil = Time.time + Plugin.RetreatCooldown.Value;
			base.targetPlayer = null;
			hasHideSpot = false;
			SetState(0);
		}
	}

	private bool CheckSpotted()
	{
		//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_0051: 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_0065: 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_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0193: Unknown result type (might be due to invalid IL or missing references)
		PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
		if (spotTimers.Length != allPlayerScripts.Length)
		{
			spotTimers = new float[allPlayerScripts.Length];
		}
		float value = Plugin.SpotAngle.Value;
		int value2 = Plugin.SpotRange.Value;
		Vector3 val = ((Component)this).transform.position + Vector3.up * 1.4f * GauntModel.Scale;
		PlayerControllerB val2 = null;
		for (int i = 0; i < allPlayerScripts.Length; i++)
		{
			PlayerControllerB val3 = allPlayerScripts[i];
			if (!IsAliveInside(val3))
			{
				spotTimers[i] = 0f;
				continue;
			}
			bool flag = val3.HasLineOfSightToPosition(base.eye.position, value, value2, -1f, Mask) || val3.HasLineOfSightToPosition(val, value, value2, -1f, Mask);
			spotTimers[i] = (flag ? (spotTimers[i] + base.AIIntervalTime) : Mathf.Max(0f, spotTimers[i] - base.AIIntervalTime * 0.5f));
			if (spotTimers[i] >= Plugin.SpotSeconds.Value)
			{
				val2 = val3;
				break;
			}
		}
		if ((Object)(object)val2 == (Object)null)
		{
			return false;
		}
		for (int j = 0; j < spotTimers.Length; j++)
		{
			spotTimers[j] = 0f;
		}
		if (IsAlone(val2))
		{
			StartHunt(val2, val2.playerUsername + " spotted it alone");
		}
		else
		{
			StartRetreat(((Component)val2).transform.position);
		}
		return true;
	}

	private bool CheckSighted()
	{
		PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
		if (sightTimers.Length != allPlayerScripts.Length)
		{
			sightTimers = new float[allPlayerScripts.Length];
		}
		for (int i = 0; i < allPlayerScripts.Length; i++)
		{
			PlayerControllerB val = allPlayerScripts[i];
			bool flag = IsAliveInside(val) && CanSee(val) && IsAlone(val);
			sightTimers[i] = (flag ? (sightTimers[i] + base.AIIntervalTime) : Mathf.Max(0f, sightTimers[i] - base.AIIntervalTime));
			if (sightTimers[i] >= Plugin.SightSeconds.Value)
			{
				for (int j = 0; j < sightTimers.Length; j++)
				{
					sightTimers[j] = 0f;
				}
				StartHunt(val, "it saw " + val.playerUsername + " alone");
				return true;
			}
		}
		return false;
	}

	private bool CanSee(PlayerControllerB player)
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//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_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_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		Vector3 position = ((Component)player.gameplayCamera).transform.position;
		Vector3 val = position - base.eye.position;
		float magnitude = ((Vector3)(ref val)).magnitude;
		if (magnitude > Plugin.SightRange.Value)
		{
			return false;
		}
		if (magnitude > 4f && Vector3.Angle(base.eye.forward, val) > 70f)
		{
			return false;
		}
		return !Physics.Linecast(base.eye.position, position, Mask, (QueryTriggerInteraction)1);
	}

	private void ChaseTarget()
	{
		//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_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: 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_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: 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_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: 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_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0151: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0113: Unknown result type (might be due to invalid IL or missing references)
		//IL_0119: Invalid comparison between Unknown and I4
		//IL_014a: Unknown result type (might be due to invalid IL or missing references)
		//IL_014f: Unknown result type (might be due to invalid IL or missing references)
		base.movingTowardsTargetPlayer = false;
		Vector3 position = ((Component)base.targetPlayer).transform.position;
		if (base.AIIntervalTime > 0f)
		{
			Vector3 val = (position - lastTargetPosition) / base.AIIntervalTime;
			val.y = 0f;
			targetVelocity = Vector3.Lerp(targetVelocity, Vector3.ClampMagnitude(val, 12f), 0.5f);
		}
		lastTargetPosition = position;
		Vector3 val2 = position + Vector3.ClampMagnitude(targetVelocity * 0.35f, 2.5f);
		NavMeshHit val3 = default(NavMeshHit);
		val2 = (NavMesh.SamplePosition(val2, ref val3, 2f, base.agent.areaMask) ? ((NavMeshHit)(ref val3)).position : ((!NavMesh.SamplePosition(position, ref val3, 3f, base.agent.areaMask)) ? position : ((NavMeshHit)(ref val3)).position));
		if (base.agent.isOnNavMesh && NavMesh.CalculatePath(((Component)this).transform.position, val2, base.agent.areaMask, scratchPath) && (int)scratchPath.status == 1 && scratchPath.corners.Length > 0)
		{
			val2 = scratchPath.corners[scratchPath.corners.Length - 1];
		}
		((EnemyAI)this).SetDestinationToPosition(val2, false);
	}

	private void StartHunt(PlayerControllerB player, string reason)
	{
		//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_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		Plugin.Log.LogInfo((object)("Gaunt is hunting: " + reason + "."));
		StopRoaming();
		StopMoving();
		base.targetPlayer = player;
		lastTargetPosition = ((Component)player).transform.position;
		targetVelocity = Vector3.zero;
		huntStart = Time.time;
		nextStrike = 0f;
		SetState(3);
	}

	private void StartRetreat(Vector3 awayFrom)
	{
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		StopRoaming();
		StopMoving();
		hasHideSpot = false;
		Transform val = ((EnemyAI)this).ChooseFarthestNodeFromPosition(awayFrom, true, 0, false, 50, -1);
		Vector3 val2 = (((Object)(object)val != (Object)null) ? val.position : RoundManager.Instance.GetRandomNavMeshPositionInRadius(((Component)this).transform.position, 30f, default(NavMeshHit)));
		((EnemyAI)this).SetDestinationToPosition(val2, false);
		retreatUntil = Time.time + 8f;
		SetState(4);
	}

	private void BackToStalking()
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		lastSpot = hideSpot;
		hasHideSpot = false;
		nextSpotSearch = 0f;
		SetState(0);
	}

	private void SetState(int newState)
	{
		state = newState;
		stateStart = Time.time;
		((EnemyAI)this).SwitchToBehaviourClientRpc(newState);
	}

	private bool FindHideSpot()
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_00ca: 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_00d4: 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_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02be: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bf: 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_011a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0125: Unknown result type (might be due to invalid IL or missing references)
		//IL_0145: Unknown result type (might be due to invalid IL or missing references)
		//IL_014a: Unknown result type (might be due to invalid IL or missing references)
		//IL_014c: Unknown result type (might be due to invalid IL or missing references)
		//IL_014e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0189: Unknown result type (might be due to invalid IL or missing references)
		//IL_018e: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_019a: Unknown result type (might be due to invalid IL or missing references)
		//IL_019d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a7: 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_01e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0208: Unknown result type (might be due to invalid IL or missing references)
		//IL_0212: Unknown result type (might be due to invalid IL or missing references)
		//IL_0214: Unknown result type (might be due to invalid IL or missing references)
		//IL_0215: Unknown result type (might be due to invalid IL or missing references)
		//IL_021a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0228: Unknown result type (might be due to invalid IL or missing references)
		//IL_022b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0272: Unknown result type (might be due to invalid IL or missing references)
		//IL_0293: Unknown result type (might be due to invalid IL or missing references)
		//IL_0295: Unknown result type (might be due to invalid IL or missing references)
		Vector3 position = ((Component)base.targetPlayer).transform.position;
		Vector3 position2 = ((Component)base.targetPlayer.gameplayCamera).transform.position;
		Vector3 forward = ((Component)base.targetPlayer.gameplayCamera).transform.forward;
		forward.y = 0f;
		((Vector3)(ref forward)).Normalize();
		float value = Plugin.WatchDistance.Value;
		List<Vector3> list = new List<Vector3>();
		if (base.allAINodes != null)
		{
			GameObject[] allAINodes = base.allAINodes;
			foreach (GameObject val in allAINodes)
			{
				if ((Object)(object)val != (Object)null && FlatDistance(val.transform.position, position) <= value)
				{
					list.Add(val.transform.position);
				}
			}
		}
		for (int j = 0; j < 24; j++)
		{
			list.Add(RoundManager.Instance.GetRandomNavMeshPositionInRadius(position, value, default(NavMeshHit)));
		}
		float num = float.MaxValue;
		Vector3 val2 = Vector3.zero;
		int num2 = 0;
		NavMeshHit val4 = default(NavMeshHit);
		while (list.Count > 0 && num2 < 40)
		{
			int index = Random.Range(0, list.Count);
			Vector3 val3 = list[index];
			list.RemoveAt(index);
			if (!NavMesh.SamplePosition(val3, ref val4, 1.5f, base.agent.areaMask))
			{
				continue;
			}
			val3 = ((NavMeshHit)(ref val4)).position;
			float num3 = FlatDistance(val3, position);
			if (num3 < 5f || num3 > value || Mathf.Abs(val3.y - position.y) > 3.5f)
			{
				continue;
			}
			if (lastSpot != Vector3.zero)
			{
				Vector3 val5 = val3 - lastSpot;
				if (((Vector3)(ref val5)).sqrMagnitude < 9f)
				{
					continue;
				}
			}
			num2++;
			if (IsHidden(val3, position2) && PeekSide(val3, position2) != 0 && NavMesh.CalculatePath(((Component)this).transform.position, val3, base.agent.areaMask, scratchPath) && (int)scratchPath.status == 0)
			{
				Vector3 val6 = val3 - position2;
				val6.y = 0f;
				float num4 = Vector3.Dot(forward, ((Vector3)(ref val6)).normalized);
				float num5 = Mathf.Abs(num3 - 11f) + PathLength(scratchPath) * 0.08f + ((num4 > 0.3f) ? 6f : 0f) + (PathIsSeen(scratchPath, position2) ? 15f : 0f);
				if (num5 < num)
				{
					num = num5;
					val2 = val3;
				}
			}
		}
		if (num == float.MaxValue)
		{
			return false;
		}
		hideSpot = val2;
		targetPositionAtSpot = position;
		spotChosenAt = Time.time;
		return true;
	}

	private bool SpotIsStale()
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: 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)
		if (Vector3.Distance(((Component)base.targetPlayer).transform.position, targetPositionAtSpot) > 6f)
		{
			return true;
		}
		return !IsHidden(hideSpot, ((Component)base.targetPlayer.gameplayCamera).transform.position);
	}

	private bool ArrivedAtSpot()
	{
		//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)
		return FlatDistance(((Component)this).transform.position, hideSpot) < 0.8f;
	}

	private static bool IsHidden(Vector3 spot, Vector3 eyePosition)
	{
		//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_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: 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_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		float scale = GauntModel.Scale;
		if (Physics.Linecast(eyePosition, spot + Vector3.up * 1.4f * scale, Mask, (QueryTriggerInteraction)1))
		{
			return Physics.Linecast(eyePosition, spot + Vector3.up * 2.85f * scale, Mask, (QueryTriggerInteraction)1);
		}
		return false;
	}

	private static int PeekSide(Vector3 spot, Vector3 eyePosition)
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: 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_001e: Unknown result type (might be due to invalid IL or missing references)
		int num = ((!(Random.value < 0.5f)) ? 1 : (-1));
		if (HeadHasView(spot, eyePosition, num))
		{
			return num;
		}
		if (!HeadHasView(spot, eyePosition, -num))
		{
			return 0;
		}
		return -num;
	}

	private static bool HeadHasView(Vector3 spot, Vector3 eyePosition, int side)
	{
		//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_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: 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_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = spot + Vector3.up * GauntModel.PeekHeight;
		Vector3 val2 = PeekHeadPosition(spot, eyePosition, side);
		if (!Physics.Linecast(val, val2, Mask, (QueryTriggerInteraction)1))
		{
			return !Physics.Linecast(val2, eyePosition, Mask, (QueryTriggerInteraction)1);
		}
		return false;
	}

	private static Vector3 PeekHeadPosition(Vector3 spot, Vector3 eyePosition, int side)
	{
		//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_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0025: 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_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: 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_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = eyePosition - spot;
		val.y = 0f;
		Vector3 val2 = Vector3.Cross(Vector3.up, ((Vector3)(ref val)).normalized);
		return spot + Vector3.up * GauntModel.PeekHeight + val2 * (float)side * GauntModel.PeekReach;
	}

	private static bool PathIsSeen(NavMeshPath path, Vector3 eyePosition)
	{
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		Vector3[] corners = path.corners;
		for (int i = 1; i < corners.Length; i++)
		{
			Vector3 point = (corners[i - 1] + corners[i]) * 0.5f;
			if (Visible(corners[i], eyePosition) || Visible(point, eyePosition))
			{
				return true;
			}
		}
		return false;
	}

	private static bool Visible(Vector3 point, Vector3 eyePosition)
	{
		//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_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		if (Vector3.Distance(point, eyePosition) < 30f)
		{
			return !Physics.Linecast(eyePosition, point + Vector3.up * 1.4f, Mask, (QueryTriggerInteraction)1);
		}
		return false;
	}

	private static float PathLength(NavMeshPath path)
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		float num = 0f;
		Vector3[] corners = path.corners;
		for (int i = 1; i < corners.Length; i++)
		{
			num += Vector3.Distance(corners[i - 1], corners[i]);
		}
		return num;
	}

	private static bool IsLookingToward(PlayerControllerB player, Vector3 point, float degrees)
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		Transform transform = ((Component)player.gameplayCamera).transform;
		return Vector3.Angle(transform.forward, point - transform.position) < degrees;
	}

	private PlayerControllerB PickTarget()
	{
		PlayerControllerB result = null;
		float num = float.MinValue;
		PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
		foreach (PlayerControllerB val in allPlayerScripts)
		{
			if (IsValidTarget(val))
			{
				float num2 = Mathf.Min(NearestOtherPlayer(val), 40f) + Random.Range(0f, 12f);
				if (num2 > num)
				{
					num = num2;
					result = val;
				}
			}
		}
		return result;
	}

	private static bool IsAlone(PlayerControllerB player)
	{
		return NearestOtherPlayer(player) > Plugin.AloneRadius.Value;
	}

	private static float NearestOtherPlayer(PlayerControllerB player)
	{
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		float num = float.MaxValue;
		PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
		foreach (PlayerControllerB val in allPlayerScripts)
		{
			if (!((Object)(object)val == (Object)null) && !((Object)(object)val == (Object)(object)player) && val.isPlayerControlled && !val.isPlayerDead)
			{
				num = Mathf.Min(num, Vector3.Distance(((Component)val).transform.position, ((Component)player).transform.position));
			}
		}
		return num;
	}

	private static bool IsValidTarget(PlayerControllerB player)
	{
		return IsAliveInside(player);
	}

	private static bool IsAliveInside(PlayerControllerB player)
	{
		if ((Object)(object)player != (Object)null && player.isPlayerControlled && !player.isPlayerDead)
		{
			return player.isInsideFactory;
		}
		return false;
	}

	private static float FlatDistance(Vector3 a, Vector3 b)
	{
		//IL_0018: 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)
		a.y = 0f;
		b.y = 0f;
		return Vector3.Distance(a, b);
	}

	private void Roam()
	{
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		if (base.currentSearch == null || !base.currentSearch.inProgress)
		{
			((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
		}
	}

	private void StopRoaming()
	{
		if (base.currentSearch != null && base.currentSearch.inProgress)
		{
			((EnemyAI)this).StopSearch(base.currentSearch, true);
		}
	}

	private void StopMoving()
	{
		base.movingTowardsTargetPlayer = false;
		base.moveTowardsDestination = false;
		if (base.agent.isOnNavMesh)
		{
			base.agent.ResetPath();
		}
	}

	public override void HitEnemy(int force = 1, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
	{
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		((EnemyAI)this).HitEnemy(force, playerWhoHit, playHitSFX, hitID);
		if (((NetworkBehaviour)this).IsOwner && state != 4)
		{
			StartRetreat(((Object)(object)playerWhoHit != (Object)null) ? ((Component)playerWhoHit).transform.position : ((Component)this).transform.position);
		}
	}

	private static EnemyBehaviourState MakeState(string name)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Expected O, but got Unknown
		EnemyBehaviourState val = new EnemyBehaviourState();
		val.name = name;
		return val;
	}

	private AudioSource CreateAudioSource(string name, float height, float minDistance, float maxDistance)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject(name);
		val.transform.SetParent(((Component)this).transform, false);
		val.transform.localPosition = new Vector3(0f, height * GauntModel.Scale, 0f);
		AudioSource val2 = val.AddComponent<AudioSource>();
		val2.playOnAwake = false;
		val2.spatialBlend = 1f;
		val2.rolloffMode = (AudioRolloffMode)0;
		val2.minDistance = minDistance;
		val2.maxDistance = maxDistance;
		val2.dopplerLevel = 0f;
		val2.spread = 30f;
		PlayerControllerB val3 = (((Object)(object)GameNetworkManager.Instance != (Object)null) ? GameNetworkManager.Instance.localPlayerController : null);
		if ((Object)(object)val3 != (Object)null && (Object)(object)val3.movementAudio != (Object)null)
		{
			val2.outputAudioMixerGroup = val3.movementAudio.outputAudioMixerGroup;
		}
		val.AddComponent<AudioLowPassFilter>().cutoffFrequency = 20000f;
		return val2;
	}

	private void CreateScanNode()
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("ScanNode");
		val.layer = 22;
		val.transform.SetParent(((Component)this).transform, false);
		val.transform.localPosition = new Vector3(0f, 1.6f * GauntModel.Scale, 0f);
		BoxCollider val2 = val.AddComponent<BoxCollider>();
		((Collider)val2).isTrigger = true;
		val2.size = new Vector3(0.6f, 0.6f, 0.6f);
		ScanNodeProperties val3 = val.AddComponent<ScanNodeProperties>();
		val3.headerText = "Gaunt";
		val3.subText = "Don't look at it alone.";
		val3.nodeType = 1;
		val3.minRange = 1;
		val3.maxRange = 25;
		val3.requiresLineOfSight = true;
		val3.creatureScanID = (((Object)(object)Plugin.BestiaryNode != (Object)null) ? Plugin.BestiaryNode.creatureFileID : (-1));
	}
}
public class GauntModel : MonoBehaviour
{
	private class Arm
	{
		public int Side;

		public Transform Shoulder;

		public Transform Elbow;

		public Transform LowerElbow;

		public Transform Wrist;

		public readonly List<Transform> Fingers = new List<Transform>();

		public float[] FingerTwitch;

		public float[] FingerTwitchTarget;

		public float NextFingerTwitch;
	}

	private class Strand
	{
		public Transform Pivot;

		public float Phase;

		public float Stiffness;
	}

	private class Noise
	{
		private readonly float[] lattice;

		private readonly int period;

		public Noise(int seed, int period)
		{
			this.period = period;
			Random random = new Random(seed);
			lattice = new float[period * period * 16];
			for (int i = 0; i < lattice.Length; i++)
			{
				lattice[i] = (float)random.NextDouble();
			}
		}

		public float Fbm(float u, float v, int octaves)
		{
			float num = 0f;
			float num2 = 0.5f;
			float num3 = 0f;
			int num4 = 1;
			for (int i = 0; i < octaves; i++)
			{
				num += Value(u, v, period * num4) * num2;
				num3 += num2;
				num2 *= 0.5f;
				num4 *= 2;
			}
			return num / num3;
		}

		private float Value(float u, float v, int cells)
		{
			float num = u * (float)cells;
			float num2 = v * (float)cells;
			int num3 = Mathf.FloorToInt(num);
			int num4 = Mathf.FloorToInt(num2);
			float num5 = num - (float)num3;
			float num6 = num2 - (float)num4;
			num5 = num5 * num5 * (3f - 2f * num5);
			num6 = num6 * num6 * (3f - 2f * num6);
			float num7 = Cell(num3, num4, cells);
			float num8 = Cell(num3 + 1, num4, cells);
			float num9 = Cell(num3, num4 + 1, cells);
			float num10 = Cell(num3 + 1, num4 + 1, cells);
			return Mathf.Lerp(Mathf.Lerp(num7, num8, num5), Mathf.Lerp(num9, num10, num5), num6);
		}

		private float Cell(int x, int y, int cells)
		{
			x = (x % cells + cells) % cells;
			y = (y % cells + cells) % cells;
			int num = ((x * 73856093) ^ (y * 19349663) ^ (cells * 83492791)) & 0x7FFFFFFF;
			return lattice[num % lattice.Length];
		}
	}

	private const int EnemyLayer = 19;

	private const float BaseScale = 0.85f;

	private const float HipHeight = 1.8f;

	private const float ThighLength = 0.92f;

	private const float ShinLength = 0.88f;

	private const float StrideLength = 1.6f;

	private const float PeekLean = 50f;

	private const float LegSplay = 7f;

	private const float ArmSplay = 22f;

	private static readonly Color BoneColor = new Color(0.26f, 0.235f, 0.2f);

	private static readonly Color ToothColor = new Color(0.78f, 0.72f, 0.55f);

	private static readonly Color ClawColor = new Color(0.32f, 0.29f, 0.25f);

	private static readonly Color HollowColor = new Color(0.003f, 0.003f, 0.003f);

	private static readonly Color OozeColor = new Color(0.01f, 0.008f, 0.008f);

	private static readonly Color HairColor = new Color(0.018f, 0.016f, 0.016f);

	private static readonly Color EyeshineColor = new Color(0.92f, 0.95f, 0.85f);

	private static Shader litShader;

	private static Texture2D skinTexture;

	private static Texture2D faceTexture;

	private static readonly Dictionary<string, Material> materials = new Dictionary<string, Material>();

	public Transform Eye;

	private Transform enemyRoot;

	private Transform waist;

	private Transform head;

	private Transform mouth;

	private Transform jaw;

	private Transform legL;

	private Transform kneeL;

	private Transform ankleL;

	private Transform legR;

	private Transform kneeR;

	private Transform ankleR;

	private Arm armL;

	private Arm armR;

	private readonly List<Transform> eyes = new List<Transform>();

	private readonly List<Strand> hair = new List<Strand>();

	private AudioSource stepSource;

	private AudioSource voiceSource;

	private AudioLowPassFilter stepFilter;

	private AudioLowPassFilter voiceFilter;

	private Vector3 lastRootPosition;

	private Vector3 lastHeadPosition;

	private Vector3 hairSway;

	private float smoothSpeed;

	private float phase;

	private float noiseSeed;

	private float hunch = 28f;

	private float lean;

	private float nextLeanStep;

	private float reach;

	private float spread;

	private float grip;

	private float mouthOpen;

	private float stepVolume;

	private float dragAt = -1f;

	private float nextOcclusionCheck;

	private Vector3 twitch;

	private Vector3 twitchTarget;

	private float nextTwitch;

	private float twitchHold;

	private static readonly Vector3[] ChestPoints = (Vector3[])(object)new Vector3[6]
	{
		new Vector3(0f, 0.02f, 0f),
		new Vector3(0f, 0.2f, 0f),
		new Vector3(0f, 0.38f, 0f),
		new Vector3(0f, 0.55f, 0f),
		new Vector3(0f, 0.78f, 0f),
		new Vector3(0f, 0.93f, 0f)
	};

	private static readonly float[] ChestRadii = new float[6] { 0.09f, 0.075f, 0.15f, 0.2f, 0.21f, 0.13f };

	internal static float Scale => 0.85f * Mathf.Clamp(Plugin.Size.Value, 0.5f, 1.5f);

	internal static float PeekReach => 0.9f * Scale;

	internal static float PeekHeight => 2.55f * Scale;

	public static GauntModel Build(Transform enemyRoot)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		//IL_001e: 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_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_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)
		GameObject val = new GameObject("GauntVisual");
		val.transform.SetParent(enemyRoot, false);
		val.transform.localScale = Vector3.one * Scale;
		GauntModel gauntModel = val.AddComponent<GauntModel>();
		gauntModel.enemyRoot = enemyRoot;
		gauntModel.lastRootPosition = enemyRoot.position;
		gauntModel.noiseSeed = Random.Range(0f, 100f);
		gauntModel.BuildLegs();
		gauntModel.BuildUpperBody();
		gauntModel.lastHeadPosition = gauntModel.head.position;
		return gauntModel;
	}

	public void SetAudio(AudioSource steps, AudioSource voice)
	{
		stepSource = steps;
		voiceSource = voice;
		stepFilter = ((Component)steps).GetComponent<AudioLowPassFilter>();
		voiceFilter = ((Component)voice).GetComponent<AudioLowPassFilter>();
	}

	public void Screech()
	{
		PlayVoice(Sounds.Screeches, Mathf.Clamp01(Plugin.ScreechVolume.Value), overWalkie: true);
	}

	public void Swipe()
	{
		PlayVoice(Sounds.Swipes, 1f, overWalkie: true);
	}

	public void Crack()
	{
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		PlayVoice(Sounds.Cracks, 0.6f, overWalkie: false);
		twitchTarget = new Vector3(Random.Range(-10f, 10f), Random.Range(-20f, 20f), Random.Range(-25f, 25f));
		twitchHold = 0.6f;
	}

	private void PlayVoice(AudioClip[] clips, float volume, bool overWalkie)
	{
		AudioClip val = Sounds.Pick(clips);
		if (!((Object)(object)voiceSource == (Object)null) && !((Object)(object)val == (Object)null))
		{
			voiceSource.pitch = Random.Range(0.92f, 1.06f);
			voiceSource.PlayOneShot(val, volume);
			if (overWalkie)
			{
				WalkieTalkie.TransmitOneShotAudio(voiceSource, val, volume);
			}
		}
	}

	public void Animate(int state, float timeInState, bool lunging, bool stunned)
	{
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: 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_0078: 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_03ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_040a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0426: Unknown result type (might be due to invalid IL or missing references)
		//IL_0442: Unknown result type (might be due to invalid IL or missing references)
		//IL_0462: Unknown result type (might be due to invalid IL or missing references)
		//IL_0482: Unknown result type (might be due to invalid IL or missing references)
		//IL_04cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0501: Unknown result type (might be due to invalid IL or missing references)
		//IL_0506: Unknown result type (might be due to invalid IL or missing references)
		//IL_0514: Unknown result type (might be due to invalid IL or missing references)
		//IL_0519: Unknown result type (might be due to invalid IL or missing references)
		//IL_051e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0523: Unknown result type (might be due to invalid IL or missing references)
		//IL_056a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0578: Unknown result type (might be due to invalid IL or missing references)
		//IL_0529: Unknown result type (might be due to invalid IL or missing references)
		//IL_0558: Unknown result type (might be due to invalid IL or missing references)
		//IL_055d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0562: Unknown result type (might be due to invalid IL or missing references)
		//IL_05a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0620: Unknown result type (might be due to invalid IL or missing references)
		//IL_0657: Unknown result type (might be due to invalid IL or missing references)
		//IL_0682: Unknown result type (might be due to invalid IL or missing references)
		float num = (stunned ? 0f : Time.deltaTime);
		float num2 = Time.time + noiseSeed;
		bool flag = state == 1 || state == 2;
		bool flag2 = state == 3;
		bool flag3 = state == 5;
		bool flag4 = state == 4;
		bool flag5 = flag2 || flag3;
		int num3 = ((state != 1) ? 1 : (-1));
		Vector3 position = enemyRoot.position;
		Vector3 val = position - lastRootPosition;
		val.y = 0f;
		lastRootPosition = position;
		float magnitude = ((Vector3)(ref val)).magnitude;
		if (Time.deltaTime > 0f)
		{
			smoothSpeed = Mathf.Lerp(smoothSpeed, magnitude / Time.deltaTime, 1f - Mathf.Exp((0f - Time.deltaTime) * 8f));
		}
		float num4 = Mathf.Clamp01(smoothSpeed / 1.2f);
		float num5 = (lunging ? 0f : (flag3 ? StrikeHunch(timeInState) : (flag2 ? 50f : (flag4 ? 58f : (flag ? 18f : (26f + num4 * 8f))))));
		hunch = Mathf.Lerp(hunch, num5, 1f - Mathf.Exp((0f - num) * ((lunging || flag3) ? 14f : 4f)));
		reach = Mathf.MoveTowards(reach, (flag5 && !lunging) ? 1f : 0f, num * 4f);
		spread = Mathf.MoveTowards(spread, lunging ? 1f : 0f, num * 6f);
		grip = Mathf.MoveTowards(grip, flag ? 1f : 0f, num * 2.5f);
		float num6 = (flag5 ? 1f : (flag4 ? 0.5f : (flag ? 0.3f : 0.35f)));
		mouthOpen = Mathf.MoveTowards(mouthOpen, num6, num * (flag5 ? 8f : 2f));
		float num7 = (flag ? ((float)num3 * 50f) : 0f);
		if (!flag)
		{
			lean = Mathf.MoveTowards(lean, num7, num * 120f);
		}
		else if (num > 0f && Time.time >= nextLeanStep)
		{
			nextLeanStep = Time.time + Random.Range(0.08f, 0.2f);
			lean = Mathf.MoveTowards(lean, num7, Random.Range(4f, 16f));
		}
		float num8 = 1.6f * ((flag5 || flag4) ? 0.85f : 1f) * Scale;
		float num9 = Mathf.Cos(phase);
		float num10 = ((num9 >= 0f) ? 1.3f : 0.75f);
		phase += magnitude / num8 * (float)Math.PI * num10;
		phase %= (float)Math.PI * 2f;
		float num11 = Mathf.Cos(phase);
		if (magnitude > 0f && Mathf.Sign(num11) != Mathf.Sign(num9))
		{
			Footfall(flag5, flag4);
		}
		if (dragAt > 0f && Time.time >= dragAt)
		{
			dragAt = -1f;
			PlayStep(Sounds.Drags, stepVolume * 0.45f);
		}
		float num12 = Mathf.Sin(phase);
		float num13 = 26f * num4;
		float num14 = ((flag5 || flag4) ? 60f : 40f) * num4;
		float num15 = (0f - num12) * num13;
		float num16 = num12 * num13;
		float num17 = Mathf.Max(0f, num11) * num14;
		float num18 = Mathf.Max(0f, 0f - num11) * num14;
		legL.localRotation = Quaternion.Euler(num15, 0f, -7f);
		legR.localRotation = Quaternion.Euler(num16, 0f, 7f);
		kneeL.localRotation = Quaternion.Euler(num17, 0f, 0f);
		kneeR.localRotation = Quaternion.Euler(num18, 0f, 0f);
		ankleL.localRotation = Quaternion.Euler(0f - (num15 + num17), 0f, 7f);
		ankleR.localRotation = Quaternion.Euler(0f - (num16 + num18), 0f, -7f);
		float num19 = Mathf.Abs(num12) * num13 * ((float)Math.PI / 180f);
		float num20 = 1.8f * (1f - Mathf.Cos(num19));
		((Component)this).transform.localPosition = new Vector3(0f, (0f - num20) * Scale, 0f);
		float num21 = Mathf.Sin(num2 * 1.3f) * 1.5f;
		float num22 = num12 * 7f * num4;
		Quaternion val2 = Quaternion.AngleAxis(0f - lean + num22, Vector3.forward) * Quaternion.AngleAxis(hunch + num21, Vector3.right);
		if (stunned)
		{
			val2 *= Quaternion.Euler(Random.Range(-2f, 2f), Random.Range(-2f, 2f), Random.Range(-2f, 2f));
		}
		waist.localRotation = val2;
		PoseArm(armL, val2, num12, num4, flag && num3 < 0, flag3 ? (-1f) : 0f, timeInState, num2, num);
		PoseArm(armR, val2, 0f - num12, num4, flag && num3 > 0, flag3 ? 1f : 0f, timeInState, num2, num);
		PoseHead(flag, num3, flag5, stunned, timeInState, num, num2);
		PoseEyes();
		PoseHair(num, num2);
		float num23 = mouthOpen * mouthOpen;
		mouth.localPosition = new Vector3(0f, Mathf.Lerp(-0.03f, -0.11f, num23), 0.06f);
		mouth.localScale = new Vector3(Mathf.Lerp(0.075f, 0.09f, num23), Mathf.Lerp(0.07f, 0.25f, num23), 0.08f);
		jaw.localPosition = new Vector3(0f, Mathf.Lerp(-0.1f, -0.25f, num23), 0.035f);
		UpdateOcclusion();
	}

	private static float StrikeHunch(float time)
	{
		if (time < 0.26f)
		{
			return 4f;
		}
		if (!(time < 0.49f))
		{
			return 45f;
		}
		return 62f;
	}

	private void PoseArm(Arm arm, Quaternion waistRotation, float swing, float moving, bool gripping, float strikeSide, float timeInState, float t, float dt)
	{
		//IL_003d: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0147: 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_0165: Unknown result type (might be due to invalid IL or missing references)
		//IL_016a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0216: Unknown result type (might be due to invalid IL or missing references)
		//IL_0217: Unknown result type (might be due to invalid IL or missing references)
		//IL_021c: Unknown result type (might be due to invalid IL or missing references)
		//IL_021d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0222: Unknown result type (might be due to invalid IL or missing references)
		//IL_022c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0231: Unknown result type (might be due to invalid IL or missing references)
		//IL_023c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0241: Unknown result type (might be due to invalid IL or missing references)
		//IL_029c: 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_02b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0256: Unknown result type (might be due to invalid IL or missing references)
		//IL_0260: Unknown result type (might be due to invalid IL or missing references)
		//IL_0262: Unknown result type (might be due to invalid IL or missing references)
		//IL_026a: Unknown result type (might be due to invalid IL or missing references)
		//IL_026f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0271: Unknown result type (might be due to invalid IL or missing references)
		//IL_0273: Unknown result type (might be due to invalid IL or missing references)
		//IL_027b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0280: Unknown result type (might be due to invalid IL or missing references)
		//IL_0282: Unknown result type (might be due to invalid IL or missing references)
		//IL_0284: Unknown result type (might be due to invalid IL or missing references)
		//IL_028f: 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_039c: Unknown result type (might be due to invalid IL or missing references)
		int side = arm.Side;
		float num = Mathf.Sin(t * 0.9f + (float)side) * 3f;
		Quaternion pose = Quaternion.Euler(-8f + swing * 14f * moving + num, 0f, (float)side * 22f);
		float elbowBend = -6f - Mathf.Max(0f, swing) * 10f * moving;
		float lowerBend = 10f + Mathf.Sin(t * 1.7f + (float)side) * 4f;
		float num2 = (float)(-side) * 10f;
		float num3 = (float)(-side) * 6f;
		float curl = 25f;
		if (reach > 0f)
		{
			pose = Quaternion.Slerp(pose, Quaternion.Euler(-78f + swing * 10f, 0f, (float)side * 18f), reach);
			elbowBend = Mathf.Lerp(elbowBend, -15f, reach);
			lowerBend = Mathf.Lerp(lowerBend, -10f, reach);
			num2 = Mathf.Lerp(num2, 0f, reach);
			num3 = Mathf.Lerp(num3, 0f, reach);
			curl = Mathf.Lerp(curl, -5f, reach);
		}
		if (spread > 0f)
		{
			pose = Quaternion.Slerp(pose, Quaternion.Euler(-35f, 0f, (float)side * 80f), spread);
			elbowBend = Mathf.Lerp(elbowBend, -30f, spread);
			lowerBend = Mathf.Lerp(lowerBend, -25f, spread);
			num2 = Mathf.Lerp(num2, 0f, spread);
			num3 = Mathf.Lerp(num3, 0f, spread);
			curl = Mathf.Lerp(curl, -15f, spread);
		}
		if (gripping && grip > 0f)
		{
			curl = Mathf.Lerp(curl, 80f, grip);
		}
		if (strikeSide == (float)side)
		{
			StrikePose(timeInState, side, ref pose, ref elbowBend, ref lowerBend, ref curl);
			num2 = 0f;
			num3 = 0f;
		}
		Quaternion val = Quaternion.Inverse(waistRotation) * pose;
		Quaternion val2 = Quaternion.Euler(elbowBend, 0f, num2);
		Quaternion val3 = Quaternion.Euler(lowerBend, 0f, num3);
		if (gripping && grip > 0f)
		{
			GripReach(arm, waistRotation, out var shoulderLocal, out var elbowLocal);
			val = Quaternion.Slerp(val, shoulderLocal, grip);
			val2 = Quaternion.Slerp(val2, elbowLocal, grip);
			val3 = Quaternion.Slerp(val3, Quaternion.identity, grip);
		}
		arm.Shoulder.localRotation = val;
		arm.Elbow.localRotation = val2;
		arm.LowerElbow.localRotation = val3;
		if (dt > 0f && Time.time >= arm.NextFingerTwitch)
		{
			arm.NextFingerTwitch = Time.time + Random.Range(0.15f, 0.9f);
			int num4 = Random.Range(0, arm.Fingers.Count);
			arm.FingerTwitchTarget[num4] = Random.Range(-25f, 30f);
		}
		for (int i = 0; i < arm.Fingers.Count; i++)
		{
			arm.FingerTwitch[i] = Mathf.Lerp(arm.FingerTwitch[i], arm.FingerTwitchTarget[i], 1f - Mathf.Exp((0f - dt) * 25f));
			arm.FingerTwitchTarget[i] = Mathf.Lerp(arm.FingerTwitchTarget[i], 0f, dt * 0.7f);
			arm.Fingers[i].localRotation = Quaternion.Euler(curl + arm.FingerTwitch[i], 0f, 0f);
		}
	}

	private void GripReach(Arm arm, Quaternion waistRotation, out Quaternion shoulderLocal, out Quaternion elbowLocal)
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: 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_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0104: Unknown result type (might be due to invalid IL or missing references)
		//IL_0109: Unknown result type (might be due to invalid IL or missing references)
		//IL_010e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0112: Unknown result type (might be due to invalid IL or missing references)
		//IL_0117: Unknown result type (might be due to invalid IL or missing references)
		//IL_0119: Unknown result type (might be due to invalid IL or missing references)
		//IL_011e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0120: Unknown result type (might be due to invalid IL or missing references)
		//IL_0125: Unknown result type (might be due to invalid IL or missing references)
		//IL_0128: Unknown result type (might be due to invalid IL or missing references)
		//IL_0129: Unknown result type (might be due to invalid IL or missing references)
		//IL_012e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0130: Unknown result type (might be due to invalid IL or missing references)
		//IL_0135: Unknown result type (might be due to invalid IL or missing references)
		//IL_013c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0141: Unknown result type (might be due to invalid IL or missing references)
		//IL_0143: Unknown result type (might be due to invalid IL or missing references)
		//IL_0148: Unknown result type (might be due to invalid IL or missing references)
		//IL_014a: Unknown result type (might be due to invalid IL or missing references)
		//IL_014f: 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)
		int side = arm.Side;
		Vector3 val = new Vector3(0f, 1.8f, 0f) + waistRotation * arm.Shoulder.localPosition;
		Vector3 val2 = new Vector3((float)side * 0.25f, 2.25f, 1.1f) - val;
		float num = Mathf.Clamp(((Vector3)(ref val2)).magnitude, 0.58000004f, 2.1f);
		Vector3 normalized = ((Vector3)(ref val2)).normalized;
		Vector3 normalized2 = default(Vector3);
		((Vector3)(ref normalized2))..ctor((float)side, 0.5f, -0.3f);
		Vector3 val3 = normalized2 - Vector3.Dot(normalized2, normalized) * normalized;
		normalized2 = ((Vector3)(ref val3)).normalized;
		float num2 = Mathf.Acos(Mathf.Clamp((0.6083999f + num * num - 1.7956f) / (1.56f * num), -1f, 1f));
		Vector3 val4 = normalized * Mathf.Cos(num2) + normalized2 * Mathf.Sin(num2);
		Vector3 val5 = normalized * num - val4 * 0.78f;
		Vector3 normalized3 = ((Vector3)(ref val5)).normalized;
		Quaternion val6 = Quaternion.FromToRotation(Vector3.down, val4);
		shoulderLocal = Quaternion.Inverse(waistRotation) * val6;
		elbowLocal = Quaternion.FromToRotation(Vector3.down, Quaternion.Inverse(val6) * normalized3);
	}

	private static void StrikePose(float time, int armSide, ref Quaternion pose, ref float elbowBend, ref float lowerBend, ref float curl)
	{
		//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_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_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0107: Unknown result type (might be due to invalid IL or missing references)
		//IL_0109: Unknown result type (might be due to invalid IL or missing references)
		//IL_0110: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: 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)
		Quaternion val = Quaternion.Euler(-170f, 0f, (float)armSide * 35f);
		Quaternion val2 = Quaternion.Euler(-25f, 0f, (float)(-armSide) * 30f);
		float num = 0.26f;
		float num2 = 0.4f;
		if (time < num)
		{
			float num3 = Mathf.SmoothStep(0f, 1f, time / num);
			pose = Quaternion.Slerp(pose, val, num3);
			elbowBend = Mathf.Lerp(elbowBend, -50f, num3);
			lowerBend = Mathf.Lerp(lowerBend, -40f, num3);
			curl = Mathf.Lerp(curl, -20f, num3);
		}
		else if (time < num2)
		{
			float num4 = (time - num) / (num2 - num);
			pose = Quaternion.Slerp(val, val2, num4);
			elbowBend = Mathf.Lerp(-50f, -5f, num4);
			lowerBend = Mathf.Lerp(-40f, 0f, num4);
			curl = Mathf.Lerp(-20f, 55f, num4);
		}
		else
		{
			float num5 = Mathf.Clamp01((time - num2) / 0.4f);
			pose = Quaternion.Slerp(val2, pose, num5);
			elbowBend = Mathf.Lerp(-5f, elbowBend, num5);
			lowerBend = Mathf.Lerp(0f, lowerBend, num5);
			curl = Mathf.Lerp(55f, curl, num5);
		}
	}

	private void PoseHead(bool peeking, int side, bool aggressive, bool stunned, float timeInState, float dt, float t)
	{
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: 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_00b6: 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_0153: Unknown result type (might be due to invalid IL or missing references)
		//IL_016f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0174: Unknown result type (might be due to invalid IL or missing references)
		//IL_0181: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
		if (dt > 0f)
		{
			twitchHold -= dt;
			if (Time.time >= nextTwitch)
			{
				nextTwitch = Time.time + Random.Range(2.5f, 7f);
				twitchTarget = new Vector3(Random.Range(-12f, 12f), Random.Range(-25f, 25f), Random.Range(-20f, 20f));
				twitchHold = Random.Range(0.4f, 1.5f);
			}
			if (twitchHold <= 0f)
			{
				twitchTarget = Vector3.Lerp(twitchTarget, Vector3.zero, dt * 0.8f);
			}
			twitch = Vector3.Lerp(twitch, twitchTarget, 1f - Mathf.Exp((0f - dt) * 22f));
		}
		float num = 0f - lean;
		if (peeking)
		{
			float num2 = 28f + Mathf.Min(timeInState * 9f, 75f);
			num = (float)(-side) * (50f + num2) * (Mathf.Abs(lean) / 50f);
		}
		float num3 = (aggressive ? 18f : 4f) + Mathf.Sin(t * 0.7f) * 3f;
		Vector3 val = ((stunned || aggressive) ? (Random.insideUnitSphere * (stunned ? 4f : 1.5f)) : Vector3.zero);
		head.rotation = enemyRoot.rotation * Quaternion.AngleAxis(num + twitch.z + val.z, Vector3.forward) * Quaternion.Euler(num3 + twitch.x + val.x, twitch.y + val.y, 0f);
	}

	private void PoseEyes()
	{
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: 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_0079: 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_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: 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)
		StartOfRound instance = StartOfRound.Instance;
		if ((Object)(object)instance == (Object)null || (Object)(object)instance.audioListener == (Object)null)
		{
			return;
		}
		Vector3 position = ((Component)instance.audioListener).transform.position;
		foreach (Transform eye in eyes)
		{
			Vector3 val = head.InverseTransformDirection(position - eye.position);
			if (val.z <= 0.05f)
			{
				eye.localRotation = Quaternion.identity;
				continue;
			}
			Quaternion val2 = Quaternion.LookRotation(val);
			eye.localRotation = Quaternion.RotateTowards(Quaternion.identity, val2, 22f);
		}
	}

	private void PoseHair(float dt, float t)
	{
		//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_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: 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_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_00ae: 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)
		Vector3 position = head.position;
		if (dt > 0f)
		{
			Vector3 val = (position - lastHeadPosition) / dt;
			hairSway = Vector3.Lerp(hairSway, -val, 1f - Mathf.Exp((0f - dt) * 4f));
		}
		lastHeadPosition = position;
		foreach (Strand item in hair)
		{
			float num = Mathf.Sin(t * 1.1f + item.Phase) * 3f;
			Vector3 val2 = Vector3.ClampMagnitude(hairSway * item.Stiffness, 7f) * 6f;
			item.Pivot.rotation = Quaternion.Euler(0f - val2.z + num, 0f, val2.x + num * 0.5f);
		}
	}

	private void Footfall(bool aggressive, bool fleeing)
	{
		stepVolume = (aggressive ? 1f : (fleeing ? 0.85f : 0.65f)) * Mathf.Clamp01(Plugin.FootstepVolume.Value);
		PlayStep(Sounds.Steps, stepVolume * Random.Range(0.8f, 1f));
		if (!aggressive && dragAt < 0f && Random.value < 0.3f)
		{
			dragAt = Time.time + Random.Range(0.1f, 0.2f);
		}
	}

	private void PlayStep(AudioClip[] clips, float volume)
	{
		AudioClip val = Sounds.Pick(clips);
		if (!((Object)(object)stepSource == (Object)null) && !((Object)(object)val == (Object)null) && !(volume <= 0f))
		{
			stepSource.pitch = Random.Range(0.9f, 1.08f);
			stepSource.PlayOneShot(val, volume);
		}
	}

	private void UpdateOcclusion()
	{
		//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_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: 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_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: 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_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		if (!(Time.time < nextOcclusionCheck) && !((Object)(object)stepFilter == (Object)null) && !((Object)(object)StartOfRound.Instance == (Object)null) && !((Object)(object)StartOfRound.Instance.audioListener == (Object)null))
		{
			nextOcclusionCheck = Time.time + 0.2f;
			Vector3 position = ((Component)StartOfRound.Instance.audioListener).transform.position;
			Vector3 val = enemyRoot.position + Vector3.up * 1.2f * Scale;
			bool flag = Physics.Linecast(position, val, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1);
			float num = Mathf.Lerp(18000f, 5000f, Mathf.InverseLerp(8f, 45f, Vector3.Distance(position, val)));
			if (flag)
			{
				num *= 0.25f;
			}
			stepFilter.cutoffFrequency = num;
			if ((Object)(object)voiceFilter != (Object)null)
			{
				voiceFilter.cutoffFrequency = Mathf.Max(num, 2500f);
			}
		}
	}

	private void BuildLegs()
	{
		//IL_0006: 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_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: 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)
		Material val = Skin();
		Material val2 = Mat(BoneColor);
		Primitive(((Component)this).transform, "Pelvis", (PrimitiveType)0, val, new Vector3(0f, 1.8f, 0f), new Vector3(0.34f, 0.18f, 0.2f), Quaternion.identity);
		for (int i = -1; i <= 1; i += 2)
		{
			Primitive(((Component)this).transform, "HipBone", (PrimitiveType)0, val2, new Vector3((float)i * 0.155f, 1.8599999f, 0.035f), new Vector3(0.09f, 0.06f, 0.08f), Quaternion.Euler(0f, 0f, (float)i * 25f));
		}
		BuildLeg(-1, val, val2, out legL, out kneeL, out ankleL);
		BuildLeg(1, val, val2, out legR, out kneeR, out ankleR);
	}

	private void BuildLeg(int side, Material skin, Material bone, out Transform hip, out Transform knee, out Transform ankle)
	{
		//IL_0000: 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_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_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)
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: 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_0116: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: Unknown result type (might be due to invalid IL or missing references)
		//IL_013e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0143: Unknown result type (might be due to invalid IL or missing references)
		//IL_015f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0164: Unknown result type (might be due to invalid IL or missing references)
		//IL_0180: Unknown result type (might be due to invalid IL or missing references)
		//IL_0185: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0255: Unknown result type (might be due to invalid IL or missing references)
		//IL_025a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0278: Unknown result type (might be due to invalid IL or missing references)
		//IL_027d: Unknown result type (might be due to invalid IL or missing references)
		//IL_029b: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0305: Unknown result type (might be due to invalid IL or missing references)
		//IL_0317: 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_0321: Unknown result type (might be due to invalid IL or missing references)
		Material mat = Mat(ClawColor);
		hip = Pivot(((Component)this).transform, (side < 0) ? "LegL" : "LegR", new Vector3((float)side * 0.13f, 1.8f, 0f));
		Part(hip, "Thigh", Tube((Vector3[])(object)new Vector3[3]
		{
			Vector3.zero,
			new Vector3(0f, -0.35f, 0.015f),
			new Vector3(0f, -0.92f, 0f)
		}, new float[3] { 0.075f, 0.052f, 0.034f }, 10), skin);
		knee = Pivot(hip, "Knee", new Vector3(0f, -0.92f, 0f));
		Primitive(knee, "Kneecap", (PrimitiveType)0, skin, new Vector3(0f, 0f, 0.016f), new Vector3(0.08f, 0.09f, 0.075f), Quaternion.identity);
		Part(knee, "Shin", Tube((Vector3[])(object)new Vector3[3]
		{
			Vector3.zero,
			new Vector3(0f, -0.3f, -0.01f),
			new Vector3(0f, -0.88f, 0f)
		}, new float[3] { 0.036f, 0.03f, 0.018f }, 8), skin);
		ankle = Pivot(knee, "Ankle", new Vector3(0f, -0.88f, 0f));
		Primitive(ankle, "Heel", (PrimitiveType)0, skin, new Vector3(0f, 0.02f, -0.015f), Vector3.one * 0.055f, Quaternion.identity);
		Vector3 val = default(Vector3);
		for (int i = 0; i < 4; i++)
		{
			float num = ((float)i - 1.5f) * 0.05f;
			((Vector3)(ref val))..ctor(num * 2.4f, 0.004f, 0.4f);
			Vector3[] points = (Vector3[])(object)new Vector3[4]
			{
				new Vector3(num * 0.3f, 0.02f, 0f),
				new Vector3(num * 1.2f, 0.08f, 0.12f),
				new Vector3(num * 2f, 0.05f, 0.28f),
				val
			};
			Part(ankle, "Toe", Tube(points, new float[4] { 0.018f, 0.014f, 0.01f, 0.007f }, 6), skin);
			Part(ankle, "ToeClaw", Tube((Vector3[])(object)new Vector3[2]
			{
				val,
				val + new Vector3(num * 0.2f, -0.004f, 0.07f)
			}, new float[2] { 0.007f, 0.0005f }, 5), mat);
		}
	}

	private void BuildUpperBody()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: 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_00f2: 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_019a: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0202: Unknown result type (might be due to invalid IL or missing references)
		//IL_0216: Unknown result type (might be due to invalid IL or missing references)
		//IL_0232: Unknown result type (might be due to invalid IL or missing references)
		//IL_025d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0271: Unknown result type (might be due to invalid IL or missing references)
		//IL_0289: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c6: 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_035b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0360: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_039d: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_03be: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_041a: 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_043b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0440: Unknown result type (might be due to invalid IL or missing references)
		//IL_045c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0461: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_04cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_04d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_04f3: 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)
		Material val = Skin();
		Material val2 = Mat(BoneColor);
		waist = Pivot(((Component)this).transform, "Waist", new Vector3(0f, 1.8f, 0f));
		Transform val3 = Pivot(waist, "Torso", Vector3.zero);
		val3.localScale = new Vector3(1f, 1f, 0.75f);
		Part(val3, "Chest", Tube(ChestPoints, ChestRadii, 16), val);
		for (int i = 0; i < 7; i++)
		{
			float y = 0.42f + (float)i * 0.065f;
			Part(val3, "Rib", Tube(RibArc(y, ChestRadius(y) + 0.004f), Fill(13, 0.012f), 5), val2);
		}
		Part(val3, "Sternum", Tube(Line(new Vector3(0f, 0.5f, ChestRadius(0.5f)), new Vector3(0f, 0.86f, ChestRadius(0.86f))), new float[2] { 0.012f, 0.016f }, 5), val2);
		for (int j = 0; j < 10; j++)
		{
			float num = 0.08f + (float)j * 0.088f;
			float num2 = ChestRadius(num) - 0.01f;
			float num3 = 0.03f + Mathf.Sin((float)j / 9f * (float)Math.PI) * 0.035f;
			Primitive(val3, "Vertebra", (PrimitiveType)0, val2, new Vector3(0f, num, 0f - num2), new Vector3(0.03f, 0.038f, num3 * 2f), Quaternion.Euler(-25f, 0f, 0f));
		}
		for (int k = -1; k <= 1; k += 2)
		{
			Primitive(val3, "ShoulderBlade", (PrimitiveType)0, val2, new Vector3((float)k * 0.11f, 0.74f, -0.2f), new Vector3(0.12f, 0.17f, 0.04f), Quaternion.Euler(10f, (float)k * 20f, (float)k * -12f));
			Primitive(waist, "Hunch", (PrimitiveType)0, val, new Vector3((float)k * 0.15f, 0.88f, -0.03f), new Vector3(0.24f, 0.13f, 0.17f), Quaternion.Euler(0f, 0f, (float)k * -18f));
			Part(waist, "Collarbone", Tube(Line(new Vector3(0f, 0.9f, 0.1f), new Vector3((float)k * 0.27f, 0.88f, 0.02f)), new float[2] { 0.016f, 0.024f }, 6), val2);
		}
		armL = BuildArm(-1, val, val2);
		armR = BuildArm(1, val, val2);
		Transform parent = Pivot(waist, "Neck", new Vector3(0f, 0.9f, 0.01f));
		Vector3[] points = (Vector3[])(object)new Vector3[4]
		{
			Vector3.zero,
			new Vector3(0f, 0.12f, 0.04f),
			new Vector3(0f, 0.24f, 0.11f),
			new Vector3(0f, 0.32f, 0.21f)
		};
		Part(parent, "NeckTube", Tube(points, new float[4] { 0.06f, 0.045f, 0.04f, 0.042f }, 10), val);
		Part(parent, "Tendon", Tube((Vector3[])(object)new Vector3[3]
		{
			new Vector3(-0.025f, 0.02f, 0.03f),
			new Vector3(-0.02f, 0.2f, 0.12f),
			new Vector3(-0.015f, 0.32f, 0.22f)
		}, new float[3] { 0.009f, 0.008f, 0.006f }, 5), val);
		Part(parent, "Tendon", Tube((Vector3[])(object)new Vector3[3]
		{
			new Vector3(0.025f, 0.02f, 0.03f),
			new Vector3(0.02f, 0.2f, 0.12f),
			new Vector3(0.015f, 0.32f, 0.22f)
		}, new float[3] { 0.009f, 0.008f, 0.006f }, 5), val);
		head = Pivot(parent, "Head", new Vector3(0f, 0.34f, 0.22f));
		BuildHead(head);
	}

	private Arm BuildArm(int side, Material skin, Material bone)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_011f: Unknown result type (might be due to invalid IL or missing references)
		//IL_013b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0140: Unknown result type (might be due to invalid IL or missing references)
		//IL_014a: Unknown result type (might be due to invalid IL or missing references)
		//IL_014f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0165: Unknown result type (might be due to invalid IL or missing references)
		//IL_0179: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_020d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0221: Unknown result type (might be due to invalid IL or missing references)
		//IL_026f: 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_02ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0347: Unknown result type (might be due to invalid IL or missing references)
		//IL_0331: 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_03c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_03eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_03fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_036a: 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_044b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0455: Unknown result type (might be due to invalid IL or missing references)
		//IL_045a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0487: Unknown result type (might be due to invalid IL or missing references)
		//IL_0489: Unknown result type (might be due to invalid IL or missing references)
		//IL_0496: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b1: Unknown result type (might be due to invalid IL or missing references)
		Material mat = Mat(ClawColor);
		Arm arm = new Arm();
		arm.Side = side;
		arm.Shoulder = Pivot(waist, (side < 0) ? "ShoulderL" : "ShoulderR", new Vector3((float)side * 0.27f, 0.86f, 0f));
		Primitive(arm.Shoulder, "ShoulderKnob", (PrimitiveType)0, skin, Vector3.zero, Vector3.one * 0.11f, Quaternion.identity);
		Part(arm.Shoulder, "UpperArm", Tube((Vector3[])(object)new Vector3[3]
		{
			Vector3.zero,
			new Vector3(0f, -0.3f, 0.01f),
			new Vector3(0f, -0.78f, 0f)
		}, new float[3] { 0.055f, 0.042f, 0.032f }, 10), skin);
		arm.Elbow = Pivot(arm.Shoulder, "Elbow", new Vector3(0f, -0.78f, 0f));
		Primitive(arm.Elbow, "ElbowKnob", (PrimitiveType)0, skin, Vector3.zero, Vector3.one * 0.068f, Quaternion.identity);
		Part(arm.Elbow, "MidArm", Tube(Line(Vector3.zero, new Vector3(0f, -0.72f, 0f)), new float[2] { 0.034f, 0.026f }, 8), skin);
		arm.LowerElbow = Pivot(arm.Elbow, "LowerElbow", new Vector3(0f, -0.72f, 0f));
		Primitive(arm.LowerElbow, "LowerElbowKnob", (PrimitiveType)0, skin, Vector3.zero, Vector3.one * 0.054f, Quaternion.identity);
		Part(arm.LowerElbow, "Forearm", Tube(Line(Vector3.zero, new Vector3(0f, -0.62f, 0f)), new float[2] { 0.027f, 0.019f }, 8), skin);