Decompiled source of MysteriousHarbingers v0.5.1

HarbingerBehaviour.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Xml.Serialization;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarbingerBehaviour.AICode;
using HarbingerBehaviour.NetcodePatcher;
using HarmonyLib;
using LethalLib.Modules;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Events;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("22e8fa27-caf7-4b7e-8740-ef5c67f9766d")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyVersion("0.0.0.0")]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace HarbingerBehaviour
{
	[Serializable]
	public class Config : SyncedInstance<Config>
	{
		public readonly ConfigEntry<float> TeleportSpeed;

		public readonly ConfigEntry<float> TPSelfCooldown;

		public readonly ConfigEntry<float> TPOtherCooldown;

		public readonly ConfigEntry<int> MaxCount;

		public readonly ConfigEntry<string> HarbingerSpawnLocations;

		public readonly ConfigEntry<string> BlackList;

		public readonly ConfigEntry<string> WhiteList;

		public readonly ConfigEntry<bool> CanTPItems;

		public Config()
		{
			InitInstance(this);
		}

		public Config(ConfigFile cfg)
		{
			InitInstance(this);
			TeleportSpeed = cfg.Bind<float>("Teleport Enemies", "Teleportation speed multiplier", 1f, "How fast the telporation animation should play (default 1 -> 3.35 Sec)");
			TPOtherCooldown = cfg.Bind<float>("Teleport Enemies", "Teleport Enemies Cooldown", 10f, "How frequantly should the harbinger teleport enemies to players (default 15 sec). Minimum of 10 seconds");
			TPSelfCooldown = cfg.Bind<float>("Teleport Self", "Teleport Self Cooldown", 20f, "How frequantly should the harbinger teleport to players (default 20 sec). Minimum of 5 seconds");
			MaxCount = cfg.Bind<int>("Spawning", "Maximum Harbingers", 2, "What is the maximum number of harbingers that should be able to spawn (defaut 2)");
			HarbingerSpawnLocations = cfg.Bind<string>("Spawning", "Moon Spawn Weight", "Modded:35,ExperimentationLevel:10,AssuranceLevel:10,VowLevel:10,OffenseLevel:20,MarchLevel:20,RendLevel:40,DineLevel:40,TitanLevel:50,AdamanceLevel:20,EmbrionLevel:20,ArtificeLevel:50", "Rarety of Harbinger spawning on Each Moon (works will LLL as well).");
			BlackList = cfg.Bind<string>("Teleport Enemies", "Teleportation BlackList", "none", "Add the names of the entities that should not be teleported (This must be the internal name of the entities). Make sure to separate each name with a comma and a space (PjonkGoose, Harbinger)");
			WhiteList = cfg.Bind<string>("Teleport Enemies", "Teleportation WhiteList", "none", "An alternative to the blacklist. If this value is not default it will only teleport enemies that are part of the whitelist.");
			CanTPItems = cfg.Bind<bool>("Teleport Items", "Can Teleport Items", true, "This allows you to turn off the ability to teleport the apparatus.");
		}

		public static void RequestSync()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			if (!SyncedInstance<Config>.IsClient)
			{
				return;
			}
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(SyncedInstance<Config>.IntSize, (Allocator)2, -1);
			try
			{
				SyncedInstance<Config>.MessageManager.SendNamedMessage("ModName_OnRequestConfigSync", 0uL, val, (NetworkDelivery)3);
			}
			finally
			{
				((IDisposable)(FastBufferWriter)(ref val)).Dispose();
			}
		}

		public static void OnRequestSync(ulong clientId, FastBufferReader _)
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			if (!SyncedInstance<Config>.IsHost)
			{
				return;
			}
			HarbingerLoader.mls.LogInfo((object)$"Config sync request received from client: {clientId}");
			byte[] array = SyncedInstance<Config>.SerializeToBytes(SyncedInstance<Config>.Instance);
			int num = array.Length;
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(num + SyncedInstance<Config>.IntSize, (Allocator)2, -1);
			try
			{
				((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref num, default(ForPrimitives));
				((FastBufferWriter)(ref val)).WriteBytesSafe(array, -1, 0);
				SyncedInstance<Config>.MessageManager.SendNamedMessage("ModName_OnReceiveConfigSync", clientId, val, (NetworkDelivery)3);
			}
			catch (Exception arg)
			{
				HarbingerLoader.mls.LogInfo((object)$"Error occurred syncing config with client: {clientId}\n{arg}");
			}
			finally
			{
				((IDisposable)(FastBufferWriter)(ref val)).Dispose();
			}
		}

		public static void OnReceiveSync(ulong _, FastBufferReader reader)
		{
			//IL_002d: 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)
			if (!((FastBufferReader)(ref reader)).TryBeginRead(SyncedInstance<Config>.IntSize))
			{
				HarbingerLoader.mls.LogError((object)"Config sync error: Could not begin reading buffer.");
				return;
			}
			int num = default(int);
			((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num, default(ForPrimitives));
			if (!((FastBufferReader)(ref reader)).TryBeginRead(num))
			{
				HarbingerLoader.mls.LogError((object)"Config sync error: Host could not sync.");
				return;
			}
			byte[] data = new byte[num];
			((FastBufferReader)(ref reader)).ReadBytesSafe(ref data, num, 0);
			SyncedInstance<Config>.SyncInstance(data);
			HarbingerLoader.mls.LogInfo((object)"Successfully synced config with host.");
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")]
		public static void InitializeLocalPlayer()
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			if (SyncedInstance<Config>.IsHost)
			{
				SyncedInstance<Config>.MessageManager.RegisterNamedMessageHandler("ModName_OnRequestConfigSync", new HandleNamedMessageDelegate(OnRequestSync));
				SyncedInstance<Config>.Synced = true;
			}
			else
			{
				SyncedInstance<Config>.Synced = false;
				SyncedInstance<Config>.MessageManager.RegisterNamedMessageHandler("ModName_OnReceiveConfigSync", new HandleNamedMessageDelegate(OnReceiveSync));
				RequestSync();
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameNetworkManager), "StartDisconnect")]
		public static void PlayerLeave()
		{
			SyncedInstance<Config>.RevertSync();
		}
	}
	[BepInPlugin("InstanceWorld.Harbinger", "Harbinger Scripts", "1.0.0")]
	public class HarbingerLoader : BaseUnityPlugin
	{
		private Harmony harmony = new Harmony("InstanceWorld.Harbinger");

		private const string GUID = "InstanceWorld.Harbinger";

		private const string NAME = "Harbinger Scripts";

		private const string VERSION = "1.0.0";

		public static Config HarbConfig;

		private static HarbingerLoader Inst;

		internal static ManualLogSource mls;

		public static AssetBundle HarbBundle;

		public static int SpawnWeight = 25;

		private static EnemyType VoidHarbinger;

		public static string[] BlacklistNames;

		public static string[] WhitelistNames;

		private void Awake()
		{
			if ((Object)(object)Inst == (Object)null)
			{
				Inst = this;
			}
			mls = Logger.CreateLogSource("InstanceWorld.Harbinger");
			mls.LogInfo((object)"Starting HarbingerPatcher...");
			HarbBundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "harbinger"));
			VoidHarbinger = HarbBundle.LoadAsset<EnemyType>("Assets/LethalCompany/Mods/Harbinger/Harbinger_enemyType.asset");
			if ((Object)(object)VoidHarbinger == (Object)null)
			{
				mls.LogError((object)"EnemyType Missing...");
			}
			harmony.PatchAll(typeof(HarbingerAI));
			harmony.PatchAll(typeof(TeleportRing));
			harmony.PatchAll(typeof(Config));
			HarbConfig = new Config(((BaseUnityPlugin)this).Config);
			SetharbValues();
			mls.LogInfo((object)"Patching Networking...");
			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);
					}
				}
			}
			mls.LogInfo((object)"Completed Harbinger Patcher");
		}

		private void SetharbValues()
		{
			TerminalNode val = HarbBundle.LoadAsset<TerminalNode>("Assets/LethalCompany/Mods/Harbinger/HarbingerFile.asset");
			TerminalKeyword val2 = HarbBundle.LoadAsset<TerminalKeyword>("Assets/LethalCompany/Mods/Harbinger/Harbinger.asset");
			VoidHarbinger.MaxCount = SyncedInstance<Config>.Instance.MaxCount.Value;
			if ((Object)(object)val2 == (Object)null)
			{
				mls.LogError((object)"TerminalNode Missing...");
			}
			if ((Object)(object)val == (Object)null)
			{
				mls.LogError((object)"Keyword Missing...");
			}
			NetworkPrefabs.RegisterNetworkPrefab(VoidHarbinger.enemyPrefab);
			(Dictionary<LevelTypes, int> spawnRateByLevelType, Dictionary<string, int> spawnRateByCustomLevelType) tuple = ConfigParsing(SyncedInstance<Config>.Instance.HarbingerSpawnLocations.Value);
			Dictionary<LevelTypes, int> item = tuple.spawnRateByLevelType;
			Dictionary<string, int> item2 = tuple.spawnRateByCustomLevelType;
			BlacklistNames = ParseBlacklist(SyncedInstance<Config>.Instance.BlackList.Value);
			WhitelistNames = ParseBlacklist(SyncedInstance<Config>.Instance.WhiteList.Value);
			if (!WhitelistNames.Contains("none"))
			{
				mls.LogWarning((object)"WhiteList active. Blacklist Disabled");
			}
			Enemies.RegisterEnemy(VoidHarbinger, item, item2, val, val2);
		}

		private static (Dictionary<LevelTypes, int> spawnRateByLevelType, Dictionary<string, int> spawnRateByCustomLevelType) ConfigParsing(string configMoonRarity)
		{
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<LevelTypes, int> dictionary = new Dictionary<LevelTypes, int>();
			Dictionary<string, int> dictionary2 = new Dictionary<string, int>();
			foreach (string item in from s in configMoonRarity.Split(',')
				select s.Trim())
			{
				string[] array = item.Split(':');
				if (array.Length != 2)
				{
					continue;
				}
				string text = array[0];
				if (int.TryParse(array[1], out var result))
				{
					if (Enum.TryParse<LevelTypes>(text, ignoreCase: true, out LevelTypes result2))
					{
						dictionary[result2] = result;
						mls.LogDebug((object)$"Registered spawn rate for level type {result2} to {result}");
					}
					else
					{
						dictionary2[text] = result;
						mls.LogDebug((object)$"Registered spawn rate for custom level type {text} to {result}");
					}
				}
			}
			return (dictionary, dictionary2);
		}

		private static string[] ParseBlacklist(string list)
		{
			string[] array = list.Split(",");
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = array[i].ToLower().Trim();
			}
			return array;
		}
	}
	[Serializable]
	public class SyncedInstance<T>
	{
		[NonSerialized]
		protected static int IntSize = 4;

		internal static CustomMessagingManager MessageManager => NetworkManager.Singleton.CustomMessagingManager;

		internal static bool IsClient => NetworkManager.Singleton.IsClient;

		internal static bool IsHost => NetworkManager.Singleton.IsHost;

		public static T Default { get; private set; }

		public static T Instance { get; private set; }

		public static bool Synced { get; internal set; }

		protected void InitInstance(T instance)
		{
			Default = instance;
			Instance = instance;
			IntSize = 4;
		}

		internal static void SyncInstance(byte[] data)
		{
			Instance = DeserializeFromBytes(data);
			Synced = true;
		}

		internal static void RevertSync()
		{
			Instance = Default;
			Synced = false;
		}

		public static byte[] SerializeToBytes(T val)
		{
			using MemoryStream memoryStream = new MemoryStream();
			try
			{
				XmlSerializer xmlSerializer = new XmlSerializer(typeof(T));
				xmlSerializer.Serialize(memoryStream, val);
				return memoryStream.ToArray();
			}
			catch (Exception arg)
			{
				HarbingerLoader.mls.LogError((object)$"Error serializing instance: {arg}");
				return null;
			}
		}

		public static T DeserializeFromBytes(byte[] data)
		{
			XmlSerializer xmlSerializer = new XmlSerializer(typeof(T));
			using MemoryStream stream = new MemoryStream(data);
			try
			{
				return (T)xmlSerializer.Deserialize(stream);
			}
			catch (Exception arg)
			{
				HarbingerLoader.mls.LogError((object)$"Error deserializing instance: {arg}");
				return default(T);
			}
		}
	}
}
namespace HarbingerBehaviour.AICode
{
	internal class EventIntermediate : MonoBehaviour
	{
		[SerializeField]
		private UnityEvent Listen;

