Decompiled source of MysteriousHarbingers v1.0.6

HarbingerBehaviour.dll

Decompiled 2 weeks 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.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarbingerBehaviour.AICode;
using HarbingerBehaviour.ConfigSync;
using HarbingerBehaviour.Items;
using HarbingerBehaviour.NetcodePatcher;
using HarmonyLib;
using LethalLib.Modules;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Events;
using UnityEngine.VFX;

[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.ShaderBS
{
	public class ShaderTimeSync : MonoBehaviour
	{
		public Material[] SyncedMats;

		public void Update()
		{
			Material[] syncedMats = SyncedMats;
			foreach (Material val in syncedMats)
			{
				val.SetFloat("_SyncedTime", Time.time);
			}
		}
	}
}
namespace HarbingerBehaviour.Items
{
	internal class RealityFracture : PhysicsProp
	{
		public int DamagePlayer = 20;

		public AudioSource UseSource;

		public AudioClip UseItemAudio;

		public AudioClip CantUseItemAudio;

		private GameObject[] allAINodes;

		private Random TeleportRandom;

		private Random noisemakerRandom;

		public bool CanBeUsed = true;

		private void Awake()
		{
		}

		public override void Start()
		{
			((GrabbableObject)this).Start();
			TeleportRandom = new Random();
			noisemakerRandom = new Random();
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			if (CanBeUsed)
			{
				HarbingerLoader.mls.LogInfo((object)"Item activiated");
				float pitch = (float)noisemakerRandom.Next(80, 100) / 100f;
				UseSource.pitch = pitch;
				allAINodes = GameObject.FindGameObjectsWithTag("AINode");
				if (!((GrabbableObject)this).playerHeldBy.isInsideFactory || allAINodes == null)
				{
					((GrabbableObject)this).currentUseCooldown = 0.2f;
					UseSource.PlayOneShot(CantUseItemAudio);
				}
				else
				{
					((MonoBehaviour)this).StartCoroutine(Teleport());
				}
			}
		}

		private IEnumerator Teleport()
		{
			HarbingerLoader.mls.LogInfo((object)"Item Teleporting");
			UseSource.PlayOneShot(UseItemAudio);
			yield return (object)new WaitForSeconds(1.5f);
			if ((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null || !((NetworkBehaviour)RoundManager.Instance).IsHost)
			{
				yield break;
			}
			int tries = 5;
			while (tries > 0)
			{
				int nextLoc = TeleportRandom.Next(allAINodes.Length);
				Vector3 ExitPosition = allAINodes[nextLoc].transform.position;
				NavMeshHit hit = FindMoveLocation(ExitPosition, new Vector2(0.5f, 1f), 5);
				if (((NavMeshHit)(ref hit)).hit)
				{
					if ((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null)
					{
						TeleportPlayerClientRPC(((GrabbableObject)this).playerHeldBy.playerClientId, ((NavMeshHit)(ref hit)).position);
					}
					break;
				}
				tries--;
				hit = default(NavMeshHit);
			}
		}

		public NavMeshHit FindMoveLocation(Vector3 SourceLocation, Vector2 distanceRange, int maxTries = 15, float maxDistance = 2f, bool hasVertical = false, float VerticalAmount = 0f)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: 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_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			HarbingerLoader.mls.LogInfo((object)"Item find location");
			NavMeshHit result = default(NavMeshHit);
			int num = 0;
			bool flag = false;
			while (!flag && 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);
				if (((NavMeshHit)(ref result)).hit && allAINodes.Length != 0)
				{
					HarbingerLoader.mls.LogInfo((object)"Item found location");
					flag = true;
				}
				HarbingerLoader.mls.LogInfo((object)"Item failed location");
				num++;
			}
			return result;
		}

		[ClientRpc]
		public void TeleportPlayerClientRPC(ulong playernum, Vector3 pos)
		{
			//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_00f2: 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_0105: 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(3433015883u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playernum);
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref pos);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3433015883u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					PlayerControllerB val3 = StartOfRound.Instance.allPlayerScripts[playernum];
					val3.DamagePlayer(DamagePlayer, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
					((Component)val3).GetComponent<PlayerControllerB>().TeleportPlayer(pos, true, 0f, false, true);
				}
			}
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_RealityFracture()
		{
			//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(3433015883u, new RpcReceiveHandler(__rpc_handler_3433015883));
		}

		private static void __rpc_handler_3433015883(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 playernum = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref playernum);
				Vector3 pos = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref pos);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((RealityFracture)(object)target).TeleportPlayerClientRPC(playernum, pos);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "RealityFracture";
		}
	}
}
namespace HarbingerBehaviour.ConfigSync
{
	[Serializable]
	public class Config : SyncedInstance<Config>
	{
		[NonSerialized]
		public ConfigItem<float> TeleportSpeed;

