Decompiled source of BrolyCuloPlus v1.1.0

Stash.BrolyCulo.dll

Decompiled an hour ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
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 CustomEnnemies.Configuration;
using GameNetcodeStuff;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("FrenchPlatypus.BrolyCulo")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.3.0.0")]
[assembly: AssemblyInformationalVersion("1.3.0")]
[assembly: AssemblyProduct("FrenchPlatypus.BrolyCulo")]
[assembly: AssemblyTitle("FrenchPlatypus.BrolyCulo")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.3.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace CustomEnnemies
{
	internal class BrolyAI : EnemyAI
	{
		public Transform turnCompass;

		public Transform attackArea;

		public Transform assParent;

		public Transform playerParent;

		public AudioSource stepSound;

		private Vector3 spawnPos;

		private Random enemyRandom;

		private bool isDeadAnimationDone;

		private bool attackingPlayer;

		private bool isInterrupted;

		private float fleaTimer;

		private Coroutine attackingPlayerCoroutine;

		private Ray playerRay;

		public bool carryingPlayerBody;

		public DeadBodyInfo bodyBeingCarried;

		private FlowermanAI flowermanTarget;

		private float chaseGraceTimer;

		private float lastChargeTime = -1000f;

		private float chargeTimer;

		private bool isCharging;

		private Vector3 chargeDirection = Vector3.forward;

		private readonly HashSet<int> chargeKilled = new HashSet<int>();

		private float chaseChargeRollTimer;

		private PlayerControllerB chargeGrabVictim;

		private bool isChargeHolding;

		private float chargeAttackDeadline;

		private readonly HashSet<int> chargeHitServer = new HashSet<int>();

		private float lastChaseTime;

		private bool isStealthing;

		private PlayerControllerB stealthTarget;

		private float stealthRollTimer;

		private DoorLock[] doorCache;

		private float lastDoorScan = -100f;

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

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

		private bool useDragGrab;

		private bool isDragging;

		private Vector3 dragSyncPos;

		private static FieldInfo triggerAnimatorField;

		private static PluginConfig C => Plugin.BoundConfig;

		private static int LosRange => Mathf.CeilToInt(Mathf.Max(C.ChaseSightRange.Value, C.SightRange.Value));

		public override void Start()
		{
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Start();
			base.agent.acceleration = C.Acceleration.Value;
			base.agent.angularSpeed = C.AngularSpeed.Value;
			base.agent.stoppingDistance = 0f;
			if (C.Health.Value > 0)
			{
				base.enemyHP = C.Health.Value;
			}
			if ((Object)(object)base.enemyType != (Object)null)
			{
				base.enemyType.doorSpeedMultiplier = 1f / Mathf.Max(0.05f, C.DoorOpenTime.Value);
			}
			spawnPos = ((Component)this).transform.position;
			enemyRandom = new Random(StartOfRound.Instance.randomMapSeed + base.thisEnemyIndex);
			lastChaseTime = Time.time;
			if ((Object)(object)stepSound != (Object)null)
			{
				stepSound.spatialBlend = 1f;
				stepSound.rolloffMode = (AudioRolloffMode)1;
				stepSound.minDistance = 1f;
				stepSound.maxDistance = C.StepSoundMaxDistance.Value;
			}
			((Component)this).gameObject.AddComponent<BrolyDragFollower>().brolyAI = this;
			isDeadAnimationDone = false;
			DoAnimation("startWalk");
			MuteVoice(mute: true);
			MuteSteps(mute: false);
			base.currentBehaviourStateIndex = 0;
			((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
		}

		public override void Update()
		{
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Update();
			if (base.isEnemyDead)
			{
				if (!isDeadAnimationDone)
				{
					isDeadAnimationDone = true;
					ApplyMuteVoice(mute: true);
					ApplyMuteSteps(mute: true);
					ApplyAnimation("killEnemy");
					ApplyDeathSound();
				}
				return;
			}
			if (isChargeHolding && ((Object)(object)chargeGrabVictim == (Object)null || chargeGrabVictim.isPlayerDead || !chargeGrabVictim.isPlayerControlled))
			{
				ReleaseChargeHold();
			}
			if ((attackingPlayer || isChargeHolding) && (Object)(object)base.inSpecialAnimationWithPlayer != (Object)null && !base.inSpecialAnimationWithPlayer.isPlayerDead)
			{
				base.inSpecialAnimationWithPlayer.voiceMuffledByEnemy = true;
			}
			if ((Object)(object)base.targetPlayer != (Object)null && base.currentBehaviourStateIndex == 1 && !isCharging && (Object)(object)turnCompass != (Object)null)
			{
				turnCompass.LookAt(((Component)base.targetPlayer.gameplayCamera).transform.position);
				((Component)this).transform.rotation = Quaternion.Lerp(((Component)this).transform.rotation, Quaternion.Euler(0f, turnCompass.eulerAngles.y, 0f), 6f * Time.deltaTime);
			}
			if (base.stunNormalizedTimer > 0f)
			{
				base.agent.speed = 0f;
			}
			if (fleaTimer > 0f)
			{
				fleaTimer -= Time.deltaTime;
			}
		}

		public override void OnGainedOwnership()
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			((NetworkBehaviour)this).OnGainedOwnership();
			if (!((NetworkBehaviour)this).IsOwner)
			{
				return;
			}
			if (base.currentBehaviourStateIndex == 0)
			{
				if (isStealthing)
				{
					MuteSteps(mute: true);
					MuteVoice(mute: true);
					return;
				}
				DoAnimation("startWalk");
				MuteVoice(mute: true);
				MuteSteps(mute: false);
				((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
			}
			else if (base.currentBehaviourStateIndex == 1)
			{
				if ((Object)(object)base.targetPlayer == (Object)null)
				{
					FoundClosestPlayerInRange(C.SightRange.Value, C.SenseRange.Value);
				}
				chaseGraceTimer = C.ChaseGraceTime.Value;
			}
		}

		public override void DoAIInterval()
		{
			//IL_0368: Unknown result type (might be due to invalid IL or missing references)
			//IL_0410: Unknown result type (might be due to invalid IL or missing references)
			//IL_0416: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0453: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).DoAIInterval();
			if (base.isEnemyDead || StartOfRound.Instance.allPlayersDead)
			{
				return;
			}
			if (chargeAttackDeadline > 0f)
			{
				if (!attackingPlayer)
				{
					if (Time.time > chargeAttackDeadline)
					{
						chargeAttackDeadline = 0f;
						SendReleaseChargeHold();
						ResumeAfterCharge();
					}
					return;
				}
				chargeAttackDeadline = 0f;
			}
			DoDoorLogic();
			base.agent.autoBraking = !isCharging && base.currentBehaviourStateIndex != 1;
			if (isCharging)
			{
				DoChargeTick();
				return;
			}
			if (isStealthing && base.currentBehaviourStateIndex == 0)
			{
				DoStealthTick();
				return;
			}
			switch (base.currentBehaviourStateIndex)
			{
			case 0:
				base.agent.speed = C.WanderSpeed.Value;
				if (!((NetworkBehaviour)this).IsServer && ((NetworkBehaviour)this).IsOwner)
				{
					((EnemyAI)this).ChangeOwnershipOfEnemy(StartOfRound.Instance.allPlayerScripts[0].actualClientId);
				}
				else if (!TryStartCharge())
				{
					if (C.HuntBrackens.Value && FoundBrackenInMap() && (Object)(object)flowermanTarget != (Object)null)
					{
						DoAnimation("chaseBracken");
						((EnemyAI)this).SwitchToBehaviourState(2);
						MuteSteps(mute: true);
						MuteVoice(mute: true);
					}
					else if (FoundClosestPlayerInRange(C.SightRange.Value, C.SenseRange.Value) && (Object)(object)base.targetPlayer != (Object)null)
					{
						BeginChase();
					}
					else
					{
						TryStartStealth();
					}
				}
				break;
			case 1:
				base.agent.speed = C.ChaseSpeed.Value;
				if (TryStartCharge())
				{
					break;
				}
				if ((Object)(object)base.targetPlayer != (Object)null && (base.targetPlayer.isPlayerDead || !base.targetPlayer.isPlayerControlled))
				{
					base.targetPlayer = null;
				}
				if ((Object)(object)base.targetPlayer == (Object)null && FoundClosestPlayerInRange(C.SightRange.Value, C.SenseRange.Value))
				{
					chaseGraceTimer = C.ChaseGraceTime.Value;
				}
				if ((Object)(object)base.targetPlayer != (Object)null && TryRandomChaseCharge())
				{
					break;
				}
				if ((Object)(object)base.targetPlayer != (Object)null)
				{
					((EnemyAI)this).SetDestinationToPosition(GetChaseDestination(base.targetPlayer), false);
					if (((NetworkBehaviour)this).IsOwner && (Object)(object)base.targetPlayer != (Object)(object)GameNetworkManager.Instance.localPlayerController)
					{
						((EnemyAI)this).ChangeOwnershipOfEnemy(base.targetPlayer.actualClientId);
					}
					if (CanSeeTarget(base.targetPlayer))
					{
						chaseGraceTimer = C.ChaseGraceTime.Value;
					}
					else
					{
						chaseGraceTimer -= base.AIIntervalTime;
					}
				}
				if ((Object)(object)base.targetPlayer == (Object)null || (C.HuntBrackens.Value && FoundBrackenInMap()) || chaseGraceTimer <= 0f)
				{
					EndChase();
				}
				break;
			case 2:
				base.agent.speed = C.BrackenChaseSpeed.Value;
				if ((Object)(object)flowermanTarget == (Object)null || ((EnemyAI)flowermanTarget).isEnemyDead)
				{
					((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
					DoAnimation("startWalk");
					((EnemyAI)this).SwitchToBehaviourState(0);
					MuteVoice(mute: true);
					MuteSteps(mute: false);
				}
				else
				{
					((EnemyAI)this).SetDestinationToPosition(((Component)flowermanTarget).transform.position, false);
				}
				break;
			case 3:
				base.agent.speed = C.FleeSpeed.Value;
				break;
			case 4:
				base.agent.speed = C.BrackenChaseSpeed.Value;
				break;
			case 5:
				base.agent.speed = C.FleeSpeed.Value;
				if (fleaTimer <= 0f || Vector3.Distance(((Component)this).transform.position, spawnPos) < 1.5f)
				{
					fleaTimer = 0f;
					if (carryingPlayerBody)
					{
						DropPlayerBody();
						DropPlayerBodyServerRpc();
					}
					MarkChased();
					((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
					DoAnimation("startWalk");
					((EnemyAI)this).SwitchToBehaviourState(0);
					MuteVoice(mute: true);
					MuteSteps(mute: false);
				}
				break;
			}
		}

		private void BeginChase()
		{
			chaseGraceTimer = C.ChaseGraceTime.Value;
			chaseChargeRollTimer = 0f;
			MarkChased();
			DoAnimation("chasePlayer");
			((EnemyAI)this).SwitchToBehaviourState(1);
			MuteSteps(mute: true);
			MuteVoice(mute: false);
			SetTargetPlayerServerRpc((int)base.targetPlayer.playerClientId);
		}

		private void EndChase()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			MarkChased();
			((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
			DoAnimation("startWalk");
			((EnemyAI)this).SwitchToBehaviourState(0);
			MuteSteps(mute: false);
			MuteVoice(mute: true);
		}

		private Vector3 GetChaseDestination(PlayerControllerB player)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: 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_0054: 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_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: 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_0069: 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_007c: 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_0094: 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)
			Vector3 position = ((Component)player).transform.position;
			float value = C.ChaseOvershoot.Value;
			if (value <= 0f)
			{
				return position;
			}
			Vector3 val = position - ((Component)this).transform.position;
			val.y = 0f;
			if (((Vector3)(ref val)).sqrMagnitude < 0.01f)
			{
				return position;
			}
			Vector3 val2 = position + ((Vector3)(ref val)).normalized * value;
			NavMeshHit val3 = default(NavMeshHit);
			if (NavMesh.Raycast(position, val2, ref val3, -1))
			{
				return ((NavMeshHit)(ref val3)).position;
			}
			NavMeshHit val4 = default(NavMeshHit);
			if (NavMesh.SamplePosition(val2, ref val4, 2f, -1))
			{
				return ((NavMeshHit)(ref val4)).position;
			}
			return position;
		}

		private bool CanSeeTarget(PlayerControllerB player)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			if (Vector3.Distance(((Component)this).transform.position, ((Component)player).transform.position) < C.SenseRange.Value)
			{
				return true;
			}
			return ((EnemyAI)this).CheckLineOfSightForPosition(((Component)player.gameplayCamera).transform.position, C.ViewAngle.Value, LosRange, -1f, (Transform)null);
		}

		private DoorLock[] GetDoors()
		{
			if (doorCache == null || (doorCache.Length == 0 && Time.time - lastDoorScan > 10f))
			{
				doorCache = Object.FindObjectsOfType<DoorLock>();
				lastDoorScan = Time.time;
			}
			return doorCache;
		}

		private static bool IsDoorOpen(DoorLock door)
		{
			AnimatedObjectTrigger component = ((Component)door).GetComponent<AnimatedObjectTrigger>();
			if ((Object)(object)component != (Object)null)
			{
				return component.boolValue;
			}
			return false;
		}

		private void DoDoorLogic()
		{
			if (((NetworkBehaviour)this).IsOwner && !attackingPlayer && !base.inSpecialAnimation)
			{
				if (isCharging || base.currentBehaviourStateIndex == 1)
				{
					TryBreakDoor();
				}
				if (C.CloseDoors.Value && (!isStealthing || C.CloseDoorsInStealth.Value))
				{
					TryCloseDoorsBehind();
				}
			}
		}

		private void TryBreakDoor()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			if (!C.BreakDoors.Value)
			{
				return;
			}
			Vector3 val = (isCharging ? chargeDirection : ((Component)this).transform.forward);
			val.y = 0f;
			if (((Vector3)(ref val)).sqrMagnitude < 0.01f)
			{
				return;
			}
			((Vector3)(ref val)).Normalize();
			float num = C.DoorBreakRange.Value + (isCharging ? (C.ChargeSpeed.Value * base.AIIntervalTime) : 0f);
			DoorLock[] doors = GetDoors();
			DoorLock val2 = null;
			float num2 = float.MaxValue;
			foreach (DoorLock val3 in doors)
			{
				if ((Object)(object)val3 == (Object)null || !((Behaviour)val3).isActiveAndEnabled || brokenDoors.Contains(val3) || IsDoorOpen(val3) || (val3.isLocked && !C.BreakLockedDoors.Value))
				{
					continue;
				}
				Vector3 val4 = ((Component)val3).transform.position - ((Component)this).transform.position;
				if (!(Mathf.Abs(val4.y) > 3f))
				{
					val4.y = 0f;
					float magnitude = ((Vector3)(ref val4)).magnitude;
					if (!(magnitude > num) && (!(magnitude > 0.5f) || !(Vector3.Dot(val, val4 / magnitude) < 0.5f)) && magnitude < num2)
					{
						num2 = magnitude;
						val2 = val3;
					}
				}
			}
			if ((Object)(object)val2 != (Object)null)
			{
				brokenDoors.Add(val2);
				SendBreakDoor(((Component)val2).transform.position);
			}
		}

		private void TryCloseDoorsBehind()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			DoorLock[] doors = GetDoors();
			Vector3 forward = ((Component)this).transform.forward;
			forward.y = 0f;
			foreach (DoorLock val in doors)
			{
				if ((Object)(object)val == (Object)null || !((Behaviour)val).isActiveAndEnabled || brokenDoors.Contains(val))
				{
					continue;
				}
				if (!IsDoorOpen(val))
				{
					trackedDoors.Remove(val);
					continue;
				}
				Vector3 val2 = ((Component)val).transform.position - ((Component)this).transform.position;
				if (Mathf.Abs(val2.y) > 3f)
				{
					trackedDoors.Remove(val);
					continue;
				}
				val2.y = 0f;
				float magnitude = ((Vector3)(ref val2)).magnitude;
				if (magnitude < 2.5f)
				{
					trackedDoors.Add(val);
				}
				else if (trackedDoors.Contains(val))
				{
					if (magnitude > C.DoorCloseDistance.Value && Vector3.Dot(forward, val2) < 0f)
					{
						trackedDoors.Remove(val);
						CloseDoor(val);
					}
					else if (magnitude > C.DoorCloseDistance.Value + 6f)
					{
						trackedDoors.Remove(val);
					}
				}
			}
		}

		private void CloseDoor(DoorLock door)
		{
			PlayerControllerB val = (((Object)(object)GameNetworkManager.Instance != (Object)null) ? GameNetworkManager.Instance.localPlayerController : null);
			if (!((Object)(object)door == (Object)null) && !((Object)(object)val == (Object)null) && IsDoorOpen(door))
			{
				door.OpenOrCloseDoor(val);
			}
		}

		private DoorLock FindDoorNear(Vector3 position)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			DoorLock[] doors = GetDoors();
			DoorLock result = null;
			float num = 1.5f;
			for (int i = 0; i < doors.Length; i++)
			{
				if (!((Object)(object)doors[i] == (Object)null))
				{
					float num2 = Vector3.Distance(((Component)doors[i]).transform.position, position);
					if (num2 < num)
					{
						num = num2;
						result = doors[i];
					}
				}
			}
			return result;
		}

		private void ApplyBreakDoor(Vector3 position)
		{
			//IL_0001: 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_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			DoorLock val = FindDoorNear(position);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			brokenDoors.Add(val);
			bool value = C.DebugDoors.Value;
			if (value)
			{
				LogDoorHierarchy(val);
			}
			List<Transform> list = new List<Transform>();
			Transform[] componentsInChildren = ((Component)val).GetComponentsInChildren<Transform>(true);
			foreach (Transform val2 in componentsInChildren)
			{
				if ((Object)(object)val2 != (Object)(object)((Component)val).transform && IsDoorFrame(val2) && !HasFrameAncestor(val2, ((Component)val).transform))
				{
					list.Add(val2);
				}
			}
			for (int j = 0; j < list.Count; j++)
			{
				if (value)
				{
					Plugin.Logger.LogInfo((object)("Door break: keeping frame " + ((Object)list[j]).name));
				}
				list[j].SetParent(((Component)val).transform.parent, true);
			}
			List<Renderer> list2 = new List<Renderer>();
			List<Collider> list3 = new List<Collider>();
			List<Animator> list4 = new List<Animator>();
			CollectDoorParts(val, list2, list3, list4, value);
			Vector3 val3 = ((Component)val).transform.position + Vector3.up * 1.2f;
			bool flag = false;
			Bounds bounds = default(Bounds);
			((Bounds)(ref bounds))..ctor(val3, Vector3.zero);
			for (int k = 0; k < list2.Count; k++)
			{
				if (!((Object)(object)list2[k] == (Object)null))
				{
					if (!flag)
					{
						bounds = list2[k].bounds;
						flag = true;
					}
					else
					{
						((Bounds)(ref bounds)).Encapsulate(list2[k].bounds);
					}
				}
			}
			if (flag)
			{
				val3 = ((Bounds)(ref bounds)).center;
			}
			val.isLocked = false;
			NavMeshObstacle[] componentsInChildren2 = ((Component)val).GetComponentsInChildren<NavMeshObstacle>(true);
			foreach (NavMeshObstacle obj in componentsInChildren2)
			{
				obj.carving = false;
				((Behaviour)obj).enabled = false;
			}
			for (int l = 0; l < list3.Count; l++)
			{
				if ((Object)(object)list3[l] != (Object)null)
				{
					list3[l].enabled = false;
					Object.Destroy((Object)(object)list3[l]);
				}
			}
			for (int m = 0; m < list4.Count; m++)
			{
				if ((Object)(object)list4[m] != (Object)null)
				{
					((Behaviour)list4[m]).enabled = false;
				}
			}
			for (int n = 0; n < list2.Count; n++)
			{
				Renderer val4 = list2[n];
				if (!((Object)(object)val4 == (Object)null))
				{
					val4.enabled = false;
					MeshFilter component = ((Component)val4).GetComponent<MeshFilter>();
					Object.Destroy((Object)(object)val4);
					if ((Object)(object)component != (Object)null)
					{
						Object.Destroy((Object)(object)component);
					}
				}
			}
			((Behaviour)val).enabled = false;
			RemoveDoorObject(val);
			SpawnDoorExplosion(val3);
		}

		private void CollectDoorParts(DoorLock door, List<Renderer> rends, List<Collider> cols, List<Animator> anims, bool log)
		{
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			List<Transform> list = new List<Transform>();
			list.Add(((Component)door).transform);
			AnimatedObjectTrigger component = ((Component)door).GetComponent<AnimatedObjectTrigger>();
			if ((Object)(object)component != (Object)null)
			{
				if (triggerAnimatorField == null)
				{
					triggerAnimatorField = typeof(AnimatedObjectTrigger).GetField("triggerAnimator", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				}
				Animator val = (Animator)((triggerAnimatorField != null) ? /*isinst with value type is only supported in some contexts*/: null);
				if ((Object)(object)val != (Object)null)
				{
					anims.Add(val);
					if (!list.Contains(((Component)val).transform))
					{
						list.Add(((Component)val).transform);
					}
				}
			}
			for (int i = 0; i < list.Count; i++)
			{
				Transform val2 = list[i];
				Renderer[] componentsInChildren = ((Component)val2).GetComponentsInChildren<Renderer>(true);
				foreach (Renderer val3 in componentsInChildren)
				{
					if (!IsDoorFrame(((Component)val3).transform) && !HasFrameAncestor(((Component)val3).transform, val2) && !rends.Contains(val3))
					{
						rends.Add(val3);
					}
				}
				Collider[] componentsInChildren2 = ((Component)val2).GetComponentsInChildren<Collider>(true);
				foreach (Collider val4 in componentsInChildren2)
				{
					if (!IsDoorFrame(((Component)val4).transform) && !HasFrameAncestor(((Component)val4).transform, val2) && !cols.Contains(val4))
					{
						cols.Add(val4);
					}
				}
			}
			Transform parent = ((Component)door).transform.parent;
			for (int k = 0; k < 2; k++)
			{
				if (!((Object)(object)parent != (Object)null))
				{
					break;
				}
				Renderer[] componentsInChildren = ((Component)parent).GetComponentsInChildren<Renderer>(true);
				Bounds bounds;
				foreach (Renderer val5 in componentsInChildren)
				{
					if (!rends.Contains(val5) && IsLooseDoorPart(((Component)val5).transform, parent, door))
					{
						bounds = val5.bounds;
						if (Vector3.Distance(((Bounds)(ref bounds)).center, ((Component)door).transform.position) < 4f)
						{
							rends.Add(val5);
						}
					}
				}
				Collider[] componentsInChildren2 = ((Component)parent).GetComponentsInChildren<Collider>(true);
				foreach (Collider val6 in componentsInChildren2)
				{
					if (!cols.Contains(val6) && IsLooseDoorPart(((Component)val6).transform, parent, door))
					{
						bounds = val6.bounds;
						if (Vector3.Distance(((Bounds)(ref bounds)).center, ((Component)door).transform.position) < 4f)
						{
							cols.Add(val6);
						}
					}
				}
				parent = parent.parent;
			}
			if (log)
			{
				for (int l = 0; l < rends.Count; l++)
				{
					Plugin.Logger.LogInfo((object)("Door break: removing renderer " + PathOf(((Component)rends[l]).transform)));
				}
				for (int m = 0; m < cols.Count; m++)
				{
					Plugin.Logger.LogInfo((object)("Door break: removing collider " + PathOf(((Component)cols[m]).transform)));
				}
			}
		}

		private static bool IsLooseDoorPart(Transform t, Transform scanRoot, DoorLock door)
		{
			DoorLock componentInParent = ((Component)t).GetComponentInParent<DoorLock>();
			if ((Object)(object)componentInParent != (Object)null && (Object)(object)componentInParent != (Object)(object)door)
			{
				return false;
			}
			bool result = false;
			Transform val = t;
			while ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)scanRoot)
			{
				string text = ((Object)val).name.ToLowerInvariant();
				if (text.Contains("frame"))
				{
					return false;
				}
				if (text.Contains("door"))
				{
					result = true;
				}
				val = val.parent;
			}
			return result;
		}

		private static string PathOf(Transform t)
		{
			string text = ((Object)t).name;
			while ((Object)(object)t.parent != (Object)null)
			{
				t = t.parent;
				text = ((Object)t).name + "/" + text;
			}
			return text;
		}

		private static void LogDoorHierarchy(DoorLock door)
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected O, but got Unknown
			Plugin.Logger.LogInfo((object)("Door break: DoorLock is at " + PathOf(((Component)door).transform)));
			Transform parent = ((Component)door).transform.parent;
			if (!((Object)(object)parent != (Object)null))
			{
				return;
			}
			foreach (Transform item in parent)
			{
				Transform val = item;
				Plugin.Logger.LogInfo((object)("Door break: sibling " + ((Object)val).name));
			}
		}

		private static bool HasFrameAncestor(Transform t, Transform doorRoot)
		{
			Transform parent = t.parent;
			while ((Object)(object)parent != (Object)null && (Object)(object)parent != (Object)(object)doorRoot)
			{
				if (IsDoorFrame(parent))
				{
					return true;
				}
				parent = parent.parent;
			}
			return false;
		}

		private void RemoveDoorObject(DoorLock door)
		{
			NetworkObject componentInParent = ((Component)door).GetComponentInParent<NetworkObject>();
			if ((Object)(object)componentInParent != (Object)null && (Object)(object)((Component)componentInParent).gameObject == (Object)(object)((Component)door).gameObject && componentInParent.IsSpawned)
			{
				if (((NetworkBehaviour)this).IsServer)
				{
					componentInParent.Despawn(true);
				}
			}
			else
			{
				Object.Destroy((Object)(object)((Component)door).gameObject);
			}
		}

		private static IEnumerator KnockbackRoutine(PlayerControllerB player, Vector3 velocity, float duration)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			float t = 0f;
			while (t < duration && !((Object)(object)player == (Object)null) && !player.isPlayerDead && !((Object)(object)player.thisController == (Object)null) && ((Collider)player.thisController).enabled && !player.inSpecialInteractAnimation && !player.isClimbingLadder)
			{
				float num = 1f - t / duration;
				player.thisController.Move(velocity * num * Time.deltaTime);
				t += Time.deltaTime;
				yield return null;
			}
		}

		private void SpawnDoorExplosion(Vector3 center)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			if (C.DoorExplosion.Value)
			{
				SpawnBlast(center, C.DoorExplosionFearRange.Value, C.DoorExplosionFearLevel.Value, C.DoorExplosionKnockbackRange.Value, C.DoorExplosionKnockbackForce.Value);
			}
		}

		private void SpawnBlast(Vector3 center, float fearRange, float fearLevel, float kbRange, float kbForce)
		{
			//IL_0055: 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_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_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: 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)
			StartOfRound instance = StartOfRound.Instance;
			if ((Object)(object)instance != (Object)null && (Object)(object)instance.explosionPrefab != (Object)null)
			{
				Transform val = (((Object)(object)RoundManager.Instance != (Object)null && (Object)(object)RoundManager.Instance.mapPropsContainer != (Object)null) ? RoundManager.Instance.mapPropsContainer.transform : null);
				GameObject obj = Object.Instantiate<GameObject>(instance.explosionPrefab, center, Quaternion.Euler(-90f, 0f, 0f), val);
				obj.SetActive(true);
				Object.Destroy((Object)(object)obj, 10f);
			}
			PlayerControllerB val2 = (((Object)(object)GameNetworkManager.Instance != (Object)null) ? GameNetworkManager.Instance.localPlayerController : null);
			if ((Object)(object)val2 == (Object)null || val2.isPlayerDead)
			{
				return;
			}
			float num = Vector3.Distance(((Component)val2).transform.position, center);
			if ((Object)(object)HUDManager.Instance != (Object)null)
			{
				if (num < 14f)
				{
					HUDManager.Instance.ShakeCamera((ScreenShakeType)1);
				}
				else if (num < 25f)
				{
					HUDManager.Instance.ShakeCamera((ScreenShakeType)2);
				}
			}
			if (num < fearRange && fearLevel > 0f)
			{
				val2.JumpToFearLevel(fearLevel, true);
			}
			if (kbForce > 0f && num < kbRange && !val2.inSpecialInteractAnimation && !val2.isClimbingLadder)
			{
				Vector3 val3 = ((Component)val2).transform.position - center;
				val3.y = 0f;
				if (((Vector3)(ref val3)).sqrMagnitude < 0.01f)
				{
					val3 = -((Component)this).transform.forward;
					val3.y = 0f;
				}
				Vector3 val4 = ((Vector3)(ref val3)).normalized + Vector3.up * 0.2f;
				val3 = ((Vector3)(ref val4)).normalized;
				float num2 = Mathf.Clamp01(1f - num / kbRange);
				float num3 = kbForce * (0.3f + 0.7f * num2);
				((MonoBehaviour)val2).StartCoroutine(KnockbackRoutine(val2, val3 * num3, 0.6f));
			}
		}

		private static bool IsDoorFrame(Transform t)
		{
			return ((Object)t).name.ToLowerInvariant().Contains("frame");
		}

		private void SendBreakDoor(Vector3 position)
		{
			//IL_0011: 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)
			if (((NetworkBehaviour)this).IsServer)
			{
				BreakDoorClientRpc(position);
			}
			else
			{
				BreakDoorServerRpc(position);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void BreakDoorServerRpc(Vector3 position)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			BreakDoorClientRpc(position);
		}

		[ClientRpc]
		private void BreakDoorClientRpc(Vector3 position)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			ApplyBreakDoor(position);
		}

		private void MarkChased()
		{
			lastChaseTime = Time.time;
			if (((NetworkBehaviour)this).IsServer)
			{
				MarkChasedClientRpc();
			}
			else
			{
				MarkChasedServerRpc();
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void MarkChasedServerRpc()
		{
			MarkChasedClientRpc();
		}

		[ClientRpc]
		private void MarkChasedClientRpc()
		{
			lastChaseTime = Time.time;
		}

		private bool IsExposedTo(PlayerControllerB p, Vector3 position, float halfAngle, float range)
		{
			//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_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: 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_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)p == (Object)null || (Object)(object)p.gameplayCamera == (Object)null)
			{
				return false;
			}
			Vector3 position2 = ((Component)p.gameplayCamera).transform.position;
			Vector3 val = position + Vector3.up * 1.5f;
			Vector3 val2 = val - position2;
			if (((Vector3)(ref val2)).magnitude > range)
			{
				return false;
			}
			if (Vector3.Angle(((Component)p.gameplayCamera).transform.forward, val2) > halfAngle)
			{
				return false;
			}
			return !Physics.Linecast(position2, val, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1);
		}

		private void TryStartStealth()
		{
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			if (!C.StealthEnabled.Value || isStealthing || Time.time - lastChaseTime < C.StealthIdleSeconds.Value || isCharging || attackingPlayer || carryingPlayerBody || fleaTimer > 0f || base.inSpecialAnimation || base.stunNormalizedTimer > 0f)
			{
				return;
			}
			if (stealthRollTimer > 0f)
			{
				stealthRollTimer -= base.AIIntervalTime;
				return;
			}
			stealthRollTimer = C.StealthRerollTime.Value;
			if ((Object)(object)StartOfRound.Instance == (Object)null || StartOfRound.Instance.allPlayerScripts == null)
			{
				return;
			}
			List<PlayerControllerB> list = new List<PlayerControllerB>();
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if ((Object)(object)val != (Object)null && val.isPlayerControlled && !val.isPlayerDead && val.isInsideFactory)
				{
					list.Add(val);
				}
			}
			if (list.Count != 0)
			{
				PlayerControllerB val2 = list[enemyRandom.Next(list.Count)];
				if (TryFindStealthSpot(val2, out var spot))
				{
					BeginStealth(val2, spot);
				}
			}
		}

		private bool TryFindStealthSpot(PlayerControllerB player, out Vector3 spot)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: 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_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			spot = Vector3.zero;
			if ((Object)(object)RoundManager.Instance == (Object)null || RoundManager.Instance.insideAINodes == null)
			{
				return false;
			}
			GameObject[] insideAINodes = RoundManager.Instance.insideAINodes;
			Vector3 origin = ((Component)player).transform.position;
			List<Vector3> list = new List<Vector3>();
			for (int i = 0; i < insideAINodes.Length; i++)
			{
				if (!((Object)(object)insideAINodes[i] == (Object)null))
				{
					Vector3 position = insideAINodes[i].transform.position;
					if (!(Vector3.Distance(position, origin) < C.StealthSpotMinDistance.Value) && !IsExposedTo(player, position, 180f, 80f))
					{
						list.Add(position);
					}
				}
			}
			if (list.Count == 0)
			{
				return false;
			}
			list.Sort(delegate(Vector3 a, Vector3 b)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_0019: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0023: Unknown result type (might be due to invalid IL or missing references)
				Vector3 val2 = a - origin;
				float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude;
				val2 = b - origin;
				return sqrMagnitude.CompareTo(((Vector3)(ref val2)).sqrMagnitude);
			});
			NavMeshHit val = default(NavMeshHit);
			if (NavMesh.SamplePosition(list[Mathf.Clamp(C.StealthSpotRank.Value - 1, 0, list.Count - 1)], ref val, 3f, -1))
			{
				spot = ((NavMeshHit)(ref val)).position;
				return true;
			}
			return false;
		}

		private void BeginStealth(PlayerControllerB target, Vector3 spot)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			if (base.currentSearch != null && base.currentSearch.inProgress)
			{
				((EnemyAI)this).StopSearch(base.currentSearch, true);
			}
			((Behaviour)base.agent).enabled = true;
			base.agent.Warp(spot);
			((Component)this).transform.position = spot;
			if (base.isOutside)
			{
				((EnemyAI)this).SetEnemyOutside(false);
			}
			((EnemyAI)this).SyncPositionToClients();
			isStealthing = true;
			stealthTarget = target;
			stealthRollTimer = 0f;
			base.agent.speed = C.StealthSpeed.Value;
			DoAnimation("startWalk");
			MuteSteps(mute: true);
			MuteVoice(mute: true);
			SendStealthState(active: true, (int)target.playerClientId);
		}

		private void EndStealth(bool returnToWander)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			isStealthing = false;
			stealthTarget = null;
			SendStealthState(active: false, -1);
			if (returnToWander)
			{
				stealthRollTimer = C.StealthRerollTime.Value;
				((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
				DoAnimation("startWalk");
				MuteSteps(mute: false);
				MuteVoice(mute: true);
			}
		}

		private void DoStealthTick()
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: 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)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			if (base.stunNormalizedTimer > 0f)
			{
				base.agent.speed = 0f;
				return;
			}
			PlayerControllerB val = stealthTarget;
			if ((Object)(object)val == (Object)null || val.isPlayerDead || !val.isPlayerControlled || !val.isInsideFactory)
			{
				EndStealth(returnToWander: true);
				return;
			}
			if (IsExposedTo(val, ((Component)this).transform.position, C.StealthSeenAngle.Value, C.StealthSightRange.Value))
			{
				EndStealth(returnToWander: false);
				base.targetPlayer = val;
				BeginChase();
				return;
			}
			if (IsExposedTo(val, ((Component)this).transform.position, C.StealthHoldAngle.Value, C.StealthSightRange.Value))
			{
				base.agent.speed = 0f;
				return;
			}
			base.agent.speed = C.StealthSpeed.Value;
			Vector3 position = ((Component)val).transform.position;
			Vector3 forward = ((Component)val.gameplayCamera).transform.forward;
			forward.y = 0f;
			if (((Vector3)(ref forward)).sqrMagnitude < 0.01f)
			{
				forward = ((Component)val).transform.forward;
				forward.y = 0f;
			}
			((Vector3)(ref forward)).Normalize();
			Vector3 val2 = ((Component)this).transform.position - position;
			val2.y = 0f;
			float magnitude = ((Vector3)(ref val2)).magnitude;
			Vector3 val3 = position;
			if (magnitude > C.StealthFlankRange.Value && Vector3.Dot(forward, val2 / magnitude) > 0f)
			{
				Vector3 val4 = Vector3.Cross(Vector3.up, forward);
				float num = ((Vector3.Dot(val4, val2) >= 0f) ? 1f : (-1f));
				NavMeshHit val5 = default(NavMeshHit);
				if (NavMesh.SamplePosition(position + val4 * num * C.StealthFlankOffset.Value - forward * 3f, ref val5, C.StealthFlankOffset.Value, -1))
				{
					val3 = ((NavMeshHit)(ref val5)).position;
				}
			}
			((EnemyAI)this).SetDestinationToPosition(val3, false);
		}

		private void SendStealthState(bool active, int targetId)
		{
			if (((NetworkBehaviour)this).IsServer)
			{
				StealthStateClientRpc(active, targetId);
			}
			else
			{
				StealthStateServerRpc(active, targetId);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void StealthStateServerRpc(bool active, int targetId)
		{
			StealthStateClientRpc(active, targetId);
		}

		[ClientRpc]
		private void StealthStateClientRpc(bool active, int targetId)
		{
			isStealthing = active;
			stealthTarget = ((active && targetId >= 0) ? StartOfRound.Instance.allPlayerScripts[targetId] : null);
			if (active)
			{
				ApplyMuteSteps(mute: true);
				ApplyMuteVoice(mute: true);
			}
		}

		private bool TryStartCharge()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			if (!CanCharge(out var direction))
			{
				return false;
			}
			StartCharge(direction);
			return true;
		}

		private void StartCharge(Vector3 dir)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			lastChargeTime = Time.time;
			if (isStealthing)
			{
				isStealthing = false;
				stealthTarget = null;
			}
			StartChargeServerRpc(dir);
			isCharging = true;
			chargeDirection = dir;
			chargeTimer = C.ChargeDuration.Value;
			chargeKilled.Clear();
		}

		private bool TryRandomChaseCharge()
		{
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			if (!C.ChargeEnabled.Value || !C.ChaseChargeEnabled.Value || (Object)(object)base.targetPlayer == (Object)null)
			{
				return false;
			}
			chaseChargeRollTimer += base.AIIntervalTime;
			if (chaseChargeRollTimer < 1f)
			{
				return false;
			}
			chaseChargeRollTimer -= 1f;
			if (Time.time - lastChargeTime < C.ChargeCooldown.Value)
			{
				return false;
			}
			if (isCharging || attackingPlayer || carryingPlayerBody || fleaTimer > 0f || base.inSpecialAnimation || base.stunNormalizedTimer > 0f)
			{
				return false;
			}
			if (!((EnemyAI)this).CheckLineOfSightForPosition(((Component)base.targetPlayer.gameplayCamera).transform.position, C.ViewAngle.Value, LosRange, -1f, (Transform)null))
			{
				return false;
			}
			if (enemyRandom.NextDouble() * 100.0 >= (double)C.ChaseChargeChance.Value)
			{
				return false;
			}
			Vector3 val = ((Component)base.targetPlayer).transform.position - ((Component)this).transform.position;
			val.y = 0f;
			if (((Vector3)(ref val)).sqrMagnitude < 0.01f)
			{
				return false;
			}
			StartCharge(((Vector3)(ref val)).normalized);
			return true;
		}

		private bool CanCharge(out Vector3 direction)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0290: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02de: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0333: Unknown result type (might be due to invalid IL or missing references)
			//IL_0343: Unknown result type (might be due to invalid IL or missing references)
			//IL_0348: Unknown result type (might be due to invalid IL or missing references)
			//IL_034a: Unknown result type (might be due to invalid IL or missing references)
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			//IL_0306: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0364: Unknown result type (might be due to invalid IL or missing references)
			//IL_0366: Unknown result type (might be due to invalid IL or missing references)
			//IL_0368: Unknown result type (might be due to invalid IL or missing references)
			//IL_0372: Unknown result type (might be due to invalid IL or missing references)
			//IL_037d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0382: Unknown result type (might be due to invalid IL or missing references)
			//IL_0387: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ab: Unknown result type (might be due to invalid IL or missing references)
			direction = Vector3.zero;
			if (!C.ChargeEnabled.Value)
			{
				return false;
			}
			bool value = C.DebugAlwaysCharge.Value;
			if (!value && Time.time - lastChargeTime < C.ChargeCooldown.Value)
			{
				return false;
			}
			if (isCharging || attackingPlayer || carryingPlayerBody || fleaTimer > 0f || base.inSpecialAnimation || base.stunNormalizedTimer > 0f)
			{
				return false;
			}
			if ((Object)(object)StartOfRound.Instance == (Object)null || StartOfRound.Instance.allPlayerScripts == null)
			{
				return false;
			}
			int num = 0;
			int num2 = 0;
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if (!((Object)(object)val == (Object)null))
				{
					if (val.isPlayerControlled || val.isPlayerDead)
					{
						num2++;
					}
					if (val.isPlayerControlled && !val.isPlayerDead)
					{
						num++;
					}
				}
			}
			int value2 = C.ChargeMinPlayers.Value;
			if (!value && (num < value2 || num2 < value2))
			{
				return false;
			}
			float value3 = C.ChargeDetectRange.Value;
			float num3 = Mathf.Cos(C.ChargeConeAngle.Value * (MathF.PI / 180f));
			Vector3 forward = ((Component)this).transform.forward;
			forward.y = 0f;
			((Vector3)(ref forward)).Normalize();
			List<PlayerControllerB> list = new List<PlayerControllerB>();
			foreach (PlayerControllerB val2 in allPlayerScripts)
			{
				if (!((Object)(object)val2 == (Object)null) && val2.isPlayerControlled && !val2.isPlayerDead)
				{
					Vector3 val3 = ((Component)val2).transform.position - ((Component)this).transform.position;
					val3.y = 0f;
					float magnitude = ((Vector3)(ref val3)).magnitude;
					if (!(magnitude > value3) && !(magnitude < 0.1f) && (value || !(Vector3.Dot(forward, val3 / magnitude) < num3)) && ((EnemyAI)this).CheckLineOfSightForPosition(((Component)val2.gameplayCamera).transform.position, C.ViewAngle.Value, LosRange, -1f, (Transform)null))
					{
						list.Add(val2);
					}
				}
			}
			if (value)
			{
				if (list.Count == 0)
				{
					return false;
				}
				PlayerControllerB val4 = list[0];
				float num4 = float.MaxValue;
				for (int k = 0; k < list.Count; k++)
				{
					float num5 = Vector3.Distance(((Component)this).transform.position, ((Component)list[k]).transform.position);
					if (num5 < num4)
					{
						num4 = num5;
						val4 = list[k];
					}
				}
				Vector3 val5 = ((Component)val4).transform.position - ((Component)this).transform.position;
				val5.y = 0f;
				if (((Vector3)(ref val5)).sqrMagnitude < 0.01f)
				{
					val5 = forward;
				}
				direction = ((Vector3)(ref val5)).normalized;
				return true;
			}
			for (int l = 0; l < list.Count; l++)
			{
				for (int m = l + 1; m < list.Count; m++)
				{
					Vector3 position = ((Component)list[l]).transform.position;
					Vector3 position2 = ((Component)list[m]).transform.position;
					if (Vector3.Distance(position, position2) <= C.ChargePairDistance.Value)
					{
						Vector3 val6 = (position + position2) * 0.5f - ((Component)this).transform.position;
						val6.y = 0f;
						if (!(((Vector3)(ref val6)).sqrMagnitude < 0.01f))
						{
							direction = ((Vector3)(ref val6)).normalized;
							return true;
						}
					}
				}
			}
			return false;
		}

		private void DoChargeTick()
		{
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: 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_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			if (base.stunNormalizedTimer > 0f)
			{
				EndCharge(slammed: false);
				return;
			}
			base.agent.speed = C.ChargeSpeed.Value;
			base.agent.acceleration = C.ChargeAcceleration.Value;
			chargeTimer -= base.AIIntervalTime;
			float num = C.ChargeDuration.Value - chargeTimer;
			Vector3 val = ((Component)this).transform.position + chargeDirection * 40f;
			bool flag = false;
			NavMeshHit val2 = default(NavMeshHit);
			if (NavMesh.Raycast(((Component)this).transform.position, val, ref val2, -1))
			{
				val = ((NavMeshHit)(ref val2)).position;
				flag = true;
			}
			((EnemyAI)this).SetDestinationToPosition(val, false);
			int num2;
			if (num > 0.8f)
			{
				Vector3 velocity = base.agent.velocity;
				num2 = ((((Vector3)(ref velocity)).magnitude < 1f) ? 1 : 0);
			}
			else
			{
				num2 = 0;
			}
			bool flag2 = flag && num > 0.3f && Vector3.Distance(((Component)this).transform.position, val) < 1.5f;
			if (((uint)num2 | (flag2 ? 1u : 0u)) != 0)
			{
				EndCharge(slammed: true);
			}
			else if (chargeTimer <= 0f)
			{
				EndCharge(slammed: false);
			}
		}

		private void EndCharge(bool slammed)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: 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_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			isCharging = false;
			chargeTimer = 0f;
			base.agent.acceleration = C.Acceleration.Value;
			if (slammed && C.ChargeSlamExplosion.Value)
			{
				Vector3 val = chargeDirection;
				val.y = 0f;
				SendChargeSlam(((Component)this).transform.position + ((Vector3)(ref val)).normalized * 1.2f + Vector3.up * 1.2f);
			}
			if (((NetworkBehaviour)this).IsServer)
			{
				EndChargeClientRpc();
			}
			else
			{
				EndChargeServerRpc();
			}
			PlayerControllerB val2 = chargeGrabVictim;
			if ((Object)(object)val2 != (Object)null && !val2.isPlayerDead && val2.isPlayerControlled)
			{
				chargeAttackDeadline = Time.time + 1.5f;
				AttackPlayerServerRpc((int)val2.playerClientId);
				return;
			}
			if ((Object)(object)val2 != (Object)null)
			{
				SendReleaseChargeHold();
			}
			ResumeAfterCharge();
		}

		private void ResumeAfterCharge()
		{
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)base.targetPlayer != (Object)null && (base.targetPlayer.isPlayerDead || !base.targetPlayer.isPlayerControlled))
			{
				base.targetPlayer = null;
			}
			if ((Object)(object)base.targetPlayer != (Object)null || FoundClosestPlayerInRange(C.SightRange.Value, C.SenseRange.Value))
			{
				BeginChase();
				return;
			}
			((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
			DoAnimation("startWalk");
			((EnemyAI)this).SwitchToBehaviourState(0);
			MuteVoice(mute: true);
			MuteSteps(mute: false);
		}

		[ServerRpc(RequireOwnership = false)]
		private void EndChargeServerRpc()
		{
			EndChargeClientRpc();
		}

		[ClientRpc]
		private void EndChargeClientRpc()
		{
			isCharging = false;
			chargeTimer = 0f;
			lastChaseTime = Time.time;
		}

		[ServerRpc(RequireOwnership = false)]
		private void StartChargeServerRpc(Vector3 direction)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			chargeHitServer.Clear();
			StartChargeClientRpc(direction);
		}

		[ClientRpc]
		private void StartChargeClientRpc(Vector3 direction)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)chargeGrabVictim != (Object)null)
			{
				ReleaseChargeHold();
			}
			lastChargeTime = Time.time;
			lastChaseTime = Time.time;
			isStealthing = false;
			stealthTarget = null;
			chargeDirection = direction;
			chargeTimer = C.ChargeDuration.Value;
			chargeKilled.Clear();
			isCharging = true;
			ApplyAnimation("chasePlayer");
			ApplyMuteSteps(mute: true);
			ApplyMuteVoice(mute: false);
		}

		[ServerRpc(RequireOwnership = false)]
		private void ChargeHitServerRpc(int playerObjectId)
		{
			if (isCharging && chargeHitServer.Add(playerObjectId))
			{
				ChargeHitClientRpc(playerObjectId);
			}
		}

		[ClientRpc]
		private void ChargeHitClientRpc(int playerObjectId)
		{
			//IL_0048: 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)
			PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[playerObjectId];
			if (!((Object)(object)val == (Object)null) && !((Object)(object)val != (Object)(object)GameNetworkManager.Instance.localPlayerController) && !val.isPlayerDead)
			{
				val.DamagePlayer(C.ChargeDamage.Value, true, true, (CauseOfDeath)6, 0, false, default(Vector3));
				if (val.isPlayerDead)
				{
					ChargeBodyServerRpc(playerObjectId);
				}
				else
				{
					ChargeGrabServerRpc(playerObjectId);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void ChargeBodyServerRpc(int playerObjectId)
		{
			ChargeBodyClientRpc(playerObjectId);
		}

		[ClientRpc]
		private void ChargeBodyClientRpc(int playerObjectId)
		{
			PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[playerObjectId];
			if ((Object)(object)val != (Object)null && (Object)(object)assParent != (Object)null)
			{
				((MonoBehaviour)this).StartCoroutine(AttachChargedBody(val));
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void ChargeGrabServerRpc(int playerObjectId)
		{
			if (C.ChargeGrabSurvivors.Value && isCharging && !((Object)(object)chargeGrabVictim != (Object)null) && !attackingPlayer && !carryingPlayerBody)
			{
				ChargeGrabClientRpc(playerObjectId);
			}
		}

		[ClientRpc]
		private void ChargeGrabClientRpc(int playerObjectId)
		{
			//IL_0049: 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_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[playerObjectId];
			if (!((Object)(object)val == (Object)null) && !val.isPlayerDead)
			{
				chargeGrabVictim = val;
				base.inSpecialAnimationWithPlayer = val;
				val.inAnimationWithEnemy = (EnemyAI)(object)this;
				val.inSpecialInteractAnimation = true;
				val.snapToServerPosition = true;
				val.DropAllHeldItems(true, false, false, false, default(Vector3), default(Vector3), default(Vector3), default(Vector3), default(Vector3));
				val.voiceMuffledByEnemy = true;
				isChargeHolding = true;
			}
		}

		private void ReleaseChargeHold()
		{
			PlayerControllerB val = chargeGrabVictim;
			isChargeHolding = false;
			chargeGrabVictim = null;
			if ((Object)(object)val != (Object)null)
			{
				val.inSpecialInteractAnimation = false;
				val.snapToServerPosition = false;
				val.inAnimationWithEnemy = null;
				val.voiceMuffledByEnemy = false;
				if ((Object)(object)base.inSpecialAnimationWithPlayer == (Object)(object)val)
				{
					base.inSpecialAnimationWithPlayer = null;
				}
			}
		}

		private void SendReleaseChargeHold()
		{
			if (((NetworkBehaviour)this).IsServer)
			{
				ReleaseChargeHoldClientRpc();
			}
			else
			{
				ReleaseChargeHoldServerRpc();
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void ReleaseChargeHoldServerRpc()
		{
			ReleaseChargeHoldClientRpc();
		}

		[ClientRpc]
		private void ReleaseChargeHoldClientRpc()
		{
			ReleaseChargeHold();
		}

		private void SendChargeSlam(Vector3 position)
		{
			//IL_0011: 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)
			if (((NetworkBehaviour)this).IsServer)
			{
				ChargeSlamClientRpc(position);
			}
			else
			{
				ChargeSlamServerRpc(position);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void ChargeSlamServerRpc(Vector3 position)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			ChargeSlamClientRpc(position);
		}

		[ClientRpc]
		private void ChargeSlamClientRpc(Vector3 position)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			SpawnBlast(position, C.ChargeSlamFearRange.Value, C.ChargeSlamFearLevel.Value, C.ChargeSlamKnockbackRange.Value, C.ChargeSlamKnockbackForce.Value);
		}

		private IEnumerator AttachChargedBody(PlayerControllerB victim)
		{
			float waited = 0f;
			while (waited < 2f && (Object)(object)victim != (Object)null && (Object)(object)victim.deadBody == (Object)null)
			{
				waited += Time.deltaTime;
				yield return null;
			}
			if (!((Object)(object)victim == (Object)null) && !((Object)(object)victim.deadBody == (Object)null) && !((Object)(object)assParent == (Object)null))
			{
				DeadBodyInfo body = victim.deadBody;
				body.attachedTo = assParent;
				body.attachedLimb = body.bodyParts[0];
				body.matchPositionExactly = true;
				yield return (object)new WaitForSeconds(C.ChargeBodyHoldTime.Value);
				if ((Object)(object)body != (Object)null && (Object)(object)body.attachedTo == (Object)(object)assParent)
				{
					body.matchPositionExactly = false;
					body.attachedTo = null;
				}
			}
		}

		private IEnumerator DragPhase()
		{
			isDragging = true;
			dragSyncPos = ((Component)this).transform.position;
			bool canMove = false;
			float dragSpeed = C.DragSpeed.Value;
			float dragDuration = C.DragDuration.Value;
			if (((NetworkBehaviour)this).IsOwner)
			{
				NavMeshHit val = default(NavMeshHit);
				if (NavMesh.SamplePosition(((Component)this).transform.position, ref val, 3f, -1))
				{
					((Behaviour)base.agent).enabled = true;
					base.agent.Warp(((NavMeshHit)(ref val)).position);
					canMove = base.agent.isOnNavMesh;
				}
				if (canMove)
				{
					base.agent.speed = dragSpeed;
					base.agent.SetDestination(PickDragTarget());
				}
			}
			float t = 0f;
			float syncTimer = 0f;
			while (t < dragDuration && !base.isEnemyDead && !((Object)(object)base.inSpecialAnimationWithPlayer == (Object)null) && !base.inSpecialAnimationWithPlayer.isPlayerDead && !isInterrupted)
			{
				if (((NetworkBehaviour)this).IsOwner && canMove)
				{
					base.agent.speed = dragSpeed;
					if (!base.agent.pathPending && base.agent.remainingDistance <= 1f)
					{
						base.agent.SetDestination(PickDragTarget());
					}
					syncTimer += Time.deltaTime;
					if (syncTimer >= 0.1f)
					{
						syncTimer = 0f;
						SendDragPos(((Component)this).transform.position, final: false);
					}
				}
				t += Time.deltaTime;
				yield return null;
			}
			if (((NetworkBehaviour)this).IsOwner && canMove)
			{
				base.agent.ResetPath();
				((Behaviour)base.agent).enabled = false;
				SendDragPos(((Component)this).transform.position, final: true);
			}
			isDragging = false;
		}

		private Vector3 PickDragTarget()
		{
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			GameObject[] array = null;
			if ((Object)(object)RoundManager.Instance != (Object)null)
			{
				array = (base.isOutside ? RoundManager.Instance.outsideAINodes : RoundManager.Instance.insideAINodes);
			}
			if (array != null && array.Length != 0)
			{
				NavMeshHit val2 = default(NavMeshHit);
				for (int i = 0; i < 8; i++)
				{
					GameObject val = array[enemyRandom.Next(array.Length)];
					if (!((Object)(object)val == (Object)null) && NavMesh.SamplePosition(val.transform.position, ref val2, 3f, -1))
					{
						return ((NavMeshHit)(ref val2)).position;
					}
				}
			}
			Vector3 val3 = Quaternion.Euler(0f, (float)enemyRandom.Next(360), 0f) * Vector3.forward;
			return ((Component)this).transform.position + val3 * 15f;
		}

		internal void DragLateUpdate()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: 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_00e9: 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)
			if (!isDragging && !isChargeHolding)
			{
				return;
			}
			if (isDragging && !((NetworkBehaviour)this).IsOwner)
			{
				((Component)this).transform.position = Vector3.Lerp(((Component)this).transform.position, dragSyncPos, 12f * Time.deltaTime);
			}
			PlayerControllerB inSpecialAnimationWithPlayer = base.inSpecialAnimationWithPlayer;
			if ((Object)(object)inSpecialAnimationWithPlayer != (Object)null && !inSpecialAnimationWithPlayer.isPlayerDead)
			{
				Vector3 position = ((Component)this).transform.position + ((Component)this).transform.forward * 0.8f;
				position.y = ((Component)this).transform.position.y;
				if (((NetworkBehaviour)inSpecialAnimationWithPlayer).IsOwner && (Object)(object)inSpecialAnimationWithPlayer.thisController != (Object)null)
				{
					((Collider)inSpecialAnimationWithPlayer.thisController).enabled = false;
					((Component)inSpecialAnimationWithPlayer).transform.position = position;
					((Collider)inSpecialAnimationWithPlayer.thisController).enabled = true;
				}
				else
				{
					((Component)inSpecialAnimationWithPlayer).transform.position = position;
				}
			}
		}

		private void SendDragPos(Vector3 pos, bool final)
		{
			//IL_0012: 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)
			if (((NetworkBehaviour)this).IsServer)
			{
				DragSyncClientRpc(pos, final);
			}
			else
			{
				DragSyncServerRpc(pos, final);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void DragSyncServerRpc(Vector3 pos, bool final)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			DragSyncClientRpc(pos, final);
		}

		[ClientRpc]
		private void DragSyncClientRpc(Vector3 pos, bool final)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			dragSyncPos = pos;
			if (!((NetworkBehaviour)this).IsOwner && final)
			{
				((Component)this).transform.position = pos;
			}
		}

		private bool FoundBrackenInMap()
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			flowermanTarget = null;
			float num = 2000f;
			if ((Object)(object)RoundManager.Instance == (Object)null || RoundManager.Instance.SpawnedEnemies == null)
			{
				return false;
			}
			for (int i = 0; i < RoundManager.Instance.SpawnedEnemies.Count; i++)
			{
				EnemyAI obj = RoundManager.Instance.SpawnedEnemies[i];
				FlowermanAI val = (FlowermanAI)(object)((obj is FlowermanAI) ? obj : null);
				if ((Object)(object)val != (Object)null && !((EnemyAI)val).isEnemyDead)
				{
					float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position);
					if (num2 < num)
					{
						num = num2;
						flowermanTarget = val;
					}
				}
			}
			return (Object)(object)flowermanTarget != (Object)null;
		}

		private bool FoundClosestPlayerInRange(float range, float senseRange)
		{
			//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_0084: Unknown result type (might be due to invalid IL or missing references)
			base.targetPlayer = null;
			float num = float.MaxValue;
			if ((Object)(object)StartOfRound.Instance == (Object)null || StartOfRound.Instance.allPlayerScripts == null)
			{
				return false;
			}
			for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++)
			{
				PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[i];
				if ((Object)(object)val == (Object)null || !val.isPlayerControlled || val.isPlayerDead)
				{
					continue;
				}
				float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position);
				if (num2 < range && ((EnemyAI)this).CheckLineOfSightForPosition(((Component)val.gameplayCamera).transform.position, C.ViewAngle.Value, LosRange, -1f, (Transform)null))
				{
					if (num2 < num)
					{
						num = num2;
						base.targetPlayer = val;
					}
				}
				else if (num2 < senseRange && num2 < num)
				{
					num = num2;
					base.targetPlayer = val;
				}
			}
			return (Object)(object)base.targetPlayer != (Object)null;
		}

		[ServerRpc(RequireOwnership = false)]
		public void DropPlayerBodyServerRpc()
		{
			DropPlayerBodyClientRpc();
		}

		[ClientRpc]
		public void DropPlayerBodyClientRpc()
		{
			DropPlayerBody();
		}

		private void DropPlayerBody()
		{
			if (carryingPlayerBody)
			{
				carryingPlayerBody = false;
				if ((Object)(object)bodyBeingCarried != (Object)null)
				{
					bodyBeingCarried.matchPositionExactly = false;
					bodyBeingCarried.attachedTo = null;
					bodyBeingCarried = null;
				}
			}
		}

		private IEnumerator FleaPlayer(bool carryingBody = true)
		{
			if (attackingPlayerCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(attackingPlayerCoroutine);
			}
			base.inSpecialAnimation = false;
			attackingPlayer = false;
			DoAnimation("startWalk");
			MuteVoice(mute: true);
			MuteSteps(mute: true);
			fleaTimer = C.FleeDuration.Value;
			if ((Object)(object)base.inSpecialAnimationWithPlayer != (Object)null)
			{
				base.inSpecialAnimationWithPlayer.inSpecialInteractAnimation = false;
				base.inSpecialAnimationWithPlayer.snapToServerPosition = false;
				base.inSpecialAnimationWithPlayer.inAnimationWithEnemy = null;
				base.inSpecialAnimationWithPlayer.voiceMuffledByEnemy = false;
				if (carryingBody && (Object)(object)base.inSpecialAnimationWithPlayer.deadBody != (Object)null)
				{
					bodyBeingCarried = base.inSpecialAnimationWithPlayer.deadBody;
					bodyBeingCarried.attachedTo = assParent;
					bodyBeingCarried.attachedLimb = base.inSpecialAnimationWithPlayer.deadBody.bodyParts[0];
					bodyBeingCarried.matchPositionExactly = true;
					carryingPlayerBody = true;
				}
			}
			if (carryingBody)
			{
				yield return (object)new WaitForSeconds(1f);
			}
			if (((NetworkBehaviour)this).IsOwner)
			{
				((Behaviour)base.agent).enabled = true;
				base.isClientCalculatingAI = true;
			}
			((EnemyAI)this).SwitchToBehaviourState(5);
			((EnemyAI)this).SetDestinationToPosition(spawnPos, false);
		}

		[ServerRpc(RequireOwnership = false)]
		private void AttackPlayerServerRpc(int playerObjectId)
		{
			//IL_0061: 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_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			if (!attackingPlayer && !carryingPlayerBody)
			{
				isInterrupted = false;
				attackingPlayer = true;
				base.inSpecialAnimation = true;
				base.isClientCalculatingAI = false;
				base.inSpecialAnimationWithPlayer = StartOfRound.Instance.allPlayerScripts[playerObjectId];
				base.inSpecialAnimationWithPlayer.inAnimationWithEnemy = (EnemyAI)(object)this;
				((Component)this).transform.position = new Vector3(((Component)base.inSpecialAnimationWithPlayer).transform.position.x, ((Component)base.inSpecialAnimationWithPlayer).transform.position.y + 0.5f, ((Component)base.inSpecialAnimationWithPlayer).transform.position.z);
				AttackPlayerClientRpc(playerObjectId, C.ExperimentalDragGrab.Value);
			}
		}

		[ClientRpc]
		private void AttackPlayerClientRpc(int playerObjectId, bool drag)
		{
			//IL_006f: 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_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: 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_00e8: 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_00f1: 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_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			isChargeHolding = false;
			chargeGrabVictim = null;
			chargeAttackDeadline = 0f;
			isStealthing = false;
			stealthTarget = null;
			lastChaseTime = Time.time;
			useDragGrab = drag;
			isInterrupted = false;
			base.inSpecialAnimationWithPlayer = StartOfRound.Instance.allPlayerScripts[playerObjectId];
			base.inSpecialAnimationWithPlayer.inAnimationWithEnemy = (EnemyAI)(object)this;
			((Component)this).transform.position = new Vector3(((Component)base.inSpecialAnimationWithPlayer).transform.position.x, ((Component)base.inSpecialAnimationWithPlayer).transform.position.y + 0.5f, ((Component)base.inSpecialAnimationWithPlayer).transform.position.z);
			((EnemyAI)this).SyncPositionToClients();
			base.inSpecialAnimationWithPlayer.SyncBodyPositionWithClients();
			base.inSpecialAnimationWithPlayer.DropAllHeldItems(true, false, false, false, default(Vector3), default(Vector3), default(Vector3), default(Vector3), default(Vector3));
			base.inSpecialAnimationWithPlayer.voiceMuffledByEnemy = true;
			attackingPlayer = true;
			base.inSpecialAnimation = true;
			((Behaviour)base.agent).enabled = false;
			base.inSpecialAnimationWithPlayer.inSpecialInteractAnimation = true;
			base.inSpecialAnimationWithPlayer.snapToServerPosition = true;
			Vector3 val = ((!((NetworkBehaviour)base.inSpecialAnimationWithPlayer).IsOwner) ? ((Component)base.inSpecialAnimationWithPlayer).transform.parent.TransformPoint(base.inSpecialAnimationWithPlayer.serverPlayerPosition) : ((Component)base.inSpecialAnimationWithPlayer).transform.position);
			Vector3 position = ((Component)this).transform.position;
			position.y = ((Component)base.inSpecialAnimationWithPlayer).transform.position.y;
			playerRay = new Ray(val, position - ((Component)base.inSpecialAnimationWithPlayer).transform.position);
			if ((Object)(object)turnCompass != (Object)null)
			{
				turnCompass.LookAt(val);
				position = ((Component)this).transform.eulerAngles;
				position.y = turnCompass.eulerAngles.y;
				((Component)this).transform.eulerAngles = position;
			}
			if (attackingPlayerCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(attackingPlayerCoroutine);
			}
			attackingPlayerCoroutine = ((MonoBehaviour)this).StartCoroutine(AttackPlayer());
		}

		private IEnumerator AttackPlayer()
		{
			Vector3 endPosition = ((Ray)(ref playerRay)).GetPoint(1f);
			if (endPosition.y < -80f)
			{
				for (int i = 0; i < 15; i++)
				{
					yield return null;
				}
				((Component)this).transform.position = endPosition;
			}
			if (useDragGrab)
			{
				ApplyAnimation("chasePlayer");
			}
			else
			{
				DoAnimation("attack");
			}
			((EnemyAI)this).SwitchToBehaviourState(3);
			MuteSteps(mute: true);
			MuteVoice(mute: true);
			yield return (object)new WaitForSeconds(0.1f);
			InterruptNetwork(interrupt: false);
			int hitCount = 0;
			if ((Object)(object)base.inSpecialAnimationWithPlayer == (Object)null)
			{
				yield break;
			}
			if (useDragGrab)
			{
				yield return ((MonoBehaviour)this).StartCoroutine(DragPhase());
				if ((Object)(object)base.inSpecialAnimationWithPlayer == (Object)null || (isInterrupted && (Object)(object)base.inSpecialAnimationWithPlayer.deadBody == (Object)null))
				{
					((MonoBehaviour)this).StartCoroutine(FleaPlayer(carryingBody: false));
					yield break;
				}
				DoAnimation("attack");
			}
			int maxHits = C.AttackMaxHits.Value;
			while (hitCount < maxHits || (Object)(object)base.inSpecialAnimationWithPlayer.deadBody == (Object)null || !isInterrupted)
			{
				yield return (object)new WaitForSeconds(C.AttackTickInterval.Value);
				base.inSpecialAnimationWithPlayer.DamagePlayer(C.AttackDamage.Value, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
				hitCount++;
				if (hitCount >= maxHits || (Object)(object)base.inSpecialAnimationWithPlayer.deadBody != (Object)null || isInterrupted)
				{
					break;
				}
				yield return null;
			}
			if ((Object)(object)base.inSpecialAnimationWithPlayer == (Object)null || (Object)(object)base.inSpecialAnimationWithPlayer.deadBody == (Object)null)
			{
				((MonoBehaviour)this).StartCoroutine(FleaPlayer(carryingBody: false));
				yield break;
			}
			base.inSpecialAnimationWithPlayer.snapToServerPosition = false;
			base.inSpecialAnimationWithPlayer.deadBody.causeOfDeath = (CauseOfDeath)5;
			base.inSpecialAnimationWithPlayer.deadBody.bodyBleedingHeavily = true;
			((MonoBehaviour)this).StartCoroutine(FleaPlayer());
		}

		[ServerRpc(RequireOwnership = false)]
		private void AttackBrackenServerRpc(int flowermanId)
		{
			AttackBrackenClientRpc(flowermanId);
		}

		[ClientRpc]
		private void AttackBrackenClientRpc(int flowermanId)
		{
		}

		private IEnumerator AttackBracken()
		{
			((EnemyAI)this).SwitchToBehaviourState(4);
			MuteSteps(mute: true);
			MuteVoice(mute: false);
			yield return (object)new WaitForSeconds(4f);
			((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
			DoAnimation("attack");
			((EnemyAI)this).SwitchToBehaviourState(0);
			MuteVoice(mute: true);
			MuteSteps(mute: false);
		}

		public override void OnCollideWithEnemy(Collider other, EnemyAI collidedEnemy = null)
		{
			((EnemyAI)this).OnCollideWithEnemy(other, collidedEnemy);
			if (C.HuntBrackens.Value)
			{
				FlowermanAI componentInParent = ((Component)other).GetComponentInParent<FlowermanAI>();
				if ((Object)(object)componentInParent != (Object)null && !((EnemyAI)componentInParent).isEnemyDead)
				{
					((EnemyAI)componentInParent).KillEnemyOnOwnerClient(false);
					((MonoBehaviour)this).StartCoroutine(AttackBracken());
				}
			}
		}

		public override void OnCollideWithPlayer(Collider other)
		{
			((EnemyAI)this).OnCollideWithPlayer(other);
			if (isCharging)
			{
				PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, false, false);
				if ((Object)(object)val != (Object)null && chargeKilled.Add((int)val.playerClientId))
				{
					ChargeHitServerRpc((int)val.playerClientId);
				}
			}
			else
			{
				PlayerControllerB val2 = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, attackingPlayer || carryingPlayerBody || fleaTimer > 0f, false);
				if ((Object)(object)val2 != (Object)null && ((NetworkBehaviour)this).IsOwner)
				{
					AttackPlayerServerRpc((int)val2.playerClientId);
				}
			}
		}

		public override void KillEnemy(bool destroy = false)
		{
			if ((Object)(object)base.creatureVoice != (Object)null)
			{
				base.creatureVoice.Stop();
			}
			if ((Object)(object)base.creatureSFX != (Object)null)
			{
				base.creatureSFX.Stop();
			}
			if ((Object)(object)stepSound != (Object)null)
			{
				stepSound.Stop();
			}
			if ((Object)(object)base.creatureAnimator != (Object)null)
			{
				base.creatureAnimator.SetLayerWeight(2, 0f);
			}
			((EnemyAI)this).KillEnemy(false);
			ReleaseChargeHold();
			isDragging = false;
			isStealthing = false;
			stealthTarget = null;
			base.agent.acceleration = C.Acceleration.Value;
			if (carryingPlayerBody)
			{
				carryingPlayerBody = false;
				if ((Object)(object)bodyBeingCarried != (Object)null)
				{
					bodyBeingCarried.matchPositionExactly = false;
					bodyBeingCarried.attachedTo = null;
				}
			}
			if (attackingPlayer && (Object)(object)base.inSpecialAnimationWithPlayer != (Object)null)
			{
				base.inSpecialAnimationWithPlayer.inSpecialInteractAnimation = false;
				base.inSpecialAnimationWithPlayer.snapToServerPosition = false;
				base.inSpecialAnimationWithPlayer.voiceMuffledByEnemy = false;
			}
		}

		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)
			{
				return;
			}
			isStealthing = false;
			stealthTarget = null;
			if (!isInterrupted)
			{
				InterruptNetwork(interrupt: true);
			}
			if (base.currentBehaviourStateIndex == 0 && (Object)(object)playerWhoHit != (Object)null)
			{
				base.targetPlayer = playerWhoHit;
				chaseGraceTimer = C.ChaseGraceTime.Value;
				chaseChargeRollTimer = 0f;
				MarkChased();
				DoAnimation("chasePlayer");
				((EnemyAI)this).SwitchToBehaviourState(1);
				MuteVoice(mute: false);
				MuteSteps(mute: true);
				SetTargetPlayerServerRpc((int)playerWhoHit.playerClientId);
			}
			base.enemyHP -= force;
			if (((NetworkBehaviour)this).IsOwner && base.enemyHP <= 0)
			{
				if (base.searchCoroutine != null)
				{
					((MonoBehaviour)this).StopCoroutine(base.searchCoroutine);
				}
				if (attackingPlayerCoroutine != null)
				{
					((MonoBehaviour)this).StopCoroutine(attackingPlayerCoroutine);
				}
				MuteVoice(mute: false);
				MuteSteps(mute: true);
				((EnemyAI)this).KillEnemyOnOwnerClient(false);
			}
		}

		private void DoAnimation(string animationName)
		{
			if (((NetworkBehaviour)this).IsServer)
			{
				DoAnimationClientRpc(animationName);
			}
			else
			{
				DoAnimationServerRpc(animationName);
			}
		}

		private void MuteVoice(bool mute)
		{
			if (((NetworkBehaviour)this).IsServer)
			{
				MuteVoiceClientRpc(mute);
			}
			else
			{
				MuteVoiceServerRpc(mute);
			}
		}

		private void MuteSteps(bool mute)
		{
			if (((NetworkBehaviour)this).IsServer)
			{
				MuteStepsClientRpc(mute);
			}
			else
			{
				MuteStepsServerRpc(mute);
			}
		}

		private void InterruptNetwork(bool interrupt)
		{
			if (((NetworkBehaviour)this).IsServer)
			{
				InterruptClientRpc(interrupt);
			}
			else
			{
				InterruptServerRpc(interrupt);
			}
		}

		private void ApplyAnimation(string animationName)
		{
			if ((Object)(object)base.creatureAnimator != (Object)null)
			{
				base.creatureAnimator.SetTrigger(animationName);
			}
		}

		private void ApplyMuteVoice(bool mute)
		{
			if ((Object)(object)base.creatureVoice != (Object)null)
			{
				base.creatureVoice.mute = mute;
			}
		}

		private void ApplyMuteSteps(bool mute)
		{
			if ((Object)(object)stepSound != (Object)null)
			{
				stepSound.mute = mute;
			}
		}

		private void ApplyDeathSound()
		{
			if ((Object)(object)base.creatureSFX != (Object)null && (Object)(object)base.dieSFX != (Object)null)
			{
				base.creatureSFX.PlayOneShot(base.dieSFX);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void DoAnimationServerRpc(string animationName)
		{
			DoAnimationClientRpc(animationName);
		}

		[ServerRpc(RequireOwnership = false)]
		public void MuteVoiceServerRpc(bool mute)
		{
			MuteVoiceClientRpc(mute);
		}

		[ServerRpc(RequireOwnership = false)]
		public void MuteStepsServerRpc(bool mute)
		{
			MuteStepsClientRpc(mute);
		}

		[ServerRpc(RequireOwnership = false)]
		public void InterruptServerRpc(bool interrupt)
		{
			InterruptClientRpc(interrupt);
		}

		[ClientRpc]
		public void InterruptClientRpc(bool interrupt)
		{
			isInterrupted = interrupt;
		}

		[ServerRpc(RequireOwnership = false)]
		public void StartSearchServerRpc(Vector3 pos)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			StartSearchClientRpc(pos);
		}

		[ClientRpc]
		public void StartSearchClientRpc(Vector3 pos)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).StartSearch(pos, (AISearchRoutine)null);
		}

		[ServerRpc(RequireOwnership = false)]
		public void SetTargetPlayerServerRpc(int playerObjectId)
		{
			SetTargetPlayerClientRpc(playerObjectId);
		}

		[ClientRpc]
		public void SetTargetPlayerClientRpc(int playerObjectId)
		{
			base.targetPlayer = StartOfRound.Instance.allPlayerScripts[playerObjectId];
		}

		[ClientRpc]
		public void PlayDeathSoundClientRpc()
		{
			ApplyDeathSound();
		}

		[ClientRpc]
		public void MuteVoiceClientRpc(bool mute)
		{
			ApplyMuteVoice(mute);
		}

		[ClientRpc]
		public void MuteStepsClientRpc(bool mute)
		{
			ApplyMuteSteps(mute);
		}

		[ClientRpc]
		public void DoAnimationClientRpc(string animationName)
		{
			ApplyAnimation(animationName);
		}
	}
	internal class BrolyDragFollower : MonoBehaviour
	{
		public BrolyAI brolyAI;

		private void LateUpdate()
		{
			if ((Object)(object)brolyAI != (Object)null)
			{
				brolyAI.DragLateUpdate();
			}
		}
	}
	[BepInPlugin("Stash.BrolyCulo", "BrolyCulo", "1.3.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		public static AssetBundle ModAssets;

		internal static PluginConfig BoundConfig { get; private set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			BoundConfig = new PluginConfig(((BaseUnityPlugin)this).Config);
			InitializeNetworkBehaviours();
			string path = "modassets_broly";
			ModAssets = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), path));
			if ((Object)(object)ModAssets == (Object)null)
			{
				Logger.LogError((object)"Failed to load custom assets.");
				return;
			}
			EnemyType obj = ModAssets.LoadAsset<EnemyType>("BrolyCulo");
			TerminalNode val = ModAssets.LoadAsset<TerminalNode>("BrolyCuloTN");
			TerminalKeyword val2 = ModAssets.LoadAsset<TerminalKeyword>("BrolyCuloTK");
			NetworkPrefabs.RegisterNetworkPrefab(obj.enemyPrefab);
			Enemies.RegisterEnemy(obj, BoundConfig.SpawnWeight.Value, (LevelTypes)(-1), (SpawnType)0, val, val2);
			Logger.LogInfo((object)"Plugin Stash.BrolyCulo is loaded!");
			Logger.LogInfo((object)"KAKAROOOOOOOOT!");
		}

		private static void InitializeNetworkBehaviours()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			for (int i = 0; i < types.Length; i++)
			{
				MethodInfo[] methods = types[i].GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				foreach (MethodInfo methodInfo in methods)
				{
					if (methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false).Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "Stash.BrolyCulo";

		public const string PLUGIN_NAME = "BrolyCulo";

		public const string PLUGIN_VERSION = "1.1";
	}
}
namespace CustomEnnemies.Configuration
{
	public class PluginConfig
	{
		public ConfigEntry<int> SpawnWeight;