		public void TriggerEvent()
		{
			Listen.Invoke();
		}
	}
	internal class HarbingerAI : EnemyAI
	{
		public enum HarbingerStates
		{
			Moving,
			Standing,
			Teleporting,
			TeleportingSelf,
			TeleportItem
		}

		private Vector3 mainEntrancePosition;

		public float MaxDistanceToPlayerBeforeTeleport = 20f;

		public HarbingerStates state = HarbingerStates.Standing;

		public float movementspeed = 5f;

		private Random enemyRandom;

		public Vector2 MinMaxMovement = new Vector2(5f, 10f);

		public GameObject debugPoint;

		public GameObject NextPos;

		public float stationaryTime = 2f;

		public float ActionStart = 0f;

		public float MovementTimeout = 6f;

		[Header("Teleport Other")]
		public TeleportRing tpRing;

		public float TPOtherCooldown = 15f;

		private float TPOtherInitCooldown;

		private Random TeleportRandom;

		private bool TeleportValid = false;

		private bool aligned = false;

		private Quaternion lookRotation;

		[Header("TeleportSelf")]
		public Vector2 TeleportSelfArriveRadius = new Vector2(4f, 6f);

		public float SelfTeleportCooldown = 40f;

		public AudioSource PositionBeforeSelfTeleport;

