Decompiled source of LethalPlaytime v1.3.6

Nuclear_Fox.LethalPlaytime.dll

Decompiled 3 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Events;
using UnityEngine.InputSystem.Utilities;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ClientNetworkTransform")]
[assembly: IgnoresAccessChecksTo("DissonanceVoip")]
[assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Jobs")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")]
[assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")]
[assembly: IgnoresAccessChecksTo("Unity.Services.QoS")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Relay")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Nuclear_Fox.LethalPlaytime")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.3.6.0")]
[assembly: AssemblyInformationalVersion("1.3.6")]
[assembly: AssemblyProduct("LethalPlaytime")]
[assembly: AssemblyTitle("Nuclear_Fox.LethalPlaytime")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.3.6.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace LethalPlaytime
{
	public class BoxyBooAI : EnemyAI
	{
		private enum BoxyStates
		{
			BasicSearch,
			AdvancedSearch,
			BasicChase,
			AdvancedChase,
			Box,
			Jumpscare,
			Leap,
			Armgrab,
			Retreat
		}

		private enum CrankStates
		{
			WindUp,
			Static,
			NormalSpin,
			FastSpin
		}

		private Random rng;

		private AISearchRoutine boxySearchRoutine;

		private CrankStates crankState;

		public Transform crank;

		public InteractTrigger interactTrigger;

		public bool box = false;

		public bool partial = true;

		public bool full = false;

		public bool attacking = false;

		public bool leaping = false;

		public bool grabbing = false;

		public bool jumpscaring = false;

		public static readonly int maxEnergy = 26;

		public static readonly int thresholdEnergy = 21;

		public float energy = 0f;

		public bool reversing = false;

		private static readonly int maxCrankBackwardsTime = 2;

		private float crankBackwardsTime = 0f;

		public static readonly float maxLeapCooldown = 8f;

		public static readonly float maxGrabCooldown = 10f;

		public static readonly float startLeapCooldown = 2000f;

		public static readonly float startGrabCooldown = 2000f;

		public float leapCooldown = 5f;

		public float grabCooldown = 6f;

		public static readonly float maxTimeSinceMoving = 0.15f;

		public float timeSinceMoving = 0f;

		public int numJumps = 1;

		public Transform leftsideCheck;

		public Transform rightsideCheck;

		private Vector3 landingPosition;

		private static float peakJumpHeight = 0.5f;

		private static float jumpSpeed = 5f;

		public float timeSinceOnNavMesh = 0f;

		private Vector3 reservedAgentSpeed;

		private bool wasOnOffMeshLink = false;

		public AudioSource crankAudio;

		public AudioSource hitConnectAudio;

		public AudioSource grabAudioPoint;

		public AudioSource musicAudio;

		public AudioSource creakAudio;

		public AudioSource jumpAudio;

		public AudioSource retractAudio;

		public AudioClip[] walkSounds;

		public AudioClip[] staticSounds;

		public AudioClip[] attackSounds;

		public AudioClip[] hitConnectSounds;

		public AudioClip[] grabLaunchSounds;

		public AudioClip[] grabReadySounds;

		public AudioClip[] crankSounds;

		public AudioClip[] musicTrackSounds;

		public AudioClip[] boxLandSounds;

		public AudioClip[] leapSounds;

		public AudioClip[] landSounds;

		public AudioClip[] creakSounds;

		public AudioClip[] popSounds;

		public AudioClip[] jumpscareSounds;

		public AudioClip[] partialRetractSounds;

		public AudioClip[] fullRetractSounds;

		public AudioClip[] hitConnectSlashSounds;

		private float maxTimeBetweenCranks = 0.75f;

		public float timeBetweenCranks = 0f;

		private static readonly float maxCreakTime = 6f;

		private static readonly float minCreekTime = 3f;

		public float creakTime = 5f;

		public BoxCollider attackArea;

		public static readonly float maxAttackCooldown = 1.4f;

		public float attackCooldown = 0f;

		public int numGrabs = 1;

		private int angleOffsetGrab = 45;

		private static readonly float maxTimeAimingGrab = 0.6f;

		public float timeAimingGrab = 0f;

		public bool grabbedPlayer = false;

		public bool checkingArmCollision = false;

		public Transform jumpscareAttachPoint;

		private ulong jumpscareClientID;

		public BoxCollider jumpscareCollision;

		public Coroutine jumpscare;

		private Vector3 retreatPosition;

		private readonly float maxRetreatTime = 25f;

		public float retreatTime = 0f;

		public float trackedDamage = 0f;

		public bool shouldEnterRetreat = false;

		public readonly float maxTrackedDamaged = 8f;

		private bool setupFinished = false;

		public BoxCollider boxCollision;

		public bool checkingLastSeenPostion = false;

		public float timeSinceSeeingTarget = 0f;

		public readonly float losTimeBasicChase = 6f;

		public readonly float losTimeAdvancedChase = 9f;

		public readonly float maxTimeCheckingLastSeenPosition = 12f;

		public float timeCheckingLastSeenPosition = 0f;

		private Vector3 lastSeenEnemyPosition;

		public override void Start()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Start();
			rng = new Random(StartOfRound.Instance.randomMapSeed);
			boxySearchRoutine = new AISearchRoutine();
			crankState = CrankStates.Static;
			if ((Object)(object)musicAudio != (Object)null && musicTrackSounds != null)
			{
				musicAudio.clip = musicTrackSounds[0];
			}
			if (!((NetworkBehaviour)this).IsServer && ((NetworkBehaviour)this).IsOwner)
			{
				((EnemyAI)this).ChangeOwnershipOfEnemy(StartOfRound.Instance.allPlayerScripts[0].actualClientId);
			}
			retreatPosition = ((Component)this).transform.position;
			base.debugEnemyAI = false;
		}

		public void SetupStartTrigger()
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			if (base.debugEnemyAI && ((NetworkBehaviour)this).IsClient)
			{
				Debug.Log((object)"SetupStartTrigger called on client.");
			}
			if (interactTrigger.onInteract != null)
			{
				((UnityEvent<PlayerControllerB>)(object)interactTrigger.onInteract).AddListener((UnityAction<PlayerControllerB>)CrankBackwards);
				return;
			}
			interactTrigger.onInteract = new InteractEvent();
			((UnityEvent<PlayerControllerB>)(object)interactTrigger.onInteract).AddListener((UnityAction<PlayerControllerB>)CrankBackwards);
		}

		public override void DoAIInterval()
		{
			//IL_0ce2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ce8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c5a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c65: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d3b: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e9: 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_02cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_052e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0539: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0726: Unknown result type (might be due to invalid IL or missing references)
			//IL_0731: Unknown result type (might be due to invalid IL or missing references)
			//IL_0447: Unknown result type (might be due to invalid IL or missing references)
			//IL_0452: Unknown result type (might be due to invalid IL or missing references)
			//IL_0591: Unknown result type (might be due to invalid IL or missing references)
			//IL_0482: Unknown result type (might be due to invalid IL or missing references)
			//IL_0492: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ad4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ae6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0af6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b0d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b22: Unknown result type (might be due to invalid IL or missing references)
			//IL_07fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0811: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_07cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_08c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_08de: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_08f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_08f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0900: Unknown result type (might be due to invalid IL or missing references)
			//IL_0905: Unknown result type (might be due to invalid IL or missing references)
			//IL_090a: Unknown result type (might be due to invalid IL or missing references)
			//IL_090c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0926: Unknown result type (might be due to invalid IL or missing references)
			//IL_0934: Unknown result type (might be due to invalid IL or missing references)
			//IL_0939: Unknown result type (might be due to invalid IL or missing references)
			//IL_0941: Unknown result type (might be due to invalid IL or missing references)
			//IL_0946: Unknown result type (might be due to invalid IL or missing references)
			//IL_0948: Unknown result type (might be due to invalid IL or missing references)
			//IL_0959: Unknown result type (might be due to invalid IL or missing references)
			//IL_095b: Unknown result type (might be due to invalid IL or missing references)
			//IL_09c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_09de: Unknown result type (might be due to invalid IL or missing references)
			//IL_09fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a0f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0880: Unknown result type (might be due to invalid IL or missing references)
			//IL_0895: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a6e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a70: Unknown result type (might be due to invalid IL or missing references)
			if (base.isEnemyDead || StartOfRound.Instance.allPlayersDead || base.isEnemyDead)
			{
				return;
			}
			((EnemyAI)this).DoAIInterval();
			if (base.timeSinceSpawn < 2f && base.timeSinceSpawn > 1f && !setupFinished)
			{
				setupFinished = true;
				if (base.debugEnemyAI)
				{
					Debug.Log((object)"Setting up interact trigger on clients.");
				}
				BoxyBooSendStringClientRcp("SetupClientInteractTrigger");
			}
			timeSinceSeeingTarget += base.AIIntervalTime;
			switch (base.currentBehaviourStateIndex)
			{
			case 0:
			{
				if (energy <= 0f)
				{
					((EnemyAI)this).SwitchToBehaviourState(4);
					BoxyBooSendStringClientRcp("SwitchToBox");
					((EnemyAI)this).StopSearch(boxySearchRoutine, false);
					break;
				}
				PlayerControllerB val = ((EnemyAI)this).CheckLineOfSightForClosestPlayer(360f, 2, -1, 0f);
				if ((Object)(object)val == (Object)null)
				{
					val = ((EnemyAI)this).CheckLineOfSightForClosestPlayer(150f, 25, -1, 0f);
				}
				if ((Object)(object)val != (Object)null && val.isInsideFactory && !val.isPlayerDead && !Object.op_Implicit((Object)(object)val.inAnimationWithEnemy))
				{
					timeSinceSeeingTarget = 0f;
					base.targetPlayer = val;
					((EnemyAI)this).SwitchToBehaviourState(2);
					BoxyBooSendStringClientRcp("SwitchToBasicChase");
				}
				else if (!boxySearchRoutine.inProgress)
				{
					((EnemyAI)this).StartSearch(((Component)this).transform.position, boxySearchRoutine);
				}
				break;
			}
			case 1:
			{
				if (energy <= 0f)
				{
					((EnemyAI)this).SwitchToBehaviourState(4);
					BoxyBooSendStringClientRcp("SwitchToBox");
					((EnemyAI)this).StopSearch(boxySearchRoutine, false);
					break;
				}
				PlayerControllerB val = ((EnemyAI)this).CheckLineOfSightForClosestPlayer(360f, 3, -1, 0f);
				if ((Object)(object)val == (Object)null)
				{
					val = ((EnemyAI)this).CheckLineOfSightForClosestPlayer(180f, 32, -1, 0f);
				}
				if ((Object)(object)val != (Object)null && val.isInsideFactory && !val.isPlayerDead && !Object.op_Implicit((Object)(object)val.inAnimationWithEnemy))
				{
					timeSinceSeeingTarget = 0f;
					base.targetPlayer = val;
					((EnemyAI)this).SwitchToBehaviourState(3);
					BoxyBooSendStringClientRcp("SwitchToAdvancedChase");
				}
				else if (!boxySearchRoutine.inProgress)
				{
					((EnemyAI)this).StartSearch(((Component)this).transform.position, boxySearchRoutine);
				}
				break;
			}
			case 2:
				if (boxySearchRoutine.inProgress)
				{
					((EnemyAI)this).StopSearch(boxySearchRoutine, true);
				}
				if (energy <= 0f)
				{
					((EnemyAI)this).SwitchToBehaviourState(4);
					BoxyBooSendStringClientRcp("SwitchToBox");
				}
				else if ((Object)(object)base.targetPlayer != (Object)null && !base.targetPlayer.isPlayerDead && base.targetPlayer.isInsideFactory && !Object.op_Implicit((Object)(object)base.targetPlayer.inAnimationWithEnemy))
				{
					if (timeSinceSeeingTarget > losTimeBasicChase)
					{
						lastSeenEnemyPosition = ((Component)base.targetPlayer).transform.position;
						checkingLastSeenPostion = true;
						base.targetPlayer = null;
						break;
					}
					float num = Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position);
					bool flag = !Physics.Linecast(((Component)base.eye).transform.position, ((Component)base.targetPlayer.gameplayCamera).transform.position, StartOfRound.Instance.collidersAndRoomMaskAndDefault);
					PlayerControllerB val = ((EnemyAI)this).CheckLineOfSightForClosestPlayer(150f, 25, -1, 0f);
					if ((Object)(object)val != (Object)(object)base.targetPlayer && (Object)(object)val != (Object)null && Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position) < num)
					{
						timeSinceSeeingTarget = 0f;
						base.targetPlayer = val;
						num = Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position);
						flag = true;
					}
					if (num < 1.5f && !attacking && attackCooldown <= 0f)
					{
						AttackRandom();
						break;
					}
					((EnemyAI)this).SetDestinationToPosition(((Component)base.targetPlayer).transform.position, false);
					if (flag)
					{
						timeSinceSeeingTarget = 0f;
						if (num > 26f)
						{
							base.targetPlayer = null;
						}
					}
				}
				else if (checkingLastSeenPostion && Vector3.Distance(lastSeenEnemyPosition, ((Component)this).transform.position) > 2f)
				{
					timeCheckingLastSeenPosition += base.AIIntervalTime;
					if (timeCheckingLastSeenPosition > maxTimeCheckingLastSeenPosition)
					{
						checkingLastSeenPostion = false;
						timeCheckingLastSeenPosition = 0f;
					}
					((EnemyAI)this).SetDestinationToPosition(lastSeenEnemyPosition, false);
				}
				else
				{
					checkingLastSeenPostion = false;
					timeCheckingLastSeenPosition = 0f;
					PlayerControllerB val = ((EnemyAI)this).CheckLineOfSightForClosestPlayer(150f, 25, -1, 0f);
					if ((Object)(object)val != (Object)null)
					{
						base.targetPlayer = val;
					}
					else if (energy > 2f)
					{
						base.targetPlayer = null;
						((EnemyAI)this).SwitchToBehaviourState(0);
						BoxyBooSendStringClientRcp("SwitchToBasicSearch");
					}
					else
					{
						base.targetPlayer = null;
						((EnemyAI)this).SwitchToBehaviourState(4);
						BoxyBooSendStringClientRcp("SwitchToBox");
					}
				}
				break;
			case 3:
				if (boxySearchRoutine.inProgress)
				{
					((EnemyAI)this).StopSearch(boxySearchRoutine, true);
				}
				if (energy <= 0f)
				{
					((EnemyAI)this).SwitchToBehaviourState(4);
					BoxyBooSendStringClientRcp("SwitchToBox");
				}
				else if ((Object)(object)base.targetPlayer != (Object)null && !base.targetPlayer.isPlayerDead && base.targetPlayer.isInsideFactory && !Object.op_Implicit((Object)(object)base.targetPlayer.inAnimationWithEnemy))
				{
					float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position);
					PlayerControllerB val = ((EnemyAI)this).CheckLineOfSightForClosestPlayer(360f, 25, -1, 0f);
					if ((Object)(object)val != (Object)(object)base.targetPlayer && (Object)(object)val != (Object)null && Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position) < num2)
					{
						((EnemyAI)this).TargetClosestPlayer(5f, false, 70f);
						base.targetPlayer = val;
					}
					if (energy > 2f)
					{
						if (grabCooldown <= 0f && (double)num2 < 3.25 && (double)num2 > 0.6 && !base.agent.isOnOffMeshLink && (double)Math.Abs(((Component)this).transform.position.y - ((Component)base.targetPlayer).transform.position.y) < 1.25 && !Physics.Linecast(((Component)base.eye).transform.position, ((Component)base.targetPlayer.gameplayCamera).transform.position, StartOfRound.Instance.collidersAndRoomMaskAndDefault))
						{
							((EnemyAI)this).SwitchToBehaviourState(7);
							BoxyBooSendStringClientRcp("SwitchToGrab");
							break;
						}
						if (leapCooldown <= 0f && num2 < 10f && (double)num2 > 5.5 && !base.agent.isOnOffMeshLink && (double)Math.Abs(((Component)this).transform.position.y - ((Component)base.targetPlayer).transform.position.y) < 0.7)
						{
							Vector3 val2 = ((Component)base.targetPlayer).transform.position - ((Component)this).transform.position;
							Vector3 normalized = ((Vector3)(ref val2)).normalized;
							Vector3 val3 = ((Component)base.targetPlayer).transform.position - normalized * 0.5f;
							NavMeshHit val4 = default(NavMeshHit);
							if (NavMesh.SamplePosition(val3, ref val4, 0.6f, -1))
							{
								Vector3 randomNavMeshPositionInRadiusSpherical = GetRandomNavMeshPositionInRadiusSpherical(val3, 1f, 0.02f, 100);
								Debug.DrawLine(((Component)this).transform.position, randomNavMeshPositionInRadiusSpherical, Color.magenta, 4f);
								landingPosition = randomNavMeshPositionInRadiusSpherical;
								BoxyBooSendStringClientRcp("Vector3: " + landingPosition.x + "," + landingPosition.y + "," + landingPosition.z);
								bool flag2 = Physics.Linecast(leftsideCheck.position, ((Component)base.targetPlayer.playerEye).transform.position, StartOfRound.Instance.collidersAndRoomMaskAndDefault);
								bool flag3 = Physics.Linecast(rightsideCheck.position, ((Component)base.targetPlayer.playerEye).transform.position, StartOfRound.Instance.collidersAndRoomMaskAndDefault);
								if (base.debugEnemyAI)
								{
									Debug.Log((object)("Leftcheck: " + flag2));
									Debug.Log((object)("Rightcheck: " + flag3));
								}
								if (flag2 && flag3)
								{
									landingPosition = randomNavMeshPositionInRadiusSpherical;
									((EnemyAI)this).SwitchToBehaviourState(6);
									BoxyBooSendStringClientRcp("SwitchToLeap");
									break;
								}
							}
						}
					}
					if (num2 < 1.5f && !attacking && attackCooldown <= 0f)
					{
						AttackRandom();
						break;
					}
					((EnemyAI)this).SetDestinationToPosition(((Component)base.targetPlayer).transform.position, false);
					float num3 = Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position);
					if (!Physics.Linecast(((Component)base.eye).transform.position, ((Component)base.targetPlayer.gameplayCamera).transform.position, StartOfRound.Instance.collidersAndRoomMaskAndDefault))
					{
						if (num3 > 31f)
						{
							base.targetPlayer = null;
						}
					}
					else if (num3 > 20f)
					{
						base.targetPlayer = null;
					}
				}
				else
				{
					PlayerControllerB val = ((EnemyAI)this).CheckLineOfSightForClosestPlayer(360f, 25, -1, 0f);
					if ((Object)(object)val != (Object)null)
					{
						base.targetPlayer = val;
					}
					else if (energy > 2f)
					{
						base.targetPlayer = null;
						((EnemyAI)this).SwitchToBehaviourState(1);
						BoxyBooSendStringClientRcp("SwitchToAdvancedSearch");
					}
					else
					{
						base.targetPlayer = null;
						((EnemyAI)this).SwitchToBehaviourState(4);
						BoxyBooSendStringClientRcp("SwitchToBox");
					}
				}
				break;
			case 4:
			{
				PlayerControllerB val = ((EnemyAI)this).CheckLineOfSightForPlayer(270f, 7, -1);
				if (energy >= (float)maxEnergy)
				{
					((EnemyAI)this).SwitchToBehaviourState(1);
					BoxyBooSendStringClientRcp("SwitchToAdvancedSearch");
				}
				else if (energy >= (float)thresholdEnergy && (Object)(object)val != (Object)null && Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position) < 7f)
				{
					((EnemyAI)this).SwitchToBehaviourState(0);
					BoxyBooSendStringClientRcp("SwitchToBasicSearch");
				}
				break;
			}
			case 5:
				break;
			case 6:
				break;
			case 7:
				if (numGrabs <= 0 && !jumpscaring)
				{
					((EnemyAI)this).SwitchToBehaviourState(1);
					BoxyBooSendStringClientRcp("SwitchToAdvancedSearch");
				}
				break;
			case 8:
				if (Vector3.Distance(((Component)this).transform.position, retreatPosition) < 2.5f || retreatTime > maxRetreatTime)
				{
					retreatTime = 0f;
					base.targetPlayer = null;
					((EnemyAI)this).SwitchToBehaviourState(4);
					BoxyBooSendStringClientRcp("SwitchToBox");
				}
				else
				{
					((EnemyAI)this).SetDestinationToPosition(retreatPosition, false);
				}
				break;
			}
		}

		public override void Update()
		{
			if (!base.isEnemyDead)
			{
				((EnemyAI)this).Update();
				UpdateOffmeshJumpState();
				UpdateCrank(crankState, reversing);
				UpdateEnergy((BoxyStates)base.currentBehaviourStateIndex);
				UpdateCooldowns();
				UpdateStateDependent();
				UpdateCreak();
				if (((NetworkBehaviour)this).IsHost || ((NetworkBehaviour)this).IsServer)
				{
					UpdateRetreatCheck();
					UpdateWalking();
					UpdateNavMesh();
					CheckArmCollision();
				}
			}
		}

		private void UpdateRetreatCheck()
		{
			if (!attacking && shouldEnterRetreat && (base.currentBehaviourStateIndex == 0 || base.currentBehaviourStateIndex == 1 || base.currentBehaviourStateIndex == 2 || base.currentBehaviourStateIndex == 3))
			{
				shouldEnterRetreat = false;
				trackedDamage = 0f;
				((EnemyAI)this).SwitchToBehaviourState(8);
				BoxyBooSendStringClientRcp("SwitchToRetreat");
			}
		}

		private void UpdateOffmeshJumpState()
		{
			if (base.agent.isOnOffMeshLink && !wasOnOffMeshLink)
			{
				BoxyBooSendStringClientRcp("PlayJumpAnimation");
			}
			wasOnOffMeshLink = base.agent.isOnOffMeshLink;
		}

		private void UpdateCreak()
		{
			if (base.currentBehaviourStateIndex < 4)
			{
				creakTime -= Time.deltaTime;
				if (creakTime <= 0f)
				{
					creakTime = (float)(rng.NextDouble() * (double)(maxCreakTime - minCreekTime)) + minCreekTime;
					PlayRandomCreakSound();
				}
			}
		}

		private void UpdateStateDependent()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_006e: 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_013a: 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_0152: 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_016a: 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_0171: 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_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			if (attacking && (Object)(object)base.targetPlayer != (Object)null)
			{
				Vector3 val = ((Component)base.targetPlayer).transform.position - ((Component)this).transform.position;
				val.y = 0f;
				Quaternion val2 = Quaternion.LookRotation(val);
				((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, val2, Time.deltaTime * 10f);
			}
			switch (base.currentBehaviourStateIndex)
			{
			case 4:
				timeBetweenCranks += Time.deltaTime;
				if (timeBetweenCranks > maxTimeBetweenCranks)
				{
					timeBetweenCranks = 0f;
					PlayRandomCrankSound();
				}
				break;
			case 7:
			{
				PlayerControllerB val3 = ((EnemyAI)this).CheckLineOfSightForClosestPlayer(360f, 7, -1, 0f);
				if ((Object)(object)val3 != (Object)null && val3.isInsideFactory && !val3.isPlayerDead)
				{
					Vector3 val4 = ((Component)val3).transform.position - ((Component)this).transform.position;
					val4.y = 0f;
					Quaternion val5 = Quaternion.LookRotation(val4);
					Quaternion val6 = Quaternion.Euler(0f, 7f, 0f);
					Quaternion val7 = val5 * val6;
					((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, val7, Time.deltaTime * 20f);
				}
				if ((double)timeAimingGrab > -0.5)
				{
					timeAimingGrab += Time.deltaTime;
					if (timeAimingGrab > maxTimeAimingGrab)
					{
						timeAimingGrab = -1f;
						BoxyBooSendStringClientRcp("FinishArmGrab");
					}
				}
				break;
			}
			case 8:
				retreatTime += Time.deltaTime;
				break;
			}
		}

		private IEnumerator Leap()
		{
			Vector3 startingPosition = ((Component)this).transform.position;
			_ = startingPosition.y;
			float distanceToDestination = Vector3.Distance(startingPosition, landingPosition);
			float currentDistanceToDestination = distanceToDestination;
			float timeTaken = 0f;
			while (currentDistanceToDestination > 0.2f && (double)timeTaken < 0.75)
			{
				((Component)this).transform.position = Vector3.Lerp(((Component)this).transform.position, landingPosition, Time.deltaTime * jumpSpeed);
				Vector3 diff = ((Component)base.targetPlayer).transform.position - ((Component)this).transform.position;
				diff.y = 0f;
				Quaternion targetLook = Quaternion.LookRotation(diff);
				((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, targetLook, Time.deltaTime * 10f);
				currentDistanceToDestination = Vector3.Distance(((Component)this).transform.position, landingPosition);
				timeTaken += Time.deltaTime;
				yield return null;
			}
			if (currentDistanceToDestination <= 0.15f)
			{
				if (!base.agent.isOnNavMesh)
				{
					FindAndSetValidNavMeshPosition();
				}
				((EnemyAI)this).SwitchToBehaviourState(3);
				BoxyBooSendStringClientRcp("SwitchToAdvancedChase");
				if ((Object)(object)base.targetPlayer != (Object)null && base.targetPlayer.isInsideFactory && !base.targetPlayer.isPlayerDead)
				{
					((EnemyAI)this).SetDestinationToPosition(((Component)base.targetPlayer).transform.position, true);
				}
			}
			else
			{
				if (!base.agent.isOnNavMesh)
				{
					FindAndSetValidNavMeshPosition();
				}
				((EnemyAI)this).SwitchToBehaviourState(3);
				BoxyBooSendStringClientRcp("SwitchToAdvancedChase");
				if ((Object)(object)base.targetPlayer != (Object)null && base.targetPlayer.isInsideFactory && !base.targetPlayer.isPlayerDead)
				{
					((EnemyAI)this).SetDestinationToPosition(((Component)base.targetPlayer).transform.position, true);
				}
			}
		}

		public void FindAndSetValidNavMeshPosition(float searchRadius = 0.1f, int maxAttempts = 500)
		{
			//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_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = ((Component)this).transform.position;
			int num = 0;
			NavMeshHit val2 = default(NavMeshHit);
			while (num < maxAttempts && !base.agent.isOnNavMesh)
			{
				Vector3 val = position + Random.insideUnitSphere * searchRadius;
				if (NavMesh.SamplePosition(val, ref val2, searchRadius, -1))
				{
					base.agent.Warp(((NavMeshHit)(ref val2)).position);
					return;
				}
				num++;
				searchRadius += 0.03f;
			}
			Debug.LogWarning((object)"Failed to find a valid NavMesh position after maximum attempts.");
		}

		private Vector3 GetRandomNavMeshPositionInRadiusSpherical(Vector3 pos, float initialRadius = 10f, float radiusIncrement = 5f, int maxAttempts = 10)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00b3: Unknown result type (might be due to invalid IL or missing references)
			float num = initialRadius;
			NavMeshHit val2 = default(NavMeshHit);
			for (int i = 0; i < maxAttempts; i++)
			{
				Vector3 val = pos + Random.insideUnitSphere * num;
				if (NavMesh.SamplePosition(val, ref val2, num, -1))
				{
					Debug.DrawRay(((NavMeshHit)(ref val2)).position + Vector3.forward * 0.01f, Vector3.up * 2f, Color.blue);
					return ((NavMeshHit)(ref val2)).position;
				}
				num += radiusIncrement;
			}
			Debug.DrawRay(pos + Vector3.forward * 0.01f, Vector3.up * 2f, Color.yellow);
			return pos;
		}

		private void SwitchToAdvancedSearch()
		{
			if ((Object)(object)musicAudio.clip != (Object)(object)musicTrackSounds[1])
			{
				musicAudio.clip = musicTrackSounds[1];
				musicAudio.Play();
			}
			numJumps = 1;
			box = false;
			partial = false;
			full = true;
			UpdateAnimationState();
			base.agent.speed = 5f;
			crankState = CrankStates.FastSpin;
		}

		private void SwitchToAdvancedChase()
		{
			if ((Object)(object)musicAudio.clip != (Object)(object)musicTrackSounds[1])
			{
				musicAudio.clip = musicTrackSounds[1];
				musicAudio.Play();
			}
			box = false;
			partial = false;
			full = true;
			UpdateAnimationState();
			base.agent.speed = 6f;
			attacking = false;
			attackCooldown = maxAttackCooldown * 1.5f;
			crankState = CrankStates.FastSpin;
		}

		private void SwitchToBasicSearch()
		{
			if ((Object)(object)musicAudio.clip != (Object)(object)musicTrackSounds[0])
			{
				musicAudio.clip = musicTrackSounds[0];
				musicAudio.Play();
			}
			box = false;
			partial = false;
			full = true;
			UpdateAnimationState();
			base.agent.speed = 4f;
			crankState = CrankStates.NormalSpin;
		}

		private void SwitchToBasicChase()
		{
			if ((Object)(object)musicAudio.clip != (Object)(object)musicTrackSounds[0])
			{
				musicAudio.clip = musicTrackSounds[0];
				musicAudio.Play();
			}
			attacking = false;
			attackCooldown = maxAttackCooldown * 2f;
			box = false;
			partial = false;
			full = true;
			UpdateAnimationState();
			base.agent.speed = 5.5f;
			crankState = CrankStates.NormalSpin;
		}

		private void SwitchToLeap()
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			numJumps = 0;
			box = false;
			partial = false;
			full = true;
			leapCooldown = maxLeapCooldown;
			UpdateAnimationState();
			base.agent.speed = 0f;
			base.agent.velocity = Vector3.zero;
			base.creatureAnimator.SetTrigger("JumpHop");
			PlayRandomLeapSound();
			if (((NetworkBehaviour)this).IsHost)
			{
				((MonoBehaviour)this).StartCoroutine(Leap());
			}
		}

		private void SwitchToGrab()
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			numGrabs = 1;
			box = false;
			partial = false;
			full = true;
			UpdateAnimationState();
			base.agent.speed = 0f;
			base.agent.velocity = Vector3.zero;
			timeAimingGrab = 0f;
			crankState = CrankStates.FastSpin;
			base.creatureAnimator.SetTrigger("ArmGrab");
			base.creatureAnimator.SetBool("Winding", true);
			PlayRandomGrabReadySound();
			grabCooldown = maxGrabCooldown;
		}

		private void SwitchToRetreat()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			if (boxySearchRoutine.inProgress)
			{
				((EnemyAI)this).StopSearch(boxySearchRoutine, true);
			}
			retreatPosition = ((EnemyAI)this).ChooseFarthestNodeFromPosition(((Component)this).transform.position, false, 0, false, 50, false).position;
			energy = 0f;
			base.agent.speed = 0f;
			base.agent.velocity = Vector3.zero;
			((MonoBehaviour)this).StartCoroutine(SetSpeedAfterDelay(1.2f, 5.5f));
		}

		private IEnumerator SetSpeedAfterDelay(float delay, float speed)
		{
			yield return (object)new WaitForSeconds(delay);
			base.agent.speed = speed;
		}

		private void SwitchToBox()
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			musicAudio.clip = null;
			box = true;
			partial = false;
			full = false;
			UpdateAnimationState();
			base.agent.speed = 0f;
			base.agent.velocity = Vector3.zero;
			crankState = CrankStates.WindUp;
			((Behaviour)interactTrigger).enabled = true;
			if ((Object)(object)boxCollision != (Object)null)
			{
				((Collider)boxCollision).isTrigger = false;
			}
		}

		private void SwitchToFull()
		{
			box = false;
			partial = false;
			full = true;
			UpdateAnimationState();
			base.agent.speed = 4.5f;
			((Behaviour)interactTrigger).enabled = false;
			if ((Object)(object)boxCollision != (Object)null)
			{
				((Collider)boxCollision).isTrigger = true;
			}
		}

		private void SwitchToPartial()
		{
			musicAudio.clip = null;
			box = false;
			partial = true;
			full = false;
			UpdateAnimationState();
			crankState = CrankStates.Static;
			((Behaviour)interactTrigger).enabled = false;
			if ((Object)(object)boxCollision != (Object)null)
			{
				((Collider)boxCollision).isTrigger = true;
			}
		}

		private void UpdateAnimationState()
		{
			base.creatureAnimator.SetBool("box", box);
			base.creatureAnimator.SetBool("partial", partial);
			base.creatureAnimator.SetBool("full", full);
		}

		private void UpdateCooldowns()
		{
			if (leapCooldown > 0f)
			{
				leapCooldown -= Time.deltaTime;
			}
			if (grabCooldown > 0f)
			{
				grabCooldown -= Time.deltaTime;
			}
			if (attackCooldown > 0f)
			{
				attackCooldown -= Time.deltaTime;
			}
		}

		private void UpdateWalking()
		{
			//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)
			timeSinceMoving += Time.deltaTime;
			Vector3 velocity = base.agent.velocity;
			if ((double)((Vector3)(ref velocity)).magnitude < 0.1)
			{
				if (timeSinceMoving > maxTimeSinceMoving && base.creatureAnimator.GetBool("walking"))
				{
					BoxyBooSendStringClientRcp("Idle");
					base.creatureAnimator.SetBool("walking", false);
				}
				return;
			}
			if (!base.creatureAnimator.GetBool("walking"))
			{
				BoxyBooSendStringClientRcp("Walking");
				base.creatureAnimator.SetBool("walking", true);
			}
			timeSinceMoving = 0f;
		}

		private void UpdateEnergy(BoxyStates boxyState)
		{
			switch (boxyState)
			{
			case BoxyStates.BasicChase:
				energy -= Time.deltaTime * 0.5f;
				break;
			case BoxyStates.AdvancedChase:
				energy -= Time.deltaTime;
				break;
			case BoxyStates.BasicSearch:
				energy -= Time.deltaTime * 0.3333f;
				break;
			case BoxyStates.AdvancedSearch:
				energy -= Time.deltaTime * 0.75f;
				break;
			case BoxyStates.Box:
				energy += Time.deltaTime;
				break;
			}
		}

		private void UpdateCrank(CrankStates crankState, bool reversing = false)
		{
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			switch (crankState)
			{
			case CrankStates.WindUp:
				num = 90;
				break;
			case CrankStates.Static:
				num = 0;
				break;
			case CrankStates.NormalSpin:
				num = -270;
				break;
			case CrankStates.FastSpin:
				num = -540;
				break;
			}
			if (reversing)
			{
				crankBackwardsTime -= Time.deltaTime;
				if (crankBackwardsTime <= 0f)
				{
					this.reversing = false;
					return;
				}
				num *= -5;
			}
			crank.Rotate(Vector3.right, (float)num * Time.deltaTime);
		}

		private void UpdateNavMesh()
		{
			if (base.agent.isOnNavMesh)
			{
				timeSinceOnNavMesh = 0f;
				return;
			}
			timeSinceOnNavMesh += Time.deltaTime;
			if (timeSinceOnNavMesh > 5f)
			{
				Debug.Log((object)"Tried to fix Boxy Boo's position.");
				FindAndSetValidNavMeshPosition();
			}
		}

		public void CrankBackwards(PlayerControllerB player)
		{
			if (base.debugEnemyAI)
			{
				Debug.Log((object)$"Boxy: Tried to alert host to crank request. Is client?: {((NetworkBehaviour)this).IsClient}");
			}
			BoxyBooSendStringCrankRpc("ClientCrank");
		}

		public void CheckAttackArea()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			Bounds bounds = ((Collider)((Component)StartOfRound.Instance.localPlayerController).GetComponent<BoxCollider>()).bounds;
			if (((Bounds)(ref bounds)).Intersects(((Collider)attackArea).bounds))
			{
				PlayRandomHitConnectSound();
				if (!base.debugEnemyAI)
				{
					StartOfRound.Instance.localPlayerController.DamagePlayer(27, false, true, (CauseOfDeath)6, 0, false, default(Vector3));
				}
			}
			else
			{
				PlayRandomSwingSound();
			}
		}

		private void InterpretRpcString(string informationString)
		{
			//IL_005e: 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)
			if (informationString.Contains("Vector3:"))
			{
				informationString = informationString.Replace("Vector3:", "").Trim();
				string[] array = informationString.Split(",");
				if (array.Length >= 3)
				{
					landingPosition = new Vector3(float.Parse(array[0]), float.Parse(array[1]), float.Parse(array[2]));
				}
				return;
			}
			if (informationString.Contains("Jumpscare:"))
			{
				if (base.debugEnemyAI)
				{
					Debug.Log((object)"Boxy: Processing Jumpscare clientID");
				}
				informationString = informationString.Replace("Jumpscare:", "").Trim();
				ulong playerID = (ulong)int.Parse(informationString);
				base.creatureAnimator.SetBool("GrabbedTarget", true);
				jumpscare = ((MonoBehaviour)this).StartCoroutine(GrabAndJumpscare(playerID));
				return;
			}
			if (!((NetworkBehaviour)this).IsHost && base.debugEnemyAI)
			{
				Debug.Log((object)("String received from host: " + informationString));
			}
			string text = informationString;
			string text2 = text;
			if (text2 == null)
			{
				return;
			}
			switch (text2.Length)
			{
			case 11:
				switch (text2[0])
				{
				case 'S':
					if (text2 == "SwitchToBox")
					{
						SwitchToBox();
					}
					break;
				case 'C':
					if (text2 == "ClientCrank" && ((NetworkBehaviour)this).IsHost)
					{
						CrankBackwardsHostProcess();
					}
					break;
				case 'A':
					if (text2 == "AttackRight")
					{
						AttackRight();
					}
					break;
				}
				break;
			case 12:
				switch (text2[8])
				{
				case 'G':
					if (text2 == "SwitchToGrab")
					{
						SwitchToGrab();
					}
					break;
				case 'L':
					if (text2 == "SwitchToLeap")
					{
						SwitchToLeap();
					}
					break;
				}
				break;
			case 22:
				if (text2 == "SwitchToAdvancedSearch")
				{
					SwitchToFull();
					SwitchToAdvancedSearch();
				}
				break;
			case 21:
				if (text2 == "SwitchToAdvancedChase")
				{
					SwitchToFull();
					SwitchToAdvancedChase();
				}
				break;
			case 19:
				if (text2 == "SwitchToBasicSearch")
				{
					SwitchToFull();
					SwitchToBasicSearch();
				}
				break;
			case 18:
				if (text2 == "SwitchToBasicChase")
				{
					SwitchToFull();
					SwitchToBasicChase();
				}
				break;
			case 7:
				if (text2 == "Walking")
				{
					base.creatureAnimator.SetBool("walking", true);
				}
				break;
			case 4:
				if (text2 == "Idle")
				{
					base.creatureAnimator.SetBool("walking", false);
				}
				break;
			case 16:
				if (text2 == "HostCrankApprove")
				{
					reversing = true;
					crankBackwardsTime += maxCrankBackwardsTime;
				}
				break;
			case 10:
				if (text2 == "AttackLeft")
				{
					AttackLeft();
				}
				break;
			case 13:
				if (text2 == "FinishArmGrab")
				{
					base.creatureAnimator.SetBool("Winding", false);
				}
				break;
			case 17:
				if (text2 == "PlayJumpAnimation")
				{
					base.creatureAnimator.SetTrigger("JumpHop");
					if ((((NetworkBehaviour)this).IsHost || ((NetworkBehaviour)this).IsServer) && base.currentBehaviourStateIndex == 3)
					{
						leapCooldown += 0.65f;
						grabCooldown += 0.65f;
						attackCooldown += 0.65f;
					}
				}
				break;
			case 15:
				if (text2 == "SwitchToRetreat")
				{
					SwitchToRetreat();
					SwitchToPartial();
				}
				break;
			case 26:
				if (text2 == "SetupClientInteractTrigger")
				{
					SetupStartTrigger();
				}
				break;
			case 5:
			case 6:
			case 8:
			case 9:
			case 14:
			case 20:
			case 23:
			case 24:
			case 25:
				break;
			}
		}

		private void AttackLeft()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			base.agent.speed = 0f;
			base.agent.velocity = Vector3.zero;
			base.creatureAnimator.SetTrigger("AttackLeft");
			((Collider)((Component)base.agent).gameObject.GetComponent<BoxCollider>()).isTrigger = false;
		}

		private void AttackRight()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			base.agent.speed = 0f;
			base.agent.velocity = Vector3.zero;
			base.creatureAnimator.SetTrigger("AttackRight");
			((Collider)((Component)base.agent).gameObject.GetComponent<BoxCollider>()).isTrigger = false;
		}

		public void ResetAfterAttack()
		{
			((Collider)((Component)base.agent).gameObject.GetComponent<BoxCollider>()).isTrigger = true;
			attacking = false;
			switch (base.currentBehaviourStateIndex)
			{
			case 3:
				base.agent.speed = 6f;
				break;
			case 1:
				base.agent.speed = 5f;
				break;
			case 2:
				base.agent.speed = 5.5f;
				break;
			case 0:
				base.agent.speed = 4f;
				break;
			case 4:
				base.agent.speed = 0f;
				break;
			}
		}

		private void AttackRandom()
		{
			attacking = true;
			if (rng.Next(2) == 0)
			{
				BoxyBooSendStringClientRcp("AttackLeft");
			}
			else
			{
				BoxyBooSendStringClientRcp("AttackRight");
			}
		}

		private void CrankBackwardsHostProcess()
		{
			if (base.debugEnemyAI)
			{
				Debug.Log((object)$"CrankBackwardsHostProcess called. Host: {((NetworkBehaviour)this).IsHost}, Server: {((NetworkBehaviour)this).IsServer}, Energy: {energy}");
			}
			if (!((NetworkBehaviour)this).IsHost && !((NetworkBehaviour)this).IsServer)
			{
				return;
			}
			if (box && energy < 22f)
			{
				energy -= 2f;
				if (energy < 0f)
				{
					energy = 0f;
				}
				BoxyBooSendStringClientRcp("HostCrankApprove");
				Debug.Log((object)"Request to uncrank approved.");
			}
			else
			{
				Debug.Log((object)"Request to uncrank denied.");
			}
		}

		public void FinishGrab()
		{
			numGrabs = 0;
			if (base.debugEnemyAI)
			{
				Debug.Log((object)"Finished Boxy Grab");
			}
		}

		private void CheckArmCollision()
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			if (!checkingArmCollision || !((NetworkBehaviour)this).IsHost || !((Object)(object)jumpscareCollision != (Object)null))
			{
				return;
			}
			for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++)
			{
				if (grabbedPlayer || jumpscaring)
				{
					continue;
				}
				Bounds bounds = ((Collider)((Component)StartOfRound.Instance.allPlayerScripts[i]).GetComponent<BoxCollider>()).bounds;
				if (((Bounds)(ref bounds)).Intersects(((Collider)jumpscareCollision).bounds))
				{
					if (base.debugEnemyAI)
					{
						Debug.Log((object)"Boxy: Arm Collided with player.");
					}
					jumpscaring = true;
					grabbedPlayer = true;
					checkingArmCollision = false;
					ulong actualClientId = StartOfRound.Instance.allPlayerScripts[i].actualClientId;
					((EnemyAI)this).SwitchToBehaviourState(5);
					BoxyBooSendStringClientRcp("Jumpscare:" + actualClientId);
				}
			}
		}

		public void SetArmGrabChech(bool value)
		{
			checkingArmCollision = value;
		}

		public void EndJumpscare()
		{
			//IL_001b: 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_0041: 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_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: 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)
			if ((Object)(object)base.inSpecialAnimationWithPlayer != (Object)null)
			{
				base.inSpecialAnimationWithPlayer.DropBlood(Vector3.forward, true, false);
				base.inSpecialAnimationWithPlayer.DropBlood(Vector3.left, true, false);
				base.inSpecialAnimationWithPlayer.DropBlood(Vector3.right, true, false);
				base.inSpecialAnimationWithPlayer.DropBlood(Vector3.up, true, false);
				base.inSpecialAnimationWithPlayer.DropBlood(Vector3.back, true, false);
				base.inSpecialAnimationWithPlayer.DropBlood(Vector3.down, true, false);
				base.inSpecialAnimationWithPlayer.DamagePlayer(10000, false, true, (CauseOfDeath)0, 7, false, default(Vector3));
				base.inSpecialAnimationWithPlayer.inSpecialInteractAnimation = false;
				base.inSpecialAnimationWithPlayer.snapToServerPosition = false;
				base.inSpecialAnimationWithPlayer.disableLookInput = false;
				base.inSpecialAnimationWithPlayer = null;
			}
			grabbedPlayer = false;
			jumpscaring = false;
			base.creatureAnimator.SetBool("GrabbedTarget", false);
			base.targetPlayer = null;
			base.inSpecialAnimation = false;
			((EnemyAI)this).SwitchToBehaviourState(1);
			BoxyBooSendStringClientRcp("SwitchToAdvancedSearch");
			if (base.debugEnemyAI)
			{
				Debug.Log((object)"Boxy: Ended Jumpscare.");
			}
		}

		private IEnumerator GrabAndJumpscare(ulong playerID)
		{
			if (base.debugEnemyAI)
			{
				Debug.Log((object)"Boxy: Beginning Jumpscare");
			}
			base.agent.speed = 0f;
			base.agent.velocity = Vector3.zero;
			base.inSpecialAnimationWithPlayer = StartOfRound.Instance.allPlayerScripts[playerID];
			base.targetPlayer = base.inSpecialAnimationWithPlayer;
			if ((Object)(object)base.inSpecialAnimationWithPlayer != (Object)null)
			{
				base.inSpecialAnimation = true;
				base.inSpecialAnimationWithPlayer.inSpecialInteractAnimation = true;
				base.inSpecialAnimationWithPlayer.snapToServerPosition = true;
				base.inSpecialAnimationWithPlayer.disableLookInput = true;
				base.inSpecialAnimationWithPlayer.DropAllHeldItems(true, false);
			}
			bool inArmGrab = true;
			float timeElapsed = 0f;
			while (inArmGrab && timeElapsed < 2f && (Object)(object)base.inSpecialAnimationWithPlayer != (Object)null)
			{
				Vector3 diff2 = ((Component)this).transform.position - ((Component)base.targetPlayer).transform.position;
				diff2.y = 0f;
				((Component)base.inSpecialAnimationWithPlayer).transform.position = jumpscareAttachPoint.position + Vector3.down;
				((Component)base.inSpecialAnimationWithPlayer).transform.rotation = Quaternion.LookRotation(diff2);
				base.inSpecialAnimationWithPlayer.ResetFallGravity();
				if (base.creatureAnimator.GetAnimatorStateName(0, true) == "Boxy_Jumpscare")
				{
					inArmGrab = false;
				}
				timeElapsed += Time.deltaTime;
				yield return null;
			}
			bool inJumpscare = true;
			timeElapsed = 0f;
			while (inJumpscare && timeElapsed < 1.7f && (Object)(object)base.inSpecialAnimationWithPlayer != (Object)null)
			{
				Vector3 diff3 = ((Component)this).transform.position - ((Component)base.targetPlayer).transform.position;
				diff3.y = 0f;
				((Component)base.inSpecialAnimationWithPlayer).transform.position = jumpscareAttachPoint.position + Vector3.down;
				((Component)base.inSpecialAnimationWithPlayer).transform.rotation = Quaternion.LookRotation(diff3);
				base.inSpecialAnimationWithPlayer.ResetFallGravity();
				timeElapsed += Time.deltaTime;
				yield return null;
			}
		}

		[ClientRpc]
		private void BoxyBooSendStringClientRcp(string informationString)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Invalid comparison between Unknown and I4
			//IL_004b: 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_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: 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_0096: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if ((Object)(object)networkManager == (Object)null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1245740165u, val, (RpcDelivery)0);
				bool flag = informationString != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(informationString, false);
				}
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1245740165u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost || ((NetworkBehaviour)this).IsServer))
			{
				if (!((NetworkBehaviour)this).IsHost && !((NetworkBehaviour)this).IsServer)
				{
					InterpretRpcString(informationString);
				}
				else
				{
					InterpretRpcString(informationString);
				}
			}
		}

		private static void __rpc_handler_1245740165(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0027: 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_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if ((Object)(object)networkManager != (Object)null && networkManager.IsListening)
			{
				bool flag = false;
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string informationString = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref informationString, false);
				}
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((BoxyBooAI)(object)target).BoxyBooSendStringClientRcp(informationString);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void BoxyBooSendStringCrankRpc(string informationString)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Invalid comparison between Unknown and I4
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Invalid comparison between Unknown and I4
			//IL_0046: 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_0054: 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_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (!((Object)(object)networkManager != (Object)null) || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1245549521u, val, (RpcDelivery)0);
				bool flag = informationString != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(informationString, false);
				}
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1245549521u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				if (base.debugEnemyAI)
				{
					Debug.Log((object)("[Server] Processing on server with information: " + informationString));
				}
				InterpretClientCrank(informationString);
			}
		}

		private void InterpretClientCrank(string informationString)
		{
			if (base.debugEnemyAI)
			{
				Debug.Log((object)$"InterpretClientCrank tried to interpret the crank received.  IsClient? {((NetworkBehaviour)this).IsClient}");
			}
			if (informationString == "ClientCrank" && ((NetworkBehaviour)this).IsHost)
			{
				if (base.debugEnemyAI)
				{
					Debug.Log((object)$"InterpretClientCrank tried to interpret the crank received.  IsClient? {((NetworkBehaviour)this).IsClient}");
				}
				CrankBackwardsHostProcess();
			}
		}

		private static void __rpc_handler_1245549521(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0027: 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_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if ((Object)(object)networkManager != (Object)null && networkManager.IsListening)
			{
				bool flag = false;
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string informationString = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref informationString, false);
				}
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((BoxyBooAI)(object)target).BoxyBooSendStringCrankRpc(informationString);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_BoxyBooAI()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(1245740165u, new RpcReceiveHandler(__rpc_handler_1245740165));
			NetworkManager.__rpc_func_table.Add(1245549521u, new RpcReceiveHandler(__rpc_handler_1245549521));
		}

		public void PlayRandomWalkSound()
		{
			if (walkSounds != null && (Object)(object)base.creatureSFX != (Object)null)
			{
				RoundManager.PlayRandomClip(base.creatureSFX, walkSounds, true, 3f, 0, 1000);
			}
		}

		public void PlayRandomSwingSound()
		{
			if (attackSounds != null && (Object)(object)hitConnectAudio != (Object)null)
			{
				RoundManager.PlayRandomClip(hitConnectAudio, attackSounds, true, 2f, 0, 1000);
			}
		}

		public void PlayRandomHitConnectSound()
		{
			if (hitConnectSounds != null && (Object)(object)hitConnectAudio != (Object)null)
			{
				RoundManager.PlayRandomClip(hitConnectAudio, hitConnectSounds, true, 2f, 0, 1000);
				PlayRandomHitConnectslashSound();
			}
		}

		public void PlayRandomHitConnectslashSound()
		{
			if (hitConnectSlashSounds != null && (Object)(object)jumpAudio != (Object)null)
			{
				RoundManager.PlayRandomClip(jumpAudio, hitConnectSlashSounds, true, 2f, 0, 1000);
			}
		}

		public void PlayRandomGrabReadySound()
		{
			if (grabReadySounds != null && (Object)(object)grabAudioPoint != (Object)null)
			{
				RoundManager.PlayRandomClip(grabAudioPoint, grabReadySounds, true, 2f, 0, 1000);
			}
		}

		public void PlayRandomGrabLaunchSound()
		{
			if (grabLaunchSounds != null && (Object)(object)grabAudioPoint != (Object)null)
			{
				RoundManager.PlayRandomClip(grabAudioPoint, grabLaunchSounds, true, 3f, 0, 1000);
			}
		}

		public void PlayRandomBoxLandSound()
		{
			if (boxLandSounds != null && (Object)(object)base.creatureSFX != (Object)null)
			{
				RoundManager.PlayRandomClip(base.creatureSFX, boxLandSounds, true, 1f, 0, 1000);
			}
		}

		public void PlayRandomLandingSound()
		{
			if (landSounds != null && (Object)(object)base.creatureSFX != (Object)null)
			{
				RoundManager.PlayRandomClip(base.creatureSFX, landSounds, true, 1f, 0, 1000);
			}
		}

		public void PlayRandomCrankSound()
		{
			if (crankSounds != null && (Object)(object)crankAudio != (Object)null)
			{
				RoundManager.PlayRandomClip(crankAudio, crankSounds, true, 1f, 0, 1000);
			}
		}

		public void PlayRandomLeapSound()
		{
			if (leapSounds != null && (Object)(object)jumpAudio != (Object)null)
			{
				RoundManager.PlayRandomClip(jumpAudio, leapSounds, true, 4f, 0, 1000);
			}
		}

		public void PlayRandomFullPopSound()
		{
			if (popSounds != null && (Object)(object)base.creatureSFX != (Object)null)
			{
				RoundManager.PlayRandomClip(base.creatureSFX, popSounds, true, 3f, 0, 1000);
			}
		}

		public void PlayRandomCreakSound()
		{
			if (creakSounds != null && (Object)(object)creakAudio != (Object)null)
			{
				RoundManager.PlayRandomClip(creakAudio, creakSounds, true, 3f, 0, 1000);
			}
		}

		public void PlayRandomJumpscareSound()
		{
			if (jumpscareSounds != null && (Object)(object)hitConnectAudio != (Object)null)
			{
				RoundManager.PlayRandomClip(hitConnectAudio, jumpscareSounds, true, 3f, 0, 1000);
			}
		}

		public void PlayRandomPartialRetractSound()
		{
			if (partialRetractSounds != null && (Object)(object)retractAudio != (Object)null)
			{
				RoundManager.PlayRandomClip(retractAudio, partialRetractSounds, true, 2.5f, 0, 1000);
			}
		}

		public void PlayRandomFullRetractSound()
		{
			if (fullRetractSounds != null && (Object)(object)retractAudio != (Object)null)
			{
				RoundManager.PlayRandomClip(retractAudio, fullRetractSounds, true, 2.5f, 0, 1000);
			}
		}

		public override void HitEnemy(int force = 1, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
		{
			if (base.currentBehaviourStateIndex != 8 && base.currentBehaviourStateIndex != 4)
			{
				((EnemyAI)this).HitEnemy(force, playerWhoHit, playHitSFX, hitID);
				trackedDamage += force;
				if (((NetworkBehaviour)this).IsHost && trackedDamage > maxTrackedDamaged)
				{
					shouldEnterRetreat = true;
				}
			}
		}
	}
	public class BoxyBooAnimationEvents : MonoBehaviour
	{
		public BoxyBooAI scriptReference;

		public void PlayRandomWalkSound()
		{
			if ((Object)(object)scriptReference != (Object)null)
			{
				scriptReference.PlayRandomWalkSound();
			}
		}

		public void PlayRandomLandingSound()
		{
			if ((Object)(object)scriptReference != (Object)null)
			{
				scriptReference.PlayRandomLandingSound();
			}
		}

		public void PlayRandomBoxLandSound()
		{
			if ((Object)(object)scriptReference != (Object)null)
			{
				scriptReference.PlayRandomBoxLandSound();
			}
		}

		public void CheckAttackArea()
		{
			if ((Object)(object)scriptReference != (Object)null)
			{
				scriptReference.CheckAttackArea();
			}
		}

		public void PlayRandomGrabLaunchSound()
		{
			if ((Object)(object)scriptReference != (Object)null)
			{
				scriptReference.PlayRandomGrabLaunchSound();
			}
		}

		public void ResetAfterAttack()
		{
			if ((Object)(object)scriptReference != (Object)null)
			{
				scriptReference.ResetAfterAttack();
			}
		}

		public void PlayRandomFullPopSound()
		{
			if ((Object)(object)scriptReference != (Object)null)
			{
				scriptReference.PlayRandomFullPopSound();
			}
		}

		public void PlayRandomGrabReadySound()
		{
			if ((Object)(object)scriptReference != (Object)null)
			{
				scriptReference.PlayRandomGrabReadySound();
			}
		}

		public void PlayRandomJumpscareSound()
		{
			if ((Object)(object)scriptReference != (Object)null)
			{
				scriptReference.PlayRandomJumpscareSound();
			}
		}

		public void PlayRandomPartialRetractSound()
		{
			if ((Object)(object)scriptReference != (Object)null)
			{
				scriptReference.PlayRandomPartialRetractSound();
			}
		}

		public void PlayRandomFullRetractSound()
		{
			if ((Object)(object)scriptReference != (Object)null)
			{
				scriptReference.PlayRandomFullRetractSound();
			}
		}

		public void FinishGrab()
		{
			if ((Object)(object)scriptReference != (Object)null)
			{
				scriptReference.FinishGrab();
			}
		}

		public void EndJumpscare()
		{
			if ((Object)(object)scriptReference != (Object)null)
			{
				scriptReference.EndJumpscare();
			}
		}

		public void SetArmGrabCheck(int value)
		{
			if ((Object)(object)scriptReference != (Object)null)
			{
				if (value == 2)
				{
					scriptReference.SetArmGrabChech(value: false);
				}
				else
				{
					scriptReference.SetArmGrabChech(value: true);
				}
			}
		}
	}
	public class PlaytimeConfig
	{
		internal enum RarityAddTypes
		{
			All,
			Modded,
			Vanilla,
			List
		}

		private static AssetBundle assetBundle;

		private static LevelTypes chosenRegistrationMethod = (LevelTypes)(-1);

		private static RarityAddTypes defaultCreatureRegistrationMethod = RarityAddTypes.All;

		private static int missDelightRarity;

		private static int huggyWuggyRarity;

		private static int dogdayMonsterRarity;

		private static int boxyBooMonsterRarity;

		public static void ConfigureAndRegisterAssets(LethalPlaytime Instance, ManualLogSource Logger)
		{
			LoadAssets();
			CreateConfigEntries(Instance, Logger);
			ConfigureAndRegisterMissDelight();
			ConfigureAndRegisterHuggyWuggy();
			ConfigureAndRegisterDogday();
			ConfigureAndRegisterBoxyBoo();
		}

		internal static void CreateConfigEntries(LethalPlaytime Instance, ManualLogSource Logger)
		{
			//IL_004a: 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_0056: 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)
			ConfigEntry<RarityAddTypes> val = ((BaseUnityPlugin)Instance).Config.Bind<RarityAddTypes>("Creatures", "Registration Method", RarityAddTypes.All, "The method to add creatures to the level. \n Default = All \n Vanilla \n Modded \n List (Not yet implemented for creatures, defaults to All)");
			EnumDropDownConfigItem<RarityAddTypes> val2 = new EnumDropDownConfigItem<RarityAddTypes>(val);
			switch (val.Value)
			{
			case RarityAddTypes.All:
				chosenRegistrationMethod = (LevelTypes)(-1);
				break;
			case RarityAddTypes.Vanilla:
				chosenRegistrationMethod = (LevelTypes)15356;
				break;
			case RarityAddTypes.Modded:
				chosenRegistrationMethod = (LevelTypes)1024;
				break;
			case RarityAddTypes.List:
				chosenRegistrationMethod = (LevelTypes)(-1);
				break;
			}
			ConfigEntry<int> val3 = Instance.CreateIntSliderConfig("Miss Delight", 65, "Adjust how often you see the enemy Miss Delight.", 0, 400, "Creatures");
			missDelightRarity = val3.Value;
			ConfigEntry<int> val4 = Instance.CreateIntSliderConfig("Huggy Wuggy", 55, "Adjust how often you see Huggy Wuggy.", 0, 400, "Creatures");
			huggyWuggyRarity = val4.Value;
			ConfigEntry<int> val5 = Instance.CreateIntSliderConfig("Monster Dogday", 55, "Adjust how often you see Dogday.", 0, 400, "Creatures");
			dogdayMonsterRarity = val5.Value;
			ConfigEntry<int> val6 = Instance.CreateIntSliderConfig("Boxy Boo", 55, "Adjust how often you see Boxy Boo.", 0, 400, "Creatures");
			boxyBooMonsterRarity = val6.Value;
			Logger.LogInfo((object)("Miss Delight rarity set to: " + missDelightRarity));
			Logger.LogInfo((object)("Huggy Wuggy rarity set to: " + huggyWuggyRarity));
			Logger.LogInfo((object)("Dogday rarity set to: " + dogdayMonsterRarity));
			Logger.LogInfo((object)("Boxy Boo rarity set to: " + boxyBooMonsterRarity));
		}

		private static void ConfigureAndRegisterMissDelight()
		{
			//IL_03b2: Unknown result type (might be due to invalid IL or missing references)
			EnemyType val = assetBundle.LoadAsset<EnemyType>("Miss Delight");
			MissDelightAI missDelightAI = val.enemyPrefab.AddComponent<MissDelightAI>();
			((EnemyAI)missDelightAI).creatureVoice = val.enemyPrefab.GetComponent<AudioSource>();
			((EnemyAI)missDelightAI).creatureSFX = val.enemyPrefab.GetComponent<AudioSource>();
			missDelightAI.weaponAudioPoint = ((Component)FindDeepChild(val.enemyPrefab.transform, "DelightWeaponAudio")).GetComponent<AudioSource>();
			((EnemyAI)missDelightAI).agent = val.enemyPrefab.GetComponent<NavMeshAgent>();
			((EnemyAI)missDelightAI).creatureAnimator = val.enemyPrefab.GetComponent<Animator>();
			((EnemyAI)missDelightAI).syncMovementSpeed = 0.1f;
			((EnemyAI)missDelightAI).exitVentAnimationTime = 1f;
			((EnemyAI)missDelightAI).eye = val.enemyPrefab.transform.Find("Eye");
			((EnemyAI)missDelightAI).enemyType = val;
			((EnemyAI)missDelightAI).updatePositionThreshold = 0.1f;
			((EnemyAI)missDelightAI).enemyBehaviourStates = (EnemyBehaviourState[])(object)new EnemyBehaviourState[4];
			((EnemyAI)missDelightAI).AIIntervalTime = 0.08f;
			missDelightAI.weaponCollider = ((Component)FindDeepChild(val.enemyPrefab.transform, "JNT_R_Hand_IK")).GetComponent<SphereCollider>();
			((Component)val.enemyPrefab.transform.Find("Teacher")).GetComponent<EnemyAICollisionDetect>().mainScript = (EnemyAI)(object)missDelightAI;
			missDelightAI.footstepClips = (AudioClip[])(object)new AudioClip[7];
			missDelightAI.footstepClips[0] = assetBundle.LoadAsset<AudioClip>("DelightFootstep1");
			missDelightAI.footstepClips[1] = assetBundle.LoadAsset<AudioClip>("DelightFootstep2");
			missDelightAI.footstepClips[2] = assetBundle.LoadAsset<AudioClip>("DelightFootstep3");
			missDelightAI.footstepClips[3] = assetBundle.LoadAsset<AudioClip>("DelightFootstep4");
			missDelightAI.footstepClips[4] = assetBundle.LoadAsset<AudioClip>("DelightFootstep5");
			missDelightAI.footstepClips[5] = assetBundle.LoadAsset<AudioClip>("DelightFootstep6");
			missDelightAI.footstepClips[6] = assetBundle.LoadAsset<AudioClip>("DelightFootstep7");
			missDelightAI.weaponSwingClip = (AudioClip[])(object)new AudioClip[1];
			missDelightAI.weaponSwingClip[0] = assetBundle.LoadAsset<AudioClip>("DelightWeaponSwing1");
			missDelightAI.weaponSwingVoiceClips = (AudioClip[])(object)new AudioClip[4];
			missDelightAI.weaponSwingVoiceClips[0] = assetBundle.LoadAsset<AudioClip>("DelightSwingVoice1");
			missDelightAI.weaponSwingVoiceClips[1] = assetBundle.LoadAsset<AudioClip>("DelightSwingVoice2");
			missDelightAI.weaponSwingVoiceClips[2] = assetBundle.LoadAsset<AudioClip>("DelightSwingVoice3");
			missDelightAI.weaponSwingVoiceClips[3] = assetBundle.LoadAsset<AudioClip>("DelightSwingVoice4");
			missDelightAI.weaponImpactClips = (AudioClip[])(object)new AudioClip[2];
			missDelightAI.weaponImpactClips[0] = assetBundle.LoadAsset<AudioClip>("DelightWeaponImpact1");
			missDelightAI.weaponImpactClips[1] = assetBundle.LoadAsset<AudioClip>("DelightWeaponImpact2");
			missDelightAI.laughClips = (AudioClip[])(object)new AudioClip[4];
			missDelightAI.laughClips[0] = assetBundle.LoadAsset<AudioClip>("DelightLaugh1");
			missDelightAI.laughClips[1] = assetBundle.LoadAsset<AudioClip>("DelightLaugh2");
			missDelightAI.laughClips[2] = assetBundle.LoadAsset<AudioClip>("DelightLaugh3");
			missDelightAI.laughClips[3] = assetBundle.LoadAsset<AudioClip>("DelightLaugh4");
			missDelightAI.doorSmashClips = (AudioClip[])(object)new AudioClip[1];
			missDelightAI.doorSmashClips[0] = assetBundle.LoadAsset<AudioClip>("DelightDoorKick 1");
			missDelightAI.growlClips = (AudioClip[])(object)new AudioClip[4];
			missDelightAI.growlClips[0] = assetBundle.LoadAsset<AudioClip>("DelightBreathe1");
			missDelightAI.growlClips[1] = assetBundle.LoadAsset<AudioClip>("DelightBreathe2");
			missDelightAI.growlClips[2] = assetBundle.LoadAsset<AudioClip>("DelightBreathe3");
			missDelightAI.growlClips[3] = assetBundle.LoadAsset<AudioClip>("DelightBreathe4");
			NetworkPrefabs.RegisterNetworkPrefab(val.enemyPrefab);
			TerminalNode val2 = assetBundle.LoadAsset<TerminalNode>("Miss Delight Terminal Node");
			TerminalKeyword val3 = assetBundle.LoadAsset<TerminalKeyword>("Miss Delight Terminal Keyword");
			Enemies.RegisterEnemy(val, missDelightRarity, chosenRegistrationMethod, val2, val3);
		}

		private static void ConfigureAndRegisterHuggyWuggy()
		{
			//IL_03d0: Unknown result type (might be due to invalid IL or missing references)
			EnemyType val = assetBundle.LoadAsset<EnemyType>("Huggy Wuggy");
			HuggyAI huggyAI = val.enemyPrefab.AddComponent<HuggyAI>();
			((EnemyAI)huggyAI).creatureVoice = val.enemyPrefab.GetComponent<AudioSource>();
			((EnemyAI)huggyAI).creatureSFX = val.enemyPrefab.GetComponent<AudioSource>();
			huggyAI.voiceAudio = ((Component)val.enemyPrefab.transform.Find("VoiceAudio")).GetComponent<AudioSource>();
			huggyAI.voiceFarAudio = ((Component)val.enemyPrefab.transform.Find("VoiceFarAudio")).GetComponent<AudioSource>();
			huggyAI.slashAudio = ((Component)val.enemyPrefab.transform.Find("SlashAudio")).GetComponent<AudioSource>();
			((EnemyAI)huggyAI).enemyBehaviourStates = (EnemyBehaviourState[])(object)new EnemyBehaviourState[6];
			((EnemyAI)huggyAI).AIIntervalTime = 0.08f;
			((EnemyAI)huggyAI).syncMovementSpeed = 0.1f;
			((EnemyAI)huggyAI).updatePositionThreshold = 0.12f;
			((EnemyAI)huggyAI).exitVentAnimationTime = 1f;
			((EnemyAI)huggyAI).enemyType = val;
			((EnemyAI)huggyAI).eye = val.enemyPrefab.transform.Find("Eye");
			((EnemyAI)huggyAI).agent = val.enemyPrefab.GetComponent<NavMeshAgent>();
			((EnemyAI)huggyAI).creatureAnimator = val.enemyPrefab.GetComponent<Animator>();
			huggyAI.jumpScarePoint = FindDeepChild(val.enemyPrefab.transform, "JumpScarePoint");
			((EnemyAI)huggyAI).agent.baseOffset = 0f;
			((Component)val.enemyPrefab.transform.Find("HuggyWuggyModelContainer")).GetComponent<EnemyAICollisionDetect>().mainScript = (EnemyAI)(object)huggyAI;
			huggyAI.weaponSwingCheckArea = ((Component)val.enemyPrefab.transform.Find("AttackCollisionArea")).GetComponent<BoxCollider>();
			huggyAI.sitCollisionArea = ((Component)val.enemyPrefab.transform.Find("SitCollision")).GetComponent<BoxCollider>();
			huggyAI.footstepClips = (AudioClip[])(object)new AudioClip[3]
			{
				assetBundle.LoadAsset<AudioClip>("HuggyStomp1"),
				assetBundle.LoadAsset<AudioClip>("HuggyStomp2"),
				assetBundle.LoadAsset<AudioClip>("HuggyStomp3")
			};
			huggyAI.attackSwingClips = (AudioClip[])(object)new AudioClip[4]
			{
				assetBundle.LoadAsset<AudioClip>("HuggyAttack1"),
				assetBundle.LoadAsset<AudioClip>("HuggyAttack2"),
				assetBundle.LoadAsset<AudioClip>("HuggyAttack3"),
				assetBundle.LoadAsset<AudioClip>("HuggyAttack4")
			};
			huggyAI.attackVoiceClips = (AudioClip[])(object)new AudioClip[3]
			{
				assetBundle.LoadAsset<AudioClip>("HuggyAttackVoice1"),
				assetBundle.LoadAsset<AudioClip>("HuggyAttackVoice2"),
				assetBundle.LoadAsset<AudioClip>("HuggyAttackVoice3")
			};
			huggyAI.crouchClips = (AudioClip[])(object)new AudioClip[1] { assetBundle.LoadAsset<AudioClip>("HuggyCrouch1") };
			huggyAI.sitDownClips = (AudioClip[])(object)new AudioClip[1] { assetBundle.LoadAsset<AudioClip>("HuggySitDown") };
			huggyAI.sitUpClips = (AudioClip[])(object)new AudioClip[1] { assetBundle.LoadAsset<AudioClip>("HuggySitUp") };
			huggyAI.roarClips = (AudioClip[])(object)new AudioClip[3]
			{
				assetBundle.LoadAsset<AudioClip>("HuggyRoar1"),
				assetBundle.LoadAsset<AudioClip>("HuggyRoar2"),
				assetBundle.LoadAsset<AudioClip>("HuggyRoar3")
			};
			huggyAI.roarFarClips = (AudioClip[])(object)new AudioClip[3]
			{
				assetBundle.LoadAsset<AudioClip>("HuggyRoar1Far"),
				assetBundle.LoadAsset<AudioClip>("HuggyRoar2Far"),
				assetBundle.LoadAsset<AudioClip>("HuggyRoar3Far")
			};
			huggyAI.slashClips = (AudioClip[])(object)new AudioClip[1] { assetBundle.LoadAsset<AudioClip>("HuggySlash") };
			huggyAI.jumpscareClips = (AudioClip[])(object)new AudioClip[1];
			huggyAI.jumpscareClips[0] = assetBundle.LoadAsset<AudioClip>("Huggie_Jumpscare");
			TerminalNode val2 = assetBundle.LoadAsset<TerminalNode>("Huggy Wuggy Terminal Node");
			TerminalKeyword val3 = assetBundle.LoadAsset<TerminalKeyword>("Huggy Wuggy Terminal Keyword");
			NetworkPrefabs.RegisterNetworkPrefab(val.enemyPrefab);
			Enemies.RegisterEnemy(val, huggyWuggyRarity, chosenRegistrationMethod, val2, val3);
		}

		private static void ConfigureAndRegisterDogday()
		{
			//IL_037b: Unknown result type (might be due to invalid IL or missing references)
			EnemyType val = assetBundle.LoadAsset<EnemyType>("Dogday Monster");
			DogdayAI dogdayAI = val.enemyPrefab.AddComponent<DogdayAI>();
			((EnemyAI)dogdayAI).creatureVoice = val.enemyPrefab.GetComponent<AudioSource>();
			((EnemyAI)dogdayAI).creatureSFX = val.enemyPrefab.GetComponent<AudioSource>();
			((EnemyAI)dogdayAI).enemyBehaviourStates = (EnemyBehaviourState[])(object)new EnemyBehaviourState[4];
			((EnemyAI)dogdayAI).AIIntervalTime = 0.1f;
			((EnemyAI)dogdayAI).syncMovementSpeed = 0.1f;
			((EnemyAI)dogdayAI).updatePositionThreshold = 0.12f;
			((EnemyAI)dogdayAI).exitVentAnimationTime = 1f;
			((EnemyAI)dogdayAI).enemyType = val;
			((EnemyAI)dogdayAI).eye = val.enemyPrefab.transform.Find("Eye");
			((EnemyAI)dogdayAI).agent = val.enemyPrefab.GetComponent<NavMeshAgent>();
			((EnemyAI)dogdayAI).creatureAnimator = ((Component)val.enemyPrefab.transform.Find("DogdayModelContainer")).GetComponent<Animator>();
			((EnemyAI)dogdayAI).enemyHP = 6;
			((Component)val.enemyPrefab.transform.Find("DogdayCollision")).GetComponent<EnemyAICollisionDetect>().mainScript = (EnemyAI)(object)dogdayAI;
			DogdayAnimationEvents dogdayAnimationEvents = ((Component)val.enemyPrefab.transform.Find("DogdayModelContainer")).gameObject.AddComponent<DogdayAnimationEvents>();
			dogdayAnimationEvents.scriptReference = dogdayAI;
			dogdayAI.attackArea = ((Component)val.enemyPrefab.transform.Find("AttackArea")).GetComponent<BoxCollider>();
			dogdayAI.walkAudio = ((Component)val.enemyPrefab.transform.Find("FootStepAudio")).GetComponent<AudioSource>();
			dogdayAI.staticSoundSource = ((Component)val.enemyPrefab.transform.Find("StaticAudio")).GetComponent<AudioSource>();
			dogdayAI.hitConnectAudio = ((Component)val.enemyPrefab.transform.Find("HitAudio")).GetComponent<AudioSource>();
			dogdayAI.dogdayModel = val.enemyPrefab.transform.Find("DogdayModelContainer");
			dogdayAI.walkSounds = (AudioClip[])(object)new AudioClip[3]
			{
				assetBundle.LoadAsset<AudioClip>("HuggyStomp1"),
				assetBundle.LoadAsset<AudioClip>("HuggyStomp2"),
				assetBundle.LoadAsset<AudioClip>("HuggyStomp3")
			};
			dogdayAI.gurrgleSounds = (AudioClip[])(object)new AudioClip[5]
			{
				assetBundle.LoadAsset<AudioClip>("DogdayMonsterGurgle1"),
				assetBundle.LoadAsset<AudioClip>("DogdayMonsterGurgle2"),
				assetBundle.LoadAsset<AudioClip>("DogdayMonsterGurgle3"),
				assetBundle.LoadAsset<AudioClip>("DogdayMonsterGurgle4"),
				assetBundle.LoadAsset<AudioClip>("DogdayMonsterGurgle5")
			};
			((EnemyAI)dogdayAI).dieSFX = assetBundle.LoadAsset<AudioClip>("DogdayDie1");
			dogdayAI.hitSounds = (AudioClip[])(object)new AudioClip[3]
			{
				assetBundle.LoadAsset<AudioClip>("DogdayHit1"),
				assetBundle.LoadAsset<AudioClip>("DogdayHit2"),
				assetBundle.LoadAsset<AudioClip>("DogdayHit3")
			};
			dogdayAI.attackSounds = (AudioClip[])(object)new AudioClip[3]
			{
				assetBundle.LoadAsset<AudioClip>("DogdayAttack1"),
				assetBundle.LoadAsset<AudioClip>("DogdayAttack2"),
				assetBundle.LoadAsset<AudioClip>("DogdayAttack3")
			};
			dogdayAI.hitConnectSounds = (AudioClip[])(object)new AudioClip[4]
			{
				assetBundle.LoadAsset<AudioClip>("DogdayHitConnect1"),
				assetBundle.LoadAsset<AudioClip>("DogdayHitConnect2"),
				assetBundle.LoadAsset<AudioClip>("DogdayHitConnect3"),
				assetBundle.LoadAsset<AudioClip>("DogdayHitConnect4")
			};
			TerminalNode val2 = assetBundle.LoadAsset<TerminalNode>("Dogday Monster Terminal Node");
			TerminalKeyword val3 = assetBundle.LoadAsset<TerminalKeyword>("Dogday Monster Terminal Keyword");
			NetworkPrefabs.RegisterNetworkPrefab(val.enemyPrefab);
			Enemies.RegisterEnemy(val, dogdayMonsterRarity, chosenRegistrationMethod, val2, val3);
		}

		private static void ConfigureAndRegisterBoxyBoo()
		{
			//IL_0784: Unknown result type (might be due to invalid IL or missing references)
			EnemyType val = assetBundle.LoadAsset<EnemyType>("Boxy Boo");
			BoxyBooAI boxyBooAI = val.enemyPrefab.AddComponent<BoxyBooAI>();
			((EnemyAI)boxyBooAI).creatureVoice = val.enemyPrefab.GetComponent<AudioSource>();
			((EnemyAI)boxyBooAI).creatureSFX = val.enemyPrefab.GetComponent<AudioSource>();
			((EnemyAI)boxyBooAI).enemyBehaviourStates = (EnemyBehaviourState[])(object)new EnemyBehaviourState[9];
			((EnemyAI)boxyBooAI).AIIntervalTime = 0.1f;
			((EnemyAI)boxyBooAI).syncMovementSpeed = 0.2f;
			((EnemyAI)boxyBooAI).updatePositionThreshold = 0.2f;
			((EnemyAI)boxyBooAI).exitVentAnimationTime = 1f;
			((EnemyAI)boxyBooAI).enemyType = val;
			((EnemyAI)boxyBooAI).eye = val.enemyPrefab.transform.Find("Eye");
			((EnemyAI)boxyBooAI).agent = val.enemyPrefab.GetComponent<NavMeshAgent>();
			((EnemyAI)boxyBooAI).creatureAnimator = ((Component)val.enemyPrefab.transform.Find("BoxyBoo Model")).GetComponent<Animator>();
			BoxyBooAnimationEvents boxyBooAnimationEvents = ((Component)((EnemyAI)boxyBooAI).creatureAnimator).gameObject.AddComponent<BoxyBooAnimationEvents>();
			boxyBooAnimationEvents.scriptReference = boxyBooAI;
			boxyBooAI.crank = FindDeepChild(val.enemyPrefab.transform, "box_handle_JNT");
			boxyBooAI.leftsideCheck = ((Component)FindDeepChild(val.enemyPrefab.transform, "BoxcheckLeft")).transform;
			boxyBooAI.rightsideCheck = ((Component)FindDeepChild(val.enemyPrefab.transform, "BoxcheckRight")).transform;
			((EnemyAI)boxyBooAI).agent.baseOffset = -0.3f;
			((Component)val.enemyPrefab.transform.Find("BoxyCollision")).GetComponent<EnemyAICollisionDetect>().mainScript = (EnemyAI)(object)boxyBooAI;
			boxyBooAI.interactTrigger = ((Component)boxyBooAI.crank.Find("Handle_Trigger")).GetComponent<InteractTrigger>();
			boxyBooAI.interactTrigger.playersManager = StartOfRound.Instance;
			((UnityEvent<PlayerControllerB>)(object)boxyBooAI.interactTrigger.onInteract).AddListener((UnityAction<PlayerControllerB>)boxyBooAI.CrankBackwards);
			boxyBooAI.attackArea = ((Component)FindDeepChild(val.enemyPrefab.transform, "AttackArea")).GetComponent<BoxCollider>();
			boxyBooAI.boxCollision = ((Component)FindDeepChild(val.enemyPrefab.transform, "cog_JNT")).GetComponent<BoxCollider>();
			boxyBooAI.jumpscareAttachPoint = FindDeepChild(val.enemyPrefab.transform, "JumpscarePoint");
			boxyBooAI.jumpscareCollision = ((Component)boxyBooAI.jumpscareAttachPoint).GetComponent<BoxCollider>();
			boxyBooAI.musicAudio = ((Component)FindDeepChild(val.enemyPrefab.transform, "MusicAudio")).GetComponent<AudioSource>();
			boxyBooAI.grabAudioPoint = ((Component)FindDeepChild(val.enemyPrefab.transform, "GrabAudio")).GetComponent<AudioSource>();
			boxyBooAI.hitConnectAudio = ((Component)FindDeepChild(val.enemyPrefab.transform, "HitConnectAudio")).GetComponent<AudioSource>();
			boxyBooAI.crankAudio = ((Component)FindDeepChild(val.enemyPrefab.transform, "CrankAudio")).GetComponent<AudioSource>();
			boxyBooAI.creakAudio = ((Component)FindDeepChild(val.enemyPrefab.transform, "CreakAudio")).GetComponent<AudioSource>();
			boxyBooAI.jumpAudio = ((Component)FindDeepChild(val.enemyPrefab.transform, "JumpAudio")).GetComponent<AudioSource>();
			boxyBooAI.retractAudio = ((Component)FindDeepChild(val.enemyPrefab.transform, "RetractAudio")).GetComponent<AudioSource>();
			boxyBooAI.walkSounds = (AudioClip[])(object)new AudioClip[3];
			boxyBooAI.walkSounds[0] = assetBundle.LoadAsset<AudioClip>("BoxyStepHard1");
			boxyBooAI.walkSounds[1] = assetBundle.LoadAsset<AudioClip>("BoxyStepHard2");
			boxyBooAI.walkSounds[2] = assetBundle.LoadAsset<AudioClip>("BoxyStepHard3");
			boxyBooAI.attackSounds = (AudioClip[])(object)new AudioClip[2];
			boxyBooAI.attackSounds[0] = assetBundle.LoadAsset<AudioClip>("BoxySwing1");
			boxyBooAI.attackSounds[1] = assetBundle.LoadAsset<AudioClip>("BoxySwing2");
			boxyBooAI.hitConnectSounds = (AudioClip[])(object)new AudioClip[2];
			boxyBooAI.hitConnectSounds[0] = assetBundle.LoadAsset<AudioClip>("BoxyHitConnect1");
			boxyBooAI.hitConnectSounds[1] = assetBundle.LoadAsset<AudioClip>("BoxyHitConnect2");
			boxyBooAI.grabLaunchSounds = (AudioClip[])(object)new AudioClip[4];
			boxyBooAI.grabLaunchSounds[0] = assetBundle.LoadAsset<AudioClip>("BoxyGrabLaunch1");
			boxyBooAI.grabLaunchSounds[1] = assetBundle.LoadAsset<AudioClip>("BoxyGrabLaunch2");
			boxyBooAI.grabLaunchSounds[2] = assetBundle.LoadAsset<AudioClip>("BoxyGrabLaunch3");
			boxyBooAI.grabLaunchSounds[3] = assetBundle.LoadAsset<AudioClip>("BoxyGrabLaunch4");
			boxyBooAI.grabReadySounds = (AudioClip[])(object)new AudioClip[1];
			boxyBooAI.grabReadySounds[0] = assetBundle.LoadAsset<AudioClip>("BoxyGrabReady");
			boxyBooAI.crankSounds = (AudioClip[])(object)new AudioClip[6];
			boxyBooAI.crankSounds[0] = assetBundle.LoadAsset<AudioClip>("BoxyCrank1");
			boxyBooAI.crankSounds[1] = assetBundle.LoadAsset<AudioClip>("BoxyCrank2");
			boxyBooAI.crankSounds[2] = assetBundle.LoadAsset<AudioClip>("BoxyCrank3");
			boxyBooAI.crankSounds[3] = assetBundle.LoadAsset<AudioClip>("BoxyCrank4");
			boxyBooAI.crankSounds[4] = assetBundle.LoadAsset<AudioClip>("BoxyCrank5");
			boxyBooAI.crankSounds[5] = assetBundle.LoadAsset<AudioClip>("BoxyCrank6");
			boxyBooAI.boxLandSounds = (AudioClip[])(object)new AudioClip[1];
			boxyBooAI.boxLandSounds[0] = assetBundle.LoadAsset<AudioClip>("BoxyCrateLand");
			boxyBooAI.leapSounds = (AudioClip[])(object)new AudioClip[1];
			boxyBooAI.leapSounds[0] = assetBundle.LoadAsset<AudioClip>("BoxyLeap");
			boxyBooAI.landSounds = (AudioClip[])(object)new AudioClip[1];
			boxyBooAI.landSounds[0] = assetBundle.LoadAsset<AudioClip>("BoxyMetal1");
			boxyBooAI.musicTrackSounds = (AudioClip[])(object)new AudioClip[2];
			boxyBooAI.musicTrackSounds[0] = assetBundle.LoadAsset<AudioClip>("BoxySongSlow");
			boxyBooAI.musicTrackSounds[1] = assetBundle.LoadAsset<AudioClip>("BoxySongFast");
			boxyBooAI.creakSounds = (AudioClip[])(object)new AudioClip[9];
			boxyBooAI.creakSounds[0] = assetBundle.LoadAsset<AudioClip>("BoxyCreak1");
			boxyBooAI.creakSounds[1] = assetBundle.LoadAsset<AudioClip>("BoxyCreak2");
			boxyBooAI.creakSounds[2] = assetBundle.LoadAsset<AudioClip>("BoxyCreak3");
			boxyBooAI.creakSounds[3] = assetBundle.LoadAsset<AudioClip>("BoxyCreak4");
			boxyBooAI.creakSounds[4] = assetBundle.LoadAsset<AudioClip>("BoxyCreak5");
			boxyBooAI.creakSounds[5] = assetBundle.LoadAsset<AudioClip>("BoxyCreak6");
			boxyBooAI.creakSounds[6] = assetBundle.LoadAsset<AudioClip>("BoxyCreak7");
			boxyBooAI.creakSounds[7] = assetBundle.LoadAsset<AudioClip>("BoxyCreak8");
			boxyBooAI.creakSounds[8] = assetBundle.LoadAsset<AudioClip>("BoxyCreak9");
			boxyBooAI.popSounds = (AudioClip[])(object)new AudioClip[1];
			boxyBooAI.popSounds[0] = assetBundle.LoadAsset<AudioClip>("BoxyFullPop1");
			boxyBooAI.jumpscareSounds = (AudioClip[])(object)new AudioClip[1];
			boxyBooAI.jumpscareSounds[0] = assetBundle.LoadAsset<AudioClip>("BoxyJumpscare");
			boxyBooAI.partialRetractSounds = (AudioClip[])(object)new AudioClip[1];
			boxyBooAI.partialRetractSounds[0] = assetBundle.LoadAsset<AudioClip>("BoxyRetractPartial");
			boxyBooAI.fullRetractSounds = (AudioClip[])(object)new AudioClip[1];
			boxyBooAI.fullRetractSounds[0] = assetBundle.LoadAsset<AudioClip>("BoxyRetractFull");
			boxyBooAI.hitConnectSlashSounds = (AudioClip[])(object)new AudioClip[3];
			boxyBooAI.hitConnectSlashSounds[0] = assetBundle.LoadAsset<AudioClip>("BoxyHitConnectSlash1");
			boxyBooAI.hitConnectSlashSounds[1] = assetBundle.LoadAsset<AudioClip>("BoxyHitConnectSlash2");
			boxyBooAI.hitConnectSlashSounds[2] = assetBundle.LoadAsset<AudioClip>("BoxyHitConnectSlash3");
			TerminalNode val2 = assetBundle.LoadAsset<TerminalNode>("Boxy Terminal Node");
			TerminalKeyword val3 = assetBundle.LoadAsset<TerminalKeyword>("Boxy Terminal Keyword");
			Utilities.FixMixerGroups(val.enemyPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val.enemyPrefab);
			Enemies.RegisterEnemy(val, boxyBooMonsterRarity, chosenRegistrationMethod, val2, val3);
		}

		private static void LoadAssets()
		{
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "lethalplaytime");
			assetBundle = AssetBundle.LoadFromFile(text);
		}

		public static Transform FindDeepChild(Transform parent, string childName)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			foreach (Transform item in parent)
			{
				Transform val = item;
				if (((Object)val).name == childName)
				{
					return val;
				}
				Transform val2 = FindDeepChild(val, childName);
				if ((Object)(object)val2 != (Object)null)
				{
					return val2;
				}
			}
			return null;
		}
	}
	internal static class CreatureUtil
	{
		public static void AdjustCreatureRotationWithSlope(EnemyAI monster)
		{
			DogdayAI dogdayAI = monster as DogdayAI;
			if (dogdayAI != null)
			{
				return;
			}
			HuggyAI huggyAI = monster as HuggyAI;
			if (huggyAI == null)
			{
				MissDelightAI missDelightAI = monster as MissDelightAI;
				if (missDelightAI != null)
				{
				}
			}
		}

		private static void MakeForwardAngleAdjustment(EnemyAI monster, float targetForwardAngle)
		{
			//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_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: 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_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			Quaternion rotation = ((Component)monster).transform.rotation;
			float num = Mathf.DeltaAngle(((Quaternion)(ref rotation)).eulerAngles.x, targetForwardAngle);
			if (!(num < 1f))
			{
				rotation = ((Component)monster).transform.rotation;
				Quaternion val = Quaternion.Euler(targetForwardAngle, ((Quaternion)(ref rotation)).eulerAngles.y, 0f);
				((Component)monster).transform.rotation = Quaternion.Slerp(((Component)monster).transform.rotation, val, Time.deltaTime * 2f);
			}
		}

		public static void CalculateForwardTargetRotation(EnemyAI monster)
		{
			//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_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			RaycastHit val = default(RaycastHit);
			if (Physics.Raycast(new Vector3(((Component)monster).transform.position.x, ((Component)monster).transform.position.y + 0.5f, ((Component)monster).transform.position.z), Vector3.down, ref val))
			{
				Vector3 normal = ((RaycastHit)(ref val)).normal;
				float num = Vector3.Angle(Vector3.up, normal);
				float num2 = Mathf.Clamp(num, -15f, 15f);
				DogdayAI dogdayAI = monster as DogdayAI;
				if (dogdayAI != null)
				{
				}
			}
		}
	}
	public class DogdayAI : EnemyAI
	{
		public enum dogdayStates
		{
			Searching,
			Chasing,
			Enrage,
			HuntingSound
		}

		public Transform dogdayModel;

		private readonly float debugSpeedCheck = 6f;

		private float debugSpeed = 6f;

		private readonly float animationSpeedNormal = 1f;

		private readonly float animationSpeedChase = 1.7f;

		private readonly float agentSpeedNormal = 2.5f;

		private readonly float agentSpeedChase = 5.5f;

		private Random rng;

		public AISearchRoutine dogdaySearch;

		public PlayerControllerB playerLooking = null;

		public bool attacking = false;

		public bool dying = false;

		public bool changeInAnimationStateNeeded = false;

		private readonly float hearNoiseCooldown = 0.1f;