Decompiled source of CaveDweller v1.0.4

Logan.CaveDweller.dll

Decompiled a month ago
#define DEBUG
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using CaveDweller.Configuration;
using GameNetcodeStuff;
using LethalLib.Modules;
using Logan.CaveDweller.NetcodePatcher;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("Logan.CaveDweller")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.4.0")]
[assembly: AssemblyInformationalVersion("1.0.4+0864a05544691c96bb0f101813317f1ce77b7629")]
[assembly: AssemblyProduct("CaveDweller")]
[assembly: AssemblyTitle("Logan.CaveDweller")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.4.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 CaveDweller
{
	internal class CaveDwellerAI : EnemyAI
	{
		private enum State
		{
			SearchingForPlayer,
			ChasePlayer,
			StareAtPlayer,
			AttackInProgress,
			Taunting,
			Stalking
		}

		private enum DwellerBehavior
		{
			Default,
			Stalk,
			Aggressive,
			VeryAggressive
		}

		public AISearchRoutine searchForPlayers;

		private bool crawling = false;

		private bool taunting = false;

		private bool climbingOnWalls = false;

		private bool climbingBusy = false;

		private Collider[] nearPlayerColliders;

		public Transform[] bodyPoints;

		public List<Transform> ignoredNodes = new List<Transform>();

		private Vector3 lastPositionOfSeenPlayer;

		private bool wasBodyVisible;

		private RaycastHit rayHit;

		private RaycastHit rayHitB;

		private RaycastHit rayHitC;

		private Ray ray;

		public Vector3 wallPosition;

		public Vector3 wallNormal;

		public Vector3 floorPosition;

		private Vector3 positionAtLeavingLOS;

		public Vector3 floorPositionFromMesh;

		public Vector3 navigateToPositionTarget;

		private Quaternion meshContainerTargetRotation;

		public Vector3 meshContainerTarget;

		public Vector3 meshContainerPosition;

		public Vector3 meshContainerServerPosition;

		public Vector3 meshContainerServerRotation;

		private Vector3 refVel;

		public Vector3 favoriteSpotPos;

		public float sneakSpeed = 4f;

		private bool gettingFarthestNodeFromPlayerAsync;

		private Transform farthestNodeFromTargetPlayer;

		[Space(5f)]
		public int maxAsync = 50;

		public bool lookingForWallPosition;

		private bool gotWallPositionInLOS;

		private float tryWallPositionInterval;

		private bool reachedWallPosition;

		private bool onWall;

		public bool navigateMeshTowardsPosition;

		private bool overrideLookRotation;

		private bool isAngry;

		public NavMeshHit navHit;

		public Transform meshContainer;

		public AudioClip[] randomScreamClips;

		public AudioSource spawnSFX;

		public AudioSource deathTauntAudio;

		public AudioSource deathTauntAudioPre;

		public Transform turnCompass = null;

		public Transform attackArea = null;

		private float timeSinceHittingLocalPlayer;

		private float timeSinceNewRandPos;

		private Vector3 positionRandomness;

		private Vector3 StalkPos;

		private Random enemyRandom = null;

		private Random behaviorRandom = null;

		private bool isDeadAnimationDone;

		private DwellerBehavior dwellerBehavior = DwellerBehavior.Default;

		[Conditional("DEBUG")]
		private void LogIfDebugBuild(string text)
		{
			Plugin.Logger.LogInfo((object)text);
		}

		public override void Start()
		{
			//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_008a: 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_00a3: 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_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: 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_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Start();
			nearPlayerColliders = (Collider[])(object)new Collider[10];
			timeSinceHittingLocalPlayer = 0f;
			timeSinceNewRandPos = 0f;
			positionRandomness = new Vector3(0f, 0f, 0f);
			enemyRandom = new Random(StartOfRound.Instance.randomMapSeed + base.thisEnemyIndex);
			behaviorRandom = new Random(StartOfRound.Instance.randomMapSeed + base.thisEnemyIndex);
			isDeadAnimationDone = false;
			rayHitB = default(RaycastHit);
			rayHitC = default(RaycastHit);
			meshContainerPosition = ((Component)this).transform.position;
			meshContainerTarget = ((Component)this).transform.position;
			meshContainerTargetRotation = Quaternion.identity;
			favoriteSpotPos = ((Component)this).transform.position;
			base.agent.acceleration = 100f;
			dwellerBehavior = (DwellerBehavior)behaviorRandom.Next(0, Enum.GetNames(typeof(DwellerBehavior)).Length);
			LogIfDebugBuild($"Cave Dweller Spawned : Dweller Behavior({dwellerBehavior})");
			if (dwellerBehavior == DwellerBehavior.Default || dwellerBehavior == DwellerBehavior.Aggressive)
			{
				base.creatureAnimator.SetBool("walking", true);
				SetAnimationClientRpc("walking", animationState: true);
			}
			else if (dwellerBehavior == DwellerBehavior.VeryAggressive)
			{
				base.creatureAnimator.SetBool("running", true);
				SetAnimationClientRpc("running", animationState: true);
			}
			else if (dwellerBehavior == DwellerBehavior.Stalk)
			{
				base.creatureAnimator.SetBool("crawl", true);
				SetAnimationClientRpc("crawl", animationState: true);
			}
			if (dwellerBehavior == DwellerBehavior.Stalk)
			{
				Object.Destroy((Object)(object)((Component)meshContainer).GetComponent<PlayAudioAnimationEvent>());
				base.currentBehaviourStateIndex = 5;
				base.creatureVoice.Stop();
			}
			else
			{
				base.currentBehaviourStateIndex = 0;
			}
			if (Object.op_Implicit((Object)(object)spawnSFX) && dwellerBehavior != DwellerBehavior.Stalk)
			{
				spawnSFX.Play();
			}
			((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
		}

		public override void Update()
		{
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Update();
			if (base.isEnemyDead)
			{
				if (!isDeadAnimationDone)
				{
					isDeadAnimationDone = true;
					base.creatureVoice.Stop();
					base.creatureVoice.PlayOneShot(base.dieSFX);
				}
				return;
			}
			timeSinceHittingLocalPlayer += Time.deltaTime;
			timeSinceNewRandPos += Time.deltaTime;
			if (GameNetworkManager.Instance.localPlayerController.HasLineOfSightToPosition(((Component)this).transform.position, 60f, 30, 2.5f))
			{
				GameNetworkManager.Instance.localPlayerController.JumpToFearLevel(0.7f, true);
			}
			int currentBehaviourStateIndex = base.currentBehaviourStateIndex;
			int num = currentBehaviourStateIndex;
			if (num == 5)
			{
				base.agent.speed = 6f;
			}
			if (((NetworkBehaviour)this).IsOwner && gettingFarthestNodeFromPlayerAsync && (Object)(object)base.targetPlayer != (Object)null)
			{
				float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position);
				if (num2 < 16f)
				{
					maxAsync = 100;
				}
				else if (num2 < 40f)
				{
					maxAsync = 25;
				}
				else
				{
					maxAsync = 4;
				}
				Transform val = ((EnemyAI)this).ChooseFarthestNodeFromPosition(((Component)base.targetPlayer).transform.position, true, 0, true, maxAsync, true);
				if (!base.gotFarthestNodeAsync)
				{
					return;
				}
				farthestNodeFromTargetPlayer = val;
				gettingFarthestNodeFromPlayerAsync = false;
			}
			if (((NetworkBehaviour)this).IsOwner)
			{
				SyncMeshContainerPositionToClients();
				CalculateMeshMovement();
			}
			int currentBehaviourStateIndex2 = base.currentBehaviourStateIndex;
			if (base.stunNormalizedTimer > 0f)
			{
				base.agent.speed = 0f;
			}
		}

		public override void DoAIInterval()
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0437: Unknown result type (might be due to invalid IL or missing references)
			//IL_044e: 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_046d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0472: Unknown result type (might be due to invalid IL or missing references)
			//IL_0482: Unknown result type (might be due to invalid IL or missing references)
			//IL_0494: Unknown result type (might be due to invalid IL or missing references)
			//IL_0499: Unknown result type (might be due to invalid IL or missing references)
			//IL_053c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_0324: Unknown result type (might be due to invalid IL or missing references)
			//IL_0334: Unknown result type (might be due to invalid IL or missing references)
			//IL_0351: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_039e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).DoAIInterval();
			if (base.isEnemyDead || StartOfRound.Instance.allPlayersDead)
			{
				return;
			}
			if (lookingForWallPosition && Object.op_Implicit((Object)(object)base.targetPlayer) && climbingOnWalls)
			{
				gotWallPositionInLOS = GetWallPosition(((Component)this).transform.position);
			}
			if (navigateMeshTowardsPosition)
			{
				CalculatePathToPosition();
			}
			switch (base.currentBehaviourStateIndex)
			{
			case 0:
			{
				NavMeshAgent agent = base.agent;
				DwellerBehavior dwellerBehavior = this.dwellerBehavior;
				if (1 == 0)
				{
				}
				float speed = dwellerBehavior switch
				{
					DwellerBehavior.Default => 3f, 
					DwellerBehavior.Aggressive => 6f, 
					DwellerBehavior.VeryAggressive => 10f, 
					_ => base.agent.speed, 
				};
				if (1 == 0)
				{
				}
				agent.speed = speed;
				if (FoundClosestPlayerInRange(25f, 3f))
				{
					((EnemyAI)this).StopSearch(base.currentSearch, true);
					if (this.dwellerBehavior == DwellerBehavior.Aggressive || this.dwellerBehavior == DwellerBehavior.VeryAggressive)
					{
						((MonoBehaviour)this).StartCoroutine(StareAtPlayerThenChase());
					}
					else if (this.dwellerBehavior == DwellerBehavior.Default)
					{
						((MonoBehaviour)this).StartCoroutine(StareAtPlayerThenChase());
					}
				}
				break;
			}
			case 1:
			{
				NavMeshAgent agent2 = base.agent;
				DwellerBehavior dwellerBehavior2 = this.dwellerBehavior;
				if (1 == 0)
				{
				}
				float speed = dwellerBehavior2 switch
				{
					DwellerBehavior.Default => 9.5f, 
					DwellerBehavior.Aggressive => 11f, 
					DwellerBehavior.VeryAggressive => 15f, 
					DwellerBehavior.Stalk => 17f, 
					_ => base.agent.speed, 
				};
				if (1 == 0)
				{
				}
				agent2.speed = speed;
				if (Object.op_Implicit((Object)(object)base.targetPlayer) && !climbingBusy)
				{
					if (Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position) > 3.5f)
					{
						climbingOnWalls = true;
						lookingForWallPosition = true;
						reachedWallPosition = false;
					}
					else
					{
						if (onWall)
						{
							climbingBusy = true;
						}
						climbingOnWalls = false;
						lookingForWallPosition = false;
						reachedWallPosition = false;
						navigateMeshTowardsPosition = false;
					}
					if (lookingForWallPosition && reachedWallPosition)
					{
						Vector3 position = ((Component)base.targetPlayer).transform.position;
						float num = Vector3.Dot(position - meshContainer.position, wallNormal);
						Vector3 val = position - num * wallNormal;
						meshContainerTargetRotation = Quaternion.LookRotation(val, wallNormal);
						overrideLookRotation = true;
					}
				}
				if (!TargetClosestPlayerInAnyCase() || (this.dwellerBehavior == DwellerBehavior.Stalk && !TargetClosestPlayerInAnyCase()) || (Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position) > 20f && !((EnemyAI)this).CheckLineOfSightForPosition(((Component)base.targetPlayer).transform.position, 45f, 60, -1f, (Transform)null)))
				{
					StopChasePlayer();
					if (this.dwellerBehavior == DwellerBehavior.Stalk)
					{
						((EnemyAI)this).SwitchToBehaviourClientRpc(5);
						((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
					}
					else
					{
						((EnemyAI)this).SwitchToBehaviourClientRpc(0);
						((EnemyAI)this).StartSearch(lastPositionOfSeenPlayer, (AISearchRoutine)null);
					}
				}
				else if (!taunting)
				{
					lastPositionOfSeenPlayer = ((Component)base.targetPlayer).transform.position;
					((EnemyAI)this).SetDestinationToPosition(((Component)base.targetPlayer).transform.position, false);
				}
				break;
			}
			case 2:
				base.agent.speed = 0f;
				turnCompass.LookAt(((Component)base.targetPlayer.gameplayCamera).transform.position);
				((Component)this).transform.rotation = Quaternion.Lerp(((Component)this).transform.rotation, Quaternion.Euler(new Vector3(0f, turnCompass.eulerAngles.y, 0f)), 15f * Time.deltaTime);
				meshContainerTargetRotation = ((Component)this).transform.rotation;
				break;
			case 3:
				break;
			case 4:
				base.agent.speed = 0f;
				break;
			case 5:
				if (base.currentSearch.inProgress)
				{
					((EnemyAI)this).StopSearch(base.currentSearch, true);
				}
				base.agent.speed = 3.5f;
				SetAnimationClientRpc("crawl", animationState: true);
				base.creatureAnimator.SetBool("crawl", true);
				if (TargetClosestPlayerInAnyCase())
				{
					ChooseClosestNodeToPlayer2();
				}
				if (!isAngry && GameNetworkManager.Instance.localPlayerController.HasLineOfSightToPosition(((Component)this).transform.position, 60f, 10, 1.5f))
				{
					isAngry = true;
					((MonoBehaviour)this).StartCoroutine(StareAtPlayerThenChase(WaitBeforeScream: true));
					isAngry = false;
				}
				break;
			default:
				LogIfDebugBuild("This Behavior State doesn't exist!");
				break;
			}
		}

		public void LateUpdate()
		{
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: 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_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0037: 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_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_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			if (!base.isEnemyDead && !StartOfRound.Instance.allPlayersDead)
			{
				if (((NetworkBehaviour)this).IsOwner)
				{
					Vector3 val = meshContainerPosition;
					meshContainerPosition = Vector3.MoveTowards(meshContainerPosition, meshContainerTarget, base.agent.speed * Time.deltaTime);
					refVel = val - meshContainerPosition;
					meshContainer.position = meshContainerPosition;
					meshContainer.rotation = Quaternion.Lerp(meshContainer.rotation, meshContainerTargetRotation, 8f * Time.deltaTime);
				}
				else
				{
					meshContainer.position = Vector3.SmoothDamp(meshContainerPosition, meshContainerServerPosition, ref refVel, 4f * Time.deltaTime);
					meshContainerPosition = meshContainer.position;
					meshContainer.rotation = Quaternion.Lerp(meshContainer.rotation, Quaternion.Euler(meshContainerServerRotation), 9f * Time.deltaTime);
				}
			}
		}

		private bool GetWallPosition(Vector3 NearPosition)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: 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_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			float num = 6f;
			if (Physics.Raycast(NearPosition, Vector3.up, ref rayHit, 22f, StartOfRound.Instance.collidersAndRoomMask, (QueryTriggerInteraction)1))
			{
				num = ((RaycastHit)(ref rayHit)).distance - 1.3f;
			}
			float num2 = RoundManager.Instance.YRotationThatFacesTheNearestFromPosition(NearPosition + Vector3.up * num, 10f, 6);
			if (num2 != -777f)
			{
				turnCompass.eulerAngles = new Vector3(0f, num2, 0f);
				ray = new Ray(NearPosition + Vector3.up * num, turnCompass.forward);
				if (Physics.Raycast(ray, ref rayHit, 10.1f, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1))
				{
					wallPosition = ((Ray)(ref ray)).GetPoint(((RaycastHit)(ref rayHit)).distance - 0.2f);
					wallNormal = ((RaycastHit)(ref rayHit)).normal;
					if (Physics.Raycast(wallPosition, Vector3.down, ref rayHitB, 7f, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1))
					{
						floorPosition = ((RaycastHit)(ref rayHitB)).point;
						return true;
					}
				}
			}
			return false;
		}

		private void SetLookAtPosition(Vector3 lookAt)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			turnCompass.position = meshContainer.position;
			turnCompass.LookAt(lookAt, Vector3.up);
			meshContainerTargetRotation = turnCompass.rotation;
		}

		private void CalculatePathToPosition()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: 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_00f9: 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_008f: 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_00a4: 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)
			if (NavMesh.CalculatePath(meshContainer.position, navigateToPositionTarget, base.agent.areaMask, base.path1))
			{
				if (base.path1.corners.Length > 1)
				{
					meshContainerTarget = base.path1.corners[1];
					if (!overrideLookRotation)
					{
						SetLookAtPosition(base.path1.corners[1]);
					}
				}
				else
				{
					meshContainerTarget = navigateToPositionTarget;
					if (!overrideLookRotation)
					{
						SetLookAtPosition(navigateToPositionTarget);
					}
				}
			}
			else
			{
				meshContainer.position = RoundManager.Instance.GetNavMeshPosition(meshContainer.position, navHit, 5f, base.agent.areaMask);
				meshContainerTarget = meshContainer.position;
			}
		}

		private void CalculateMeshMovement()
		{
			//IL_0028: 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_024b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: 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_0227: 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_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00c3: 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_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			//IL_0307: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			if (lookingForWallPosition && gotWallPositionInLOS)
			{
				if (!onWall || Vector3.Distance(meshContainer.position, wallPosition) > 6.5f)
				{
					base.agent.obstacleAvoidanceType = (ObstacleAvoidanceType)4;
					navigateMeshTowardsPosition = true;
					navigateToPositionTarget = floorPosition;
					if (!overrideLookRotation)
					{
						turnCompass.position = meshContainer.position;
						turnCompass.LookAt(floorPosition, Vector3.up);
						meshContainerTargetRotation = turnCompass.rotation;
					}
					if (Vector3.Distance(((Component)meshContainer).transform.position, floorPosition) < 0.7f)
					{
						onWall = true;
					}
				}
				else
				{
					base.agent.obstacleAvoidanceType = (ObstacleAvoidanceType)0;
					navigateMeshTowardsPosition = false;
					meshContainerTarget = wallPosition;
					if (!reachedWallPosition && Vector3.Distance(meshContainer.position, wallPosition) < 0.1f)
					{
						reachedWallPosition = true;
					}
					if (!overrideLookRotation)
					{
						turnCompass.position = meshContainer.position;
						turnCompass.LookAt(wallPosition, wallNormal);
						meshContainerTargetRotation = turnCompass.rotation;
					}
				}
				return;
			}
			if (!lookingForWallPosition)
			{
				gotWallPositionInLOS = false;
				reachedWallPosition = false;
			}
			if (!onWall)
			{
				base.agent.obstacleAvoidanceType = (ObstacleAvoidanceType)4;
				if (!navigateMeshTowardsPosition)
				{
					CalculatePathToPosition();
					navigateMeshTowardsPosition = true;
				}
				navigateToPositionTarget = ((Component)this).transform.position + Vector3.Normalize(base.agent.desiredVelocity) * 2f;
				return;
			}
			base.agent.obstacleAvoidanceType = (ObstacleAvoidanceType)0;
			navigateMeshTowardsPosition = false;
			if (Physics.Raycast(meshContainerPosition, Vector3.down, ref rayHitC, 15f, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1))
			{
				floorPositionFromMesh = ((RaycastHit)(ref rayHitC)).point;
			}
			else
			{
				floorPositionFromMesh = floorPosition;
			}
			meshContainerTarget = floorPositionFromMesh;
			if (!overrideLookRotation)
			{
				turnCompass.position = meshContainer.position;
				turnCompass.LookAt(floorPositionFromMesh, wallNormal);
				meshContainerTargetRotation = turnCompass.rotation;
			}
			if (Vector3.Distance(((Component)meshContainer).transform.position, floorPositionFromMesh) < 1.1f)
			{
				onWall = false;
				climbingBusy = false;
			}
		}

		public void AvoidClosestPlayer()
		{
			//IL_0048: 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_0088: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)farthestNodeFromTargetPlayer == (Object)null)
			{
				gettingFarthestNodeFromPlayerAsync = true;
				return;
			}
			Transform val = farthestNodeFromTargetPlayer;
			farthestNodeFromTargetPlayer = null;
			if ((Object)(object)val != (Object)null && base.mostOptimalDistance > 5f && Physics.Linecast(((Component)val).transform.position, ((Component)base.targetPlayer.gameplayCamera).transform.position, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1))
			{
				base.targetNode = val;
				((EnemyAI)this).SetDestinationToPosition(base.targetNode.position, false);
			}
			else
			{
				base.agent.speed = 0f;
			}
		}

		public void SyncMeshContainerPositionToClients()
		{
			//IL_0002: 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_001f: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: 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)
			if (Vector3.Distance(meshContainerServerPosition, ((Component)this).transform.position) > 0.5f || Vector3.SignedAngle(meshContainerServerRotation, meshContainer.eulerAngles, Vector3.up) > 30f)
			{
				meshContainerServerPosition = meshContainer.position;
				meshContainerServerRotation = meshContainer.eulerAngles;
				if (((NetworkBehaviour)this).IsServer)
				{
					SyncMeshContainerPositionClientRpc(meshContainerServerPosition, meshContainer.eulerAngles);
				}
				else
				{
					SyncMeshContainerPositionServerRpc(meshContainerServerPosition, meshContainer.eulerAngles);
				}
			}
		}

		[ServerRpc]
		public void SyncMeshContainerPositionServerRpc(Vector3 syncPosition, Vector3 syncRotation)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Invalid comparison between Unknown and I4
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: 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_00dc: 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_0084: Invalid comparison between Unknown and I4
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3013525659u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe(ref syncPosition);
				((FastBufferWriter)(ref val2)).WriteValueSafe(ref syncRotation);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3013525659u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				SyncMeshContainerPositionClientRpc(syncPosition, syncRotation);
			}
		}

		[ClientRpc]
		public void SyncMeshContainerPositionClientRpc(Vector3 syncPosition, Vector3 syncRotation)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2272636777u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref syncPosition);
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref syncRotation);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2272636777u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && !((NetworkBehaviour)this).IsOwner)
				{
					meshContainerServerPosition = syncPosition;
					meshContainerServerRotation = syncRotation;
				}
			}
		}

		public Transform ChooseClosestNodeToPositionNoPathCheck(Vector3 pos)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			base.nodesTempArray = base.allAINodes.OrderBy((GameObject x) => Vector3.Distance(pos, x.transform.position)).ToArray();
			return base.nodesTempArray[0].transform;
		}

		public Transform ChooseClosestNodeToPositionNoLOS(Vector3 pos, bool avoidLineOfSight = false, int offset = 0)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: 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_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: 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_0132: 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_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: 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_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			base.nodesTempArray = base.allAINodes.OrderBy((GameObject x) => Vector3.Distance(pos, x.transform.position)).ToArray();
			Transform transform = base.nodesTempArray[0].transform;
			float num = Vector3.Distance(transform.position, ((Component)base.targetPlayer).transform.position);
			bool flag = false;
			for (int i = 0; i < base.nodesTempArray.Length; i++)
			{
				if (ignoredNodes.Contains(base.nodesTempArray[i].transform) || !(Vector3.Distance(favoriteSpotPos, base.nodesTempArray[i].transform.position) <= base.currentSearch.searchWidth) || !(Vector3.Distance(((Component)this).transform.position, base.nodesTempArray[i].transform.position) <= 40f) || !Physics.Linecast(base.nodesTempArray[i].transform.position + Vector3.up, pos, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1))
				{
					continue;
				}
				bool flag2 = !wasBodyVisible;
				if (((EnemyAI)this).PathIsIntersectedByLineOfSight(base.nodesTempArray[i].transform.position, true, flag2, flag2) || (!(base.pathDistance <= num + 16f) && !wasBodyVisible))
				{
					continue;
				}
				if (wasBodyVisible)
				{
					bool flag3 = false;
					for (int j = 1; j < base.path1.corners.Length; j++)
					{
						if (Vector3.Distance(Vector3.Lerp(base.path1.corners[j - 1], base.path1.corners[j], 0.5f), ((Component)base.targetPlayer).transform.position) < 8f || Vector3.Distance(base.path1.corners[j], ((Component)base.targetPlayer).transform.position) < 8f || num - Vector3.Distance(base.path1.corners[j], ((Component)base.targetPlayer).transform.position) > 4f)
						{
							flag3 = true;
							break;
						}
					}
					if (flag3)
					{
						continue;
					}
				}
				base.mostOptimalDistance = Vector3.Distance(pos, base.nodesTempArray[i].transform.position);
				transform = base.nodesTempArray[i].transform;
				if (offset == 0 || i >= base.nodesTempArray.Length - 1)
				{
					flag = true;
					break;
				}
				offset--;
			}
			if (!flag)
			{
				ignoredNodes.Clear();
				return base.nodesTempArray[Mathf.Min(Random.Range(6, 15), base.nodesTempArray.Length)].transform;
			}
			return transform;
		}

		public void ChooseClosestNodeToPlayer()
		{
			//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_003c: 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)
			if ((Object)(object)base.targetNode == (Object)null)
			{
				base.targetNode = base.allAINodes[0].transform;
			}
			Transform val = ChooseClosestNodeToPositionNoLOS(((Component)base.targetPlayer).transform.position + Vector3.up, avoidLineOfSight: true);
			if ((Object)(object)val != (Object)null)
			{
				base.targetNode = val;
			}
			((EnemyAI)this).SetDestinationToPosition(base.targetNode.position, false);
		}

		public void ChooseClosestNodeToPlayer2()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)base.targetNode == (Object)null)
			{
				base.targetNode = base.allAINodes[0].transform;
			}
			Transform val = ((EnemyAI)this).ChooseClosestNodeToPosition(((Component)base.targetPlayer).transform.position, true, 0);
			if ((Object)(object)val != (Object)null)
			{
				base.targetNode = val;
			}
			float num = Vector3.Distance(((Component)base.targetPlayer).transform.position, ((Component)this).transform.position);
			if (num - base.mostOptimalDistance < 0.1f && (!((EnemyAI)this).PathIsIntersectedByLineOfSight(((Component)base.targetPlayer).transform.position, true, true, false) || num < 3f))
			{
				if (base.pathDistance > 10f && !ignoredNodes.Contains(base.targetNode) && ignoredNodes.Count < 4)
				{
					ignoredNodes.Add(base.targetNode);
				}
				base.movingTowardsTargetPlayer = true;
			}
			else
			{
				((EnemyAI)this).SetDestinationToPosition(base.targetNode.position, false);
			}
		}

		private bool IsBodyVisibleToTarget()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)base.targetPlayer == (Object)null)
			{
				return false;
			}
			for (int i = 0; i < bodyPoints.Length; i++)
			{
				if (base.targetPlayer.HasLineOfSightToPosition(((Component)bodyPoints[i]).transform.position, 45f, 15, -1f))
				{
					return true;
				}
			}
			return false;
		}

		private bool FoundClosestPlayerInRange(float range, float senseRange)
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).TargetClosestPlayer(1.5f, true, 70f);
			if ((Object)(object)base.targetPlayer == (Object)null)
			{
				((EnemyAI)this).TargetClosestPlayer(1.5f, false, 70f);
				range = senseRange;
			}
			return (Object)(object)base.targetPlayer != (Object)null && Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position) < range;
		}

		private bool TargetClosestPlayerInAnyCase()
		{
			//IL_001f: 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)
			base.mostOptimalDistance = 2000f;
			base.targetPlayer = null;
			for (int i = 0; i < StartOfRound.Instance.connectedPlayersAmount + 1; i++)
			{
				base.tempDist = Vector3.Distance(((Component)this).transform.position, ((Component)StartOfRound.Instance.allPlayerScripts[i]).transform.position);
				if (base.tempDist < base.mostOptimalDistance)
				{
					base.mostOptimalDistance = base.tempDist;
					base.targetPlayer = StartOfRound.Instance.allPlayerScripts[i];
				}
			}
			if ((Object)(object)base.targetPlayer == (Object)null)
			{
				return false;
			}
			return true;
		}

		private void CheckForClosePlayer(float radius = 1.5f)
		{
			//IL_0007: 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_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			if (Physics.OverlapSphereNonAlloc(((Component)this).transform.position, radius, nearPlayerColliders, 8, (QueryTriggerInteraction)1) > 0)
			{
				PlayerControllerB component = ((Component)((Component)nearPlayerColliders[0]).transform).GetComponent<PlayerControllerB>();
				if ((Object)(object)component != (Object)null && (Object)(object)component != (Object)(object)base.targetPlayer && !Physics.Linecast(((Component)this).transform.position + Vector3.up * 0.3f, ((Component)component).transform.position, StartOfRound.Instance.collidersAndRoomMask))
				{
					base.targetPlayer = component;
				}
			}
		}

		private IEnumerator StareAtPlayerThenChase(bool WaitBeforeScream = false)
		{
			base.creatureAnimator.SetBool("crawl", false);
			base.creatureAnimator.SetBool("walking", false);
			base.creatureAnimator.SetBool("running", false);
			SetAnimationClientRpc("crawl", animationState: false);
			SetAnimationClientRpc("walking", animationState: false);
			SetAnimationClientRpc("running", animationState: false);
			((EnemyAI)this).SwitchToBehaviourClientRpc(2);
			if (WaitBeforeScream)
			{
				yield return (object)new WaitForSeconds(3f);
			}
			DoAnimationClientRpc("scream");
			((MonoBehaviour)this).StartCoroutine(PlayScream());
		}

		private IEnumerator PlayScream()
		{
			int num = Random.Range(0, randomScreamClips.Length);
			if (!((Object)(object)randomScreamClips[num] == (Object)null))
			{
				float oldVolume = base.creatureSFX.volume;
				base.creatureSFX.spatialize = false;
				base.creatureSFX.volume = 2f;
				base.creatureSFX.PlayOneShot(randomScreamClips[num]);
				WalkieTalkie.TransmitOneShotAudio(base.creatureSFX, randomScreamClips[num], 1f);
				RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, 10f, 0.65f, 0, false, 546);
				yield return (object)new WaitForSeconds(randomScreamClips[num].length / 2f - 0.45f);
				base.creatureSFX.volume = oldVolume;
			}
			ChasePlayer();
		}

		private void ChasePlayer()
		{
			if (!(((Object)(object)base.targetPlayer == (Object)null) | !((NetworkBehaviour)this).IsOwner))
			{
				((EnemyAI)this).SwitchToBehaviourClientRpc(1);
				if (dwellerBehavior == DwellerBehavior.Default)
				{
					base.creatureAnimator.SetBool("walking", false);
					SetAnimationClientRpc("walking", animationState: false);
				}
				else if (dwellerBehavior == DwellerBehavior.VeryAggressive)
				{
					base.creatureAnimator.SetBool("running", false);
					SetAnimationClientRpc("running", animationState: false);
				}
				base.creatureAnimator.SetBool("crawl", true);
				SetAnimationClientRpc("crawl", animationState: true);
			}
		}

		private void StopChasePlayer()
		{
			//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)
			overrideLookRotation = false;
			lookingForWallPosition = false;
			navigateMeshTowardsPosition = false;
			meshContainerTarget = ((Component)this).transform.position;
			if (dwellerBehavior == DwellerBehavior.Default)
			{
				base.creatureAnimator.SetBool("walking", true);
				SetAnimationClientRpc("walking", animationState: true);
			}
			else if (dwellerBehavior == DwellerBehavior.VeryAggressive)
			{
				base.creatureAnimator.SetBool("running", true);
				SetAnimationClientRpc("running", animationState: true);
			}
			else if (dwellerBehavior == DwellerBehavior.Stalk)
			{
				return;
			}
			base.creatureAnimator.SetBool("crawl", false);
			SetAnimationClientRpc("crawl", animationState: false);
		}

		private IEnumerator DeathTaunt()
		{
			((EnemyAI)this).SwitchToBehaviourClientRpc(4);
			base.agent.speed = 0f;
			taunting = true;
			base.targetPlayer = null;
			base.creatureAnimator.SetBool("crawl", false);
			base.creatureAnimator.SetBool("walking", false);
			base.creatureAnimator.SetBool("running", false);
			SetAnimationClientRpc("crawl", animationState: false);
			SetAnimationClientRpc("walking", animationState: false);
			SetAnimationClientRpc("running", animationState: false);
			DoAnimationClientRpc("deathTaunt");
			((Component)deathTauntAudioPre).GetComponent<AudioSource>().Stop();
			((Component)deathTauntAudioPre).GetComponent<AudioSource>().Play();
			yield return (object)new WaitForSeconds(6.165f);
			for (int i = 0; i < 2; i++)
			{
				((Component)deathTauntAudio).GetComponent<AudioSource>().Stop();
				((Component)deathTauntAudio).GetComponent<AudioSource>().Play();
				yield return (object)new WaitForSeconds(((Component)deathTauntAudio).GetComponent<AudioSource>().time);
			}
			yield return (object)new WaitForSeconds(19f);
			taunting = false;
			if (dwellerBehavior == DwellerBehavior.Default)
			{
				base.creatureAnimator.SetBool("walking", true);
				SetAnimationClientRpc("walking", animationState: true);
			}
			else if (dwellerBehavior == DwellerBehavior.VeryAggressive)
			{
				base.creatureAnimator.SetBool("running", true);
				SetAnimationClientRpc("running", animationState: true);
			}
			if (dwellerBehavior == DwellerBehavior.Stalk)
			{
				((EnemyAI)this).SwitchToBehaviourClientRpc(5);
				base.currentBehaviourStateIndex = 5;
			}
			else
			{
				((EnemyAI)this).SwitchToBehaviourClientRpc(0);
				base.currentBehaviourStateIndex = 0;
			}
			((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
		}

		private IEnumerator SwingAttack()
		{
			((EnemyAI)this).SwitchToBehaviourClientRpc(3);
			StalkPos = ((Component)base.targetPlayer).transform.position;
			((EnemyAI)this).SetDestinationToPosition(StalkPos, false);
			yield return (object)new WaitForSeconds(0.2f);
			if (!base.isEnemyDead)
			{
				DoAnimationClientRpc("attack");
				yield return (object)new WaitForSeconds(0.7f);
				SwingAttackHitClientRpc();
				if (base.currentBehaviourStateIndex == 3)
				{
					((EnemyAI)this).SwitchToBehaviourClientRpc(1);
				}
			}
		}

		public override void OnCollideWithPlayer(Collider other)
		{
			//IL_008a: 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)
			if (timeSinceHittingLocalPlayer < 0.8f || base.currentBehaviourStateIndex == 5 || taunting)
			{
				return;
			}
			PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, false, false);
			if ((Object)(object)val != (Object)null)
			{
				timeSinceHittingLocalPlayer = 0f;
				if (val.health - 50 <= 0 && Plugin.isTauntEnabled && Random.Range(0, 100) <= Plugin.tauntChance)
				{
					TauntClientRpc();
				}
				val.DamagePlayer(50, true, true, (CauseOfDeath)6, 0, false, default(Vector3));
				GameNetworkManager.Instance.localPlayerController.JumpToFearLevel(1f, true);
			}
		}

		public override void HitEnemy(int force = 1, PlayerControllerB? playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
		{
			((EnemyAI)this).HitEnemy(force, playerWhoHit, playHitSFX, hitID);
			if (!base.isEnemyDead)
			{
				base.enemyHP -= force;
				if (((NetworkBehaviour)this).IsOwner && base.enemyHP <= 0 && !base.isEnemyDead)
				{
					((MonoBehaviour)this).StopCoroutine(SwingAttack());
					((MonoBehaviour)this).StopCoroutine(base.searchCoroutine);
					((EnemyAI)this).KillEnemyOnOwnerClient(false);
				}
			}
		}

		[ClientRpc]
		public void DoAnimationClientRpc(string animationName)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3912213238u, val, (RpcDelivery)0);
				bool flag = animationName != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(animationName, false);
				}
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3912213238u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				base.creatureAnimator.SetTrigger(animationName);
			}
		}

		[ClientRpc]
		public void SetAnimationClientRpc(string animationName, bool animationState)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: 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_00d5: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1930366465u, val, (RpcDelivery)0);
				bool flag = animationName != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(animationName, false);
				}
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref animationState, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1930366465u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				base.creatureAnimator.SetBool(animationName, animationState);
			}
		}

		[ClientRpc]
		public void TauntClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(239213885u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 239213885u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					((MonoBehaviour)this).StartCoroutine(DeathTaunt());
				}
			}
		}

		[ClientRpc]
		public void SwingAttackHitClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1594705663u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1594705663u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			int num = 8;
			Collider[] array = Physics.OverlapBox(attackArea.position, attackArea.localScale, Quaternion.identity, num);
			if (array.Length == 0)
			{
				return;
			}
			Collider[] array2 = array;
			foreach (Collider val3 in array2)
			{
				PlayerControllerB val4 = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(val3, false, false);
				if ((Object)(object)val4 != (Object)null)
				{
					timeSinceHittingLocalPlayer = 0f;
					if (val4.health - 40 <= 0 && Plugin.isTauntEnabled && Random.Range(0, 100) <= Plugin.tauntChance)
					{
						((MonoBehaviour)this).StartCoroutine(DeathTaunt());
					}
					val4.DamagePlayer(40, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
				}
			}
		}

		protected override void __initializeVariables()
		{
			((EnemyAI)this).__initializeVariables();
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_CaveDwellerAI()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(3013525659u, new RpcReceiveHandler(__rpc_handler_3013525659));
			NetworkManager.__rpc_func_table.Add(2272636777u, new RpcReceiveHandler(__rpc_handler_2272636777));
			NetworkManager.__rpc_func_table.Add(3912213238u, new RpcReceiveHandler(__rpc_handler_3912213238));
			NetworkManager.__rpc_func_table.Add(1930366465u, new RpcReceiveHandler(__rpc_handler_1930366465));
			NetworkManager.__rpc_func_table.Add(239213885u, new RpcReceiveHandler(__rpc_handler_239213885));
			NetworkManager.__rpc_func_table.Add(1594705663u, new RpcReceiveHandler(__rpc_handler_1594705663));
		}

		private static void __rpc_handler_3013525659(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//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_0029: 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_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: 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_0055: Invalid comparison between Unknown and I4
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
			}
			else
			{
				Vector3 syncPosition = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref syncPosition);
				Vector3 syncRotation = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref syncRotation);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((CaveDwellerAI)(object)target).SyncMeshContainerPositionServerRpc(syncPosition, syncRotation);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2272636777(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0043: 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_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				Vector3 syncPosition = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref syncPosition);
				Vector3 syncRotation = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref syncRotation);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((CaveDwellerAI)(object)target).SyncMeshContainerPositionClientRpc(syncPosition, syncRotation);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3912213238(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: 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_0061: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string animationName = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref animationName, false);
				}
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((CaveDwellerAI)(object)target).DoAnimationClientRpc(animationName);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1930366465(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: 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_0067: 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_007c: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string animationName = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref animationName, false);
				}
				bool animationState = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref animationState, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((CaveDwellerAI)(object)target).SetAnimationClientRpc(animationName, animationState);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_239213885(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((CaveDwellerAI)(object)target).TauntClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1594705663(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((CaveDwellerAI)(object)target).SwingAttackHitClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "CaveDwellerAI";
		}
	}
	public class CaveDwellerAICollisionDetect : MonoBehaviour, IHittable, INoiseListener, IShockableWithGun
	{
		public EnemyAI mainScript;

		public bool canCollideWithEnemies;

		public bool onlyCollideWhenGrounded;

		private void OnTriggerStay(Collider other)
		{
			if (((Component)other).CompareTag("Player"))
			{
				if (onlyCollideWhenGrounded)
				{
					CharacterController component = ((Component)other).gameObject.GetComponent<CharacterController>();
					if (!((Object)(object)component != (Object)null) || !component.isGrounded)
					{
						return;
					}
					mainScript.OnCollideWithPlayer(other);
				}
				mainScript.OnCollideWithPlayer(other);
			}
			else if (!onlyCollideWhenGrounded && canCollideWithEnemies && ((Component)other).CompareTag("Enemy"))
			{
				EnemyAICollisionDetect component2 = ((Component)other).gameObject.GetComponent<EnemyAICollisionDetect>();
				if ((Object)(object)component2 != (Object)null && (Object)(object)component2.mainScript != (Object)(object)mainScript)
				{
					mainScript.OnCollideWithEnemy(other, component2.mainScript);
				}
			}
		}

		bool IHittable.Hit(int force, Vector3 hitDirection, PlayerControllerB playerWhoHit, bool playHitSFX, int hitID)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			if (onlyCollideWhenGrounded)
			{
				Debug.Log((object)"Enemy collision detect returned false");
				return false;
			}
			mainScript.HitEnemyOnLocalClient(force, hitDirection, playerWhoHit, playHitSFX, hitID);
			return true;
		}

		void INoiseListener.DetectNoise(Vector3 noisePosition, float noiseLoudness, int timesNoisePlayedInOneSpot, int noiseID)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			if (!onlyCollideWhenGrounded)
			{
				mainScript.DetectNoise(noisePosition, noiseLoudness, timesNoisePlayedInOneSpot, noiseID);
			}
		}

		bool IShockableWithGun.CanBeShocked()
		{
			if (!onlyCollideWhenGrounded && mainScript.postStunInvincibilityTimer <= 0f && mainScript.enemyType.canBeStunned)
			{
				return !mainScript.isEnemyDead;
			}
			return false;
		}

		Vector3 IShockableWithGun.GetShockablePosition()
		{
			//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_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)mainScript.eye != (Object)null)
			{
				return mainScript.eye.position;
			}
			return ((Component)this).transform.position + Vector3.up * 0.5f;
		}

		float IShockableWithGun.GetDifficultyMultiplier()
		{
			return mainScript.enemyType.stunGameDifficultyMultiplier;
		}

		void IShockableWithGun.ShockWithGun(PlayerControllerB shockedByPlayer)
		{
			mainScript.SetEnemyStunned(true, 0.25f, shockedByPlayer);
			EnemyAI obj = mainScript;
			obj.stunnedIndefinitely++;
		}

		Transform IShockableWithGun.GetShockableTransform()
		{
			return ((Component)this).transform;
		}

		NetworkObject IShockableWithGun.GetNetworkObject()
		{
			return ((NetworkBehaviour)mainScript).NetworkObject;
		}

		void IShockableWithGun.StopShockingWithGun()
		{
			mainScript.stunnedIndefinitely = Mathf.Clamp(mainScript.stunnedIndefinitely - 1, 0, 100);
		}
	}
	internal class CaveDwellerTestAI : EnemyAI
	{
		private enum State
		{
			SearchingForPlayer,
			StickingInFrontOfPlayer,
			HeadSwingAttackInProgress
		}

		public Transform turnCompass = null;

		public Transform attackArea = null;

		private float timeSinceHittingLocalPlayer;

		private float timeSinceNewRandPos;

		private Vector3 positionRandomness;

		private Vector3 StalkPos;

		private Random enemyRandom = null;

		private bool isDeadAnimationDone;

		[Conditional("DEBUG")]
		private void LogIfDebugBuild(string text)
		{
			Plugin.Logger.LogInfo((object)text);
		}

		public override void Start()
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Start();
			LogIfDebugBuild("Example Enemy Spawned");
			timeSinceHittingLocalPlayer = 0f;
			base.creatureAnimator.SetTrigger("startWalk");
			timeSinceNewRandPos = 0f;
			positionRandomness = new Vector3(0f, 0f, 0f);
			enemyRandom = new Random(StartOfRound.Instance.randomMapSeed + base.thisEnemyIndex);
			isDeadAnimationDone = false;
			base.currentBehaviourStateIndex = 0;
			((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
		}

		public override void Update()
		{
			//IL_00ba: 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_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Update();
			if (base.isEnemyDead)
			{
				if (!isDeadAnimationDone)
				{
					LogIfDebugBuild("Stopping enemy voice with janky code.");
					isDeadAnimationDone = true;
					base.creatureVoice.Stop();
					base.creatureVoice.PlayOneShot(base.dieSFX);
				}
				return;
			}
			timeSinceHittingLocalPlayer += Time.deltaTime;
			timeSinceNewRandPos += Time.deltaTime;
			int currentBehaviourStateIndex = base.currentBehaviourStateIndex;
			if ((Object)(object)base.targetPlayer != (Object)null && (currentBehaviourStateIndex == 1 || currentBehaviourStateIndex == 2))
			{
				turnCompass.LookAt(((Component)base.targetPlayer.gameplayCamera).transform.position);
				((Component)this).transform.rotation = Quaternion.Lerp(((Component)this).transform.rotation, Quaternion.Euler(new Vector3(0f, turnCompass.eulerAngles.y, 0f)), 4f * Time.deltaTime);
			}
			if (base.stunNormalizedTimer > 0f)
			{
				base.agent.speed = 0f;
			}
		}

		public override void DoAIInterval()
		{
			//IL_00b5: 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_00e2: 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)
			((EnemyAI)this).DoAIInterval();
			if (base.isEnemyDead || StartOfRound.Instance.allPlayersDead)
			{
				return;
			}
			switch (base.currentBehaviourStateIndex)
			{
			case 0:
				base.agent.speed = 3f;
				if (FoundClosestPlayerInRange(25f, 3f))
				{
					LogIfDebugBuild("Start Target Player");
					((EnemyAI)this).StopSearch(base.currentSearch, true);
					((EnemyAI)this).SwitchToBehaviourClientRpc(1);
				}
				break;
			case 1:
				base.agent.speed = 5f;
				if (!TargetClosestPlayerInAnyCase() || (Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position) > 20f && !((EnemyAI)this).CheckLineOfSightForPosition(((Component)base.targetPlayer).transform.position, 45f, 60, -1f, (Transform)null)))
				{
					LogIfDebugBuild("Stop Target Player");
					((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
					((EnemyAI)this).SwitchToBehaviourClientRpc(0);
				}
				else
				{
					StickingInFrontOfPlayer();
				}
				break;
			case 2:
				break;
			default:
				LogIfDebugBuild("This Behavior State doesn't exist!");
				break;
			}
		}

		private bool FoundClosestPlayerInRange(float range, float senseRange)
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).TargetClosestPlayer(1.5f, true, 70f);
			if ((Object)(object)base.targetPlayer == (Object)null)
			{
				((EnemyAI)this).TargetClosestPlayer(1.5f, false, 70f);
				range = senseRange;
			}
			return (Object)(object)base.targetPlayer != (Object)null && Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position) < range;
		}

		private bool TargetClosestPlayerInAnyCase()
		{
			//IL_001f: 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)
			base.mostOptimalDistance = 2000f;
			base.targetPlayer = null;
			for (int i = 0; i < StartOfRound.Instance.connectedPlayersAmount + 1; i++)
			{
				base.tempDist = Vector3.Distance(((Component)this).transform.position, ((Component)StartOfRound.Instance.allPlayerScripts[i]).transform.position);
				if (base.tempDist < base.mostOptimalDistance)
				{
					base.mostOptimalDistance = base.tempDist;
					base.targetPlayer = StartOfRound.Instance.allPlayerScripts[i];
				}
			}
			if ((Object)(object)base.targetPlayer == (Object)null)
			{
				return false;
			}
			return true;
		}

		private void StickingInFrontOfPlayer()
		{
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)base.targetPlayer == (Object)null) && ((NetworkBehaviour)this).IsOwner && timeSinceNewRandPos > 0.7f)
			{
				timeSinceNewRandPos = 0f;
				if (enemyRandom.Next(0, 5) == 0)
				{
					((MonoBehaviour)this).StartCoroutine(SwingAttack());
				}
				else
				{
					positionRandomness = new Vector3((float)enemyRandom.Next(-2, 2), 0f, (float)enemyRandom.Next(-2, 2));
					StalkPos = ((Component)base.targetPlayer).transform.position - Vector3.Scale(new Vector3(-5f, 0f, -5f), ((Component)base.targetPlayer).transform.forward) + positionRandomness;
				}
				((EnemyAI)this).SetDestinationToPosition(StalkPos, false);
			}
		}

		private IEnumerator SwingAttack()
		{
			((EnemyAI)this).SwitchToBehaviourClientRpc(2);
			StalkPos = ((Component)base.targetPlayer).transform.position;
			((EnemyAI)this).SetDestinationToPosition(StalkPos, false);
			yield return (object)new WaitForSeconds(0.5f);
			if (!base.isEnemyDead)
			{
				DoAnimationClientRpc("swingAttack");
				yield return (object)new WaitForSeconds(0.35f);
				SwingAttackHitClientRpc();
				if (base.currentBehaviourStateIndex == 2)
				{
					((EnemyAI)this).SwitchToBehaviourClientRpc(1);
				}
			}
		}

		public override void OnCollideWithPlayer(Collider other)
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			if (!(timeSinceHittingLocalPlayer < 1f))
			{
				PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, false, false);
				if ((Object)(object)val != (Object)null)
				{
					LogIfDebugBuild("Example Enemy Collision with Player!");
					timeSinceHittingLocalPlayer = 0f;
					val.DamagePlayer(20, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
				}
			}
		}

		public override void HitEnemy(int force = 1, PlayerControllerB? playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
		{
			((EnemyAI)this).HitEnemy(force, playerWhoHit, playHitSFX, hitID);
			if (!base.isEnemyDead)
			{
				base.enemyHP -= force;
				if (((NetworkBehaviour)this).IsOwner && base.enemyHP <= 0 && !base.isEnemyDead)
				{
					((MonoBehaviour)this).StopCoroutine(SwingAttack());
					((MonoBehaviour)this).StopCoroutine(base.searchCoroutine);
					((EnemyAI)this).KillEnemyOnOwnerClient(false);
				}
			}
		}

		[ClientRpc]
		public void DoAnimationClientRpc(string animationName)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2197414567u, val, (RpcDelivery)0);
				bool flag = animationName != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(animationName, false);
				}
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2197414567u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				LogIfDebugBuild("Animation: " + animationName);
				base.creatureAnimator.SetTrigger(animationName);
			}
		}

		[ClientRpc]
		public void SwingAttackHitClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: 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_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_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2542932983u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2542932983u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			LogIfDebugBuild("SwingAttackHitClientRPC");
			int num = 8;
			Collider[] array = Physics.OverlapBox(attackArea.position, attackArea.localScale, Quaternion.identity, num);
			if (array.Length == 0)
			{
				return;
			}
			Collider[] array2 = array;
			foreach (Collider val3 in array2)
			{
				PlayerControllerB val4 = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(val3, false, false);
				if ((Object)(object)val4 != (Object)null)
				{
					LogIfDebugBuild("Swing attack hit player!");
					timeSinceHittingLocalPlayer = 0f;
					val4.DamagePlayer(40, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
				}
			}
		}

		protected override void __initializeVariables()
		{
			((EnemyAI)this).__initializeVariables();
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_CaveDwellerTestAI()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(2197414567u, new RpcReceiveHandler(__rpc_handler_2197414567));
			NetworkManager.__rpc_func_table.Add(2542932983u, new RpcReceiveHandler(__rpc_handler_2542932983));
		}

		private static void __rpc_handler_2197414567(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: 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_0061: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string animationName = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref animationName, false);
				}
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((CaveDwellerTestAI)(object)target).DoAnimationClientRpc(animationName);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2542932983(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((CaveDwellerTestAI)(object)target).SwingAttackHitClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "CaveDwellerTestAI";
		}
	}
	public class CaveDwellerTestAICollisionDetect : MonoBehaviour, IHittable, INoiseListener, IShockableWithGun
	{
		public EnemyAI mainScript;

		public bool canCollideWithEnemies;

		public bool onlyCollideWhenGrounded;

		private void OnTriggerStay(Collider other)
		{
		}

		bool IHittable.Hit(int force, Vector3 hitDirection, PlayerControllerB playerWhoHit, bool playHitSFX, int hitID)
		{
			return false;
		}

		void INoiseListener.DetectNoise(Vector3 noisePosition, float noiseLoudness, int timesNoisePlayedInOneSpot, int noiseID)
		{
		}

		bool IShockableWithGun.CanBeShocked()
		{
			return false;
		}

		Vector3 IShockableWithGun.GetShockablePosition()
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: 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)
			return default(Vector3);
		}

		float IShockableWithGun.GetDifficultyMultiplier()
		{
			return 0f;
		}

		void IShockableWithGun.ShockWithGun(PlayerControllerB shockedByPlayer)
		{
		}

		Transform IShockableWithGun.GetShockableTransform()
		{
			return null;
		}

		NetworkObject IShockableWithGun.GetNetworkObject()
		{
			return null;
		}

		void IShockableWithGun.StopShockingWithGun()
		{
		}
	}
	internal class ExampleEnemyAI : EnemyAI
	{
		private enum State
		{
			SearchingForPlayer,
			StickingInFrontOfPlayer,
			HeadSwingAttackInProgress
		}

		public Transform turnCompass = null;

		public Transform attackArea = null;

		private float timeSinceHittingLocalPlayer;

		private float timeSinceNewRandPos;

		private Vector3 positionRandomness;

		private Vector3 StalkPos;

		private Random enemyRandom = null;

		private bool isDeadAnimationDone;

		[Conditional("DEBUG")]
		private void LogIfDebugBuild(string text)
		{
			Plugin.Logger.LogInfo((object)text);
		}

		public override void Start()
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Start();
			LogIfDebugBuild("Example Enemy Spawned");
			timeSinceHittingLocalPlayer = 0f;
			base.creatureAnimator.SetTrigger("startWalk");
			timeSinceNewRandPos = 0f;
			positionRandomness = new Vector3(0f, 0f, 0f);
			enemyRandom = new Random(StartOfRound.Instance.randomMapSeed + base.thisEnemyIndex);
			isDeadAnimationDone = false;
			base.currentBehaviourStateIndex = 0;
			((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
		}

		public override void Update()
		{
			//IL_00ba: 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_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Update();
			if (base.isEnemyDead)
			{
				if (!isDeadAnimationDone)
				{
					LogIfDebugBuild("Stopping enemy voice with janky code.");
					isDeadAnimationDone = true;
					base.creatureVoice.Stop();
					base.creatureVoice.PlayOneShot(base.dieSFX);
				}
				return;
			}
			timeSinceHittingLocalPlayer += Time.deltaTime;
			timeSinceNewRandPos += Time.deltaTime;
			int currentBehaviourStateIndex = base.currentBehaviourStateIndex;
			if ((Object)(object)base.targetPlayer != (Object)null && (currentBehaviourStateIndex == 1 || currentBehaviourStateIndex == 2))
			{
				turnCompass.LookAt(((Component)base.targetPlayer.gameplayCamera).transform.position);
				((Component)this).transform.rotation = Quaternion.Lerp(((Component)this).transform.rotation, Quaternion.Euler(new Vector3(0f, turnCompass.eulerAngles.y, 0f)), 4f * Time.deltaTime);
			}
			if (base.stunNormalizedTimer > 0f)
			{
				base.agent.speed = 0f;
			}
		}

		public override void DoAIInterval()
		{
			//IL_00b5: 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_00e2: 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)
			((EnemyAI)this).DoAIInterval();
			if (base.isEnemyDead || StartOfRound.Instance.allPlayersDead)
			{
				return;
			}
			switch (base.currentBehaviourStateIndex)
			{
			case 0:
				base.agent.speed = 3f;
				if (FoundClosestPlayerInRange(25f, 3f))
				{
					LogIfDebugBuild("Start Target Player");
					((EnemyAI)this).StopSearch(base.currentSearch, true);
					((EnemyAI)this).SwitchToBehaviourClientRpc(1);
				}
				break;
			case 1:
				base.agent.speed = 5f;
				if (!TargetClosestPlayerInAnyCase() || (Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position) > 20f && !((EnemyAI)this).CheckLineOfSightForPosition(((Component)base.targetPlayer).transform.position, 45f, 60, -1f, (Transform)null)))
				{
					LogIfDebugBuild("Stop Target Player");
					((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
					((EnemyAI)this).SwitchToBehaviourClientRpc(0);
				}
				else
				{
					StickingInFrontOfPlayer();
				}
				break;
			case 2:
				break;
			default:
				LogIfDebugBuild("This Behavior State doesn't exist!");
				break;
			}
		}

		private bool FoundClosestPlayerInRange(float range, float senseRange)
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).TargetClosestPlayer(1.5f, true, 70f);
			if ((Object)(object)base.targetPlayer == (Object)null)
			{
				((EnemyAI)this).TargetClosestPlayer(1.5f, false, 70f);
				range = senseRange;
			}
			return (Object)(object)base.targetPlayer != (Object)null && Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position) < range;
		}

		private bool TargetClosestPlayerInAnyCase()
		{
			//IL_001f: 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)
			base.mostOptimalDistance = 2000f;
			base.targetPlayer = null;
			for (int i = 0; i < StartOfRound.Instance.connectedPlayersAmount + 1; i++)
			{
				base.tempDist = Vector3.Distance(((Component)this).transform.position, ((Component)StartOfRound.Instance.allPlayerScripts[i]).transform.position);
				if (base.tempDist < base.mostOptimalDistance)
				{
					base.mostOptimalDistance = base.tempDist;
					base.targetPlayer = StartOfRound.Instance.allPlayerScripts[i];
				}
			}
			if ((Object)(object)base.targetPlayer == (Object)null)
			{
				return false;
			}
			return true;
		}

		private void StickingInFrontOfPlayer()
		{
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)base.targetPlayer == (Object)null) && ((NetworkBehaviour)this).IsOwner && timeSinceNewRandPos > 0.7f)
			{
				timeSinceNewRandPos = 0f;
				if (enemyRandom.Next(0, 5) == 0)
				{
					((MonoBehaviour)this).StartCoroutine(SwingAttack());
				}
				else
				{
					positionRandomness = new Vector3((float)enemyRandom.Next(-2, 2), 0f, (float)enemyRandom.Next(-2, 2));
					StalkPos = ((Component)base.targetPlayer).transform.position - Vector3.Scale(new Vector3(-5f, 0f, -5f), ((Component)base.targetPlayer).transform.forward) + positionRandomness;
				}
				((EnemyAI)this).SetDestinationToPosition(StalkPos, false);
			}
		}

		private IEnumerator SwingAttack()
		{
			((EnemyAI)this).SwitchToBehaviourClientRpc(2);
			StalkPos = ((Component)base.targetPlayer).transform.position;
			((EnemyAI)this).SetDestinationToPosition(StalkPos, false);
			yield return (object)new WaitForSeconds(0.5f);
			if (!base.isEnemyDead)
			{
				DoAnimationClientRpc("swingAttack");
				yield return (object)new WaitForSeconds(0.35f);
				SwingAttackHitClientRpc();
				if (base.currentBehaviourStateIndex == 2)
				{
					((EnemyAI)this).SwitchToBehaviourClientRpc(1);
				}
			}
		}

		public override void OnCollideWithPlayer(Collider other)
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			if (!(timeSinceHittingLocalPlayer < 1f))
			{
				PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, false, false);
				if ((Object)(object)val != (Object)null)
				{
					LogIfDebugBuild("Example Enemy Collision with Player!");
					timeSinceHittingLocalPlayer = 0f;
					val.DamagePlayer(20, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
				}
			}
		}

		public override void HitEnemy(int force = 1, PlayerControllerB? playerWhoHit = null, bool playHitSFX