		private float lastTeleportTime = 0f;

		private List<EnemyAI> Alreadyused = new List<EnemyAI>();

		private float IntialCooldown;

		private bool TPSelfBehaviourOverridable = false;

		[Header("TeleportApparatus")]
		public GrabbableObject LungProp;

		public float ResetToStealCooldown = 5f;

		public float StealCooldown = 5f;

		public ItemCollider IC;

		private static List<GrabbableObject> grabbableObjectsInMap = new List<GrabbableObject>();

		private float startTeleporItemTimer = 0f;

		public override void Start()
		{
			//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)
			((EnemyAI)this).Start();
			base.movingTowardsTargetPlayer = true;
			enemyRandom = new Random(StartOfRound.Instance.randomMapSeed + base.thisEnemyIndex);
			TeleportRandom = new Random(StartOfRound.Instance.randomMapSeed + base.thisEnemyIndex);
			mainEntrancePosition = RoundManager.FindMainEntrancePosition(false, false);
			ActionStart = Time.time;
			lastTeleportTime = Time.time;
			((Component)PositionBeforeSelfTeleport).transform.SetParent(((Component)((Component)this).transform).transform.parent);
			((Component)tpRing).transform.SetParent(((Component)((Component)this).transform).transform.parent);
			HarbingerLoader.mls.LogWarning((object)("Testing TP Speed: " + SyncedInstance<Config>.Instance.TPSelfCooldown.Value));
			HostConfigApply(SyncedInstance<Config>.Instance.TeleportSpeed.Value, Math.Max(SyncedInstance<Config>.Instance.TPSelfCooldown.Value, 5f), Math.Max(SyncedInstance<Config>.Instance.TPOtherCooldown.Value, 5f));
			RefreshGrabbableObjectsInMapList();
		}

		public static void RefreshGrabbableObjectsInMapList()
		{
			grabbableObjectsInMap.Clear();
			GrabbableObject[] array = Object.FindObjectsOfType<GrabbableObject>();
			HarbingerLoader.mls.LogInfo((object)$"objects in scene!! : {array.Length}");
			for (int i = 0; i < array.Length; i++)
			{
				if (array[i].grabbableToEnemies && (Object)(object)((Component)array[i]).GetComponent<LungProp>() != (Object)null)
				{
					grabbableObjectsInMap.Add(((Component)array[i]).GetComponent<GrabbableObject>());
				}
			}
			HarbingerLoader.mls.LogInfo((object)$"Picked : {grabbableObjectsInMap.Count}");
		}

		public void HostConfigApply(float tpSpeedMult, float teleportSelfCooldown, float teleportOthersCooldown)
		{
			base.creatureAnimator.SetFloat("TeleportMultipier", tpSpeedMult);
			SelfTeleportCooldown = teleportSelfCooldown;
			IntialCooldown = SelfTeleportCooldown;
			TPOtherCooldown = teleportOthersCooldown;
			TPOtherInitCooldown = TPOtherCooldown;
		}

		public override void OnDestroy()
		{
			Object.Destroy((Object)(object)((Component)tpRing).gameObject);
			Object.Destroy((Object)(object)((Component)PositionBeforeSelfTeleport).gameObject);
		}

