Decompiled source of Herobrine v1.3.5

BepInEx/plugins/HerobrineMod.dll

Decompiled a week 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.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using HerobrineMod.NetcodePatcher;
using Kittenji.HerobrineMod.Networking;
using Kittenji.HerobrineMod.Skins;
using Kittenji.HerobrineMod.Skins.Models;
using LethalConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using Steamworks;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Animations;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("Kittenji")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+af04c7ca169401da9be7c4113bd74fe3c59b6cf7")]
[assembly: AssemblyProduct("HerobrineMod")]
[assembly: AssemblyTitle("HerobrineMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Kittenji
{
	internal static class KUtility
	{
		internal static T InstantiateComponent<T>(string name, bool ddol = true) where T : Component
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			GameObject val = new GameObject(name);
			if (ddol)
			{
				Object.DontDestroyOnLoad((Object)(object)val);
				((Object)val).hideFlags = (HideFlags)61;
			}
			return val.AddComponent<T>();
		}

		internal static bool GetKey(Key key)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return ((ButtonControl)Keyboard.current[key]).isPressed;
		}

		internal static bool GetKeyDown(Key key)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return ((ButtonControl)Keyboard.current[key]).wasPressedThisFrame;
		}

		internal static bool GetKeyUp(Key key)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return ((ButtonControl)Keyboard.current[key]).wasReleasedThisFrame;
		}

		internal static IEnumerable<Type> GetAssemblyTypes()
		{
			try
			{
				return Assembly.GetExecutingAssembly().GetTypes();
			}
			catch (ReflectionTypeLoadException ex)
			{
				return ex.Types.Where((Type t) => t != null);
			}
		}

		[Conditional("DEBUG")]
		internal static void GenerateConfigTable(ConfigFile Config)
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.AppendLine("<details><summary>Available Config Variables</summary>");
			stringBuilder.AppendLine();
			stringBuilder.AppendLine("| Settings | Value Type | Default Value | Description | Acceptable Values |");
			stringBuilder.AppendLine("|-|-|-|-|-|");
			foreach (IGrouping<string, KeyValuePair<ConfigDefinition, ConfigEntryBase>> item in from v in (IEnumerable<KeyValuePair<ConfigDefinition, ConfigEntryBase>>)Config
				group v by v.Key.Section)
			{
				stringBuilder.AppendLine("| **" + item.Key + "** | - | - | - | - |");
				foreach (KeyValuePair<ConfigDefinition, ConfigEntryBase> item2 in item)
				{
					ConfigDefinition key = item2.Key;
					ConfigEntryBase value = item2.Value;
					stringBuilder.Append("| `");
					stringBuilder.Append(key.Key);
					stringBuilder.Append("` | `");
					stringBuilder.Append(value.SettingType.IsEnum ? "Enum" : value.SettingType.Name);
					stringBuilder.Append("` | ");
					string value2 = value.DefaultValue.ToString();
					if (string.IsNullOrEmpty(value2))
					{
						stringBuilder.Append('-');
					}
					else
					{
						stringBuilder.Append('`');
						stringBuilder.Append(value2);
						stringBuilder.Append('`');
					}
					stringBuilder.Append(" | ");
					stringBuilder.Append(Regex.Replace(value.Description.Description, "\\r\\n?|\\n", "<br>"));
					stringBuilder.Append(" |");
					if (value.SettingType.IsEnum)
					{
						string[] names = Enum.GetNames(value.SettingType);
						foreach (string text in names)
						{
							stringBuilder.Append(" `" + text + "`");
						}
					}
					else if (value.Description.AcceptableValues != null)
					{
						if (value.Description.AcceptableValues is AcceptableValueList<string> val)
						{
							string[] names = val.AcceptableValues;
							foreach (string text2 in names)
							{
								stringBuilder.Append(" `" + text2 + "`");
							}
						}
					}
					else
					{
						stringBuilder.Append(" -");
					}
					stringBuilder.AppendLine(" |");
				}
			}
			stringBuilder.AppendLine();
			stringBuilder.AppendLine("</details>");
			File.WriteAllText(Config.ConfigFilePath.TrimEnd('\\', '/') + ".md", stringBuilder.ToString());
		}
	}
	internal static class NavMeshUtils
	{
		private const string ColorProperty = "_Color";

		public static void Update(int index, NavMeshPath navMeshPath)
		{
		}
	}
	internal class CompatibleDependencyAttribute : BepInDependency
	{
		public Type Handler;

		public CompatibleDependencyAttribute(string guid, Type handlerType)
			: base(guid, (DependencyFlags)2)
		{
			Handler = handlerType;
		}

		public static void Init(BaseUnityPlugin source)
		{
			foreach (CompatibleDependencyAttribute customAttribute in ((MemberInfo)((object)source).GetType()).GetCustomAttributes<CompatibleDependencyAttribute>())
			{
				if (Chainloader.PluginInfos.ContainsKey(((BepInDependency)customAttribute).DependencyGUID))
				{
					customAttribute.Handler.GetMethod("Initialize", BindingFlags.Static | BindingFlags.NonPublic)?.Invoke(null, null);
					customAttribute.Handler = null;
				}
			}
		}
	}
	internal static class LethalConfigUtils
	{
		internal const string GUID = "ainavt.lc.lethalconfig";

		internal static bool Enabled;

		private static void Initialize()
		{
			Enabled = true;
			Debug.Log((object)"Compatibility initialized for Lethal Config.");
		}

		public static ConfigEntry<int> Register(this ConfigEntry<int> entry, int min, int max, bool requireRestart = false)
		{
			AddSlider(entry, min, max, requireRestart);
			return entry;
		}

		public static ConfigEntry<int> Register(this ConfigEntry<int> entry, bool requireRestart = false)
		{
			AddInt(entry, requireRestart);
			return entry;
		}

		public static ConfigEntry<bool> Register(this ConfigEntry<bool> entry, bool requireRestart = false)
		{
			AddToggle(entry, requireRestart);
			return entry;
		}

		public static ConfigEntry<string> Register(this ConfigEntry<string> entry, bool requireRestart = false)
		{
			AddTextInput(entry, requireRestart);
			return entry;
		}

		public static void AddSlider(ConfigEntry<int> entry, int min, int max, bool requireRestart = false)
		{
			if (Enabled)
			{
				AddSliderInternal(entry, min, max, requireRestart);
			}
		}

		public static void AddInt(ConfigEntry<int> entry, bool requireRestart = false)
		{
			if (Enabled)
			{
				AddIntInternal(entry, requireRestart);
			}
		}

		public static void AddToggle(ConfigEntry<bool> entry, bool requireRestart = false)
		{
			if (Enabled)
			{
				AddToggleInternal(entry, requireRestart);
			}
		}

		public static void AddTextInput(ConfigEntry<string> entry, bool requireRestart = false)
		{
			if (Enabled)
			{
				AddTextInputInternal(entry, requireRestart);
			}
		}

		public static void AddButton(Action buttonAction, string section, string name, string description, string buttonText)
		{
			if (Enabled)
			{
				AddButtonInternal(buttonAction, section, name, description, buttonText);
			}
		}

		private static void AddSliderInternal(ConfigEntry<int> entry, int min, int max, bool requireRestart = false)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0020: Expected O, but got Unknown
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			IntSliderOptions val = new IntSliderOptions
			{
				RequiresRestart = requireRestart
			};
			((BaseRangeOptions<int>)val).Min = min;
			((BaseRangeOptions<int>)val).Max = max;
			LethalConfigManager.AddConfigItem((BaseConfigItem)new IntSliderConfigItem(entry, val));
		}

		private static void AddIntInternal(ConfigEntry<int> entry, bool requireRestart = false)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			LethalConfigManager.AddConfigItem((BaseConfigItem)new IntInputFieldConfigItem(entry, requireRestart));
		}

		private static void AddToggleInternal(ConfigEntry<bool> entry, bool requireRestart = false)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(entry, requireRestart));
		}

		private static void AddTextInputInternal(ConfigEntry<string> entry, bool requireRestart = false)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			LethalConfigManager.AddConfigItem((BaseConfigItem)new TextInputFieldConfigItem(entry, requireRestart));
		}

		private static void AddButtonInternal(Action buttonAction, string section, string name, string description, string buttonText)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			LethalConfigManager.AddConfigItem((BaseConfigItem)new GenericButtonConfigItem(section, name, description, buttonText, (GenericButtonHandler)delegate
			{
				buttonAction?.Invoke();
			}));
		}
	}
	internal static class NetcodeUtils
	{
		private static class Patch
		{
			internal static bool IsPatched;

			[HarmonyPatch(typeof(GameNetworkManager), "Start")]
			[HarmonyPostfix]
			[HarmonyWrapSafe]
			private static void StartPatch()
			{
				foreach (GameObject prefab in m_Prefabs)
				{
					if (!NetworkManager.Singleton.NetworkConfig.Prefabs.Contains(prefab))
					{
						NetworkManager.Singleton.AddNetworkPrefab(prefab);
					}
				}
			}
		}

		private static HashSet<GameObject> m_Prefabs = new HashSet<GameObject>();

		internal static void InitNetcode(Harmony harmony)
		{
			foreach (Type assemblyType in KUtility.GetAssemblyTypes())
			{
				MethodInfo[] methods = assemblyType.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				foreach (MethodInfo methodInfo in methods)
				{
					try
					{
						if (methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false).Length != 0)
						{
							methodInfo.Invoke(null, null);
						}
					}
					catch (FileNotFoundException)
					{
					}
				}
			}
			if (!Patch.IsPatched && harmony != null)
			{
				harmony.PatchAll(typeof(Patch));
				Patch.IsPatched = true;
			}
		}

		internal static void RegisterNetworkPrefab(GameObject prefab)
		{
			if (!m_Prefabs.Contains(prefab))
			{
				m_Prefabs.Add(prefab);
			}
		}

		internal static void RegisterNetworkPrefab(this EnemyType enemyType)
		{
			RegisterNetworkPrefab(enemyType.enemyPrefab);
		}

		internal static void RegisterNetworkPrefab(this Item item)
		{
			RegisterNetworkPrefab(item.spawnPrefab);
		}
	}
	internal static class ResourceUtils
	{
		internal static Stream Get(string name)
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			string[] manifestResourceNames = executingAssembly.GetManifestResourceNames();
			if (manifestResourceNames.Length == 0)
			{
				throw new FileNotFoundException("Assembly does not contain any resource stream names.");
			}
			string text = manifestResourceNames.FirstOrDefault((string n) => n.EndsWith(name));
			if (string.IsNullOrEmpty(text))
			{
				throw new FileNotFoundException("Assembly does not contain a resource stream ending with '" + name + "'");
			}
			return executingAssembly.GetManifestResourceStream(text);
		}

		internal static string GetString(string name)
		{
			using Stream stream = Get(name);
			using StreamReader streamReader = new StreamReader(stream);
			return streamReader.ReadToEnd();
		}
	}
	internal class Assets
	{
		private readonly AssetBundle mainAssetBundle;

		private readonly string[] allAssetNames;

		internal Assets(string name = ".bundle")
		{
			mainAssetBundle = AssetBundle.LoadFromStream(ResourceUtils.Get(name));
			allAssetNames = mainAssetBundle.GetAllAssetNames();
		}

		public T Load<T>(string name) where T : Object
		{
			if (name == null)
			{
				return default(T);
			}
			return mainAssetBundle.LoadAsset<T>(name);
		}

		public T LoadByName<T>(string name, bool nameOnly = false) where T : Object
		{
			string name2 = allAssetNames.FirstOrDefault((string x) => (nameOnly ? Path.GetFileNameWithoutExtension(x) : Path.GetFileName(x)).Equals(name, StringComparison.OrdinalIgnoreCase));
			return Load<T>(name2);
		}
	}
	internal class DynamicEnemyWithRarity : SpawnableEnemyWithRarity
	{
		public ConfigEntry<int> Multiplier;

		public ConfigEntry<int> ConfigEntry { get; private set; }

		public static DynamicEnemyWithRarity From(ConfigEntry<int> config, EnemyType enemyDef, ConfigEntry<int> mult = null)
		{
			DynamicEnemyWithRarity dynamicEnemyWithRarity = new DynamicEnemyWithRarity
			{
				enemyType = enemyDef,
				ConfigEntry = config,
				Multiplier = mult
			};
			dynamicEnemyWithRarity.OnChanged(null, null);
			config.SettingChanged += dynamicEnemyWithRarity.OnChanged;
			if (mult != null)
			{
				mult.SettingChanged += dynamicEnemyWithRarity.OnChanged;
			}
			return dynamicEnemyWithRarity;
		}

		private void OnChanged(object sender, EventArgs args)
		{
			base.rarity = Mathf.Max(0, ConfigEntry.Value);
			if (Multiplier != null)
			{
				base.rarity *= Multiplier.Value;
			}
		}
	}
	internal static class Log
	{
		internal static ManualLogSource Source { get; set; }

		internal static void Print(LogLevel level, object message)
		{
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Invalid comparison between Unknown and I4
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Invalid comparison between Unknown and I4
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected I4, but got Unknown
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Invalid comparison between Unknown and I4
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Invalid comparison between Unknown and I4
			if (Source == null)
			{
				if ((int)level <= 16)
				{
					switch ((int)level)
					{
					default:
						if ((int)level != 16)
						{
							break;
						}
						Debug.Log(message);
						return;
					case 1:
						Debug.LogError(message);
						return;
					case 2:
						Debug.LogError(message);
						return;
					case 4:
						Debug.LogWarning(message);
						return;
					case 8:
						Debug.Log(message);
						return;
					case 3:
					case 5:
					case 6:
					case 7:
						break;
					case 0:
						return;
					}
				}
				else
				{
					if ((int)level == 32)
					{
						Debug.Log(message);
						return;
					}
					if ((int)level == 63)
					{
						Debug.Log(message);
						return;
					}
				}
				Debug.Log(message);
			}
			else
			{
				Source.Log(level, message);
			}
		}

		public static void Fatal(object data)
		{
			Print((LogLevel)1, data);
		}

		public static void Error(object data)
		{
			Print((LogLevel)2, data);
		}

		public static void Warning(object data)
		{
			Print((LogLevel)4, data);
		}

		public static void Message(object data)
		{
			Print((LogLevel)8, data);
		}

		public static void Info(object data)
		{
			Print((LogLevel)16, data);
		}

		[Conditional("DEBUG")]
		public static void Debug(object data)
		{
			Print((LogLevel)32, data);
		}
	}
}
namespace Kittenji.HerobrineMod
{
	public class FortressLock : MonoBehaviour
	{
		public Transform stareLocation;

