Decompiled source of CreakStalker v1.0.2

elrandomman.CreakStalker.dll

Decompiled 5 hours ago
#define DEBUG
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 CreakStalker.Configuration;
using GameNetcodeStuff;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using elrandomman.CreakStalker.NetcodePatcher;

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

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[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 CreakStalker
{
	public class CreakStalkerAI : EnemyAI
	{
		private enum State
		{
			Searching,
			Stalking,
			Backstab,
			Chasing,
			Attacking,
			Fleeing
		}

		[SerializeField]
		private AudioClip[] footsteps = null;

		[SerializeField]
		private AudioClip[] growls = null;

		[SerializeField]
		private AudioClip screech = null;

		[SerializeField]
		private AudioClip fleeScreech = null;

		[SerializeField]
		private AudioClip creakDamaged = null;

		[SerializeField]
		private AudioClip creakAttack = null;

		public Transform turnCompass = null;

		public Transform attackArea = null;

		private float timeSinceHittingLocalPlayer;

		private float timeSinceNewRandPos;

		private Vector3 positionRandomness;

		private Vector3 StalkPos;

		private Random enemyRandom = null;

		private Vector3 seenLoc;

		public bool playFootstepSFX = true;

		public bool beingSeen = false;

		public bool seenOnce = false;

		public bool seenTwice = false;

		public bool seenReset = false;

		public bool induceFear = false;

		public bool justSeen = false;

		public bool backstabbable = false;

		public bool fled = false;

		public bool fledDebounce = false;

		public bool isMoving = false;

		private bool isDeadAnimationDone;

		private const float searchingSpeed = 2f;

		private const float searchingAcc = 10f;

		private const float stalkingSpeed = 3f;

		private const float stalkingAcc = 10f;

		private const float backstabSpeed = 3.5f;

		private const float backstabAcc = 15f;

		private const float chasingSpeed = 7f;

		private const float chasingAcc = 30f;

		private const float fleeingSpeed = 12f;

		private const float fleeingAcc = 50f;

		private float[] creakSpeed = new float[6] { 2f, 3f, 3.5f, 7f, 7f, 12f };

		private float[] creakAcceleration = new float[6] { 10f, 10f, 15f, 30f, 30f, 50f };

		private const float cooldownAmt = 10f;

		private float seenDegPlr = 40f;

		private const float seenCloseThresh = 2.5f;

		private const float seenFarThresh = 1.2f;

		private float seenThreshold = 1.2f;

		private float seenCharge = 0f;

		private float seenCooldown = 0f;

		private float attackCooldown = 0f;

		private const float hidingTimer = 5f;

		private float hiding = 0f;

		private const float backstabTimer = 10f;

		private float backstab = 10f;

		private const float fleeingTimer = 10f;

		private float fleeing = 0f;

		private float enemyMaxHealth;

		private int currDmg = 34;

		private const int backstabDmg = 80;

		private const int attackDmg = 34;

		private float chasingRadius = 28f;

		private float stalkingRadius = 48f;

		private float stalkDistance = 15f;

		private float stalkThreshold = 10f;

		private float attackDistance = 4f;

		private float backstabRadius = 32f;

		private float bufferRadius = 1f;

		private bool debugLog = false;

		private bool f1played = false;

		private bool f2played = false;

		private bool f3played = false;

		private bool f4played = false;

		private float lastNormalizedTime = 0f;

		private bool fledAudio = false;

		private bool prevIsMoving;

		private int prevBehaviourState = -1;

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

		public override void Start()
		{
			//IL_005c: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Start();
			PrintLog("Creak Stalker Spawned");
			Plugin.Logger.LogInfo((object)"Creak is now stalking you... :)");
			timeSinceHittingLocalPlayer = 0f;
			base.creatureAnimator.SetBool("isWalking", true);
			timeSinceNewRandPos = 0f;
			positionRandomness = new Vector3(0f, 0f, 0f);
			enemyRandom = new Random(StartOfRound.Instance.randomMapSeed + base.thisEnemyIndex);
			isDeadAnimationDone = false;
			base.currentBehaviourStateIndex = 0;
			enemyMaxHealth = base.enemyHP;
			((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
		}

		public override void Update()
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_05dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0601: Unknown result type (might be due to invalid IL or missing references)
			//IL_06df: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_066f: Unknown result type (might be due to invalid IL or missing references)
			//IL_067a: Unknown result type (might be due to invalid IL or missing references)
			//IL_067f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0684: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_06bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ca: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Update();
			if (base.isEnemyDead)
			{
				if (!isDeadAnimationDone)
				{
					PrintLog("Stopping enemy voice with janky code.");
					isDeadAnimationDone = true;
					base.creatureVoice.Stop();
					base.creatureVoice.PlayOneShot(base.dieSFX);
				}
				return;
			}
			Vector3 velocity = base.agent.velocity;
			isMoving = ((Vector3)(ref velocity)).magnitude > 0.1f && base.agent.remainingDistance > base.agent.stoppingDistance;
			if (((NetworkBehaviour)this).IsServer)
			{
				UpdateAnimationStateServer();
			}
			if ((Object)(object)base.targetPlayer != (Object)null)
			{
				float num = Vector3.Distance(((Component)base.targetPlayer).transform.position, ((Component)this).transform.position);
				bool flag = CanPlayerSeeMe(base.targetPlayer, num, 40f);
				if (num <= bufferRadius && (base.currentBehaviourStateIndex == 4 || base.currentBehaviourStateIndex == 3))
				{
					base.agent.speed = 0f;
					base.agent.acceleration = 0f;
					((EnemyAI)this).SetDestinationToPosition(((Component)this).transform.position, false);
				}
				else if (flag && base.currentBehaviourStateIndex == 1)
				{
					base.agent.speed = 5f;
					base.agent.acceleration = 20f;
				}
				else
				{
					base.agent.speed = creakSpeed[base.currentBehaviourStateIndex];
					base.agent.acceleration = creakAcceleration[base.currentBehaviourStateIndex];
				}
			}
			seenCooldown -= Time.deltaTime;
			attackCooldown -= Time.deltaTime;
			hiding -= Time.deltaTime;
			fleeing -= Time.deltaTime;
			if (fled && fleeing <= 0f && !fledDebounce)
			{
				fledDebounce = true;
				base.creatureAnimator.speed = 1f;
				((EnemyAI)this).SwitchToBehaviourClientRpc(0);
			}
			if (backstabbable && base.currentBehaviourStateIndex != 2)
			{
				if (backstab <= 0f)
				{
					PrintLog("!!!!!!!!!!Backstabbing: " + (((Object)(object)base.targetPlayer != (Object)null) ? base.targetPlayer.playerUsername : "Player DNE"));
					((EnemyAI)this).SwitchToBehaviourClientRpc(2);
					backstab = 10f;
					backstabbable = false;
				}
				else
				{
					PrintLog(string.Format("Targetting: {0} | Backstab timer at: {1}/{2}", ((Object)(object)base.targetPlayer != (Object)null) ? base.targetPlayer.playerUsername : "Player DNE", backstab, 10f));
					backstab -= Time.deltaTime;
				}
			}
			timeSinceHittingLocalPlayer += Time.deltaTime;
			timeSinceNewRandPos += Time.deltaTime;
			if (beingSeen && seenCooldown <= 0f)
			{
				if (seenCharge >= seenThreshold)
				{
					if (fled)
					{
						seenReset = true;
						beingSeen = false;
						base.agent.updateRotation = true;
						base.creatureVoice.PlayOneShot(screech);
						((EnemyAI)this).SwitchToBehaviourClientRpc(3);
						PrintLog("Seen Third Time: CHASING!!!! ..do chasing() func here..");
					}
					else
					{
						if (!seenOnce)
						{
							seenOnce = true;
							playGrowlClientRpc();
							if ((Object)(object)base.targetPlayer != (Object)null)
							{
								base.targetPlayer.JumpToFearLevel(0.3f, true);
							}
							else
							{
								PrintLog("Player DNE");
							}
							PrintLog("Seen Once");
						}
						else if (seenOnce && !seenTwice)
						{
							seenTwice = true;
							playGrowlClientRpc();
							if ((Object)(object)base.targetPlayer != (Object)null)
							{
								base.targetPlayer.JumpToFearLevel(0.3f, true);
							}
							else
							{
								PrintLog("Player DNE");
							}
							PrintLog("Seen Twice");
						}
						else
						{
							seenReset = true;
							beingSeen = false;
							base.agent.updateRotation = true;
							base.creatureVoice.PlayOneShot(screech);
							((EnemyAI)this).SwitchToBehaviourClientRpc(3);
							PrintLog("Seen Third Time: CHASING!!!! ..do chasing() func here..");
						}
						seenCooldown = 10f;
						seenCharge = 0f;
					}
				}
				else
				{
					seenCharge += Time.deltaTime;
				}
			}
			if (seenReset)
			{
				seenReset = false;
				seenOnce = false;
				seenTwice = false;
				seenCharge = 0f;
				seenCooldown = 10f;
			}
			int currentBehaviourStateIndex = base.currentBehaviourStateIndex;
			if ((Object)(object)base.targetPlayer != (Object)null && (currentBehaviourStateIndex == 3 || currentBehaviourStateIndex == 4))
			{
				turnCompass.LookAt(((Component)base.targetPlayer.gameplayCamera).transform.position);
				((Component)this).transform.rotation = Quaternion.Lerp(((Component)this).transform.rotation, Quaternion.Euler(new Vector3(0f, turnCompass.eulerAngles.y, 0f)), 4f * Time.deltaTime);
			}
			if (base.stunNormalizedTimer > 0f)
			{
				base.agent.speed = 0f;
			}
			float num2 = 25f;
			if (!base.agent.updateRotation && (Object)(object)base.targetPlayer != (Object)null)
			{
				Vector3 val = ((Component)base.targetPlayer).transform.position - ((Component)this).transform.position;
				val.y = 0f;
				if (((Vector3)(ref val)).sqrMagnitude > 0.001f)
				{
					Quaternion val2 = Quaternion.LookRotation(val);
					((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, val2, Time.deltaTime * num2);
				}
			}
			AnimatorStateInfo currentAnimatorStateInfo = base.creatureAnimator.GetCurrentAnimatorStateInfo(0);
			if (((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("walkCycle"))
			{
				float num3 = ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).normalizedTime % 1f;
				if (num3 < lastNormalizedTime)
				{
					f1played = false;
					f2played = false;
				}
				lastNormalizedTime = num3;
				if (num3 >= 0.4202f && !f1played)
				{
					playFootstepsClientRpc();
					f1played = true;
				}
				if (num3 >= 0.9159f && !f2played)
				{
					playFootstepsClientRpc();
					f2played = true;
				}
			}
			else if (((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("chaseCycle"))
			{
				float num4 = ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).normalizedTime % 1f;
				if (num4 < lastNormalizedTime)
				{
					f1played = false;
					f2played = false;
					f3played = false;
					f4played = false;
				}
				lastNormalizedTime = num4;
				if ((double)num4 >= 0.22 && !f1played)
				{
					playFootstepsClientRpc();
					f1played = true;
				}
				if ((double)num4 >= 0.47 && !f2played)
				{
					playFootstepsClientRpc();
					f2played = true;
				}
				if ((double)num4 >= 0.72 && !f3played)
				{
					playFootstepsClientRpc();
					f3played = true;
				}
				if ((double)num4 >= 0.97 && !f4played)
				{
					playFootstepsClientRpc();
					f4played = true;
				}
			}
			else
			{
				f1played = false;
				f2played = false;
				f3played = false;
				f4played = false;
				lastNormalizedTime = 0f;
			}
		}

		public override void DoAIInterval()
		{
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03df: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_0364: Unknown result type (might be due to invalid IL or missing references)
			//IL_0316: Unknown result type (might be due to invalid IL or missing references)
			//IL_0326: Unknown result type (might be due to invalid IL or missing references)
			//IL_0455: Unknown result type (might be due to invalid IL or missing references)
			//IL_0477: Unknown result type (might be due to invalid IL or missing references)
			//IL_0487: Unknown result type (might be due to invalid IL or missing references)
			//IL_0407: Unknown result type (might be due to invalid IL or missing references)
			//IL_0417: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c2: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).DoAIInterval();
			if (base.isEnemyDead || StartOfRound.Instance.allPlayersDead)
			{
				return;
			}
			bool flag = (Object)(object)((EnemyAI)this).CheckLineOfSightForPlayer(50f, (int)(chasingRadius * 2f), (int)(chasingRadius / 1.5f)) != (Object)null;
			switch (base.currentBehaviourStateIndex)
			{
			case 0:
				base.agent.speed = 2f;
				base.agent.acceleration = 10f;
				playFootstepSFX = true;
				DoAnimationClientRpc("startWalk");
				if (FoundClosestPlayerInRange(40f, 20f) && base.targetPlayer.isSprinting)
				{
					PrintLog("Creak Stalker has found you... (running) " + base.targetPlayer.playerUsername);
					((EnemyAI)this).StopSearch(base.currentSearch, true);
					playGrowlClientRpc();
					((EnemyAI)this).SwitchToBehaviourClientRpc(1);
				}
				else if (FoundClosestPlayerInRange(40f, 14f) && !base.targetPlayer.isCrouching && !base.targetPlayer.isSprinting)
				{
					PrintLog("Creak Stalker has found you... (walking) " + base.targetPlayer.playerUsername);
					((EnemyAI)this).StopSearch(base.currentSearch, true);
					playGrowlClientRpc();
					((EnemyAI)this).SwitchToBehaviourClientRpc(1);
				}
				else if (FoundClosestPlayerInRange(40f, 4f) && base.targetPlayer.isCrouching)
				{
					PrintLog("Creak Stalker has found you... (crouching) " + base.targetPlayer.playerUsername);
					((EnemyAI)this).StopSearch(base.currentSearch, true);
					playGrowlClientRpc();
					((EnemyAI)this).SwitchToBehaviourClientRpc(1);
				}
				break;
			case 1:
				base.agent.speed = 3f;
				base.agent.acceleration = 10f;
				playFootstepSFX = false;
				if (!TargetClosestPlayerInAnyCase() || (Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position) > stalkingRadius && !((EnemyAI)this).CheckLineOfSightForPosition(((Component)base.targetPlayer).transform.position, 45f, 60, -1f, (Transform)null)))
				{
					PrintLog("STALKING - Player lost, Creak Stalker is searching again...");
					((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
					((EnemyAI)this).SwitchToBehaviourClientRpc(0);
				}
				else
				{
					StalkPlayerFromDistance();
				}
				break;
			case 2:
				base.agent.speed = 3.5f;
				base.agent.acceleration = 15f;
				if (!TargetClosestPlayerInAnyCase() || (flag && Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position) > backstabRadius) || (!flag && (double)Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position) > (double)backstabRadius / 1.5))
				{
					PrintLog("CHASING - Player lost, Creak Stalker is searchin again...");
					((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
					((EnemyAI)this).SwitchToBehaviourClientRpc(0);
				}
				else
				{
					CreakBackstabPlayer();
				}
				break;
			case 3:
				base.agent.speed = 7f;
				base.agent.acceleration = 30f;
				playFootstepSFX = true;
				DoAnimationClientRpc("startWalk");
				if (!TargetClosestPlayerInAnyCase() || (flag && Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position) > chasingRadius) || (base.targetPlayer.isCrouching && !flag && (double)Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position) > (double)chasingRadius / 1.75))
				{
					PrintLog("CHASING - Player lost, Creak Stalker is searchin again...");
					((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
					((EnemyAI)this).SwitchToBehaviourClientRpc(0);
				}
				else if (!flag && (double)Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position) > (double)chasingRadius / 1.25)
				{
					PrintLog("CHASING - Player lost, Creak Stalker is searchin again...");
					((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
					((EnemyAI)this).SwitchToBehaviourClientRpc(0);
				}
				else
				{
					CreakChasePlayer();
				}
				break;
			case 4:
				break;
			case 5:
				base.agent.speed = 12f;
				base.agent.acceleration = 50f;
				CreakFleeFromPlayer();
				break;
			default:
				PrintLog("This Behavior State doesn't exist!");
				break;
			}
		}

		private bool FoundClosestPlayerInRange(float range, float senseRange)
		{
			//IL_0054: 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)
			((EnemyAI)this).TargetClosestPlayer(1.5f, true, 70f, false, false, true);
			if ((Object)(object)base.targetPlayer == (Object)null)
			{
				((EnemyAI)this).TargetClosestPlayer(1.5f, false, 70f, false, false, true);
				range = senseRange;
			}
			return (Object)(object)base.targetPlayer != (Object)null && Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position) < range;
		}

		private bool TargetClosestPlayerInAnyCase()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			base.mostOptimalDistance = 2000f;
			base.targetPlayer = null;
			for (int i = 0; i < StartOfRound.Instance.connectedPlayersAmount + 1; i++)
			{
				base.tempDist = Vector3.Distance(((Component)this).transform.position, ((Component)StartOfRound.Instance.allPlayerScripts[i]).transform.position);
				if (base.tempDist < base.mostOptimalDistance)
				{
					base.mostOptimalDistance = base.tempDist;
					base.targetPlayer = StartOfRound.Instance.allPlayerScripts[i];
				}
			}
			if ((Object)(object)base.targetPlayer == (Object)null)
			{
				return false;
			}
			return true;
		}

		public bool CanPlayerSeeMe(PlayerControllerB player, float distance, float vision = 0f)
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: 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)
			if ((Object)(object)player == (Object)null)
			{
				return false;
			}
			if (vision == 0f)
			{
				vision = seenDegPlr;
			}
			Vector3 val = (((Object)(object)base.eye != (Object)null) ? base.eye.position : (((Component)this).transform.position + Vector3.up * 1.5f));
			return player.HasLineOfSightToPosition(val, vision, (int)(distance * 2f), -1f, -1);
		}

		private void StalkPlayerFromDistance()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_039e: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03af: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bc: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)base.targetPlayer == (Object)null)
			{
				return;
			}
			float num = Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position);
			float distance = ((num < 2f) ? 5f : num);
			bool flag = (Object)(object)((EnemyAI)this).CheckLineOfSightForPlayer(-1f, (int)(num * 2f), (int)(num * 2f)) != (Object)null;
			bool flag2 = CanPlayerSeeMe(base.targetPlayer, distance, 40f);
			AnimatorStateInfo currentAnimatorStateInfo = base.creatureAnimator.GetCurrentAnimatorStateInfo(0);
			if (flag && num < stalkDistance)
			{
				if (flag2)
				{
					PrintLog(base.targetPlayer.playerUsername + " is too close! Creak is backing away! | BEING SEEN! INCREASING CHARGE");
					if (!justSeen && hiding <= 0f)
					{
						justSeen = true;
					}
					if (base.agent.updateRotation)
					{
						base.agent.updateRotation = false;
					}
					if (!beingSeen)
					{
						seenThreshold = 2.5f;
						beingSeen = true;
						backstabbable = false;
						backstab = 10f;
					}
					Transform val = ((EnemyAI)this).ChooseFarthestNodeFromPosition(((Component)base.targetPlayer).transform.position, true, 0, false, 50, -1);
					if ((Object)(object)val != (Object)null)
					{
						((EnemyAI)this).SetDestinationToPosition(val.position, false);
						return;
					}
					PrintLog("Oops! No retreat node found.. :(");
					((EnemyAI)this).SetDestinationToPosition(((Component)this).transform.position, false);
				}
				else
				{
					PrintLog($"Stopped in CLOSE THRESHOLD | Current Distance: {num}");
					base.agent.speed = 0f;
					base.agent.acceleration = creakAcceleration[base.currentBehaviourStateIndex];
					if (base.agent.updateRotation)
					{
						base.agent.updateRotation = false;
					}
					((EnemyAI)this).SetDestinationToPosition(((Component)this).transform.position, false);
					beingSeen = false;
					backstabbable = true;
				}
				return;
			}
			if (flag && num < stalkDistance + stalkThreshold)
			{
				PrintLog($"Stopped in Default Threshold | Current Distance: {num}");
				base.agent.speed = 0f;
				base.agent.acceleration = creakAcceleration[base.currentBehaviourStateIndex];
				if (base.agent.updateRotation)
				{
					base.agent.updateRotation = false;
				}
				((EnemyAI)this).SetDestinationToPosition(((Component)this).transform.position, false);
				if (flag2)
				{
					if (!beingSeen)
					{
						seenThreshold = 1.2f;
						beingSeen = true;
						backstabbable = false;
						backstab = 10f;
					}
					PrintLog("Creak is being seen, increasing hostility...");
				}
				else
				{
					beingSeen = false;
					backstabbable = true;
				}
				return;
			}
			beingSeen = false;
			backstabbable = false;
			backstab = 10f;
			if (hiding > 0f)
			{
				PrintLog($"Creak is currently hiding... Timer at: {hiding}");
				return;
			}
			if (justSeen)
			{
				justSeen = false;
				seenLoc = ((Component)this).transform.position;
				PrintLog($"Creak was just seen, setting hiding timer and staying put temporarily... Stopped location: {seenLoc}");
				hiding = 5f;
				if (!base.agent.updateRotation)
				{
					base.agent.updateRotation = true;
				}
				((EnemyAI)this).SetDestinationToPosition(seenLoc, false);
				return;
			}
			base.agent.speed = creakSpeed[base.currentBehaviourStateIndex];
			base.agent.acceleration = creakAcceleration[base.currentBehaviourStateIndex];
			if (num < stalkDistance)
			{
				PrintLog($"Creak is close BUT STILL MOVING ---- Distance: {num} ---- stalkDistance: {stalkDistance} ---- LineOfSight?: {flag}");
			}
			else
			{
				PrintLog($"Creak is not close... Moving closer ---- Distance: {num}");
			}
			if (!base.agent.updateRotation)
			{
				base.agent.updateRotation = true;
			}
			((EnemyAI)this).SetDestinationToPosition(((Component)base.targetPlayer).transform.position, false);
		}

		private void CreakFleeFromPlayer()
		{
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			if (fleeing <= 0f)
			{
				backstabbable = false;
				backstab = 10f;
				fleeing = 10f;
				fled = true;
				base.creatureAnimator.speed = 1.25f;
				if (!base.agent.updateRotation)
				{
					base.agent.updateRotation = true;
				}
			}
			Transform val = ((EnemyAI)this).ChooseFarthestNodeFromPosition(((Component)base.targetPlayer).transform.position, true, 0, false, 50, -1);
			if ((Object)(object)val != (Object)null)
			{
				((EnemyAI)this).SetDestinationToPosition(val.position, false);
				return;
			}
			PrintLog("Oops! No retreat node found.. :(");
			((EnemyAI)this).SetDestinationToPosition(((Component)this).transform.position, false);
		}

		private void CreakChasePlayer()
		{
			//IL_0007: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			float num = Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position);
			bool flag = (Object)(object)((EnemyAI)this).CheckLineOfSightForPlayer(-1f, (int)(num * 2f), (int)(num * 2f)) != (Object)null;
			base.targetPlayer.JumpToFearLevel(1f, true);
			if (base.targetPlayer.health <= 0 || base.targetPlayer.isPlayerDead)
			{
				PrintLog(base.targetPlayer.playerUsername + " is DEAD... back to searching :)");
				((EnemyAI)this).SwitchToBehaviourClientRpc(0);
				((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
			}
			if (num >= attackDistance)
			{
				PrintLog($"Farther than attack, moving closer ----- DISTANCE: {num} ---- ATTACK DISTANCE: {attackDistance}");
				((EnemyAI)this).SetDestinationToPosition(((Component)base.targetPlayer).transform.position, false);
				return;
			}
			currDmg = 34;
			if (attackCooldown <= 0f)
			{
				PrintLog("Swinging for attack");
				((EnemyAI)this).SwitchToBehaviourClientRpc(4);
				attackCooldown = 2f;
				((MonoBehaviour)this).StartCoroutine(SwingAttack());
			}
		}

		private void CreakBackstabPlayer()
		{
			//IL_0007: 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_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			float num = Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position);
			bool flag = (Object)(object)((EnemyAI)this).CheckLineOfSightForPlayer(-1f, (int)(num * 2f), (int)(num * 2f)) != (Object)null;
			bool flag2 = CanPlayerSeeMe(base.targetPlayer, num, 45f);
			base.targetPlayer.JumpToFearLevel(0.4f, true);
			if (flag2)
			{
				PrintLog("CAUGHT SNEAKING, engaging in attack immediately!");
				base.creatureVoice.PlayOneShot(screech);
				((EnemyAI)this).SwitchToBehaviourClientRpc(3);
				return;
			}
			if (base.targetPlayer.health <= 0 || base.targetPlayer.isPlayerDead)
			{
				PrintLog(base.targetPlayer.playerUsername + " is DEAD... back to searching :)");
				((EnemyAI)this).SwitchToBehaviourClientRpc(0);
				((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
			}
			if (num >= attackDistance)
			{
				PrintLog($"Farther than attack, sneaking closer ----- DISTANCE: {num} ---- ATTACK DISTANCE: {attackDistance}");
				((EnemyAI)this).SetDestinationToPosition(((Component)base.targetPlayer).transform.position, false);
				return;
			}
			currDmg = 80;
			if (attackCooldown > 0f)
			{
				PrintLog("OnCooldown" + attackCooldown);
				return;
			}
			PrintLog("Swinging for attack");
			((EnemyAI)this).SwitchToBehaviourClientRpc(4);
			attackCooldown = 2f;
			((MonoBehaviour)this).StartCoroutine(SwingAttack());
		}

		private void CreakAttackPlayer()
		{
			//IL_0052: 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_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: 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_0075: 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_0093: 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_009b: 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_010d: Unknown result type (might be due to invalid IL or missing references)
			if (!((NetworkBehaviour)this).IsServer)
			{
				return;
			}
			PrintLog("CreakAttackPlayer: KILL THEMMM");
			Vector3 val = (((Object)(object)attackArea != (Object)null) ? attackArea.position : (((Component)this).transform.position + ((Component)this).transform.forward));
			Vector3 val2 = (Vector3)(((Object)(object)attackArea != (Object)null) ? attackArea.localScale : new Vector3(2.5f, 3f, 2.5f));
			int playersMask = StartOfRound.Instance.playersMask;
			Collider[] array = Physics.OverlapBox(val, val2, ((Component)this).transform.rotation, playersMask);
			HashSet<PlayerControllerB> hashSet = new HashSet<PlayerControllerB>();
			Collider[] array2 = array;
			foreach (Collider val3 in array2)
			{
				PlayerControllerB val4 = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(val3, false, false);
				if ((Object)(object)val4 != (Object)null && !hashSet.Contains(val4))
				{
					hashSet.Add(val4);
					val4.DamagePlayer(currDmg, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
					base.creatureAnimator.SetTrigger("isAttacking");
					base.creatureVoice.PlayOneShot(creakAttack);
					PrintLog($"Creak has attacked a player: {val4.playerUsername}'s health: {val4.health}");
				}
			}
		}

		private IEnumerator SwingAttack()
		{
			((EnemyAI)this).SwitchToBehaviourClientRpc(4);
			StalkPos = ((Component)base.targetPlayer).transform.position;
			((EnemyAI)this).SetDestinationToPosition(StalkPos, false);
			if (!base.isEnemyDead)
			{
				yield return (object)new WaitForSeconds(0.15f);
				CreakAttackPlayer();
				if (base.currentBehaviourStateIndex == 4)
				{
					((EnemyAI)this).SwitchToBehaviourClientRpc(3);
				}
			}
		}

		public override void OnCollideWithPlayer(Collider other)
		{
			if (!(timeSinceHittingLocalPlayer < 1f))
			{
				PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, false, false);
				if ((Object)(object)val != (Object)null)
				{
					PrintLog("Creak Stalker Collision with Player!");
					timeSinceHittingLocalPlayer = 0f;
				}
			}
		}

		public override void HitEnemy(int force = 1, PlayerControllerB? playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
		{
			if (base.isEnemyDead)
			{
				return;
			}
			if ((float)(base.enemyHP - force) <= enemyMaxHealth / 2f && !fledAudio)
			{
				fledAudio = true;
				base.enemyType.hitEnemyVoiceSFX = fleeScreech;
			}
			else
			{
				base.enemyType.hitEnemyVoiceSFX = creakDamaged;
			}
			((EnemyAI)this).HitEnemy(force, playerWhoHit, playHitSFX, hitID);
			base.creatureAnimator.SetTrigger("isDamaged");
			base.enemyHP -= force;
			if (!seenOnce)
			{
				PrintLog("Enemy angered once");
				seenOnce = true;
			}
			else if (!seenTwice)
			{
				PrintLog("Enemy angered twice");
				seenTwice = true;
				base.targetPlayer.JumpToFearLevel(0.4f, true);
			}
			if ((double)((float)base.enemyHP / enemyMaxHealth) <= 0.5 && !fled)
			{
				((EnemyAI)this).SwitchToBehaviourClientRpc(5);
			}
			PrintLog($"{base.enemyHP}/{enemyMaxHealth}");
			if (((NetworkBehaviour)this).IsOwner && base.enemyHP <= 0 && !base.isEnemyDead)
			{
				PrintLog("dead!?????");
				((EnemyAI)this).KillEnemyOnOwnerClient(false);
				((MonoBehaviour)this).StopCoroutine(SwingAttack());
				if (base.searchCoroutine != null)
				{
					((MonoBehaviour)this).StopCoroutine(base.searchCoroutine);
				}
			}
		}

		public void UpdateAnimationStateServer()
		{
			if (((NetworkBehaviour)this).IsServer && (isMoving != prevIsMoving || base.currentBehaviourStateIndex != prevBehaviourState))
			{
				prevIsMoving = isMoving;
				prevBehaviourState = base.currentBehaviourStateIndex;
				SwitchAnimationClientRpc(isMoving, base.currentBehaviourStateIndex);
			}
		}

		private void SetAnimBools(bool isWalking, bool isStalking, bool isChasing, bool isBackstabbing)
		{
			base.creatureAnimator.SetBool("isWalking", isWalking);
			base.creatureAnimator.SetBool("isStalking", isStalking);
			base.creatureAnimator.SetBool("isChasing", isChasing);
			base.creatureAnimator.SetBool("isBackstabbing", isBackstabbing);
		}

		[ClientRpc]
		public void SwitchAnimationClientRpc(bool moving, int stateIndex)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val2 = default(ClientRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(31786042u, val2, (RpcDelivery)0);
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref moving, default(ForPrimitives));
				BytePacker.WriteValueBitPacked(val, stateIndex);
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 31786042u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			if ((Object)(object)base.creatureAnimator == (Object)null)
			{
				return;
			}
			if (moving)
			{
				switch (stateIndex)
				{
				case 2:
					SetAnimBools(isWalking: false, isStalking: false, isChasing: false, isBackstabbing: true);
					break;
				default:
					if (stateIndex != 5)
					{
						SetAnimBools(isWalking: true, isStalking: false, isChasing: false, isBackstabbing: false);
						break;
					}
					goto case 3;
				case 3:
					SetAnimBools(isWalking: false, isStalking: false, isChasing: true, isBackstabbing: false);
					break;
				}
			}
			else
			{
				SetAnimBools(isWalking: false, isStalking: true, isChasing: false, isBackstabbing: false);
			}
		}

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

		[ClientRpc]
		public void playFootstepsClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val2 = default(ClientRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(1556188226u, val2, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 1556188226u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			if (playFootstepSFX)
			{
				if (footsteps == null || footsteps.Length == 0)
				{
					PrintLog("Footsteps array is empty or null.");
					return;
				}
				int num = Random.Range(0, footsteps.Length);
				AudioClip clip = footsteps[num];
				base.creatureSFX.volume = 0.7f;
				base.creatureSFX.clip = clip;
				base.creatureSFX.Play();
			}
		}

		[ClientRpc]
		public void playGrowlClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val2 = default(ClientRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(2484398047u, val2, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 2484398047u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				if (growls == null || growls.Length == 0)
				{
					PrintLog("Growls array is empty or null.");
					return;
				}
				int num = Random.Range(0, growls.Length);
				AudioClip val3 = growls[num];
				base.creatureVoice.PlayOneShot(val3);
			}
		}

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

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(31786042u, new RpcReceiveHandler(__rpc_handler_31786042), "SwitchAnimationClientRpc");
			((NetworkBehaviour)this).__registerRpc(3737082076u, new RpcReceiveHandler(__rpc_handler_3737082076), "DoAnimationClientRpc");
			((NetworkBehaviour)this).__registerRpc(1556188226u, new RpcReceiveHandler(__rpc_handler_1556188226), "playFootstepsClientRpc");
			((NetworkBehaviour)this).__registerRpc(2484398047u, new RpcReceiveHandler(__rpc_handler_2484398047), "playGrowlClientRpc");
			((EnemyAI)this).__initializeRpcs();
		}

		private static void __rpc_handler_31786042(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool moving = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref moving, default(ForPrimitives));
				int stateIndex = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref stateIndex);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((CreakStalkerAI)(object)target).SwitchAnimationClientRpc(moving, stateIndex);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3737082076(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string animationName = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref animationName, false);
				}
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((CreakStalkerAI)(object)target).DoAnimationClientRpc(animationName);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1556188226(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((CreakStalkerAI)(object)target).playFootstepsClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2484398047(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((CreakStalkerAI)(object)target).playGrowlClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "CreakStalkerAI";
		}
	}
	[BepInPlugin("elrandomman.CreakStalker", "CreakStalker", "1.0.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 = "creakasset";
			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 val = ModAssets.LoadAsset<EnemyType>("CreakEnemy");
			TerminalNode val2 = ModAssets.LoadAsset<TerminalNode>("CreakEnemyTN");
			TerminalKeyword val3 = ModAssets.LoadAsset<TerminalKeyword>("CreakEnemyTK");
			NetworkPrefabs.RegisterNetworkPrefab(val.enemyPrefab);
			Enemies.RegisterEnemy(val, BoundConfig.SpawnWeight.Value, (LevelTypes)(-1), val2, val3);
			Logger.LogInfo((object)"Plugin elrandomman.CreakStalker is loaded!");
		}

		private static void InitializeNetworkBehaviours()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "elrandomman.CreakStalker";

		public const string PLUGIN_NAME = "CreakStalker";

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

		public PluginConfig(ConfigFile cfg)
		{
			SpawnWeight = cfg.Bind<int>("General", "Spawn weight", 40, "The spawn chance weight for CreakStalker, relative to other existing enemies.\nGoes up from 0, lower is more rare, 100 and up is very common.");
			ClearUnusedEntries(cfg);
		}

		private void ClearUnusedEntries(ConfigFile cfg)
		{
			PropertyInfo property = ((object)cfg).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic);
			Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)property.GetValue(cfg, null);
			dictionary.Clear();
			cfg.Save();
		}
	}
}
namespace __GEN
{
	internal class NetworkVariableSerializationHelper
	{
		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeSerialization()
		{
		}
	}
}
namespace elrandomman.CreakStalker.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}