Decompiled source of RetrieverUnits v1.0.1

Packages/neoninc.RetrieverUnit.dll

Decompiled 8 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using RetrieverUnit.Configuration;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using neoninc.RetrieverUnit.NetcodePatcher;

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

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ExampleEnemy
{
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "neoninc.RetrieverUnit";

		public const string PLUGIN_NAME = "RetrieverUnit";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace RetrieverUnit
{
	[HarmonyPatch(typeof(ItemDropship))]
	public static class DropshipMusicPatch
	{
		[HarmonyPatch("LandShipClientRpc")]
		[HarmonyPostfix]
		private static void LandShipClientRpc_Postfix(ItemDropship __instance)
		{
			FieldInfo field = typeof(ItemDropship).GetField("itemsToDeliver", BindingFlags.Instance | BindingFlags.NonPublic);
			if (field == null || !(field.GetValue(__instance) is List<int> list) || list.Count == 0)
			{
				return;
			}
			Terminal val = Object.FindObjectOfType<Terminal>();
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			bool flag = false;
			foreach (int item in list)
			{
				if (item < 0 || item >= val.buyableItemsList.Length || !(val.buyableItemsList[item]?.itemName == "RetrieverUnit"))
				{
					continue;
				}
				flag = true;
				break;
			}
			if (!flag)
			{
				return;
			}
			if ((Object)(object)Plugin.RetrieverDeliveryMusic == (Object)null)
			{
				AudioClip[] array = Resources.FindObjectsOfTypeAll<AudioClip>();
				AudioClip[] array2 = array;
				foreach (AudioClip val2 in array2)
				{
					if (((Object)val2).name == "IcecreamTruckV2VehicleDeliveryVer")
					{
						Plugin.RetrieverDeliveryMusic = val2;
						Plugin.Logger.LogInfo((object)("Found cruiser music: " + ((Object)val2).name));
						break;
					}
				}
			}
			if ((Object)(object)Plugin.RetrieverDeliveryMusic == (Object)null)
			{
				AudioClip[] array3 = Resources.FindObjectsOfTypeAll<AudioClip>();
				Plugin.Logger.LogWarning((object)$"Music not found! Searching similar ({array3.Length} total):");
				AudioClip[] array4 = array3;
				foreach (AudioClip val3 in array4)
				{
					if (((Object)val3).name.ToLower().Contains("truck") || ((Object)val3).name.ToLower().Contains("cruiser") || ((Object)val3).name.ToLower().Contains("icecream"))
					{
						Plugin.Logger.LogWarning((object)("  → " + ((Object)val3).name));
					}
				}
				return;
			}
			AudioSource[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<AudioSource>(true);
			Plugin.Logger.LogInfo((object)$"Dropship AudioSources ({componentsInChildren.Length}):");
			AudioSource[] array5 = componentsInChildren;
			foreach (AudioSource val4 in array5)
			{
				ManualLogSource logger = Plugin.Logger;
				object[] obj = new object[4]
				{
					((Object)val4).name,
					val4.loop,
					val4.isPlaying,
					null
				};
				AudioClip clip = val4.clip;
				obj[3] = ((clip != null) ? ((Object)clip).name : null);
				logger.LogInfo((object)string.Format("  {0} | loop={1} playing={2} clip={3}", obj));
			}
			AudioSource[] array6 = componentsInChildren;
			foreach (AudioSource val5 in array6)
			{
				if (val5.isPlaying && val5.loop)
				{
					val5.Stop();
					val5.clip = Plugin.RetrieverDeliveryMusic;
					val5.loop = true;
					val5.volume = 0.8f;
					val5.Play();
					Plugin.Logger.LogInfo((object)"Music replaced successfully!");
					return;
				}
			}
			if (componentsInChildren.Length != 0)
			{
				componentsInChildren[0].PlayOneShot(Plugin.RetrieverDeliveryMusic, 0.8f);
				Plugin.Logger.LogInfo((object)"Music via PlayOneShot.");
			}
		}
	}
	[BepInPlugin("neoninc.RetrieverUnit", "RetrieverUnit", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		public static AssetBundle? ModAssets;

		public static AudioClip? RetrieverDeliveryMusic;

		public const string RETRIEVER_ITEM_NAME = "RetrieverUnit";

		internal static PluginConfig BoundConfig { get; private set; }

		private void Awake()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			BoundConfig = new PluginConfig(((BaseUnityPlugin)this).Config);
			LoadAssetBundle();
			Harmony val = new Harmony("neoninc.RetrieverUnit");
			val.PatchAll();
			if ((Object)(object)ModAssets == (Object)null)
			{
				Logger.LogError((object)"AssetBundle failed to load.");
				return;
			}
			InitializeNetworkBehaviours();
			EnemyType val2 = ModAssets.LoadAsset<EnemyType>("RetrieverUnit");
			if ((Object)(object)val2 == (Object)null)
			{
				Logger.LogError((object)"RetrieverEnemy NOT FOUND in AssetBundle!");
				return;
			}
			if ((Object)(object)val2.enemyPrefab == (Object)null)
			{
				Logger.LogError((object)"Enemy prefab is NULL!");
				return;
			}
			NetworkPrefabs.RegisterNetworkPrefab(val2.enemyPrefab);
			Logger.LogInfo((object)"Enemy prefab registered.");
			Dictionary<LevelTypes, int> dictionary = new Dictionary<LevelTypes, int> { 
			{
				(LevelTypes)(-1),
				0
			} };
			Enemies.RegisterEnemy(val2, 60, (LevelTypes)(-1), (SpawnType)2, (TerminalNode)null, (TerminalKeyword)null);
			Logger.LogInfo((object)"Retriever Enemy successfully registered!");
			Item val3 = ModAssets.LoadAsset<Item>("RetrieverItem");
			if ((Object)(object)val3 != (Object)null && (Object)(object)val3.spawnPrefab != (Object)null)
			{
				NetworkPrefabs.RegisterNetworkPrefab(val3.spawnPrefab);
				TerminalNode val4 = ModAssets.LoadAsset<TerminalNode>("BuyRetriever");
				if ((Object)(object)val4 != (Object)null)
				{
					Items.RegisterShopItem(val3, (TerminalNode)null, (TerminalNode)null, val4, BoundConfig.ShopPrice.Value);
					Logger.LogInfo((object)"Shop item registered.");
				}
			}
		}

		private void LoadAssetBundle()
		{
			try
			{
				string path = "modassets";
				string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), path);
				if (!File.Exists(text))
				{
					Logger.LogError((object)("Bundle not found: " + text));
					return;
				}
				ModAssets = AssetBundle.LoadFromFile(text);
				Logger.LogInfo((object)"AssetBundle loaded.");
			}
			catch (Exception ex)
			{
				Logger.LogError((object)ex.ToString());
			}
		}

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

		public const string PLUGIN_NAME = "RetrieverUnit";

		public const string PLUGIN_VERSION = "1.0.0";
	}
	internal class RetrieverUnitAI : EnemyAI
	{
		private enum State
		{
			Init,
			GoingToEntrance,
			GoingToItem,
			GoingToExit,
			GoingToShip,
			Dropping,
			PlacingLockpicker,
			GoingToLockedDoor,
			Parked
		}

		[CompilerGenerated]
		private sealed class <DropRoutine>d__71 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public RetrieverUnitAI <>4__this;

			private NavMeshHit <hit>5__1;

			private NetworkObject <netObj>5__2;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <DropRoutine>d__71(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<netObj>5__2 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0063: Unknown result type (might be due to invalid IL or missing references)
				//IL_006d: Expected O, but got Unknown
				//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f5: Expected O, but got Unknown
				//IL_013a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0168: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>4__this.isDropping = true;
					((EnemyAI)<>4__this).SwitchToBehaviourClientRpc(5);
					((EnemyAI)<>4__this).agent.speed = 0f;
					<>2__current = (object)new WaitForSeconds(0.8f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					if ((Object)(object)<>4__this.carriedItem != (Object)null)
					{
						<netObj>5__2 = ((Component)<>4__this.carriedItem).GetComponent<NetworkObject>();
						if ((Object)(object)<netObj>5__2 != (Object)null)
						{
							<>4__this.DropItemClientRpc(<netObj>5__2.NetworkObjectId, dropOnShip: true);
						}
						<>4__this.carriedItem = null;
						<netObj>5__2 = null;
					}
					<>2__current = (object)new WaitForSeconds(0.5f);
					<>1__state = 2;
					return true;
				case 2:
					<>1__state = -1;
					<>4__this.isDropping = false;
					<>4__this.carriedItemIsKey = false;
					if (!((EnemyAI)<>4__this).agent.isOnNavMesh && NavMesh.SamplePosition(((Component)<>4__this).transform.position, ref <hit>5__1, 5f, -1))
					{
						((EnemyAI)<>4__this).agent.Warp(((NavMeshHit)(ref <hit>5__1)).position);
					}
					<>4__this.FilterReachableEntrances();
					<>4__this.BeginGoToEntrance(<>4__this.chosenEntrance);
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <ExplodeSequence>d__65 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public RetrieverUnitAI <>4__this;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <ExplodeSequence>d__65(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0100: Unknown result type (might be due to invalid IL or missing references)
				//IL_010a: Expected O, but got Unknown
				//IL_0137: Unknown result type (might be due to invalid IL or missing references)
				//IL_0141: Expected O, but got Unknown
				//IL_016d: 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_00d3: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					if (((EnemyAI)<>4__this).isEnemyDead || <>4__this.isExploding)
					{
						return false;
					}
					<>4__this.isExploding = true;
					<>4__this.Log("SELF-DESTRUCTING.");
					((EnemyAI)<>4__this).agent.speed = 0f;
					((EnemyAI)<>4__this).agent.isStopped = true;
					<>4__this.DropItemLocal();
					<>4__this.PlaySound(<>4__this.errorSFX);
					<>2__current = (object)new WaitForSeconds(0.3f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<>4__this.PlaySound(<>4__this.errorSFX);
					<>2__current = (object)new WaitForSeconds(0.3f);
					<>1__state = 2;
					return true;
				case 2:
					<>1__state = -1;
					<>4__this.PlaySound(<>4__this.errorSFX);
					<>2__current = (object)new WaitForSeconds(0.5f);
					<>1__state = 3;
					return true;
				case 3:
					<>1__state = -1;
					if (((EnemyAI)<>4__this).isEnemyDead)
					{
						return false;
					}
					Landmine.SpawnExplosion(((Component)<>4__this).transform.position, true, 4f, 6f, 50, 80f, (GameObject)null, false);
					((EnemyAI)<>4__this).KillEnemyOnOwnerClient(false);
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <InitRoutine>d__49 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public RetrieverUnitAI <>4__this;

			private float <waited>5__1;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <InitRoutine>d__49(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0133: Unknown result type (might be due to invalid IL or missing references)
				//IL_013d: Expected O, but got Unknown
				//IL_005c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0066: Expected O, but got Unknown
				//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f8: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>4__this.Log("Waiting for NavMesh...");
					<waited>5__1 = 0f;
					goto IL_0089;
				case 1:
					<>1__state = -1;
					<waited>5__1 += 0.2f;
					goto IL_0089;
				case 2:
					<>1__state = -1;
					goto IL_0109;
				case 3:
					{
						<>1__state = -1;
						<>4__this.CacheAllEntrances();
						break;
					}
					IL_0089:
					if (!((EnemyAI)<>4__this).agent.isOnNavMesh && <waited>5__1 < 10f)
					{
						<>2__current = (object)new WaitForSeconds(0.2f);
						<>1__state = 1;
						return true;
					}
					if (!((EnemyAI)<>4__this).agent.isOnNavMesh)
					{
						((EnemyAI)<>4__this).agent.Warp(((Component)<>4__this).transform.position);
						<>2__current = (object)new WaitForSeconds(1f);
						<>1__state = 2;
						return true;
					}
					goto IL_0109;
					IL_0109:
					<>4__this.CacheAllEntrances();
					if (<>4__this.allOutsideEntrances.Count == 0)
					{
						<>2__current = (object)new WaitForSeconds(3f);
						<>1__state = 3;
						return true;
					}
					break;
				}
				<>4__this.FilterReachableEntrances();
				<>4__this.Log($"Reachable: {<>4__this.reachableOutsideEntrances.Count} outside, {<>4__this.reachableInsideExits.Count} inside.");
				if (<>4__this.reachableOutsideEntrances.Count > 0)
				{
					<>4__this.BeginGoToEntrance();
				}
				else
				{
					<>4__this.Log("No reachable entrances. Self-destructing.");
					((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.ExplodeSequence());
				}
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <PickupRoutine>d__68 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public RetrieverUnitAI <>4__this;

			private GrabbableObject <itemRef>5__1;

			private NetworkObject <netObj>5__2;

			private bool <isKeyItem>5__3;

			private DoorLock <door>5__4;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <PickupRoutine>d__68(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<itemRef>5__1 = null;
				<netObj>5__2 = null;
				<door>5__4 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0056: Unknown result type (might be due to invalid IL or missing references)
				//IL_0060: Expected O, but got Unknown
				//IL_0237: 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_01ac: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>4__this.isPickingUp = true;
					((EnemyAI)<>4__this).agent.speed = 0f;
					<>2__current = (object)new WaitForSeconds(0.4f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					if ((Object)(object)<>4__this.targetItem == (Object)null || <>4__this.targetItem.isHeld || <>4__this.targetItem.isPocketed)
					{
						<>4__this.Log("Item gone during pickup.");
						<>4__this.isPickingUp = false;
						<>4__this.targetItem = null;
						<>4__this.FindAndTargetItem();
						return false;
					}
					<itemRef>5__1 = <>4__this.targetItem;
					<>4__this.targetItem = null;
					<>4__this.isPickingUp = false;
					<netObj>5__2 = ((Component)<itemRef>5__1).GetComponent<NetworkObject>();
					if ((Object)(object)<netObj>5__2 == (Object)null)
					{
						<>4__this.FindAndTargetItem();
						return false;
					}
					<isKeyItem>5__3 = <>4__this.IsKey(<itemRef>5__1);
					<>4__this.Log($"Picked up: {<itemRef>5__1.itemProperties.itemName} IsKey={<isKeyItem>5__3}");
					<>4__this.PickupItemClientRpc(<netObj>5__2.NetworkObjectId);
					<>2__current = (object)new WaitForSeconds(0.2f);
					<>1__state = 2;
					return true;
				case 2:
					<>1__state = -1;
					<>4__this.emptySearchCount = 0;
					<>4__this.carriedItemIsKey = <isKeyItem>5__3;
					if (<isKeyItem>5__3)
					{
						<door>5__4 = <>4__this.FindNearestLockedDoor();
						if ((Object)(object)<door>5__4 != (Object)null)
						{
							<>4__this.Log("Key picked up! Going to locked door.");
							((EnemyAI)<>4__this).SwitchToBehaviourClientRpc(7);
							((EnemyAI)<>4__this).SetDestinationToPosition(((Component)<door>5__4).transform.position, false);
							return false;
						}
						<>4__this.Log("Key picked up but no locked doors. Going to exit.");
						<door>5__4 = null;
					}
					<>4__this.GoToExit();
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <PlaceLockpickerRoutine>d__63 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public DoorLock door;

			public RetrieverUnitAI <>4__this;

			private GrabbableObject <lp>5__1;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <PlaceLockpickerRoutine>d__63(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<lp>5__1 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0056: Unknown result type (might be due to invalid IL or missing references)
				//IL_0060: Expected O, but got Unknown
				//IL_011a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0130: Unknown result type (might be due to invalid IL or missing references)
				//IL_0159: Unknown result type (might be due to invalid IL or missing references)
				//IL_0163: Expected O, but got Unknown
				//IL_020b: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>4__this.isPlacingLockpicker = true;
					((EnemyAI)<>4__this).agent.speed = 0f;
					<>2__current = (object)new WaitForSeconds(0.5f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					if ((Object)(object)door == (Object)null || !door.isLocked)
					{
						<>4__this.isPlacingLockpicker = false;
						<>4__this.GoToExit();
						return false;
					}
					<lp>5__1 = <>4__this.FindLockpickerItem();
					if ((Object)(object)<lp>5__1 != (Object)null)
					{
						<>4__this.Log("Placing lockpicker on door.");
						((Component)<lp>5__1).transform.SetParent(((Component)door).transform);
						((Component)<lp>5__1).transform.localPosition = new Vector3(0f, 0f, -0.1f);
						((Component)<lp>5__1).transform.localRotation = Quaternion.identity;
						<lp>5__1.isHeld = false;
						<lp>5__1.isPocketed = false;
						<>2__current = (object)new WaitForSeconds(5f);
						<>1__state = 2;
						return true;
					}
					<>4__this.Log("No lockpicker available, stuck timer will switch target.");
					break;
				case 2:
					<>1__state = -1;
					if ((Object)(object)door != (Object)null && door.isLocked)
					{
						door.UnlockDoorSyncWithServer();
					}
					if ((Object)(object)<lp>5__1 != (Object)null)
					{
						((Component)<lp>5__1).transform.SetParent((Transform)(((Object)(object)<>4__this.itemHoldPoint != (Object)null) ? ((object)<>4__this.itemHoldPoint) : ((object)((Component)<>4__this).transform)));
						((Component)<lp>5__1).transform.localPosition = new Vector3(0.2f, 0f, 0f);
						<lp>5__1.isHeld = true;
						<lp>5__1.isPocketed = true;
						<>4__this.heldLockpicker = <lp>5__1;
						<>4__this.Log("Lockpicker recovered.");
					}
					break;
				}
				<>4__this.isPlacingLockpicker = false;
				((EnemyAI)<>4__this).SwitchToBehaviourClientRpc(2);
				<>4__this.FindAndTargetItem();
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <TeleportInside>d__66 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public RetrieverUnitAI <>4__this;

			private Transform <dest>5__1;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <TeleportInside>d__66(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<dest>5__1 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_013d: Unknown result type (might be due to invalid IL or missing references)
				//IL_016b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0177: Unknown result type (might be due to invalid IL or missing references)
				//IL_0181: Expected O, but got Unknown
				//IL_0100: Unknown result type (might be due to invalid IL or missing references)
				//IL_010a: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>4__this.isTeleporting = true;
					((EnemyAI)<>4__this).agent.speed = 0f;
					<>4__this.usedOutsideEntrance = <>4__this.chosenEntrance;
					<dest>5__1 = <>4__this.chosenEntrance?.exitPoint;
					if ((Object)(object)<dest>5__1 == (Object)null && <>4__this.allInsideExits.Count > 0)
					{
						<dest>5__1 = ((Component)<>4__this.allInsideExits[0]).transform;
					}
					if ((Object)(object)<dest>5__1 == (Object)null)
					{
						<>4__this.Log("No inside point!");
						<>4__this.isTeleporting = false;
						return false;
					}
					<>2__current = (object)new WaitForSeconds(0.3f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					((Behaviour)((EnemyAI)<>4__this).agent).enabled = false;
					((Component)<>4__this).transform.position = <dest>5__1.position;
					((Behaviour)((EnemyAI)<>4__this).agent).enabled = true;
					((EnemyAI)<>4__this).agent.Warp(<dest>5__1.position);
					<>2__current = (object)new WaitForEndOfFrame();
					<>1__state = 2;
					return true;
				case 2:
					<>1__state = -1;
					<>4__this.usedInsideExit = ((Component)<dest>5__1).GetComponent<EntranceTeleport>() ?? ((Component)<dest>5__1).GetComponentInParent<EntranceTeleport>();
					<>4__this.chosenInsideExit = <>4__this.usedInsideExit ?? <>4__this.PickRandomInsideExit();
					<>4__this.FilterReachableInsideExits();
					<>4__this.isPickingUp = false;
					<>4__this.isDropping = false;
					<>4__this.targetItem = null;
					<>4__this.stuckOnItemTimer = 0f;
					<>4__this.isTeleporting = false;
					((EnemyAI)<>4__this).SwitchToBehaviourClientRpc(2);
					<>4__this.FindAndTargetItem();
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <TeleportOutside>d__67 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public EntranceTeleport insideExit;

			public RetrieverUnitAI <>4__this;

			private Transform <dest>5__1;

			private NavMeshHit <hit>5__2;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <TeleportOutside>d__67(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<dest>5__1 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_015e: Unknown result type (might be due to invalid IL or missing references)
				//IL_018c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0198: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a2: Expected O, but got Unknown
				//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
				//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
				//IL_0241: Unknown result type (might be due to invalid IL or missing references)
				//IL_021e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0223: Unknown result type (might be due to invalid IL or missing references)
				//IL_0121: Unknown result type (might be due to invalid IL or missing references)
				//IL_012b: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>4__this.isTeleporting = true;
					((EnemyAI)<>4__this).agent.speed = 0f;
					<dest>5__1 = insideExit?.exitPoint;
					if ((Object)(object)<dest>5__1 == (Object)null && (Object)(object)<>4__this.usedOutsideEntrance != (Object)null)
					{
						<dest>5__1 = ((Component)<>4__this.usedOutsideEntrance).transform;
					}
					if ((Object)(object)<dest>5__1 == (Object)null && <>4__this.allOutsideEntrances.Count > 0)
					{
						<dest>5__1 = ((Component)<>4__this.allOutsideEntrances[0]).transform;
					}
					if ((Object)(object)<dest>5__1 == (Object)null)
					{
						<>4__this.Log("No outside point!");
						<>4__this.isTeleporting = false;
						return false;
					}
					<>2__current = (object)new WaitForSeconds(0.3f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					((Behaviour)((EnemyAI)<>4__this).agent).enabled = false;
					((Component)<>4__this).transform.position = <dest>5__1.position;
					((Behaviour)((EnemyAI)<>4__this).agent).enabled = true;
					((EnemyAI)<>4__this).agent.Warp(<dest>5__1.position);
					<>2__current = (object)new WaitForEndOfFrame();
					<>1__state = 2;
					return true;
				case 2:
					<>1__state = -1;
					<>4__this.usedOutsideEntrance = null;
					<>4__this.usedInsideExit = null;
					<>4__this.isTeleporting = false;
					<>4__this.cachedShipPos = StartOfRound.Instance.elevatorTransform.position;
					if (NavMesh.SamplePosition(<>4__this.cachedShipPos, ref <hit>5__2, 10f, -1))
					{
						<>4__this.cachedShipPos = ((NavMeshHit)(ref <hit>5__2)).position;
					}
					((EnemyAI)<>4__this).SwitchToBehaviourClientRpc(4);
					((EnemyAI)<>4__this).SetDestinationToPosition(<>4__this.cachedShipPos, false);
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <UnlockDoorWithKeyRoutine>d__60 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public DoorLock door;

			public RetrieverUnitAI <>4__this;

			private NetworkObject <netObj>5__1;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <UnlockDoorWithKeyRoutine>d__60(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<netObj>5__1 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_003c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0046: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					((EnemyAI)<>4__this).agent.speed = 0f;
					<>2__current = (object)new WaitForSeconds(0.5f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					if ((Object)(object)door != (Object)null && door.isLocked)
					{
						<>4__this.Log("Unlocking door with key.");
						door.UnlockDoorSyncWithServer();
						if ((Object)(object)<>4__this.carriedItem != (Object)null)
						{
							((Component)<>4__this.carriedItem).transform.SetParent((Transform)null);
							<>4__this.carriedItem.isHeld = false;
							<>4__this.carriedItem.isPocketed = false;
							if (((Component)<>4__this.carriedItem).TryGetComponent<NetworkObject>(ref <netObj>5__1))
							{
								<netObj>5__1.Despawn(true);
							}
							<>4__this.carriedItem = null;
							<>4__this.carriedItemIsKey = false;
							<netObj>5__1 = null;
						}
					}
					<>4__this.Log("Door unlocked. Searching next item.");
					<>4__this.FindAndTargetItem();
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		public Transform itemHoldPoint = null;

		public AudioSource droneAmbientAudio = null;

		public AudioClip idleHumSFX = null;

		public AudioClip activateSFX = null;

		public AudioClip pickupSFX = null;

		public AudioClip dropSFX = null;

		public AudioClip errorSFX = null;

		public Light droneLight = null;

		[Header("Retriever Settings")]
		public float activeSpeed = 10f;

		public float itemStuckTime = 8f;

		public float maxItemHeightDiff = 6f;

		public float lockpickerPlaceRadius = 12f;

		private bool isTeleporting;

		private bool isPickingUp;

		private bool isDropping;

		private bool isParked;

		private bool isPlacingLockpicker;

		private bool isExploding;

		private bool lockRotation;

		private GrabbableObject carriedItem = null;

		private GrabbableObject targetItem = null;

		private GrabbableObject heldLockpicker = null;

		private bool carriedItemIsKey;

		private EntranceTeleport usedOutsideEntrance = null;

		private EntranceTeleport usedInsideExit = null;

		private List<EntranceTeleport> reachableOutsideEntrances = new List<EntranceTeleport>();

		private List<EntranceTeleport> reachableInsideExits = new List<EntranceTeleport>();

		private List<EntranceTeleport> allOutsideEntrances = new List<EntranceTeleport>();

		private List<EntranceTeleport> allInsideExits = new List<EntranceTeleport>();

		private EntranceTeleport chosenEntrance = null;

		private EntranceTeleport chosenInsideExit = null;

		private Vector3 cachedShipPos;

		private Vector3 smoothedForward;

		private float stuckOnItemTimer;

		private Vector3 lastPosCheck;

		private float lastPosCheckTime;

		private int emptySearchCount = 0;

		private const int MAX_EMPTY_SEARCHES = 2;

		private string droneName = "Retriever";

		private Random droneRandom = null;

		private void Log(string msg)
		{
			Plugin.Logger.LogInfo((object)("[Retriever:" + droneName + "] " + msg));
		}

		public override void Start()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Start();
			base.agent.updateRotation = false;
			base.agent.updatePosition = true;
			smoothedForward = ((Component)this).transform.forward;
			droneRandom = new Random(StartOfRound.Instance.randomMapSeed + base.thisEnemyIndex);
			droneName = GenerateDroneName();
			activeSpeed = Plugin.BoundConfig.MoveSpeed.Value;
			base.agent.speed = activeSpeed;
			base.agent.angularSpeed = activeSpeed * 30f;
			base.agent.acceleration = activeSpeed * 8f;
			if ((Object)(object)droneAmbientAudio != (Object)null && (Object)(object)idleHumSFX != (Object)null)
			{
				droneAmbientAudio.clip = idleHumSFX;
				droneAmbientAudio.loop = true;
				droneAmbientAudio.volume = 0.4f;
				droneAmbientAudio.spatialBlend = 1f;
				droneAmbientAudio.Play();
			}
			PlaySound(activateSFX);
			SetupScanNode();
			RegisterAsRadarTarget();
			((EnemyAI)this).SwitchToBehaviourClientRpc(0);
			((MonoBehaviour)this).StartCoroutine(InitRoutine());
		}

		private string GenerateDroneName()
		{
			string[] array = new string[5] { "UNIT", "BOT", "DRONE", "RET", "MK" };
			string[] array2 = new string[10] { "Alpha", "Beta", "Gamma", "Delta", "Echo", "Foxtrot", "Sigma", "Omega", "Prime", "Zero" };
			return array[droneRandom.Next(0, array.Length)] + $"-{droneRandom.Next(1, 99):D2}" + "-" + array2[droneRandom.Next(0, array2.Length)];
		}

		public override void Update()
		{
			//IL_0042: 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)
			((EnemyAI)this).Update();
			AlignToSurface();
			if ((Object)(object)carriedItem != (Object)null && (Object)(object)itemHoldPoint != (Object)null)
			{
				((Component)carriedItem).transform.position = itemHoldPoint.position;
				((Component)carriedItem).transform.rotation = itemHoldPoint.rotation;
			}
		}

		private void AlignToSurface()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: 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_0070: 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_0075: 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_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: 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_00c6: 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_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: 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_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: 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_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: 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_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			Vector3 velocity = base.agent.velocity;
			velocity.y = 0f;
			if (((Vector3)(ref velocity)).sqrMagnitude > 0.1f)
			{
				smoothedForward = Vector3.Lerp(smoothedForward, ((Vector3)(ref velocity)).normalized, Time.deltaTime * 8f);
			}
			Vector3 val = ((((Vector3)(ref smoothedForward)).sqrMagnitude > 0.01f) ? smoothedForward : ((Component)this).transform.forward);
			RaycastHit val2 = default(RaycastHit);
			if (!Physics.Raycast(((Component)this).transform.position + Vector3.up * 0.3f, Vector3.down, ref val2, 1.5f, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1))
			{
				Quaternion val3 = Quaternion.LookRotation(val, Vector3.up);
				((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, val3, Time.deltaTime * 5f);
				return;
			}
			Vector3 normal = ((RaycastHit)(ref val2)).normal;
			if (!(Vector3.Dot(normal, Vector3.up) < 0.3f))
			{
				Vector3 val4 = Vector3.ProjectOnPlane(val, normal);
				if (((Vector3)(ref val4)).sqrMagnitude < 0.01f)
				{
					val4 = Vector3.ProjectOnPlane(Vector3.forward, normal);
				}
				((Vector3)(ref val4)).Normalize();
				Quaternion val5 = Quaternion.LookRotation(val4, normal);
				float num = Quaternion.Angle(((Component)this).transform.rotation, val5);
				float num2 = Mathf.Lerp(5f, 15f, num / 45f);
				((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, val5, Time.deltaTime * num2);
			}
		}

		private void RegisterAsRadarTarget()
		{
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			ManualCameraRenderer val = StartOfRound.Instance?.mapScreen;
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			try
			{
				List<TransformAndName> radarTargets = val.radarTargets;
				Type type = ((object)radarTargets[0]).GetType();
				object obj = Activator.CreateInstance(type, ((Component)this).transform, droneName, false);
				radarTargets.Add((TransformAndName)obj);
			}
			catch (Exception ex)
			{
				Log("Radar register failed: " + ex.Message);
			}
		}

		private void UnregisterRadarTarget()
		{
			ManualCameraRenderer val = StartOfRound.Instance?.mapScreen;
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			for (int num = val.radarTargets.Count - 1; num >= 0; num--)
			{
				if ((Object)(object)val.radarTargets[num]?.transform == (Object)(object)((Component)this).transform)
				{
					val.radarTargets.RemoveAt(num);
					break;
				}
			}
		}

		private void SetupScanNode()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			//IL_0048: 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)
			ScanNodeProperties componentInChildren = ((Component)this).GetComponentInChildren<ScanNodeProperties>();
			if ((Object)(object)componentInChildren != (Object)null)
			{
				componentInChildren.headerText = droneName;
				return;
			}
			GameObject val = new GameObject("ScanNode");
			val.transform.SetParent(((Component)this).transform);
			val.transform.localPosition = Vector3.up * 0.5f;
			val.layer = LayerMask.NameToLayer("ScanNode");
			componentInChildren = val.AddComponent<ScanNodeProperties>();
			componentInChildren.maxRange = 40;
			componentInChildren.minRange = 0;
			componentInChildren.requiresLineOfSight = false;
			componentInChildren.nodeType = 1;
			componentInChildren.headerText = droneName;
			componentInChildren.subText = "Retriever Unit";
			SphereCollider val2 = val.AddComponent<SphereCollider>();
			val2.radius = 0.5f;
			((Collider)val2).isTrigger = true;
		}

		[IteratorStateMachine(typeof(<InitRoutine>d__49))]
		private IEnumerator InitRoutine()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <InitRoutine>d__49(0)
			{
				<>4__this = this
			};
		}

		private void CacheAllEntrances()
		{
			allOutsideEntrances.Clear();
			allInsideExits.Clear();
			EntranceTeleport[] array = Object.FindObjectsOfType<EntranceTeleport>();
			foreach (EntranceTeleport val in array)
			{
				if (val.isEntranceToBuilding)
				{
					allOutsideEntrances.Add(val);
				}
				else
				{
					allInsideExits.Add(val);
				}
			}
		}

		private void FilterReachableEntrances()
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			reachableOutsideEntrances.Clear();
			foreach (EntranceTeleport allOutsideEntrance in allOutsideEntrances)
			{
				if ((Object)(object)allOutsideEntrance != (Object)null && IsPositionReachable(((Component)allOutsideEntrance).transform.position))
				{
					reachableOutsideEntrances.Add(allOutsideEntrance);
				}
			}
			reachableInsideExits.Clear();
			reachableInsideExits.AddRange(allInsideExits);
		}

		private void FilterReachableInsideExits()
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			reachableInsideExits.Clear();
			foreach (EntranceTeleport allInsideExit in allInsideExits)
			{
				if ((Object)(object)allInsideExit != (Object)null && IsPositionReachable(((Component)allInsideExit).transform.position))
				{
					reachableInsideExits.Add(allInsideExit);
				}
			}
			if (reachableInsideExits.Count == 0)
			{
				reachableInsideExits.AddRange(allInsideExits);
			}
		}

		private bool IsPositionReachable(Vector3 pos)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//IL_0028: 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_003b: Invalid comparison between Unknown and I4
			NavMeshHit val = default(NavMeshHit);
			if (!NavMesh.SamplePosition(pos, ref val, 3f, -1))
			{
				return false;
			}
			NavMeshPath val2 = new NavMeshPath();
			base.agent.CalculatePath(((NavMeshHit)(ref val)).position, val2);
			return (int)val2.status == 0;
		}

		private EntranceTeleport PickRandomReachableEntrance(EntranceTeleport exclude = null)
		{
			if (reachableOutsideEntrances.Count == 0)
			{
				return null;
			}
			List<EntranceTeleport> list = new List<EntranceTeleport>();
			foreach (EntranceTeleport reachableOutsideEntrance in reachableOutsideEntrances)
			{
				if ((Object)(object)reachableOutsideEntrance != (Object)(object)exclude)
				{
					list.Add(reachableOutsideEntrance);
				}
			}
			if (list.Count == 0)
			{
				list = reachableOutsideEntrances;
			}
			return list[droneRandom.Next(0, list.Count)];
		}

		private EntranceTeleport PickRandomInsideExit()
		{
			return (reachableInsideExits.Count == 0) ? null : reachableInsideExits[droneRandom.Next(0, reachableInsideExits.Count)];
		}

		public override void DoAIInterval()
		{
			//IL_03d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0377: Unknown result type (might be due to invalid IL or missing references)
			//IL_0389: Unknown result type (might be due to invalid IL or missing references)
			//IL_0395: Unknown result type (might be due to invalid IL or missing references)
			base.moveTowardsDestination = true;
			base.movingTowardsTargetPlayer = false;
			((EnemyAI)this).DoAIInterval();
			if (base.isEnemyDead || isTeleporting || isParked || isExploding)
			{
				return;
			}
			switch ((State)base.currentBehaviourStateIndex)
			{
			case State.Init:
				break;
			case State.GoingToEntrance:
				base.agent.speed = activeSpeed;
				if ((Object)(object)chosenEntrance == (Object)null)
				{
					chosenEntrance = PickRandomReachableEntrance();
					if ((Object)(object)chosenEntrance == (Object)null)
					{
						break;
					}
				}
				((EnemyAI)this).SetDestinationToPosition(((Component)chosenEntrance).transform.position, false);
				if (XZDist(((Component)this).transform.position, ((Component)chosenEntrance).transform.position) < 2f)
				{
					((MonoBehaviour)this).StartCoroutine(TeleportInside());
				}
				break;
			case State.GoingToItem:
				base.agent.speed = activeSpeed;
				if ((Object)(object)targetItem == (Object)null || targetItem.isHeld || targetItem.isPocketed)
				{
					FindAndTargetItem();
					break;
				}
				((EnemyAI)this).SetDestinationToPosition(((Component)targetItem).transform.position, false);
				CheckStuckOnItem();
				if (XZDist(((Component)this).transform.position, ((Component)targetItem).transform.position) < 2.5f && !isPickingUp)
				{
					stuckOnItemTimer = 0f;
					((MonoBehaviour)this).StartCoroutine(PickupRoutine());
				}
				break;
			case State.GoingToLockedDoor:
			{
				base.agent.speed = activeSpeed;
				DoorLock val3 = FindNearestLockedDoor();
				if ((Object)(object)val3 == (Object)null)
				{
					Log("No locked doors, going to exit.");
					GoToExit();
					break;
				}
				((EnemyAI)this).SetDestinationToPosition(((Component)val3).transform.position, false);
				if (XZDist(((Component)this).transform.position, ((Component)val3).transform.position) < 2f)
				{
					Log("At locked door with key. Unlocking.");
					((MonoBehaviour)this).StartCoroutine(UnlockDoorWithKeyRoutine(val3));
				}
				break;
			}
			case State.PlacingLockpicker:
			{
				base.agent.speed = activeSpeed;
				DoorLock val = FindNearestLockedDoor();
				if ((Object)(object)val == (Object)null)
				{
					GoToExit();
					break;
				}
				((EnemyAI)this).SetDestinationToPosition(((Component)val).transform.position, false);
				if (XZDist(((Component)this).transform.position, ((Component)val).transform.position) < 2f && !isPlacingLockpicker)
				{
					((MonoBehaviour)this).StartCoroutine(PlaceLockpickerRoutine(val));
				}
				break;
			}
			case State.GoingToExit:
			{
				base.agent.speed = activeSpeed;
				EntranceTeleport val2 = usedInsideExit ?? chosenInsideExit;
				if ((Object)(object)val2 == (Object)null)
				{
					val2 = (chosenInsideExit = PickRandomInsideExit());
				}
				if (!((Object)(object)val2 == (Object)null))
				{
					((EnemyAI)this).SetDestinationToPosition(((Component)val2).transform.position, false);
					if (XZDist(((Component)this).transform.position, ((Component)val2).transform.position) < 2f)
					{
						((MonoBehaviour)this).StartCoroutine(TeleportOutside(val2));
					}
				}
				break;
			}
			case State.GoingToShip:
				base.agent.speed = activeSpeed;
				((EnemyAI)this).SetDestinationToPosition(cachedShipPos, false);
				if (XZDist(((Component)this).transform.position, cachedShipPos) < 4f && !isDropping)
				{
					((MonoBehaviour)this).StartCoroutine(DropRoutine());
				}
				break;
			case State.Dropping:
			case State.Parked:
				base.agent.speed = 0f;
				break;
			}
		}

		private void FindAndTargetItem()
		{
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: 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_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: 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_00c0: 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_00c7: 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_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Expected O, but got Unknown
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Invalid comparison between Unknown and I4
			if ((Object)(object)carriedItem != (Object)null)
			{
				Log("Already carrying, going to exit.");
				GoToExit();
				return;
			}
			List<GrabbableObject> list = new List<GrabbableObject>();
			GrabbableObject[] array = Object.FindObjectsOfType<GrabbableObject>();
			NavMeshHit val3 = default(NavMeshHit);
			foreach (GrabbableObject val in array)
			{
				if ((Object)(object)val == (Object)null || val.isHeld || val.isInShipRoom || val.isPocketed || (Object)(object)((Component)val).gameObject == (Object)(object)((Component)this).gameObject || (Object)(object)val == (Object)(object)targetItem || !val.isInFactory)
				{
					continue;
				}
				Vector3 position = ((Component)val).transform.position;
				Vector3 val2 = position;
				if (NavMesh.SamplePosition(position, ref val3, 4f, -1))
				{
					val2 = ((NavMeshHit)(ref val3)).position;
				}
				float num = Mathf.Abs(position.y - val2.y);
				if (!(num > maxItemHeightDiff))
				{
					NavMeshPath val4 = new NavMeshPath();
					base.agent.CalculatePath(val2, val4);
					if ((int)val4.status <= 0)
					{
						list.Add(val);
					}
				}
			}
			if (list.Count > 0)
			{
				emptySearchCount = 0;
				GrabbableObject val5 = list[droneRandom.Next(0, list.Count)];
				Log($"Target: {val5.itemProperties.itemName} ({list.Count} candidates)");
				targetItem = val5;
				stuckOnItemTimer = 0f;
				lastPosCheck = ((Component)this).transform.position;
				lastPosCheckTime = Time.time;
				((EnemyAI)this).SwitchToBehaviourClientRpc(2);
				Vector3 position2 = ((Component)targetItem).transform.position;
				NavMeshHit val6 = default(NavMeshHit);
				if (NavMesh.SamplePosition(position2, ref val6, 4f, -1))
				{
					position2 = ((NavMeshHit)(ref val6)).position;
				}
				((EnemyAI)this).SetDestinationToPosition(position2, false);
			}
			else
			{
				emptySearchCount++;
				Log($"No items inside. Empty count: {emptySearchCount}/{2}");
				targetItem = null;
				if (emptySearchCount >= 2)
				{
					Log("Confirmed no items. EXPLODING.");
					((MonoBehaviour)this).StartCoroutine(ExplodeSequence());
				}
				else
				{
					Log("Going to exit to try another entrance.");
					GoToExit();
				}
			}
		}

		private bool IsKey(GrabbableObject item)
		{
			if ((Object)(object)item?.itemProperties == (Object)null)
			{
				return false;
			}
			return item.itemProperties.itemName.ToLower().Contains("key");
		}

		private DoorLock FindNearestLockedDoor()
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			//IL_007a: 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_008f: Invalid comparison between Unknown and I4
			DoorLock result = null;
			float num = float.MaxValue;
			DoorLock[] array = Object.FindObjectsOfType<DoorLock>();
			foreach (DoorLock val in array)
			{
				if ((Object)(object)val == (Object)null || !val.isLocked)
				{
					continue;
				}
				float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position);
				if (num2 < num)
				{
					NavMeshPath val2 = new NavMeshPath();
					base.agent.CalculatePath(((Component)val).transform.position, val2);
					if ((int)val2.status <= 0)
					{
						num = num2;
						result = val;
					}
				}
			}
			return result;
		}

		[IteratorStateMachine(typeof(<UnlockDoorWithKeyRoutine>d__60))]
		private IEnumerator UnlockDoorWithKeyRoutine(DoorLock door)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <UnlockDoorWithKeyRoutine>d__60(0)
			{
				<>4__this = this,
				door = door
			};
		}

		private DoorLock FindBlockingLockedDoor()
		{
			//IL_0043: 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_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Expected O, but got Unknown
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Invalid comparison between Unknown and I4
			DoorLock result = null;
			float num = lockpickerPlaceRadius;
			DoorLock[] array = Object.FindObjectsOfType<DoorLock>();
			foreach (DoorLock val in array)
			{
				if ((Object)(object)val == (Object)null || !val.isLocked)
				{
					continue;
				}
				float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position);
				if (num2 < num)
				{
					NavMeshPath val2 = new NavMeshPath();
					base.agent.CalculatePath(((Component)val).transform.position, val2);
					if ((int)val2.status <= 0)
					{
						num = num2;
						result = val;
					}
				}
			}
			return result;
		}

		private GrabbableObject FindLockpickerItem()
		{
			if ((Object)(object)heldLockpicker != (Object)null)
			{
				return heldLockpicker;
			}
			GrabbableObject[] array = Object.FindObjectsOfType<GrabbableObject>();
			foreach (GrabbableObject val in array)
			{
				if (!((Object)(object)val == (Object)null) && !val.isHeld && !((Object)(object)val.itemProperties == (Object)null) && val.itemProperties.itemName.ToLower().Contains("lockpicker"))
				{
					return val;
				}
			}
			return null;
		}

		[IteratorStateMachine(typeof(<PlaceLockpickerRoutine>d__63))]
		private IEnumerator PlaceLockpickerRoutine(DoorLock door)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <PlaceLockpickerRoutine>d__63(0)
			{
				<>4__this = this,
				door = door
			};
		}

		private void CheckStuckOnItem()
		{
			//IL_0023: 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_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_008c: 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)
			if (Time.time - lastPosCheckTime < 2f)
			{
				return;
			}
			float num = Vector3.Distance(((Component)this).transform.position, lastPosCheck);
			if (num < 0.5f)
			{
				stuckOnItemTimer += 2f;
				DoorLock val = FindBlockingLockedDoor();
				if ((Object)(object)val != (Object)null && stuckOnItemTimer >= 4f)
				{
					Log($"Locked door blocking path at dist={Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position):F1}m. Placing lockpicker.");
					stuckOnItemTimer = 0f;
					((EnemyAI)this).SwitchToBehaviourClientRpc(6);
					return;
				}
				if (stuckOnItemTimer >= itemStuckTime)
				{
					Log("Stuck too long, switching target.");
					stuckOnItemTimer = 0f;
					targetItem = null;
					FindAndTargetItem();
				}
			}
			else
			{
				stuckOnItemTimer = 0f;
			}
			lastPosCheck = ((Component)this).transform.position;
			lastPosCheckTime = Time.time;
		}

		[IteratorStateMachine(typeof(<ExplodeSequence>d__65))]
		private IEnumerator ExplodeSequence()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <ExplodeSequence>d__65(0)
			{
				<>4__this = this
			};
		}

		[IteratorStateMachine(typeof(<TeleportInside>d__66))]
		private IEnumerator TeleportInside()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <TeleportInside>d__66(0)
			{
				<>4__this = this
			};
		}

		[IteratorStateMachine(typeof(<TeleportOutside>d__67))]
		private IEnumerator TeleportOutside(EntranceTeleport insideExit)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <TeleportOutside>d__67(0)
			{
				<>4__this = this,
				insideExit = insideExit
			};
		}

		[IteratorStateMachine(typeof(<PickupRoutine>d__68))]
		private IEnumerator PickupRoutine()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <PickupRoutine>d__68(0)
			{
				<>4__this = this
			};
		}

		[ClientRpc]
		private void PickupItemClientRpc(ulong itemNetId)
		{
			//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_0071: 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_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: 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 val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(4159747592u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, itemNetId);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4159747592u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			if (NetworkManager.Singleton.SpawnManager.SpawnedObjects.TryGetValue(itemNetId, out var value))
			{
				GrabbableObject component = ((Component)value).GetComponent<GrabbableObject>();
				if (!((Object)(object)component == (Object)null) && !component.isHeld)
				{
					PlaySound(pickupSFX);
					((Component)component).transform.SetParent((Transform)(((Object)(object)itemHoldPoint != (Object)null) ? ((object)itemHoldPoint) : ((object)((Component)this).transform)));
					((Component)component).transform.localPosition = Vector3.zero;
					((Component)component).transform.localRotation = Quaternion.identity;
					component.isHeld = true;
					component.isPocketed = true;
					carriedItem = component;
				}
			}
		}

		private void GoToExit()
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			EntranceTeleport val = usedInsideExit ?? chosenInsideExit ?? PickRandomInsideExit();
			if ((Object)(object)val != (Object)null)
			{
				chosenInsideExit = val;
				((EnemyAI)this).SwitchToBehaviourClientRpc(3);
				((EnemyAI)this).SetDestinationToPosition(((Component)val).transform.position, false);
			}
			else
			{
				Log("No exit! Emergency drop.");
				DropItemLocal();
			}
		}

		[IteratorStateMachine(typeof(<DropRoutine>d__71))]
		private IEnumerator DropRoutine()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <DropRoutine>d__71(0)
			{
				<>4__this = this
			};
		}

		private void DropItemLocal()
		{
			if (!((Object)(object)carriedItem == (Object)null))
			{
				NetworkObject component = ((Component)carriedItem).GetComponent<NetworkObject>();
				if ((Object)(object)component != (Object)null)
				{
					DropItemClientRpc(component.NetworkObjectId, dropOnShip: false);
					carriedItem = null;
				}
			}
		}

		[ClientRpc]
		private void DropItemClientRpc(ulong itemNetId, bool dropOnShip)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: 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_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: 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 val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1733472747u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, itemNetId);
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref dropOnShip, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1733472747u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			if (!NetworkManager.Singleton.SpawnManager.SpawnedObjects.TryGetValue(itemNetId, out var value))
			{
				return;
			}
			GrabbableObject component = ((Component)value).GetComponent<GrabbableObject>();
			if ((Object)(object)component == (Object)null)
			{
				return;
			}
			PlaySound(dropSFX);
			((Component)component).transform.SetParent((Transform)null);
			Vector3 val3;
			if (dropOnShip)
			{
				Transform[] insideShipPositions = StartOfRound.Instance.insideShipPositions;
				if (insideShipPositions != null && insideShipPositions.Length != 0)
				{
					val3 = StartOfRound.Instance.insideShipPositions[droneRandom.Next(0, StartOfRound.Instance.insideShipPositions.Length)].position;
					goto IL_01b8;
				}
			}
			val3 = (((Object)(object)itemHoldPoint != (Object)null) ? itemHoldPoint.position : ((Component)this).transform.position);
			goto IL_01b8;
			IL_01b8:
			((Component)component).transform.position = val3;
			component.isHeld = false;
			component.isPocketed = false;
			component.startFallingPosition = val3;
			component.FallToGround(false, false, default(Vector3));
			carriedItem = null;
		}

		private void BeginGoToEntrance(EntranceTeleport excludeEntrance = null)
		{
			//IL_0014: 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_00b0: Unknown result type (might be due to invalid IL or missing references)
			NavMeshHit val = default(NavMeshHit);
			if (!base.agent.isOnNavMesh && NavMesh.SamplePosition(((Component)this).transform.position, ref val, 5f, -1))
			{
				base.agent.Warp(((NavMeshHit)(ref val)).position);
			}
			chosenEntrance = PickRandomReachableEntrance(excludeEntrance);
			chosenInsideExit = null;
			if ((Object)(object)chosenEntrance == (Object)null)
			{
				Log("No reachable entrances. Self-destructing.");
				((MonoBehaviour)this).StartCoroutine(ExplodeSequence());
			}
			else
			{
				Log("Going to entrance: " + ((Object)chosenEntrance).name);
				((EnemyAI)this).SwitchToBehaviourClientRpc(1);
				((EnemyAI)this).SetDestinationToPosition(((Component)chosenEntrance).transform.position, false);
			}
		}

		private static float XZDist(Vector3 a, Vector3 b)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = new Vector2(a.x - b.x, a.z - b.z);
			return ((Vector2)(ref val)).magnitude;
		}

		private void PlaySound(AudioClip clip)
		{
			if (!((Object)(object)clip == (Object)null) && !((Object)(object)base.creatureVoice == (Object)null))
			{
				base.creatureVoice.PlayOneShot(clip);
			}
		}

		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)
			{
				PlaySound(errorSFX);
				base.enemyHP -= force;
				if (((NetworkBehaviour)this).IsOwner && base.enemyHP <= 0 && !base.isEnemyDead)
				{
					((MonoBehaviour)this).StartCoroutine(ExplodeSequence());
				}
			}
		}

		public override void KillEnemy(bool destroy = false)
		{
			((EnemyAI)this).KillEnemy(destroy);
			DropItemLocal();
			UnregisterRadarTarget();
			if ((Object)(object)droneAmbientAudio != (Object)null)
			{
				droneAmbientAudio.Stop();
			}
		}

		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
			((NetworkBehaviour)this).__registerRpc(4159747592u, new RpcReceiveHandler(__rpc_handler_4159747592), "PickupItemClientRpc");
			((NetworkBehaviour)this).__registerRpc(1733472747u, new RpcReceiveHandler(__rpc_handler_1733472747), "DropItemClientRpc");
			((EnemyAI)this).__initializeRpcs();
		}

		private static void __rpc_handler_4159747592(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ulong itemNetId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref itemNetId);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((RetrieverUnitAI)(object)target).PickupItemClientRpc(itemNetId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1733472747(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ulong itemNetId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref itemNetId);
				bool dropOnShip = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref dropOnShip, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((RetrieverUnitAI)(object)target).DropItemClientRpc(itemNetId, dropOnShip);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "RetrieverUnitAI";
		}
	}
}
namespace RetrieverUnit.Configuration
{
	public class PluginConfig
	{
		public ConfigEntry<int> SpawnWeight;

		public ConfigEntry<int> ShopPrice;

		public ConfigEntry<float> MoveSpeed;

		public ConfigEntry<float> TurnSpeed;

		public PluginConfig(ConfigFile cfg)
		{
			ShopPrice = cfg.Bind<int>("Shop", "Price", 60, "Price of Retriever Unit in the shop");
			MoveSpeed = cfg.Bind<float>("Unit", "MoveSpeed", 10f, "Movement speed of the Retriever Unit");
		}
	}
}
namespace __GEN
{
	internal class NetworkVariableSerializationHelper
	{
		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeSerialization()
		{
		}
	}
}
namespace neoninc.RetrieverUnit.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}