Decompiled source of Vecna v1.0.3

Vecna.dll

Decompiled 6 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.Collections;
using Unity.Jobs;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Audio;
using UnityEngine.Rendering;
using Vecna;
using Vecna.Configuration;
using Vecna.NetcodePatcher;

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

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Vecna
{
	[BepInPlugin("Reiko88.Vecna", "Vecna", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(Terminal))]
		public class TerminalKeywordPatch
		{
			[HarmonyPatch("Awake")]
			[HarmonyPostfix]
			public static void AddExtraKeywords(Terminal __instance)
			{
				TerminalKeyword val = ModAssets.LoadAsset<TerminalKeyword>("HenryTK");
				TerminalKeyword val2 = ModAssets.LoadAsset<TerminalKeyword>("CreelTK");
				if (!((Object)(object)val == (Object)null) && !((Object)(object)val2 == (Object)null))
				{
					List<TerminalKeyword> list = __instance.terminalNodes.allKeywords.ToList();
					if (!list.Contains(val))
					{
						list.Add(val);
					}
					if (!list.Contains(val2))
					{
						list.Add(val2);
					}
					__instance.terminalNodes.allKeywords = list.ToArray();
					Logger.LogInfo((object)"Successfully injected extra Vecna keywords into the Terminal!");
				}
			}
		}

		internal static ManualLogSource Logger;

		public static AssetBundle? ModAssets;

		public static GameObject? ClockPrefab;

		public static GameObject? ClonePrefab;

		internal static PluginConfig BoundConfig { get; private set; }

		private void Awake()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			Harmony val = new Harmony("Reiko88.Vecna");
			val.PatchAll(typeof(TerminalKeywordPatch));
			val.PatchAll(typeof(VecnaEnemyAIPatch));
			val.PatchAll(typeof(VecnaAudioMixerPatch));
			val.PatchAll(typeof(VecnaEventManager));
			val.PatchAll(typeof(VecnaTeleportInterceptPatch));
			Logger = ((BaseUnityPlugin)this).Logger;
			BoundConfig = new PluginConfig(((BaseUnityPlugin)this).Config);
			InitializeNetworkBehaviours();
			string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "vecnabundle");
			ModAssets = AssetBundle.LoadFromFile(text);
			if ((Object)(object)ModAssets == (Object)null)
			{
				Logger.LogError((object)"Failed to load vecnabundle bundle.");
				return;
			}
			ClockPrefab = ModAssets.LoadAsset<GameObject>("GrandfatherClock");
			Logger.LogInfo((object)"Vecna Clock Prefab loaded successfully!");
			ClonePrefab = ModAssets.LoadAsset<GameObject>("Scavenger");
			Logger.LogInfo((object)"player clone Prefab loaded successfully!");
			EnemyType val2 = ModAssets.LoadAsset<EnemyType>("vecnaEnemy");
			TerminalNode val3 = ModAssets.LoadAsset<TerminalNode>("VecnaTN");
			TerminalKeyword val4 = ModAssets.LoadAsset<TerminalKeyword>("VecnaTK");
			if ((Object)(object)val2 == (Object)null)
			{
				Logger.LogError((object)"Failed to load Vecna EnemyType from Asset Bundle!");
				return;
			}
			NetworkPrefabs.RegisterNetworkPrefab(val2.enemyPrefab);
			Enemies.RegisterEnemy(val2, BoundConfig.SpawnWeight.Value, (LevelTypes)(-1), val3, val4);
			Logger.LogInfo((object)"Plugin Vecna is loaded and assets are registered!");
		}

		private static void InitializeNetworkBehaviours()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}
	}
	public class VecnaAI : EnemyAI
	{
		public enum VecnaPhase
		{
			Cooldown,
			ClockStalking,
			ClockSpotted,
			Chasing,
			ExecutingKill
		}

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

			private object <>2__current;

			public PlayerControllerB dyingPlayer;

			public VecnaAI <>4__this;

			private float <timer>5__1;

			private float <timeToRightElbow>5__2;

			private float <timeToLeftElbow>5__3;

			private float <timeToRightKnee>5__4;

			private float <timeToLeftKnee>5__5;

			private float[] <snapDelays>5__6;

			private Transform <rightElbow>5__7;

			private Transform <leftElbow>5__8;

			private Transform <leftKnee>5__9;

			private Transform <rightKnee>5__10;

			private Transform <cloneHead>5__11;

			private Transform[] <snapBones>5__12;

			private AudioSource <cloneAudio>5__13;

			private Transform[] <>s__14;

			private int <>s__15;

			private Transform <t>5__16;

			private string <cleanName>5__17;

			private int <i>5__18;

			private float <audioTimer>5__19;

			private Vector3 <snapPos>5__20;

			private AudioSource <cloneAudio>5__21;

			private Vector3 <splashPos>5__22;

			private Vector3 <headPos>5__23;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<snapDelays>5__6 = null;
				<rightElbow>5__7 = null;
				<leftElbow>5__8 = null;
				<leftKnee>5__9 = null;
				<rightKnee>5__10 = null;
				<cloneHead>5__11 = null;
				<snapBones>5__12 = null;
				<cloneAudio>5__13 = null;
				<>s__14 = null;
				<t>5__16 = null;
				<cleanName>5__17 = null;
				<cloneAudio>5__21 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0488: Unknown result type (might be due to invalid IL or missing references)
				//IL_0471: Unknown result type (might be due to invalid IL or missing references)
				//IL_048d: Unknown result type (might be due to invalid IL or missing references)
				//IL_04ca: Unknown result type (might be due to invalid IL or missing references)
				//IL_015b: Unknown result type (might be due to invalid IL or missing references)
				//IL_054e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0553: Unknown result type (might be due to invalid IL or missing references)
				//IL_0559: Unknown result type (might be due to invalid IL or missing references)
				//IL_0526: Unknown result type (might be due to invalid IL or missing references)
				//IL_052b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0535: Unknown result type (might be due to invalid IL or missing references)
				//IL_053a: Unknown result type (might be due to invalid IL or missing references)
				//IL_050f: Unknown result type (might be due to invalid IL or missing references)
				//IL_05f3: Unknown result type (might be due to invalid IL or missing references)
				//IL_05f8: Unknown result type (might be due to invalid IL or missing references)
				//IL_05fe: Unknown result type (might be due to invalid IL or missing references)
				//IL_05d2: Unknown result type (might be due to invalid IL or missing references)
				//IL_05d7: Unknown result type (might be due to invalid IL or missing references)
				//IL_05e1: Unknown result type (might be due to invalid IL or missing references)
				//IL_05e6: Unknown result type (might be due to invalid IL or missing references)
				//IL_05a7: Unknown result type (might be due to invalid IL or missing references)
				//IL_05ac: Unknown result type (might be due to invalid IL or missing references)
				//IL_05b6: Unknown result type (might be due to invalid IL or missing references)
				//IL_05bb: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<timer>5__1 = 0f;
					goto IL_007d;
				case 1:
					<>1__state = -1;
					goto IL_007d;
				case 2:
					{
						<>1__state = -1;
						goto IL_0437;
					}
					IL_007d:
					if (<timer>5__1 < 1f)
					{
						if (<>4__this.currentLocalPhase != VecnaPhase.ExecutingKill)
						{
							return false;
						}
						<timer>5__1 += Time.deltaTime;
						<>2__current = null;
						<>1__state = 1;
						return true;
					}
					if ((Object)(object)<>4__this.activeCloneAnim != (Object)null)
					{
						((Behaviour)<>4__this.activeCloneAnim).enabled = true;
						<>4__this.activeCloneAnim.SetTrigger(AnimHasDied);
						if (!<>4__this.cursingLocalPlayer && (Object)(object)<>4__this.liftTelekinesisClip != (Object)null)
						{
							<cloneAudio>5__13 = <>4__this.activeClone.GetComponent<AudioSource>();
							if ((Object)(object)<cloneAudio>5__13 != (Object)null)
							{
								<cloneAudio>5__13.PlayOneShot(<>4__this.liftTelekinesisClip, 1f);
							}
							else
							{
								AudioSource.PlayClipAtPoint(<>4__this.liftTelekinesisClip, <>4__this.activeClone.transform.position, 1f);
							}
							<cloneAudio>5__13 = null;
						}
					}
					<timeToRightElbow>5__2 = 3.2f;
					<timeToLeftElbow>5__3 = 0.3f;
					<timeToRightKnee>5__4 = 1f;
					<timeToLeftKnee>5__5 = 0.2f;
					<snapDelays>5__6 = new float[4] { <timeToRightElbow>5__2, <timeToLeftElbow>5__3, <timeToRightKnee>5__4, <timeToLeftKnee>5__5 };
					<rightElbow>5__7 = null;
					<leftElbow>5__8 = null;
					<leftKnee>5__9 = null;
					<rightKnee>5__10 = null;
					<cloneHead>5__11 = null;
					if ((Object)(object)<>4__this.activeClone != (Object)null)
					{
						<>s__14 = <>4__this.activeClone.GetComponentsInChildren<Transform>();
						for (<>s__15 = 0; <>s__15 < <>s__14.Length; <>s__15++)
						{
							<t>5__16 = <>s__14[<>s__15];
							<cleanName>5__17 = ((Object)<t>5__16).name.ToLower().Replace(".", "").Replace("_", "");
							if (<cleanName>5__17.Contains("armrlower"))
							{
								<rightElbow>5__7 = <t>5__16;
							}
							else if (<cleanName>5__17.Contains("armllower"))
							{
								<leftElbow>5__8 = <t>5__16;
							}
							else if (<cleanName>5__17.Contains("shinl") || <cleanName>5__17.Contains("calfl"))
							{
								<leftKnee>5__9 = <t>5__16;
							}
							else if (<cleanName>5__17.Contains("shinr") || <cleanName>5__17.Contains("calfr"))
							{
								<rightKnee>5__10 = <t>5__16;
							}
							else if (<cleanName>5__17.Contains("spine004") || <cleanName>5__17.Contains("head"))
							{
								<cloneHead>5__11 = <t>5__16;
							}
							<cleanName>5__17 = null;
							<t>5__16 = null;
						}
						<>s__14 = null;
					}
					<snapBones>5__12 = (Transform[])(object)new Transform[4] { <leftElbow>5__8, <rightElbow>5__7, <rightKnee>5__10, <leftKnee>5__9 };
					<i>5__18 = 0;
					goto IL_0624;
					IL_0437:
					if (<audioTimer>5__19 < <snapDelays>5__6[<i>5__18])
					{
						if (<>4__this.currentLocalPhase != VecnaPhase.ExecutingKill)
						{
							return false;
						}
						<audioTimer>5__19 += Time.deltaTime;
						<>2__current = null;
						<>1__state = 2;
						return true;
					}
					<snapPos>5__20 = (((Object)(object)<>4__this.activeClone != (Object)null) ? <>4__this.activeClone.transform.position : ((Component)dyingPlayer).transform.position);
					<cloneAudio>5__21 = (((Object)(object)<>4__this.activeClone != (Object)null) ? <>4__this.activeClone.GetComponent<AudioSource>() : null);
					<>4__this.audioTools.PlayBoneSnap(<snapPos>5__20, <cloneAudio>5__21);
					<splashPos>5__22 = (((Object)(object)<snapBones>5__12[<i>5__18] != (Object)null) ? <snapBones>5__12[<i>5__18].position : (((Object)(object)<>4__this.activeClone != (Object)null) ? (<>4__this.activeClone.transform.position + Vector3.up * 1.5f) : ((Component)dyingPlayer).transform.position));
					VecnaVFXHelper.CreateSmallBloodSplash(<splashPos>5__22);
					if (<i>5__18 >= 2)
					{
						<headPos>5__23 = (((Object)(object)<cloneHead>5__11 != (Object)null) ? <cloneHead>5__11.position : (((Object)(object)<>4__this.activeClone != (Object)null) ? (<>4__this.activeClone.transform.position + Vector3.up * 1.6f) : (((Component)dyingPlayer).transform.position + Vector3.up * 1.6f)));
						VecnaVFXHelper.CreateSmallBloodSplash(<headPos>5__23);
					}
					<cloneAudio>5__21 = null;
					<i>5__18++;
					goto IL_0624;
					IL_0624:
					if (<i>5__18 < 4)
					{
						<audioTimer>5__19 = 0f;
						goto IL_0437;
					}
					return false;
				}
			}

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

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

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

			private object <>2__current;

			public VecnaAI <>4__this;

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

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

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

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

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					if ((Object)(object)((EnemyAI)<>4__this).creatureAnimator != (Object)null)
					{
						((EnemyAI)<>4__this).creatureAnimator.SetTrigger(AnimBlastDoor);
					}
					<>2__current = <>4__this.wait1Point5Seconds;
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					if ((Object)(object)((EnemyAI)<>4__this).creatureAnimator != (Object)null)
					{
						((EnemyAI)<>4__this).creatureAnimator.SetTrigger(AnimBlastDoorDone);
					}
					return false;
				}
			}

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

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

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

			private object <>2__current;

			public GameObject fakeBody;

			public PlayerControllerB victim;

			public Vector3 dirToPlayer;

			public bool isLocalPlayer;

			public VecnaAI <>4__this;

			private ScanNodeProperties <scanNode>5__1;

			private Exception <e>5__2;

			private Rigidbody[] <>s__3;

			private int <>s__4;

			private Rigidbody <rb>5__5;

			private Renderer[] <bodyRenderers>5__6;

			private Canvas[] <bodyCanvases>5__7;

			private Renderer[] <>s__8;

			private int <>s__9;

			private Renderer <r>5__10;

			private Canvas[] <>s__11;

			private int <>s__12;

			private Canvas <c>5__13;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<scanNode>5__1 = null;
				<e>5__2 = null;
				<>s__3 = null;
				<rb>5__5 = null;
				<bodyRenderers>5__6 = null;
				<bodyCanvases>5__7 = null;
				<>s__8 = null;
				<r>5__10 = null;
				<>s__11 = null;
				<c>5__13 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_012b: 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_013a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0144: Unknown result type (might be due to invalid IL or missing references)
				//IL_0149: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = <>4__this.waitEndOfFrame;
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					if ((Object)(object)fakeBody == (Object)null || (Object)(object)victim == (Object)null)
					{
						return false;
					}
					<scanNode>5__1 = fakeBody.GetComponentInChildren<ScanNodeProperties>();
					if ((Object)(object)<scanNode>5__1 != (Object)null)
					{
						<scanNode>5__1.headerText = "Body of " + victim.playerUsername;
						<scanNode>5__1.subText = "Cause of death: Unknown";
					}
					try
					{
						VecnaVFXHelper.DressCloneLikePlayer(fakeBody, victim);
					}
					catch (Exception ex)
					{
						<e>5__2 = ex;
						Debug.LogWarning((object)("VECNA: Safely caught cosmetic error: " + <e>5__2.Message));
					}
					<>s__3 = fakeBody.GetComponentsInChildren<Rigidbody>();
					for (<>s__4 = 0; <>s__4 < <>s__3.Length; <>s__4++)
					{
						<rb>5__5 = <>s__3[<>s__4];
						<rb>5__5.AddForce(dirToPlayer * 5f + Vector3.down * 4f, (ForceMode)1);
						<rb>5__5 = null;
					}
					<>s__3 = null;
					if (!isLocalPlayer)
					{
						<bodyRenderers>5__6 = fakeBody.GetComponentsInChildren<Renderer>(true);
						<>s__8 = <bodyRenderers>5__6;
						for (<>s__9 = 0; <>s__9 < <>s__8.Length; <>s__9++)
						{
							<r>5__10 = <>s__8[<>s__9];
							<r>5__10.enabled = false;
							<r>5__10 = null;
						}
						<>s__8 = null;
						<bodyCanvases>5__7 = fakeBody.GetComponentsInChildren<Canvas>(true);
						<>s__11 = <bodyCanvases>5__7;
						for (<>s__12 = 0; <>s__12 < <>s__11.Length; <>s__12++)
						{
							<c>5__13 = <>s__11[<>s__12];
							((Behaviour)<c>5__13).enabled = false;
							<c>5__13 = null;
						}
						<>s__11 = null;
						<bodyRenderers>5__6 = null;
						<bodyCanvases>5__7 = null;
					}
					return false;
				}
			}

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

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

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

			private object <>2__current;

			public PlayerControllerB victim;

			public VecnaAI <>4__this;

			private float <liftDuration>5__1;

			private float <elapsed>5__2;

			private Vector3 <startPos>5__3;

			private Vector3 <targetPos>5__4;

			private RaycastHit <hit>5__5;

			private Vector3 <dirToVecna>5__6;

			private Quaternion <startBodyRot>5__7;

			private Quaternion <targetBodyRot>5__8;

			private Quaternion <startCamRot>5__9;

			private Vector3 <originalCamRot>5__10;

			private float <holdDuration>5__11;

			private float <holdTimer>5__12;

			private Vector3 <currentCamRotEulers>5__13;

			private Vector3 <finalDeathPos>5__14;

			private float <t>5__15;

			private Vector3 <vecnaFace>5__16;

			private Vector3 <dirFromCam>5__17;

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

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

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

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

			private bool MoveNext()
			{
				//IL_00b5: 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)
				//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)
				//IL_00da: Unknown result type (might be due to invalid IL or missing references)
				//IL_00df: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
				//IL_04b9: Unknown result type (might be due to invalid IL or missing references)
				//IL_04be: Unknown result type (might be due to invalid IL or missing references)
				//IL_0156: Unknown result type (might be due to invalid IL or missing references)
				//IL_0166: Unknown result type (might be due to invalid IL or missing references)
				//IL_016b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0170: Unknown result type (might be due to invalid IL or missing references)
				//IL_019d: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
				//IL_0110: Unknown result type (might be due to invalid IL or missing references)
				//IL_013a: Unknown result type (might be due to invalid IL or missing references)
				//IL_013f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0144: Unknown result type (might be due to invalid IL or missing references)
				//IL_0592: Unknown result type (might be due to invalid IL or missing references)
				//IL_059c: Expected O, but got Unknown
				//IL_04ef: Unknown result type (might be due to invalid IL or missing references)
				//IL_04f4: Unknown result type (might be due to invalid IL or missing references)
				//IL_04fe: Unknown result type (might be due to invalid IL or missing references)
				//IL_0503: Unknown result type (might be due to invalid IL or missing references)
				//IL_0508: Unknown result type (might be due to invalid IL or missing references)
				//IL_0543: Unknown result type (might be due to invalid IL or missing references)
				//IL_055c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0566: Expected O, but got Unknown
				//IL_05de: Unknown result type (might be due to invalid IL or missing references)
				//IL_05fa: Unknown result type (might be due to invalid IL or missing references)
				//IL_060b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0615: Unknown result type (might be due to invalid IL or missing references)
				//IL_061b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0440: Unknown result type (might be due to invalid IL or missing references)
				//IL_0445: Unknown result type (might be due to invalid IL or missing references)
				//IL_0481: Unknown result type (might be due to invalid IL or missing references)
				//IL_025d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0263: Unknown result type (might be due to invalid IL or missing references)
				//IL_026e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0285: Unknown result type (might be due to invalid IL or missing references)
				//IL_028b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0296: Unknown result type (might be due to invalid IL or missing references)
				//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
				//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
				//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
				//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
				//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
				//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
				//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
				//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
				//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
				//IL_0302: Unknown result type (might be due to invalid IL or missing references)
				//IL_0308: Unknown result type (might be due to invalid IL or missing references)
				//IL_030d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0318: Unknown result type (might be due to invalid IL or missing references)
				//IL_03e3: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					victim.inAnimationWithEnemy = (EnemyAI)(object)<>4__this;
					victim.disableLookInput = true;
					victim.disableMoveInput = true;
					victim.disableInteract = true;
					((Collider)victim.thisController).enabled = false;
					<liftDuration>5__1 = 3f;
					<elapsed>5__2 = 0f;
					<startPos>5__3 = ((Component)victim).transform.position;
					<targetPos>5__4 = <startPos>5__3 + new Vector3(0f, 1.5f, 0f);
					if (Physics.Raycast(<startPos>5__3, Vector3.up, ref <hit>5__5, 2.6f, StartOfRound.Instance.collidersAndRoomMask))
					{
						<targetPos>5__4 = <startPos>5__3 + new Vector3(0f, Mathf.Max(0f, ((RaycastHit)(ref <hit>5__5)).distance - 0.5f), 0f);
					}
					<dirToVecna>5__6 = ((Component)<>4__this).transform.position - ((Component)victim).transform.position;
					<dirToVecna>5__6.y = 0f;
					((Vector3)(ref <dirToVecna>5__6)).Normalize();
					<startBodyRot>5__7 = ((Component)victim).transform.rotation;
					<targetBodyRot>5__8 = Quaternion.LookRotation(<dirToVecna>5__6);
					<startCamRot>5__9 = ((Component)victim.gameplayCamera).transform.rotation;
					<originalCamRot>5__10 = ((Component)victim.gameplayCamera).transform.localEulerAngles;
					goto IL_035b;
				case 1:
					<>1__state = -1;
					goto IL_035b;
				case 2:
					<>1__state = -1;
					goto IL_0418;
				case 3:
					<>1__state = -1;
					<finalDeathPos>5__14 = ((Component)victim).transform.position;
					if ((Object)(object)<>4__this.activeClone != (Object)null)
					{
						<finalDeathPos>5__14 = <>4__this.activeClone.transform.position + Vector3.up * 0.1f;
						((Collider)victim.thisController).enabled = true;
						Object.Destroy((Object)(object)<>4__this.activeClone);
						<>4__this.activeClone = null;
						victim.TeleportPlayer(<finalDeathPos>5__14, false, 0f, false, true);
						<>2__current = (object)new WaitForSeconds(0.8f);
						<>1__state = 4;
						return true;
					}
					((Collider)victim.thisController).enabled = true;
					<>2__current = (object)new WaitForSeconds(0.4f);
					<>1__state = 5;
					return true;
				case 4:
					<>1__state = -1;
					break;
				case 5:
					{
						<>1__state = -1;
						break;
					}
					IL_035b:
					if (<elapsed>5__2 < <liftDuration>5__1)
					{
						<elapsed>5__2 += Time.deltaTime;
						<t>5__15 = Mathf.SmoothStep(0f, 1f, <elapsed>5__2 / <liftDuration>5__1);
						if (!victim.playerCollider.enabled)
						{
							victim.playerCollider.enabled = true;
						}
						((Component)victim).transform.position = Vector3.Lerp(<startPos>5__3, <targetPos>5__4, <t>5__15);
						((Component)victim).transform.rotation = Quaternion.Slerp(<startBodyRot>5__7, <targetBodyRot>5__8, <t>5__15);
						<vecnaFace>5__16 = ((Component)<>4__this).transform.position + Vector3.up * 2.4f;
						<dirFromCam>5__17 = <vecnaFace>5__16 - ((Component)victim.gameplayCamera).transform.position;
						((Component)victim.gameplayCamera).transform.rotation = Quaternion.Slerp(<startCamRot>5__9, Quaternion.LookRotation(<dirFromCam>5__17), <t>5__15);
						victim.fallValue = 0f;
						victim.fallValueUncapped = 0f;
						<>2__current = null;
						<>1__state = 1;
						return true;
					}
					<holdDuration>5__11 = 2.7f;
					<holdTimer>5__12 = 0f;
					goto IL_0418;
					IL_0418:
					if (<holdTimer>5__12 < <holdDuration>5__11)
					{
						if (!victim.playerCollider.enabled)
						{
							victim.playerCollider.enabled = true;
						}
						victim.fallValue = 0f;
						victim.fallValueUncapped = 0f;
						((Component)victim).transform.position = <targetPos>5__4;
						<holdTimer>5__12 += Time.deltaTime;
						<>2__current = null;
						<>1__state = 2;
						return true;
					}
					<currentCamRotEulers>5__13 = ((Component)victim.gameplayCamera).transform.localEulerAngles;
					((Component)victim.gameplayCamera).transform.localEulerAngles = new Vector3(<currentCamRotEulers>5__13.x - 45f, <currentCamRotEulers>5__13.y + 60f, 70f);
					<>2__current = <>4__this.wait0Point21Seconds;
					<>1__state = 3;
					return true;
				}
				VecnaVFXHelper.TogglePlayerThirdPersonModel(<>4__this, victim, isVisible: true);
				((Collider)victim.thisController).enabled = false;
				((Component)victim).transform.position = <finalDeathPos>5__14;
				((Component)victim.gameplayCamera).transform.localEulerAngles = <originalCamRot>5__10;
				victim.KillPlayer(Vector3.zero, true, (CauseOfDeath)4, 0, default(Vector3));
				victim.inAnimationWithEnemy = null;
				victim.disableLookInput = false;
				victim.disableMoveInput = false;
				victim.disableInteract = false;
				if (!victim.isPlayerDead)
				{
					((Collider)victim.thisController).enabled = true;
					victim.fallValue = 0f;
					victim.fallValueUncapped = 0f;
				}
				if (<>4__this.cursingLocalPlayer)
				{
					VecnaVFXHelper.ToggleTeammatesForVictim(<>4__this, isVisible: true);
				}
				return false;
			}

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

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

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

			private object <>2__current;

			public PlayerControllerB victim;

			public VecnaAI <>4__this;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0095: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
				//IL_0166: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = <>4__this.wait5Seconds;
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					if ((Object)(object)victim != (Object)null && !victim.isPlayerDead)
					{
						victim.bloodDropTimer = -1f;
						victim.DropBlood(Vector3.down, true, false);
						<>2__current = <>4__this.wait1Point5Seconds;
						<>1__state = 2;
						return true;
					}
					break;
				case 2:
					<>1__state = -1;
					if ((Object)(object)victim != (Object)null && !victim.isPlayerDead)
					{
						victim.bloodDropTimer = -1f;
						victim.DropBlood(Vector3.down, true, false);
					}
					<>2__current = <>4__this.wait2Seconds;
					<>1__state = 3;
					return true;
				case 3:
					<>1__state = -1;
					if ((Object)(object)victim != (Object)null && !victim.isPlayerDead)
					{
						victim.bloodDropTimer = -1f;
						victim.DropBlood(Vector3.down, true, false);
					}
					break;
				}
				return false;
			}

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

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

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

			private object <>2__current;

			public PlayerControllerB victim;

			public AudioClip snapClip;

			public float delayTime;

			public VecnaAI <>4__this;

			private GameObject <audioSpawner>5__1;

			private AudioSource <snapSource>5__2;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_0031: Expected O, but got Unknown
				//IL_006c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0076: Expected O, but got Unknown
				//IL_0091: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(delayTime);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					if ((Object)(object)snapClip != (Object)null && (Object)(object)victim != (Object)null)
					{
						<audioSpawner>5__1 = new GameObject("VecnaSnapAudio");
						<audioSpawner>5__1.transform.position = ((Component)victim.gameplayCamera).transform.position;
						<snapSource>5__2 = <audioSpawner>5__1.AddComponent<AudioSource>();
						<snapSource>5__2.clip = snapClip;
						<snapSource>5__2.spatialBlend = 0f;
						<snapSource>5__2.volume = 1f;
						if ((Object)(object)SoundManager.Instance != (Object)null && (Object)(object)SoundManager.Instance.diageticMixer != (Object)null)
						{
							<snapSource>5__2.outputAudioMixerGroup = SoundManager.Instance.diageticMixer.FindMatchingGroups("Master")[0];
						}
						<snapSource>5__2.Play();
						Object.Destroy((Object)(object)<audioSpawner>5__1, snapClip.length + 0.5f);
						<audioSpawner>5__1 = null;
						<snapSource>5__2 = null;
					}
					return false;
				}
			}

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

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

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

			private object <>2__current;

			public VecnaAI <>4__this;

			private string <message>5__1;

			private float <delay>5__2;

			private int <i>5__3;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0046: Unknown result type (might be due to invalid IL or missing references)
				//IL_0050: Expected O, but got Unknown
				//IL_0191: Unknown result type (might be due to invalid IL or missing references)
				//IL_019b: Expected O, but got Unknown
				//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ea: Expected O, but got Unknown
				//IL_010e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0118: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(10f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					if ((Object)(object)<>4__this.cursingPlayer != (Object)null && <>4__this.cursingPlayer.isInHangarShipRoom && <>4__this.currentLocalPhase != VecnaPhase.ExecutingKill && (Object)(object)HUDManager.Instance != (Object)null && (Object)(object)HUDManager.Instance.signalTranslatorText != (Object)null)
					{
						if ((Object)(object)HUDManager.Instance.signalTranslatorAnimator != (Object)null)
						{
							HUDManager.Instance.signalTranslatorAnimator.SetBool("transmitting", true);
						}
						((TMP_Text)HUDManager.Instance.signalTranslatorText).text = "";
						<>2__current = (object)new WaitForSeconds(1.2f);
						<>1__state = 2;
						return true;
					}
					break;
				case 2:
					<>1__state = -1;
					<message>5__1 = "YOU CANT HIDE";
					<delay>5__2 = 2.5f / (float)<message>5__1.Length;
					<i>5__3 = 0;
					goto IL_01be;
				case 3:
					<>1__state = -1;
					<i>5__3++;
					goto IL_01be;
				case 4:
					{
						<>1__state = -1;
						if ((Object)(object)HUDManager.Instance.signalTranslatorAnimator != (Object)null)
						{
							HUDManager.Instance.signalTranslatorAnimator.SetBool("transmitting", false);
						}
						<message>5__1 = null;
						break;
					}
					IL_01be:
					if (<i>5__3 < <message>5__1.Length)
					{
						TextMeshProUGUI signalTranslatorText = HUDManager.Instance.signalTranslatorText;
						((TMP_Text)signalTranslatorText).text = ((TMP_Text)signalTranslatorText).text + <message>5__1[<i>5__3];
						<>2__current = (object)new WaitForSeconds(<delay>5__2);
						<>1__state = 3;
						return true;
					}
					<>2__current = (object)new WaitForSeconds(3f);
					<>1__state = 4;
					return true;
				}
				return false;
			}

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

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

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

			private object <>2__current;

			public PlayerControllerB victim;

			public VecnaAI <>4__this;

			private float <timer>5__1;

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

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

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

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

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<timer>5__1 = 0f;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if (<timer>5__1 < 6.35f && <>4__this.currentLocalPhase == VecnaPhase.ExecutingKill)
				{
					<timer>5__1 += Time.deltaTime;
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				if ((Object)(object)victim != (Object)null)
				{
					VecnaVFXHelper.TogglePlayerThirdPersonModel(<>4__this, victim, isVisible: true);
				}
				return false;
			}

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

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

		private static readonly int AnimStartWalk = Animator.StringToHash("startWalk");

		private static readonly int AnimBlastDoor = Animator.StringToHash("blastDoor");

		private static readonly int AnimBlastDoorDone = Animator.StringToHash("blastDoorDone");

		private static readonly int AnimSwingAttack = Animator.StringToHash("swingAttack");

		private static readonly int AnimHasDied = Animator.StringToHash("hasDied");

		private readonly WaitForSeconds wait5Seconds = new WaitForSeconds(5f);

		private readonly WaitForSeconds wait1Point5Seconds = new WaitForSeconds(1.5f);

		private readonly WaitForSeconds wait2Seconds = new WaitForSeconds(2f);

		private readonly WaitForSeconds wait0Point21Seconds = new WaitForSeconds(0.21f);

		private readonly WaitForSeconds wait0Point15Seconds = new WaitForSeconds(0.15f);

		private readonly WaitForEndOfFrame waitEndOfFrame = new WaitForEndOfFrame();

		public static List<VecnaAI> ActiveInstances = new List<VecnaAI>();

		public VecnaEnvironmentManipulator environmentTools;

		public VecnaAudioManager audioTools;

		public VecnaStats stats;

		public AudioSource vecnaSnapAudioSource;

		public AudioClip playerSnapClip;

		public AudioSource breathingAudioSource;

		public AudioClip[] breathingClips;

		public AudioClip[] executionVoiceLines;

		public AudioClip[] clockSpotTaunts;

		public AudioClip[] escapeVoiceLines;

		public AudioClip finalChimeClip;

		public AudioClip doorTelekinesisClip;

		public AudioClip liftTelekinesisClip;

		public AudioClip vecnafpexecution;

		public bool canKill = false;

		public float SFXVolumeLerpTo = 1f;

		public AudioSource chimechase;

		public float maxChaseMusicVolume = 1f;

		public float musicFadeRadius = 25f;

		public float fadeSpeed = 2f;

		private bool hasPlayedShipTaunt = false;

		private Coroutine shipTauntCoroutine;

		public float spawnTimer = 0f;

		public float unspottedTimer = 0f;

		public BoomboxItem[] cachedBoomboxes;

		private Light[] cachedLights;

		private DoorLock[] cachedDoors;

		private float slowScanTimer = 0f;

		private const float SLOW_SCAN_INTERVAL = 2f;

		public GameObject activeClone = null;

		public Animator activeCloneAnim = null;

		public float boomboxRescueTimer = 0f;

		public bool isPortalOpen = false;

		public bool spectatorInUpsideDown = false;

		public GameObject currentClock;

		public float stareTimer = 0f;

		public PlayerControllerB cursingPlayer;

		public bool cursingLocalPlayer;

		public HashSet<Renderer> hiddenCosmetics = new HashSet<Renderer>();

		public Dictionary<Light, float> hiddenLights = new Dictionary<Light, float>();

		public Dictionary<Renderer, int> hiddenTeammateLayers = new Dictionary<Renderer, int>();

		private bool isVecnaVisible = true;

		public int storedCameraMask = -1;

		public Camera storedCamera = null;

		public const int PORTAL_ONLY_LAYER = 31;

		public const int UPSIDE_DOWN_LAYER = 30;

		private int timesChoosingAPlayer;

		private Random vecnaCurseRandom;

		private bool initializedRandomSeed;

		public float hauntCooldownTimer = 0f;

		public VecnaPortalManager portalManager;

		public GameObject[] outsideNodes;

		public GameObject[] insideNodes;

		public float chaseTimer = 0f;

		public int clocksSpawned = 0;

		public VecnaCinematicDirector cinematicDirector;

		[HideInInspector]
		public NetworkVariable<VecnaPhase> currentPhase = new NetworkVariable<VecnaPhase>(VecnaPhase.Cooldown, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public VecnaPhase currentLocalPhase = VecnaPhase.Cooldown;

		private IVecnaState currentState;

		public static List<PlayerControllerB> UpsideDownPlayers = new List<PlayerControllerB>();

		[ServerRpc(RequireOwnership = false)]
		public void RequestChaseStartServerRpc(int victimId, Vector3 spawnPos)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3884433865u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, victimId);
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref spawnPos);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3884433865u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					SyncChaseStartClientRpc(victimId, spawnPos);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void RequestHauntEndServerRpc(bool repelledByMusic, bool playerKilled)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: 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_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2643355442u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref repelledByMusic, default(ForPrimitives));
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref playerKilled, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2643355442u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					SyncHauntEndClientRpc(repelledByMusic, playerKilled);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void RequestCinematicKillServerRpc(int victimId, Vector3 stopPos, Vector3 lookDir)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(525788326u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, victimId);
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref stopPos);
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref lookDir);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 525788326u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					SyncCinematicKillClientRpc(victimId, stopPos, lookDir);
				}
			}
		}

		public override void OnNetworkSpawn()
		{
			((NetworkBehaviour)this).OnNetworkSpawn();
			NetworkVariable<VecnaPhase> obj = currentPhase;
			obj.OnValueChanged = (OnValueChangedDelegate<VecnaPhase>)(object)Delegate.Combine((Delegate?)(object)obj.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<VecnaPhase>(OnPhaseChanged));
		}

		public override void OnNetworkDespawn()
		{
			((NetworkBehaviour)this).OnNetworkDespawn();
			NetworkVariable<VecnaPhase> obj = currentPhase;
			obj.OnValueChanged = (OnValueChangedDelegate<VecnaPhase>)(object)Delegate.Remove((Delegate?)(object)obj.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<VecnaPhase>(OnPhaseChanged));
		}

		private void OnPhaseChanged(VecnaPhase oldPhase, VecnaPhase newPhase)
		{
			if (currentState != null)
			{
				currentState.Exit();
			}
			switch (newPhase)
			{
			case VecnaPhase.Cooldown:
				currentState = new VecnaCooldownState(this);
				break;
			case VecnaPhase.ClockStalking:
				currentState = new VecnaClockStalkingState(this);
				break;
			case VecnaPhase.ClockSpotted:
				currentState = new VecnaClockSpottedState(this);
				break;
			case VecnaPhase.Chasing:
				currentState = new VecnaChaseState(this);
				break;
			case VecnaPhase.ExecutingKill:
				currentState = new VecnaExecutingKillState(this);
				break;
			}
			if (currentState != null)
			{
				currentState.Enter();
			}
		}

		private void Awake()
		{
			environmentTools = new VecnaEnvironmentManipulator(this);
			audioTools = new VecnaAudioManager(this);
			cinematicDirector = new VecnaCinematicDirector(this);
			portalManager = new VecnaPortalManager(this);
		}

		public override void Start()
		{
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Invalid comparison between Unknown and I4
			((EnemyAI)this).Start();
			if (currentState == null)
			{
				currentState = new VecnaCooldownState(this);
				currentState.Enter();
			}
			if ((Object)(object)Plugin.ClockPrefab != (Object)null)
			{
				AudioSource[] componentsInChildren = Plugin.ClockPrefab.GetComponentsInChildren<AudioSource>(true);
				foreach (AudioSource val in componentsInChildren)
				{
					if ((Object)(object)val != (Object)null && (Object)(object)val.clip != (Object)null && (int)val.clip.loadState != 2)
					{
						val.clip.LoadAudioData();
					}
				}
			}
			if ((Object)(object)stats == (Object)null)
			{
				Debug.LogWarning((object)"VECNA: Stats ScriptableObject not assigned! Creating a fallback instance.");
				stats = ScriptableObject.CreateInstance<VecnaStats>();
			}
			Plugin.BoundConfig.ApplyTo(stats);
			for (int j = 0; j < 32; j++)
			{
				Physics.IgnoreLayerCollision(31, j, true);
				Physics.IgnoreLayerCollision(30, j, true);
			}
			if (ActiveInstances.Count > 0 && (Object)(object)ActiveInstances[0] != (Object)(object)this)
			{
				if (!((Object)(object)ActiveInstances[0] == (Object)null) && !((EnemyAI)ActiveInstances[0]).isEnemyDead && ((Component)ActiveInstances[0]).gameObject.activeInHierarchy)
				{
					Debug.LogWarning((object)"VECNA: A duplicate Vecna tried to spawn!.");
					ToggleGhostVisuals(isVisible: false);
					if (((NetworkBehaviour)this).IsServer)
					{
						((Component)this).GetComponent<NetworkObject>().Despawn(true);
					}
					return;
				}
				ActiveInstances[0] = this;
			}
			else if (!ActiveInstances.Contains(this))
			{
				ActiveInstances.Add(this);
			}
			if (!RoundManager.Instance.hasInitializedLevelRandomSeed)
			{
				RoundManager.Instance.InitializeRandomNumberGenerators();
			}
			outsideNodes = GameObject.FindGameObjectsWithTag("OutsideAINode");
			insideNodes = GameObject.FindGameObjectsWithTag("AINode");
			if (((NetworkBehaviour)this).IsServer)
			{
				ChoosePlayerToCurse();
			}
			ToggleGhostVisuals(isVisible: false);
			Debug.Log((object)"!!!VECNA CURSE TAKEN HOLD!!!");
			ScanNodeProperties componentInChildren = ((Component)this).GetComponentInChildren<ScanNodeProperties>(true);
			Terminal val2 = Object.FindObjectOfType<Terminal>();
			if (!((Object)(object)componentInChildren != (Object)null) || !((Object)(object)val2 != (Object)null))
			{
				return;
			}
			foreach (TerminalNode enemyFile in val2.enemyFiles)
			{
				if ((Object)(object)enemyFile != (Object)null && enemyFile.creatureName == "Vecna")
				{
					componentInChildren.creatureScanID = enemyFile.creatureFileID;
					break;
				}
			}
		}

		private void OnEnable()
		{
			VecnaEventManager.OnShipLeft += OnShipLeft;
			VecnaEventManager.OnPlayerDied += OnVictimDied;
			VecnaEventManager.OnPlayerDisconnect += OnVictimDisconnected;
		}

		private void OnDisable()
		{
			VecnaEventManager.OnShipLeft -= OnShipLeft;
			VecnaEventManager.OnPlayerDied -= OnVictimDied;
			VecnaEventManager.OnPlayerDisconnect -= OnVictimDisconnected;
		}

		private void OnShipLeft()
		{
			if (currentPhase.Value == VecnaPhase.Chasing || currentPhase.Value == VecnaPhase.ClockStalking)
			{
				ResetHaunt(repelledByMusic: true);
			}
		}

		private void OnVictimDied(PlayerControllerB deadPlayer)
		{
			if (((NetworkBehaviour)this).IsServer && !((Object)(object)cursingPlayer != (Object)(object)deadPlayer))
			{
				if (currentPhase.Value != VecnaPhase.ExecutingKill && currentPhase.Value != 0)
				{
					ResetHaunt(repelledByMusic: false);
				}
				else if (currentPhase.Value == VecnaPhase.Cooldown && hauntCooldownTimer <= 0f)
				{
					Debug.Log((object)"VECNA: Target missing/dead. Choosing new victim!");
					ChoosePlayerToCurse();
					currentPhase.Value = VecnaPhase.ClockStalking;
				}
			}
		}

		private void OnVictimDisconnected(PlayerControllerB disconnectedPlayer)
		{
			OnVictimDied(disconnectedPlayer);
		}

		private void PerformSlowEnvironmentScan()
		{
			slowScanTimer += Time.deltaTime;
			if (slowScanTimer >= 2f)
			{
				slowScanTimer = 0f;
				cachedBoomboxes = Object.FindObjectsOfType<BoomboxItem>();
			}
		}

		public override void OnDestroy()
		{
			((EnemyAI)this).OnDestroy();
			if ((Object)(object)currentClock != (Object)null)
			{
				Object.Destroy((Object)(object)currentClock);
			}
			if ((Object)(object)activeClone != (Object)null)
			{
				Object.Destroy((Object)(object)activeClone);
				activeClone = null;
			}
			if ((Object)(object)cinematicDirector.activeFakeBody != (Object)null)
			{
				Object.Destroy((Object)(object)cinematicDirector.activeFakeBody);
				cinematicDirector.activeFakeBody = null;
			}
			environmentTools?.RestoreLights();
			audioTools?.StopChaseMusic();
			UpsideDownPlayers.Clear();
			if (ActiveInstances.Contains(this))
			{
				ActiveInstances.Remove(this);
			}
			Debug.Log((object)"VECNA: Destroyed. Round wiped and memory cleared.");
		}

		public void ChoosePlayerToCurse()
		{
			timesChoosingAPlayer++;
			SFXVolumeLerpTo = 0f;
			if (timesChoosingAPlayer <= 1)
			{
				spawnTimer = stats.spawnInterval - 10f;
				Debug.Log((object)"VECNA: Level started. First clock spawning in 10 seconds...");
			}
			else
			{
				spawnTimer = stats.spawnInterval - 5f;
				Debug.Log((object)"VECNA: Target eliminated. Acquiring new target in 5 seconds...");
			}
			clocksSpawned = 0;
			hasPlayedShipTaunt = false;
			if ((Object)(object)base.creatureVoice != (Object)null)
			{
				base.creatureVoice.Stop();
			}
			if (!initializedRandomSeed)
			{
				vecnaCurseRandom = new Random(StartOfRound.Instance.randomMapSeed + 158);
				initializedRandomSeed = true;
			}
			float num = 0f;
			float num2 = 0f;
			int num3 = 0;
			int num4 = 0;
			for (int i = 0; i < 4; i++)
			{
				PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[i];
				if (!((Object)(object)val == (Object)null))
				{
					if (StartOfRound.Instance.gameStats != null && StartOfRound.Instance.gameStats.allPlayerStats != null && i < StartOfRound.Instance.gameStats.allPlayerStats.Length && StartOfRound.Instance.gameStats.allPlayerStats[i].turnAmount > num3)
					{
						num3 = StartOfRound.Instance.gameStats.allPlayerStats[i].turnAmount;
						num4 = i;
					}
					if (val.insanityLevel > num)
					{
						num = val.insanityLevel;
						num2 = i;
					}
				}
			}
			int[] array = new int[4];
			for (int j = 0; j < 4; j++)
			{
				PlayerControllerB val2 = StartOfRound.Instance.allPlayerScripts[j];
				if ((Object)(object)val2 == (Object)null || !val2.isPlayerControlled || val2.isPlayerDead)
				{
					array[j] = 0;
					continue;
				}
				array[j] += 80;
				if (num2 == (float)j && num > 1f)
				{
					array[j] += 50;
				}
				if (num4 == j)
				{
					array[j] += 30;
				}
				if (!val2.hasBeenCriticallyInjured)
				{
					array[j] += 10;
				}
				if ((Object)(object)val2.currentlyHeldObjectServer != (Object)null && val2.currentlyHeldObjectServer.scrapValue > 150)
				{
					array[j] += 30;
				}
			}
			int randomWeightedIndex = RoundManager.Instance.GetRandomWeightedIndex(array, vecnaCurseRandom);
			cursingPlayer = StartOfRound.Instance.allPlayerScripts[randomWeightedIndex];
			if ((Object)(object)cursingPlayer == (Object)null)
			{
				cursingPlayer = GameNetworkManager.Instance.localPlayerController;
			}
			if (((NetworkBehaviour)this).IsServer && (Object)(object)cursingPlayer != (Object)null)
			{
				SyncVictimClientRpc((int)cursingPlayer.playerClientId);
			}
			if ((Object)(object)cursingPlayer != (Object)null)
			{
				((EnemyAI)this).ChangeOwnershipOfEnemy(cursingPlayer.actualClientId);
				cursingLocalPlayer = (Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)(object)cursingPlayer;
			}
		}

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

		[ClientRpc]
		public void SyncVictimClientRpc(int victimPlayerId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1430063458u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, victimPlayerId);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1430063458u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					cursingPlayer = StartOfRound.Instance.allPlayerScripts[victimPlayerId];
					cursingLocalPlayer = (Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)(object)cursingPlayer;
					((MonoBehaviour)this).StartCoroutine(NosebleedRoutine(cursingPlayer));
					Debug.Log((object)$"VECNA: Network synced! The victim is {cursingPlayer.playerUsername}. Local: {cursingLocalPlayer}");
				}
			}
		}

		public override void Update()
		{
			((EnemyAI)this).Update();
			if (!base.isEnemyDead && !StartOfRound.Instance.allPlayersDead)
			{
				environmentTools.UpdateScanner(Time.deltaTime);
				PerformSlowEnvironmentScan();
				UpdateGlobalVisuals();
				currentState?.Update();
			}
		}

		private void UpdateGlobalVisuals()
		{
			bool flag = (currentLocalPhase == VecnaPhase.Chasing || currentLocalPhase == VecnaPhase.ExecutingKill) && IsVictimOrSpectatingVictim();
			if (base.skinnedMeshRenderers != null && base.skinnedMeshRenderers.Length != 0)
			{
				if (((Renderer)base.skinnedMeshRenderers[0]).enabled != flag)
				{
					ToggleGhostVisuals(flag);
				}
			}
			else if (isVecnaVisible != flag)
			{
				ToggleGhostVisuals(flag);
			}
			if (GameNetworkManager.Instance.localPlayerController.isPlayerDead)
			{
				bool flag2 = IsVictimOrSpectatingVictim();
				if ((Object)(object)currentClock != (Object)null)
				{
					Renderer[] componentsInChildren = currentClock.GetComponentsInChildren<Renderer>(true);
					if (componentsInChildren.Length != 0 && componentsInChildren[0].enabled != flag2)
					{
						Renderer[] array = componentsInChildren;
						foreach (Renderer val in array)
						{
							val.enabled = flag2;
						}
						AudioSource[] componentsInChildren2 = currentClock.GetComponentsInChildren<AudioSource>(true);
						AudioSource[] array2 = componentsInChildren2;
						foreach (AudioSource val2 in array2)
						{
							val2.volume = (flag2 ? 1f : 0f);
						}
					}
				}
				if ((Object)(object)activeClone != (Object)null)
				{
					Renderer[] componentsInChildren3 = activeClone.GetComponentsInChildren<Renderer>(true);
					if (componentsInChildren3.Length != 0 && componentsInChildren3[0].enabled == flag2)
					{
						Renderer[] array3 = componentsInChildren3;
						foreach (Renderer val3 in array3)
						{
							val3.enabled = !flag2;
						}
						Canvas[] componentsInChildren4 = activeClone.GetComponentsInChildren<Canvas>(true);
						Canvas[] array4 = componentsInChildren4;
						foreach (Canvas val4 in array4)
						{
							((Behaviour)val4).enabled = !flag2;
						}
					}
				}
				if ((Object)(object)cinematicDirector.activeFakeBody != (Object)null)
				{
					Renderer[] componentsInChildren5 = cinematicDirector.activeFakeBody.GetComponentsInChildren<Renderer>(true);
					if (componentsInChildren5.Length != 0 && componentsInChildren5[0].enabled != flag2)
					{
						Renderer[] array5 = componentsInChildren5;
						foreach (Renderer val5 in array5)
						{
							val5.enabled = flag2;
						}
						Canvas[] componentsInChildren6 = cinematicDirector.activeFakeBody.GetComponentsInChildren<Canvas>(true);
						Canvas[] array6 = componentsInChildren6;
						foreach (Canvas val6 in array6)
						{
							((Behaviour)val6).enabled = flag2;
						}
					}
				}
				if (!cursingLocalPlayer)
				{
					if (flag && !spectatorInUpsideDown)
					{
						spectatorInUpsideDown = true;
						if (currentLocalPhase == VecnaPhase.Chasing)
						{
							audioTools.StartChaseMusic();
						}
						VecnaVFXHelper.ToggleTeammatesForVictim(this, isVisible: false);
						foreach (EnemyAI spawnedEnemy in RoundManager.Instance.SpawnedEnemies)
						{
							if (!((Object)(object)spawnedEnemy != (Object)null) || !((Object)(object)spawnedEnemy != (Object)(object)this))
							{
								continue;
							}
							AudioSource[] componentsInChildren7 = ((Component)spawnedEnemy).GetComponentsInChildren<AudioSource>(true);
							foreach (AudioSource val7 in componentsInChildren7)
							{
								if ((Object)(object)val7 != (Object)null)
								{
									val7.mute = true;
								}
							}
						}
						BoomboxItem[] array7 = Object.FindObjectsOfType<BoomboxItem>();
						foreach (BoomboxItem val8 in array7)
						{
							if ((Object)(object)val8 != (Object)null && (Object)(object)val8.boomboxAudio != (Object)null)
							{
								val8.boomboxAudio.mute = true;
							}
						}
					}
					else if (!flag && spectatorInUpsideDown)
					{
						spectatorInUpsideDown = false;
						audioTools.StopChaseMusic();
						VecnaVFXHelper.ToggleTeammatesForVictim(this, isVisible: true);
						foreach (EnemyAI spawnedEnemy2 in RoundManager.Instance.SpawnedEnemies)
						{
							if (!((Object)(object)spawnedEnemy2 != (Object)null) || !((Object)(object)spawnedEnemy2 != (Object)(object)this) || spawnedEnemy2.isEnemyDead)
							{
								continue;
							}
							AudioSource[] componentsInChildren8 = ((Component)spawnedEnemy2).GetComponentsInChildren<AudioSource>(true);
							foreach (AudioSource val9 in componentsInChildren8)
							{
								if ((Object)(object)val9 != (Object)null)
								{
									val9.mute = false;
								}
							}
						}
						BoomboxItem[] array8 = Object.FindObjectsOfType<BoomboxItem>();
						foreach (BoomboxItem val10 in array8)
						{
							if ((Object)(object)val10 != (Object)null && (Object)(object)val10.boomboxAudio != (Object)null)
							{
								val10.boomboxAudio.mute = false;
							}
						}
					}
				}
			}
			if ((currentLocalPhase == VecnaPhase.Chasing || currentLocalPhase == VecnaPhase.ExecutingKill) && (Object)(object)cursingPlayer != (Object)null)
			{
				VecnaVFXHelper.TogglePlayerThirdPersonModel(this, cursingPlayer, isVisible: false);
				cursingPlayer.timeSinceMakingLoudNoise = 100f;
				if ((cursingLocalPlayer || (GameNetworkManager.Instance.localPlayerController.isPlayerDead && flag)) && currentPhase.Value == VecnaPhase.Chasing)
				{
					audioTools.HandleBreathing();
					VecnaVFXHelper.EnforceTeammateHeldItems(this);
				}
			}
			if (cursingLocalPlayer && (Object)(object)cursingPlayer != (Object)null && cursingPlayer.isInHangarShipRoom && !hasPlayedShipTaunt)
			{
				hasPlayedShipTaunt = true;
				if (shipTauntCoroutine != null)
				{
					((MonoBehaviour)this).StopCoroutine(shipTauntCoroutine);
				}
				shipTauntCoroutine = ((MonoBehaviour)this).StartCoroutine(ShipTransmissionRoutine());
			}
		}

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

		private void LateUpdate()
		{
			portalManager?.UpdatePortalRotation();
			if (IsVictimOrSpectatingVictim() && (currentLocalPhase == VecnaPhase.Chasing || currentLocalPhase == VecnaPhase.ExecutingKill))
			{
				PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
				Camera val = localPlayerController.gameplayCamera;
				if (localPlayerController.isPlayerDead && (Object)(object)StartOfRound.Instance.spectateCamera != (Object)null)
				{
					val = StartOfRound.Instance.spectateCamera;
				}
				if ((Object)(object)val != (Object)null)
				{
					Camera obj = val;
					obj.cullingMask &= 0x7FFFFFFF;
					Camera obj2 = val;
					obj2.cullingMask |= 0x40000000;
				}
			}
		}

		[ClientRpc]
		public void TogglePortalClientRpc(bool open, NetworkObjectReference boomboxRef, Vector3 position)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: 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_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1111366090u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref open, default(ForPrimitives));
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref boomboxRef, default(ForNetworkSerializable));
				((FastBufferWriter)(ref val2)).WriteValueSafe(ref position);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1111366090u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			if (!IsVictimOrSpectatingVictim())
			{
				return;
			}
			if (open)
			{
				BoomboxItem val3 = null;
				NetworkObject val4 = default(NetworkObject);
				if (((NetworkObjectReference)(ref boomboxRef)).TryGet(ref val4, (NetworkManager)null))
				{
					val3 = ((Component)val4).GetComponent<BoomboxItem>();
				}
				if ((Object)(object)val3 == (Object)null)
				{
					BoomboxItem[] array = Object.FindObjectsOfType<BoomboxItem>();
					foreach (BoomboxItem val5 in array)
					{
						if (val5.isPlayingMusic)
						{
							val3 = val5;
							break;
						}
					}
				}
				portalManager.TogglePortal(open: true, val3, position);
			}
			else
			{
				portalManager.TogglePortal(open: false, null, position);
			}
		}

		public bool IsVictimOrSpectatingVictim()
		{
			if ((Object)(object)cursingPlayer == (Object)null)
			{
				return false;
			}
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			if ((Object)(object)localPlayerController == (Object)null)
			{
				return false;
			}
			if ((Object)(object)localPlayerController == (Object)(object)cursingPlayer)
			{
				return true;
			}
			if (localPlayerController.isPlayerDead && (Object)(object)localPlayerController.spectatedPlayerScript == (Object)(object)cursingPlayer)
			{
				return true;
			}
			return false;
		}

		public bool JobifiedClockLineOfSightCheck()
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: 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_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)cursingPlayer == (Object)null || (Object)(object)currentClock == (Object)null)
			{
				return false;
			}
			Camera gameplayCamera = cursingPlayer.gameplayCamera;
			if ((Object)(object)gameplayCamera == (Object)null)
			{
				return false;
			}
			Vector3 position = ((Component)gameplayCamera).transform.position;
			Vector3 forward = ((Component)gameplayCamera).transform.forward;
			Vector3 position2 = currentClock.transform.position;
			Vector3 val = currentClock.transform.position + Vector3.up * 1.5f;
			Vector3 val2 = position2 - position;
			Vector3 normalized = ((Vector3)(ref val2)).normalized;
			val2 = val - position;
			Vector3 normalized2 = ((Vector3)(ref val2)).normalized;
			bool flag = Vector3.Dot(forward, normalized) > 0.5f;
			bool flag2 = Vector3.Dot(forward, normalized2) > 0.5f;
			if (!flag && !flag2)
			{
				return false;
			}
			int collidersAndRoomMask = StartOfRound.Instance.collidersAndRoomMask;
			QueryParameters val3 = default(QueryParameters);
			((QueryParameters)(ref val3))..ctor(collidersAndRoomMask, false, (QueryTriggerInteraction)1, false);
			NativeArray<RaycastCommand> val4 = default(NativeArray<RaycastCommand>);
			val4..ctor(2, (Allocator)3, (NativeArrayOptions)1);
			NativeArray<RaycastHit> val5 = default(NativeArray<RaycastHit>);
			val5..ctor(2, (Allocator)3, (NativeArrayOptions)1);
			val4[0] = new RaycastCommand(position, normalized, val3, Mathf.Max(0f, Vector3.Distance(position, position2) - 0.1f));
			val4[1] = new RaycastCommand(position, normalized2, val3, Mathf.Max(0f, Vector3.Distance(position, val) - 0.1f));
			JobHandle val6 = RaycastCommand.ScheduleBatch(val4, val5, 1, default(JobHandle));
			((JobHandle)(ref val6)).Complete();
			RaycastHit val7 = val5[0];
			bool flag3 = (Object)(object)((RaycastHit)(ref val7)).collider != (Object)null;
			val7 = val5[1];
			bool flag4 = (Object)(object)((RaycastHit)(ref val7)).collider != (Object)null;
			val4.Dispose();
			val5.Dispose();
			return (flag && !flag3) || (flag2 && !flag4);
		}

		public bool TrySpawningClock()
		{
			//IL_0082: 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_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)cursingPlayer == (Object)null || insideNodes == null || outsideNodes == null)
			{
				return false;
			}
			GameObject[] array = (cursingPlayer.isInsideFactory ? insideNodes : outsideNodes);
			List<GameObject> list = new List<GameObject>();
			GameObject[] array2 = array;
			foreach (GameObject val in array2)
			{
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				float num = Vector3.Distance(((Component)cursingPlayer).transform.position, val.transform.position);
				if (num > 3f && num < 15f && !cursingPlayer.HasLineOfSightToPosition(val.transform.position, 80f, 100, -1f))
				{
					Vector3 val2 = val.transform.position + Vector3.up * 1f;
					if (!Physics.CheckSphere(val2, 0.5f, StartOfRound.Instance.collidersAndRoomMask))
					{
						list.Add(val);
					}
				}
			}
			if (list.Count > 0)
			{
				int index = vecnaCurseRandom.Next(list.Count);
				Vector3 position = list[index].transform.position;
				Vector3 val3 = position;
				NavMeshHit val4 = default(NavMeshHit);
				if (NavMesh.SamplePosition(position, ref val4, 5f, -1))
				{
					val3 = ((NavMeshHit)(ref val4)).position;
				}
				if (((NetworkBehaviour)this).IsServer)
				{
					SpawnClockClientRpc(val3, clocksSpawned);
					if (clocksSpawned == 1)
					{
						SpawnFakeBodyClientRpc(val3);
					}
				}
				stareTimer = 0f;
				unspottedTimer = 0f;
				return true;
			}
			return false;
		}

		public bool IsMusicPlayingNearVictim()
		{
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: 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)
			if ((Object)(object)cursingPlayer == (Object)null || cachedBoomboxes == null)
			{
				return false;
			}
			float num = stats.boomboxRescueRadius * stats.boomboxRescueRadius;
			BoomboxItem[] array = cachedBoomboxes;
			foreach (BoomboxItem val in array)
			{
				if ((Object)(object)val != (Object)null && val.isPlayingMusic)
				{
					Vector3 val2 = ((Component)val).transform.position - ((Component)cursingPlayer).transform.position;
					float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude;
					if (sqrMagnitude <= num)
					{
						return true;
					}
				}
			}
			return false;
		}

		[ClientRpc]
		public void SpawnFakeBodyClientRpc(Vector3 clockPos)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0300: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2191911464u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe(ref clockPos);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2191911464u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			Vector3 val3 = Vector3.forward;
			if ((Object)(object)cursingPlayer != (Object)null)
			{
				val3 = ((Component)cursingPlayer).transform.position - clockPos;
				val3.y = 0f;
				if (val3 != Vector3.zero)
				{
					((Vector3)(ref val3)).Normalize();
				}
			}
			Vector3 val4 = clockPos + val3 * 2.5f;
			RaycastHit val5 = default(RaycastHit);
			if (Physics.Raycast(clockPos + Vector3.up * 0.5f, val3, ref val5, 2.5f, StartOfRound.Instance.collidersAndRoomMask))
			{
				val4 = ((RaycastHit)(ref val5)).point - val3 * 0.5f;
			}
			NavMeshHit val6 = default(NavMeshHit);
			if (NavMesh.SamplePosition(val4, ref val6, 3f, -1))
			{
				val4 = ((NavMeshHit)(ref val6)).position;
			}
			Vector3 val7 = val4 + Vector3.up * 1.5f;
			Quaternion val8 = Quaternion.LookRotation(val3);
			GameObject val9 = cursingPlayer.playersManager.playerRagdolls[0];
			cinematicDirector.activeFakeBody = Object.Instantiate<GameObject>(val9, val7, val8);
			List<PlayerControllerB> list = new List<PlayerControllerB>();
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val10 in allPlayerScripts)
			{
				if ((Object)(object)val10 != (Object)null && val10.isPlayerControlled && !val10.isPlayerDead)
				{
					list.Add(val10);
				}
			}
			PlayerControllerB val11 = cursingPlayer;
			if (list.Count > 0)
			{
				val11 = list[Random.Range(0, list.Count)];
			}
			DeadBodyInfo component = cinematicDirector.activeFakeBody.GetComponent<DeadBodyInfo>();
			if ((Object)(object)component != (Object)null)
			{
				component.playerObjectId = (int)val11.playerClientId;
				component.overrideSpawnPosition = true;
				component.setMaterialToPlayerSuit = true;
				if ((Object)(object)component.grabBodyObject != (Object)null)
				{
					component.grabBodyObject.grabbable = false;
					component.grabBodyObject.grabbableToEnemies = false;
				}
			}
			((MonoBehaviour)this).StartCoroutine(FinalizeFakeBodyRoutine(cinematicDirector.activeFakeBody, val11, val3, cursingLocalPlayer));
		}

		[IteratorStateMachine(typeof(<FinalizeFakeBodyRoutine>d__100))]
		private IEnumerator FinalizeFakeBodyRoutine(GameObject fakeBody, PlayerControllerB victim, Vector3 dirToPlayer, bool isLocalPlayer)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <FinalizeFakeBodyRoutine>d__100(0)
			{
				<>4__this = this,
				fakeBody = fakeBody,
				victim = victim,
				dirToPlayer = dirToPlayer,
				isLocalPlayer = isLocalPlayer
			};
		}

		[ClientRpc]
		public void SpawnClockClientRpc(Vector3 spawnPos, int currentClockCount)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: 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_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: 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_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0422: Unknown result type (might be due to invalid IL or missing references)
			//IL_0429: Expected O, but got Unknown
			//IL_043b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0440: Unknown result type (might be due to invalid IL or missing references)
			//IL_044a: Unknown result type (might be due to invalid IL or missing references)
			//IL_044f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0454: Unknown result type (might be due to invalid IL or missing references)
			//IL_045a: Unknown result type (might be due to invalid IL or missing references)
			//IL_045f: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0503: Unknown result type (might be due to invalid IL or missing references)
			//IL_050d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0512: Unknown result type (might be due to invalid IL or missing references)
			//IL_0517: Unknown result type (might be due to invalid IL or missing references)
			//IL_0520: Unknown result type (might be due to invalid IL or missing references)
			//IL_031e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0323: Unknown result type (might be due to invalid IL or missing references)
			//IL_0328: Unknown result type (might be due to invalid IL or missing references)
			//IL_032d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0333: Unknown result type (might be due to invalid IL or missing references)
			//IL_0338: Unknown result type (might be due to invalid IL or missing references)
			//IL_0354: Unknown result type (might be due to invalid IL or missing references)
			//IL_0359: Unknown result type (might be due to invalid IL or missing references)
			//IL_0364: Unknown result type (might be due to invalid IL or missing references)
			//IL_0366: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1065904563u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe(ref spawnPos);
				BytePacker.WriteValueBitPacked(val2, currentClockCount);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1065904563u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			try
			{
				if ((Object)(object)Plugin.ClockPrefab == (Object)null)
				{
					return;
				}
				currentClock = Object.Instantiate<GameObject>(Plugin.ClockPrefab, spawnPos, Quaternion.identity);
				if ((Object)(object)currentClock == (Object)null)
				{
					return;
				}
				AudioSource[] componentsInChildren = currentClock.GetComponentsInChildren<AudioSource>(true);
				AudioSource[] array = componentsInChildren;
				foreach (AudioSource val3 in array)
				{
					if ((Object)(object)val3 != (Object)null)
					{
						val3.dopplerLevel = 0f;
					}
					if ((Object)(object)SoundManager.Instance != (Object)null && (Object)(object)SoundManager.Instance.diageticMixer != (Object)null)
					{
						val3.outputAudioMixerGroup = SoundManager.Instance.diageticMixer.FindMatchingGroups("Master")[0];
					}
				}
				Vector3 val4 = Vector3.forward;
				Vector3 val5 = Vector3.forward;
				if ((Object)(object)cursingPlayer != (Object)null)
				{
					val5 = ((Component)cursingPlayer).transform.position - spawnPos;
					val5.y = 0f;
					if (val5 != Vector3.zero)
					{
						((Vector3)(ref val5)).Normalize();
					}
					else
					{
						val5 = Vector3.forward;
					}
				}
				if ((Object)(object)cursingPlayer != (Object)null && !cursingPlayer.isInsideFactory)
				{
					val4 = val5;
				}
				else
				{
					float num = -1f;
					int collidersAndRoomMask = StartOfRound.Instance.collidersAndRoomMask;
					int num2 = 8;
					NativeArray<RaycastCommand> val6 = default(NativeArray<RaycastCommand>);
					val6..ctor(num2, (Allocator)3, (NativeArrayOptions)1);
					NativeArray<RaycastHit> val7