Decompiled source of Junker Queen v0.1.31

plugins/AJ-JunkerQueen/JunkerQueen.dll

Decompiled an hour ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Dissonance;
using GameNetcodeStuff;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace JunkerQueenMod
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("aj.junkerqueen.test", "Junker Queen Test", "0.1.31")]
	public sealed class Plugin : BaseUnityPlugin
	{
		internal static Plugin Instance;

		internal AssetBundle Bundle;

		internal GameObject Prefab;

		internal string AssetFolder;

		internal float MovementVolume;

		internal float KillDelay;

		internal float DoorDelay;

		internal float Roam;

		internal float Turn;

		internal float Windup;

		internal float Speed;

		internal float Range;

		internal int Damage;

		private readonly Dictionary<ulong, QueenController> queens = new Dictionary<ulong, QueenController>();

		internal ManualLogSource Log => ((BaseUnityPlugin)this).Logger;

		private void Awake()
		{
			Instance = this;
			AssetFolder = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			MovementVolume = Mathf.Clamp01(((BaseUnityPlugin)this).Config.Bind<float>("Audio", "MovementLoopVolume", 0.55f, (ConfigDescription)null).Value);
			KillDelay = Mathf.Max(0f, ((BaseUnityPlugin)this).Config.Bind<float>("Dialogue", "KillLineDelaySeconds", 1.5f, (ConfigDescription)null).Value);
			DoorDelay = Mathf.Max(0f, ((BaseUnityPlugin)this).Config.Bind<float>("Movement", "RoamingDoorOpenSeconds", 3f, (ConfigDescription)null).Value);
			Roam = ((BaseUnityPlugin)this).Config.Bind<float>("Movement", "RoamingSpeed", 1.2f, (ConfigDescription)null).Value;
			Turn = ((BaseUnityPlugin)this).Config.Bind<float>("Movement", "RotationSpeed", 60f, (ConfigDescription)null).Value;
			Windup = ((BaseUnityPlugin)this).Config.Bind<float>("Attack", "WindupSeconds", 1.3f, (ConfigDescription)null).Value;
			Speed = ((BaseUnityPlugin)this).Config.Bind<float>("Attack", "ChargeSpeed", 33f, (ConfigDescription)null).Value;
			Range = ((BaseUnityPlugin)this).Config.Bind<float>("Attack", "ChargeDistance", 25f, (ConfigDescription)null).Value;
			Damage = ((BaseUnityPlugin)this).Config.Bind<int>("Attack", "Damage", 50, (ConfigDescription)null).Value;
			int rarity = Mathf.Clamp(((BaseUnityPlugin)this).Config.Bind<int>("Spawning", "SpawnWeight", 20, "Same indoor spawn weight on every moon; zero disables natural selection. Native cap is two; low weight makes a second Queen uncommon.").Value, 0, 1000);
			try
			{
				Bundle = AssetBundle.LoadFromMemory(File.ReadAllBytes(Path.Combine(AssetFolder, "jqvisual012")));
				if (!Object.op_Implicit((Object)(object)Bundle))
				{
					throw new Exception("Junker Queen visual bundle failed to load");
				}
				Prefab = Bundle.LoadAsset<GameObject>("JunkerQueenVisual");
				if (!Object.op_Implicit((Object)(object)Prefab))
				{
					throw new Exception("JunkerQueenVisual missing");
				}
				Registration.Register(Prefab, rarity);
				((BaseUnityPlugin)this).Logger.LogInfo((object)("JQ_REGISTERED: native indoor enemy + Imperium Entities; uniform moon weight=" + rarity + "; maximum=2; power=1.5; independent per-Queen controllers"));
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)ex);
				((Behaviour)this).enabled = false;
			}
		}

		internal void Attach(JunkerQueenAI ai)
		{
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Expected O, but got Unknown
			if (!((Behaviour)this).enabled || !Object.op_Implicit((Object)(object)ai) || !Object.op_Implicit((Object)(object)((NetworkBehaviour)ai).NetworkObject) || !((NetworkBehaviour)ai).NetworkObject.IsSpawned)
			{
				return;
			}
			ulong networkObjectId = ((NetworkBehaviour)ai).NetworkObjectId;
			if (queens.ContainsKey(networkObjectId))
			{
				return;
			}
			int num = 0;
			foreach (QueenController value in queens.Values)
			{
				if (Object.op_Implicit((Object)(object)value) && value.HasLivingQueen)
				{
					num++;
				}
			}
			if (((NetworkBehaviour)ai).IsServer && num >= 2)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)"JQ_CAP_REJECTED: two Queens already active");
				((NetworkBehaviour)ai).NetworkObject.Despawn(true);
				return;
			}
			GameObject val = new GameObject("JunkerQueenController-" + networkObjectId);
			val.transform.SetParent(((Component)this).transform, false);
			QueenController queenController = val.AddComponent<QueenController>();
			queens.Add(networkObjectId, queenController);
			queenController.Initialize(this, ai);
		}

		internal void Detach(JunkerQueenAI ai)
		{
			if (queens.TryGetValue(((NetworkBehaviour)ai).NetworkObjectId, out var value) && Object.op_Implicit((Object)(object)value))
			{
				value.Detach(ai);
			}
		}

		internal void Hear(JunkerQueenAI ai, Vector3 position, float loudness, int repetitions)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			if (queens.TryGetValue(((NetworkBehaviour)ai).NetworkObjectId, out var value) && Object.op_Implicit((Object)(object)value))
			{
				value.Hear(ai, position, loudness, repetitions);
			}
		}

		internal void Forget(ulong id, QueenController controller)
		{
			if (queens.TryGetValue(id, out var value) && (Object)(object)value == (Object)(object)controller)
			{
				queens.Remove(id);
			}
		}
	}
	public sealed class ChargeState
	{
		public enum Phase
		{
			Roaming,
			Turning,
			Windup,
			Charging,
			Repositioning,
			Falling,
			Dead
		}

		public float Speed = 35.7f;

		public float MaximumDistance = 25f;

		public float WindupSeconds = 1f;

		private float windupElapsed;

		private bool chargeReady;

		private readonly HashSet<ulong> hitPlayers = new HashSet<ulong>();

		public Phase Current { get; private set; } = Phase.Roaming;

		public bool AttackCommitted => Current == Phase.Windup || Current == Phase.Charging;

		public float DirectionX { get; private set; }

		public float DirectionZ { get; private set; }

		public float DistanceTravelled { get; private set; }

		public uint Sequence { get; private set; }

		public void Detect()
		{
			if (Current == Phase.Roaming)
			{
				Current = Phase.Turning;
			}
		}

		public void Aligned()
		{
			if (Current == Phase.Turning)
			{
				windupElapsed = 0f;
				chargeReady = false;
				Current = Phase.Windup;
			}
		}

		public bool AdvanceWindup(float delta, bool ultimateDialogueFinished)
		{
			ValidateDelta(delta);
			if (Current != Phase.Windup)
			{
				return false;
			}
			windupElapsed += delta;
			chargeReady = windupElapsed >= Math.Max(0f, WindupSeconds) && ultimateDialogueFinished;
			return chargeReady;
		}

		public bool BeginCharge(float x, float z, float targetX, float targetZ)
		{
			if (Current != Phase.Windup || !chargeReady)
			{
				return false;
			}
			float num = targetX - x;
			float num2 = targetZ - z;
			float num3 = (float)Math.Sqrt(num * num + num2 * num2);
			if (float.IsNaN(num3) || float.IsInfinity(num3) || num3 < 0.001f)
			{
				return false;
			}
			DirectionX = num / num3;
			DirectionZ = num2 / num3;
			DistanceTravelled = 0f;
			hitPlayers.Clear();
			Sequence++;
			Current = Phase.Charging;
			return true;
		}

		public float RequestedStep(float delta)
		{
			ValidateDelta(delta);
			if (Current != Phase.Charging)
			{
				return 0f;
			}
			return Math.Min(Math.Max(0f, Speed) * delta, Math.Max(0f, MaximumDistance - DistanceTravelled));
		}

		public void CommitMovement(float actualDistance, bool blocked, bool supported)
		{
			if (Current == Phase.Charging)
			{
				if (float.IsNaN(actualDistance) || float.IsInfinity(actualDistance) || actualDistance < 0f)
				{
					throw new ArgumentOutOfRangeException("actualDistance");
				}
				DistanceTravelled = Math.Min(MaximumDistance, DistanceTravelled + actualDistance);
				if (!supported)
				{
					Current = Phase.Falling;
				}
				else if (blocked || DistanceTravelled >= MaximumDistance)
				{
					Current = Phase.Turning;
				}
			}
		}

		public bool AcceptPlayerHit(ulong playerId)
		{
			return Current == Phase.Charging && hitPlayers.Add(playerId);
		}

		public void LoseTarget()
		{
			if (Current == Phase.Turning)
			{
				Current = Phase.Roaming;
			}
		}

		public bool EnvironmentalDeath()
		{
			if (Current != Phase.Falling)
			{
				return false;
			}
			Current = Phase.Dead;
			return true;
		}

		public void Land()
		{
			if (Current == Phase.Falling)
			{
				Current = Phase.Repositioning;
			}
		}

		public void BeginFalling()
		{
			if (Current != Phase.Dead)
			{
				Current = Phase.Falling;
			}
		}

		public void BeginRepositioning()
		{
			if (Current != Phase.Dead && Current != Phase.Falling)
			{
				Current = Phase.Repositioning;
			}
		}

		public void FinishRepositioning(bool hasTarget)
		{
			if (Current == Phase.Repositioning)
			{
				Current = (hasTarget ? Phase.Turning : Phase.Roaming);
			}
		}

		private static void ValidateDelta(float delta)
		{
			if (float.IsNaN(delta) || float.IsInfinity(delta) || delta < 0f)
			{
				throw new ArgumentOutOfRangeException("delta");
			}
		}
	}
	internal static class Registration
	{
		internal static EnemyType Type;

		internal static void Register(GameObject visual, int rarity)
		{
			//IL_002b: 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_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			//IL_00a3: 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_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Expected O, but got Unknown
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Expected O, but got Unknown
			//IL_0126: 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)
			GameObject val = NetworkPrefabs.CreateNetworkPrefab("JunkerQueenEnemy");
			GameObject val2 = Object.Instantiate<GameObject>(visual, val.transform);
			((Object)val2).name = "Visual";
			val2.transform.localPosition = Vector3.zero;
			val2.transform.localRotation = Quaternion.identity;
			NavMeshAgent val3 = val.AddComponent<NavMeshAgent>();
			((Behaviour)val3).enabled = false;
			val3.height = 2.13f;
			val3.radius = 0.225f;
			JunkerQueenAI junkerQueenAI = val.AddComponent<JunkerQueenAI>();
			((EnemyAI)junkerQueenAI).agent = val3;
			GameObject val4 = new GameObject("Eye");
			val4.transform.SetParent(val.transform, false);
			val4.transform.localPosition = Vector3.up * 2.6f;
			((EnemyAI)junkerQueenAI).eye = val4.transform;
			((EnemyAI)junkerQueenAI).meshRenderers = val.GetComponentsInChildren<MeshRenderer>();
			((EnemyAI)junkerQueenAI).skinnedMeshRenderers = (SkinnedMeshRenderer[])(object)new SkinnedMeshRenderer[0];
			((EnemyAI)junkerQueenAI).enemyBehaviourStates = (EnemyBehaviourState[])(object)new EnemyBehaviourState[1]
			{
				new EnemyBehaviourState()
			};
			GameObject val5 = new GameObject("EnemyCollision");
			val5.transform.SetParent(val.transform, false);
			val5.layer = 19;
			CapsuleCollider val6 = val5.AddComponent<CapsuleCollider>();
			val6.center = Vector3.up * 1.48f;
			val6.height = 2.96f;
			val6.radius = 0.225f;
			((Collider)val6).isTrigger = true;
			val5.AddComponent<EnemyAICollisionDetect>().mainScript = (EnemyAI)(object)junkerQueenAI;
			val5.AddComponent<JunkerQueenNoiseRelay>().queen = junkerQueenAI;
			Type = ScriptableObject.CreateInstance<EnemyType>();
			((Object)Type).hideFlags = (HideFlags)32;
			((Object)Type).name = "Junker Queen";
			Type.enemyName = "Junker Queen";
			Type.enemyPrefab = val;
			Type.MaxCount = 2;
			Type.PowerLevel = 1.5f;
			Type.probabilityCurve = AnimationCurve.Constant(0f, 1f, 1f);
			((EnemyAI)junkerQueenAI).enemyType = Type;
			Enemies.RegisterEnemy(Type, rarity, (LevelTypes)(-1), (SpawnType)0, (TerminalNode)null, (TerminalKeyword)null);
			Type.spawningDisabled = false;
			if (val.activeInHierarchy)
			{
				throw new Exception("Junker Queen template must stay inactive in the prefab container");
			}
			bool flag = false;
			EnemyType[] array = Resources.FindObjectsOfTypeAll<EnemyType>();
			foreach (EnemyType val7 in array)
			{
				if ((Object)(object)val7 == (Object)(object)Type && Object.op_Implicit((Object)(object)val7.enemyPrefab))
				{
					flag = true;
				}
			}
			if (!flag)
			{
				throw new Exception("Junker Queen EnemyType is not discoverable");
			}
		}
	}
	public sealed class JunkerQueenAI : EnemyAI
	{
		public override void Awake()
		{
			if (Object.op_Implicit((Object)(object)RoundManager.Instance))
			{
				base.thisEnemyIndex = RoundManager.Instance.numberOfEnemiesInScene;
			}
		}

		public override void Start()
		{
			if (Object.op_Implicit((Object)(object)((NetworkBehaviour)this).NetworkObject) && ((NetworkBehaviour)this).NetworkObject.IsSpawned)
			{
				Plugin.Instance.Attach(this);
			}
		}

		public override void OnNetworkDespawn()
		{
			if (Object.op_Implicit((Object)(object)Plugin.Instance))
			{
				Plugin.Instance.Detach(this);
			}
			if (Object.op_Implicit((Object)(object)RoundManager.Instance))
			{
				RoundManager.Instance.SpawnedEnemies.Remove((EnemyAI)(object)this);
			}
			((NetworkBehaviour)this).OnNetworkDespawn();
		}

		public override void Update()
		{
		}

		public override void DoAIInterval()
		{
		}

		public override void HitEnemy(int force, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
		{
		}

		public override void KillEnemy(bool destroy = false)
		{
		}
	}
	public sealed class QueenController : MonoBehaviour
	{
		[Serializable]
		private class VoiceEvent
		{
			public int index;

			public Vector3 position;

			public bool death;
		}

		[Serializable]
		private class Snapshot
		{
			public bool alive;

			public bool charging;

			public bool movementAudio;

			public Vector3 position;

			public Quaternion rotation;
		}

		private string VoiceChannel;

		private readonly string[] voiceNames = new string[30]
		{
			"00000005BA67-Oi", "00000005C6FB-Oi", "00000005C7F4-Oi", "00000005C802-Oi", "00000005C87F-Oi", "0000000648B6-Oi", "Behind-ya", "Ultimate-05BA72-Time-for-the-Reckoning", "Junker_Queen_-_(prolonged_screaming)_(1)", "Junker_Queen_-_(prolonged_screaming)_(2)",
			"Junker_Queen_-_(prolonged_screaming)_(3)", "Roam-00000005BA80", "Roam-00000005BA81", "Roam-00000005C661", "Roam-00000005C664", "Roam-00000005C6B1", "Roam-00000005C6B2", "Roam-00000005C6F7", "Roam-00000005C724", "Roam-00000005C84F",
			"Roam-00000005D42E", "Roam-000000061ECD", "Kill-0000000640E8", "Kill-000000061F03", "Kill-000000061F00", "Kill-000000061F01", "Kill-00000005C64E", "Kill-00000005C64D", "Kill-00000005C64C", "Kill-00000005BE72"
		};

		private int previousDetection = -1;

		private int previousRoaming = -1;

		private int previousDeath = -1;

		private readonly Dictionary<int, ShuffleCycle> voiceCycles = new Dictionary<int, ShuffleCycle>();

		private static readonly Func<int, int> randomVoice = (int maximum) => Random.Range(0, maximum);

		private AudioClip[] voices;

		private AudioSource speaking;

		private float dialogueUntil;

		private float voicePlaybackUntil;

		private int activeVoiceIndex = -1;

		private const float GameMetres = 1.388889f;

		private const float BodyRadius = 0.225f;

		private const float WallRadius = 0.21f;

		private const float DamageRadius = 0.35f;

		private Transform groundedVisual;

		private float visualBaseY;

		private float visualGroundAt;

		private Vector3 lastWallNormal;

		private Vector3 recoveryStart;

		private Vector3 recoveryPosition;

		private float recoveryCheckAt;

		private float recoveryStartedAt;

		private int recoveryAttempts;

		private Vector3 lastWalkablePosition;

		private bool hasWalkablePosition;

		private readonly List<Vector3> chargeTrail = new List<Vector3>();

		private Collider lastChargeWall;

		private CapsuleCollider recoveryBodyProbe;

		private float floorNavOffset;

		private float floorCalibrationAt;

		private bool hasFloorNavOffset;

		private Vector3 lastSeenPosition;

		private Vector3 walkCheckPosition;

		private float lastSeenAt = -100f;

		private float walkCheckAt;

		private float repathAt;

		private float roamVoiceAt;

		private float recognizeTargetUntil;

		private float chargeRetryAt;

		private readonly HashSet<DoorLock> slammedDoors = new HashSet<DoorLock>();

		private readonly Dictionary<DoorLock, float> doorWaitUntil = new Dictionary<DoorLock, float>();

		private DoorLock roamingDoor;

		private float roamingDoorReady;

		private float roamingDoorDelay = 3f;

		private Type imperiumType;

		private bool imperiumLookedUp;

		private bool imperiumWarning;

		private AudioClip rampageBell;

		private AudioSource rampageSound;

		private Vector3 heardPosition;

		private float listenUntil;

		private float stepCheckAt;

		private float voiceCheckAt;

		private readonly Dictionary<ulong, Vector3> previousStepPositions = new Dictionary<ulong, Vector3>();

		private float visionRange = 28f;

		private float visionDegrees = 120f;

		private float heardAt = -100f;

		private string KillAckChannel;

		private float killDelay = 1.5f;

		private float killReadyAt;

		private float roamingAfterKillUntil;

		private int previousKill = -1;

		private int pendingKillVoice = -1;

		private readonly Queue<float> killQueue = new Queue<float>();

		private readonly Dictionary<uint, ulong> pendingKillHits = new Dictionary<uint, ulong>();

		private AudioClip movementClip;

		private AudioSource movementSource;

		private bool movementWanted;

		private float movementVolume = 0.55f;

		private readonly Dictionary<ulong, float> rejectedPlayers = new Dictionary<ulong, float>();

		private readonly Dictionary<ulong, Vector3> rejectedPlayerPositions = new Dictionary<ulong, Vector3>();

		private readonly Dictionary<int, float> searchedNodes = new Dictionary<int, float>();

		private float searchRetryAt;

		private float rejectedGoalUntil;

		private Vector3 rejectedGoalPosition;

		private static float sharedShakeAt;

		private bool remoteCharging;

		private bool shakeWasCharging;

		private float nextChargeShake;

		private float shakeTravel;

		private float shakeSincePulse;

		private Vector3 shakePosition;

		private float gapCheckAt;

		private Vector3 gapStart;

		private Vector3 gapEnd;

		private bool gapClear;

		private float recoveryEpisodeAt = -100f;

		private float recoveryProgressAt;

		private float recoveryRepairAt;

		private float lastBlockedAt = -100f;

		private Vector3 recoveryProgressPosition;

		private Vector3 blockedAnchor;

		private int recoveryCandidate;

		private int blockedCharges;

		private float audioSpatialAt;

		private float radarRetryAt;

		private bool radarReady;

		private Plugin owner;

		private ulong queenId;

		private bool detached;

		private bool assetsReady;

		private float disposeAfter;

		private string StateChannel;

		private string DamageChannel;

		private AssetBundle bundle;

		private GameObject prefab;

		private GameObject actor;

		private NavMeshAgent agent;

		private NetworkManager registered;

		private JunkerQueenAI pendingActor;

		private Vector3 lockedAim;

		private float windupReadyAt;

		private float fallStarted;

		private ChargeState rules;

		private PlayerControllerB target;

		private float timer;

		private float fallSpeed;

		private uint lastDamage;

		private uint damageSerial;

		private float roam = 1f;

		private float turn = 60f;

		private float windup = 1f;

		private float speed = 33f;

		private float range = 25f;

		private int damage = 50;

		private int runtimePhase = -1;

		internal bool HasLivingQueen => !detached && (Object.op_Implicit((Object)(object)actor) || Object.op_Implicit((Object)(object)pendingActor));

		private ManualLogSource Logger => owner.Log;

		private int PickVoice(int first, int count, ref int previous)
		{
			if (!voiceCycles.TryGetValue(first, out var value))
			{
				value = new ShuffleCycle(count);
				voiceCycles.Add(first, value);
			}
			previous = first + value.Next(randomVoice);
			return previous;
		}

		private bool LocalListenerInside()
		{
			StartOfRound instance = StartOfRound.Instance;
			if (!Object.op_Implicit((Object)(object)instance) || instance.inShipPhase || instance.shipIsLeaving || !instance.shipHasLanded)
			{
				return false;
			}
			PlayerControllerB val = ListeningPlayer();
			return Object.op_Implicit((Object)(object)val) && val.isInsideFactory && !val.isInHangarShipRoom;
		}

		private void UpdateLocalAudio()
		{
			UpdateSpatialVoices();
			bool mute = !LocalListenerInside();
			if (Object.op_Implicit((Object)(object)speaking))
			{
				speaking.mute = mute;
			}
			if (Object.op_Implicit((Object)(object)rampageSound))
			{
				rampageSound.mute = mute;
			}
		}

		private void StopLocalAudio()
		{
			StopMovementLoop();
			ClearKillDialogue();
			if (Object.op_Implicit((Object)(object)speaking))
			{
				speaking.Stop();
				Object.Destroy((Object)(object)((Component)speaking).gameObject);
				speaking = null;
			}
			if (Object.op_Implicit((Object)(object)rampageSound))
			{
				rampageSound.Stop();
				Object.Destroy((Object)(object)((Component)rampageSound).gameObject);
				rampageSound = null;
			}
			activeVoiceIndex = -1;
			dialogueUntil = 0f;
			voicePlaybackUntil = 0f;
		}

		private void LoadVoices()
		{
			voices = (AudioClip[])(object)new AudioClip[voiceNames.Length];
			for (int i = 0; i < voices.Length; i++)
			{
				voices[i] = bundle.LoadAsset<AudioClip>(voiceNames[i]);
				if (!Object.op_Implicit((Object)(object)voices[i]))
				{
					throw new Exception("Missing voice clip: " + voiceNames[i]);
				}
			}
		}

		private void DetectionVoice(PlayerControllerB player)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: 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_004d: 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)
			Vector3 val = actor.transform.position + Vector3.up * 1.5f - ((Component)player.gameplayCamera).transform.position;
			bool flag = Vector3.Dot(((Component)player.gameplayCamera).transform.forward, ((Vector3)(ref val)).normalized) >= 0.342f;
			Say(flag ? PickVoice(0, 6, ref previousDetection) : 6, death: false, actor.transform.position);
		}

		private unsafe bool Say(int index, bool death, Vector3 position)
		{
			//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_00b6: Unknown result type (might be due to invalid IL or missing references)
			VoiceEvent voiceEvent = new VoiceEvent
			{
				index = index,
				death = death,
				position = position
			};
			if (!PlayVoice(voiceEvent))
			{
				return false;
			}
			dialogueUntil = voicePlaybackUntil;
			if ((Object)(object)registered == (Object)null)
			{
				return true;
			}
			string text = JsonUtility.ToJson((object)voiceEvent);
			FastBufferWriter val = default(FastBufferWriter);
			foreach (ulong connectedClientsId in registered.ConnectedClientsIds)
			{
				if (connectedClientsId != 0)
				{
					((FastBufferWriter)(ref val))..ctor(1024, (Allocator)2, -1);
					try
					{
						((FastBufferWriter)(ref val)).WriteValueSafe(text, false);
						registered.CustomMessagingManager.SendNamedMessage(VoiceChannel, connectedClientsId, val, (NetworkDelivery)3);
					}
					finally
					{
						((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose();
					}
				}
			}
			return true;
		}

		private void ReceiveVoice(ulong sender, FastBufferReader reader)
		{
			if (!((Object)(object)registered == (Object)null) && RoundGameplayReady() && sender == 0L && !registered.IsServer)
			{
				string text = default(string);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref text, false);
				VoiceEvent voiceEvent = JsonUtility.FromJson<VoiceEvent>(text);
				if (!detached || voiceEvent.death)
				{
					PlayVoice(voiceEvent);
				}
			}
		}

		private void CancelPreparatoryVoice()
		{
			if ((activeVoiceIndex == 7 || activeVoiceIndex >= 22) && Time.time < voicePlaybackUntil)
			{
				dialogueUntil = Mathf.Max(dialogueUntil, voicePlaybackUntil);
				return;
			}
			if (Object.op_Implicit((Object)(object)speaking))
			{
				speaking.Stop();
				Object.Destroy((Object)(object)((Component)speaking).gameObject);
				speaking = null;
			}
			dialogueUntil = 0f;
		}

		private bool PlayVoice(VoiceEvent e)
		{
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Expected O, but got Unknown
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			if (voices == null || e.index < 0 || e.index >= voices.Length)
			{
				return false;
			}
			if (Object.op_Implicit((Object)(object)speaking) && activeVoiceIndex == 7 && Time.time < voicePlaybackUntil && !e.death)
			{
				Logger.LogInfo((object)("JQ_VOICE_PROTECTED: ignored interrupt/restart index=" + e.index));
				return false;
			}
			if (Object.op_Implicit((Object)(object)speaking))
			{
				speaking.Stop();
				Object.Destroy((Object)(object)((Component)speaking).gameObject);
			}
			activeVoiceIndex = e.index;
			voicePlaybackUntil = Time.time + voices[e.index].length;
			if (e.index == 7)
			{
				PlayRampageSound(e.position);
			}
			GameObject val = new GameObject("JunkerQueenDialogue");
			val.transform.position = e.position + Vector3.up * 2f;
			if (!e.death && Object.op_Implicit((Object)(object)actor))
			{
				val.transform.SetParent(actor.transform, true);
			}
			speaking = val.AddComponent<AudioSource>();
			speaking.playOnAwake = false;
			speaking.spatialBlend = 1f;
			speaking.minDistance = 3f;
			speaking.maxDistance = 40f;
			speaking.rolloffMode = (AudioRolloffMode)0;
			speaking.dopplerLevel = 0f;
			speaking.volume = 1f;
			ConfigureSpatialVoice(speaking, 28f);
			speaking.clip = voices[e.index];
			speaking.mute = !LocalListenerInside();
			ApplyVoiceDistance(speaking, 28f);
			speaking.PlayOneShot(voices[e.index], (e.index == 7) ? 1.26f : 1.12f);
			Object.Destroy((Object)(object)val, voices[e.index].length + 0.2f);
			if (e.index >= 22)
			{
				Logger.LogInfo((object)("JQ_KILL_PLAYED: index=" + e.index + " muted=" + speaking.mute));
			}
			return true;
		}

		private void SetupVisual(GameObject enemy)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: 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_007d: 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_00a0: 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_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_02af: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Expected O, but got Unknown
			//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_034f: Unknown result type (might be due to invalid IL or missing references)
			//IL_043a: Unknown result type (might be due to invalid IL or missing references)
			//IL_042c: Unknown result type (might be due to invalid IL or missing references)
			//IL_044c: Unknown result type (might be due to invalid IL or missing references)
			//IL_045e: 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)
			Transform val = enemy.transform.Find("Visual");
			if (!Object.op_Implicit((Object)(object)val))
			{
				throw new Exception("Visual child missing");
			}
			enemy.transform.localScale = Vector3.one;
			Renderer[] componentsInChildren = ((Component)val).GetComponentsInChildren<Renderer>(true);
			Bounds bounds = componentsInChildren[0].bounds;
			Renderer[] array = componentsInChildren;
			foreach (Renderer val2 in array)
			{
				((Bounds)(ref bounds)).Encapsulate(val2.bounds);
			}
			float y = ((Bounds)(ref bounds)).size.y;
			val.localScale *= 3.0741525f / Mathf.Max(1E-05f, y);
			bounds = componentsInChildren[0].bounds;
			Renderer[] array2 = componentsInChildren;
			foreach (Renderer val3 in array2)
			{
				((Bounds)(ref bounds)).Encapsulate(val3.bounds);
			}
			val.position += Vector3.up * (enemy.transform.position.y - ((Bounds)(ref bounds)).min.y);
			groundedVisual = val;
			visualBaseY = val.localPosition.y;
			visualGroundAt = 0f;
			HashSet<Shader> hashSet = new HashSet<Shader>();
			Renderer[] array3 = componentsInChildren;
			foreach (Renderer val4 in array3)
			{
				Material[] sharedMaterials = val4.sharedMaterials;
				foreach (Material val5 in sharedMaterials)
				{
					if (Object.op_Implicit((Object)(object)val5))
					{
						hashSet.Add(val5.shader);
					}
				}
			}
			Material val6 = null;
			Material[] array4 = Resources.FindObjectsOfTypeAll<Material>();
			foreach (Material val7 in array4)
			{
				if (Object.op_Implicit((Object)(object)val7) && Object.op_Implicit((Object)(object)val7.shader) && ((Object)val7.shader).name == "HDRP/Lit" && val7.shader.isSupported && !hashSet.Contains(val7.shader))
				{
					val6 = val7;
					break;
				}
			}
			if (!Object.op_Implicit((Object)(object)val6))
			{
				Logger.LogError((object)"JQ_MATERIAL_ERROR: no supported native HDRP/Lit material found");
				return;
			}
			Dictionary<Material, Material> dictionary = new Dictionary<Material, Material>();
			Renderer[] array5 = componentsInChildren;
			foreach (Renderer val8 in array5)
			{
				Material[] sharedMaterials2 = val8.sharedMaterials;
				for (int num = 0; num < sharedMaterials2.Length; num++)
				{
					Material val9 = sharedMaterials2[num];
					if (!Object.op_Implicit((Object)(object)val9))
					{
						continue;
					}
					if (!dictionary.TryGetValue(val9, out var value))
					{
						value = new Material(val6);
						((Object)value).name = "JQ_Game_" + ((Object)val9).name;
						value.SetColor("_BaseColor", Color.white);
						string[] array6 = new string[3] { "_NormalMap", "_MaskMap", "_EmissiveColorMap" };
						foreach (string text in array6)
						{
							if (value.HasProperty(text))
							{
								value.SetTexture(text, (Texture)null);
							}
						}
						if (value.HasProperty("_EmissiveColor"))
						{
							value.SetColor("_EmissiveColor", Color.black);
						}
						value.DisableKeyword("_EMISSIVE_COLOR_MAP");
						value.DisableKeyword("_NORMALMAP_TANGENT_SPACE");
						value.DisableKeyword("_MASKMAP");
						value.SetTexture("_BaseColorMap", (Texture)null);
						Texture val10 = val9.GetTexture("_BaseColorMap");
						if (!Object.op_Implicit((Object)(object)val10))
						{
							string text2 = ((((Object)val9).name.StartsWith("00000000A237") || ((Object)val9).name.StartsWith("00000000A239")) ? "00000002CDAD" : null);
							if (text2 != null)
							{
								val10 = (Texture)(object)bundle.LoadAsset<Texture2D>(text2);
							}
						}
						if (Object.op_Implicit((Object)(object)val10))
						{
							value.SetTexture("_BaseColorMap", val10);
						}
						else
						{
							value.SetColor("_BaseColor", val9.HasProperty("_BaseColor") ? val9.GetColor("_BaseColor") : Color.white);
						}
						value.SetTextureScale("_BaseColorMap", Vector2.one);
						value.SetTextureOffset("_BaseColorMap", Vector2.zero);
						value.SetFloat("_UVBase", 0f);
						value.SetVector("_UVMappingMask", new Vector4(1f, 0f, 0f, 0f));
						value.DisableKeyword("_MAPPING_PLANAR");
						value.DisableKeyword("_MAPPING_TRIPLANAR");
						value.SetFloat("_SurfaceType", 0f);
						value.DisableKeyword("_SURFACE_TYPE_TRANSPARENT");
						value.SetFloat("_AlphaRemapMin", 0f);
						value.SetFloat("_AlphaRemapMax", 1f);
						if (((Object)val9).name.StartsWith("00000000A237") || ((Object)val9).name.StartsWith("00000000A239"))
						{
							val8.shadowCastingMode = (ShadowCastingMode)0;
							value.SetFloat("_AlphaCutoffEnable", 0f);
							value.DisableKeyword("_ALPHATEST_ON");
							value.renderQueue = 2000;
						}
						if (((Object)val9).name.StartsWith("JQ_FaceCard_") || ((Object)val9).name.StartsWith("00000000A237") || ((Object)val9).name.StartsWith("00000000A239"))
						{
							val8.shadowCastingMode = (ShadowCastingMode)0;
							value.SetFloat("_AlphaCutoffEnable", 0f);
							value.DisableKeyword("_ALPHATEST_ON");
							value.SetFloat("_DoubleSidedEnable", 1f);
							value.EnableKeyword("_DOUBLESIDED_ON");
							value.SetFloat("_CullMode", 0f);
							value.SetFloat("_CullModeForward", 0f);
							value.renderQueue = 2000;
							value.SetOverrideTag("RenderType", "Opaque");
						}
						value.SetFloat("_Metallic", 0f);
						value.SetFloat("_Smoothness", 0.35f);
						dictionary.Add(val9, value);
					}
					sharedMaterials2[num] = value;
				}
				val8.sharedMaterials = sharedMaterials2;
			}
			Logger.LogInfo((object)("JQ_VISUAL_OK: previous height=" + y + "; target posed height=" + 3.0741525f + " game units; native shader=" + ((Object)val6.shader).name));
		}

		private void GroundVisual()
		{
			//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_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: 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_013b: 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_00ed: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)actor) || !Object.op_Implicit((Object)(object)groundedVisual) || Time.time < visualGroundAt)
			{
				return;
			}
			visualGroundAt = Time.time + 0.05f;
			if (rules != null && rules.Current == ChargeState.Phase.Falling)
			{
				return;
			}
			float num = float.NegativeInfinity;
			RaycastHit[] array = Physics.RaycastAll(actor.transform.position + Vector3.up * 0.08f, Vector3.down, 0.9f, StartOfRound.Instance.collidersAndRoomMask, (QueryTriggerInteraction)1);
			for (int i = 0; i < array.Length; i++)
			{
				RaycastHit val = array[i];
				if (IsEnvironmentFloor(((RaycastHit)(ref val)).collider) && ((RaycastHit)(ref val)).normal.y > 0.45f)
				{
					num = Mathf.Max(num, ((RaycastHit)(ref val)).point.y);
				}
			}
			if (!float.IsNegativeInfinity(num))
			{
				Vector3 localPosition = groundedVisual.localPosition;
				localPosition.y = visualBaseY + num - actor.transform.position.y;
				groundedVisual.localPosition = localPosition;
			}
		}

		private float MotionBodyTop()
		{
			return (rules != null && (rules.AttackCommitted || rules.Current == ChargeState.Phase.Turning)) ? 1.2f : 1.8f;
		}

		private void ReportSupportLoss()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			NavMeshHit val = default(NavMeshHit);
			bool flag = NavMesh.SamplePosition(actor.transform.position, ref val, 0.5f, -1);
			Logger.LogWarning((object)("JQ_SUPPORT_LOST: position=" + ((object)actor.transform.position/*cast due to .constrained prefix*/).ToString() + " nearbyNav=" + (flag ? ((object)((NavMeshHit)(ref val)).position/*cast due to .constrained prefix*/).ToString() : "none") + " distance=" + rules.DistanceTravelled));
			int num = 0;
			Collider[] array = Physics.OverlapCapsule(actor.transform.position + Vector3.up * 0.2f, actor.transform.position + Vector3.up * 1.9f, 0.65f, -1, (QueryTriggerInteraction)2);
			foreach (Collider val2 in array)
			{
				if (!((Component)val2).transform.IsChildOf(actor.transform) && !Object.op_Implicit((Object)(object)((Component)val2).GetComponentInParent<PlayerControllerB>()))
				{
					Logger.LogInfo((object)("JQ_EDGE_COLLIDER: name=" + ((Object)val2).name + " layer=" + ((Component)val2).gameObject.layer + " trigger=" + val2.isTrigger + " bounds=" + ((object)val2.bounds/*cast due to .constrained prefix*/).ToString()));
					if (++num >= 4)
					{
						break;
					}
				}
			}
		}

		private bool NearestWall(Vector3 origin, Vector3 dir, float distance, out RaycastHit wall)
		{
			//IL_0003: 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_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_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_003e: 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_022b: 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_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: 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_01ee: Unknown result type (might be due to invalid IL or missing references)
			wall = default(RaycastHit);
			bool result = false;
			float num = distance;
			RaycastHit[] array = Physics.CapsuleCastAll(origin + Vector3.up * 0.55f, origin + Vector3.up * MotionBodyTop(), 0.21f, dir, distance, -1, (QueryTriggerInteraction)2);
			for (int i = 0; i < array.Length; i++)
			{
				RaycastHit val = array[i];
				if (((Component)((RaycastHit)(ref val)).collider).transform.IsChildOf(actor.transform) || Object.op_Implicit((Object)(object)((Component)((RaycastHit)(ref val)).collider).GetComponentInParent<PlayerControllerB>()) || (((RaycastHit)(ref val)).normal.y > 0.45f && ((RaycastHit)(ref val)).point.y <= origin.y + 0.15f) || (((RaycastHit)(ref val)).normal.y < -0.35f && ((RaycastHit)(ref val)).point.y > origin.y + 1.2f))
				{
					continue;
				}
				DoorLock val2 = FindDoor(((RaycastHit)(ref val)).collider);
				if (Object.op_Implicit((Object)(object)val2))
				{
					if (((RaycastHit)(ref val)).collider.isTrigger && DoorIsOpen(val2) && !WaitingForDoor(((RaycastHit)(ref val)).collider))
					{
						continue;
					}
				}
				else if (((RaycastHit)(ref val)).collider.isTrigger || (StartOfRound.Instance.collidersAndRoomMask & (1 << ((Component)((RaycastHit)(ref val)).collider).gameObject.layer)) == 0)
				{
					continue;
				}
				if ((!(((RaycastHit)(ref val)).distance <= 0.001f) || !MovingOutOfContact(((RaycastHit)(ref val)).collider, origin, dir * Mathf.Min(distance, 0.1f))) && ((RaycastHit)(ref val)).distance <= num)
				{
					num = ((RaycastHit)(ref val)).distance;
					wall = val;
					result = true;
				}
			}
			if (rules != null && (rules.AttackCommitted || rules.Current == ChargeState.Phase.Turning) && UpperBarrier(origin, dir, distance, out var barrier) && ((RaycastHit)(ref barrier)).distance <= num)
			{
				wall = barrier;
				result = true;
			}
			return result;
		}

		private bool UpperBarrier(Vector3 origin, Vector3 direction, float distance, out RaycastHit barrier)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: 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_0049: 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_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_004a: 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_004f: 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_0058: 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_005d: 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_0071: 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_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_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			barrier = default(RaycastHit);
			bool result = false;
			float num = distance;
			Vector3 val = origin + Vector3.up * 1.65f;
			for (int i = 0; i < 2; i++)
			{
				Vector3 val2 = ((i == 0) ? val : (val + direction * (distance + 0.2f + 0.02f)));
				Vector3 val3 = ((i == 0) ? direction : (-direction));
				RaycastHit[] array = Physics.CapsuleCastAll(val2 - Vector3.up * 1.1f, val2, 0.1f, val3, (i == 0) ? distance : (distance + 0.2f + 0.02f), -1, (QueryTriggerInteraction)1);
				for (int j = 0; j < array.Length; j++)
				{
					RaycastHit val4 = array[j];
					if (!IsEnvironmentFloor(((RaycastHit)(ref val4)).collider) || ((RaycastHit)(ref val4)).distance <= 0.001f || Mathf.Abs(((RaycastHit)(ref val4)).normal.y) > 0.85f)
					{
						continue;
					}
					float num2 = ((i == 0) ? ((RaycastHit)(ref val4)).distance : (distance + 0.02f - ((RaycastHit)(ref val4)).distance));
					if (!(num2 < -0.01f) && !(num2 > num))
					{
						RaycastHit val5 = val4;
						((RaycastHit)(ref val5)).distance = Mathf.Max(0f, num2);
						if (i != 0)
						{
							((RaycastHit)(ref val5)).normal = -((RaycastHit)(ref val4)).normal;
						}
						barrier = val5;
						num = ((RaycastHit)(ref val5)).distance;
						result = true;
					}
				}
			}
			return result;
		}

		private float BodyPenetration(Collider collider, Vector3 origin)
		{
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_007a: 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)
			if (!Object.op_Implicit((Object)(object)recoveryBodyProbe))
			{
				GameObject val = new GameObject("JQ clearance probe");
				val.transform.SetParent(actor.transform, false);
				val.layer = 2;
				recoveryBodyProbe = val.AddComponent<CapsuleCollider>();
				recoveryBodyProbe.radius = 0.21f;
				recoveryBodyProbe.height = 1.67f;
				recoveryBodyProbe.center = Vector3.up * 1.175f;
				((Collider)recoveryBodyProbe).isTrigger = true;
				((Collider)recoveryBodyProbe).enabled = true;
				Physics.SyncTransforms();
			}
			float num = MotionBodyTop();
			recoveryBodyProbe.height = num - 0.55f + 0.42f;
			recoveryBodyProbe.center = Vector3.up * ((num + 0.55f) * 0.5f);
			Vector3 val2 = default(Vector3);
			float num2 = default(float);
			return Physics.ComputePenetration((Collider)(object)recoveryBodyProbe, origin, Quaternion.identity, collider, ((Component)collider).transform.position, ((Component)collider).transform.rotation, ref val2, ref num2) ? num2 : 0f;
		}

		private bool MovingOutOfContact(Collider collider, Vector3 origin, Vector3 movement)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: 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)
			float num = BodyPenetration(collider, origin);
			float num2 = BodyPenetration(collider, origin + movement);
			return num2 < 0.001f || num2 <= num + 0.0001f;
		}

		private void DamageSegment(Vector3 origin, Vector3 dir, float distance)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0018: 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_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			Collider[] array = Physics.OverlapCapsule(origin + Vector3.up * 0.5f, origin + Vector3.up * 2.5f, 0.35f, -1, (QueryTriggerInteraction)2);
			foreach (Collider collider in array)
			{
				TryHit(collider);
			}
			if (!(distance <= 0f))
			{
				RaycastHit[] array2 = Physics.CapsuleCastAll(origin + Vector3.up * 0.5f, origin + Vector3.up * 2.5f, 0.35f, dir, distance, -1, (QueryTriggerInteraction)2);
				for (int j = 0; j < array2.Length; j++)
				{
					RaycastHit val = array2[j];
					TryHit(((RaycastHit)(ref val)).collider);
				}
			}
		}

		private bool IsEnvironmentFloor(Collider c)
		{
			return !((Component)c).transform.IsChildOf(actor.transform) && !Object.op_Implicit((Object)(object)((Component)c).GetComponentInParent<PlayerControllerB>()) && !Object.op_Implicit((Object)(object)((Component)c).GetComponentInParent<EnemyAI>()) && !Object.op_Implicit((Object)(object)((Component)c).GetComponentInParent<GrabbableObject>()) && (!Object.op_Implicit((Object)(object)FindDoor(c)) || DoorIsOpen(FindDoor(c))) && (!Object.op_Implicit((Object)(object)c.attachedRigidbody) || c.attachedRigidbody.isKinematic);
		}

		private bool PhysicalFloor(Vector3 point, out Vector3 grounded)
		{
			//IL_0002: 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 ChargeFloorRay(point, out grounded) || FootprintFloor(point, (rules != null && rules.AttackCommitted) ? 1.3f : 0.65f, out grounded);
		}

		private bool ChargeFloor(Vector3 point, out Vector3 grounded)
		{
			//IL_0002: 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_002d: 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_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: 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_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00d0: 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_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_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: 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_0182: 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_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			if (PhysicalFloor(point, out grounded))
			{
				return true;
			}
			if (NavigationFloor(point, out grounded))
			{
				return true;
			}
			NavMeshHit val = default(NavMeshHit);
			if (!NavMesh.SamplePosition(point, ref val, 0.35f, -1) || Mathf.Abs(((NavMeshHit)(ref val)).position.y - point.y) > 0.3f)
			{
				return false;
			}
			Vector3 val2 = ((NavMeshHit)(ref val)).position - point;
			val2.y = 0f;
			if (((Vector3)(ref val2)).sqrMagnitude > 0.04f)
			{
				return false;
			}
			NavMeshHit val3 = default(NavMeshHit);
			if (Object.op_Implicit((Object)(object)agent) && ((Behaviour)agent).enabled && agent.isOnNavMesh && NavMesh.Raycast(agent.nextPosition, ((NavMeshHit)(ref val)).position, ref val3, agent.areaMask))
			{
				return false;
			}
			float num = 0.14625f;
			Vector3[] array = (Vector3[])(object)new Vector3[4]
			{
				Vector3.forward * num,
				Vector3.back * num,
				Vector3.left * num,
				Vector3.right * num
			};
			foreach (Vector3 val4 in array)
			{
				if (ChargeFloorRay(point + val4, out var grounded2) && !(Mathf.Abs(grounded2.y - ((NavMeshHit)(ref val)).position.y) > 0.3f))
				{
					grounded = new Vector3(point.x, grounded2.y, point.z);
					return true;
				}
			}
			return false;
		}

		private bool ChargeFloorRay(Vector3 point, out Vector3 grounded)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: 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_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: 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_0091: 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_00cc: 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_00b1: 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_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			grounded = point;
			float num = float.PositiveInfinity;
			float num2 = ((rules != null && rules.AttackCommitted) ? 1.3f : 0.65f);
			RaycastHit[] array = Physics.RaycastAll(point + Vector3.up * 0.7f, Vector3.down, 0.75f + num2, -1, (QueryTriggerInteraction)1);
			for (int i = 0; i < array.Length; i++)
			{
				RaycastHit val = array[i];
				if (IsEnvironmentFloor(((RaycastHit)(ref val)).collider) && !(((RaycastHit)(ref val)).normal.y < 0.45f) && !(((RaycastHit)(ref val)).point.y - point.y > 0.65f) && !(point.y - ((RaycastHit)(ref val)).point.y > num2))
				{
					float num3 = 0f - ((RaycastHit)(ref val)).point.y;
					if (num3 < num)
					{
						num = num3;
						grounded = new Vector3(point.x, ((RaycastHit)(ref val)).point.y, point.z);
					}
				}
			}
			bool flag = !float.IsPositiveInfinity(num);
			if (flag)
			{
				RememberFloorOffset(grounded);
			}
			return flag;
		}

		private void RememberFloorOffset(Vector3 floor)
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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_00c8: 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)
			if (!Object.op_Implicit((Object)(object)agent) || !((Behaviour)agent).enabled || !agent.isOnNavMesh || Time.time < floorCalibrationAt)
			{
				return;
			}
			floorCalibrationAt = Time.time + 0.2f;
			NavMeshHit val = default(NavMeshHit);
			if (NavMesh.SamplePosition(floor, ref val, 0.4f, agent.areaMask))
			{
				Vector3 val2 = ((NavMeshHit)(ref val)).position - floor;
				val2.y = 0f;
				if (!(((Vector3)(ref val2)).sqrMagnitude > 0.0004f) && !(Mathf.Abs(((NavMeshHit)(ref val)).position.y - floor.y) > 0.35f))
				{
					floorNavOffset = ((NavMeshHit)(ref val)).position.y - floor.y;
					hasFloorNavOffset = true;
				}
			}
		}

		private bool NavigationFloor(Vector3 point, out Vector3 grounded)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: 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_005b: 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_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_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			grounded = point;
			if (!Object.op_Implicit((Object)(object)agent) || !((Behaviour)agent).enabled || !agent.isOnNavMesh)
			{
				return false;
			}
			NavMeshHit val = default(NavMeshHit);
			if (!NavMesh.SamplePosition(point, ref val, 0.4f, agent.areaMask) || Mathf.Abs(((NavMeshHit)(ref val)).position.y - point.y) > 0.35f)
			{
				return false;
			}
			Vector3 val2 = ((NavMeshHit)(ref val)).position - point;
			val2.y = 0f;
			if (((Vector3)(ref val2)).sqrMagnitude > 0.032399997f)
			{
				return false;
			}
			NavMeshHit val3 = default(NavMeshHit);
			if (NavMesh.Raycast(agent.nextPosition, ((NavMeshHit)(ref val)).position, ref val3, agent.areaMask))
			{
				return false;
			}
			grounded.y = ((NavMeshHit)(ref val)).position.y - (hasFloorNavOffset ? floorNavOffset : 0f);
			return true;
		}

		private bool FootprintFloor(Vector3 point, float drop, out Vector3 grounded)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: 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)
			//IL_0029: 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_004b: 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_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: 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_008a: 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_00c3: 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_00d7: 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_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			grounded = point;
			float num = float.NegativeInfinity;
			RaycastHit[] array = Physics.SphereCastAll(point + Vector3.up * 0.90999997f, 0.21f, Vector3.down, 0.75f + drop, -1, (QueryTriggerInteraction)1);
			for (int i = 0; i < array.Length; i++)
			{
				RaycastHit val = array[i];
				if (IsEnvironmentFloor(((RaycastHit)(ref val)).collider) && !(((RaycastHit)(ref val)).normal.y < 0.45f) && !(((RaycastHit)(ref val)).point.y - point.y > 0.65f) && !(point.y - ((RaycastHit)(ref val)).point.y > drop) && ((RaycastHit)(ref val)).point.y > num)
				{
					num = ((RaycastHit)(ref val)).point.y;
					grounded = new Vector3(point.x, ((RaycastHit)(ref val)).point.y, point.z);
				}
			}
			bool flag = !float.IsNegativeInfinity(num);
			if (flag)
			{
				RememberFloorOffset(grounded);
			}
			return flag;
		}

		private bool LandDuringFall(float distance)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: 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_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: 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_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: 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_011a: Unknown result type (might be due to invalid IL or missing references)
			RaycastHit val = default(RaycastHit);
			bool flag = false;
			float num = distance + 0.7f;
			RaycastHit[] array = Physics.RaycastAll(actor.transform.position + Vector3.up * 0.65f, Vector3.down, distance + 0.7f, -1, (QueryTriggerInteraction)1);
			for (int i = 0; i < array.Length; i++)
			{
				RaycastHit val2 = array[i];
				if (IsEnvironmentFloor(((RaycastHit)(ref val2)).collider) && !(((RaycastHit)(ref val2)).normal.y < 0.45f) && !(((RaycastHit)(ref val2)).distance >= num))
				{
					num = ((RaycastHit)(ref val2)).distance;
					val = val2;
					flag = true;
				}
			}
			Vector3 grounded;
			bool flag2 = FootprintFloor(actor.transform.position, distance + 0.05f, out grounded);
			if (!flag && !flag2)
			{
				return false;
			}
			Vector3 val3 = (flag ? ((RaycastHit)(ref val)).point : grounded);
			if (flag2 && grounded.y > val3.y)
			{
				val3 = grounded;
			}
			actor.transform.position = new Vector3(actor.transform.position.x, val3.y, actor.transform.position.z);
			fallSpeed = 0f;
			fallStarted = 0f;
			rules.Land();
			BeginWallRecovery();
			Logger.LogInfo((object)("JQ_LANDED: " + (flag ? ((Object)((RaycastHit)(ref val)).collider).name : "physical footprint support")));
			return true;
		}

		private float SlideStep(Vector3 desired, out bool stopped, out bool supported)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: 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_00fe: 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_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: 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)
			float num = 0f;
			stopped = false;
			supported = true;
			bool allowDrop = rules.Current == ChargeState.Phase.Charging;
			int num2 = Mathf.Max(1, Mathf.CeilToInt(((Vector3)(ref desired)).magnitude / 0.1f));
			Vector3 val = desired / (float)num2;
			for (int num3 = 0; num3 < num2; num3++)
			{
				Vector3 position = actor.transform.position;
				Vector3 grounded;
				bool flag = ChargeFloor(actor.transform.position + val, out grounded);
				float y = actor.transform.position.y;
				if (flag && grounded.y > y)
				{
					if (!CanRaiseBody(actor.transform.position, grounded.y - y))
					{
						stopped = true;
						return num;
					}
					actor.transform.position = new Vector3(actor.transform.position.x, grounded.y, actor.transform.position.z);
				}
				bool stopped2;
				bool contact;
				bool supported2;
				float num4 = SlideSubstep(val, out stopped2, out contact, out supported2, allowDrop);
				num += num4;
				if (!supported2)
				{
					supported = false;
					return num;
				}
				if (ChargeFloor(actor.transform.position, out var grounded2))
				{
					actor.transform.position = grounded2;
				}
				else
				{
					if (!ChargeFloor(new Vector3(actor.transform.position.x, position.y, actor.transform.position.z), out grounded2))
					{
						actor.transform.position = position;
						stopped = true;
						return num;
					}
					actor.transform.position = grounded2;
				}
				if (rules.Current == ChargeState.Phase.Charging)
				{
					if (chargeTrail.Count != 0)
					{
						Vector3 val2 = actor.transform.position - chargeTrail[chargeTrail.Count - 1];
						if (!(((Vector3)(ref val2)).sqrMagnitude > 0.04f))
						{
							goto IL_027d;
						}
					}
					chargeTrail.Add(actor.transform.position);
				}
				goto IL_027d;
				IL_027d:
				RememberWalkable();
				if (stopped2)
				{
					stopped = true;
					return num;
				}
			}
			return num;
		}

		private float SlideSubstep(Vector3 desired, out bool stopped, out bool contact, out bool supported, bool allowDrop = false)
		{
			//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_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: 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_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: 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_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: 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_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			contact = false;
			supported = true;
			float num = 0f;
			stopped = false;
			Vector3 val = desired;
			for (int i = 0; i < 3; i++)
			{
				float magnitude = ((Vector3)(ref val)).magnitude;
				if (magnitude < 0.001f)
				{
					return num;
				}
				Vector3 val2 = val / magnitude;
				if (!NearestWall(actor.transform.position, val2, magnitude + 0.01f, out var wall))
				{
					if (!ChargeFloor(actor.transform.position + val, out var _))
					{
						if (!allowDrop)
						{
							stopped = true;
							return num;
						}
						supported = false;
					}
					DamageSegment(actor.transform.position, val2, magnitude);
					Transform transform = actor.transform;
					transform.position += val;
					return num + magnitude;
				}
				if (TryStairStep(val, wall))
				{
					if (!ChargeFloor(actor.transform.position, out var _))
					{
						supported = false;
					}
					return num + magnitude;
				}
				contact = true;
				lastChargeWall = ((RaycastHit)(ref wall)).collider;
				if (WaitingForDoor(((RaycastHit)(ref wall)).collider) || SlamDoor(((RaycastHit)(ref wall)).collider))
				{
					stopped = false;
					return num;
				}
				float num2 = Mathf.Clamp(((RaycastHit)(ref wall)).distance - 0.01f, 0f, magnitude);
				DamageSegment(actor.transform.position, val2, num2);
				Transform transform2 = actor.transform;
				transform2.position += val2 * num2;
				num += num2;
				lastWallNormal = ((RaycastHit)(ref wall)).normal;
				WallSlideMath.Project(val.x - val2.x * num2, val.z - val2.z * num2, ((RaycastHit)(ref wall)).normal.x, ((RaycastHit)(ref wall)).normal.z, out var sx, out var sz);
				((Vector3)(ref val))..ctor(sx, 0f, sz);
				if (((Vector3)(ref val)).magnitude < 0.01f)
				{
					stopped = true;
					return num;
				}
			}
			stopped = true;
			return num;
		}

		private bool CanRaiseBody(Vector3 origin, float rise)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: 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_0095: 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)
			RaycastHit[] array = Physics.CapsuleCastAll(origin + Vector3.up * 0.55f, origin + Vector3.up * MotionBodyTop(), 0.21f, Vector3.up, rise + 0.02f, StartOfRound.Instance.collidersAndRoomMask, (QueryTriggerInteraction)1);
			for (int i = 0; i < array.Length; i++)
			{
				RaycastHit val = array[i];
				if (IsEnvironmentFloor(((RaycastHit)(ref val)).collider) && ((RaycastHit)(ref val)).normal.y < -0.1f && (!(((RaycastHit)(ref val)).distance <= 0.001f) || !MovingOutOfContact(((RaycastHit)(ref val)).collider, origin, Vector3.up * (rise + 0.02f))))
				{
					lastChargeWall = ((RaycastHit)(ref val)).collider;
					return false;
				}
			}
			return true;
		}

		private bool TryStairStep(Vector3 movement, RaycastHit obstacle, bool applyMovement = true)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: 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_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: 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_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: 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_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_031e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0325: Unknown result type (might be due to invalid IL or missing references)
			//IL_034a: Unknown result type (might be due to invalid IL or missing references)
			//IL_034e: Unknown result type (might be due to invalid IL or missing references)
			//IL_036b: Unknown result type (might be due to invalid IL or missing references)
			//IL_036d: Unknown result type (might be due to invalid IL or missing references)
			//IL_036e: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = actor.transform.position;
			float num = ((rules.Current == ChargeState.Phase.Charging || rules.Current == ChargeState.Phase.Turning || rules.Current == ChargeState.Phase.Windup) ? 1.25f : 0.65f);
			if (!IsEnvironmentFloor(((RaycastHit)(ref obstacle)).collider) || (((RaycastHit)(ref obstacle)).distance > 0.001f && ((RaycastHit)(ref obstacle)).point.y > position.y + num))
			{
				return false;
			}
			float num2 = 0f;
			float num3 = ((Vector3)(ref movement)).magnitude + 0.21f + 0.04f;
			for (float num4 = 0.04f; num4 <= num3 + 0.039f; num4 += 0.04f)
			{
				Vector3 val = position + ((Vector3)(ref movement)).normalized * Mathf.Min(num4, num3);
				Vector3 val2 = Vector3.Cross(Vector3.up, ((Vector3)(ref movement)).normalized) * 0.21f;
				for (int i = -1; i <= 1; i++)
				{
					RaycastHit[] array = Physics.RaycastAll(val + val2 * (float)i + Vector3.up * (num + 0.08f), Vector3.down, num + 0.1f, -1, (QueryTriggerInteraction)1);
					for (int j = 0; j < array.Length; j++)
					{
						RaycastHit val3 = array[j];
						if (IsEnvironmentFloor(((RaycastHit)(ref val3)).collider) && ((RaycastHit)(ref val3)).normal.y >= 0.45f && ((RaycastHit)(ref val3)).point.y > position.y && ((RaycastHit)(ref val3)).point.y <= position.y + num)
						{
							num2 = Mathf.Max(num2, ((RaycastHit)(ref val3)).point.y - position.y);
						}
					}
				}
			}
			if (num2 < 0.05f || num2 > num)
			{
				return false;
			}
			Vector3 point = position + Vector3.up * num2 + ((Vector3)(ref movement)).normalized * (((Vector3)(ref movement)).magnitude + 0.42f + 0.1f);
			if (!ChargeFloor(point, out var _))
			{
				return false;
			}
			if (!CanRaiseBody(position, num2))
			{
				return false;
			}
			Vector3 val4 = position + Vector3.up * (num2 + 0.01f);
			if (NearestWall(val4, ((Vector3)(ref movement)).normalized, ((Vector3)(ref movement)).magnitude + 0.01f, out var _))
			{
				return false;
			}
			Vector3 grounded2;
			bool flag = ChargeFloor(val4 + movement, out grounded2) || ChargeFloor(position + movement, out grounded2);
			if (!flag && rules.Current != ChargeState.Phase.Charging)
			{
				return false;
			}
			if (flag && grounded2.y < position.y - 0.1f)
			{
				return false;
			}
			if (applyMovement)
			{
				DamageSegment(val4, ((Vector3)(ref movement)).normalized, ((Vector3)(ref movement)).magnitude);
				actor.transform.position = val4 + movement;
			}
			return true;
		}

		private void BeginWallRecovery()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			StartRecoveryWatch();
			recoveryStartedAt = Time.time;
			recoveryAttempts = 0;
			rules.BeginRepositioning();
			recoveryStart = actor.transform.position;
			recoveryPosition = recoveryStart;
			if (!RestoreWalking())
			{
				recoveryCheckAt = Time.time + 1f;
				return;
			}
			agent.updateRotation = false;
			agent.isStopped = false;
			recoveryCheckAt = Time.time + 1f;
			ChooseRecoveryPath();
			Logger.LogInfo((object)"JQ_WALL_RECOVERY: repositioning before next windup");
		}

		private void RememberWalkable()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//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_00fb: Unknown result type (might be due to invalid IL or missing references)
			NavMeshHit val = default(NavMeshHit);
			if (!Object.op_Implicit((Object)(object)actor) || !NavMesh.SamplePosition(actor.transform.position, ref val, 0.3f, -1) || !(Mathf.Abs(((NavMeshHit)(ref val)).position.y - actor.transform.position.y) < 0.3f))
			{
				return;
			}
			Vector3 val2 = ((NavMeshHit)(ref val)).position - actor.transform.position;
			val2.y = 0f;
			if (((Vector3)(ref val2)).sqrMagnitude < 0.04f)
			{
				lastWalkablePosition = ((NavMeshHit)(ref val)).position;
				hasWalkablePosition = true;
				if (((Behaviour)agent).enabled && agent.isOnNavMesh && !agent.updatePosition)
				{
					agent.nextPosition = ((NavMeshHit)(ref val)).position;
				}
			}
		}

		private void RetreatToWalkable()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00e5: 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_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: 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_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: 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_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: 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_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			while (chargeTrail.Count > 0)
			{
				Vector3 val = chargeTrail[chargeTrail.Count - 1] - actor.transform.position;
				float num = Mathf.Abs(val.y);
				val.y = 0f;
				if (((Vector3)(ref val)).sqrMagnitude >= 0.01f || num > 0.7f)
				{
					break;
				}
				chargeTrail.RemoveAt(chargeTrail.Count - 1);
			}
			if (chargeTrail.Count > 0)
			{
				Vector3 val2 = chargeTrail[chargeTrail.Count - 1] - actor.transform.position;
				val2.y = 0f;
				SlideStep(Vector3.ClampMagnitude(val2, roam * Time.deltaTime), out var _, out var _);
			}
			else
			{
				if (!hasWalkablePosition)
				{
					return;
				}
				Vector3 val3 = lastWalkablePosition - actor.transform.position;
				val3.y = 0f;
				if (((Vector3)(ref val3)).magnitude > 4f)
				{
					return;
				}
				Vector3 point = actor.transform.position + Vector3.ClampMagnitude(val3, roam * Time.deltaTime);
				if (ChargeFloor(point, out var grounded))
				{
					float y = actor.transform.position.y;
					if (grounded.y > y)
					{
						actor.transform.position = new Vector3(actor.transform.position.x, grounded.y, actor.transform.position.z);
					}
					SlideSubstep(Vector3.ClampMagnitude(val3, roam * Time.deltaTime), out var _, out var _, out var _);
					if (ChargeFloor(actor.transform.position, out grounded))
					{
						actor.transform.position = grounded;
					}
				}
			}
		}

		private bool RestoreWalking()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: 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_0040: 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_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: 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_00cc: 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_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: 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_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: 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)
			Vector3 position = actor.transform.position;
			NavMeshHit val2 = default(NavMeshHit);
			for (int i = 0; i < 33; i++)
			{
				float num = (float)(i - 1) * (float)Math.PI / 4f;
				Vector3 val = ((i == 0) ? position : (position + new Vector3(Mathf.Cos(num), 0f, Mathf.Sin(num)) * (0.2f + 0.1f * (float)((i - 1) / 8))));
				if (!NavMesh.SamplePosition(val, ref val2, 0.45f, -1) || Mathf.Abs(((NavMeshHit)(ref val2)).position.y - position.y) > 0.55f)
				{
					continue;
				}
				Vector3 movement = ((NavMeshHit)(ref val2)).position - position;
				movement.y = 0f;
				if ((!(((Vector3)(ref movement)).sqrMagnitude > 0.0001f) || !NearestWall(position, ((Vector3)(ref movement)).normalized, ((Vector3)(ref movement)).magnitude, out var wall) || TryStairStep(movement, wall, applyMovement: false)) && ChargeFloor(((NavMeshHit)(ref val2)).position, out var grounded) && !(((NavMeshHit)(ref val2)).position.y - grounded.y > 0.55f) && !(grounded.y - ((NavMeshHit)(ref val2)).position.y > 0.3f))
				{
					((Behaviour)agent).enabled = true;
					if (agent.Warp(((NavMeshHit)(ref val2)).position))
					{
						actor.transform.position = ((NavMeshHit)(ref val2)).position;
						agent.updatePosition = true;
						agent.updateRotation = false;
						return true;
					}
				}
			}
			return false;
		}

		private bool ChooseRecoveryPath()
		{
			//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)
			//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_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: 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_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00c1: 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_00d3: 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_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might