Decompiled source of SpectreLib v1.2.53

BepInEx/plugins/UhhSomething.dll

Decompiled 20 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using Dawn;
using Dawn.Utils;
using DigitalRuby.ThunderAndLightning;
using DunGen;
using DunGen.Tags;
using Dusk;
using EasyTextEffects.Editor.MyBoxCopy.Extensions;
using GameNetcodeStuff;
using Microsoft.CodeAnalysis;
using Spectre;
using Spectre.Enemy;
using Spectre.Items;
using Spectre.Misc;
using Spectre.Scriptable;
using TMPro;
using UhhSomething.NetcodePatcher;
using Unity.Mathematics;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Animations.Rigging;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.Rendering.HighDefinition;
using UnityEngine.UI;
using UnityEngine.VFX;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ClientNetworkTransform")]
[assembly: IgnoresAccessChecksTo("com.olegknyazev.softmask")]
[assembly: IgnoresAccessChecksTo("DissonanceVoip")]
[assembly: IgnoresAccessChecksTo("DunGen")]
[assembly: IgnoresAccessChecksTo("DunGen.Integration.ASPP")]
[assembly: IgnoresAccessChecksTo("DunGen.Integration.UnityNav")]
[assembly: IgnoresAccessChecksTo("EasyTextEffects")]
[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.Components")]
[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("Unity.XR.CoreUtils")]
[assembly: IgnoresAccessChecksTo("Unity.XR.Management")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.ConformanceAutomation")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.MetaQuestSupport")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.MockRuntime")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.OculusQuestSupport")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.RuntimeDebugger")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.SpatialTracking")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: IgnoresAccessChecksTo("UnityEngine.XR.LegacyInputHelpers")]
[assembly: AssemblyCompany("UhhSomething")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("UhhSomething")]
[assembly: AssemblyTitle("UhhSomething")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
public class CollectorBugAI : EnemyAI
{
	public AISearchRoutine searchForItems;

	public AISearchRoutine searchForPlayer;

	[Header("Tracking/Memory")]
	[Space(3f)]
	public Vector3 nestPosition;

	private bool choseNestPosition;

	[Space(3f)]
	public static List<HoarderBugItem> HoarderBugItems = new List<HoarderBugItem>();

	public static List<GameObject> grabbableObjectsInMap = new List<GameObject>();

	public float angryTimer;

	public GrabbableObject targetItem;

	public HoarderBugItem heldItem;

	[Header("Animations")]
	[Space(5f)]
	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 MultiAimConstraint 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 detectPlayersInterval;

	private bool inReturnToNestMode;

	public GameObject ghostCostume;

	public float itemGrabRange = 0.75f;

	public float roamSpeed = 6f;

	public float retrieveSpeed = 6f;

	public float chaseSpeed = 18f;

	public float retrieveAccel = 30f;

	public float chaseAccel = 16f;

	public float fearOnLOS = 0.4f;

	[Range(1f, 12f)]
	public int turnIntoGhostMonth = 10;

	[Range(1f, 31f)]
	public int turnIntoGhostDay = 31;

	[Range(1f, 12f)]
	public int[] ghostMonthList;

	[Range(1f, 31f)]
	public int[] ghostDayList;

	public DateTime turnIntoGhostTime = new DateTime(DateTime.Now.Year, 10, 31);

	public override void Start()
	{
		((EnemyAI)this).Start();
		heldItem = null;
		RefreshGrabbableObjectsInMapList();
		turnIntoGhostTime = new DateTime(DateTime.Now.Year, turnIntoGhostMonth, turnIntoGhostDay);
		for (int i = 0; i < ghostMonthList.Length; i++)
		{
			if (DateTime.Today.Month == ghostMonthList[i] && DateTime.Today.Day == ghostDayList[i])
			{
				ghostCostume.SetActive(true);
				break;
			}
		}
		if (!ghostCostume.activeSelf && DateTime.Today == turnIntoGhostTime)
		{
			ghostCostume.SetActive(true);
		}
	}

	public static void RefreshGrabbableObjectsInMapList()
	{
		grabbableObjectsInMap.Clear();
		GrabbableObject[] array = Object.FindObjectsOfType<GrabbableObject>();
		for (int i = 0; i < array.Length; i++)
		{
			CaveDwellerPhysicsProp component = ((Component)array[i]).GetComponent<CaveDwellerPhysicsProp>();
			CustomManeaterBaby component2 = ((Component)array[i]).GetComponent<CustomManeaterBaby>();
			if (array[i].grabbableToEnemies && !array[i].deactivated && (Object)(object)component == (Object)null && (Object)(object)component2 == (Object)null)
			{
				grabbableObjectsInMap.Add(((Component)array[i]).gameObject);
			}
		}
	}

	private bool GrabTargetItemIfClose()
	{
		//IL_0022: 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_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: 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_0073: 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) < itemGrabRange)
		{
			if (!((EnemyAI)this).SetDestinationToPosition(nestPosition, true))
			{
				nestPosition = ((EnemyAI)this).ChooseClosestNodeToPosition(((Component)this).transform.position, false, 0).position;
				((EnemyAI)this).SetDestinationToPosition(nestPosition, false);
			}
			NetworkObject component = ((Component)targetItem).GetComponent<NetworkObject>();
			((EnemyAI)this).SwitchToBehaviourStateOnLocalClient(1);
			GrabItem(component);
			sendingGrabOrDropRPC = true;
			GrabItemServerRpc(NetworkObjectReference.op_Implicit(component));
			return true;
		}
		return false;
	}

	private void ChooseNestPosition()
	{
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: 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_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: 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_0038: Unknown result type (might be due to invalid IL or missing references)
		HoarderBugAI[] array = Object.FindObjectsOfType<HoarderBugAI>();
		for (int i = 0; i < array.Length; i++)
		{
			if ((Object)(object)array[i] != (Object)(object)this && !((EnemyAI)this).PathIsIntersectedByLineOfSight(array[i].nestPosition, false, false, false))
			{
				nestPosition = array[i].nestPosition;
				SyncNestPositionServerRpc(nestPosition);
				return;
			}
		}
		nestPosition = ((EnemyAI)this).ChooseClosestNodeToPosition(((Component)this).transform.position, false, 0).position;
		SyncNestPositionServerRpc(nestPosition);
	}

	[ServerRpc]
	private void SyncNestPositionServerRpc(Vector3 newNestPosition)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e9: Invalid comparison between Unknown and I4
		//IL_0114: Unknown result type (might be due to invalid IL or missing references)
		//IL_011a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Invalid comparison between Unknown and I4
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
		{
			if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
				return;
			}
			ServerRpcParams val2 = default(ServerRpcParams);
			FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(4245383865u, val2, (RpcDelivery)0);
			((FastBufferWriter)(ref val)).WriteValueSafe(ref newNestPosition);
			((NetworkBehaviour)this).__endSendServerRpc(ref val, 4245383865u, val2, (RpcDelivery)0);
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
		{
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			SyncNestPositionClientRpc(newNestPosition);
		}
	}

	[ClientRpc]
	private void SyncNestPositionClientRpc(Vector3 newNestPosition)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val2 = default(ClientRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(3305399717u, val2, (RpcDelivery)0);
				((FastBufferWriter)(ref val)).WriteValueSafe(ref newNestPosition);
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 3305399717u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				nestPosition = newNestPosition;
			}
		}
	}

	public override void DoAIInterval()
	{
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0303: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_0150: 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_026c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0278: Unknown result type (might be due to invalid IL or missing references)
		((EnemyAI)this).DoAIInterval();
		if (base.isEnemyDead || StartOfRound.Instance.allPlayersDead)
		{
			return;
		}
		if (!choseNestPosition)
		{
			choseNestPosition = true;
			ChooseNestPosition();
			return;
		}
		if (((EnemyAI)this).CheckLineOfSightForPosition(nestPosition, 60f, 40, 0.5f, (Transform)null))
		{
			for (int i = 0; i < HoarderBugItems.Count; i++)
			{
				if (HoarderBugItems[i].itemGrabbableObject.isHeld && HoarderBugItems[i].itemNestPosition == nestPosition)
				{
					HoarderBugItems[i].status = (HoarderBugItemStatus)1;
				}
			}
		}
		HoarderBugItem val = CheckLineOfSightForItem((HoarderBugItemStatus)1, 60f, 30, 3f);
		if (val != null && !val.itemGrabbableObject.isHeld)
		{
			val.status = (HoarderBugItemStatus)2;
			if (!grabbableObjectsInMap.Contains(((Component)val.itemGrabbableObject).gameObject))
			{
				grabbableObjectsInMap.Add(((Component)val.itemGrabbableObject).gameObject);
			}
		}
		switch (base.currentBehaviourStateIndex)
		{
		case 0:
		{
			inReturnToNestMode = false;
			ExitChaseMode();
			if (GrabTargetItemIfClose())
			{
				break;
			}
			if ((Object)(object)targetItem == (Object)null && !searchForItems.inProgress)
			{
				((EnemyAI)this).StartSearch(nestPosition, searchForItems);
				break;
			}
			if ((Object)(object)targetItem != (Object)null)
			{
				SetGoTowardsTargetObject(((Component)targetItem).gameObject);
				break;
			}
			GameObject val3 = ((EnemyAI)this).CheckLineOfSight(grabbableObjectsInMap, 60f, 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.deactivated && (!component.isHeld || (Random.Range(0, 100) < 4 && !component.isPocketed)))
				{
					SetGoTowardsTargetObject(val3);
				}
			}
			break;
		}
		case 1:
			ExitChaseMode();
			if (!inReturnToNestMode)
			{
				inReturnToNestMode = true;
				SetReturningToNest();
			}
			GrabTargetItemIfClose();
			if (waitingAtNest)
			{
				if (heldItem != null)
				{
					DropItemAndCallDropRPC(((Component)heldItem.itemGrabbableObject).GetComponent<NetworkObject>());
				}
				else
				{
					GameObject val2 = ((EnemyAI)this).CheckLineOfSight(grabbableObjectsInMap, 60f, 40, 5f, (Transform)null, (int[])null);
					if (Object.op_Implicit((Object)(object)val2) && Vector3.Distance(base.eye.position, val2.transform.position) < 6f)
					{
						targetItem = val2.GetComponent<GrabbableObject>();
						if ((Object)(object)targetItem != (Object)null && !targetItem.isHeld && !targetItem.deactivated)
						{
							waitingAtNest = false;
							((EnemyAI)this).SwitchToBehaviourState(0);
							break;
						}
					}
				}
				if (waitingAtNestTimer <= 0f && !watchingPlayerNearPosition)
				{
					waitingAtNest = false;
					((EnemyAI)this).SwitchToBehaviourStateOnLocalClient(0);
				}
			}
			else if (Vector3.Distance(((Component)this).transform.position, nestPosition) < 0.75f)
			{
				waitingAtNest = true;
				waitingAtNestTimer = 15f;
			}
			break;
		case 2:
			inReturnToNestMode = false;
			if (heldItem != null)
			{
				DropItemAndCallDropRPC(((Component)heldItem.itemGrabbableObject).GetComponent<NetworkObject>(), droppedInNest: false);
			}
			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)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"));
			}
			base.movingTowardsTargetPlayer = true;
			break;
		case 3:
			break;
		}
	}

	private void SetGoTowardsTargetObject(GameObject foundObject)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		if (((EnemyAI)this).SetDestinationToPosition(foundObject.transform.position, true) && grabbableObjectsInMap.Contains(foundObject))
		{
			Debug.Log((object)(((Object)((Component)this).gameObject).name + ": Setting target object and going towards it."));
			targetItem = foundObject.GetComponent<GrabbableObject>();
			((EnemyAI)this).StopSearch(searchForItems, false);
		}
		else
		{
			targetItem = null;
		}
	}

	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 SetReturningToNest()
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		if (((EnemyAI)this).SetDestinationToPosition(nestPosition, true))
		{
			targetItem = null;
			((EnemyAI)this).StopSearch(searchForItems, false);
		}
		else
		{
			Debug.Log((object)(((Object)((Component)this).gameObject).name + ": Return to nest was called, but nest is not accessible! Abandoning and choosing a new nest position."));
			ChooseNestPosition();
		}
	}

	private void LateUpdate()
	{
		if (!base.inSpecialAnimation && !base.isEnemyDead && !StartOfRound.Instance.allPlayersDead)
		{
			if (detectPlayersInterval <= 0f)
			{
				detectPlayersInterval = 0.2f;
				DetectAndLookAtPlayers();
			}
			else
			{
				detectPlayersInterval -= Time.deltaTime;
			}
			AnimateLooking();
			CalculateAnimationDirection();
			SetArmLayerWeight();
		}
	}

	private void SetArmLayerWeight()
	{
		if (heldItem != null)
		{
			armsHoldLayerWeight = Mathf.Lerp(armsHoldLayerWeight, 0.85f, 8f * Time.deltaTime);
		}
		else
		{
			armsHoldLayerWeight = Mathf.Lerp(armsHoldLayerWeight, 0f, 8f * Time.deltaTime);
		}
		base.creatureAnimator.SetLayerWeight(1, armsHoldLayerWeight);
	}

	private void CalculateAnimationDirection(float maxSpeed = 1f)
	{
		//IL_000d: 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_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
		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_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_0109: Unknown result type (might be due to invalid IL or missing references)
		//IL_0114: Unknown result type (might be due to invalid IL or missing references)
		//IL_011f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0124: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a2: 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_01bd: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)watchingPlayer != (Object)null)
		{
			lookTarget.position = ((Component)watchingPlayer.gameplayCamera).transform.position;
		}
		else
		{
			if (!lookingAtPositionOfInterest)
			{
				base.agent.angularSpeed = 220f;
				((RigConstraint<MultiAimConstraintJob, MultiAimConstraintData, MultiAimConstraintJobBinder<MultiAimConstraintData>>)(object)headLookRig).weight = Mathf.Lerp(((RigConstraint<MultiAimConstraintJob, MultiAimConstraintData, MultiAimConstraintJobBinder<MultiAimConstraintData>>)(object)headLookRig).weight, 0f, 10f);
				return;
			}
			lookTarget.position = positionOfInterest;
		}
		if (((NetworkBehaviour)this).IsOwner)
		{
			base.agent.angularSpeed = 0f;
			turnCompass.LookAt(lookTarget);
			((Component)this).transform.rotation = Quaternion.Lerp(((Component)this).transform.rotation, turnCompass.rotation, 6f * Time.deltaTime);
			((Component)this).transform.localEulerAngles = new Vector3(0f, ((Component)this).transform.localEulerAngles.y, 0f);
		}
		float num = Vector3.Angle(((Component)this).transform.forward, lookTarget.position - ((Component)this).transform.position);
		if (num > 22f)
		{
			((RigConstraint<MultiAimConstraintJob, MultiAimConstraintData, MultiAimConstraintJobBinder<MultiAimConstraintData>>)(object)headLookRig).weight = Mathf.Lerp(((RigConstraint<MultiAimConstraintJob, MultiAimConstraintData, MultiAimConstraintJobBinder<MultiAimConstraintData>>)(object)headLookRig).weight, 1f * (Mathf.Abs(num - 180f) / 180f), 7f);
		}
		else
		{
			((RigConstraint<MultiAimConstraintJob, MultiAimConstraintData, MultiAimConstraintJobBinder<MultiAimConstraintData>>)(object)headLookRig).weight = Mathf.Lerp(((RigConstraint<MultiAimConstraintJob, MultiAimConstraintData, MultiAimConstraintJobBinder<MultiAimConstraintData>>)(object)headLookRig).weight, 1f, 7f);
		}
		headLookTarget.position = Vector3.Lerp(headLookTarget.position, lookTarget.position, 8f * Time.deltaTime);
	}

	private void DetectAndLookAtPlayers()
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0120: Unknown result type (might be due to invalid IL or missing references)
		//IL_0143: Unknown result type (might be due to invalid IL or missing references)
		//IL_0149: Unknown result type (might be due to invalid IL or missing references)
		//IL_016d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0173: Invalid comparison between Unknown and I4
		//IL_018a: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0274: 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_023a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0245: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = ((base.currentBehaviourStateIndex != 1) ? ((Component)this).transform.position : nestPosition);
		PlayerControllerB[] allPlayersInLineOfSight = ((EnemyAI)this).GetAllPlayersInLineOfSight(70f, 30, base.eye, 1.2f, -1);
		if (allPlayersInLineOfSight != null)
		{
			PlayerControllerB val2 = 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 (!flag && (Object)(object)allPlayersInLineOfSight[i].currentlyHeldObjectServer != (Object)null)
				{
					for (int j = 0; j < HoarderBugItems.Count; j++)
					{
						if ((Object)(object)HoarderBugItems[j].itemGrabbableObject == (Object)(object)allPlayersInLineOfSight[i].currentlyHeldObjectServer)
						{
							HoarderBugItems[j].status = (HoarderBugItemStatus)1;
							angryAtPlayer = allPlayersInLineOfSight[i];
							flag = true;
						}
					}
				}
				if (IsHoarderBugAngry() && (Object)(object)allPlayersInLineOfSight[i] == (Object)(object)angryAtPlayer)
				{
					watchingPlayer = angryAtPlayer;
				}
				else
				{
					float num2 = Vector3.Distance(((Component)allPlayersInLineOfSight[i]).transform.position, val);
					if (num2 < num)
					{
						num = num2;
						watchingPlayer = allPlayersInLineOfSight[i];
					}
				}
				float num3 = Vector3.Distance(((Component)allPlayersInLineOfSight[i]).transform.position, nestPosition);
				bool flag2 = HoarderBugItems.Count == 1 && (int)HoarderBugItems[0].status != 1 && Vector3.Distance(((Component)HoarderBugItems[0].itemGrabbableObject).transform.position, nestPosition) > 4f;
				if (HoarderBugItems.Count > 0 && !flag2)
				{
					if ((num3 < 4f || (inChase && num3 < 8f)) && angryTimer < 3.25f)
					{
						angryAtPlayer = allPlayersInLineOfSight[i];
						watchingPlayer = allPlayersInLineOfSight[i];
						angryTimer = 3.25f;
						break;
					}
					if (!isAngry && base.currentBehaviourStateIndex == 0 && num3 < 8f && ((Object)(object)targetItem == (Object)null || Vector3.Distance(((Component)targetItem).transform.position, ((Component)this).transform.position) > 7.5f) && ((NetworkBehaviour)this).IsOwner)
					{
						((EnemyAI)this).SwitchToBehaviourState(1);
					}
				}
				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)val2)
			{
				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;
					((EnemyAI)this).SwitchToBehaviourState(2);
				}
			}
			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)
		{
			if (timeSinceSeeingAPlayer > 15f)
			{
				((EnemyAI)this).SwitchToBehaviourState(1);
			}
			else if (timeSinceSeeingAPlayer > 2.5f)
			{
				lostPlayerInChase = true;
			}
		}
	}

	private bool IsHoarderBugAngry()
	{
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Invalid comparison between Unknown and I4
		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;
		for (int i = 0; i < HoarderBugItems.Count; i++)
		{
			if ((int)HoarderBugItems[i].status == 1)
			{
				num2++;
			}
			else if ((int)HoarderBugItems[i].status == 2)
			{
				num++;
			}
		}
		if (!(angryTimer > 0f))
		{
			return num2 > 0;
		}
		return true;
	}

	public override void Update()
	{
		//IL_0241: Unknown result type (might be due to invalid IL or missing references)
		//IL_0255: Unknown result type (might be due to invalid IL or missing references)
		//IL_0336: Unknown result type (might be due to invalid IL or missing references)
		//IL_033b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0345: Unknown result type (might be due to invalid IL or missing references)
		//IL_034a: Unknown result type (might be due to invalid IL or missing references)
		((EnemyAI)this).Update();
		timeSinceHittingPlayer += Time.deltaTime;
		timeSinceLookingTowardsNoise += Time.deltaTime;
		if (timeSinceLookingTowardsNoise > 0.6f)
		{
			lookingAtPositionOfInterest = false;
		}
		if (base.inSpecialAnimation || base.isEnemyDead || StartOfRound.Instance.allPlayersDead)
		{
			return;
		}
		if (angryTimer >= 0f)
		{
			angryTimer -= Time.deltaTime;
		}
		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:
			ExitChaseMode();
			base.addPlayerVelocityToDestination = 0f;
			if (base.stunNormalizedTimer > 0f)
			{
				base.agent.speed = 0f;
			}
			else
			{
				base.agent.speed = roamSpeed;
			}
			waitingAtNest = false;
			break;
		case 1:
			ExitChaseMode();
			base.addPlayerVelocityToDestination = 0f;
			if (base.stunNormalizedTimer > 0f)
			{
				base.agent.speed = 0f;
			}
			else
			{
				base.agent.speed = retrieveSpeed;
			}
			base.agent.acceleration = retrieveAccel;
			if (waitingAtNest && waitingAtNestTimer > 0f)
			{
				waitingAtNestTimer -= Time.deltaTime;
			}
			break;
		case 2:
			if (!inChase)
			{
				inChase = true;
				base.creatureSFX.clip = bugFlySFX;
				base.creatureSFX.Play();
				RoundManager.PlayRandomClip(base.creatureVoice, angryScreechSFX, true, 1f, 0, 1000);
				base.creatureAnimator.SetBool("Chase", true);
				waitingAtNest = false;
				if (Vector3.Distance(((Component)this).transform.position, ((Component)GameNetworkManager.Instance.localPlayerController).transform.position) < 10f)
				{
					GameNetworkManager.Instance.localPlayerController.JumpToFearLevel(0.5f, true);
				}
			}
			base.addPlayerVelocityToDestination = 2f;
			if (!((NetworkBehaviour)this).IsOwner)
			{
				break;
			}
			if (!IsHoarderBugAngry())
			{
				HoarderBugItem val = CheckLineOfSightForItem((HoarderBugItemStatus)2, 60f, 12, 3f);
				if (val != null && !val.itemGrabbableObject.isHeld)
				{
					((EnemyAI)this).SwitchToBehaviourState(0);
					SetGoTowardsTargetObject(((Component)val.itemGrabbableObject).gameObject);
				}
				else
				{
					((EnemyAI)this).SwitchToBehaviourState(1);
				}
				ExitChaseMode();
				break;
			}
			if (base.stunNormalizedTimer > 0f)
			{
				base.agent.speed = 0f;
			}
			else
			{
				base.agent.speed = chaseSpeed;
			}
			base.agent.acceleration = chaseAccel;
			if (GameNetworkManager.Instance.localPlayerController.HasLineOfSightToPosition(((Component)this).transform.position + Vector3.up * 0.75f, 60f, 15, -1f, -1))
			{
				GameNetworkManager.Instance.localPlayerController.IncreaseFearLevelOverTime(fearOnLOS, 1f);
			}
			break;
		}
	}

	public override void DetectNoise(Vector3 noisePosition, float noiseLoudness, int timesPlayedInOneSpot = 0, int noiseID = 0)
	{
		//IL_0001: 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_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		((EnemyAI)this).DetectNoise(noisePosition, noiseLoudness, timesPlayedInOneSpot, noiseID);
		if (timesPlayedInOneSpot <= 10 && !(timeSinceLookingTowardsNoise < 0.6f))
		{
			timeSinceLookingTowardsNoise = 0f;
			float num = Vector3.Distance(noisePosition, nestPosition);
			if (((NetworkBehaviour)this).IsOwner && HoarderBugItems.Count > 0 && !isAngry && base.currentBehaviourStateIndex == 0 && num < 15f && ((Object)(object)targetItem == (Object)null || Vector3.Distance(((Component)targetItem).transform.position, ((Component)this).transform.position) > 4.5f))
			{
				((EnemyAI)this).SwitchToBehaviourState(1);
			}
			positionOfInterest = noisePosition;
			lookingAtPositionOfInterest = true;
		}
	}

	private void DropItemAndCallDropRPC(NetworkObject dropItemNetworkObject, bool droppedInNest = true)
	{
		//IL_0012: 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_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: 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_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		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_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_0115: Unknown result type (might be due to invalid IL or missing references)
		//IL_011f: Invalid comparison between Unknown and I4
		//IL_014a: 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_0151: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Invalid comparison between Unknown and I4
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
		{
			if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
				return;
			}
			ServerRpcParams val2 = default(ServerRpcParams);
			FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(662820216u, val2, (RpcDelivery)0);
			((FastBufferWriter)(ref val)).WriteValueSafe<NetworkObjectReference>(ref objectRef, default(ForNetworkSerializable));
			((FastBufferWriter)(ref val)).WriteValueSafe(ref targetFloorPosition);
			((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref droppedInNest, default(ForPrimitives));
			((NetworkBehaviour)this).__endSendServerRpc(ref val, 662820216u, val2, (RpcDelivery)0);
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
		{
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			DropItemClientRpc(objectRef, targetFloorPosition, droppedInNest);
		}
	}

	[ClientRpc]
	public void DropItemClientRpc(NetworkObjectReference objectRef, Vector3 targetFloorPosition, bool droppedInNest)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d9: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_0104: Unknown result type (might be due to invalid IL or missing references)
		//IL_0117: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
		{
			ClientRpcParams val2 = default(ClientRpcParams);
			FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(3319827056u, val2, (RpcDelivery)0);
			((FastBufferWriter)(ref val)).WriteValueSafe<NetworkObjectReference>(ref objectRef, default(ForNetworkSerializable));
			((FastBufferWriter)(ref val)).WriteValueSafe(ref targetFloorPosition);
			((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref droppedInNest, default(ForPrimitives));
			((NetworkBehaviour)this).__endSendClientRpc(ref val, 3319827056u, val2, (RpcDelivery)0);
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
		{
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			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 GrabItemServerRpc(NetworkObjectReference objectRef)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f7: Invalid comparison between Unknown and I4
		//IL_0122: Unknown result type (might be due to invalid IL or missing references)
		//IL_0128: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Invalid comparison between Unknown and I4
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
		{
			if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
				return;
			}
			ServerRpcParams val2 = default(ServerRpcParams);
			FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(2883007434u, val2, (RpcDelivery)0);
			((FastBufferWriter)(ref val)).WriteValueSafe<NetworkObjectReference>(ref objectRef, default(ForNetworkSerializable));
			((NetworkBehaviour)this).__endSendServerRpc(ref val, 2883007434u, val2, (RpcDelivery)0);
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
		{
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			GrabItemClientRpc(objectRef);
		}
	}

	[ClientRpc]
	public void GrabItemClientRpc(NetworkObjectReference objectRef)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
		{
			ClientRpcParams val2 = default(ClientRpcParams);
			FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(2686653120u, val2, (RpcDelivery)0);
			((FastBufferWriter)(ref val)).WriteValueSafe<NetworkObjectReference>(ref objectRef, default(ForNetworkSerializable));
			((NetworkBehaviour)this).__endSendClientRpc(ref val, 2686653120u, val2, (RpcDelivery)0);
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
		{
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			((EnemyAI)this).SwitchToBehaviourStateOnLocalClient(1);
			NetworkObject item = default(NetworkObject);
			if (((NetworkObjectReference)(ref objectRef)).TryGet(ref item, (NetworkManager)null))
			{
				GrabItem(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_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: 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)
		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)
		{
			grabbableObjectsInMap.Add(((Component)itemGrabbableObject).gameObject);
		}
	}

	private void GrabItem(NetworkObject item)
	{
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d1: Expected O, but got Unknown
		//IL_0095: 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_009c: Unknown result type (might be due to invalid IL or missing references)
		if (sendingGrabOrDropRPC)
		{
			sendingGrabOrDropRPC = false;
			return;
		}
		if (heldItem != null)
		{
			Debug.Log((object)(((Object)((Component)this).gameObject).name + ": Trying to grab another item (" + ((Object)((Component)item).gameObject).name + ") while hands are already full with item (" + ((Object)((Component)heldItem.itemGrabbableObject).gameObject).name + "). Dropping the currently held one."));
			DropItem(((Component)heldItem.itemGrabbableObject).GetComponent<NetworkObject>(), heldItem.itemGrabbableObject.GetItemFloorPosition(default(Vector3)));
		}
		targetItem = null;
		GrabbableObject component = ((Component)item).gameObject.GetComponent<GrabbableObject>();
		HoarderBugItems.Add(new HoarderBugItem(component, (HoarderBugItemStatus)0, nestPosition));
		heldItem = HoarderBugItems[HoarderBugItems.Count - 1];
		component.parentObject = grabTarget;
		component.hasHitGround = false;
		component.GrabItemFromEnemy((EnemyAI)(object)this);
		component.EnablePhysics(false);
		grabbableObjectsInMap.Remove(((Component)component).gameObject);
	}

	public override void OnCollideWithPlayer(Collider other)
	{
		//IL_0044: 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)
		((EnemyAI)this).OnCollideWithPlayer(other);
		if (inChase && !(timeSinceHittingPlayer < 0.5f))
		{
			PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, false, false);
			if ((Object)(object)val != (Object)null)
			{
				timeSinceHittingPlayer = 0f;
				val.DamagePlayer(30, true, true, (CauseOfDeath)6, 0, false, default(Vector3));
				HitPlayerServerRpc();
			}
		}
	}

	[ServerRpc(RequireOwnership = false)]
	public void HitPlayerServerRpc()
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val2 = default(ServerRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(2017144155u, val2, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendServerRpc(ref val, 2017144155u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				HitPlayerClientRpc();
			}
		}
	}

	[ClientRpc]
	public void HitPlayerClientRpc()
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
		{
			ClientRpcParams val2 = default(ClientRpcParams);
			FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(3300716622u, val2, (RpcDelivery)0);
			((NetworkBehaviour)this).__endSendClientRpc(ref val, 3300716622u, val2, (RpcDelivery)0);
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
		{
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			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)
	{
		((EnemyAI)this).HitEnemy(force, playerWhoHit, playHitSFX, hitID);
		Debug.Log((object)"HA");
		if (!base.isEnemyDead)
		{
			Debug.Log((object)"HB");
			base.creatureAnimator.SetTrigger("damage");
			angryAtPlayer = playerWhoHit;
			angryTimer += 18f;
			Debug.Log((object)"HC");
			base.enemyHP -= force;
			if (base.enemyHP <= 0 && ((NetworkBehaviour)this).IsOwner)
			{
				((EnemyAI)this).KillEnemyOnOwnerClient(false);
			}
		}
	}

	public override void KillEnemy(bool destroy = false)
	{
		((EnemyAI)this).KillEnemy(false);
		base.agent.speed = 0f;
		base.creatureVoice.Stop();
		base.creatureSFX.Stop();
		if (heldItem != null)
		{
			DropItemAndCallDropRPC(((Component)heldItem.itemGrabbableObject).GetComponent<NetworkObject>(), droppedInNest: false);
		}
	}

	public HoarderBugItem CheckLineOfSightForItem(HoarderBugItemStatus searchForItemsOfStatus = (HoarderBugItemStatus)(-1), float width = 45f, int range = 60, float proximityAwareness = -1f)
	{
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Invalid comparison between Unknown and I4
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: 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_008d: 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_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		for (int i = 0; i < HoarderBugItems.Count; i++)
		{
			if (!HoarderBugItems[i].itemGrabbableObject.grabbableToEnemies || HoarderBugItems[i].itemGrabbableObject.isHeld || ((int)searchForItemsOfStatus != -1 && HoarderBugItems[i].status != searchForItemsOfStatus))
			{
				continue;
			}
			Vector3 position = ((Component)HoarderBugItems[i].itemGrabbableObject).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)
				{
					Debug.Log((object)"SEEING PLAYER");
					return HoarderBugItems[i];
				}
			}
		}
		return null;
	}

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

	protected override void __initializeRpcs()
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Expected O, but got Unknown
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Expected O, but got Unknown
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Expected O, but got Unknown
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Expected O, but got Unknown
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Expected O, but got Unknown
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Expected O, but got Unknown
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Expected O, but got Unknown
		//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: Expected O, but got Unknown
		((NetworkBehaviour)this).__registerRpc(4245383865u, new RpcReceiveHandler(__rpc_handler_4245383865), "SyncNestPositionServerRpc");
		((NetworkBehaviour)this).__registerRpc(3305399717u, new RpcReceiveHandler(__rpc_handler_3305399717), "SyncNestPositionClientRpc");
		((NetworkBehaviour)this).__registerRpc(662820216u, new RpcReceiveHandler(__rpc_handler_662820216), "DropItemServerRpc");
		((NetworkBehaviour)this).__registerRpc(3319827056u, new RpcReceiveHandler(__rpc_handler_3319827056), "DropItemClientRpc");
		((NetworkBehaviour)this).__registerRpc(2883007434u, new RpcReceiveHandler(__rpc_handler_2883007434), "GrabItemServerRpc");
		((NetworkBehaviour)this).__registerRpc(2686653120u, new RpcReceiveHandler(__rpc_handler_2686653120), "GrabItemClientRpc");
		((NetworkBehaviour)this).__registerRpc(2017144155u, new RpcReceiveHandler(__rpc_handler_2017144155), "HitPlayerServerRpc");
		((NetworkBehaviour)this).__registerRpc(3300716622u, new RpcReceiveHandler(__rpc_handler_3300716622), "HitPlayerClientRpc");
		((EnemyAI)this).__initializeRpcs();
	}

	private static void __rpc_handler_4245383865(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: 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_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Invalid comparison between Unknown and I4
		NetworkManager networkManager = target.NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
		{
			if ((int)networkManager.LogLevel <= 1)
			{
				Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
			}
		}
		else
		{
			Vector3 newNestPosition = default(Vector3);
			((FastBufferReader)(ref reader)).ReadValueSafe(ref newNestPosition);
			target.__rpc_exec_stage = (__RpcExecStage)1;
			((CollectorBugAI)(object)target).SyncNestPositionServerRpc(newNestPosition);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	private static void __rpc_handler_3305399717(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
	{
		//IL_0036: 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_0050: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = target.NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			Vector3 newNestPosition = default(Vector3);
			((FastBufferReader)(ref reader)).ReadValueSafe(ref newNestPosition);
			target.__rpc_exec_stage = (__RpcExecStage)1;
			((CollectorBugAI)(object)target).SyncNestPositionClientRpc(newNestPosition);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	private static void __rpc_handler_662820216(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: 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_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Invalid comparison between Unknown and I4
		NetworkManager networkManager = target.NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
		{
			if ((int)networkManager.LogLevel <= 1)
			{
				Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
			}
			return;
		}
		NetworkObjectReference objectRef = default(NetworkObjectReference);
		((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref objectRef, default(ForNetworkSerializable));
		Vector3 targetFloorPosition = default(Vector3);
		((FastBufferReader)(ref reader)).ReadValueSafe(ref targetFloorPosition);
		bool droppedInNest = default(bool);
		((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref droppedInNest, default(ForPrimitives));
		target.__rpc_exec_stage = (__RpcExecStage)1;
		((CollectorBugAI)(object)target).DropItemServerRpc(objectRef, targetFloorPosition, droppedInNest);
		target.__rpc_exec_stage = (__RpcExecStage)0;
	}

	private static void __rpc_handler_3319827056(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
	{
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: 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_007b: 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)
		NetworkManager networkManager = target.NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			NetworkObjectReference objectRef = default(NetworkObjectReference);
			((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref objectRef, default(ForNetworkSerializable));
			Vector3 targetFloorPosition = default(Vector3);
			((FastBufferReader)(ref reader)).ReadValueSafe(ref targetFloorPosition);
			bool droppedInNest = default(bool);
			((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref droppedInNest, default(ForPrimitives));
			target.__rpc_exec_stage = (__RpcExecStage)1;
			((CollectorBugAI)(object)target).DropItemClientRpc(objectRef, targetFloorPosition, droppedInNest);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	private static void __rpc_handler_2883007434(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Invalid comparison between Unknown and I4
		NetworkManager networkManager = target.NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
		{
			if ((int)networkManager.LogLevel <= 1)
			{
				Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
			}
		}
		else
		{
			NetworkObjectReference objectRef = default(NetworkObjectReference);
			((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref objectRef, default(ForNetworkSerializable));
			target.__rpc_exec_stage = (__RpcExecStage)1;
			((CollectorBugAI)(object)target).GrabItemServerRpc(objectRef);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	private static void __rpc_handler_2686653120(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
	{
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: 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_005e: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = target.NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			NetworkObjectReference objectRef = default(NetworkObjectReference);
			((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref objectRef, default(ForNetworkSerializable));
			target.__rpc_exec_stage = (__RpcExecStage)1;
			((CollectorBugAI)(object)target).GrabItemClientRpc(objectRef);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

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

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

	[MethodImpl(MethodImplOptions.NoInlining)]
	protected internal override string __getTypeName()
	{
		return "CollectorBugAI";
	}
}
public class LocustsAI : EnemyAI
{
	private int previousBehaviour;

	public AISearchRoutine bugsRoam;

	public bool useVFX = true;

	public VisualEffect bugsEffect;

	public float bugsCollisionGoAway = 8f;

	public float bugsCollisionComeBack = 14f;

	private float timeSinceReturning;

	public ScanNodeProperties scanNode;

	public LayerMask bugsCollisionLayerMask = LayerMask.op_Implicit(520);

	public override void DoAIInterval()
	{
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: 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_008c: Unknown result type (might be due to invalid IL or missing references)
		((EnemyAI)this).DoAIInterval();
		if (StartOfRound.Instance.allPlayersDead || base.daytimeEnemyLeaving)
		{
			return;
		}
		switch (base.currentBehaviourStateIndex)
		{
		case 0:
			if (!bugsRoam.inProgress)
			{
				((EnemyAI)this).StartSearch(((Component)this).transform.position, bugsRoam);
			}
			if (Physics.CheckSphere(((Component)this).transform.position, bugsCollisionGoAway, LayerMask.op_Implicit(bugsCollisionLayerMask), (QueryTriggerInteraction)2))
			{
				((EnemyAI)this).SwitchToBehaviourState(1);
			}
			break;
		case 1:
			if (!Physics.CheckSphere(((Component)this).transform.position, bugsCollisionComeBack, LayerMask.op_Implicit(bugsCollisionLayerMask), (QueryTriggerInteraction)2))
			{
				((EnemyAI)this).SwitchToBehaviourState(0);
			}
			break;
		}
	}

	public override void Update()
	{
		//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_015b: Unknown result type (might be due to invalid IL or missing references)
		((EnemyAI)this).Update();
		if (useVFX)
		{
			bugsEffect.SetBool("Alive", Vector3.Distance(((Component)StartOfRound.Instance.activeCamera).transform.position, ((Component)this).transform.position) < 62f);
		}
		switch (base.currentBehaviourStateIndex)
		{
		case 0:
			if (previousBehaviour != 0)
			{
				previousBehaviour = 0;
				if (useVFX)
				{
					bugsEffect.SetFloat("MoveToTargetForce", 6f);
				}
				base.creatureVoice.Play();
			}
			scanNode.maxRange = 18;
			timeSinceReturning += Time.deltaTime;
			base.creatureVoice.volume = Mathf.Min(base.creatureVoice.volume + Time.deltaTime * 0.25f, 1f);
			break;
		case 1:
			if (previousBehaviour != 1)
			{
				previousBehaviour = 1;
				if (useVFX)
				{
					bugsEffect.SetFloat("MoveToTargetForce", -35f);
				}
				if (timeSinceReturning > 2f)
				{
					base.creatureSFX.PlayOneShot(base.enemyType.audioClips[0]);
					WalkieTalkie.TransmitOneShotAudio(base.creatureSFX, base.enemyType.audioClips[0], 0.8f);
					RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, 8f, 0.35f, 0, false, 14152);
				}
				timeSinceReturning = 0f;
			}
			scanNode.maxRange = 1;
			if (base.creatureVoice.volume > 0f)
			{
				base.creatureVoice.volume = Mathf.Max(base.creatureVoice.volume - Time.deltaTime * 1.75f, 0f);
			}
			else
			{
				base.creatureVoice.Stop();
			}
			break;
		}
	}

	public override void DaytimeEnemyLeave()
	{
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		((EnemyAI)this).DaytimeEnemyLeave();
		if (useVFX)
		{
			bugsEffect.SetFloat("MoveToTargetForce", -15f);
		}
		base.creatureSFX.PlayOneShot(base.enemyType.audioClips[0], 0.5f);
		WalkieTalkie.TransmitOneShotAudio(base.creatureSFX, base.enemyType.audioClips[0], 0.4f);
		RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, 6f, 0.2f, 0, false, 14152);
		((MonoBehaviour)this).StartCoroutine(bugsLeave());
	}

	private IEnumerator bugsLeave()
	{
		yield return (object)new WaitForSeconds(6f);
		((EnemyAI)this).KillEnemyOnOwnerClient(true);
	}

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

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

	[MethodImpl(MethodImplOptions.NoInlining)]
	protected internal override string __getTypeName()
	{
		return "LocustsAI";
	}
}
public class SplodyAI : EnemyAI
{
	private int previousBehaviour;

	public AISearchRoutine sRoutine;

	public AISearchRoutine rRoutine;

	public float bugsCollisionGoAway = 8f;

	public float bugsCollisionComeBack = 14f;

	public ScanNodeProperties scanNode;

	public LayerMask bugsCollisionLayerMask = LayerMask.op_Implicit(520);

	[Range(0f, 100f)]
	public int chanceToStopStare = 20;

	private int incrementToChance;

	private float timer;

	private bool isStopped;

	private bool dun;

	public float stopTime = 5f;

	public float stopTimeVar = 0.4f;

	private SplodyStop stopValue = SplodyStop.Hide;

	private int maxHP;

	[Header("Agent Settings")]
	public float roamSpeed = 4f;

	public float awareSpeed = 7f;

	public float runningSpeed = 11f;

	public float runIncrement = 0.1f;

	public override void Start()
	{
		((EnemyAI)this).Start();
		maxHP = base.enemyHP;
	}

	public override void DoAIInterval()
	{
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: 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_00be: Unknown result type (might be due to invalid IL or missing references)
		((EnemyAI)this).DoAIInterval();
		if (base.isEnemyDead || StartOfRound.Instance.allPlayersDead || base.daytimeEnemyLeaving)
		{
			return;
		}
		switch (base.currentBehaviourStateIndex)
		{
		case 0:
			if (!sRoutine.inProgress)
			{
				((EnemyAI)this).StartSearch(((Component)this).transform.position, sRoutine);
			}
			Physics.CheckSphere(((Component)this).transform.position, bugsCollisionGoAway, LayerMask.op_Implicit(bugsCollisionLayerMask), (QueryTriggerInteraction)2);
			break;
		case 1:
			Physics.CheckSphere(((Component)this).transform.position, bugsCollisionComeBack, LayerMask.op_Implicit(bugsCollisionLayerMask), (QueryTriggerInteraction)2);
			break;
		case 2:
			if (!sRoutine.inProgress)
			{
				((EnemyAI)this).StartSearch(((Component)this).transform.position, sRoutine);
			}
			break;
		}
	}

	public override void Update()
	{
		timer += Time.deltaTime;
		((EnemyAI)this).Update();
		switch (base.currentBehaviourStateIndex)
		{
		case 0:
			if (previousBehaviour != 0)
			{
				if (!dun)
				{
					base.agent.speed = roamSpeed;
					isStopped = false;
				}
				else
				{
					base.agent.speed = 0f;
					isStopped = true;
				}
				if (timer + 1f < Time.realtimeSinceStartup)
				{
					timer = Time.realtimeSinceStartup;
					RollChanceOnServerRpc();
				}
			}
			break;
		case 1:
			if (previousBehaviour != 1)
			{
				base.agent.speed = awareSpeed;
			}
			break;
		case 2:
			base.agent.speed = Mathf.Clamp(runIncrement * Time.deltaTime, awareSpeed, runningSpeed);
			break;
		}
		if (isStopped)
		{
			base.creatureAnimator.SetBool("isStopped", true);
		}
		else
		{
			base.creatureAnimator.SetBool("isStopped", false);
		}
	}

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

	[ServerRpc]
	public void RollChanceOnServerRpc()
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: Invalid comparison between Unknown and I4
		//IL_0107: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Invalid comparison between Unknown and I4
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
		{
			if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
				return;
			}
			ServerRpcParams val2 = default(ServerRpcParams);
			FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(1145933448u, val2, (RpcDelivery)0);
			((NetworkBehaviour)this).__endSendServerRpc(ref val, 1145933448u, val2, (RpcDelivery)0);
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
		{
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			int num = Random.Range(0, 99);
			if (num < chanceToStopStare)
			{
				dun = true;
			}
		}
	}

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

	protected override void __initializeRpcs()
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Expected O, but got Unknown
		((NetworkBehaviour)this).__registerRpc(1145933448u, new RpcReceiveHandler(__rpc_handler_1145933448), "RollChanceOnServerRpc");
		((EnemyAI)this).__initializeRpcs();
	}

	private static void __rpc_handler_1145933448(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Invalid comparison between Unknown and I4
		NetworkManager networkManager = target.NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
		{
			if ((int)networkManager.LogLevel <= 1)
			{
				Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
			}
		}
		else
		{
			target.__rpc_exec_stage = (__RpcExecStage)1;
			((SplodyAI)(object)target).RollChanceOnServerRpc();
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	[MethodImpl(MethodImplOptions.NoInlining)]
	protected internal override string __getTypeName()
	{
		return "SplodyAI";
	}
}
public class GunShellItem : GrabbableObject
{
	public int ammoType;

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

	protected override void __initializeRpcs()
	{
		((GrabbableObject)this).__initializeRpcs();
	}

	[MethodImpl(MethodImplOptions.NoInlining)]
	protected internal override string __getTypeName()
	{
		return "GunShellItem";
	}
}
public class JetWingsItem : GrabbableObject
{
	public bool streamlineJetpack;

	public Transform backPart;

	public Vector3 backPartRotationOffset;

	public Vector3 backPartPositionOffset;

	private float jetpackPower;

	private bool jetpackActivated;

	private Vector3 forces;

	private bool jetpackActivatedPreviousFrame;

	public GameObject fireEffect;

	public AudioSource jetpackAudio;

	public AudioSource jetpackBeepsAudio;

	public AudioClip startJetpackSFX;

	public AudioClip jetpackSustainSFX;

	public AudioClip jetpackBrokenSFX;

	public AudioClip jetpackWarningBeepSFX;

	public AudioClip jetpackLowBatteriesSFX;

	public ParticleSystem smokeTrailParticle;

	private PlayerControllerB previousPlayerHeldBy;

	private bool jetpackBroken;

	private bool jetpackPlayingWarningBeep;

	private bool jetpackPlayingLowBatteryBeep;

	private float noiseInterval;

	private RaycastHit rayHit;

	public float jetpackAcceleration = 25f;

	public float jetpackDeaccelleration = 30f;

	public float jetpackForceChangeSpeed = 50f;

	public float verticalMultiplier = 0.35f;

	public AudioClip applause;

	public ChainIKConstraint cordRig;

	public CauseOfDeath causeOfdeath = (CauseOfDeath)2;

	public float jetpackMaxAccel = 500f;

	public float jetpackMaxDeaccel = 1000f;

	public LayerMask jetpackMask = LayerMask.op_Implicit((1 << LayerMask.NameToLayer("Room")) | (1 << LayerMask.NameToLayer("Colliders")) | (1 << LayerMask.NameToLayer("Terrain")));

	public float speedRequiredToExplode = 50f;

	public float minDistanceToColliderToExplode = 4f;

	public void Awake()
	{
		//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)
		if (((LayerMask)(ref jetpackMask)).value == 0 || ((LayerMask)(ref jetpackMask)).value == -1)
		{
			jetpackMask = LayerMask.op_Implicit((1 << LayerMask.NameToLayer("Room")) | (1 << LayerMask.NameToLayer("Colliders")) | (1 << LayerMask.NameToLayer("Terrain")));
		}
	}

	public override void ItemActivate(bool used, bool buttonDown = true)
	{
		((GrabbableObject)this).ItemActivate(used, buttonDown);
		if (buttonDown)
		{
			ActivateJetpack();
		}
		else
		{
			DeactivateJetpack();
		}
	}

	private void DeactivateJetpack()
	{
		if (previousPlayerHeldBy.jetpackControls)
		{
			previousPlayerHeldBy.disablingJetpackControls = true;
		}
		jetpackActivated = false;
		jetpackActivatedPreviousFrame = false;
		jetpackPlayingLowBatteryBeep = false;
		jetpackPlayingWarningBeep = false;
		jetpackBeepsAudio.Stop();
		jetpackAudio.Stop();
		smokeTrailParticle.Stop(true, (ParticleSystemStopBehavior)1);
		if (!jetpackBroken)
		{
			JetpackEffect(enable: false);
		}
	}

	private void ActivateJetpack()
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		if (streamlineJetpack)
		{
			if (Vector3.Distance(((Component)base.playerHeldBy).transform.position, StartOfRound.Instance.elevatorTransform.position) < 40f)
			{
				EntranceTeleport[] array = Object.FindObjectsOfType<EntranceTeleport>();
				for (int i = 0; i < array.Length; i++)
				{
					if (array[i].entranceId == 0 && array[i].isEntranceToBuilding)
					{
						base.playerHeldBy.TeleportPlayer(array[i].entrancePoint.position, false, 0f, false, true);
						base.playerHeldBy.SetAllItemsInElevator(false, false);
						base.playerHeldBy.isInElevator = false;
						base.playerHeldBy.isInHangarShipRoom = false;
						AudioReverbPresets val = Object.FindObjectOfType<AudioReverbPresets>();
						if ((Object)(object)val != (Object)null)
						{
							val.audioPresets[2].ChangeAudioReverbForPlayer(base.playerHeldBy);
						}
					}
				}
			}
			else
			{
				base.playerHeldBy.TeleportPlayer(StartOfRound.Instance.outsideShipSpawnPosition.position, false, 0f, false, true);
				base.playerHeldBy.SetAllItemsInElevator(false, true);
				base.playerHeldBy.isInElevator = true;
				base.playerHeldBy.isInsideFactory = false;
				AudioReverbPresets val2 = Object.FindObjectOfType<AudioReverbPresets>();
				if ((Object)(object)val2 != (Object)null)
				{
					val2.audioPresets[3].ChangeAudioReverbForPlayer(base.playerHeldBy);
				}
			}
			if ((Object)(object)base.playerHeldBy == (Object)(object)GameNetworkManager.Instance.localPlayerController)
			{
				SoundManager.Instance.misc2DAudio.volume = 1f;
				SoundManager.Instance.misc2DAudio.PlayOneShot(applause);
			}
		}
		if (jetpackBroken)
		{
			jetpackAudio.PlayOneShot(jetpackBrokenSFX);
			return;
		}
		if (!jetpackActivatedPreviousFrame)
		{
			base.playerHeldBy.jetpackTurnCompass.rotation = ((Component)base.playerHeldBy).transform.rotation;
			JetpackEffect(enable: true);
			jetpackActivatedPreviousFrame = true;
		}
		base.playerHeldBy.disablingJetpackControls = false;
		base.playerHeldBy.jetpackControls = true;
		jetpackActivated = true;
		base.playerHeldBy.syncFullRotation = ((Component)base.playerHeldBy).transform.eulerAngles;
	}

	private void JetpackEffect(bool enable)
	{
		//IL_00a0: 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)
		if (streamlineJetpack)
		{
			return;
		}
		fireEffect.SetActive(enable);
		if (enable)
		{
			if (!jetpackActivatedPreviousFrame)
			{
				jetpackAudio.PlayOneShot(startJetpackSFX);
			}
			smokeTrailParticle.Play();
			jetpackAudio.clip = jetpackSustainSFX;
			jetpackAudio.Play();
			Debug.Log((object)$"Is jetpack audio playing?: {jetpackAudio.isPlaying}");
		}
		else
		{
			smokeTrailParticle.Stop(true, (ParticleSystemStopBehavior)1);
			jetpackAudio.Stop();
		}
		if (Vector3.Distance(((Component)GameNetworkManager.Instance.localPlayerController).transform.position, ((Component)this).transform.position) < 10f)
		{
			HUDManager.Instance.ShakeCamera((ScreenShakeType)1);
		}
	}

	public override void UseUpBatteries()
	{
		DeactivateJetpack();
	}

	public override void DiscardItem()
	{
		//IL_0087: 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)
		Debug.Log((object)$"Owner of jetpack?: {((NetworkBehaviour)this).IsOwner}");
		Debug.Log((object)$"Is dead?: {base.playerHeldBy.isPlayerDead}");
		if (((NetworkBehaviour)this).IsOwner && base.playerHeldBy.isPlayerDead && !jetpackBroken && base.playerHeldBy.jetpackControls)
		{
			ExplodeJetpackServerRpc();
		}
		JetpackEffect(enable: false);
		DeactivateJetpack();
		jetpackPower = 0f;
		backPart.localPosition = Vector3.zero;
		backPart.localEulerAngles = Vector3.zero;
		((RigConstraint<ChainIKConstraintJob, ChainIKConstraintData, ChainIKConstraintJobBinder<ChainIKConstraintData>>)(object)cordRig).weight = 0f;
		((GrabbableObject)this).DiscardItem();
	}

	[ServerRpc(RequireOwnership = false)]
	public void ExplodeJetpackServerRpc()
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val2 = default(ServerRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(3107096448u, val2, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendServerRpc(ref val, 3107096448u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				ExplodeJetpackClientRpc();
			}
		}
	}

	[ClientRpc]
	public void ExplodeJetpackClientRpc()
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
		{
			ClientRpcParams val2 = default(ClientRpcParams);
			FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(97138363u, val2, (RpcDelivery)0);
			((NetworkBehaviour)this).__endSendClientRpc(ref val, 97138363u, val2, (RpcDelivery)0);
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
		{
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			if (!jetpackBroken)
			{
				jetpackBroken = true;
				base.itemUsedUp = true;
				Debug.Log((object)"Spawning explosion");
				Landmine.SpawnExplosion(((Component)this).transform.position, true, 5f, 6f, 50, 0f, (GameObject)null, false);
			}
		}
	}

	public override void EquipItem()
	{
		((GrabbableObject)this).EquipItem();
		previousPlayerHeldBy = base.playerHeldBy;
		((RigConstraint<ChainIKConstraintJob, ChainIKConstraintData, ChainIKConstraintJobBinder<ChainIKConstraintData>>)(object)cordRig).weight = 1f;
	}

	public override void Update()
	{
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f6: 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_0110: Unknown result type (might be due to invalid IL or missing references)
		//IL_0115: Unknown result type (might be due to invalid IL or missing references)
		//IL_0147: Unknown result type (might be due to invalid IL or missing references)
		//IL_014c: Unknown result type (might be due to invalid IL or missing references)
		//IL_016c: 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_0183: 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_0212: Unknown result type (might be due to invalid IL or missing references)
		//IL_0217: Unknown result type (might be due to invalid IL or missing references)
		//IL_021c: 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_01d5: 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_01e3: Unknown result type (might be due to invalid IL or missing references)
		((GrabbableObject)this).Update();
		if ((Object)(object)GameNetworkManager.Instance == (Object)null || (Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null || streamlineJetpack)
		{
			return;
		}
		SetJetpackAudios();
		if ((Object)(object)base.playerHeldBy == (Object)null || !((NetworkBehaviour)this).IsOwner || (Object)(object)base.playerHeldBy != (Object)(object)GameNetworkManager.Instance.localPlayerController)
		{
			return;
		}
		if (jetpackActivated)
		{
			jetpackPower = Mathf.Clamp(jetpackPower + Time.deltaTime * jetpackAcceleration, 0f, 500f);
		}
		else
		{
			jetpackPower = Mathf.Clamp(jetpackPower - Time.deltaTime * jetpackDeaccelleration, 0f, 1000f);
			if (base.playerHeldBy.thisController.isGrounded)
			{
				jetpackPower = 0f;
			}
		}
		forces = Vector3.Lerp(forces, Vector3.ClampMagnitude(((Component)base.playerHeldBy).transform.up * jetpackPower, 400f), Time.deltaTime * 50f);
		if (!base.playerHeldBy.jetpackControls || (jetpackPower > 10f && base.playerHeldBy.thisController.isGrounded))
		{
			forces = Vector3.zero;
		}
		if (!base.playerHeldBy.isPlayerDead && Physics.Raycast(((Component)base.playerHeldBy).transform.position, forces, ref rayHit, 25f, LayerMask.op_Implicit(jetpackMask), (QueryTriggerInteraction)1) && ((Vector3)(ref forces)).magnitude - ((RaycastHit)(ref rayHit)).distance > speedRequiredToExplode && ((RaycastHit)(ref rayHit)).distance < minDistanceToColliderToExplode)
		{
			base.playerHeldBy.KillPlayer(forces, true, causeOfdeath, 0, default(Vector3), false);
		}
		if ((Object)(object)base.playerHeldBy != (Object)null && !base.playerHeldBy.isPlayerDead)
		{
			PlayerControllerB playerHeldBy = base.playerHeldBy;
			playerHeldBy.externalForces += forces;
		}
	}

	private void SetJetpackAudios()
	{
		//IL_002e: 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)
		if (jetpackActivated)
		{
			if (noiseInterval >= 0.5f)
			{
				noiseInterval = 0f;
				RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, 25f, 0.85f, 0, base.playerHeldBy.isInHangarShipRoom && StartOfRound.Instance.hangarDoorsClosed, 41);
			}
			else
			{
				noiseInterval += Time.deltaTime;
			}
			if (base.insertedBattery.charge < 0.15f)
			{
				if (!jetpackPlayingLowBatteryBeep)
				{
					jetpackPlayingLowBatteryBeep = true;
					jetpackBeepsAudio.clip = jetpackLowBatteriesSFX;
					jetpackBeepsAudio.Play();
				}
			}
			else if (Physics.CheckSphere(((Component)this).transform.position, 6f, StartOfRound.Instance.collidersAndRoomMaskAndDefault))
			{
				if (!jetpackPlayingWarningBeep && !jetpackPlayingLowBatteryBeep)
				{
					jetpackPlayingWarningBeep = true;
					jetpackBeepsAudio.clip = jetpackWarningBeepSFX;
					jetpackBeepsAudio.Play();
				}
			}
			else
			{
				jetpackBeepsAudio.Stop();
			}
		}
		else
		{
			jetpackPlayingWarningBeep = false;
			jetpackPlayingLowBatteryBeep = false;
			jetpackBeepsAudio.Stop();
		}