		public GameObject leavingEffect;

		public Transform spawnPoint;

		public Transform warpTarget;

		public Transform warpLimit;

		public Transform trackedObject;

		public Transform trackedHead;

		private Transform lockedTransform;

		private PlayerControllerB lockedPlayer;

		private Vector3 originLocation;

		private bool originInside;

		private float startTimestamp;

		private GameObject stareObject;

		private bool hasBeenLocked;

		public static FortressLock Instance { get; private set; }

		private void Awake()
		{
			stareObject = ((Component)stareLocation).gameObject;
		}

		public static bool LockPlayer(PlayerControllerB player)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Instance == (Object)null)
			{
				GameObject obj = Object.Instantiate<GameObject>(Plugin.FortressPrefab);
				obj.transform.position = new Vector3(500f, -500f, 100f);
				Instance = obj.GetComponent<FortressLock>();
			}
			if (Instance.hasBeenLocked)
			{
				return false;
			}
			Instance.SetLockedPlayer(player);
			return true;
		}

		private void OnDestroy()
		{
			ReleaseLockedPlayer(returnPlayer: false);
		}

		private void SetLockedPlayer(PlayerControllerB player)
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)player == (Object)null || player.isPlayerDead)
			{
				ReleaseLockedPlayer(returnPlayer: false);
				return;
			}
			player.DropAllHeldItemsAndSync();
			hasBeenLocked = true;
			((Component)Instance).gameObject.SetActive(hasBeenLocked);
			lockedPlayer = player;
			lockedTransform = ((Component)lockedPlayer).transform;
			originLocation = lockedTransform.position;
			originInside = lockedPlayer.isInsideFactory;
			HerobrineAI.TryRelocatePlayer(player, spawnPoint.position, isInside: true);
			player.TeleportPlayer(spawnPoint.position, true, spawnPoint.eulerAngles.y, false, true);
			startTimestamp = Time.time + 3f;
			HideMonster(value: false);
		}

		private void ReleaseLockedPlayer(bool returnPlayer)
		{
			//IL_0047: 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_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)lockedPlayer != (Object)null)
			{
				if (returnPlayer)
				{
					lockedPlayer.takingFallDamage = false;
					lockedPlayer.fallValue = 0f;
					lockedPlayer.fallValueUncapped = 0f;
					HerobrineAI.TryRelocatePlayer(lockedPlayer, originLocation, originInside);
					lockedPlayer.TeleportPlayer(originLocation, true, Random.Range(-180f, 180f), false, true);
					Object.Instantiate<GameObject>(leavingEffect, originLocation, Quaternion.identity);
				}
				lockedPlayer = null;
				lockedTransform = null;
			}
			((Component)Instance).gameObject.SetActive(false);
		}

		public void Update()
		{
			//IL_004e: 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_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: 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_01b8: 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_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: 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_008c: 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_00aa: 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_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: 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_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)lockedTransform == (Object)null || (Object)(object)lockedPlayer == (Object)null || lockedPlayer.isInHangarShipRoom)
			{
				((Component)Instance).gameObject.SetActive(false);
			}
			else
			{
				if (lockedPlayer.isPlayerDead)
				{
					return;
				}
				Vector3 position = lockedTransform.position;
				if (stareObject.activeSelf && Vector3.Distance(position, stareLocation.position) < 2f)
				{
					if (Time.time < startTimestamp)
					{
						lockedPlayer.KillPlayer(Vector3.up * 100f, true, (CauseOfDeath)0, Mathf.Max(Plugin.RagdollIndex, 0), default(Vector3));
					}
					HideMonster(value: true);
				}
				if (position.z > warpLimit.position.z && stareObject.activeSelf)
				{
					Vector3 velocity = lockedPlayer.playerRigidbody.velocity;
					float num = lockedTransform.eulerAngles.y;
					bool num2 = Vector3.Dot(Vector3.forward, lockedTransform.forward) < 0f;
					if (num2)
					{
						num += 180f;
						position.x += (warpLimit.position.x - position.x) * 2f;
					}
					position.z -= warpLimit.position.z - warpTarget.position.z;
					WarpTo(position, num);
					if (num2)
					{
						lockedPlayer.playerRigidbody.velocity = new Vector3(0f - velocity.x, velocity.y, 0f - velocity.z);
					}
				}
				if (position.y < warpLimit.position.y)
				{
					ReleaseLockedPlayer(returnPlayer: true);
					return;
				}
				trackedObject.position = position;
				trackedHead.position = ((Component)lockedPlayer.gameplayCamera).transform.position;
			}
		}

		private void HideMonster(bool value)
		{
			stareObject.SetActive(!value);
			leavingEffect.SetActive(value);
		}

		private void WarpTo(Vector3 pos, float yRot)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: 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_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: 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_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)
			Transform transform = ((Component)lockedPlayer).transform;
			Transform localVisor = lockedPlayer.localVisor;
			Vector3 val = transform.InverseTransformPoint(localVisor.position);
			Vector3 val2 = transform.InverseTransformVector(localVisor.forward);
			transform.position = pos;
			transform.rotation = Quaternion.Euler(0f, yRot, 0f);
			localVisor.position = transform.TransformPoint(val);
			localVisor.forward = transform.TransformVector(val2);
		}
	}
	public class ParticleCallback : MonoBehaviour
	{
		public interface ICallbackReceiver
		{
			void OnPartTrigger();
		}

		private ICallbackReceiver Receiver;

		private void Awake()
		{
			Receiver = ((Component)this).gameObject.GetComponentInParent<ICallbackReceiver>();
		}

		private void OnParticleTrigger()
		{
			Receiver.OnPartTrigger();
		}
	}
	public class HerobrineMinion : MonoBehaviour, ParticleCallback.ICallbackReceiver
	{
		public static HerobrineMinion Instance;

		public NavMeshAgent Agent;

		public Transform Trigger;

		public PlayerControllerB Target;

		[Header("Fire Audio")]
		public AudioSource FireAudio;

		public AudioClip FireClip;

		public Vector2 MinMaxPitch = new Vector2(0.9f, 1.2f);

		public Vector2 MinMaxTimer = new Vector2(0.3f, 1.5f);

		private float FireTimer;

		[Header("Other Audio")]
		public AudioSource HurtAudio;

		public AudioClip[] HurtClips;

		public ParticleSystem Particles;

		public float HurtInterval;

		private float HurtTimer;

		public Vector2 ChaseTimer = new Vector2(4f, 8f);

		public float Interval = 0.2f;

		private float Timer;

		private float Timeout;

		private bool IsChasing;

		private bool IsPlayerValid
		{
			get
			{
				if (Object.op_Implicit((Object)(object)Target) && Target.isPlayerControlled)
				{
					return !Target.isPlayerDead;
				}
				return false;
			}
		}

		public static bool Instantiate(Vector3 position, PlayerControllerB target)
		{
			//IL_0043: 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)
			if (!Object.op_Implicit((Object)(object)Instance))
			{
				Instance = Object.Instantiate<GameObject>(Plugin.assets.LoadByName<GameObject>("FireAgent.prefab", nameOnly: false)).GetComponent<HerobrineMinion>();
			}
			if (Instance.IsChasing)
			{
				return false;
			}
			((Component)Instance).transform.position = position;
			Instance.Warp(position);
			Instance.Target = target;
			return true;
		}

		public static void OnDestroy()
		{
			if (Object.op_Implicit((Object)(object)Instance))
			{
				Object.Destroy((Object)(object)((Component)Instance).gameObject);
				Instance = null;
			}
		}

		private void Awake()
		{
			Instance = this;
		}

		public void Warp(Vector3 position)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			((Behaviour)Agent).enabled = true;
			Agent.Warp(position);
			IsChasing = true;
			Particles.Play();
			Timeout = Time.time + Random.Range(ChaseTimer.x, ChaseTimer.y);
		}

		private void Update()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			if (IsPlayerValid)
			{
				Trigger.position = ((Component)Target).transform.position;
				Trigger.rotation = ((Component)Target).transform.rotation;
				if (IsChasing)
				{
					if (Timer < Time.time)
					{
						Timer = Time.time + Interval;
						Agent.SetDestination(Trigger.position);
					}
					if (FireTimer < Time.time)
					{
						FireTimer = Time.time + Random.Range(MinMaxTimer.x, MinMaxTimer.y);
						FireAudio.pitch = Random.Range(MinMaxPitch.x, MinMaxPitch.y);
						FireAudio.PlayOneShot(FireClip);
					}
				}
			}
			if (IsChasing && (Vector3.Distance(Trigger.position, ((Component)this).transform.position) < 0.7f || Timeout < Time.time || !IsPlayerValid))
			{
				IsChasing = false;
				((Behaviour)Agent).enabled = false;
				Particles.Stop();
				FireAudio.Stop();
				if (Timeout > Time.time && IsPlayerValid)
				{
					HurtAudio.PlayOneShot(HurtClips[Random.Range(0, HurtClips.Length)]);
					Target.DamagePlayer(6, true, true, (CauseOfDeath)0, Mathf.Max(Plugin.RagdollIndex, 0), false, default(Vector3));
				}
			}
		}

		public void OnPartTrigger()
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			if (IsPlayerValid && HurtTimer < Time.time)
			{
				HurtTimer = Time.time + HurtInterval;
				HurtAudio.PlayOneShot(HurtClips[Random.Range(0, HurtClips.Length)]);
				Target.DamagePlayer(2, true, true, (CauseOfDeath)0, Mathf.Max(Plugin.RagdollIndex, 0), false, default(Vector3));
			}
		}
	}
	public class HerobrineAI : EnemyAI
	{
		private static ManualLogSource Logger;

		public static int LastHauntedID = -1;

		[Header("Custom Entity")]
		public Transform[] VisiblePoints;

		public HerobrineTracker Tracker;

		public SkinnedMeshRenderer MainRenderer;

		public Material MainMaterial;

		public Material SkinMaterial;

		public Vector4 AgentSpeeds = new Vector4(5.3f, 8f, 4f, 10f);

		public AudioClip[] HitAudioClips;

		public string[] SignalMessages = new string[17]
		{
			"U ARE DEAD", "I SEE YOU", "NOT SORRY", "GO AHEAD", "TRY N HIDE", "NO ESCAPE?", "NOT SAFE", "WHY RUN?", "DEAD MAN", "JESTER",
			"NO", "HELPLESS", "HOPELESS", "ENDLESS", "SCARED?", "RUN", "LOOK BHU"
		};

		private SignalTranslator signalTranslator;

		[Header("Jumpscare Stuff")]
		public Vector2Int JumpSRarity = new Vector2Int(100, 100);

		public GameObject JumpSPrefab;

		public Material[] JumpSMaterials;

		public Vector2 JumpSDuration = new Vector2(0.2f, 0.4f);

		public AudioClip[] JumpSClips;

		private GameObject JumpSInstance;

		private SkinnedMeshRenderer JumpSRenderer;

		private Coroutine JumpSCoroutine;

		private float JumpSTime;

		[Header("Entity Rig")]
		public BoxCollider EntityHitbox;

		public ScanNodeProperties ScanNodeProps;

		public BoxCollider ScanNodeHitbox;

		public Vector4 ScanNodeIntervals = new Vector4(0.01f, 0.3f, 0f, 0f);

		public Transform EntityHead;

		public Transform EntityBody;

		public LookAtConstraint EntityLookAt;

		public Transform TurnCompass;

		public StateInfo[] StateInfos;

		[Header("Audio Clips")]
		public AudioSource AudioSFX;

		[Header("Dialogs")]
		public DialogMessages[] Dialogs;

		private static Dictionary<string, DialogMessages> NameToDialog;

		private bool lastVisibility;

		private bool isHauntingLocal;

		private bool isUsingPlayerSkin;

		private bool isInCompanyBuilding;

		public GameObject antiCheatObj;

		private float lastTargetRequestServer;

		private bool isNextTarget;

		private int lastTargetIndex = -1;

		private bool lastTargetWasRequested;

		private Coroutine waitForInitCr;

		private int stateActionCounter;

		private float stateActionTimer;

		private float stateActionTimeout;

		private float stateActionBoost;

		private bool seenByPlayer;

		private bool stateBusy;

		private bool stareFailed;

		private int totalTimesSeen;

		private float stateStartTime;

		private StateInfo currentStateInfo;

		private const float playerFOV = 60f;

		private bool effectNextFrame;

		private bool insideLastFrame;

		private float currentAgentSpeed;

		private NavMeshPath navMeshPath;

		private Texture2D lastSkinTex;

		private bool lastSkinSlim;

		public PlayerControllerB hauntingPlayer;

		private MinecraftPlayerNetworking minecraftPlayer;

		private bool hauntingLocalPlayer;

		private GameObject[] outsideNodes;

		private NavMeshHit navHit;

		private bool IsInitialized;

		private EntranceTeleport[] entranceList;

		private Transform currentExit;

		private NavMeshPath entrancePath;

		private float currentDist;

		private float traversedDist;

		private bool findingExit;

		private Vector3 currentPoint;

		private bool isNavStuck;

		private float navTimeout;

		private bool playerReceivedDamage;

		public string[] excludeTpEnemies;

		private static EntranceTeleport EntranceTP_Outside;

		private static EntranceTeleport EntranceTP_Inside;

		private static readonly int[] TPWeights = new int[5] { 96, 80, 20, 20, 20 };

		private static Dictionary<ulong, int> FriendWeights;

		private bool hasSignalTranslator => (Object)(object)signalTranslator != (Object)null;

		public PlayerControllerB PlayerSpawnedBy { get; set; }

		private float stateTime => Time.time - stateStartTime;

		private void JumpSAwake()
		{
			if (JumpSCoroutine == null)
			{
				JumpSCoroutine = ((MonoBehaviour)this).StartCoroutine(JumpSAction(Random.Range(JumpSDuration.x, JumpSDuration.y)));
			}
		}

		private IEnumerator JumpSAction(float duration)
		{
			if (!Object.op_Implicit((Object)(object)JumpSInstance))
			{
				JumpSInstance = Object.Instantiate<GameObject>(JumpSPrefab);
				JumpSRenderer = JumpSInstance.GetComponentInChildren<SkinnedMeshRenderer>(true);
			}
			JumpSTime = Time.time + duration;
			((Renderer)JumpSRenderer).sharedMaterial = JumpSMaterials[Random.Range(0, JumpSMaterials.Length)];
			JumpSInstance.SetActive(true);
			StateInfo.PlayRandomClipAt(AudioSFX, JumpSClips);
			while (Time.time < JumpSTime)
			{
				JumpSInstance.transform.position = ((Component)hauntingPlayer).transform.position + ((Component)hauntingPlayer).transform.forward;
				JumpSInstance.transform.forward = -((Component)hauntingPlayer).transform.forward * 1.8f;
				yield return null;
			}
			JumpSInstance.SetActive(false);
			JumpSCoroutine = null;
		}

		private void SendDialog(string name, string tag = null)
		{
			if (NameToDialog == null)
			{
				NameToDialog = new Dictionary<string, DialogMessages>();
				DialogMessages[] dialogs = Dialogs;
				foreach (DialogMessages dialogMessages in dialogs)
				{
					NameToDialog[((Object)dialogMessages).name] = dialogMessages;
				}
			}
			SendChatMessage(NameToDialog[name].GetRandom(tag));
		}

		public override void OnDestroy()
		{
			((EnemyAI)this).OnDestroy();
			HerobrineMinion.OnDestroy();
			if (Object.op_Implicit((Object)(object)antiCheatObj))
			{
				Object.Destroy((Object)(object)antiCheatObj);
			}
		}

		private void Awake()
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected O, but got Unknown
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_00cd: 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_00f7: Unknown result type (might be due to invalid IL or missing references)
			if (Logger == null)
			{
				Logger = new ManualLogSource("HerobrineAI");
				Logger.Sources.Add((ILogSource)(object)Logger);
			}
			Logger.LogInfo((object)"Removed Herobrine");
			entrancePath = new NavMeshPath();
			navMeshPath = new NavMeshPath();
			isInCompanyBuilding = Object.op_Implicit((Object)(object)StartOfRound.Instance) && Object.op_Implicit((Object)(object)StartOfRound.Instance.currentLevel) && StartOfRound.Instance.currentLevel.sceneName == "CompanyBuilding";
			if (isInCompanyBuilding)
			{
				Logger.LogInfo((object)"In company building..");
			}
			RedstoneTorchProp.wasSpawnedThisRound = true;
			signalTranslator = Object.FindObjectOfType<SignalTranslator>();
			antiCheatObj.transform.parent = null;
			antiCheatObj.transform.position = Vector3.zero;
			antiCheatObj.transform.rotation = Quaternion.identity;
			antiCheatObj.transform.localScale = Vector3.one;
			antiCheatObj.SetActive(false);
		}

		private void SpawnEffectByIndex(Vector3 pos, int index, bool sync = false)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)minecraftPlayer))
			{
				minecraftPlayer.SpawnEffectByIndex(pos, index, sync);
			}
		}

		[ServerRpc]
		private void RequestNewTargetServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Invalid comparison between Unknown and I4
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Invalid comparison between Unknown and I4
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1054030038u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1054030038u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				Logger.LogInfo((object)"Herobrine wants a new target to haunt.");
				SetNewTargetOnServer(requested: true);
			}
		}

		private void SetNewTargetOnServer(bool requested)
		{
			if (!((NetworkBehaviour)this).IsServer || Time.unscaledTime < lastTargetRequestServer)
			{
				return;
			}
			Logger.LogInfo((object)"Requesting new target.");
			float num = 0f;
			int num2 = 0;
			int num3 = 0;
			int num4 = 0;
			PlayerStats[] allPlayerStats = StartOfRound.Instance.gameStats.allPlayerStats;
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			int num5 = Mathf.Min(allPlayerStats.Length, allPlayerScripts.Length);
			for (int i = 0; i < num5; i++)
			{
				if (allPlayerStats[i].turnAmount > num2)
				{
					num2 = allPlayerStats[i].turnAmount;
					num3 = i;
				}
				if (allPlayerScripts[i].insanityLevel > num)
				{
					num = allPlayerScripts[i].insanityLevel;
					num4 = i;
				}
			}
			int[] array = new int[num5];
			for (int i = 0; i < num5; i++)
			{
				PlayerControllerB val = allPlayerScripts[i];
				if (!val.isPlayerControlled || val.isPlayerDead)
				{
					array[i] = 0;
					continue;
				}
				if (Object.op_Implicit((Object)(object)PlayerSpawnedBy) && PlayerSpawnedBy.isPlayerControlled && !PlayerSpawnedBy.isPlayerDead)
				{
					array[i] = (((Object)(object)PlayerSpawnedBy == (Object)(object)val) ? 100 : 0);
					continue;
				}
				array[i] += 100;
				if (num4 == i && num > 1f)
				{
					array[i] += 15;
				}
				if (num3 == i)
				{
					array[i] += 10;
				}
				if (val.hasBeenCriticallyInjured)
				{
					array[i] += 10;
				}
				if ((Object)(object)val.currentlyHeldObjectServer != (Object)null && val.currentlyHeldObjectServer.scrapValue > 150)
				{
					array[i] += 24;
				}
				if ((Object)(object)val.currentlyHeldObjectServer != (Object)null && (Object)(object)val.currentlyHeldObjectServer.itemProperties == (Object)(object)Plugin.ItemDef)
				{
					array[i] += 250;
				}
				if (!val.isInHangarShipRoom)
				{
					array[i] += 20;
				}
				if (val.isInsideFactory)
				{
					array[i] += 30;
				}
				if (!requested && LastHauntedID == (int)val.playerClientId)
				{
					array[i] = 1;
				}
				if (requested && lastTargetIndex == i)
				{
					array[i] = 1;
				}
				int friendWeights = GetFriendWeights(val.playerSteamId);
				if (friendWeights != 0)
				{
					Logger.LogMessage((object)$"Adding weight of '{friendWeights}' to friend '{val.playerUsername}'");
					array[i] += friendWeights;
				}
				array[i] = Mathf.Max(0, array[i]);
			}
			int num6 = GetRandomIndexFromWeights(array);
			hauntingPlayer = allPlayerScripts[num6];
			if (hauntingPlayer.isPlayerDead)
			{
				for (int j = 0; j < allPlayerScripts.Length; j++)
				{
					if (!allPlayerScripts[j].isPlayerDead)
					{
						hauntingPlayer = allPlayerScripts[j];
						num6 = j;
						break;
					}
				}
			}
			if (hauntingPlayer.isPlayerControlled)
			{
				lastTargetIndex = num6;
				SyncNewTargetClientRpc((int)hauntingPlayer.playerClientId, requested);
				if (!isNextTarget)
				{
					LastHauntedID = num6;
					isNextTarget = true;
				}
			}
			else
			{
				Logger.LogWarning((object)"Could not find a target player.");
			}
			lastTargetRequestServer = Time.unscaledTime + 10f;
		}

		[ClientRpc]
		internal void SyncNewTargetClientRpc(int id, bool isReq)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			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(1096127661u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, id);
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref isReq, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1096127661u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				lastTargetWasRequested = isReq;
				Logger.LogInfo((object)("Received target from server: " + id));
				hauntingPlayer = StartOfRound.Instance.allPlayerScripts[id];
				minecraftPlayer = ((Component)hauntingPlayer).GetComponent<MinecraftPlayerNetworking>();
				((EnemyAI)this).ChangeOwnershipOfEnemy(hauntingPlayer.actualClientId);
				if (!IsInitialized && waitForInitCr != null)
				{
					Logger.LogInfo((object)"Not initialized");
					waitForInitCr = ((MonoBehaviour)this).StartCoroutine(CheckAfterInit());
				}
				else
				{
					CheckHauntingLocal();
				}
			}
		}

		private void SendRandomSignal(int chance = 20)
		{
			if (hasSignalTranslator && Random.Range(0, 100) <= chance)
			{
				string text = SignalMessages[Random.Range(0, SignalMessages.Length)];
				Logger.LogInfo((object)("Sending random signal: " + text));
				signalTranslator.timeLastUsingSignalTranslator = Time.realtimeSinceStartup;
				if (signalTranslator.signalTranslatorCoroutine != null)
				{
					((MonoBehaviour)HUDManager.Instance).StopCoroutine(signalTranslator.signalTranslatorCoroutine);
				}
				string text2 = text.Substring(0, Mathf.Min(text.Length, 10));
				signalTranslator.signalTranslatorCoroutine = ((MonoBehaviour)HUDManager.Instance).StartCoroutine(HUDManager.Instance.DisplaySignalTranslatorMessage(text2, -signalTranslator.timesSendingMessage, signalTranslator));
			}
		}

		private IEnumerator CheckAfterInit()
		{
			while (!IsInitialized)
			{
				yield return null;
			}
			CheckHauntingLocal();
			waitForInitCr = null;
		}

		private void CheckHauntingLocal()
		{
			//IL_0091: 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_00b5: Unknown result type (might be due to invalid IL or missing references)
			hauntingLocalPlayer = (Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)(object)hauntingPlayer;
			SetEnemyVisible(enable: false);
			Tracker.SetEnabled(hauntingLocalPlayer);
			((Behaviour)EntityLookAt).enabled = hauntingLocalPlayer;
			((EnemyAI)this).SetClientCalculatingAI(hauntingLocalPlayer);
			if (!Object.op_Implicit((Object)(object)hauntingPlayer))
			{
				return;
			}
			if (hauntingLocalPlayer)
			{
				Logger.LogInfo((object)("Haunting local player: " + hauntingPlayer.playerUsername));
				ConstraintSource source = EntityLookAt.GetSource(0);
				((ConstraintSource)(ref source)).sourceTransform = ((Component)hauntingPlayer.gameplayCamera).transform;
				EntityLookAt.SetSource(0, source);
				SwitchState(0);
				if (lastTargetWasRequested)
				{
					Logger.LogInfo((object)"Haunting local was requested!");
					stateActionCounter = 0;
					stateActionTimer = 0f;
				}
				SendRandomSignal();
				MinecraftPlayerNetworking component = ((Component)hauntingPlayer).GetComponent<MinecraftPlayerNetworking>();
				if (Object.op_Implicit((Object)(object)component))
				{
					component.SyncWithServer();
				}
			}
			else
			{
				Logger.LogInfo((object)("Haunting remote player: " + hauntingPlayer.playerUsername));
			}
		}

		private Vector3 GetEyeLevelPos(Vector3 pos)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: 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_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			return pos += Vector3.up * Mathf.Abs(base.eye.position.y - ((Component)this).transform.position.y);
		}

		private bool PlayerCanSeePoint(Vector3 point, bool getEyeLevel = false, int range = 100, float proximity = 1f, float field = 60f)
		{
			//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_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			if (getEyeLevel)
			{
				point = GetEyeLevelPos(point);
			}
			if (!Physics.Linecast(((Component)hauntingPlayer.gameplayCamera).transform.position, point, StartOfRound.Instance.collidersAndRoomMask))
			{
				return hauntingPlayer.HasLineOfSightToPosition(point, field, range, proximity);
			}
			return false;
		}

		private bool PlayerCanSeeTransform(Transform tran)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			return PlayerCanSeePoint(tran.position);
		}

		private bool PlayerCanSeeEntity()
		{
			if (PlayerCanSeeTransform(base.eye))
			{
				return VisiblePoints.Any(PlayerCanSeeTransform);
			}
			return false;
		}

		private void State_Stalking(bool isCreeping = false)
		{
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			float time = Time.time;
			if (stateBusy)
			{
				UpdateBodyRotation();
				if (!seenByPlayer && PlayerCanSeeEntity())
				{
					if (Random.Range(0, 100) < ((Vector2Int)(ref JumpSRarity))[base.currentBehaviourStateIndex])
					{
						JumpSAwake();
					}
					seenByPlayer = true;
					stateActionTimer = currentStateInfo.GetStaring();
					stateActionTimeout = currentStateInfo.GetRange();
					currentStateInfo.PlayRandomVanishClip(AudioSFX);
					totalTimesSeen++;
				}
				float num = Vector3.Distance(((Component)hauntingPlayer).transform.position, ((Component)this).transform.position);
				if ((seenByPlayer && num < stateActionTimeout) || num < currentStateInfo.MinRange)
				{
					stateActionTimer = 0f;
				}
			}
			if (!(time > stateActionTimer))
			{
				return;
			}
			if (stateBusy)
			{
				stateActionTimer = (seenByPlayer ? currentStateInfo.GetInterval() : currentStateInfo.GetRetry());
				stateBusy = false;
				if (seenByPlayer && (--stateActionCounter <= 0 || (isInCompanyBuilding && base.currentBehaviourStateIndex == 0)))
				{
					if (Random.Range(0, 100) < 80)
					{
						FlipLightsBreakerServerRpc();
						RoundManager.Instance.FlickerLights(true, true);
					}
					if (base.currentBehaviourStateIndex == 0)
					{
						SendRandomSignal(30);
					}
					hauntingPlayer.JumpToFearLevel(1f, true);
					SwitchState(base.currentBehaviourStateIndex + 1);
					return;
				}
				SetEnemyVisible(enable: false);
				SendRandomSignal(4);
				if (seenByPlayer && Random.Range(0, 100) < (isCreeping ? 42 : 18))
				{
					RoundManager.Instance.FlickerLights(true, true);
					MessWithLightsServerRpc();
					hauntingPlayer.JumpToFearLevel((totalTimesSeen > 1) ? 0.6f : 0.2f, true);
				}
				if (seenByPlayer && Random.Range(0, 100) < (isCreeping ? 28 : 6))
				{
					HerobrineMinion.Instantiate(((Component)this).transform.position, hauntingPlayer);
				}
			}
			else
			{
				TryFindingHauntPosition(staringMode: true, mustBeInLOS: true, Random.Range(0, 100) < (isCreeping ? 50 : 5), (Random.Range(0, 100) < (isCreeping ? 40 : 25)) ? Random.Range(3, 6) : 0);
				seenByPlayer = false;
				if (stareFailed)
				{
					stateActionTimer = currentStateInfo.GetRetry();
					return;
				}
				stateBusy = true;
				stateActionTimer = currentStateInfo.GetStalking();
				TurnCompass.LookAt(((Component)hauntingPlayer).transform.position);
				((Component)this).transform.eulerAngles = new Vector3(((Component)this).transform.eulerAngles.x, TurnCompass.eulerAngles.y, ((Component)this).transform.eulerAngles.z);
			}
		}

		private void State_Creeping()
		{
			State_Stalking(isCreeping: true);
		}

		private void State_Chasing()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: 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_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: 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_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0349: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			if (effectNextFrame)
			{
				effectNextFrame = false;
				SpawnEffectByIndex(((Component)this).transform.position, 0);
			}
			float num = ((Vector3.Dot(((Component)this).transform.forward, ((Component)this).transform.position - ((Component)hauntingPlayer).transform.position) < 0f) ? 1f : 0f);
			EntityLookAt.weight = Mathf.Lerp(EntityLookAt.weight, num, 15f * Time.deltaTime);
			float time = Time.time;
			float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)hauntingPlayer).transform.position);
			if (insideLastFrame != hauntingPlayer.isInsideFactory && !hauntingPlayer.isInHangarShipRoom)
			{
				Vector3 val = TryFindingHauntPosition(staringMode: false, mustBeInLOS: false, Random.Range(0, 100) < 50, (Random.Range(0, 100) < 50) ? Random.Range(4, 10) : 0);
				ManualLogSource logger = Logger;
				Vector3 val2 = val;
				logger.LogInfo((object)("Trying to relocate and warp to: " + ((object)(Vector3)(ref val2)).ToString()));
				base.agent.Warp(val);
				SpawnEffectByIndex(val, 0);
				insideLastFrame = hauntingPlayer.isInsideFactory;
			}
			else if (time > stateActionTimer || num2 > 100f)
			{
				currentStateInfo.PlayRandomVanishClip(AudioSFX);
				SwitchState(1);
				if (Random.Range(0, 100) < 50)
				{
					RequestNewTargetServerRpc();
				}
				return;
			}
			if (time > stateActionTimeout && (num2 > 30f || findingExit || (isNavStuck && Time.time + 2f > navTimeout)))
			{
				if (!PlayerCanSeePoint(base.eye.position, getEyeLevel: false, 100, 2f, 70f) || isNavStuck)
				{
					Vector3 val3 = Vector3.zero;
					if (findingExit && NavMesh.CalculatePath(((Component)hauntingPlayer).transform.position, currentPoint, -1, entrancePath))
					{
						findingExit = false;
						NavMeshUtils.Update(2, entrancePath);
						val3 = GetPathPointOutOfLOV(entrancePath.corners, 3f);
						currentDist = 0f;
					}
					if ((val3 == Vector3.zero && num2 > 8f) || isNavStuck)
					{
						val3 = TryFindingHauntPosition(staringMode: false, mustBeInLOS: false, isNavStuck, isNavStuck ? 6 : 0);
					}
					if (val3 != Vector3.zero)
					{
						stateActionBoost = currentStateInfo.GetStaring();
						base.agent.Warp(RoundManager.Instance.GetNavMeshPosition(val3, navHit, 5f, -1));
					}
				}
				stateActionTimeout = currentStateInfo.GetStalking();
			}
			if (time > stateActionBoost)
			{
				stateActionBoost = currentStateInfo.GetStaring();
				float pathDistance = GetPathDistance(base.agent.path);
				Logger.LogInfo((object)("Path Distance: " + pathDistance));
				if (!(pathDistance < 6f) && PlayerCanSeePoint(base.eye.position))
				{
					float num3 = Mathf.Pow(Random.Range(0f, 1f), (pathDistance > 15f) ? 0.6f : 1.5f);
					float num4 = Mathf.Lerp(AgentSpeeds.z, pathDistance - 2f, num3);
					num4 = Mathf.Min(num4, pathDistance - 2f);
					Vector3 pointByDistance = GetPointByDistance(base.agent.path, num4);
					base.agent.Warp(pointByDistance);
					effectNextFrame = true;
					RoundManager.Instance.FlickerLights(true, true);
				}
			}
		}

		private static Vector3 GetPointByDistance(NavMeshPath path, float distance)
		{
			//IL_0015: 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_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: 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)
			Vector3[] corners = path.corners;
			float num = 0f;
			for (int i = 1; i < corners.Length; i++)
			{
				float num2 = Vector3.Distance(corners[i - 1], corners[i]);
				if (num + num2 >= distance)
				{
					float num3 = distance - num;
					Vector3 val = corners[i] - corners[i - 1];
					Vector3 normalized = ((Vector3)(ref val)).normalized;
					return corners[i - 1] + normalized * num3;
				}
				num += num2;
			}
			return Vector3.zero;
		}

		private void UpdateAgentSpeed()
		{
			if (base.currentBehaviourStateIndex < 2)
			{
				currentAgentSpeed = 0f;
			}
			if (!hauntingPlayer.isHoldingObject)
			{
				currentAgentSpeed = AgentSpeeds.x;
			}
			else
			{
				Item val = hauntingPlayer.ItemSlots[hauntingPlayer.currentItemSlot]?.itemProperties;
				currentAgentSpeed = ((Object.op_Implicit((Object)(object)val) && val.isDefensiveWeapon) ? AgentSpeeds.y : AgentSpeeds.x);
			}
			base.agent.speed = currentAgentSpeed;
		}

		private Vector3 GetPathPointOutOfLOV(Vector3[] path, float stepLength)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: 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_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: 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_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
			if (path.Length < 2)
			{
				return Vector3.zero;
			}
			Vector3 val = path[0];
			int num = 1;
			bool flag = false;
			while (num < path.Length)
			{
				Vector3 val2 = path[num];
				float num2 = Vector3.Magnitude(val2 - val);
				if (num2 >= stepLength)
				{
					val = Vector3.MoveTowards(val, val2, stepLength);
					if (!PlayerCanSeePoint(val, getEyeLevel: true, int.MaxValue, 10f))
					{
						if (flag)
						{
							return val;
						}
						flag = true;
					}
					continue;
				}
				float num3 = stepLength - num2;
				val = val2;
				num++;
				if (num >= path.Length)
				{
					continue;
				}
				val2 = path[num];
				val = Vector3.MoveTowards(val, val2, num3);
				if (!PlayerCanSeePoint(val, getEyeLevel: true, int.MaxValue, 10f))
				{
					if (flag)
					{
						return val;
					}
					flag = true;
				}
			}
			val = path[^1];
			if (!PlayerCanSeePoint(val, getEyeLevel: true, int.MaxValue, 10f))
			{
				return val;
			}
			return Vector3.zero;
		}

		private void SwitchState(int index)
		{
			Logger.LogInfo((object)("Switching State Index: " + index));
			currentStateInfo = StateInfos[index];
			((EnemyAI)this).SwitchToBehaviourStateOnLocalClient(index);
			bool flag = index == 2;
			stateActionTimer = currentStateInfo.GetInterval();
			stateActionCounter = currentStateInfo.GetCounter();
			stateBusy = false;
			SetEnemyVisible(flag);
			((Renderer)MainRenderer).enabled = true;
			base.creatureAnimator.SetBool("Walk", flag);
			if (flag)
			{
				stateActionTimeout = currentStateInfo.GetStalking();
				stateActionBoost = currentStateInfo.GetStaring();
				((EnemyAI)this).SetMovingTowardsTargetPlayer(hauntingPlayer);
				currentStateInfo.PlayRandomVanishClip(AudioSFX);
				hauntingPlayer.JumpToFearLevel(1f, true);
				ResetTraversing();
				insideLastFrame = hauntingPlayer.isInsideFactory;
				base.creatureSFX.Play();
			}
			else
			{
				base.creatureSFX.Stop();
			}
			base.movingTowardsTargetPlayer = flag;
			base.moveTowardsDestination = flag;
			isNavStuck = false;
			navTimeout = 0f;
			stateStartTime = Time.time;
			UpdateAgentSpeed();
			base.isInsidePlayerShip = StartOfRound.Instance.hangarDoorsClosed && hauntingPlayer.isInsideFactory;
		}

		private void UpdateBodyRotation()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			float num = Quaternion.Angle(((Component)this).transform.rotation, EntityHead.rotation);
			EntityLookAt.weight = 1f;
			if (num > 40f)
			{
				((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, Quaternion.Euler(0f, EntityHead.eulerAngles.y, 0f), 4f * Time.deltaTime);
			}
		}

		public override void Update()
		{
			((EnemyAI)this).Update();
			if (base.isEnemyDead || StartOfRound.Instance.allPlayersDead)
			{
				if (lastVisibility)
				{
					SetEnemyVisible(enable: false);
				}
				return;
			}
			if (((NetworkBehaviour)this).IsServer && (!Object.op_Implicit((Object)(object)hauntingPlayer) || !hauntingPlayer.isPlayerControlled))
			{
				SetNewTargetOnServer(requested: false);
				return;
			}
			if (!((NetworkBehaviour)this).IsOwner)
			{
				if (lastVisibility)
				{
					SetEnemyVisible(enable: false);
				}
				return;
			}
			if ((Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)(object)hauntingPlayer)
			{
				if (Object.op_Implicit((Object)(object)hauntingPlayer))
				{
					((EnemyAI)this).ChangeOwnershipOfEnemy(hauntingPlayer.actualClientId);
				}
				return;
			}
			if (!hauntingLocalPlayer)
			{
				if (base.currentBehaviourStateIndex != 0)
				{
					SwitchState(0);
				}
				return;
			}
			switch (base.currentBehaviourStateIndex)
			{
			case 0:
				State_Stalking();
				break;
			case 1:
				State_Creeping();
				break;
			case 2:
				State_Chasing();
				break;
			default:
				Logger.LogError((object)("Unregistered state: " + base.currentBehaviourStateIndex));
				break;
			}
			if (((Collider)ScanNodeHitbox).enabled)
			{
				float time = Time.time;
				if (time > ScanNodeIntervals.z)
				{
					ScanNodeProps.headerText = "<color=white>" + Random.Range(int.MinValue, int.MaxValue);
					ScanNodeIntervals.z = time + Random.Range(ScanNodeIntervals.x, ScanNodeIntervals.y);
				}
				if (time > ScanNodeIntervals.w)
				{
					ScanNodeProps.subText = "<color=white>" + Random.Range(int.MinValue, int.MaxValue);
					ScanNodeIntervals.w = time + Random.Range(ScanNodeIntervals.x, ScanNodeIntervals.y);
				}
			}
		}

		public override void HitEnemy(int force = 1, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitId = -1)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: 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_0030: 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_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: 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_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: 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_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: 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_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			if (!((NetworkBehaviour)this).IsOwner || base.currentBehaviourStateIndex != 2)
			{
				return;
			}
			Vector3 val = ((Component)this).transform.position;
			bool flag = false;
			for (int i = 0; i < 5; i++)
			{
				Vector3 insideUnitSphere = Random.insideUnitSphere;
				Vector3 val2 = ((Vector3)(ref insideUnitSphere)).normalized * Random.Range(8f, 15f);
				val2.y = 0f;
				if (NavMesh.SamplePosition(val + val2, ref navHit, 10f, -1) && Vector3.Distance(val, ((NavMeshHit)(ref navHit)).position) > 6f && base.agent.CalculatePath(((NavMeshHit)(ref navHit)).position, navMeshPath) && (int)navMeshPath.status == 0)
				{
					val = ((NavMeshHit)(ref navHit)).position;
					flag = true;
					break;
				}
			}
			if (!flag)
			{
				val = TryFindingHauntPosition(staringMode: false, mustBeInLOS: false);
				if (val == Vector3.zero)
				{
					val = ((Component)this).transform.position - ((Component)this).transform.forward * Random.Range(1.5f, 3f);
				}
				val = RoundManager.Instance.GetNavMeshPosition(val, navHit, 5f, -1);
			}
			base.agent.Warp(val);
			SpawnEffectByIndex(val, 0);
			StateInfo.PlayRandomClipAt(base.creatureVoice, HitAudioClips);
			stateActionTimeout = currentStateInfo.GetStalking();
		}

		private void SetPlayerSkin(bool value)
		{
			isUsingPlayerSkin = value && MCSkinAPI.UsableSkins.Count > 0;
			if (isUsingPlayerSkin)
			{
				Logger.LogInfo((object)"Attempting to set random usable skin.");
				KeyValuePair<Texture2D, bool> keyValuePair = MCSkinAPI.UsableSkins[Random.Range(0, MCSkinAPI.UsableSkins.Count)];
				if ((Object)(object)lastSkinTex != (Object)(object)keyValuePair.Key)
				{
					lastSkinTex = keyValuePair.Key;
					lastSkinSlim = keyValuePair.Value;
					SkinMaterial.mainTexture = (Texture)(object)lastSkinTex;
				}
			}
			MainRenderer.SetBlendShapeWeight(0, (float)((isUsingPlayerSkin && lastSkinSlim) ? 100 : 0));
			((Renderer)MainRenderer).sharedMaterial = (isUsingPlayerSkin ? SkinMaterial : MainMaterial);
		}

		public override void Start()
		{
			Logger.LogInfo((object)"Starting");
			((EnemyAI)this).Start();
			if (!RoundManager.Instance.hasInitializedLevelRandomSeed)
			{
				RoundManager.Instance.InitializeRandomNumberGenerators();
			}
			outsideNodes = GameObject.FindGameObjectsWithTag("OutsideAINode");
			SetEnemyVisible(enable: false);
			IsInitialized = true;
			if (((NetworkBehaviour)this).IsServer)
			{
				SetNewTargetOnServer(requested: false);
			}
			base.skinnedMeshRenderers = (SkinnedMeshRenderer[])(object)new SkinnedMeshRenderer[0];
			base.meshRenderers = (MeshRenderer[])(object)new MeshRenderer[0];
		}

		public override void DoAIInterval()
		{
			//IL_0012: 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_002b: 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_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: 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_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			if (base.moveTowardsDestination)
			{
				base.agent.SetDestination(base.destination);
				bool flag = (int)base.agent.pathStatus != 0 || Vector3.Distance(base.destination, base.agent.pathEndPosition) > 1f;
				if (isNavStuck != flag)
				{
					isNavStuck = flag;
					navTimeout = Time.time + 10f;
				}
				if (isNavStuck && Time.time > navTimeout)
				{
					PerformRandomTPOnPlayer(0);
					isNavStuck = false;
					navTimeout = 0f;
				}
			}
			((EnemyAI)this).SyncPositionToClients();
			if (hauntingLocalPlayer != isHauntingLocal)
			{
				isHauntingLocal = hauntingLocalPlayer && (Object)(object)hauntingPlayer != (Object)null && !hauntingPlayer.isPlayerDead;
				if (isHauntingLocal)
				{
					SetPlayerSkin(value: false);
				}
			}
			UpdateAgentSpeed();
			if (!isHauntingLocal || !hauntingPlayer.isInsideFactory || base.currentBehaviourStateIndex != 2)
			{
				if ((Object)(object)currentExit != (Object)null)
				{
					ResetTraversing();
				}
				return;
			}
			if (entranceList == null)
			{
				entranceList = Object.FindObjectsOfType<EntranceTeleport>(false);
			}
			if (findingExit)
			{
				return;
			}
			Transform val = null;
			float num = float.MaxValue;
			Vector3 val2 = Vector3.zero;
			for (int i = 0; i < entranceList.Length; i++)
			{
				EntranceTeleport val3 = entranceList[i];
				if (!val3.isEntranceToBuilding || !Object.op_Implicit((Object)(object)val3.exitPoint))
				{
					continue;
				}
				Vector3 navMeshPosition = RoundManager.Instance.GetNavMeshPosition(val3.exitPoint.position, RoundManager.Instance.navHit, 1.75f, -1);
				if (NavMesh.CalculatePath(((Component)hauntingPlayer).transform.position, navMeshPosition, -1, entrancePath) && (int)entrancePath.status == 0)
				{
					float pathDistance = GetPathDistance(entrancePath);
					if (pathDistance < num)
					{
						num = pathDistance;
						val = val3.exitPoint;
						val2 = navMeshPosition;
					}
				}
			}
			if ((Object)(object)currentExit != (Object)(object)val)
			{
				ResetTraversing(num, val);
			}
			else if (Object.op_Implicit((Object)(object)currentExit))
			{
				traversedDist = Mathf.Max(currentDist - num, -1f);
				currentDist = Mathf.Max(currentDist, num);
				if (traversedDist > 5f)
				{
					findingExit = true;
					currentPoint = val2;
					traversedDist = 0f;
					currentDist = num;
				}
			}
		}

		private void ResetTraversing(float dist = 0f, Transform tr = null)
		{
			findingExit = false;
			currentDist = dist;
			traversedDist = 0f;
			currentExit = tr;
			if (entrancePath != null)
			{
				entrancePath.ClearCorners();
			}
		}

		public override void OnCollideWithPlayer(Collider other)
		{
			if (!hauntingLocalPlayer)
			{
				return;
			}
			PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, false, true);
			if ((Object)(object)val == (Object)null || !((Object)(object)val == (Object)(object)hauntingPlayer))
			{
				return;
			}
			if (base.currentBehaviourStateIndex == 2)
			{
				Plugin.OnTouchEffect.Run(this);
				currentStateInfo.PlayRandomVanishClip(AudioSFX);
				SwitchState(1);
				if (!hauntingPlayer.isPlayerDead)
				{
					GoSomewhereElse();
				}
			}
			else if (stateBusy)
			{
				stateActionTimer = 0f;
			}
		}

		private void GoSomewhereElse()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			base.agent.Warp(base.allAINodes[Random.Range(0, base.allAINodes.Length)].transform.position);
		}

		public override void EnableEnemyMesh(bool enable, bool overrideDoNotSet = false)
		{
		}

		public void SetEnemyVisible(bool enable)
		{
			((Component)MainRenderer).gameObject.SetActive(enable);
			((Component)MainRenderer).gameObject.layer = (enable ? 19 : 23);
			((Renderer)MainRenderer).enabled = enable;
			((Collider)EntityHitbox).enabled = enable;
			((Collider)ScanNodeHitbox).enabled = enable && base.currentBehaviourStateIndex == 2;
			antiCheatObj.SetActive(((Collider)ScanNodeHitbox).enabled);
			if (lastVisibility != enable && enable)
			{
				SetPlayerSkin(Random.Range(0, 100) < Plugin.UseMCSkinChance.Value);
			}
			lastVisibility = enable;
		}

		private void SetHauntStarePosition(Vector3 newPosition)
		{
			//IL_000c: 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_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			stareFailed = false;
			Vector3 randomNavMeshPositionInRadiusSpherical = RoundManager.Instance.GetRandomNavMeshPositionInRadiusSpherical(newPosition, 1f, navHit);
			base.agent.Warp(randomNavMeshPositionInRadiusSpherical);
			base.moveTowardsDestination = false;
			base.destination = ((Component)this).transform.position;
			base.agent.SetDestination(base.destination);
			base.agent.speed = 0f;
			SetEnemyVisible(enable: true);
			ManualLogSource logger = Logger;
			Vector3 val = newPosition;
			logger.LogInfo((object)("Setting haunt pos: " + ((object)(Vector3)(ref val)).ToString()));
		}

		private static float GetPathDistance(NavMeshPath path)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			Vector3[] corners = path.corners;
			float num = 0f;
			for (int i = 1; i < corners.Length; i++)
			{
				num += Vector3.Distance(corners[i - 1], corners[i]);
			}
			return num;
		}

		private Vector3 TryFindingHauntPosition(bool staringMode = true, bool mustBeInLOS = true, bool behindPlayer = false, int randomDirectionSamples = 0, bool findNodes = true)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: 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_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_030f: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: 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_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: 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_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: 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_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0305: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			GameObject[] array = (hauntingPlayer.isInsideFactory ? base.allAINodes : outsideNodes);
			if (behindPlayer)
			{
				Vector3 val = ((Component)hauntingPlayer).transform.position + Vector3.up;
				Vector3 val2 = -((Component)hauntingPlayer).transform.forward;
				RaycastHit val3 = default(RaycastHit);
				if (!Physics.Raycast(val, val2, ref val3, 8f, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1))
				{
					((RaycastHit)(ref val3)).distance = 8f;
				}
				if (((RaycastHit)(ref val3)).distance > 3f)
				{
					float num = Random.Range(3f, ((RaycastHit)(ref val3)).distance);
					val += val2 * num;
					Vector3 navMeshPosition = RoundManager.Instance.GetNavMeshPosition(val, RoundManager.Instance.navHit, 2f, -1);
					if (!RoundManager.Instance.GotNavMeshPositionResult)
					{
						navMeshPosition = RoundManager.Instance.GetNavMeshPosition(navMeshPosition, RoundManager.Instance.navHit, -1f, -1);
					}
					if (RoundManager.Instance.GotNavMeshPositionResult)
					{
						stareFailed = false;
						if (staringMode)
						{
							SetHauntStarePosition(navMeshPosition);
						}
						return navMeshPosition;
					}
				}
			}
			if (randomDirectionSamples > 0)
			{
				for (int i = 0; i < randomDirectionSamples; i++)
				{
					Vector3 insideUnitSphere = Random.insideUnitSphere;
					Vector3 val4 = ((Vector3)(ref insideUnitSphere)).normalized * Random.Range(5f, 15f);
					val4.y = 0f;
					if (NavMesh.SamplePosition(((Component)hauntingPlayer).transform.position + val4, ref navHit, 15f, -1) && !Physics.Linecast(((Component)hauntingPlayer.gameplayCamera).transform.position, GetEyeLevelPos(((NavMeshHit)(ref navHit)).position), StartOfRound.Instance.collidersAndRoomMaskAndDefault) && !PlayerCanSeePoint(((NavMeshHit)(ref navHit)).position, getEyeLevel: true, 100, isNavStuck ? 1f : 5f, 70f))
					{
						stareFailed = false;
						if (staringMode)
						{
							SetHauntStarePosition(((NavMeshHit)(ref navHit)).position);
						}
						return ((NavMeshHit)(ref navHit)).position;
					}
				}
			}
			if (findNodes)
			{
				Vector3 position = ((Component)hauntingPlayer.gameplayCamera).transform.position;
				float num2 = float.MaxValue;
				Vector3 val5 = Vector3.zero;
				for (int j = 0; j < array.Length; j++)
				{
					Transform transform = array[j].transform;
					Vector3 eyeLevelPos = GetEyeLevelPos(transform.position);
					float num3 = Vector3.Distance(position, eyeLevelPos);
					if (num3 < num2 && num3 < 90f && (!mustBeInLOS || !Physics.Linecast(((Component)hauntingPlayer.gameplayCamera).transform.position, eyeLevelPos, StartOfRound.Instance.collidersAndRoomMaskAndDefault)) && !PlayerCanSeePoint(eyeLevelPos, getEyeLevel: false, 100, 5f, 76f))
					{
						num2 = num3;
						val5 = eyeLevelPos;
					}
				}
				stareFailed = val5 == Vector3.zero;
				if (!stareFailed)
				{
					if (staringMode)
					{
						SetHauntStarePosition(val5);
					}
					return val5;
				}
			}
			stareFailed = true;
			return Vector3.zero;
		}

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

		[ClientRpc]
		private void MessWithLightsClientRpc()
		{
			//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(3374901806u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3374901806u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && !((NetworkBehaviour)this).IsOwner)
				{
					RoundManager.Instance.FlickerLights(true, true);
					GameNetworkManager.Instance.localPlayerController.JumpToFearLevel(0.2f, true);
				}
			}
		}

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

		[ClientRpc]
		private void FlipLightsBreakerClientRpc()
		{
			//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(3234261868u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3234261868u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				BreakerBox val3 = Object.FindObjectOfType<BreakerBox>();
				if ((Object)(object)val3 != (Object)null)
				{
					val3.SetSwitchesOff();
					RoundManager.Instance.TurnOnAllLights(false);
					GameNetworkManager.Instance.localPlayerController.JumpToFearLevel(0.2f, true);
				}
			}
		}

		private void FlickerLightsAndSync()
		{
			RoundManager.Instance.FlickerLights(true, true);
			MessWithLightsServerRpc();
		}

		[WeightedMethod(140)]
		private void weight_KillPlayer()
		{
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: 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_0084: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val;
			if (stateTime < 1f || Random.Range(0, 100) < 8)
			{
				weight_SparePlayer();
			}
			else if (Random.Range(0, 100) < 35)
			{
				val = ((Component)hauntingPlayer).transform.position - ((Component)this).transform.position;
				Vector3 velocity = ((Vector3)(ref val)).normalized * Random.Range(15f, 30f);
				velocity.y = Random.Range(10f, 15f);
				minecraftPlayer.ExplodePlayer(velocity);
			}
			else
			{
				PlayerControllerB obj = hauntingPlayer;
				Vector3 zero = Vector3.zero;
				int num = Mathf.Max(Plugin.RagdollIndex, 1);
				val = default(Vector3);
				obj.KillPlayer(zero, true, (CauseOfDeath)0, num, val);
			}
		}

		[WeightedMethod(5)]
		private void weight_SparePlayer()
		{
			FlickerLightsAndSync();
			SendDialog("SparePlayer");
		}

		[WeightedMethod(10)]
		private bool weight_DropAllItems()
		{
			if (base.targetPlayer.ItemSlots.All((GrabbableObject itm) => (Object)(object)itm == (Object)null))
			{
				return false;
			}
			base.targetPlayer.DropAllHeldItems(true, false);
			FlickerLightsAndSync();
			SendDialog("DropAllItems");
			return true;
		}

		[WeightedMethod(10)]
		private bool weight_DrainBattery()
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			bool flag = false;
			for (int i = 0; i < base.targetPlayer.ItemSlots.Length; i++)
			{
				GrabbableObject val = base.targetPlayer.ItemSlots[i];
				if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.itemProperties) && val.itemProperties.requiresBattery)
				{
					val.insertedBattery = new Battery(true, 0f);
					flag = true;
				}
			}
			if (flag)
			{
				FlickerLightsAndSync();
				SendDialog("DrainBattery");
			}
			return flag;
		}

		[WeightedMethod(20)]
		private bool weight_BreakPlayer()
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			if (base.targetPlayer.health > 10 && !playerReceivedDamage)
			{
				weight_SparePlayer();
				base.targetPlayer.DamagePlayer(base.targetPlayer.health - 5, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
				playerReceivedDamage = true;
				return playerReceivedDamage;
			}
			return false;
		}

		[WeightedMethod(20)]
		private bool weight_FortressLock()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = ((Component)base.targetPlayer).transform.position;
			if (FortressLock.LockPlayer(base.targetPlayer))
			{
				SpawnEffectByIndex(position, 0, sync: true);
				SpawnEffectByIndex(((Component)base.targetPlayer).transform.position, 0);
				return true;
			}
			return false;
		}

		[WeightedMethod(20)]
		private void weight_RandomTelePlayer()
		{
			PerformRandomTPOnPlayer(GetRandomIndexFromWeights(TPWeights));
			FlickerLightsAndSync();
		}

		private void PerformRandomTPOnPlayer(int index, bool redirected = false)
		{
			//IL_01e5: 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_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missi