Decompiled source of LC Shrimp v1.0.1

Shrimp.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Shrimp.Patches;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Animations.Rigging;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("LcOffice")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LcOffice")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("8ee335db-0cbe-470c-8fbc-69263f01b35a")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Shrimp
{
	[BepInPlugin("Piggy.Shrimp", "Shrimp", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private const string modGUID = "Piggy.Shrimp";

		private const string modName = "Shrimp";

		private const string modVersion = "1.0.0";

		private readonly Harmony harmony = new Harmony("Piggy.Shrimp");

		private static Plugin Instance;

		public static ManualLogSource mls;

		public static AssetBundle Bundle;

		public static AudioClip footstep1;

		public static AudioClip footstep2;

		public static AudioClip footstep3;

		public static AudioClip footstep4;

		public static AudioClip dogEatItem;

		public static AudioClip dogEatPlayer;

		public static AudioClip bigGrowl;

		public static AudioClip enragedScream;

		public static AudioClip dogSprint;

		public static AudioClip ripPlayerApart;

		public static AudioClip cry1;

		public static AudioClip dogHowl;

		public static AudioClip stomachGrowl;

		public static AudioClip eatenExplode;

		public static AudioClip dogSneeze;

		public static AudioClip dogSatisfied;

		public static GameObject shrimpPrefab;

		public static EnemyType shrimpEnemy;

		public static GameObject shrimpItemManager;

		public static TerminalNode shrimpTerminalNode;

		public static TerminalKeyword shrimpTerminalKeyword;

		public static string PluginDirectory;

		private ConfigEntry<int> shrimpSpawnWeight;

		public static bool setKorean;

		private void Awake()
		{
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Expected O, but got Unknown
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			PluginDirectory = ((BaseUnityPlugin)this).Info.Location;
			mls = Logger.CreateLogSource("Piggy.Shrimp");
			mls.LogInfo((object)"Shrimp is loaded!");
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			Bundle = AssetBundle.LoadFromFile(Path.Combine(directoryName, "shrimp"));
			if ((Object)(object)Bundle == (Object)null)
			{
				mls.LogError((object)"Failed to load Shrimp assets.");
				return;
			}
			shrimpSpawnWeight = ((BaseUnityPlugin)this).Config.Bind<int>("Spawn", "ShrimpSpawnWeight", 5, new ConfigDescription("Sets the shrimp spawn weight for every moons.", (AcceptableValueBase)null, Array.Empty<object>()));
			setKorean = ((BaseUnityPlugin)this).Config.Bind<bool>("Translation", "Enable Korean", false, "Set language to Korean.").Value;
			shrimpPrefab = Bundle.LoadAsset<GameObject>("Shrimp.prefab");
			shrimpEnemy = Bundle.LoadAsset<EnemyType>("ShrimpEnemy.asset");
			shrimpItemManager = Bundle.LoadAsset<GameObject>("ShrimpItemManager.prefab");
			footstep1 = Bundle.LoadAsset<AudioClip>("Footstep1.ogg");
			footstep2 = Bundle.LoadAsset<AudioClip>("Footstep2.ogg");
			footstep3 = Bundle.LoadAsset<AudioClip>("Footstep3.ogg");
			footstep4 = Bundle.LoadAsset<AudioClip>("Footstep4.ogg");
			dogEatItem = Bundle.LoadAsset<AudioClip>("DogEatObject.ogg");
			dogEatPlayer = Bundle.LoadAsset<AudioClip>("EatPlayer.ogg");
			bigGrowl = Bundle.LoadAsset<AudioClip>("BigGrowl.ogg");
			enragedScream = Bundle.LoadAsset<AudioClip>("DogRage.ogg");
			dogSprint = Bundle.LoadAsset<AudioClip>("DogSprint.ogg");
			ripPlayerApart = Bundle.LoadAsset<AudioClip>("RipPlayerApart.ogg");
			cry1 = Bundle.LoadAsset<AudioClip>("Cry1.ogg");
			dogHowl = Bundle.LoadAsset<AudioClip>("DogHowl.ogg");
			stomachGrowl = Bundle.LoadAsset<AudioClip>("StomachGrowl.ogg");
			eatenExplode = Bundle.LoadAsset<AudioClip>("eatenExplode.ogg");
			dogSneeze = Bundle.LoadAsset<AudioClip>("Sneeze.ogg");
			dogSatisfied = Bundle.LoadAsset<AudioClip>("PlayBow.ogg");
			shrimpTerminalKeyword = Bundle.LoadAsset<TerminalKeyword>("shrimpTK.asset");
			if (!setKorean)
			{
				shrimpTerminalNode = Bundle.LoadAsset<TerminalNode>("ShrimpFile.asset");
				shrimpTerminalNode.creatureName = "Shrimp";
				shrimpTerminalKeyword.word = "shrimp";
			}
			else
			{
				shrimpTerminalNode = Bundle.LoadAsset<TerminalNode>("ShrimpKoreanFile.asset");
				shrimpTerminalNode.creatureName = "쉬림프";
				shrimpTerminalKeyword.word = "쉬림프";
			}
			ShrimpEnemyAI shrimpEnemyAI = shrimpPrefab.AddComponent<ShrimpEnemyAI>();
			((EnemyAI)shrimpEnemyAI).enemyType = shrimpEnemy;
			((EnemyAI)shrimpEnemyAI).creatureAnimator = ((Component)shrimpPrefab.transform.GetChild(0).GetChild(1)).GetComponent<Animator>();
			((EnemyAI)shrimpEnemyAI).creatureVoice = ((Component)shrimpPrefab.transform.GetChild(0).GetChild(3).GetChild(0)).GetComponent<AudioSource>();
			shrimpEnemyAI.growlAudio = ((Component)shrimpPrefab.transform.GetChild(0).GetChild(3).GetChild(1)).GetComponent<AudioSource>();
			shrimpEnemyAI.dogRageAudio = ((Component)shrimpPrefab.transform.GetChild(0).GetChild(3).GetChild(2)).GetComponent<AudioSource>();
			shrimpEnemyAI.hungerAudio = ((Component)shrimpPrefab.transform.GetChild(0).GetChild(3).GetChild(3)).GetComponent<AudioSource>();
			shrimpEnemyAI.sprintAudio = ((Component)shrimpPrefab.transform.GetChild(0).GetChild(3).GetChild(4)).GetComponent<AudioSource>();
			shrimpEnemyAI.mouthTransform = shrimpPrefab.transform.GetChild(0).GetChild(1).GetChild(0)
				.GetChild(0)
				.GetChild(0)
				.GetChild(0)
				.GetChild(2)
				.GetChild(0)
				.GetChild(0)
				.GetChild(0)
				.GetChild(4);
			((EnemyAI)shrimpEnemyAI).creatureSFX = shrimpPrefab.GetComponent<AudioSource>();
			((EnemyAI)shrimpEnemyAI).dieSFX = dogSneeze;
			((EnemyAI)shrimpEnemyAI).AIIntervalTime = 0.2f;
			((EnemyAI)shrimpEnemyAI).updatePositionThreshold = 1f;
			((EnemyAI)shrimpEnemyAI).syncMovementSpeed = 0.22f;
			shrimpEnemyAI.chitterSFX = (AudioClip[])(object)new AudioClip[1];
			shrimpEnemyAI.chitterSFX[0] = dogSatisfied;
			shrimpEnemyAI.angryScreechSFX = (AudioClip[])(object)new AudioClip[1];
			shrimpEnemyAI.angryScreechSFX[0] = dogEatItem;
			shrimpEnemyAI.angryVoiceSFX = dogHowl;
			shrimpEnemyAI.bugFlySFX = footstep4;
			shrimpEnemyAI.hitPlayerSFX = dogEatItem;
			((Component)shrimpPrefab.transform.GetChild(0)).GetComponent<EnemyAICollisionDetect>().mainScript = (EnemyAI)(object)shrimpEnemyAI;
			shrimpItemManager.AddComponent<ShrimpItemManager>();
			NetworkPrefabs.RegisterNetworkPrefab(shrimpPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(shrimpItemManager);
			shrimpEnemy.enemyPrefab = shrimpPrefab;
			Enemies.RegisterEnemy(shrimpEnemy, shrimpSpawnWeight.Value, (LevelTypes)(-1), (SpawnType)0, shrimpTerminalNode, shrimpTerminalKeyword);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Successfully loaded assets!");
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
		}
	}
}
namespace Shrimp.Patches
{
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("Start")]
		private static void Start_Prefix(GrabbableObject __instance)
		{
			GameObject val = Object.Instantiate<GameObject>(Plugin.shrimpItemManager);
			val.GetComponent<NetworkObject>().Spawn(false);
		}
	}
	public class ShrimpItemManager : NetworkBehaviour
	{
		public List<GrabbableObject> droppedItems = new List<GrabbableObject>();

		public List<GameObject> droppedObjects = new List<GameObject>();

		public static ShrimpItemManager Instance { get; private set; }

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			else if ((Object)(object)Instance != (Object)(object)this)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
		}
	}
	public class ShrimpEnemyAI : EnemyAI
	{
		public AISearchRoutine searchForItems;

		public AISearchRoutine searchForPlayer;

		public float hungerValue;

		public Transform mouthTransform;

		private Vector3 mouthOriginalScale;

		public AudioSource growlAudio;

		public AudioSource dogRageAudio;

		public AudioSource hungerAudio;

		public AudioSource sprintAudio;

		public bool inKillAnimation;

		public bool startingKillAnimationLocalClient;

		private float scaredBackingAway;

		private Ray backAwayRay;

		private RaycastHit hitInfo;

		private RaycastHit hitInfoB;

		private PlayerControllerB lastHitPlayer;

		[Space(3f)]
		public float angryTimer;

		public GrabbableObject targetItem;

		public HoarderBugItem heldItem;

		private Light lungLight;

		[Header("Animations")]
		[Space(5f)]
		private Transform rightEye;

		private Transform leftEye;

		private Vector3 scaleOfEyesNormally;

		private Vector3 agentLocalVelocity;

		private Vector3 previousPosition;

		private float velX;

		private float velZ;

		public Transform turnCompass;

		private float armsHoldLayerWeight;

		[Space(5f)]
		public Transform animationContainer;

		public Transform grabTarget;

		public TwoBoneIKConstraint headLookRig;

		public Transform headLookTarget;

		[Header("Special behaviour states")]
		private float annoyanceMeter;

		public bool watchingPlayerNearPosition;

		public PlayerControllerB watchingPlayer;

		public Transform lookTarget;

		public bool lookingAtPositionOfInterest;

		private Vector3 positionOfInterest;

		private bool isAngry;

		[Header("Misc logic")]
		private bool sendingGrabOrDropRPC;

		private float waitingAtNestTimer;

		private bool waitingAtNest;

		private float timeSinceSeeingAPlayer;

		[Header("Chase logic")]
		private bool lostPlayerInChase;

		private float noticePlayerTimer;

		public PlayerControllerB angryAtPlayer;

		private bool inChase;

		[Header("Audios")]
		public AudioClip[] chitterSFX;

		[Header("Audios")]
		public AudioClip[] angryScreechSFX;

		public AudioClip angryVoiceSFX;

		public AudioClip bugFlySFX;

		public AudioClip hitPlayerSFX;

		private float timeSinceHittingPlayer;

		private float timeSinceLookingTowardsNoise;

		private float timeSinceLookingTowardsItem;

		private float detectPlayersInterval;

		private bool inReturnToNestMode;

		private float footStepTime;

		[ServerRpc(RequireOwnership = false)]
		private void SyncHungerValueServerRpc(float value)
		{
			SyncHungerValueClientRpc(value);
		}

		[ClientRpc]
		private void SyncHungerValueClientRpc(float value)
		{
			hungerValue = value;
		}

		private void SetVariables()
		{
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Expected O, but got Unknown
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Expected O, but got Unknown
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Expected O, but got Unknown
			base.agent = ((Component)this).GetComponent<NavMeshAgent>();
			base.eye = ((Component)this).transform.GetChild(0).GetChild(1).GetChild(0)
				.GetChild(0)
				.GetChild(0)
				.GetChild(0)
				.GetChild(2)
				.GetChild(0)
				.GetChild(0)
				.GetChild(0)
				.GetChild(1);
			leftEye = ((Component)this).transform.GetChild(0).GetChild(1).GetChild(0)
				.GetChild(0)
				.GetChild(0)
				.GetChild(0)
				.GetChild(2)
				.GetChild(0)
				.GetChild(0)
				.GetChild(0)
				.GetChild(2);
			rightEye = ((Component)this).transform.GetChild(0).GetChild(1).GetChild(0)
				.GetChild(0)
				.GetChild(0)
				.GetChild(0)
				.GetChild(2)
				.GetChild(0)
				.GetChild(0)
				.GetChild(0)
				.GetChild(3);
			scaleOfEyesNormally = leftEye.localScale;
			headLookRig = ((Component)((Component)this).transform.GetChild(0).GetChild(1).GetChild(2)
				.GetChild(0)).GetComponent<TwoBoneIKConstraint>();
			animationContainer = ((Component)this).transform.GetChild(0);
			grabTarget = ((Component)this).transform.GetChild(0).GetChild(1).GetChild(0)
				.GetChild(0)
				.GetChild(0)
				.GetChild(0)
				.GetChild(2)
				.GetChild(0)
				.GetChild(0)
				.GetChild(0)
				.GetChild(5);
			headLookTarget = ((Component)this).transform.GetChild(0).GetChild(1).GetChild(2)
				.GetChild(0)
				.GetChild(0);
			lookTarget = ((Component)this).transform.GetChild(2);
			turnCompass = ((Component)this).transform.GetChild(3);
			lungLight = GameObject.Find("LungFlash").GetComponent<Light>();
			lungLight.intensity = 0f;
			List<EnemyBehaviourState> list = new List<EnemyBehaviourState>();
			EnemyBehaviourState val = new EnemyBehaviourState();
			val.name = "Roaming";
			list.Add(val);
			EnemyBehaviourState val2 = new EnemyBehaviourState();
			val2.name = "Following";
			list.Add(val2);
			EnemyBehaviourState val3 = new EnemyBehaviourState();
			val3.name = "Gifting";
			list.Add(val3);
			base.enemyBehaviourStates = list.ToArray();
		}

		public override void Start()
		{
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			SetVariables();
			((EnemyAI)this).Start();
			lastHitPlayer = StartOfRound.Instance.allPlayerScripts[0];
			dogRageAudio.volume = 0f;
			dogRageAudio.loop = true;
			dogRageAudio.clip = Plugin.enragedScream;
			dogRageAudio.pitch = 0f;
			dogRageAudio.Play();
			growlAudio.volume = 0f;
			growlAudio.loop = true;
			growlAudio.clip = Plugin.bigGrowl;
			growlAudio.Play();
			hungerAudio.volume = 0f;
			hungerAudio.loop = true;
			hungerAudio.clip = Plugin.stomachGrowl;
			hungerAudio.Play();
			sprintAudio.volume = 0f;
			sprintAudio.loop = true;
			sprintAudio.clip = Plugin.dogSprint;
			sprintAudio.Play();
			mouthOriginalScale = mouthTransform.localScale;
			heldItem = null;
			base.creatureAnimator.SetTrigger("Walk");
			lungLight.intensity = 0f;
		}

		private bool EatTargetItemIfClose()
		{
			//IL_001d: 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_0062: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)targetItem != (Object)null && heldItem == null && Vector3.Distance(((Component)this).transform.position, ((Component)targetItem).transform.position) < 0.75f && !targetItem.deactivated)
			{
				NetworkObject component = ((Component)targetItem).GetComponent<NetworkObject>();
				EatItemServerRpc(NetworkObjectReference.op_Implicit(component));
				return true;
			}
			return false;
		}

		public override void DoAIInterval()
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0372: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0441: Unknown result type (might be due to invalid IL or missing references)
			//IL_0451: Unknown result type (might be due to invalid IL or missing references)
			//IL_0796: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_052a: Unknown result type (might be due to invalid IL or missing references)
			//IL_053a: Unknown result type (might be due to invalid IL or missing references)
			//IL_055f: Unknown result type (might be due to invalid IL or missing references)
			//IL_056f: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).DoAIInterval();
			if (base.isEnemyDead || StartOfRound.Instance.allPlayersDead)
			{
				return;
			}
			if (base.currentBehaviourStateIndex != 2 && scaredBackingAway > 0.003f && hungerValue < 40f)
			{
				Vector3 position = ((Component)lastHitPlayer).transform.position;
				position.y = ((Component)this).transform.position.y;
				Vector3 val = position - ((Component)this).transform.position;
				backAwayRay = new Ray(((Component)this).transform.position, val * -1f);
				if (Physics.Raycast(backAwayRay, ref hitInfo, 60f, StartOfRound.Instance.collidersAndRoomMaskAndDefault))
				{
					if (((RaycastHit)(ref hitInfo)).distance < 4f)
					{
						if (Physics.Linecast(((Component)this).transform.position, ((RaycastHit)(ref hitInfo)).point + Vector3.Cross(val, Vector3.up) * 25.5f, ref hitInfoB, StartOfRound.Instance.collidersAndRoomMaskAndDefault))
						{
							float distance = ((RaycastHit)(ref hitInfoB)).distance;
							if (Physics.Linecast(((Component)this).transform.position, ((RaycastHit)(ref hitInfo)).point + Vector3.Cross(val, Vector3.up) * -25.5f, ref hitInfoB, StartOfRound.Instance.collidersAndRoomMaskAndDefault))
							{
								float distance2 = ((RaycastHit)(ref hitInfoB)).distance;
								if (Mathf.Abs(distance - distance2) < 5f)
								{
									base.agent.destination = ((RaycastHit)(ref hitInfo)).point + Vector3.Cross(val, Vector3.up) * -4.5f;
								}
								else if (distance < distance2)
								{
									base.agent.destination = ((RaycastHit)(ref hitInfo)).point + Vector3.Cross(val, Vector3.up) * -4.5f;
								}
								else
								{
									base.agent.destination = ((RaycastHit)(ref hitInfo)).point + Vector3.Cross(val, Vector3.up) * 4.5f;
								}
							}
						}
					}
					else
					{
						base.agent.destination = ((RaycastHit)(ref hitInfo)).point;
					}
				}
				base.agent.stoppingDistance = 0f;
				Quaternion val2 = Quaternion.Slerp(((Component)this).transform.rotation, Quaternion.LookRotation(val), 3f * Time.deltaTime);
				((Component)this).transform.eulerAngles = new Vector3(0f, ((Quaternion)(ref val2)).eulerAngles.y, 0f);
				base.agent.speed = 13f;
				base.creatureAnimator.SetFloat("walkSpeed", -3.5f);
				return;
			}
			switch (base.currentBehaviourStateIndex)
			{
			case 0:
				if (!inKillAnimation)
				{
					base.movingTowardsTargetPlayer = false;
					if (!searchForPlayer.inProgress)
					{
						((EnemyAI)this).StartSearch(((Component)this).transform.position, searchForPlayer);
					}
					else if (hungerValue > 0f && (Object.op_Implicit((Object)(object)((EnemyAI)this).CheckLineOfSightForPlayer(65f, 80, -1)) || (Object)(object)base.targetPlayer != (Object)null))
					{
						base.targetPlayer = ((EnemyAI)this).CheckLineOfSightForPlayer(65f, 80, -1);
						((EnemyAI)this).SwitchToBehaviourState(1);
					}
				}
				break;
			case 1:
			{
				if (inKillAnimation)
				{
					break;
				}
				((EnemyAI)this).StopSearch(searchForPlayer, true);
				if (hungerValue <= 0f)
				{
					((EnemyAI)this).SwitchToBehaviourState(0);
				}
				if ((Object)(object)targetItem != (Object)null && heldItem == null && Vector3.Distance(((Component)this).transform.position, ((Component)targetItem).transform.position) < 0.75f && !targetItem.deactivated)
				{
					if (ShrimpItemManager.Instance.droppedItems.Count > 0)
					{
						GameObject val4 = ((EnemyAI)this).CheckLineOfSight(ShrimpItemManager.Instance.droppedObjects, 60f, 40, 5f, (Transform)null, (int[])null);
						if (Object.op_Implicit((Object)(object)val4))
						{
							GrabbableObject component2 = val4.GetComponent<GrabbableObject>();
							if (Object.op_Implicit((Object)(object)component2) && !component2.isHeld && !component2.isPocketed && !component2.deactivated)
							{
								SetGoTowardsTargetObject(val4);
							}
						}
					}
					base.movingTowardsTargetPlayer = false;
				}
				else if (((Object)(object)base.targetPlayer != (Object)null && Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position) < 2.5f) || ((Object)(object)watchingPlayer != (Object)null && Vector3.Distance(((Component)this).transform.position, ((Component)watchingPlayer).transform.position) < 2.5f))
				{
					base.agent.stoppingDistance = 4.5f;
					base.movingTowardsTargetPlayer = false;
					BackAway();
				}
				else if ((Object)(object)((EnemyAI)this).CheckLineOfSight(ShrimpItemManager.Instance.droppedObjects, 160f, 40, 5f, (Transform)null, (int[])null) != (Object)null)
				{
					base.agent.stoppingDistance = 0f;
					base.movingTowardsTargetPlayer = false;
					if (ShrimpItemManager.Instance.droppedItems.Count > 0)
					{
						GameObject val5 = ((EnemyAI)this).CheckLineOfSight(ShrimpItemManager.Instance.droppedObjects, 160f, 40, 5f, (Transform)null, (int[])null);
						if (Object.op_Implicit((Object)(object)val5))
						{
							GrabbableObject component3 = val5.GetComponent<GrabbableObject>();
							if (Object.op_Implicit((Object)(object)component3) && !component3.isHeld && !component3.isPocketed && !component3.deactivated)
							{
								SetGoTowardsTargetObject(val5);
							}
						}
					}
				}
				else
				{
					base.agent.stoppingDistance = 4.5f;
					base.movingTowardsTargetPlayer = true;
				}
				PlayerControllerB val6 = ((EnemyAI)this).CheckLineOfSightForPlayer(65f, 80, -1);
				if ((Object)(object)val6 != (Object)null)
				{
					noticePlayerTimer = 0f;
				}
				else
				{
					noticePlayerTimer += 0.075f;
					if (noticePlayerTimer > 3f)
					{
						lostPlayerInChase = true;
					}
				}
				if (lostPlayerInChase && (Object)(object)targetItem == (Object)null)
				{
					((EnemyAI)this).SwitchToBehaviourState(0);
				}
				break;
			}
			case 2:
				if (inKillAnimation)
				{
					break;
				}
				inReturnToNestMode = false;
				if (heldItem != null)
				{
				}
				if (lostPlayerInChase)
				{
					if (!searchForPlayer.inProgress)
					{
						searchForPlayer.searchWidth = 30f;
						((EnemyAI)this).StartSearch(((Component)base.targetPlayer).transform.position, searchForPlayer);
						Debug.Log((object)(((Object)((Component)this).gameObject).name + ": Lost player in chase; beginning search where the player was last seen"));
					}
					break;
				}
				if ((Object)(object)((EnemyAI)this).CheckLineOfSight(ShrimpItemManager.Instance.droppedObjects, 160f, 40, 5f, (Transform)null, (int[])null) != (Object)null)
				{
					base.agent.stoppingDistance = 0f;
					base.movingTowardsTargetPlayer = false;
					if (ShrimpItemManager.Instance.droppedItems.Count > 0)
					{
						GameObject val3 = ((EnemyAI)this).CheckLineOfSight(ShrimpItemManager.Instance.droppedObjects, 160f, 40, 5f, (Transform)null, (int[])null);
						if (Object.op_Implicit((Object)(object)val3))
						{
							GrabbableObject component = val3.GetComponent<GrabbableObject>();
							if (Object.op_Implicit((Object)(object)component) && !component.isHeld && !component.isPocketed && !component.deactivated)
							{
								SetGoTowardsTargetObject(val3);
							}
						}
					}
				}
				if (hungerValue < 40f)
				{
					((EnemyAI)this).SwitchToBehaviourState(0);
				}
				if ((Object)(object)base.targetPlayer == (Object)null)
				{
					Debug.LogError((object)"TargetPlayer is null even though bug is in chase; setting targetPlayer to watchingPlayer");
					if ((Object)(object)watchingPlayer != (Object)null)
					{
						base.targetPlayer = watchingPlayer;
					}
				}
				if (searchForPlayer.inProgress)
				{
					((EnemyAI)this).StopSearch(searchForPlayer, true);
					Debug.Log((object)(((Object)((Component)this).gameObject).name + ": Found player during chase; stopping search coroutine and moving after target player"));
				}
				break;
			case 3:
				break;
			}
		}

		private void SetGoTowardsTargetObject(GameObject foundObject)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			base.agent.stoppingDistance = 0f;
			if (((EnemyAI)this).SetDestinationToPosition(foundObject.transform.position, true) && ShrimpItemManager.Instance.droppedObjects.Contains(foundObject))
			{
				Debug.Log((object)(((Object)((Component)this).gameObject).name + ": Setting target object and going towards it."));
				targetItem = foundObject.GetComponent<GrabbableObject>();
				EatTargetItemIfClose();
				((EnemyAI)this).StopSearch(searchForItems, false);
			}
			else
			{
				targetItem = null;
				Debug.Log((object)(((Object)((Component)this).gameObject).name + ": i found an object but cannot reach it (or it has been taken by another bug): " + ((Object)foundObject).name));
			}
		}

		private void ExitChaseMode()
		{
			if (inChase)
			{
				inChase = false;
				Debug.Log((object)(((Object)((Component)this).gameObject).name + ": Exiting chase mode"));
				if (searchForPlayer.inProgress)
				{
					((EnemyAI)this).StopSearch(searchForPlayer, true);
				}
				base.movingTowardsTargetPlayer = false;
				base.creatureAnimator.SetBool("Chase", false);
				base.creatureSFX.Stop();
			}
		}

		private void LateUpdate()
		{
			if (base.currentBehaviourStateIndex != 2 && scaredBackingAway > 0.003f && hungerValue < 40f)
			{
				scaredBackingAway -= Time.deltaTime;
			}
			if (!base.inSpecialAnimation && !base.isEnemyDead && !StartOfRound.Instance.allPlayersDead)
			{
				if (detectPlayersInterval <= 0f)
				{
					detectPlayersInterval = 0.2f;
					DetectAndLookAtPlayers();
				}
				else
				{
					detectPlayersInterval -= Time.deltaTime;
				}
				ShrimpAnimationController();
				AnimateLooking();
			}
		}

		private void CalculateAnimationDirection(float maxSpeed = 1f)
		{
			//IL_000e: 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_0023: 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_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			agentLocalVelocity = animationContainer.InverseTransformDirection(Vector3.ClampMagnitude(((Component)this).transform.position - previousPosition, 1f) / (Time.deltaTime * 2f));
			velX = Mathf.Lerp(velX, agentLocalVelocity.x, 10f * Time.deltaTime);
			base.creatureAnimator.SetFloat("VelocityX", Mathf.Clamp(velX, 0f - maxSpeed, maxSpeed));
			velZ = Mathf.Lerp(velZ, agentLocalVelocity.z, 10f * Time.deltaTime);
			base.creatureAnimator.SetFloat("VelocityZ", Mathf.Clamp(velZ, 0f - maxSpeed, maxSpeed));
			previousPosition = ((Component)this).transform.position;
		}

		private void AnimateLooking()
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			if (hungerValue < 47f)
			{
				base.agent.angularSpeed = 100f;
			}
			else
			{
				base.agent.angularSpeed = 1000f;
			}
			if ((Object)(object)targetItem != (Object)null)
			{
				lookTarget.position = ((Component)targetItem).transform.position;
				lookingAtPositionOfInterest = true;
				if (targetItem.isHeld)
				{
					if ((Object)(object)base.targetPlayer != (Object)null)
					{
						lookTarget.position = ((Component)base.targetPlayer).transform.position;
					}
					else
					{
						lookingAtPositionOfInterest = false;
					}
					targetItem = null;
				}
			}
			if ((Object)(object)lookTarget != (Object)null && !lookingAtPositionOfInterest && (Object)(object)watchingPlayer != (Object)null)
			{
				lookTarget.position = ((Component)watchingPlayer.gameplayCamera).transform.position;
			}
			else if (!lookingAtPositionOfInterest)
			{
				((RigConstraint<TwoBoneIKConstraintJob, TwoBoneIKConstraintData, TwoBoneIKConstraintJobBinder<TwoBoneIKConstraintData>>)(object)headLookRig).weight = Mathf.Lerp(((RigConstraint<TwoBoneIKConstraintJob, TwoBoneIKConstraintData, TwoBoneIKConstraintJobBinder<TwoBoneIKConstraintData>>)(object)headLookRig).weight, 0f, 10f);
				return;
			}
			if (((NetworkBehaviour)this).IsOwner)
			{
			}
			if ((Object)(object)watchingPlayer != (Object)null && !lookingAtPositionOfInterest)
			{
				float num = Vector3.Angle(((Component)this).transform.forward, lookTarget.position - ((Component)this).transform.position);
				Vector3 val = ((Component)watchingPlayer).transform.position - ((Component)this).transform.position;
				if (num > 22f)
				{
					Quaternion val2 = Quaternion.Slerp(((Component)this).transform.rotation, Quaternion.LookRotation(val), 3f * Time.deltaTime);
					((Component)this).transform.eulerAngles = new Vector3(0f, ((Quaternion)(ref val2)).eulerAngles.y, 0f);
				}
			}
			else
			{
				lookTarget.position = positionOfInterest;
			}
			((RigConstraint<TwoBoneIKConstraintJob, TwoBoneIKConstraintData, TwoBoneIKConstraintJobBinder<TwoBoneIKConstraintData>>)(object)headLookRig).weight = Mathf.Lerp(((RigConstraint<TwoBoneIKConstraintJob, TwoBoneIKConstraintData, TwoBoneIKConstraintJobBinder<TwoBoneIKConstraintData>>)(object)headLookRig).weight, 0.5f, 7f);
			headLookTarget.position = Vector3.Lerp(headLookTarget.position, lookTarget.position, 8f * Time.deltaTime);
		}

		private void DetectAndLookAtPlayers()
		{
			//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_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = ((Component)this).transform.position;
			PlayerControllerB[] allPlayersInLineOfSight = ((EnemyAI)this).GetAllPlayersInLineOfSight(70f, 30, base.eye, 1.2f, -1);
			if (allPlayersInLineOfSight != null)
			{
				PlayerControllerB val = watchingPlayer;
				timeSinceSeeingAPlayer = 0f;
				float num = 500f;
				bool flag = false;
				if ((Object)(object)base.stunnedByPlayer != (Object)null)
				{
					flag = true;
					angryAtPlayer = base.stunnedByPlayer;
				}
				for (int i = 0; i < allPlayersInLineOfSight.Length; i++)
				{
					if (IsHoarderBugAngry() && (Object)(object)allPlayersInLineOfSight[i] == (Object)(object)angryAtPlayer)
					{
						watchingPlayer = angryAtPlayer;
					}
					else
					{
						float num2 = Vector3.Distance(((Component)allPlayersInLineOfSight[i]).transform.position, position);
						if (num2 < num)
						{
							num = num2;
							watchingPlayer = allPlayersInLineOfSight[i];
						}
					}
					float num3 = Vector3.Distance(((Component)allPlayersInLineOfSight[i]).transform.position, ((Component)this).transform.position);
					if (ShrimpItemManager.Instance.droppedItems.Count > 0 && (num3 < 4f || (inChase && num3 < 8f)) && angryTimer < 3.25f)
					{
						angryAtPlayer = allPlayersInLineOfSight[i];
						watchingPlayer = allPlayersInLineOfSight[i];
						angryTimer = 3.25f;
						break;
					}
					if (base.currentBehaviourStateIndex != 2 && Vector3.Distance(((Component)this).transform.position, ((Component)allPlayersInLineOfSight[i]).transform.position) < 2.5f)
					{
						annoyanceMeter += 0.2f;
						if (annoyanceMeter > 2.5f)
						{
							angryAtPlayer = allPlayersInLineOfSight[i];
							watchingPlayer = allPlayersInLineOfSight[i];
							angryTimer = 3.25f;
						}
					}
				}
				watchingPlayerNearPosition = num < 6f;
				if ((Object)(object)watchingPlayer != (Object)(object)val)
				{
					RoundManager.PlayRandomClip(base.creatureVoice, chitterSFX, true, 1f, 0, 1000);
				}
				if (!((NetworkBehaviour)this).IsOwner)
				{
					return;
				}
				if (base.currentBehaviourStateIndex != 2)
				{
					if (IsHoarderBugAngry())
					{
						lostPlayerInChase = false;
						base.targetPlayer = watchingPlayer;
					}
				}
				else
				{
					base.targetPlayer = watchingPlayer;
					if (lostPlayerInChase)
					{
						lostPlayerInChase = false;
					}
				}
				return;
			}
			timeSinceSeeingAPlayer += 0.2f;
			watchingPlayerNearPosition = false;
			if (base.currentBehaviourStateIndex != 2)
			{
				if (timeSinceSeeingAPlayer > 1.5f)
				{
					watchingPlayer = null;
				}
				return;
			}
			if (timeSinceSeeingAPlayer > 1.25f)
			{
				watchingPlayer = null;
			}
			if (((NetworkBehaviour)this).IsOwner && !(timeSinceSeeingAPlayer > 15f) && timeSinceSeeingAPlayer > 2.5f)
			{
				lostPlayerInChase = true;
			}
		}

		private bool IsHoarderBugAngry()
		{
			if (base.stunNormalizedTimer > 0f)
			{
				angryTimer = 4f;
				if (Object.op_Implicit((Object)(object)base.stunnedByPlayer))
				{
					angryAtPlayer = base.stunnedByPlayer;
				}
				return true;
			}
			int num = 0;
			int num2 = 0;
			if (!(angryTimer > 0f))
			{
				return num2 > 0;
			}
			return true;
		}

		public void ShrimpAnimationController()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			float num = footStepTime;
			float deltaTime = Time.deltaTime;
			Vector3 velocity = base.agent.velocity;
			footStepTime = num + deltaTime * ((Vector3)(ref velocity)).sqrMagnitude / 8f;
			Animator creatureAnimator = base.creatureAnimator;
			velocity = base.agent.velocity;
			creatureAnimator.SetFloat("walkSpeed", Mathf.Clamp(((Vector3)(ref velocity)).sqrMagnitude / 5f, 0f, 3f));
			Animator creatureAnimator2 = base.creatureAnimator;
			velocity = base.agent.velocity;
			creatureAnimator2.SetFloat("runSpeed", Mathf.Clamp(((Vector3)(ref velocity)).sqrMagnitude / 2.7f, 3f, 4f));
			if (footStepTime > 0.5f)
			{
				switch (Random.Range(0, 5))
				{
				case 0:
					base.creatureVoice.PlayOneShot(Plugin.footstep1, Random.Range(0.8f, 1f));
					break;
				case 1:
					base.creatureVoice.PlayOneShot(Plugin.footstep2, Random.Range(0.8f, 1f));
					break;
				case 2:
					base.creatureVoice.PlayOneShot(Plugin.footstep3, Random.Range(0.8f, 1f));
					break;
				case 3:
					base.creatureVoice.PlayOneShot(Plugin.footstep4, Random.Range(0.8f, 1f));
					break;
				}
				footStepTime = 0f;
			}
		}

		public override void Update()
		{
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_036e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0374: Unknown result type (might be due to invalid IL or missing references)
			//IL_0384: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0560: Unknown result type (might be due to invalid IL or missing references)
			//IL_0565: Unknown result type (might be due to invalid IL or missing references)
			//IL_066a: Unknown result type (might be due to invalid IL or missing references)
			//IL_066f: Unknown result type (might be due to invalid IL or missing references)
			//IL_074a: Unknown result type (might be due to invalid IL or missing references)
			//IL_074f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0759: Unknown result type (might be due to invalid IL or missing references)
			//IL_075e: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b7: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Update();
			Plugin.mls.LogInfo((object)$"hungerValue: {hungerValue}, currentBehaviourState: {base.currentBehaviourStateIndex}");
			timeSinceHittingPlayer += Time.deltaTime;
			timeSinceLookingTowardsNoise += Time.deltaTime;
			if (timeSinceLookingTowardsNoise > 0.6f && !Object.op_Implicit((Object)(object)CheckLineOfSightForItem(120f, 40)))
			{
				lookingAtPositionOfInterest = false;
			}
			if (base.inSpecialAnimation || base.isEnemyDead || StartOfRound.Instance.allPlayersDead)
			{
				return;
			}
			if (((Object)(object)base.targetPlayer != (Object)null || hungerValue <= 0f) && ((NetworkBehaviour)this).IsOwner)
			{
				SyncHungerValueServerRpc(hungerValue += Time.deltaTime);
			}
			if (hungerValue > 34f)
			{
				hungerAudio.volume = Mathf.Lerp(hungerAudio.volume, 1f, Time.deltaTime * 2f);
			}
			else
			{
				hungerAudio.volume = Mathf.Lerp(hungerAudio.volume, 0f, Time.deltaTime * 2f);
			}
			if (hungerValue > 40f)
			{
				leftEye.localScale = Vector3.Lerp(leftEye.localScale, scaleOfEyesNormally * 0.4f, 20f * Time.deltaTime);
				rightEye.localScale = Vector3.Lerp(rightEye.localScale, scaleOfEyesNormally * 0.4f, 20f * Time.deltaTime);
				growlAudio.volume = 1f;
			}
			else
			{
				leftEye.localScale = Vector3.Lerp(leftEye.localScale, scaleOfEyesNormally, 20f * Time.deltaTime);
				rightEye.localScale = Vector3.Lerp(rightEye.localScale, scaleOfEyesNormally, 20f * Time.deltaTime);
				growlAudio.volume = Mathf.Lerp(growlAudio.volume, 0f, Time.deltaTime * 5f);
			}
			if (hungerValue > 45f)
			{
				dogRageAudio.volume = 1f;
				dogRageAudio.pitch = 0.8f;
				mouthTransform.localScale = Vector3.Lerp(mouthTransform.localScale, new Vector3(0.005590725f, 0.01034348f, 0.02495567f), 30f * Time.deltaTime);
			}
			else
			{
				dogRageAudio.volume = Mathf.Lerp(dogRageAudio.volume, 0f, Time.deltaTime * 10f);
				dogRageAudio.pitch = Mathf.Lerp(dogRageAudio.pitch, 0f, Time.deltaTime * 10f);
				mouthTransform.localScale = Vector3.Lerp(mouthTransform.localScale, mouthOriginalScale, 20f * Time.deltaTime);
			}
			if (hungerValue > 48f)
			{
				sprintAudio.volume = Mathf.Lerp(sprintAudio.volume, 1f, Time.deltaTime * 10f);
				base.creatureAnimator.SetBool("running", true);
				if (base.currentBehaviourStateIndex != 2)
				{
					((EnemyAI)this).SwitchToBehaviourState(2);
				}
			}
			else
			{
				sprintAudio.volume = Mathf.Lerp(sprintAudio.volume, 0f, Time.deltaTime * 10f);
				base.creatureAnimator.SetBool("running", false);
				if (base.currentBehaviourStateIndex == 2)
				{
					((EnemyAI)this).SwitchToBehaviourState(0);
				}
			}
			base.creatureAnimator.SetBool("stunned", base.stunNormalizedTimer > 0f);
			bool flag = IsHoarderBugAngry();
			if (!isAngry && flag)
			{
				isAngry = true;
				base.creatureVoice.clip = angryVoiceSFX;
				base.creatureVoice.Play();
			}
			else if (isAngry && !flag)
			{
				isAngry = false;
				angryAtPlayer = null;
				base.creatureVoice.Stop();
			}
			switch (base.currentBehaviourStateIndex)
			{
			case 0:
				if (inKillAnimation)
				{
					break;
				}
				if (Object.op_Implicit((Object)(object)CheckLineOfSightForItem(160f, 40)))
				{
					timeSinceLookingTowardsItem = 0f;
					positionOfInterest = ((Component)CheckLineOfSightForItem(160f, 40)).transform.position;
					lookingAtPositionOfInterest = true;
				}
				else if (timeSinceLookingTowardsItem < 0.6f)
				{
					timeSinceLookingTowardsItem += Time.deltaTime;
				}
				if (!searchForPlayer.inProgress)
				{
					((EnemyAI)this).StartSearch(((Component)this).transform.position, searchForPlayer);
					break;
				}
				base.addPlayerVelocityToDestination = 0f;
				if (base.stunNormalizedTimer > 0f)
				{
					base.agent.speed = 0f;
				}
				else
				{
					base.agent.speed = 6f;
				}
				break;
			case 1:
				if (!inKillAnimation)
				{
					if (Object.op_Implicit((Object)(object)CheckLineOfSightForItem(160f, 40)))
					{
						timeSinceLookingTowardsItem = 0f;
						positionOfInterest = ((Component)CheckLineOfSightForItem(160f, 40)).transform.position;
						lookingAtPositionOfInterest = true;
					}
					else if (timeSinceLookingTowardsItem < 0.6f)
					{
						timeSinceLookingTowardsItem += Time.deltaTime;
					}
					base.addPlayerVelocityToDestination = 0f;
					if (base.stunNormalizedTimer > 0f)
					{
						base.agent.speed = 0f;
					}
					else
					{
						base.agent.speed = 6f;
					}
					base.agent.acceleration = 30f;
				}
				break;
			case 2:
				if (inKillAnimation)
				{
					break;
				}
				base.agent.stoppingDistance = 0f;
				if (!inChase)
				{
					inChase = true;
					if (GameNetworkManager.Instance.localPlayerController.HasLineOfSightToPosition(((Component)this).transform.position + Vector3.up * 0.75f, 60f, 15, -1f))
					{
						GameNetworkManager.Instance.localPlayerController.JumpToFearLevel(0.7f, true);
					}
				}
				base.addPlayerVelocityToDestination = 2f;
				if (((NetworkBehaviour)this).IsOwner)
				{
					if (base.stunNormalizedTimer > 0f)
					{
						base.agent.speed = 0f;
					}
					else
					{
						base.agent.speed = 18f;
					}
					base.agent.acceleration = 100f;
				}
				break;
			}
		}

		public override void DetectNoise(Vector3 noisePosition, float noiseLoudness, int timesPlayedInOneSpot = 0, int noiseID = 0)
		{
			//IL_0002: 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_0044: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).DetectNoise(noisePosition, noiseLoudness, timesPlayedInOneSpot, noiseID);
			if (base.currentBehaviourStateIndex == 0 && timesPlayedInOneSpot <= 10 && !(timeSinceLookingTowardsNoise < 0.6f))
			{
				timeSinceLookingTowardsNoise = 0f;
				float num = Vector3.Distance(noisePosition, ((Component)this).transform.position);
				positionOfInterest = noisePosition;
				lookingAtPositionOfInterest = true;
			}
		}

		private void DropItemAndCallDropRPC(NetworkObject dropItemNetworkObject, bool droppedInNest = true)
		{
			//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_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			Vector3 targetFloorPosition = RoundManager.Instance.RandomlyOffsetPosition(heldItem.itemGrabbableObject.GetItemFloorPosition(default(Vector3)), 1.2f, 0.4f);
			DropItem(dropItemNetworkObject, targetFloorPosition);
			sendingGrabOrDropRPC = true;
			DropItemServerRpc(NetworkObjectReference.op_Implicit(dropItemNetworkObject), targetFloorPosition, droppedInNest);
		}

		[ServerRpc]
		public void DropItemServerRpc(NetworkObjectReference objectRef, Vector3 targetFloorPosition, bool droppedInNest)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			DropItemClientRpc(objectRef, targetFloorPosition, droppedInNest);
		}

		[ClientRpc]
		public void DropItemClientRpc(NetworkObjectReference objectRef, Vector3 targetFloorPosition, bool droppedInNest)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			NetworkObject item = default(NetworkObject);
			if (((NetworkObjectReference)(ref objectRef)).TryGet(ref item, (NetworkManager)null))
			{
				DropItem(item, targetFloorPosition, droppedInNest);
			}
			else
			{
				Debug.LogError((object)(((Object)((Component)this).gameObject).name + ": Failed to get network object from network object reference (Drop item RPC)"));
			}
		}

		[ServerRpc]
		public void EatItemServerRpc(NetworkObjectReference objectRef)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			EatItemClientRpc(objectRef);
		}

		[ClientRpc]
		public void EatItemClientRpc(NetworkObjectReference objectRef)
		{
			NetworkObject item = default(NetworkObject);
			if (((NetworkObjectReference)(ref objectRef)).TryGet(ref item, (NetworkManager)null))
			{
				EatItem(item);
			}
			else
			{
				Debug.LogError((object)(((Object)((Component)this).gameObject).name + ": Failed to get network object from network object reference (Grab item RPC)"));
			}
		}

		private void DropItem(NetworkObject item, Vector3 targetFloorPosition, bool droppingInNest = true)
		{
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			if (sendingGrabOrDropRPC)
			{
				sendingGrabOrDropRPC = false;
				return;
			}
			if (heldItem == null)
			{
				Debug.LogError((object)"Hoarder bug: my held item is null when attempting to drop it!!");
				return;
			}
			GrabbableObject itemGrabbableObject = heldItem.itemGrabbableObject;
			itemGrabbableObject.parentObject = null;
			((Component)itemGrabbableObject).transform.SetParent(StartOfRound.Instance.propsContainer, true);
			itemGrabbableObject.EnablePhysics(true);
			itemGrabbableObject.fallTime = 0f;
			itemGrabbableObject.startFallingPosition = ((Component)itemGrabbableObject).transform.parent.InverseTransformPoint(((Component)itemGrabbableObject).transform.position);
			itemGrabbableObject.targetFloorPosition = ((Component)itemGrabbableObject).transform.parent.InverseTransformPoint(targetFloorPosition);
			itemGrabbableObject.floorYRot = -1;
			itemGrabbableObject.DiscardItemFromEnemy();
			heldItem = null;
			if (!droppingInNest && ShrimpItemManager.Instance.droppedObjects.Count != 0)
			{
				ShrimpItemManager.Instance.droppedObjects.Add(((Component)itemGrabbableObject).gameObject);
			}
		}

		private void EatItem(NetworkObject item)
		{
			SyncHungerValueServerRpc(hungerValue - 20f);
			targetItem = null;
			base.creatureAnimator.SetTrigger("eat");
			base.creatureSFX.PlayOneShot(Plugin.dogEatItem);
			GrabbableObject component = ((Component)item).gameObject.GetComponent<GrabbableObject>();
			((NetworkBehaviour)component).NetworkObject.Despawn(true);
		}

		public override void OnCollideWithPlayer(Collider other)
		{
			((EnemyAI)this).OnCollideWithPlayer(other);
			if (base.currentBehaviourStateIndex == 2 && !base.isEnemyDead)
			{
				PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, inKillAnimation || startingKillAnimationLocalClient, false);
				if ((Object)(object)val != (Object)null)
				{
					KillPlayerAnimationServerRpc((int)val.playerClientId);
					startingKillAnimationLocalClient = true;
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void KillPlayerAnimationServerRpc(int playerObjectId)
		{
			if (!inKillAnimation)
			{
				inKillAnimation = true;
				KillPlayerAnimationClientRpc(playerObjectId);
			}
			else
			{
				CancelKillAnimationClientRpc(playerObjectId);
			}
		}

		[ClientRpc]
		public void KillPlayerAnimationClientRpc(int playerObjectId)
		{
			((MonoBehaviour)this).StartCoroutine(KillPlayerAnimation(playerObjectId));
		}

		[ClientRpc]
		public void CancelKillAnimationClientRpc(int playerObjectId)
		{
			if ((int)GameNetworkManager.Instance.localPlayerController.playerClientId == playerObjectId)
			{
				startingKillAnimationLocalClient = false;
			}
		}

		public IEnumerator KillPlayerAnimation(int playerId)
		{
			base.creatureSFX.PlayOneShot(Plugin.ripPlayerApart);
			base.agent.speed = 0f;
			base.agent.angularSpeed = 0f;
			PlayerControllerB killPlayer = StartOfRound.Instance.allPlayerScripts[playerId];
			killPlayer.KillPlayer(Vector3.zero, true, (CauseOfDeath)6, 0, default(Vector3));
			base.creatureAnimator.SetTrigger("RipObject");
			float startTime = Time.realtimeSinceStartup;
			yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)killPlayer.deadBody != (Object)null || Time.realtimeSinceStartup - startTime > 2f));
			DeadBodyInfo body = killPlayer.deadBody;
			if ((Object)(object)body != (Object)null && (Object)(object)body.attachedTo == (Object)null)
			{
				body.attachedLimb = body.bodyParts[5];
				body.attachedTo = grabTarget;
				body.matchPositionExactly = true;
			}
			yield return (object)new WaitForSeconds(0.03f);
			SyncHungerValueServerRpc(-20f);
			yield return (object)new WaitForSeconds(4f);
			base.creatureAnimator.SetTrigger("eat");
			base.creatureSFX.PlayOneShot(Plugin.dogEatPlayer);
			((NetworkBehaviour)killPlayer.deadBody.grabBodyObject).NetworkObject.Despawn(true);
			yield return (object)new WaitForSeconds(1.7f);
			base.agent.speed = 6f;
			base.agent.angularSpeed = 10f;
			inKillAnimation = false;
		}

		[ServerRpc(RequireOwnership = false)]
		public void HitPlayerServerRpc()
		{
			HitPlayerClientRpc();
		}

		[ClientRpc]
		public void HitPlayerClientRpc()
		{
			if (!base.isEnemyDead)
			{
				base.creatureAnimator.SetTrigger("HitPlayer");
				base.creatureSFX.PlayOneShot(hitPlayerSFX);
				WalkieTalkie.TransmitOneShotAudio(base.creatureSFX, hitPlayerSFX, 1f);
			}
		}

		public override void HitEnemy(int force = 1, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
		{
			if (hungerValue < 40f)
			{
				((MonoBehaviour)this).StartCoroutine(stunnedTimer());
				lastHitPlayer = playerWhoHit;
			}
		}

		private IEnumerator stunnedTimer()
		{
			base.agent.speed = 0f;
			base.creatureAnimator.SetTrigger("Recoil");
			base.creatureVoice.PlayOneShot(Plugin.cry1, 1f);
			yield return (object)new WaitForSeconds(0.5f);
			scaredBackingAway = 2.2f;
			yield return (object)new WaitForSeconds(0.3f);
		}

		public override void KillEnemy(bool destroy = false)
		{
			((EnemyAI)this).KillEnemy(false);
			base.agent.speed = 0f;
			base.creatureVoice.Stop();
			base.creatureSFX.Stop();
		}

		public GrabbableObject CheckLineOfSightForItem(float width = 45f, int range = 60, float proximityAwareness = 3f)
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			List<GrabbableObject> droppedItems = ShrimpItemManager.Instance.droppedItems;
			for (int i = 0; i < droppedItems.Count; i++)
			{
				if (!droppedItems[i].grabbableToEnemies || !droppedItems[i].isHeld || ShrimpItemManager.Instance.droppedItems.Count > 0)
				{
					continue;
				}
				Vector3 position = ((Component)droppedItems[i]).transform.position;
				if (!Physics.Linecast(base.eye.position, position, StartOfRound.Instance.collidersAndRoomMaskAndDefault))
				{
					Vector3 val = position - base.eye.position;
					if (Vector3.Angle(base.eye.forward, val) < width || Vector3.Distance(((Component)this).transform.position, position) < proximityAwareness)
					{
						return droppedItems[i];
					}
				}
			}
			return null;
		}

		private void BackAway()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_030a: Unknown result type (might be due to invalid IL or missing references)
			//IL_030f: Unknown result type (might be due to invalid IL or missing references)
			//IL_031e: Unknown result type (might be due to invalid IL or missing references)
			//IL_032d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				float num = Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position);
				if (Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position) < float.PositiveInfinity && num < 30f && !val.isPlayerDead)
				{
					base.targetPlayer = val;
				}
			}
			base.agent.destination = ((Component)base.targetPlayer).transform.position;
			Vector3 position = ((Component)base.targetPlayer).transform.position;
			position.y = ((Component)this).transform.position.y;
			Vector3 val2 = position - ((Component)this).transform.position;
			Ray val3 = default(Ray);
			((Ray)(ref val3))..ctor(((Component)this).transform.position, val2 * -1f);
			RaycastHit val4 = default(RaycastHit);
			if (Physics.Raycast(val3, ref val4, 60f, StartOfRound.Instance.collidersAndRoomMaskAndDefault))
			{
				if (((RaycastHit)(ref val4)).distance < 4f)
				{
					RaycastHit val5 = default(RaycastHit);
					if (Physics.Linecast(((Component)this).transform.position, ((RaycastHit)(ref val4)).point + Vector3.Cross(val2, Vector3.up) * 25.5f, ref val5, StartOfRound.Instance.collidersAndRoomMaskAndDefault))
					{
						float distance = ((RaycastHit)(ref val5)).distance;
						if (Physics.Linecast(((Component)this).transform.position, ((RaycastHit)(ref val4)).point + Vector3.Cross(val2, Vector3.up) * -25.5f, ref val5, StartOfRound.Instance.collidersAndRoomMaskAndDefault))
						{
							float distance2 = ((RaycastHit)(ref val5)).distance;
							if (Mathf.Abs(distance - distance2) < 5f)
							{
								base.agent.destination = ((RaycastHit)(ref val4)).point + Vector3.Cross(val2, Vector3.up) * -4.5f;
							}
							else if (distance < distance2)
							{
								base.agent.destination = ((RaycastHit)(ref val4)).point + Vector3.Cross(val2, Vector3.up) * -4.5f;
							}
							else
							{
								base.agent.destination = ((RaycastHit)(ref val4)).point + Vector3.Cross(val2, Vector3.up) * 4.5f;
							}
						}
					}
				}
				else
				{
					base.agent.destination = ((RaycastHit)(ref val4)).point;
				}
			}
			else
			{
				base.agent.destination = ((Ray)(ref val3)).GetPoint(2.3f);
			}
			base.agent.stoppingDistance = 0.2f;
			Quaternion val6 = Quaternion.Slerp(((Component)this).transform.rotation, Quaternion.LookRotation(val2), 3f * Time.deltaTime);
			((Component)this).transform.eulerAngles = new Vector3(0f, ((Quaternion)(ref val6)).eulerAngles.y, 0f);
			base.agent.speed = 8f;
			base.agent.acceleration = 50000f;
			base.creatureAnimator.SetFloat("walkSpeed", -2.2f);
		}
	}
	[HarmonyPatch(typeof(GrabbableObject))]
	internal class GrabbableObjectPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("Start")]
		private static void Start_Postfix(GrabbableObject __instance)
		{
			if ((Object)(object)((Component)__instance).gameObject.GetComponent<ItemGrabChecker>() == (Object)null)
			{
				((Component)__instance).gameObject.AddComponent<ItemGrabChecker>();
			}
		}
	}
	public class ItemGrabChecker : NetworkBehaviour
	{
		public bool isInElevatorB;

		public bool droppedItemMoment;

		private bool droppedItemAppended;

		public float dogEatTimer;

		public bool isHeldBefore;

		public GrabbableObject grabbableObject;

		private void Start()
		{
			grabbableObject = ((Component)this).GetComponent<GrabbableObject>();
		}

		private void Update()
		{
			if (grabbableObject.deactivated)
			{
				return;
			}
			if (grabbableObject.isHeld)
			{
				if (!isHeldBefore)
				{
					isHeldBefore = true;
				}
				dogEatTimer = 0f;
				droppedItemMoment = true;
				droppedItemAppended = false;
				ShrimpItemManager.Instance.droppedItems.Remove(grabbableObject);
				ShrimpItemManager.Instance.droppedObjects.Remove(((Component)this).gameObject);
				return;
			}
			if (droppedItemMoment && grabbableObject.reachedFloorTarget && !droppedItemAppended)
			{
				ShrimpItemManager.Instance.droppedItems.Add(grabbableObject);
				ShrimpItemManager.Instance.droppedObjects.Add(((Component)this).gameObject);
				droppedItemAppended = true;
			}
			dogEatTimer += Time.deltaTime;
			if (dogEatTimer > 3f)
			{
				ShrimpItemManager.Instance.droppedItems.Remove(grabbableObject);
				ShrimpItemManager.Instance.droppedObjects.Remove(((Component)this).gameObject);
				dogEatTimer = 0f;
				droppedItemMoment = false;
				droppedItemAppended = false;
			}
		}

		private void OnDestroy()
		{
			ShrimpItemManager.Instance.droppedItems.Remove(grabbableObject);
			ShrimpItemManager.Instance.droppedObjects.Remove(((Component)this).gameObject);
		}
	}
}