		public ConfigItem<float> TPSelfCooldown;

		public ConfigItem<float> TPOtherCooldown;

		public ConfigItem<int> MaxCount;

		public ConfigItem<string> HarbingerSpawnLocations;

		public ConfigItem<string> BlackList;

		public ConfigItem<string> WhiteList;

		public ConfigItem<bool> CanTPItems;

		public ConfigItem<bool> CanTeleportSelf;

		public ConfigItem<bool> CanCreateFractures;

		public ConfigItem<int> SimultaneousFractures;

		public ConfigItem<float> StunDuration;

		public ConfigItem<float> ShockDifficulty;

		public ConfigItem<float> RealityFractureChance;

		public ConfigItem<int> MinFractureValue;

		public ConfigItem<int> MaxFractureValue;

		public ConfigItem<bool> CanUseItem;

		public ConfigItem<int> FractureCooldown;

		public ConfigItem<int> FractureDamageDelt;

		public ConfigItem<int> FractureWeight;

		public ConfigItem<bool> HarbingerCanDie;

		public ConfigItem<int> HarbingerHealth;

		public ConfigItem<bool> TeleportRandom;

		public ConfigItem<bool> TpOnHarbingerTouch;

		public Config()
		{
			InitInstance(this);
		}

		public Config(ConfigFile cfg)
		{
			InitInstance(this);
			HarbingerCanDie = cfg.Bind<bool>("Health", "Can Harbinger Die", true, "If true Harbingers can be killed by breaking Space Fractures");
			HarbingerHealth = cfg.Bind<int>("Health", "Hitpoints", 3, "How many fractures need to break to kill a harbinger");
			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");
			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.");
			CanTeleportSelf = cfg.Bind<bool>("Teleport Self", "Can TP Self", true, "Can the harbinger teleport itself to players.");
			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");
			CanCreateFractures = cfg.Bind<bool>("Harbinger Space Fracture", "Can Create Space Fractures", true, "Harbingers can spawn Fractures on teleport if enabled. Note: if disabled harbingers can't die. If enabled but teleport self isn't, it will create fractures on teleporting enemies.");
			SimultaneousFractures = cfg.Bind<int>("Harbinger Space Fracture", "Max Simultaneous Fractures", 3, "How many fractures can a Harbinger have active at the same time.");
			StunDuration = cfg.Bind<float>("Harbinger Space Fracture", "Fracture stun Duration", 4f, "How long a fracture needs to be stunned for it to break");
			ShockDifficulty = cfg.Bind<float>("Harbinger Space Fracture", "Fracture stun Difficulty", 1.2f, "How hard the zap-gun minigame is when attacking a fracture. (1.1 is easy, 1.5+ is hard)");
			RealityFractureChance = cfg.Bind<float>("Reality Fracture", "Drop Chance", 0.3f, "How Frequantly a Reality Fracture item should be dropped from Space Fractures (0 for disabled and 1 for always)");
			MinFractureValue = cfg.Bind<int>("Reality Fracture", "Min Value", 50, "The lowest a dropped fragment should be worth");
			MaxFractureValue = cfg.Bind<int>("Reality Fracture", "Max Value", 100, "The highest a dropped fragment should be worth");
			CanUseItem = cfg.Bind<bool>("Reality Fracture", "CanUseItem", true, "If the item can be used to teleport the player");
			FractureCooldown = cfg.Bind<int>("Reality Fracture", "Reality Fracture Cooldown", 60, "The cooldown of using a Reality fracture to teleport (in seconds)");
			FractureDamageDelt = cfg.Bind<int>("Reality Fracture", "Fracture Self Damage", 20, "The amount of damage a fracture should do to a player when used");
			FractureWeight = cfg.Bind<int>("Reality Fracture", "Fracture Weight", 20, "Weight of the item in pounds");
			MaxCount = cfg.Bind<int>("Spawning", "Maximum Harbingers", 1, "What is the maximum number of harbingers that should be able to spawn (defaut 1)");
			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).");
			TeleportRandom = cfg.Bind<bool>("Misc", "Change retaliate to TP random", false, "If set will teleport the player to a random location if touched or attacked, instead of teleporting them to enemies.");
			TpOnHarbingerTouch = cfg.Bind<bool>("Misc", "TP On Touch", true, "If set will teleport players on physical contatct with a harbinger instead of just when attacked.");
		}

		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("Harbinger_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("Harbinger_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_0030: 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)
			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);
			if (SyncedInstance<Config>.Instance != null)
			{
				HarbingerLoader.mls.LogInfo((object)"OnReceiveSync: Successfully synced instance!");
				SetUpPrefabVariables();
			}
			else
			{
				HarbingerLoader.mls.LogError((object)"OnReceiveSync: Instance is still null after sync!");
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")]
		public static void InitializeLocalPlayer()
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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("Harbinger_OnRequestConfigSync", new HandleNamedMessageDelegate(OnRequestSync));
				SyncedInstance<Config>.Synced = true;
				SetUpPrefabVariables();
			}
			else
			{
				HarbingerLoader.mls.LogInfo((object)"I patched here");
				SyncedInstance<Config>.Synced = false;
				SyncedInstance<Config>.MessageManager.RegisterNamedMessageHandler("Harbinger_OnReceiveConfigSync", new HandleNamedMessageDelegate(OnReceiveSync));
				RequestSync();
			}
		}

		public static void SetUpPrefabVariables()
		{
			HarbingerAI component = HarbingerLoader.VoidHarbinger.enemyPrefab.GetComponent<HarbingerAI>();
			if ((Object)(object)component == (Object)null)
			{
				HarbingerLoader.mls.LogError((object)"Harbinger has not been create???");
				return;
			}
			if (SyncedInstance<Config>.Instance == null)
			{
				HarbingerLoader.mls.LogError((object)"Did not sync???");
				return;
			}
			if (SyncedInstance<Config>.Instance.HarbingerHealth == null)
			{
				HarbingerLoader.mls.LogError((object)"Health is not set...");
				HarbingerLoader.mls.LogError((object)("type: " + SyncedInstance<Config>.Instance));
				return;
			}
			HarbingerLoader.VoidHarbinger.MaxCount = SyncedInstance<Config>.Instance.MaxCount.Value;
			HarbingerLoader.VoidHarbinger.canDie = SyncedInstance<Config>.Instance.HarbingerCanDie.Value;
			((EnemyAI)component).enemyHP = SyncedInstance<Config>.Instance.HarbingerHealth.Value;
			component.CanTeleportSelf = SyncedInstance<Config>.Instance.CanTeleportSelf.Value;
			component.RandomTeleport = SyncedInstance<Config>.Instance.TeleportRandom.Value;
			component.teleportOnContact = SyncedInstance<Config>.Instance.TpOnHarbingerTouch.Value;
			component.CanCreateFractures = SyncedInstance<Config>.Instance.CanCreateFractures.Value;
			component.AllowedSimultaneousFractures = SyncedInstance<Config>.Instance.SimultaneousFractures.Value;
			component.CanTeleportSelf = SyncedInstance<Config>.Instance.CanTeleportSelf.Value;
			SpaceFractureEnemy component2 = HarbingerLoader.HarbingerFractur.GetComponent<SpaceFractureEnemy>();
			component2.NeededStunDuration = SyncedInstance<Config>.Instance.StunDuration.Value;
			((EnemyAI)component2).enemyType.stunGameDifficultyMultiplier = SyncedInstance<Config>.Instance.ShockDifficulty.Value;
			component2.dropChance = SyncedInstance<Config>.Instance.RealityFractureChance.Value;
			int num = SyncedInstance<Config>.Instance.MaxFractureValue.Value;
			int num2 = SyncedInstance<Config>.Instance.MinFractureValue.Value;
			if (SyncedInstance<Config>.Instance.MinFractureValue.Value > SyncedInstance<Config>.Instance.MaxFractureValue.Value)
			{
				int num3 = num;
				num = num2;
				num2 = num3;
			}
			HarbingerLoader.RealityFragment.minValue = num2;
			HarbingerLoader.RealityFragment.maxValue = num;
			HarbingerLoader.RealityFragment.weight = (float)SyncedInstance<Config>.Instance.FractureWeight.Value / 105f + 1f;
			((GrabbableObject)HarbingerLoader.RealityFragment.spawnPrefab.GetComponent<RealityFracture>()).useCooldown = SyncedInstance<Config>.Instance.FractureCooldown.Value;
			HarbingerLoader.RealityFragment.spawnPrefab.GetComponent<RealityFracture>().DamagePlayer = SyncedInstance<Config>.Instance.FractureDamageDelt.Value;
			HarbingerLoader.RealityFragment.spawnPrefab.GetComponent<RealityFracture>().CanBeUsed = SyncedInstance<Config>.Instance.CanUseItem.Value;
			HarbingerLoader.mls.LogInfo((object)("Item cooldown: " + ((GrabbableObject)HarbingerLoader.RealityFragment.spawnPrefab.GetComponent<RealityFracture>()).useCooldown));
			HarbingerLoader.mls.LogInfo((object)("Config Item  cooldown: " + ((GrabbableObject)HarbingerLoader.RealityFragment.spawnPrefab.GetComponent<RealityFracture>()).useCooldown));
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameNetworkManager), "StartDisconnect")]
		public static void PlayerLeave()
		{
			SyncedInstance<Config>.RevertSync();
		}
	}
	[Serializable]
	public class ConfigItem<T>
	{
		public T Value;

		[NonSerialized]
		public readonly ConfigEntry<T> entry;

		private ConfigItem()
		{
		}

		public ConfigItem(ConfigEntry<T> item)
		{
			entry = item;
			Value = item.Value;
		}

		public static implicit operator ConfigItem<T>(ConfigEntry<T> configEntry)
		{
			return new ConfigItem<T>(configEntry);
		}
	}
	[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;

		public static HarbingerLoader Inst;

		internal static ManualLogSource mls;

		public static AssetBundle HarbBundle;

		public static int SpawnWeight = 25;

		public static EnemyType VoidHarbinger;

		public static GameObject HarbingerFractur;

		public static Item RealityFragment;

		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");
			HarbingerFractur = HarbBundle.LoadAsset<GameObject>("Assets/LethalCompany/Mods/Harbinger/HarbingerFracture.prefab");
			RealityFragment = HarbBundle.LoadAsset<Item>("Assets/LethalCompany/Mods/Harbinger/RealityFractureItem.asset");
			if ((Object)(object)VoidHarbinger == (Object)null)
			{
				mls.LogError((object)"Harbinger Missing...");
			}
			if ((Object)(object)HarbingerFractur == (Object)null)
			{
				mls.LogError((object)"Fracture Missing...");
			}
			if ((Object)(object)RealityFragment == (Object)null)
			{
				mls.LogError((object)"Fragment Missing...");
			}
			harmony.PatchAll(typeof(HarbingerAI));
			harmony.PatchAll(typeof(SpaceFractureEnemy));
			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");
			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);
			NetworkPrefabs.RegisterNetworkPrefab(HarbingerFractur);
			NetworkPrefabs.RegisterNetworkPrefab(RealityFragment.spawnPrefab);
			Utilities.FixMixerGroups(RealityFragment.spawnPrefab);
			(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);
			Items.RegisterItem(RealityFragment);
		}

		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;
			if (Instance == null)
			{
				HarbingerLoader.mls.LogError((object)"SyncInstance: Deserialization failed, Instance is null.");
			}
			else
			{
				HarbingerLoader.mls.LogInfo((object)"SyncInstance: Successfully set Instance.");
			}
		}

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

		public static byte[] SerializeToBytes(T val)
		{
			try
			{
				string s = JsonUtility.ToJson((object)val);
				return Encoding.UTF8.GetBytes(s);
			}
			catch (Exception arg)
			{
				HarbingerLoader.mls.LogError((object)$"Error serializing instance: {arg}");
				return null;
			}
		}

		public static T DeserializeFromBytes(byte[] data)
		{
			try
			{
				string @string = Encoding.UTF8.GetString(data);
				HarbingerLoader.mls.LogError((object)("Recieved Json:" + @string));
				return JsonUtility.FromJson<T>(@string);
			}
			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,
			stunned
		}

		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;

		private NavMeshPath nPath;

		[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;

		public AudioSource GlobalClientSFXSource;

		[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;

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

		private float startTeleporItemTimer = 0f;

		[Header("Stuned")]
		public Material StunnMaterial;

		private float LastAnimationSpeed = 0f;

		private Material[] TempMaterial;

		public VisualEffect[] EffectsToPause;

		public Light[] LightsToTurnOff;

		public Rigidbody RigidStun;

		public CapsuleCollider RigidCollider;

		public Vector3 prestunTransform;

		public Quaternion prestunRot;

		public SkinnedMeshRenderer Smr;

		public GameObject harbingerMapNode;

		[Header("HarbingerFractures")]
		public GameObject FracturGameObject;

		public bool CanCreateFractures = true;

		public List<SpaceFractureEnemy> FractureRef;

		public int DestroyedFractures = 0;

		public int NumberOfFracturesToKill = 3;

		public int AllowedSimultaneousFractures = 3;

		private int MaxHealth = 3;

		[Header("Extra Configurations")]
		public bool RandomTeleport = false;

		public bool teleportOnContact = true;

		public bool CanTeleportSelf = true;

		[Header("Misc")]
		public AudioSource HarbingerHumSource;

		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)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Expected O, but got Unknown
			((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;
			NumberOfFracturesToKill = base.enemyHP;
			lastTeleportTime = Time.time;
			((Component)PositionBeforeSelfTeleport).transform.SetParent(((Component)((Component)this).transform).transform.parent);
			((Component)tpRing).transform.SetParent(((Component)((Component)this).transform).transform.parent);
			tpRing.HarbingerOwner = this;
			nPath = new NavMeshPath();
			MaxHealth = base.enemyHP;
			rigidDisableClientRpc();
			RefreshGrabbableObjectsInMapList();
			base.enemyHP = SyncedInstance<Config>.Instance.HarbingerHealth.Value;
			if (((NetworkBehaviour)RoundManager.Instance).IsHost)
			{
				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));
			}
		}

		[ClientRpc]
		public void rigidDisableClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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)
			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(1677967715u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1677967715u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					RigidStun.isKinematic = true;
					RigidStun.useGravity = false;
					prestunTransform = ((Component)RigidStun).transform.localPosition;
					prestunRot = ((Component)RigidStun).transform.localRotation;
				}
			}
		}

		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);
			if (!((NetworkBehaviour)RoundManager.Instance).IsHost)
			{
				((EnemyAI)this).OnDestroy();
				return;
			}
			while (FractureRef.Count > 0)
			{
				((EnemyAI)FractureRef[0]).KillEnemy(true);
				FractureRef.Remove(FractureRef[0]);
			}
			((EnemyAI)this).OnDestroy();
		}

		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_0195: 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_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_0370: Unknown result type (might be due to invalid IL or missing references)
			//IL_037b: 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 || state == HarbingerStates.stunned || base.isEnemyDead)
				{
					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 && CanTeleportSelf)
				{
					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_0126: 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_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: 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_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: 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_01ca: 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_0245: 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_02ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_031c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0322: Unknown result type (might be due to invalid IL or missing references)
			//IL_0337: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Update();
			if (base.isEnemyDead)
			{
				return;
			}
			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);
			}
			if (base.stunNormalizedTimer > 0f && state != HarbingerStates.stunned)
			{
				NewStateClientRpc(HarbingerStates.stunned);
				HarbingerLoader.mls.LogWarning((object)"In possition");
			}
			if (state != HarbingerStates.stunned && (Vector3.Distance(((Component)RigidStun).transform.localPosition, prestunTransform) > 0.001f || Quaternion.Angle(((Component)RigidStun).transform.localRotation, prestunRot) > 0.001f))
			{
				base.postStunInvincibilityTimer = 0.2f;
				((Component)RigidStun).transform.localPosition = Vector3.MoveTowards(((Component)RigidStun).transform.localPosition, prestunTransform, 0.5f * Time.deltaTime);
				((Component)RigidStun).transform.localRotation = Quaternion.RotateTowards(((Component)RigidStun).transform.localRotation, prestunRot, 120f * 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;
			case HarbingerStates.stunned:
				if (base.stunNormalizedTimer <= 0f)
				{
					NewStateClientRpc(HarbingerStates.Standing);
				}
				break;
			case HarbingerStates.TeleportItem:
				break;
			}
		}

		public void TeleportItem()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			if (LungProp is LungProp)
			{
				LungProp val = (LungProp)LungProp;
				if (val.isLungDocked)
				{
					EquipAppiClientRpc(((NetworkBehaviour)val).NetworkObjectId);
				}
				((GrabbableObject)val).ChangeOwnershipOfProp(((NetworkBehaviour)this).NetworkManager.LocalClient.ClientId);
				int num = TeleportRandom.Next(base.allAINodes.Length);
				bool flag = false;
				int num2 = 0;
				while (!flag && num2 < 10)
				{
					if (base.agent.CalculatePath(base.allAINodes[num].transform.position, nPath))
					{
						flag = true;
						continue;
					}
					num = TeleportRandom.Next(base.allAINodes.Length);
					num2++;
				}
				if (num2 == 10)
				{
					HarbingerLoader.mls.LogWarning((object)"Can't TP the Item");
				}
				if (flag)
				{
					TPItemClientRpc(((NetworkBehaviour)val).NetworkObjectId, num);
				}
			}
			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)
			{
				return;
			}
			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))
			{
				LungProp component = ((Component)NetworkManager.Singleton.SpawnManager.SpawnedObjects[Item]).GetComponent<LungProp>();
				if (component.isLungDocked)
				{
					MethodInfo methodInfo = AccessTools.Method(typeof(LungProp), "DisconnectFromMachinery", (Type[])null, (Type[])null);
					((MonoBehaviour)this).StartCoroutine((IEnumerator)methodInfo.Invoke(component, null));
					component.isLungDocked = false;
				}
			}
		}

		[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)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			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, false, default(Vector3));
				}
			}
		}

		[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_0218: 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_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0315: Unknown result type (might be due to invalid IL or missing references)
			//IL_031a: Unknown result type (might be due to invalid IL or missing references)
			//IL_032f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0334: Unknown result type (might be due to invalid IL or missing references)
			//IL_0336: Unknown result type (might be due to invalid IL or missing references)
			//IL_0355: Unknown result type (might be due to invalid IL or missing references)
			//IL_034d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0352: Unknown result type (might be due to invalid IL or missing references)
			//IL_037e: 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();
			}
			if (newstate == HarbingerStates.stunned && state == HarbingerStates.Teleporting && ((Behaviour)tpRing).enabled)
			{
				tpRing.Cancel();
			}
			if (state == HarbingerStates.stunned && newstate != HarbingerStates.stunned)
			{
				StunClientRpc(isStunned: false);
			}
			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;
				if (((NetworkBehaviour)RoundManager.Instance).IsHost)
				{
					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");
						NewStateClientRpc(HarbingerStates.Standing);
					}
				}
				break;
			case HarbingerStates.stunned:
				StunClientRpc(isStunned: true);
				break;
			}
		}

		[ClientRpc]
		public void StunClientRpc(bool isStunned)
		{
			//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_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			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(3324112327u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref isStunned, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3324112327u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			if (isStunned)
			{
				HarbingerLoader.mls.LogInfo((object)("Harbinger stunned for: " + base.stunNormalizedTimer * base.enemyType.stunTimeMultiplier));
				LastAnimationSpeed = base.creatureAnimator.speed;
				base.creatureAnimator.speed = 0f;
				base.agent.speed = 0f;
				Material[] materials = ((Renderer)Smr).materials;
				TempMaterial = (Material[])(object)new Material[materials.Length];
				materials.CopyTo(TempMaterial, 0);
				materials[0] = StunnMaterial;
				((Renderer)Smr).materials = materials;
				((Renderer)((Component)base.eye).GetComponent<MeshRenderer>()).enabled = false;
				EffectsToPause[2].Reinit();
				VisualEffect[] effectsToPause = EffectsToPause;
				foreach (VisualEffect val3 in effectsToPause)
				{
					val3.Stop();
				}
				Light[] lightsToTurnOff = LightsToTurnOff;
				foreach (Light val4 in lightsToTurnOff)
				{
					((Behaviour)val4).enabled = false;
				}
				if ((Object)(object)harbingerMapNode != (Object)null)
				{
					((Renderer)harbingerMapNode.GetComponent<MeshRenderer>()).enabled = false;
				}
				prestunTransform = ((Component)RigidStun).transform.localPosition;
				prestunRot = ((Component)RigidStun).transform.localRotation;
				HarbingerHumSource.Pause();
				RigidStun.isKinematic = false;
				RigidStun.useGravity = true;
				((MonoBehaviour)this).StopAllCoroutines();
			}
			else
			{
				base.agent.speed = movementspeed;
				((Renderer)Smr).materials = TempMaterial;
				if (((Renderer)Smr).materials != null)
				{
					((Renderer)Smr).materials[0].SetFloat("_Damage", 1f - (float)base.enemyHP / (float)MaxHealth);
				}
				((Renderer)((Component)base.eye).GetComponent<MeshRenderer>()).enabled = true;
				if ((Object)(object)harbingerMapNode != (Object)null)
				{
					((Renderer)harbingerMapNode.GetComponent<MeshRenderer>()).enabled = true;
				}
				VisualEffect[] effectsToPause2 = EffectsToPause;
				foreach (VisualEffect val5 in effectsToPause2)
				{
					val5.Play();
				}
				Light[] lightsToTurnOff2 = LightsToTurnOff;
				foreach (Light val6 in lightsToTurnOff2)
				{
					((Behaviour)val6).enabled = true;
				}
				base.creatureAnimator.speed = LastAnimationSpeed;
				HarbingerHumSource.Play();
				RigidStun.isKinematic = true;
				RigidStun.useGravity = false;
				((MonoBehaviour)this).StartCoroutine(RepositionTimeout());
			}
		}

		private IEnumerator RepositionTimeout()
		{
			yield return (object)new WaitForSeconds(15f);
			if (Vector3.Distance(((Component)RigidStun).transform.localPosition, prestunTransform) > 0.001f)
			{
				((Component)RigidStun).transform.localPosition = prestunTransform;
			}
		}

		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)
				{
					Vector3 LastPos = ((Component)this).transform.position;
					Quaternion LastRot = ((Component)this).transform.rotation;
					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;
					}
					if (CanCreateFractures)
					{
						CreateFracture(LastPos, LastRot, ((Component)this).transform.position);
					}
				}
				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 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_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: 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_002a: 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_0030: 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_0111: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			NavMeshHit result = default(NavMeshHit);
			int num = 0;
			bool flag = false;
			while (!flag && 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);
				if (((NavMeshHit)(ref result)).hit && base.allAINodes.Length != 0 && NavMesh.CalculatePath(((NavMeshHit)(ref result)).position, ((EnemyAI)this).ChooseClosestNodeToPosition(((NavMeshHit)(ref result)).position, false, 0).position, base.agent.areaMask, nPath))
				{
					flag = true;
				}
				else if (((NavMeshHit)(ref result)).hit && base.allAINodes.Length != 0)
				{
					HarbingerLoader.mls.LogWarning((object)"Harbinger cannot find any AI nodes to test movement against");
					flag = true;
				}
				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)
		{
			((EnemyAI)this).HitEnemy(force, playerWhoHit, playHitSFX, hitID);
			if (!((Object)(object)playerWhoHit == (Object)null) && ((NetworkBehaviour)playerWhoHit).IsOwner)
			{
				if (RandomTeleport)
				{
					RandomLocationTeleport(playerWhoHit);
				}
				else
				{
					PlayerToMonsterTeleport(playerWhoHit);
				}
			}
		}

		public static bool MonsterBlackList(EnemyAI toTest)
		{
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			if (toTest is SpaceFractureEnemy)
			{
				return false;
			}
			if (!HarbingerLoader.WhitelistNames.Contains("none"))
			{
				return MonsterWhiteList(toTest);
			}
			if ((Object)(object)toTest.agent == (Object)null)
			{
				return false;
			}
			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();
		}

		public void CreateFracture(Vector3 position, Quaternion rotation, Vector3 ExitPosition)
		{
			//IL_0019: 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_00af: 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)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			foreach (SpaceFractureEnemy item in FractureRef)
			{
				if (Vector3.Distance(position, ((Component)item).transform.position) < 10f)
				{
					return;
				}
			}
			if (AllowedSimultaneousFractures <= FractureRef.Count() && FractureRef.Count() != 0)
			{
				((EnemyAI)FractureRef[0]).thisNetworkObject.Despawn(true);
				FractureRef.RemoveAt(0);
			}
			GameObject val = Object.Instantiate<GameObject>(FracturGameObject, position, rotation, ((Component)this).transform.parent);
			val.GetComponent<NetworkObject>().Spawn(false);
			SpaceFractureEnemy component = val.GetComponent<SpaceFractureEnemy>();
			component.OwnedBy = this;
			component.ExitPosition = ExitPosition;
			FractureRef.Add(component);
		}

		public void FracturDestroyed(SpaceFractureEnemy DestroyedFracture)
		{
			FractureRef.Remove(DestroyedFracture);
			damageEffectClientRpc();
			HarbingerLoader.mls.LogMessage((object)("Harbinger Took damage: Destroyed: " + DestroyedFractures + "/" + NumberOfFracturesToKill));
			if (DestroyedFractures >= NumberOfFracturesToKill)
			{
				KillHarby();
			}
		}

		[ClientRpc]
		private void damageEffectClientRpc()
		{
			//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)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2853631173u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2853631173u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				DestroyedFractures++;
				base.enemyHP--;
				if (state != HarbingerStates.stunned && base.stunNormalizedTimer <= 0f && base.enemyType.canDie)
				{
					((Renderer)Smr).materials[0].SetFloat("_Damage", 1f - (float)base.enemyHP / (float)MaxHealth);
				}
			}
		}

		public void KillHarby()
		{
			if (base.enemyType.canDie)
			{
				HarbingerLoader.mls.LogMessage((object)"Harbinger has died");
				((EnemyAI)this).KillEnemyServerRpc(false);
				if (state == HarbingerStates.Teleporting)
				{
					endEffectsClientRPC();
				}
				StunClientRpc(isStunned: true);
				while (FractureRef.Count > 0)
				{
					((EnemyAI)FractureRef[0]).KillEnemy(true);
					FractureRef.Remove(FractureRef[0]);
				}
			}
		}

		[ClientRpc]
		public void endEffectsClientRPC()
		{
			//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(2384663069u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2384663069u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					tpRing.Cancel();
				}
			}
		}

		public void PlayerTouched(PlayerControllerB other)
		{
			if (((NetworkBehaviour)RoundManager.Instance).IsHost && teleportOnContact && state != HarbingerStates.stunned && base.enemyHP != 0)
			{
				if (RandomTeleport)
				{
					RandomLocationTeleport(other);
				}
				else
				{
					PlayerToMonsterTeleport(other);
				}
			}
		}

		public void RandomLocationTeleport(PlayerControllerB ToTP)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: 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)
			if (!((NetworkBehaviour)RoundManager.Instance).IsHost)
			{
				return;
			}
			for (int num = 5; num > 0; num--)
			{
				int num2 = TeleportRandom.Next(base.allAINodes.Length);
				Vector3 position = base.allAINodes[num2].transform.position;
				NavMeshHit val = FindMoveLocation(position, new Vector2(0.5f, 1f), 5);
				if (((NavMeshHit)(ref val)).hit)
				{
					if ((Object)(object)((Component)ToTP).GetComponent<PlayerControllerB>() != (Object)null)
					{
						TeleportPlayerClientRPC(ToTP.playerClientId, ((NavMeshHit)(ref val)).position);
					}
					break;
				}
			}
		}

		public void PlayerToMonsterTeleport(PlayerControllerB ToTP)
		{
			//IL_004f: 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_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: 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_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: 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_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: 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_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: 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_012e: 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_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: 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_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: 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_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			HarbingerLoader.mls.LogInfo((object)"Player teleport triggured");
			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)
				{
					TeleportPlayerClientRPC(ToTP.playerClientId, ((NavMeshHit)(ref val4)).position);
				}
				else
				{
					TeleportPlayerClientRPC(ToTP.playerClientId, ((EnemyAI)this).ChooseFarthestNodeFromPosition(mainEntrancePosition, false, 0, false, 50, false).position);
				}
			}
			else
			{
				TeleportPlayerClientRPC(ToTP.playerClientId, ((EnemyAI)this).ChooseFarthestNodeFromPosition(mainEntrancePosition, false, 0, false, 50, false).position);
			}
		}

		[ClientRpc]
		public void TeleportPlayerClientRPC(ulong playernum, Vector3 pos)
		{
			//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_0111: 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(1364620602u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, playernum);
				((FastBufferWriter)(ref val2)).WriteValueSafe(ref pos);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1364620602u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				PlayerControllerB val3 = StartOfRound.Instance.allPlayerScripts[playernum];
				if (((NetworkBehaviour)val3).IsOwner)
				{
					GlobalClientSFXSource.PlayOneShot(GlobalClientSFXSource.clip);
					((Component)val3).GetComponent<PlayerControllerB>().TeleportPlayer(pos, true, 0f, false, true);
				}
			}
		}

		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
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Expected O, but got Unknown
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Expected O, but got Unknown
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Expected O, but got Unknown
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Expected O, but got Unknown
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(1677967715u, new RpcReceiveHandler(__rpc_handler_1677967715));
			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(3324112327u, new RpcReceiveHandler(__rpc_handler_3324112327));
			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));
			NetworkManager.__rpc_func_table.Add(2853631173u, new RpcReceiveHandler(__rpc_handler_2853631173));
			NetworkManager.__rpc_func_table.Add(2384663069u, new RpcReceiveHandler(__rpc_handler_2384663069));
			NetworkManager.__rpc_func_table.Add(1364620602u, new RpcReceiveHandler(__rpc_handler_1364620602));
		}

		private static void __rpc_handler_1677967715(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).rigidDisableClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		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_3324112327(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)
			{
				bool isStunned = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref isStunned, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((HarbingerAI)(object)target).StunClientRpc(isStunned);
				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(