Decompiled source of FacelessStalker v1.1.9

FacelessStalker/SlendermanMod.dll

Decompiled 2 months 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.Serialization.Formatters.Binary;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using SlendermanMod.Behaviours;
using SlendermanMod.NetcodePatcher;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;

[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: AssemblyCompany("SlendermanMod")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("A Lethal Company plugin that adds the famous stalking Slenderman entity to the game.")]
[assembly: AssemblyFileVersion("1.1.9.0")]
[assembly: AssemblyInformationalVersion("1.1.9")]
[assembly: AssemblyProduct("SlendermanMod")]
[assembly: AssemblyTitle("SlendermanMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.9.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 SlendermanMod
{
	[BepInPlugin("sparble.slendermanmod", "SlendermanMod", "1.1.9")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		private const string GUID = "sparble.slendermanmod";

		private const string NAME = "SlendermanMod";

		private const string VERSION = "1.1.9";

		public static Harmony _harmony;

		public static EnemyType SlendermanEnemy;

		public static Item page1Item;

		public static Item page2Item;

		public static Item page3Item;

		public static Item page4Item;

		internal static ManualLogSource Logger;

		public static AssetBundle SlendermanAssets;

		public static float slendermanHauntCooldown;

		public static float slendermanHauntIntervalLength;

		public static float slendermanStalkingIntervalLength;

		public static float slendermanChaseDuration;

		public static bool slendermanFlipsLightBreaker;

		public static bool slendermanPlaysSpawningSound;

		public static bool slendermanPlaysApproachingSound;

		public static float slendermanApproachingSoundChance;

		public static float slendermanSpotFoundSoundChance;

		public static bool slendermanClosedDoorsTargetSwitch;

		public static float slendermanVolume;

		public static SlendermanConfig SlendermanConfig { get; internal set; }

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

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Assets.PopulateAssets();
			SlendermanConfig = new SlendermanConfig(((BaseUnityPlugin)this).Config);
			NetcodePatcher();
			SlendermanEnemy = Assets.SlendermanAssets.LoadAsset<EnemyType>("SlendermanEnemy");
			TerminalNode val = Assets.SlendermanAssets.LoadAsset<TerminalNode>("SlendermanEnemyTN");
			NetworkPrefabs.RegisterNetworkPrefab(SlendermanEnemy.enemyPrefab);
			Enemies.RegisterEnemy(SlendermanEnemy, SyncedInstance<SlendermanConfig>.Instance.configSlendermanSpawnChances.Value, (LevelTypes)(-1), (SpawnType)0, val, (TerminalKeyword)null);
			string value = SlendermanConfig.configPageMoons.Value;
			(Dictionary<LevelTypes, int> spawnRateByLevelType, Dictionary<string, int> spawnRateByCustomLevelType) tuple = ConfigParsing(value);
			Dictionary<LevelTypes, int> item = tuple.spawnRateByLevelType;
			Dictionary<string, int> item2 = tuple.spawnRateByCustomLevelType;
			Item val2 = Assets.SlendermanAssets.LoadAsset<Item>("Assets/Items/page1Item.asset");
			SpawnSlendermanEnemyItem spawnSlendermanEnemyItem = val2.spawnPrefab.AddComponent<SpawnSlendermanEnemyItem>();
			((GrabbableObject)spawnSlendermanEnemyItem).grabbable = true;
			((GrabbableObject)spawnSlendermanEnemyItem).grabbableToEnemies = true;
			((GrabbableObject)spawnSlendermanEnemyItem).itemProperties = val2;
			Utilities.FixMixerGroups(val2.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val2.spawnPrefab);
			Items.RegisterScrap(val2, item, item2);
			Item val3 = Assets.SlendermanAssets.LoadAsset<Item>("Assets/Items/page2Item.asset");
			SpawnSlendermanEnemyItem spawnSlendermanEnemyItem2 = val3.spawnPrefab.AddComponent<SpawnSlendermanEnemyItem>();
			((GrabbableObject)spawnSlendermanEnemyItem2).grabbable = true;
			((GrabbableObject)spawnSlendermanEnemyItem2).grabbableToEnemies = true;
			((GrabbableObject)spawnSlendermanEnemyItem2).itemProperties = val3;
			Utilities.FixMixerGroups(val3.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val3.spawnPrefab);
			Items.RegisterScrap(val3, item, item2);
			Item val4 = Assets.SlendermanAssets.LoadAsset<Item>("Assets/Items/page3Item.asset");
			SpawnSlendermanEnemyItem spawnSlendermanEnemyItem3 = val4.spawnPrefab.AddComponent<SpawnSlendermanEnemyItem>();
			((GrabbableObject)spawnSlendermanEnemyItem3).grabbable = true;
			((GrabbableObject)spawnSlendermanEnemyItem3).grabbableToEnemies = true;
			((GrabbableObject)spawnSlendermanEnemyItem3).itemProperties = val4;
			Utilities.FixMixerGroups(val4.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val4.spawnPrefab);
			Items.RegisterScrap(val4, item, item2);
			Item val5 = Assets.SlendermanAssets.LoadAsset<Item>("Assets/Items/page4Item.asset");
			SpawnSlendermanEnemyItem spawnSlendermanEnemyItem4 = val5.spawnPrefab.AddComponent<SpawnSlendermanEnemyItem>();
			((GrabbableObject)spawnSlendermanEnemyItem4).grabbable = true;
			((GrabbableObject)spawnSlendermanEnemyItem4).grabbableToEnemies = true;
			((GrabbableObject)spawnSlendermanEnemyItem4).itemProperties = val5;
			Utilities.FixMixerGroups(val5.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val5.spawnPrefab);
			Items.RegisterScrap(val5, item, item2);
			slendermanHauntCooldown = SyncedInstance<SlendermanConfig>.Instance.configSlendermanHauntCooldown.Value;
			slendermanHauntIntervalLength = SyncedInstance<SlendermanConfig>.Instance.configSlendermanAbsentIntervalRate.Value;
			slendermanStalkingIntervalLength = SyncedInstance<SlendermanConfig>.Instance.configSlendermanStalkingIntervalRate.Value;
			slendermanChaseDuration = SyncedInstance<SlendermanConfig>.Instance.configSlendermanChaseDuration.Value;
			slendermanFlipsLightBreaker = SyncedInstance<SlendermanConfig>.Instance.configSlendermanLightBreaker.Value;
			slendermanVolume = SyncedInstance<SlendermanConfig>.Instance.configSlendermanVolume.Value;
			slendermanPlaysSpawningSound = SyncedInstance<SlendermanConfig>.Instance.configSlendermanPlaysSpawnSound.Value;
			slendermanPlaysApproachingSound = SyncedInstance<SlendermanConfig>.Instance.configSlendermanPlaysApproachingSound.Value;
			slendermanApproachingSoundChance = SyncedInstance<SlendermanConfig>.Instance.configSlendermanApproachingSoundChance.Value;
			slendermanSpotFoundSoundChance = SyncedInstance<SlendermanConfig>.Instance.configSlendermanSpotFoundSoundChance.Value;
			slendermanClosedDoorsTargetSwitch = SyncedInstance<SlendermanConfig>.Instance.configSlendermanDoorsClosedTargetSwitch.Value;
			Logger.LogInfo((object)"Plugin SlendermanMod is loaded!");
		}

		private (Dictionary<LevelTypes, int> spawnRateByLevelType, Dictionary<string, int> spawnRateByCustomLevelType) ConfigParsing(string configMoonRarity)
		{
			//IL_007d: 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)
			Dictionary<LevelTypes, int> dictionary = new Dictionary<LevelTypes, int>();
			Dictionary<string, int> dictionary2 = new Dictionary<string, int>();
			foreach (string item in from s in configMoonRarity.Split(',')
				select s.Trim())
			{
				string[] array = item.Split('@');
				if (array.Length != 2)
				{
					continue;
				}
				string text = array[0];
				if (int.TryParse(array[1], out var result))
				{
					if (Enum.TryParse<LevelTypes>(text, ignoreCase: true, out LevelTypes result2))
					{
						dictionary[result2] = result;
						Logger.LogInfo((object)$"Registered spawn rate for level type {result2} to {result}");
					}
					else
					{
						dictionary2[text] = result;
						Logger.LogInfo((object)$"Registered spawn rate for custom level type {text} to {result}");
					}
				}
			}
			return (dictionary, dictionary2);
		}
	}
	public static class Assets
	{
		public static AssetBundle SlendermanAssets;

		public static void PopulateAssets()
		{
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "slendermanbundle");
			SlendermanAssets = AssetBundle.LoadFromFile(text);
			if ((Object)(object)SlendermanAssets == (Object)null)
			{
				Plugin.Logger.LogError((object)"Failed to load slendermanbundle assets.");
			}
		}
	}
	[Serializable]
	public class SlendermanConfig : SyncedInstance<SlendermanConfig>
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static HandleNamedMessageDelegate <0>__OnRequestSync;

			public static HandleNamedMessageDelegate <1>__OnReceiveSync;
		}

		public readonly ConfigEntry<string> configPageMoons;

		public readonly ConfigEntry<int> configSlendermanSpawnChances;

		public readonly ConfigEntry<float> configSlendermanHauntCooldown;

		public readonly ConfigEntry<float> configSlendermanAbsentIntervalRate;

		public readonly ConfigEntry<float> configSlendermanStalkingIntervalRate;

		public readonly ConfigEntry<float> configSlendermanChaseDuration;

		public readonly ConfigEntry<float> configSlendermanVolume;

		public readonly ConfigEntry<bool> configSlendermanLightBreaker;

		public readonly ConfigEntry<bool> configSlendermanPlaysSpawnSound;

		public readonly ConfigEntry<bool> configSlendermanPlaysApproachingSound;

		public readonly ConfigEntry<float> configSlendermanApproachingSoundChance;

		public readonly ConfigEntry<float> configSlendermanSpotFoundSoundChance;

		public readonly ConfigEntry<bool> configSlendermanDoorsClosedTargetSwitch;

		public SlendermanConfig(ConfigFile cfg)
		{
			InitInstance(this);
			configPageMoons = cfg.Bind<string>("PageItem.Values", "Page Spawning", "All@10,AssuranceLevel@5,VowLevel@20,MarchLevel@20,DineLevel@15,RendLevel@15,TitanLevel@10,AdamanceLevel@20,ArtificeLevel@15", "The LevelTypes/Moons that the page items can spawn on. \nUses the format 'Moon@Rarity,Moon2@Rarity2,' etc, also supports custom moons.");
			configSlendermanSpawnChances = cfg.Bind<int>("Slenderman", "Natural Spawn Chances", 0, "The chances of spawning Slenderman, independent from any pages. \nDefault value is 0, which will cause him to never spawn naturally and only spawn him when a page is picked up.");
			configSlendermanHauntCooldown = cfg.Bind<float>("Slenderman.Behavior", "Absent State Cooldown", 35f, "The duration of the cooldown after first picking up a page, looking at slenderman and after a chase before Slenderman tries to spawn again (in seconds). \nThe higher the value, the more time the player has before Slenderman spawns in.");
			configSlendermanAbsentIntervalRate = cfg.Bind<float>("Slenderman.Behavior", "Absent State Interval Length", 15f, "The duration of intervals of the Slenderman trying to find a haunting spot during his Absent state (in seconds). If he fails to find a spot, he will wait x seconds again before trying to find a spot again. \nThe higher the value, the longer the intervals are and the longer it will take for him to try to re-spawn. \nHigh numbers may result in him almost never spawning at all on small moons without many outside objects. (0 = Very frequent spawn intervals, 60 = Wait 60 seconds before trying to find a spawning spot again).");
			configSlendermanStalkingIntervalRate = cfg.Bind<float>("Slenderman.Behavior", "Stalking State Interval Length", 20f, "The duration of intervals (in seconds) of the Slenderman stalking the player before creeping closer - The value MUST be higher than 4.0 and it is recommended to not set this number too high or low. \nThe higher the value, the longer the intervals are and the longer it takes him to creep closer to the haunted player. \nHigh numbers mean the player has much time to spot Slenderman, while very low numbers mean they will have to constantly check their surroundings. (4.5 = Pretty much immediate chase, 60 = Wait 60 seconds before creeping closer).");
			configSlendermanChaseDuration = cfg.Bind<float>("Slenderman.Behavior", "Chase Duration", 20f, "The duration of a chase (in seconds).");
			configSlendermanLightBreaker = cfg.Bind<bool>("Slenderman.Behavior", "Light Breaker Flip", false, "Whether Slenderman should shut off the facility lights after being seen the first time.");
			configSlendermanPlaysSpawnSound = cfg.Bind<bool>("Slenderman.Behavior", "Play Spawning Sound", true, "Whether the global spawning sound should be played after Slenderman spawned in the round (both naturally and through picking up a page).");
			configSlendermanPlaysApproachingSound = cfg.Bind<bool>("Slenderman.Behavior", "Play Approaching Sound", true, "Whether the approaching sound should be enabled for the haunted player.");
			configSlendermanApproachingSoundChance = cfg.Bind<float>("Slenderman.Behavior", "Approaching Sound Chance", 25f, "(Requires the 'Play Approaching Sound' option to be set to 'true') - The chance of Slenderman playing a static noise for the haunted player when creeping closer in % (must be between 0 and 100) - 0 means no sound will be played at all, 100 means for every interval he will play the sound 100%.");
			configSlendermanSpotFoundSoundChance = cfg.Bind<float>("Slenderman.Behavior", "Play Spot Found-Sound", 50f, "Chance for the bass sound playing after Slenderman found a spot to spawn in. Value in %, must be between 0 and 100 (0 = Never play the sound, 100 = always play the sound).");
			configSlendermanDoorsClosedTargetSwitch = cfg.Bind<bool>("Slenderman.Behavior", "Closed Doors Target Switch", true, "Whether Slenderman should change targets when the haunted player is inside the ship and the doors are closed during a chase.");
			configSlendermanVolume = cfg.Bind<float>("Slenderman.Volume", "Slenderman Volume", 1f, "The volume of the Slenderman enemy voice. 1.0 means 100% (default value), 0.8 means 80% etc.");
		}

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

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

		public static void OnReceiveSync(ulong _, FastBufferReader reader)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			if (!((FastBufferReader)(ref reader)).TryBeginRead(SyncedInstance<SlendermanConfig>.IntSize))
			{
				Plugin.Logger.LogError((object)"Config sync error: Could not begin reading buffer.");
				return;
			}
			int num = default(int);
			((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num, default(ForPrimitives));
			if (!((FastBufferReader)(ref reader)).TryBeginRead(num))
			{
				Plugin.Logger.LogError((object)"Config sync error: Host could not sync.");
				return;
			}
			byte[] data = new byte[num];
			((FastBufferReader)(ref reader)).ReadBytesSafe(ref data, num, 0);
			SyncedInstance<SlendermanConfig>.SyncInstance(data);
			Plugin.Logger.LogInfo((object)"Successfully synced config with host.");
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")]
		public static void InitializeLocalPlayer()
		{
			//IL_0058: 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_0063: Expected O, but got Unknown
			//IL_0021: 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_002c: Expected O, but got Unknown
			if (SyncedInstance<SlendermanConfig>.IsHost)
			{
				CustomMessagingManager messageManager = SyncedInstance<SlendermanConfig>.MessageManager;
				object obj = <>O.<0>__OnRequestSync;
				if (obj == null)
				{
					HandleNamedMessageDelegate val = OnRequestSync;
					<>O.<0>__OnRequestSync = val;
					obj = (object)val;
				}
				messageManager.RegisterNamedMessageHandler("SlendermanMod_OnRequestConfigSync", (HandleNamedMessageDelegate)obj);
				SyncedInstance<SlendermanConfig>.Synced = true;
				return;
			}
			SyncedInstance<SlendermanConfig>.Synced = false;
			CustomMessagingManager messageManager2 = SyncedInstance<SlendermanConfig>.MessageManager;
			object obj2 = <>O.<1>__OnReceiveSync;
			if (obj2 == null)
			{
				HandleNamedMessageDelegate val2 = OnReceiveSync;
				<>O.<1>__OnReceiveSync = val2;
				obj2 = (object)val2;
			}
			messageManager2.RegisterNamedMessageHandler("SlendermanMod_OnReceiveConfigSync", (HandleNamedMessageDelegate)obj2);
			RequestSync();
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameNetworkManager), "StartDisconnect")]
		public static void PlayerLeave()
		{
			SyncedInstance<SlendermanConfig>.RevertSync();
		}
	}
	internal class SlendermanEnemyAI : EnemyAI
	{
		private enum States
		{
			Absent,
			Stalking,
			Vanishing,
			Chasing
		}

		public PlayerControllerB hauntingPlayer;

		public Renderer enemyMeshRenderer;

		public float timer;

		private float stalkingTimer;

		private float chaseTimer;

		private bool couldNotStareLastAttempt;

		private bool seenByPlayerThisTime;

		private bool disappearWithDelay;

		private bool enemyMeshEnabled;

		private bool vanishWithSound;

		private bool vanishWithJumpscare;

		private bool switchedHauntingPlayer;

		private bool toggleLights;

		private int timesSeenByPlayer;

		private float hauntingIntervalTime;

		private float stalkingIntervalTime;

		private float chaseDuration;

		private float hauntCooldown;

		private bool canFlipLightsBreaker;

		private float slendermanVoiceVolume;

		private bool spawningSoundEnabled;

		private bool approachingSoundEnabled;

		private float approachingSoundChance;

		private float spotFoundSoundChance;

		private bool switchTargetWhenDoorsClosed;

		public static int numSlendermanEnemiesInLevel;

		private int doorsTimesSwitched;

		private bool creepingCloser;

		private float creepingCloserTimer = 4f;

		public GameObject[] outsideNodes;

		public NavMeshHit navHit;

		private Coroutine disappearOnDelayCoroutine;

		public Transform turnCompass;

		public AudioClip chaseSFX;

		public AudioClip ambienceSFX;

		public AudioClip disappearSFX;

		public AudioClip jumpscareSFX;

		public AudioClip approachingSFX;

		public AudioClip spawnFirstTimeSFX;

		public override void Start()
		{
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Start();
			if (((NetworkBehaviour)this).IsServer)
			{
				base.agent = ((Component)this).GetComponent<NavMeshAgent>();
				if ((Object)(object)base.agent == (Object)null)
				{
					Debug.LogError((object)("NavMeshAgent component not found on " + ((Object)this).name));
				}
				((Behaviour)base.agent).enabled = true;
				DisableMesh();
				outsideNodes = GameObject.FindGameObjectsWithTag("OutsideAINode");
				ChoosePlayerToHaunt();
				navHit = default(NavMeshHit);
				hauntCooldown = Plugin.slendermanHauntCooldown;
				_ = hauntCooldown;
				hauntingIntervalTime = Plugin.slendermanHauntIntervalLength;
				_ = hauntingIntervalTime;
				stalkingIntervalTime = Plugin.slendermanStalkingIntervalLength;
				_ = stalkingIntervalTime;
				chaseDuration = Plugin.slendermanChaseDuration;
				_ = chaseDuration;
				canFlipLightsBreaker = Plugin.slendermanFlipsLightBreaker;
				_ = canFlipLightsBreaker;
				spawningSoundEnabled = Plugin.slendermanPlaysSpawningSound;
				_ = spawningSoundEnabled;
				approachingSoundEnabled = Plugin.slendermanPlaysApproachingSound;
				_ = approachingSoundEnabled;
				approachingSoundChance = Plugin.slendermanApproachingSoundChance;
				_ = approachingSoundChance;
				spotFoundSoundChance = Plugin.slendermanSpotFoundSoundChance;
				_ = spotFoundSoundChance;
				switchTargetWhenDoorsClosed = Plugin.slendermanClosedDoorsTargetSwitch;
				_ = switchTargetWhenDoorsClosed;
				Debug.Log((object)"Slenderman spawned in Level.");
				SyncNumSlendermanEnemiesInLevelClientRpc(1);
				slendermanVoiceVolume = Plugin.slendermanVolume;
				SetCreatureVoiceVolumeClientRpc(slendermanVoiceVolume);
				AnimStalkingBaseClientRpc();
				TeleportAway();
				if (spawningSoundEnabled)
				{
					PlaySfxClientRpc("spawnFirstTimeSFX");
				}
			}
		}

		public override void OnDestroy()
		{
			numSlendermanEnemiesInLevel = 0;
			((EnemyAI)this).OnDestroy();
		}

		private void ChoosePlayerToHaunt()
		{
			if (!((NetworkBehaviour)this).IsServer)
			{
				return;
			}
			SyncTimesSeenByPlayerClientRpc(0);
			float num = 0f;
			float num2 = 0f;
			int num3 = 0;
			int num4 = 0;
			for (int i = 0; i < 4; i++)
			{
				if (StartOfRound.Instance.gameStats.allPlayerStats[i].turnAmount > num3)
				{
					num3 = StartOfRound.Instance.gameStats.allPlayerStats[i].turnAmount;
					num4 = i;
				}
				if (StartOfRound.Instance.allPlayerScripts[i].insanityLevel > num)
				{
					num = StartOfRound.Instance.allPlayerScripts[i].insanityLevel;
					num2 = i;
				}
			}
			int[] array = new int[4];
			for (int j = 0; j < 4; j++)
			{
				if (!StartOfRound.Instance.allPlayerScripts[j].isPlayerControlled)
				{
					array[j] = 0;
					continue;
				}
				array[j] += 80;
				if (num2 == (float)j && num > 1f)
				{
					array[j] += 50;
				}
				if (num4 == j)
				{
					array[j] += 30;
				}
				if (!StartOfRound.Instance.allPlayerScripts[j].hasBeenCriticallyInjured)
				{
					array[j] += 10;
				}
				if ((Object)(object)StartOfRound.Instance.allPlayerScripts[j].currentlyHeldObjectServer != (Object)null && StartOfRound.Instance.allPlayerScripts[j].currentlyHeldObjectServer.scrapValue > 100)
				{
					array[j] += 30;
				}
			}
			hauntingPlayer = StartOfRound.Instance.allPlayerScripts[RoundManager.Instance.GetRandomWeightedIndex(array, (Random)null)];
			if (hauntingPlayer.isPlayerDead)
			{
				for (int k = 0; k < StartOfRound.Instance.allPlayerScripts.Length; k++)
				{
					if (!StartOfRound.Instance.allPlayerScripts[k].isPlayerDead)
					{
						hauntingPlayer = StartOfRound.Instance.allPlayerScripts[k];
						break;
					}
				}
			}
			switchedHauntingPlayer = false;
			HandleChangeHauntingPlayerClientRpc((int)hauntingPlayer.playerClientId);
		}

		private Vector3 TryFindingHauntPosition(bool mustBeInLOS = true)
		{
			//IL_0180: 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)
			//IL_002a: 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_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: 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_0161: Unknown result type (might be due to invalid IL or missing references)
			if (hauntingPlayer.isInsideFactory)
			{
				for (int i = 0; i < base.allAINodes.Length; i++)
				{
					if ((!mustBeInLOS || !Physics.Linecast(((Component)hauntingPlayer.gameplayCamera).transform.position, base.allAINodes[i].transform.position, StartOfRound.Instance.collidersAndRoomMaskAndDefault)) && !hauntingPlayer.HasLineOfSightToPosition(base.allAINodes[i].transform.position, 60f, 40, 25f))
					{
						SetStalkingPosition(base.allAINodes[i].transform.position);
						return base.allAINodes[i].transform.position;
					}
				}
			}
			else if (!hauntingPlayer.isInsideFactory)
			{
				for (int j = 0; j < outsideNodes.Length; j++)
				{
					if ((!mustBeInLOS || !Physics.Linecast(((Component)hauntingPlayer.gameplayCamera).transform.position, outsideNodes[j].transform.position, StartOfRound.Instance.collidersAndRoomMaskAndDefault)) && !hauntingPlayer.HasLineOfSightToPosition(outsideNodes[j].transform.position, 70f, 100, 60f))
					{
						SetStalkingPosition(base.allAINodes[j].transform.position);
						return outsideNodes[j].transform.position;
					}
				}
			}
			couldNotStareLastAttempt = true;
			return Vector3.zero;
		}

		private void SetStalkingPosition(Vector3 newPosition)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: 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_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			if (((NetworkBehaviour)this).IsServer && base.currentBehaviourStateIndex != 1)
			{
				((EnemyAI)this).SwitchToBehaviourStateOnLocalClient(1);
				couldNotStareLastAttempt = 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;
				stalkingTimer = stalkingIntervalTime;
				seenByPlayerThisTime = false;
				if ((float)Random.Range(0, 100) < spotFoundSoundChance)
				{
					PlaySfxHauntedPlayerClientRpc("ambienceSFX");
				}
			}
		}

		private IEnumerator disappearOnDelay()
		{
			if (vanishWithJumpscare)
			{
				PlaySfxHauntedPlayerClientRpc("jumpscareSFX");
				vanishWithJumpscare = false;
			}
			yield return (object)new WaitForSeconds(1.5f);
			Disappear();
			disappearOnDelayCoroutine = null;
			if (toggleLights)
			{
				FlipLightsBreaker();
				toggleLights = false;
				canFlipLightsBreaker = false;
			}
			if (vanishWithSound)
			{
				PlaySfxHauntedPlayerClientRpc("disappearSFX");
				vanishWithSound = false;
			}
		}

		private void Disappear()
		{
			if (((NetworkBehaviour)this).IsServer)
			{
				timer = 0f;
				DisableMesh();
				disappearWithDelay = false;
				TeleportAway();
				((EnemyAI)this).SwitchToBehaviourStateOnLocalClient(0);
			}
		}

		private void StartCreepingTowardsPlayer(float movementSpeed = 10f)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			if (!((NetworkBehaviour)this).IsServer)
			{
				return;
			}
			if (!creepingCloser)
			{
				DisableMesh();
				creepingCloser = true;
				base.agent.speed = movementSpeed;
				base.agent.acceleration = 24f;
				((EnemyAI)this).SetDestinationToPosition(((Component)hauntingPlayer).transform.position, false);
				base.moveTowardsDestination = true;
				creepingCloserTimer = 4f;
				timer = 0f;
				if (approachingSoundEnabled)
				{
					int num = Random.Range(0, 100);
					if ((float)num <= approachingSoundChance)
					{
						PlaySfxHauntedPlayerClientRpc("approachingSFX", toggleSpatialBlend: false);
					}
				}
			}
			else
			{
				Debug.Log((object)"Slenderman already creeping closer, abort.");
			}
		}

		private void StopCreepingTowardsPlayer()
		{
			//IL_0037: 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)
			if (((NetworkBehaviour)this).IsServer)
			{
				creepingCloser = false;
				base.agent.speed = 0f;
				base.moveTowardsDestination = false;
				float num = Vector3.Distance(((Component)hauntingPlayer.gameplayCamera).transform.position, ((Component)this).transform.position);
				if (num >= 60f)
				{
					AnimStalkingBaseClientRpc();
				}
				else if (num < 60f && num >= 30f)
				{
					AnimStalking1ClientRpc();
				}
				else
				{
					AnimStalking2ClientRpc();
				}
				if (!enemyMeshEnabled)
				{
					EnableMesh();
				}
			}
		}

		private void SwitchHauntingPlayerTo(PlayerControllerB newHauntingTarget)
		{
			if (!((NetworkBehaviour)this).IsServer)
			{
				return;
			}
			if ((Object)(object)newHauntingTarget != (Object)null)
			{
				hauntingPlayer = null;
				hauntingPlayer = newHauntingTarget;
				SyncTimesSeenByPlayerClientRpc(0);
				if (hauntingPlayer.isPlayerDead)
				{
					for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++)
					{
						if (!StartOfRound.Instance.allPlayerScripts[i].isPlayerDead)
						{
							hauntingPlayer = StartOfRound.Instance.allPlayerScripts[i];
							break;
						}
					}
				}
				HandleChangeHauntingPlayerClientRpc((int)hauntingPlayer.playerClientId);
			}
			else
			{
				Debug.LogWarning((object)"Error: Could not set new hauntingPlayer as assigned newHauntingTarget == null!");
			}
			switchedHauntingPlayer = false;
		}

		private void StartChasing()
		{
			if (((NetworkBehaviour)this).IsServer && base.currentBehaviourStateIndex != 3)
			{
				((EnemyAI)this).SwitchToBehaviourStateOnLocalClient(3);
				disappearWithDelay = false;
				StartChaseAnimClientRpc();
				chaseTimer = chaseDuration;
				timer = 0f;
				base.agent.speed = 13f;
				base.agent.acceleration = 26f;
				base.moveTowardsDestination = true;
				PlaySfxClientRpc("chaseSFX", toggleSpatialBlend: false);
				MessWithLights();
				EnableMesh(visibleToEveryone: true);
			}
		}

		private void StopChasing()
		{
			if (((NetworkBehaviour)this).IsServer)
			{
				base.agent.speed = 0f;
				base.moveTowardsDestination = false;
				StopChaseAnimClientRpc();
				base.creatureVoice.Stop();
				base.creatureSFX.Stop();
				seenByPlayerThisTime = false;
				doorsTimesSwitched = 0;
				((EnemyAI)this).SwitchToBehaviourStateOnLocalClient(2);
			}
		}

		private void TeleportAway()
		{
			//IL_0021: 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_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: 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)
			if (((NetworkBehaviour)this).IsServer)
			{
				int num = Random.Range(25, 200);
				Vector3 val = ((Component)hauntingPlayer).transform.position + Vector3.Scale(new Vector3((float)(-num), 0f, (float)(-num)), ((Component)GameNetworkManager.Instance.localPlayerController).transform.forward);
				base.agent.Warp(val);
			}
		}

		private void HandleChangeHauntingPlayer(int hauntingPlayerId)
		{
			if (hauntingPlayerId == -69420)
			{
				hauntingPlayer = null;
				return;
			}
			PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[hauntingPlayerId];
			hauntingPlayer = val;
		}

		[ClientRpc]
		private void HandleChangeHauntingPlayerClientRpc(int hauntingPlayerId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(198283396u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, hauntingPlayerId);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 198283396u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					HandleChangeHauntingPlayer(hauntingPlayerId);
				}
			}
		}

		[ClientRpc]
		private void SyncTimesSeenByPlayerClientRpc(int timesSeen)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2385237018u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, timesSeen);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2385237018u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && !((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null))
			{
				switch (timesSeen)
				{
				case 0:
					timesSeenByPlayer = 0;
					break;
				case 1:
					timesSeenByPlayer++;
					break;
				case -1:
					timesSeenByPlayer--;
					break;
				default:
					Debug.LogWarning((object)"Slenderman: Synchronization of timesSeenByPlayer - invalid number!");
					break;
				}
			}
		}

		[ClientRpc]
		private void SyncNumSlendermanEnemiesInLevelClientRpc(int numSlendermanEnemies)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2082126723u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, numSlendermanEnemies);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2082126723u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && !((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null))
			{
				switch (numSlendermanEnemies)
				{
				case 0:
					numSlendermanEnemiesInLevel = 0;
					break;
				case 1:
					numSlendermanEnemiesInLevel++;
					break;
				case -1:
					numSlendermanEnemiesInLevel--;
					break;
				default:
					Debug.LogWarning((object)"Slenderman: Synchronization of numSlendermanEnemiesInLevel - invalid number!");
					break;
				}
			}
		}

		[ClientRpc]
		private void StartChaseAnimClientRpc()
		{
			//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(556991154u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 556991154u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					base.creatureAnimator.SetBool("StalkingBase", false);
					base.creatureAnimator.SetBool("Stalking1", false);
					base.creatureAnimator.SetBool("Stalking2", false);
					base.creatureAnimator.SetBool("Chase", true);
				}
			}
		}

		[ClientRpc]
		private void StopChaseAnimClientRpc()
		{
			//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(4108450410u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4108450410u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					base.creatureAnimator.SetBool("Chase", false);
					base.creatureAnimator.SetBool("StalkingBase", true);
				}
			}
		}

		[ClientRpc]
		private void AnimStalkingBaseClientRpc()
		{
			//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(916132259u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 916132259u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					base.creatureAnimator.SetBool("StalkingBase", true);
					base.creatureAnimator.SetBool("Stalking1", false);
					base.creatureAnimator.SetBool("Stalking2", false);
					base.creatureAnimator.SetBool("Chase", false);
				}
			}
		}

		[ClientRpc]
		private void AnimStalking1ClientRpc()
		{
			//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(2420316138u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2420316138u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					base.creatureAnimator.SetBool("StalkingBase", false);
					base.creatureAnimator.SetBool("Stalking1", true);
					base.creatureAnimator.SetBool("Stalking2", false);
					base.creatureAnimator.SetBool("Chase", false);
				}
			}
		}

		[ClientRpc]
		private void AnimStalking2ClientRpc()
		{
			//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(2779633377u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2779633377u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					base.creatureAnimator.SetBool("StalkingBase", false);
					base.creatureAnimator.SetBool("Stalking1", false);
					base.creatureAnimator.SetBool("Stalking2", true);
					base.creatureAnimator.SetBool("Chase", false);
				}
			}
		}

		[ClientRpc]
		private void SetCreatureVoiceVolumeClientRpc(float creatureVoiceVolume)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			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(3175837790u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref creatureVoiceVolume, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3175837790u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					base.creatureVoice.volume = creatureVoiceVolume;
				}
			}
		}

		[ClientRpc]
		private void PlaySfxHauntedPlayerClientRpc(string sfxClipName, bool toggleSpatialBlend = true)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: 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_0088: 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_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: 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(1031461232u, val, (RpcDelivery)0);
				bool flag = sfxClipName != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(sfxClipName, false);
				}
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref toggleSpatialBlend, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1031461232u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && !((Object)(object)hauntingPlayer != (Object)(object)GameNetworkManager.Instance.localPlayerController))
			{
				if (toggleSpatialBlend)
				{
					base.creatureVoice.spatialBlend = 0f;
					base.creatureSFX.spatialBlend = 0f;
				}
				switch (sfxClipName)
				{
				case "ambienceSFX":
					base.creatureVoice.clip = ambienceSFX;
					base.creatureVoice.Play();
					break;
				case "disappearSFX":
					base.creatureSFX.clip = disappearSFX;
					base.creatureSFX.Play();
					break;
				case "chaseSFX":
					base.creatureSFX.clip = chaseSFX;
					base.creatureSFX.Play();
					break;
				case "jumpscareSFX":
					base.creatureVoice.clip = jumpscareSFX;
					base.creatureVoice.Play();
					break;
				case "spawnFirstTimeSFX":
					base.creatureVoice.clip = spawnFirstTimeSFX;
					base.creatureVoice.Play();
					break;
				case "approachingSFX":
					base.creatureVoice.clip = approachingSFX;
					base.creatureVoice.Play();
					break;
				default:
					Debug.LogWarning((object)"Slenderman: Couldn't find assigned SFX sound!");
					return;
				}
				if (toggleSpatialBlend)
				{
					base.creatureVoice.spatialBlend = 1f;
					base.creatureSFX.spatialBlend = 1f;
				}
			}
		}

		[ClientRpc]
		private void PlaySfxClientRpc(string sfxClipName, bool toggleSpatialBlend = true)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: 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_0088: 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_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: 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(1861453801u, val, (RpcDelivery)0);
				bool flag = sfxClipName != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(sfxClipName, false);
				}
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref toggleSpatialBlend, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1861453801u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (toggleSpatialBlend)
				{
					base.creatureVoice.spatialBlend = 0f;
					base.creatureSFX.spatialBlend = 0f;
				}
				switch (sfxClipName)
				{
				case "ambienceSFX":
					base.creatureVoice.clip = ambienceSFX;
					base.creatureVoice.Play();
					break;
				case "disappearSFX":
					base.creatureSFX.clip = disappearSFX;
					base.creatureSFX.Play();
					break;
				case "chaseSFX":
					base.creatureSFX.clip = chaseSFX;
					base.creatureSFX.Play();
					break;
				case "jumpscareSFX":
					base.creatureVoice.clip = jumpscareSFX;
					base.creatureVoice.Play();
					break;
				case "spawnFirstTimeSFX":
					base.creatureVoice.clip = spawnFirstTimeSFX;
					base.creatureVoice.Play();
					break;
				case "approachingSFX":
					base.creatureVoice.clip = approachingSFX;
					base.creatureVoice.Play();
					break;
				default:
					Debug.LogWarning((object)"Slenderman: Couldn't find assigned SFX sound!");
					return;
				}
				if (toggleSpatialBlend)
				{
					base.creatureVoice.spatialBlend = 1f;
					base.creatureSFX.spatialBlend = 1f;
				}
			}
		}

		private void DisableMesh()
		{
			if (((NetworkBehaviour)this).IsServer)
			{
				enemyMeshEnabled = false;
				DisableEnemyMeshClientRpc();
			}
		}

		[ClientRpc]
		private void DisableEnemyMeshClientRpc()
		{
			//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(2930548839u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2930548839u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				if ((Object)(object)enemyMeshRenderer != (Object)null)
				{
					enemyMeshRenderer.enabled = false;
				}
				else
				{
					Debug.LogError((object)"Slenderman Renderer not found on this GameObject!");
				}
			}
		}

		private void EnableMesh(bool visibleToEveryone = false)
		{
			if (((NetworkBehaviour)this).IsServer)
			{
				enemyMeshEnabled = true;
				if (visibleToEveryone)
				{
					EnableEnemyMeshEveryoneClientRpc();
				}
				else
				{
					EnableEnemyMeshClientRpc();
				}
			}
		}

		[ClientRpc]
		private void EnableEnemyMeshEveryoneClientRpc()
		{
			//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(795220426u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 795220426u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				if ((Object)(object)enemyMeshRenderer != (Object)null)
				{
					enemyMeshRenderer.enabled = true;
				}
				else
				{
					Debug.LogError((object)"Slenderman Renderer not found on this GameObject!");
				}
			}
		}

		[ClientRpc]
		private void EnableEnemyMeshClientRpc()
		{
			//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(1983075969u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1983075969u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && !((Object)(object)hauntingPlayer != (Object)(object)GameNetworkManager.Instance.localPlayerController))
			{
				if ((Object)(object)enemyMeshRenderer != (Object)null)
				{
					enemyMeshRenderer.enabled = true;
				}
				else
				{
					Debug.LogError((object)"Couldn't enable Slenderman Renderer for hauntingPlayer only!");
				}
			}
		}

		[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)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3661018855u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3661018855u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			if ((Object)(object)hauntingPlayer == (Object)null)
			{
				Debug.LogWarning((object)"Error: Could not increase fear level - hauntingPlayer == null!");
			}
			else if (!((Object)(object)hauntingPlayer != (Object)(object)GameNetworkManager.Instance.localPlayerController))
			{
				if (timesSeenByPlayer > 0)
				{
					GameNetworkManager.Instance.localPlayerController.JumpToFearLevel(0.8f, true);
					Debug.Log((object)("Jump to fear level 0.8 for player: " + ((Object)hauntingPlayer).name));
				}
				else
				{
					GameNetworkManager.Instance.localPlayerController.JumpToFearLevel(0.2f, true);
					Debug.Log((object)("Jump to fear level 0.2 for player: " + ((Object)hauntingPlayer).name));
				}
			}
		}

		[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)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(803887099u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 803887099u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					GameNetworkManager.Instance.localPlayerController.JumpToFearLevel(0.2f, true);
				}
			}
		}

		private void MessWithLights()
		{
			if (((NetworkBehaviour)this).IsServer)
			{
				RoundManager.Instance.FlickerLights(true, true);
				MessWithLightsClientRpc();
				Debug.Log((object)("Flickering flashlights for player: " + ((Object)hauntingPlayer).name));
			}
		}

		private void FlipLightsBreaker()
		{
			if (((NetworkBehaviour)this).IsServer)
			{
				BreakerBox val = Object.FindObjectOfType<BreakerBox>();
				if ((Object)(object)val != (Object)null)
				{
					val.SetSwitchesOff();
					RoundManager.Instance.TurnOnAllLights(false);
					FlipLightsBreakerClientRpc();
				}
			}
		}

		[ClientRpc]
		private void KillHauntedPlayerClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: 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(2890890656u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2890890656u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && !((Object)(object)hauntingPlayer != (Object)(object)GameNetworkManager.Instance.localPlayerController))
				{
					hauntingPlayer.KillPlayer(Vector3.zero, true, (CauseOfDeath)0, 1, default(Vector3));
				}
			}
		}

		public override void Update()
		{
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: 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_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_047c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0487: Unknown result type (might be due to invalid IL or missing references)
			//IL_0545: Unknown result type (might be due to invalid IL or missing references)
			//IL_0555: 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_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: 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)
			((EnemyAI)this).Update();
			if (!((NetworkBehaviour)this).IsServer || StartOfRound.Instance.allPlayersDead)
			{
				return;
			}
			if ((!hauntingPlayer.isPlayerControlled || hauntingPlayer.isPlayerDead || timesSeenByPlayer >= 8) && !switchedHauntingPlayer)
			{
				switchedHauntingPlayer = true;
				ChoosePlayerToHaunt();
			}
			switch (base.currentBehaviourStateIndex)
			{
			case 0:
			{
				if (enemyMeshEnabled)
				{
					DisableMesh();
				}
				float num2 = hauntCooldown;
				if (couldNotStareLastAttempt)
				{
					num2 = hauntingIntervalTime;
				}
				if (timer > num2)
				{
					timer = 0f;
					TryFindingHauntPosition();
				}
				else if (hauntingPlayer.isInsideFactory)
				{
					timer += Time.deltaTime * 2f;
				}
				else
				{
					timer += Time.deltaTime;
				}
				break;
			}
			case 1:
				if (!enemyMeshEnabled && !creepingCloser)
				{
					EnableMesh();
				}
				turnCompass.LookAt(((Component)hauntingPlayer).transform);
				((Component)this).transform.eulerAngles = new Vector3(((Component)this).transform.eulerAngles.x, turnCompass.eulerAngles.y, ((Component)this).transform.eulerAngles.z);
				if (timer > stalkingTimer)
				{
					float num3 = Vector3.Distance(((Component)hauntingPlayer.gameplayCamera).transform.position, ((Component)this).transform.position);
					if (num3 > 10f)
					{
						timer = 0f;
						StartCreepingTowardsPlayer();
						break;
					}
					if (creepingCloser)
					{
						StopCreepingTowardsPlayer();
					}
					PlaySfxHauntedPlayerClientRpc("jumpscareSFX");
					StartChasing();
				}
				else if (!creepingCloser && !Physics.Linecast(((Component)hauntingPlayer.gameplayCamera).transform.position, ((Component)this).transform.position + Vector3.up * 0.4f, StartOfRound.Instance.collidersAndRoomMask))
				{
					if (hauntingPlayer.HasLineOfSightToPosition(((Component)this).transform.position + Vector3.up * 0.4f, 50f, 100, 5f))
					{
						if (seenByPlayerThisTime)
						{
							break;
						}
						seenByPlayerThisTime = true;
						SyncTimesSeenByPlayerClientRpc(1);
						float num4 = Random.Range(0, 100);
						float num5 = Vector3.Distance(((Component)hauntingPlayer.gameplayCamera).transform.position, ((Component)this).transform.position);
						if (timesSeenByPlayer != 1)
						{
							if (num5 > 80f && num4 <= 1f + (float)timesSeenByPlayer)
							{
								PlaySfxHauntedPlayerClientRpc("jumpscareSFX");
								StartChasing();
							}
							else if (num5 < 80f && num5 > 60f && num4 < 5f + (float)timesSeenByPlayer)
							{
								PlaySfxHauntedPlayerClientRpc("jumpscareSFX");
								StartChasing();
							}
							else if (num5 < 60f && num5 > 40f && num4 < 15f + (float)timesSeenByPlayer)
							{
								PlaySfxHauntedPlayerClientRpc("jumpscareSFX");
								StartChasing();
							}
							else if (num5 < 40f && num5 > 25f && num4 < 30f + (float)timesSeenByPlayer)
							{
								PlaySfxHauntedPlayerClientRpc("jumpscareSFX");
								StartChasing();
							}
							else if (num5 < 25f && num5 > 11f && num4 < 50f + (float)timesSeenByPlayer)
							{
								PlaySfxHauntedPlayerClientRpc("jumpscareSFX");
								StartChasing();
							}
							else if (num5 <= 11f && num4 < 70f + (float)timesSeenByPlayer)
							{
								PlaySfxHauntedPlayerClientRpc("jumpscareSFX");
								StartChasing();
							}
							else
							{
								seenByPlayerThisTime = false;
								disappearWithDelay = true;
								((EnemyAI)this).SwitchToBehaviourStateOnLocalClient(2);
							}
							break;
						}
						if (timesSeenByPlayer == 1)
						{
							if (canFlipLightsBreaker)
							{
								toggleLights = true;
							}
							PlaySfxHauntedPlayerClientRpc("jumpscareSFX", toggleSpatialBlend: false);
						}
						seenByPlayerThisTime = false;
						disappearWithDelay = true;
						((EnemyAI)this).SwitchToBehaviourStateOnLocalClient(2);
					}
					else
					{
						timer += Time.deltaTime;
					}
				}
				else
				{
					timer += Time.deltaTime * 2.5f;
				}
				break;
			case 2:
				if (disappearWithDelay)
				{
					if (disappearOnDelayCoroutine == null)
					{
						float num = Vector3.Distance(((Component)hauntingPlayer.gameplayCamera).transform.position, ((Component)this).transform.position);
						if (num <= 70f && num > 25f)
						{
							vanishWithSound = true;
							MessWithLights();
						}
						else if (num <= 25f)
						{
							vanishWithJumpscare = true;
							MessWithLights();
						}
						disappearOnDelayCoroutine = ((MonoBehaviour)this).StartCoroutine(disappearOnDelay());
					}
				}
				else
				{
					Disappear();
				}
				break;
			case 3:
				if (switchTargetWhenDoorsClosed && hauntingPlayer.isInHangarShipRoom && StartOfRound.Instance.hangarDoorsClosed && doorsTimesSwitched <= 10 && !switchedHauntingPlayer)
				{
					switchedHauntingPlayer = true;
					doorsTimesSwitched++;
					ChoosePlayerToHaunt();
				}
				if (chaseTimer <= 0f || Vector3.Distance(((Component)this).transform.position, ((Component)hauntingPlayer).transform.position) > 100f)
				{
					StopChasing();
				}
				else
				{
					chaseTimer -= Time.deltaTime;
				}
				break;
			}
		}

		public override void DoAIInterval()
		{
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).DoAIInterval();
			if (!((NetworkBehaviour)this).IsServer)
			{
				return;
			}
			switch (base.currentBehaviourStateIndex)
			{
			case 1:
				if (creepingCloser && timer > creepingCloserTimer)
				{
					StopCreepingTowardsPlayer();
				}
				break;
			case 3:
				if ((Object)(object)hauntingPlayer != (Object)null && !hauntingPlayer.isPlayerDead)
				{
					((EnemyAI)this).SetDestinationToPosition(((Component)hauntingPlayer).transform.position, false);
				}
				else if (base.moveTowardsDestination)
				{
					base.moveTowardsDestination = false;
					base.destination = ((Component)this).transform.position;
					base.agent.SetDestination(base.destination);
				}
				break;
			}
		}

		private PlayerControllerB PlayerMeetsStandardCollisionConditions(Collider other)
		{
			if (!((NetworkBehaviour)this).IsServer)
			{
				return null;
			}
			if (base.isEnemyDead)
			{
				return null;
			}
			if (!base.ventAnimationFinished)
			{
				return null;
			}
			if (base.stunNormalizedTimer >= 0f)
			{
				return null;
			}
			PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
			if ((Object)(object)component == (Object)null)
			{
				return null;
			}
			if (!component.isPlayerDead && (double)component.sinkingValue < 0.7300000190734863)
			{
				return component;
			}
			return null;
		}

		public override void OnCollideWithPlayer(Collider other)
		{
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).OnCollideWithPlayer(other);
			if (!((NetworkBehaviour)this).IsServer)
			{
				return;
			}
			PlayerControllerB val = PlayerMeetsStandardCollisionConditions(other);
			if ((Object)(object)val != (Object)null)
			{
				Debug.Log((object)"Slenderman: collided with player");
				if ((Object)(object)val == (Object)(object)hauntingPlayer)
				{
					if (base.currentBehaviourStateIndex == 1)
					{
						if (!creepingCloser)
						{
							Debug.Log((object)"Slenderman: collided with hauntingPlayer during stalking phase!");
							((EnemyAI)this).SwitchToBehaviourStateOnLocalClient(2);
						}
					}
					else if (base.currentBehaviourStateIndex == 3)
					{
						hauntingPlayer.KillPlayer(Vector3.zero, true, (CauseOfDeath)0, 1, default(Vector3));
						KillHauntedPlayerClientRpc();
						Debug.Log((object)"Slenderman: killed player");
						base.moveTowardsDestination = false;
						disappearWithDelay = false;
						StopChasing();
					}
				}
				else if (base.currentBehaviourStateIndex == 1 && creepingCloser)
				{
					switchedHauntingPlayer = true;
					SwitchHauntingPlayerTo(val);
					StopChasing();
				}
				else if (base.currentBehaviourStateIndex == 3)
				{
					switchedHauntingPlayer = true;
					SwitchHauntingPlayerTo(val);
					StopChasing();
				}
				else
				{
					Debug.Log((object)"Slenderman: collided with non-haunted player outside of a chase.");
					((EnemyAI)this).SwitchToBehaviourStateOnLocalClient(2);
				}
			}
			else
			{
				Debug.LogWarning((object)"ERROR: Slenderman player collision: playerControllerB == null!!!!!!!!!!!!!!!!!!!");
			}
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_SlendermanEnemyAI()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Expected O, but got Unknown
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Expected O, but got Unknown
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Expected O, but got Unknown
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Expected O, but got Unknown
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Expected O, but got Unknown
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Expected O, but got Unknown
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Expected O, but got Unknown
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Expected O, but got Unknown
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Expected O, but got Unknown
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(198283396u, new RpcReceiveHandler(__rpc_handler_198283396));
			NetworkManager.__rpc_func_table.Add(2385237018u, new RpcReceiveHandler(__rpc_handler_2385237018));
			NetworkManager.__rpc_func_table.Add(2082126723u, new RpcReceiveHandler(__rpc_handler_2082126723));
			NetworkManager.__rpc_func_table.Add(556991154u, new RpcReceiveHandler(__rpc_handler_556991154));
			NetworkManager.__rpc_func_table.Add(4108450410u, new RpcReceiveHandler(__rpc_handler_4108450410));
			NetworkManager.__rpc_func_table.Add(916132259u, new RpcReceiveHandler(__rpc_handler_916132259));
			NetworkManager.__rpc_func_table.Add(2420316138u, new RpcReceiveHandler(__rpc_handler_2420316138));
			NetworkManager.__rpc_func_table.Add(2779633377u, new RpcReceiveHandler(__rpc_handler_2779633377));
			NetworkManager.__rpc_func_table.Add(3175837790u, new RpcReceiveHandler(__rpc_handler_3175837790));
			NetworkManager.__rpc_func_table.Add(1031461232u, new RpcReceiveHandler(__rpc_handler_1031461232));
			NetworkManager.__rpc_func_table.Add(1861453801u, new RpcReceiveHandler(__rpc_handler_1861453801));
			NetworkManager.__rpc_func_table.Add(2930548839u, new RpcReceiveHandler(__rpc_handler_2930548839));
			NetworkManager.__rpc_func_table.Add(795220426u, new RpcReceiveHandler(__rpc_handler_795220426));
			NetworkManager.__rpc_func_table.Add(1983075969u, new RpcReceiveHandler(__rpc_handler_1983075969));
			NetworkManager.__rpc_func_table.Add(3661018855u, new RpcReceiveHandler(__rpc_handler_3661018855));
			NetworkManager.__rpc_func_table.Add(803887099u, new RpcReceiveHandler(__rpc_handler_803887099));
			NetworkManager.__rpc_func_table.Add(2890890656u, new RpcReceiveHandler(__rpc_handler_2890890656));
		}

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

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

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

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

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

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

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

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

		private static void __rpc_handler_3175837790(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				float creatureVoiceVolumeClientRpc = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref creatureVoiceVolumeClientRpc, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((SlendermanEnemyAI)(object)target).SetCreatureVoiceVolumeClientRpc(creatureVoiceVolumeClientRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1031461232(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string sfxClipName = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref sfxClipName, false);
				}
				bool toggleSpatialBlend = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref toggleSpatialBlend, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((SlendermanEnemyAI)(object)target).PlaySfxHauntedPlayerClientRpc(sfxClipName, toggleSpatialBlend);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1861453801(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string sfxClipName = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref sfxClipName, false);
				}
				bool toggleSpatialBlend = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref toggleSpatialBlend, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((SlendermanEnemyAI)(object)target).PlaySfxClientRpc(sfxClipName, toggleSpatialBlend);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

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

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

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

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

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

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

		protected internal override string __getTypeName()
		{
			return "SlendermanEnemyAI";
		}
	}
	public class SlendermanNetworkHandler : NetworkBehaviour
	{
		public static SlendermanNetworkHandler Instance { get; private set; }

		public static event Action<string> LevelEvent;

		public override void OnNetworkSpawn()
		{
			SlendermanNetworkHandler.LevelEvent = null;
			if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
			{
				SlendermanNetworkHandler instance = Instance;
				if (instance != null)
				{
					((Component)instance).gameObject.GetComponent<NetworkObject>().Despawn(true);
				}
			}
			Instance = this;
			((NetworkBehaviour)this).OnNetworkSpawn();
		}

		[ClientRpc]
		public void EventClientRpc(string eventName)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: 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_0088: 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_00ba: 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)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(196005081u, val, (RpcDelivery)0);
				bool flag = eventName != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(eventName, false);
				}
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 196005081u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				SlendermanNetworkHandler.LevelEvent?.Invoke(eventName);
			}
		}

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

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

		private static void __rpc_handler_196005081(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string eventName = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref eventName, false);
				}
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((SlendermanNetworkHandler)(object)target).EventClientRpc(eventName);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "SlendermanNetworkHandler";
		}
	}
	[Serializable]
	public class SyncedInstance<T>
	{
		[NonSerialized]
		protected static int IntSize = 4;

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

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

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

		public static T Default { get; private set; }

		public static T Instance { get; private set; }

		public static bool Synced { get; internal set; }

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

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

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

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

		public static T DeserializeFromBytes(byte[] data)
		{
			BinaryFormatter binaryFormatter = new BinaryFormatter();
			using MemoryStream serializationStream = new MemoryStream(data);
			try
			{
				return (T)binaryFormatter.Deserialize(serializationStream);
			}
			catch (Exception arg)
			{
				Plugin.Logger.LogError((object)$"Error deserializing instance: {arg}");
				return default(T);
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "SlendermanMod";

		public const string PLUGIN_NAME = "SlendermanMod";

		public const string PLUGIN_VERSION = "1.1.9";
	}
}
namespace SlendermanMod.Patches
{
	[HarmonyPatch]
	public class NetworkObjectManager
	{
		private static GameObject networkPrefab;

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameNetworkManager), "Start")]
		public static void Init()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			if (!((Object)(object)networkPrefab != (Object)null))
			{
				networkPrefab = (GameObject)Plugin.SlendermanAssets.LoadAsset("SlendermanNetworkHandler");
				networkPrefab.AddComponent<SlendermanNetworkHandler>();
				NetworkManager.Singleton.AddNetworkPrefab(networkPrefab);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(StartOfRound), "Awake")]
		private static void SpawnNetworkHandler()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
			{
				GameObject val = Object.Instantiate<GameObject>(networkPrefab, Vector3.zero, Quaternion.identity);
				val.GetComponent<NetworkObject>().Spawn(false);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(RoundManager), "GenerateNewFloor")]
		private static void SubscribeToHandler()
		{
			SlendermanNetworkHandler.LevelEvent += ReceivedEventFromServer;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(RoundManager), "DespawnPropsAtEndOfRound")]
		private static void UnsubscribeFromHandler()
		{
			SlendermanNetworkHandler.LevelEvent -= ReceivedEventFromServer;
		}

		private static void ReceivedEventFromServer(string eventName)
		{
		}

		private static void SendEventToClients(string eventName)
		{
			if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
			{
				SlendermanNetworkHandler.Instance.EventClientRpc(eventName);
			}
		}
	}
}
namespace SlendermanMod.Behaviours
{
	i