		public ConfigEntry<int> Health;

		public ConfigEntry<float> WanderSpeed;

		public ConfigEntry<float> ChaseSpeed;

		public ConfigEntry<float> BrackenChaseSpeed;

		public ConfigEntry<float> FleeSpeed;

		public ConfigEntry<float> Acceleration;

		public ConfigEntry<float> AngularSpeed;

		public ConfigEntry<float> ChaseOvershoot;

		public ConfigEntry<float> SightRange;

		public ConfigEntry<float> ChaseSightRange;

		public ConfigEntry<float> ViewAngle;

		public ConfigEntry<float> SenseRange;

		public ConfigEntry<float> ChaseGraceTime;

		public ConfigEntry<int> AttackDamage;

		public ConfigEntry<float> AttackTickInterval;

		public ConfigEntry<int> AttackMaxHits;

		public ConfigEntry<float> FleeDuration;

		public ConfigEntry<bool> HuntBrackens;

		public ConfigEntry<bool> ExperimentalDragGrab;

		public ConfigEntry<float> DragDuration;

		public ConfigEntry<float> DragSpeed;

		public ConfigEntry<bool> ChargeEnabled;

		public ConfigEntry<float> ChargeCooldown;

		public ConfigEntry<float> ChargeSpeed;

		public ConfigEntry<float> ChargeAcceleration;

		public ConfigEntry<float> ChargeDuration;

		public ConfigEntry<float> ChargeDetectRange;

		public ConfigEntry<float> ChargePairDistance;

		public ConfigEntry<float> ChargeConeAngle;

		public ConfigEntry<int> ChargeMinPlayers;

		public ConfigEntry<int> ChargeDamage;

		public ConfigEntry<float> ChargeBodyHoldTime;

		public ConfigEntry<bool> ChaseChargeEnabled;

		public ConfigEntry<float> ChaseChargeChance;

		public ConfigEntry<bool> ChargeGrabSurvivors;

		public ConfigEntry<bool> ChargeSlamExplosion;

		public ConfigEntry<float> ChargeSlamKnockbackRange;

		public ConfigEntry<float> ChargeSlamKnockbackForce;

		public ConfigEntry<float> ChargeSlamFearRange;

		public ConfigEntry<float> ChargeSlamFearLevel;

		public ConfigEntry<bool> StealthEnabled;

		public ConfigEntry<float> StealthIdleSeconds;

		public ConfigEntr