		public override void DoAIInterval()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0357: Unknown result type (might be due to invalid IL or missing references)
			if (base.moveTowardsDestination)
			{
				base.agent.SetDestination(base.destination);
			}
			if (StartOfRound.Instance.livingPlayers == 0)
			{
				if (base.moveTowardsDestination)
				{
					base.agent.SetDestination(base.destination);
				}
			}
			else
			{
				if (!((NetworkBehaviour)RoundManager.Instance).IsHost)
				{
					return;
				}
				PlayerControllerB closestPlayer = ((EnemyAI)this).GetClosestPlayer(false, true, true);
				testInPickupDistance();
				if ((Object)(object)LungProp != (Object)null)
				{
					HarbingerLoader.mls.LogInfo((object)"Has Appi In Options");
				}
				if (HarbingerLoader.HarbConfig.CanTPItems.Value && state != HarbingerStates.TeleportingSelf && state != HarbingerStates.Teleporting && StealCooldown == 0f && (Object)(object)LungProp != (Object)null && !((GrabbableObject)((Component)LungProp).GetComponent<LungProp>()).isHeld)
				{
					HarbingerLoader.mls.LogWarning((object)"Meet Requirnments");
					if (state != HarbingerStates.TeleportItem)
					{
						NewStateClientRpc(HarbingerStates.TeleportItem);
					}
					if (startTeleporItemTimer != 0f)
					{
						base.agent.speed = 0f;
					}
					else
					{
						base.agent.speed = movementspeed + 2f;
					}
					if (Vector3.Distance(((Component)this).transform.position, ((Component)LungProp).transform.position) < 4f)
					{
						base.agent.speed = 0f;
						TeleportItem();
					}
				}
				else if (state == HarbingerStates.TeleportItem)
				{
					NewStateClientRpc(HarbingerStates.Standing);
				}
				if (state != HarbingerStates.Teleporting && SelfTeleportCooldown == 0f)
				{
					if ((Object)(object)closestPlayer != (Object)null && closestPlayer.isInsideFactory && closestPlayer.isInsideFactory && Vector3.Distance(((Component)closestPlayer).transform.position, ((Component)this).transform.position) > MaxDistanceToPlayerBeforeTeleport)
					{
						if (state != HarbingerStates.TeleportingSelf)
						{
							NewStateClientRpc(HarbingerStates.TeleportingSelf);
						}
					}
					else if ((Object)(object)closestPlayer == (Object)null || !closestPlayer.isInsideFactory)
					{
						if (state != HarbingerStates.TeleportingSelf && Random.Range(0, 2) == 1)
						{
							NewStateClientRpc(HarbingerStates.TeleportingSelf);
						}
						else
						{
							SelfTeleportCooldown += 5f;
						}
					}
					else if (TPSelfBehaviourOverridable && state == HarbingerStates.TeleportingSelf)
					{
						TPSelfBehaviourOverridable = false;
						((MonoBehaviour)this).StopCoroutine(TeleportSelf());
						NewStateClientRpc(HarbingerStates.Moving);
					}
					else
					{
						SelfTeleportCooldown += 5f;
					}
				}
				if (state == HarbingerStates.TeleportingSelf || state == HarbingerStates.TeleportItem || TPOtherCooldown != 0f)
				{
					return;
				}
				if ((Object)(object)closestPlayer != (Object)null && closestPlayer.isInsideFactory && Vector3.Distance(((Component)closestPlayer).transform.position, ((Component)this).transform.position) < MaxDistanceToPlayerBeforeTeleport)
				{
					if (state != HarbingerStates.Teleporting)
					{
						NewStateClientRpc(HarbingerStates.Teleporting);
					}
				}
				else if (!TeleportValid && state == HarbingerStates.Teleporting)
				{
					((MonoBehaviour)this).StopCoroutine(PrepTeleportOther());
					NewStateClientRpc(HarbingerStates.Moving);
				}
				else
				{
					TPOtherCooldown += 5f;
				}
			}
		}

		public void testInPickupDistance()
		{
			//IL_0024: 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)
			float num = float.MaxValue;
			foreach (GrabbableObject item in grabbableObjectsInMap)
			{
				float num2 = Vector3.Distance(((Component)item).transform.position, ((Component)this).transform.position);
				if (num2 < 15f && num > num2)
				{
					num = num2;
					LungProp = item;
				}
			}
			if (num >= float.MaxValue)
			{
				LungProp = null;
			}
		}

		public override void Update()
		{
			//IL_011b: 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_0181: 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_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: 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)
			((EnemyAI)this).Update();
			if (StealCooldown > 0f)
			{
				StealCooldown = Math.Max(0f, StealCooldown - Time.deltaTime);
			}
			if (SelfTeleportCooldown > 0f)
			{
				SelfTeleportCooldown = Math.Max(0f, SelfTeleportCooldown - Time.deltaTime);
			}
			if (TPOtherCooldown > 0f)
			{
				TPOtherCooldown = Math.Max(0f, TPOtherCooldown - Time.deltaTime);
			}
			if (startTeleporItemTimer > 0f)
			{
				startTeleporItemTimer = Math.Max(0f, startTeleporItemTimer - Time.deltaTime);
			}
			switch (state)
			{
			case HarbingerStates.Standing:
				if (ActionStart + stationaryTime < Time.time)
				{
					NewStateClientRpc(HarbingerStates.Moving);
				}
				break;
			case HarbingerStates.Moving:
				if (Vector3.Distance(((Component)this).transform.position, base.destination) < 0.5f || MovementTimeout + ActionStart < Time.time)
				{
					NewStateClientRpc(HarbingerStates.Standing);
				}
				break;
			case HarbingerStates.Teleporting:
				if (TeleportValid)
				{
					if (!aligned && Math.Abs(((Component)base.agent).transform.eulerAngles.y - ((Quaternion)(ref lookRotation)).eulerAngles.y) < 5f)
					{
						aligned = true;
						HarbingerLoader.mls.LogWarning((object)"In possition");
						StartTeleportEffectsClientRpc();
						((EnemyAI)this).SwitchToBehaviourState(2);
					}
					else
					{
						((Component)base.agent).transform.rotation = Quaternion.RotateTowards(((Component)base.agent).transform.rotation, lookRotation, Math.Abs(180f) * Time.deltaTime);
					}
				}
				break;
			case HarbingerStates.TeleportingSelf:
				break;
			}
		}

		public IEnumerator TimeTP()
		{
			yield return (object)new WaitForSeconds(6.25f);
			TeleportEvent();
		}

		public void TeleportItem()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			if (LungProp is LungProp)
			{
				LungProp val = (LungProp)LungProp;
				if (val.isLungDocked)
				{
					EquipAppiClientRpc(((NetworkBehaviour)val).NetworkObjectId);
				}
				((GrabbableObject)val).ChangeOwnershipOfProp(((NetworkBehaviour)this).NetworkManager.LocalClient.ClientId);
				TPItemClientRpc(((NetworkBehaviour)val).NetworkObjectId, TeleportRandom.Next(base.allAINodes.Length));
			}
			NewStateClientRpc(HarbingerStates.Standing);
		}

		[ClientRpc]
		public void EquipAppiClientRpc(ulong Item)
		{
			//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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(770069550u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, Item);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 770069550u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					((GrabbableObject)((Component)NetworkManager.Singleton.SpawnManager.SpawnedObjects[Item]).GetComponent<LungProp>()).EquipItem();
				}
			}
		}

		[ClientRpc]
		public void TPItemClientRpc(ulong Item, int Location)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: 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_010c: 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_014a: 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_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: 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 != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2152385852u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, Item);
					BytePacker.WriteValueBitPacked(val2, Location);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2152385852u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					NetworkObject val3 = NetworkManager.Singleton.SpawnManager.SpawnedObjects[Item];
					LungProp component = ((Component)val3).GetComponent<LungProp>();
					Vector3 position = base.allAINodes[Location].transform.position;
					((Component)component).transform.position = position;
					((Component)component).transform.SetParent(StartOfRound.Instance.propsContainer, true);
					((GrabbableObject)component).EnablePhysics(true);
					((GrabbableObject)component).fallTime = 0f;
					((GrabbableObject)component).startFallingPosition = ((Component)component).transform.parent.InverseTransformPoint(position);
					((GrabbableObject)component).targetFloorPosition = ((Component)component).transform.parent.InverseTransformPoint(((GrabbableObject)component).GetItemFloorPosition(default(Vector3)));
					((GrabbableObject)component).floorYRot = -1;
					((GrabbableObject)component).FallToGround(false);
				}
			}
		}

		[ClientRpc]
		public void NewStateClientRpc(HarbingerStates newstate)
		{
			//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_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0308: 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 != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3573526470u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<HarbingerStates>(ref newstate, default(ForEnums));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3573526470u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			HarbingerLoader.mls.LogInfo((object)("NewState " + newstate));
			if (state == HarbingerStates.TeleportItem && newstate != state)
			{
				StealCooldown = ResetToStealCooldown;
			}
			if (state == HarbingerStates.Teleporting && newstate != state)
			{
				aligned = false;
				TeleportValid = false;
				Alreadyused.Clear();
			}
			state = newstate;
			ActionStart = Time.time;
			switch (state)
			{
			case HarbingerStates.Standing:
				base.agent.speed = 0f;
				((EnemyAI)this).SwitchToBehaviourState(0);
				break;
			case HarbingerStates.Moving:
			{
				NavMeshHit val7 = FindMoveLocation(((Component)this).transform.position, MinMaxMovement, 50, 1f, hasVertical: true, 2.5f);
				((EnemyAI)this).SetDestinationToPosition(((NavMeshHit)(ref val7)).position, false);
				base.agent.speed = movementspeed;
				((EnemyAI)this).SwitchToBehaviourState(1);
				break;
			}
			case HarbingerStates.Teleporting:
				base.agent.speed = 0f;
				if (((NetworkBehaviour)RoundManager.Instance).IsHost)
				{
					((MonoBehaviour)this).StartCoroutine(PrepTeleportOther());
				}
				break;
			case HarbingerStates.TeleportingSelf:
				base.agent.speed = 0f;
				((MonoBehaviour)this).StartCoroutine(TeleportSelf());
				break;
			case HarbingerStates.TeleportItem:
			{
				((EnemyAI)this).SwitchToBehaviourState(4);
				startTeleporItemTimer = 0.5f;
				base.agent.speed = movementspeed + 2f;
				Ray val3 = default(Ray);
				((Ray)(ref val3))..ctor(((Component)LungProp).transform.position, Vector3.down);
				Vector3 val4 = ((Component)LungProp).transform.position;
				RaycastHit val5 = default(RaycastHit);
				if (Physics.Raycast(val3, ref val5, 7f))
				{
					val4 = ((RaycastHit)(ref val5)).point;
				}
				NavMeshHit val6 = default(NavMeshHit);
				if (NavMesh.SamplePosition(val4, ref val6, 10f, -1))
				{
					HarbingerLoader.mls.LogInfo((object)"Found Destination");
					((EnemyAI)this).SetDestinationToPosition(((NavMeshHit)(ref val6)).position, false);
				}
				else
				{
					HarbingerLoader.mls.LogWarning((object)"Cant Find Location");
				}
				break;
			}
			}
		}

		private IEnumerator TeleportSelf()
		{
			base.creatureAnimator.SetTrigger("CheckingTeleport");
			TPSelfBehaviourOverridable = true;
			yield return (object)new WaitForSeconds(2f);
			List<Transform> validTeleportPlayers = new List<Transform>();
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB a in allPlayerScripts)
			{
				if (a.isInsideFactory && !a.isPlayerDead)
				{
					validTeleportPlayers.Add(((Component)a).transform);
				}
			}
			if (((NetworkBehaviour)RoundManager.Instance).IsHost)
			{
				Vector3 tpLocation = ((validTeleportPlayers.Count != 0) ? validTeleportPlayers[TeleportRandom.Next(validTeleportPlayers.Count)].position : ((base.allAINodes.Length == 0) ? ((Component)this).transform.position : base.allAINodes[Random.Range(0, base.allAINodes.Length)].transform.position));
				NavMeshHit h = FindMoveLocation(tpLocation, TeleportSelfArriveRadius, 15, 1f, hasVertical: true, 2f);
				if (((NavMeshHit)(ref h)).hit)
				{
					LastLocationUpdateClientRpc(((Component)this).transform.position);
					((EnemyAI)this).SwitchToBehaviourState(3);
					yield return (object)new WaitForSeconds(0.1f);
					base.agent.Warp(((NavMeshHit)(ref h)).position);
					lastTeleportTime = Time.time;
					SelfTeleportCooldown = IntialCooldown;
					if (TPOtherCooldown < 1f)
					{
						TPOtherCooldown = 1f;
					}
				}
				h = default(NavMeshHit);
			}
			TPSelfBehaviourOverridable = false;
			yield return (object)new WaitForSeconds(0.3f);
			NewStateClientRpc(HarbingerStates.Moving);
		}

		[ClientRpc]
		public void LastLocationUpdateClientRpc(Vector3 newLocation)
		{
			//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_00d4: 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 != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1654902290u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe(ref newLocation);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1654902290u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				((Component)PositionBeforeSelfTeleport).transform.position = newLocation;
				if (GameNetworkManager.Instance.localPlayerController.isInsideFactory)
				{
					PositionBeforeSelfTeleport.Play();
				}
			}
		}

		private IEnumerator PrepTeleportOther()
		{
			base.creatureAnimator.SetTrigger("CheckingTeleport");
			if (!((NetworkBehaviour)RoundManager.Instance).IsHost)
			{
				yield break;
			}
			yield return (object)new WaitForSeconds(0.5f);
			List<EnemyAI> validEnemies = new List<EnemyAI>();
			foreach (EnemyAI Ai in RoundManager.Instance.SpawnedEnemies)
			{
				if (Ai.isOutside == base.isOutside && !Ai.isEnemyDead && Vector3.Distance(((Component)Ai).transform.position, ((Component)this).transform.position) > 20f && MonsterBlackList(Ai))
				{
					validEnemies.Add(Ai);
				}
			}
			if (validEnemies.Count == 0)
			{
				HarbingerLoader.mls.LogInfo((object)"No valid Targets");
				TPOtherCooldown += 5f;
				NewStateClientRpc(HarbingerStates.Standing);
				yield break;
			}
			EnemyAI a = validEnemies[TeleportRandom.Next(validEnemies.Count)];
			Alreadyused.Add(a);
			NavMeshHit h = FindMoveLocation(((Component)this).transform.position, MinMaxMovement, 15, 1f);
			if (!((NavMeshHit)(ref h)).hit)
			{
				NewStateClientRpc(HarbingerStates.Standing);
				yield break;
			}
			SettUpTPClientRpc(((NetworkBehaviour)a).NetworkObjectId, ((NavMeshHit)(ref h)).position);
			Vector3 val = ((Component)tpRing).transform.position - ((Component)base.agent).transform.position;
			Vector3 RotateToTeleportionDirection = ((Vector3)(ref val)).normalized;
			RotateToTeleportionDirection.y = 0f;
			lookRotation = Quaternion.LookRotation(RotateToTeleportionDirection);
			TeleportValid = true;
		}

		[ClientRpc]
		public void SettUpTPClientRpc(ulong EnemyNetID, Vector3 loc)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: 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_0096: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(234086616u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, EnemyNetID);
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref loc);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 234086616u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					NetworkObject val3 = NetworkManager.Singleton.SpawnManager.SpawnedObjects[EnemyNetID];
					tpRing.setup(((Component)val3).GetComponent<EnemyAI>(), loc);
				}
			}
		}

		public static NavMeshHit FindMoveLocation(Vector3 SourceLocation, Vector2 distanceRange, int maxTries = 15, float maxDistance = 2f, bool hasVertical = false, float VerticalAmount = 0f)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: 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_0017: 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_0020: 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_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: 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_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: 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_008d: Unknown result type (might be due to invalid IL or missing references)
			NavMeshHit result = default(NavMeshHit);
			int num = 0;
			while (!((NavMeshHit)(ref result)).hit && num < maxTries)
			{
				Vector2 val = Random.insideUnitCircle;
				val = ((Vector2)(ref val)).normalized;
				Vector2 val2 = ((Vector2)(ref val)).normalized * distanceRange;
				float num2 = 0f;
				if (hasVertical)
				{
					num2 = Random.Range(0f - VerticalAmount, VerticalAmount);
				}
				Vector3 val3 = SourceLocation + new Vector3(val2.x, num2, val2.y);
				NavMesh.SamplePosition(val3, ref result, maxDistance, -1);
				num++;
			}
			return result;
		}

		public void TeleportEvent()
		{
			if (((NetworkBehaviour)RoundManager.Instance).IsHost)
			{
				lastTeleportTime = Time.time;
				TPOtherCooldown += TPOtherInitCooldown;
				TeleportClientRpc();
				((MonoBehaviour)this).StartCoroutine(EndTP());
			}
		}

		[ClientRpc]
		public void TeleportClientRpc()
		{
			//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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3152957184u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3152957184u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					tpRing.CompleteTeleport();
					tpRing.BurstEffects();
				}
			}
		}

		private IEnumerator EndTP()
		{
			yield return (object)new WaitForSeconds(1.5f);
			NewStateClientRpc(HarbingerStates.Moving);
		}

		[ClientRpc]
		public void StartTeleportEffectsClientRpc()
		{
			//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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3751040310u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3751040310u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					tpRing.VisualEffectsActive();
				}
			}
		}

		[ClientRpc]
		public void CancelTeleportClientRpc()
		{
			//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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1850307525u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1850307525u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					tpRing.Cancel();
				}
			}
		}

		public override void HitEnemy(int force = 1, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
		{
			//IL_006a: 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_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: 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_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: 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_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).HitEnemy(force, playerWhoHit, playHitSFX, hitID);
			if ((Object)(object)playerWhoHit == (Object)null || !((NetworkBehaviour)playerWhoHit).IsOwner)
			{
				return;
			}
			List<EnemyAI> list = new List<EnemyAI>();
			foreach (EnemyAI spawnedEnemy in RoundManager.Instance.SpawnedEnemies)
			{
				if (spawnedEnemy.isOutside == base.isOutside && !spawnedEnemy.isEnemyDead && Vector3.Distance(((Component)spawnedEnemy).transform.position, ((Component)this).transform.position) > 10f)
				{
					list.Add(spawnedEnemy);
				}
			}
			if (list.Count > 0)
			{
				Vector3 val = ((Component)list[Random.Range(0, list.Count - 1)]).transform.position;
				Ray val2 = default(Ray);
				((Ray)(ref val2))..ctor(val, Vector3.down);
				RaycastHit val3 = default(RaycastHit);
				if (Physics.Raycast(val2, ref val3, 5f))
				{
					val = ((RaycastHit)(ref val3)).point;
				}
				NavMeshHit val4 = default(NavMeshHit);
				int num = 0;
				while (!((NavMeshHit)(ref val4)).hit && num < 10)
				{
					Vector2 val5 = Random.insideUnitCircle;
					val5 = ((Vector2)(ref val5)).normalized;
					Vector2 val6 = ((Vector2)(ref val5)).normalized * (float)Random.Range(3, 6);
					Vector3 val7 = val + new Vector3(val6.x, 0f, val6.y);
					NavMesh.SamplePosition(val7, ref val4, 0.5f, -1);
					ManualLogSource mls = HarbingerLoader.mls;
					Vector3 position = ((NavMeshHit)(ref val4)).position;
					mls.LogInfo((object)("Nav Pos: " + ((object)(Vector3)(ref position)).ToString()));
					num++;
				}
				if (num < 10)
				{
					playerWhoHit.TeleportPlayer(((NavMeshHit)(ref val4)).position, false, 0f, false, true);
				}
				else
				{
					playerWhoHit.TeleportPlayer(((EnemyAI)this).ChooseFarthestNodeFromPosition(mainEntrancePosition, false, 0, false, 50, false).position, false, 0f, false, true);
				}
			}
			else
			{
				playerWhoHit.TeleportPlayer(((EnemyAI)this).ChooseFarthestNodeFromPosition(mainEntrancePosition, false, 0, false, 50, false).position, false, 0f, false, true);
			}
		}

		public static bool MonsterBlackList(EnemyAI toTest)
		{
			//IL_0065: 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)
			if (!HarbingerLoader.WhitelistNames.Contains("none"))
			{
				return MonsterWhiteList(toTest);
			}
			if ((Object)(object)toTest == (Object)null)
			{
				return false;
			}
			if (toTest is DressGirlAI || toTest is CentipedeAI || toTest is SandSpiderAI)
			{
				return false;
			}
			if (toTest is CaveDwellerAI && (((CaveDwellerAI)toTest).holdingBaby || ((EnemyAI)(CaveDwellerAI)toTest).isOutside))
			{
				return false;
			}
			if (HarbingerLoader.BlacklistNames.Contains(StandardiesMonsterNames(toTest.enemyType.enemyName)))
			{
				return false;
			}
			HarbingerLoader.mls.LogMessage((object)("Teleport BL Result is good: " + toTest.enemyType.enemyName));
			return true;
		}

		private static bool MonsterWhiteList(EnemyAI toTest)
		{
			if (HarbingerLoader.WhitelistNames.Contains(StandardiesMonsterNames(toTest.enemyType.enemyName)))
			{
				HarbingerLoader.mls.LogMessage((object)("Teleport WL Result is good: " + toTest.enemyType.enemyName));
				return true;
			}
			return false;
		}

		private static string StandardiesMonsterNames(string Monster)
		{
			return Monster.ToLower().Trim();
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_HarbingerAI()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Expected O, but got Unknown
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(770069550u, new RpcReceiveHandler(__rpc_handler_770069550));
			NetworkManager.__rpc_func_table.Add(2152385852u, new RpcReceiveHandler(__rpc_handler_2152385852));
			NetworkManager.__rpc_func_table.Add(3573526470u, new RpcReceiveHandler(__rpc_handler_3573526470));
			NetworkManager.__rpc_func_table.Add(1654902290u, new RpcReceiveHandler(__rpc_handler_1654902290));
			NetworkManager.__rpc_func_table.Add(234086616u, new RpcReceiveHandler(__rpc_handler_234086616));
			NetworkManager.__rpc_func_table.Add(3152957184u, new RpcReceiveHandler(__rpc_handler_3152957184));
			NetworkManager.__rpc_func_table.Add(3751040310u, new RpcReceiveHandler(__rpc_handler_3751040310));
			NetworkManager.__rpc_func_table.Add(1850307525u, new RpcReceiveHandler(__rpc_handler_1850307525));
		}

		private static void __rpc_handler_770069550(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 item = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref item);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((HarbingerAI)(object)target).EquipAppiClientRpc(item);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2152385852(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ulong item = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref item);
				int location = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref location);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((HarbingerAI)(object)target).TPItemClientRpc(item, location);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3573526470(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_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				HarbingerStates newstate = default(HarbingerStates);
				((FastBufferReader)(ref reader)).ReadValueSafe<HarbingerStates>(ref newstate, default(ForEnums));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((HarbingerAI)(object)target).NewStateClientRpc(newstate);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1654902290(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 newLocation = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref newLocation);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((HarbingerAI)(object)target).LastLocationUpdateClientRpc(newLocation);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_234086616(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ulong enemyNetID = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref enemyNetID);
				Vector3 loc = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref loc);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((HarbingerAI)(object)target).SettUpTPClientRpc(enemyNetID, loc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3152957184(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)2;
				((HarbingerAI)(object)target).TeleportClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3751040310(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)2;
				((HarbingerAI)(object)target).StartTeleportEffectsClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1850307525(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)2;
				((HarbingerAI)(object)target).CancelTeleportClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "HarbingerAI";
		}
	}
	internal class ItemCollider : MonoBehaviour
	{
		public HarbingerAI AI;

		public LayerMask LayerMask;

		private void OnTriggerEnter(Collider other)
		{
			if ((Object)(object)((Component)other).GetComponent<GrabbableObject>() != (Object)null && ((Component)other).GetComponent<GrabbableObject>() is LungProp)
			{
				HarbingerLoader.mls.LogInfo((object)"Triggered Appi");
			}
		}

		public void TeleportCheck()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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_002b: Unknown result type (might be due to invalid IL or missing references)
			Bounds bounds = ((Collider)((Component)this).GetComponent<BoxCollider>()).bounds;
			Collider[] array = Physics.OverlapBox(((Bounds)(ref bounds)).center, ((Bounds)(ref bounds)).size / 2f, Quaternion.identity, LayerMask.op_Implicit(LayerMask));
			Collider[] array2 = array;
			foreach (Collider val in array2)
			{
				if ((Object)(object)((Component)val).GetComponent<GrabbableObject>() != (Object)null && ((Component)val).GetComponent<GrabbableObject>() is LungProp)
				{
					HarbingerLoader.mls.LogInfo((object)"Triggered TP appi");
					break;
				}
			}
		}

		private void OnTriggerExit(Collider other)
		{
			if (((Component)other).CompareTag("PhysicsProp") && ((Component)other).GetComponent<GrabbableObject>() is LungProp && (Object)(object)AI.LungProp == (Object)(object)((Component)other).GetComponent<GrabbableObject>())
			{
				AI.LungProp = null;
			}
		}
	}
	internal class SlimePatchExample : NetworkBehaviour
	{
		public EnemyAI ai;

		[ClientRpc]
		public void TeleportCreatureClientRpc(Vector3 TPLocation)
		{
			//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_00cf: 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_00e4: 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_00f3: 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_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: 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_01d3: 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_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: 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_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Expected O, but got Unknown
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(56883393u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe(ref TPLocation);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 56883393u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			Vector3 val3 = ((BlobAI)ai).centerPoint.position - ((Component)(BlobAI)ai).transform.position;
			Vector3[] array = (Vector3[])(object)new Vector3[8];
			if (ai is BlobAI)
			{
				for (int i = 0; i < ((BlobAI)ai).SlimeRaycastTargets.Length; i++)
				{
					array[i] = ((BlobAI)ai).SlimeBones[i].position - ((BlobAI)ai).centerPoint.position;
				}
			}
			if (((NetworkBehaviour)ai).IsOwner)
			{
				ai.agent.Warp(TPLocation);
			}
			if (ai is BlobAI)
			{
				((BlobAI)ai).centerPoint.position = ((Component)(BlobAI)ai).transform.position + val3;
				for (int j = 0; j < ((BlobAI)ai).SlimeRaycastTargets.Length; j++)
				{
					array[j] = ((BlobAI)ai).centerPoint.position + array[j];
				}
				Traverse.Create((object)(BlobAI)ai).Field("SlimeBonePositions").SetValue((object)array);
			}
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_SlimePatchExample()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(56883393u, new RpcReceiveHandler(__rpc_handler_56883393));
		}

		private static void __rpc_handler_56883393(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 tPLocation = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref tPLocation);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((SlimePatchExample)(object)target).TeleportCreatureClientRpc(tPLocation);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "SlimePatchExample";
		}
	}
	internal class TeleportRing : MonoBehaviour
	{
		public GameObject Container;

		public AudioSource FinishSound;

		public EnemyAI Teleport;

		public Vector3 EnemyLocation;

		public void setup(EnemyAI ToTeleport, Vector3 Location)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			Teleport = ToTeleport;
			((Component)this).transform.position = Location;
		}

		public void CompleteTeleport()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00dc: Unknown result type (might be due to invalid IL or missing references)
			EnemyLocation = ((Component)Teleport).transform.position;
			TeleportCreature(Teleport);
			LayerMask val = LayerMask.op_Implicit(LayerMask.GetMask(new string[1] { "Player" }));
			Collider[] array = Physics.OverlapCapsule(Container.transform.position, Container.transform.position, 3f, LayerMask.op_Implicit(val));
			Collider[] array2 = array;
			foreach (Collider val2 in array2)
			{
				if (((Component)val2).CompareTag("Player") && ((NetworkBehaviour)((Component)val2).GetComponent<PlayerControllerB>()).IsOwner)
				{
					NavMeshHit val3 = HarbingerAI.FindMoveLocation(EnemyLocation, new Vector2(1f, 2f));
					if (((NavMeshHit)(ref val3)).hit)
					{
						((MonoBehaviour)this).StartCoroutine(TeleportPlayer(val2, ((NavMeshHit)(ref val3)).position));
					}
				}
			}
		}

		private IEnumerator TeleportPlayer(Collider c, Vector3 pos)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			yield return (object)new WaitForSeconds(0.1f);
			((Component)c).GetComponent<PlayerControllerB>().TeleportPlayer(pos, true, 0f, false, true);
		}

		public void VisualEffectsActive()
		{
			Container.SetActive(true);
		}

		public void BurstEffects()
		{
			if (Object.op_Implicit((Object)(object)FinishSound))
			{
				FinishSound.Play();
			}
			((MonoBehaviour)this).StartCoroutine(Deactivate());
		}

		private IEnumerator Deactivate()
		{
			yield return (object)new WaitForSeconds(0.2f);
			Container.SetActive(false);
		}

		public void Cancel()
		{
			Container.SetActive(false);
		}

		public void CreatureConfigure()
		{
			//IL_003b: 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)
			if (Teleport is CentipedeAI)
			{
				((EnemyAI)(CentipedeAI)Teleport).SwitchToBehaviourServerRpc(2);
			}
			else
			{
				Teleport.agent.Warp(((Component)this).transform.position);
			}
		}

		public void TeleportCreature(EnemyAI ai)
		{
			//IL_0003: 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)
			//IL_0029: 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_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: 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)
			//IL_00eb: 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_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: 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_0118: 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_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Expected O, but got Unknown
			Vector3 val = default(Vector3);
			Vector3[] array = (Vector3[])(object)new Vector3[8];
			if (ai is BlobAI)
			{
				val = ((BlobAI)ai).centerPoint.position - ((Component)(BlobAI)ai).transform.position;
				for (int i = 0; i < ((BlobAI)ai).SlimeRaycastTargets.Length; i++)
				{
					array[i] = ((BlobAI)ai).SlimeBones[i].position - ((BlobAI)ai).centerPoint.position;
				}
			}
			if (((NetworkBehaviour)Teleport).IsOwner)
			{
				Teleport.agent.Warp(((Component)this).transform.position);
			}
			if (ai is BlobAI)
			{
				((BlobAI)ai).centerPoint.position = ((Component)(BlobAI)ai).transform.position + val;
				for (int j = 0; j < ((BlobAI)ai).SlimeRaycastTargets.Length; j++)
				{
					array[j] = ((BlobAI)ai).centerPoint.position + array[j];
				}
				Traverse.Create((object)(BlobAI)ai).Field("SlimeBonePositions").SetValue((object)array);
			}
		}
	}
}
namespace HarbingerBehaviour.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}