Decompiled source of Slender Man The Operator v0.1.42

plugins/SlenderPages.dll

Decompiled 31 minutes ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using Dissonance;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.InputSystem;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 SlenderCompany
{
	public sealed class ProxyVoice : MonoBehaviour
	{
		private DissonanceComms comms;

		private bool oldMute;

		private static ProxyVoice active;

		internal static void PreserveMute(DissonanceComms __instance, ref bool __0)
		{
			if ((Object)(object)active != (Object)null && (Object)(object)active.comms == (Object)(object)__instance)
			{
				active.oldMute = __0;
				__0 = true;
			}
		}

		public void StartSession()
		{
			comms = StartOfRound.Instance.voiceChatModule;
			if (!((Object)(object)comms == (Object)null))
			{
				oldMute = comms.IsMuted;
				comms.IsMuted = true;
				active = this;
			}
		}

		private void OnDisable()
		{
			if (!((Object)(object)comms == (Object)null))
			{
				if ((Object)(object)active == (Object)(object)this)
				{
					active = null;
				}
				comms.IsMuted = oldMute;
				comms = null;
			}
		}
	}
	[DefaultExecutionOrder(500)]
	public sealed class ProxyReaction : MonoBehaviour
	{
		private sealed class Arm
		{
			internal Transform upper;

			internal Transform fore;

			internal Transform hand;

			private Quaternion a;

			private Quaternion b;

			private Quaternion c;

			private Transform index;

			private Transform little;

			private readonly List<Transform> digits = new List<Transform>();

			private readonly List<Quaternion> open = new List<Quaternion>();

			private readonly List<Quaternion> saved = new List<Quaternion>();

			internal void BindFingers(SkinnedMeshRenderer mesh)
			{
				//IL_00db: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
				//IL_0104: Unknown result type (might be due to invalid IL or missing references)
				//IL_0108: Unknown result type (might be due to invalid IL or missing references)
				Transform[] bones = mesh.bones;
				Matrix4x4[] bindposes = mesh.sharedMesh.bindposes;
				for (int i = 0; i < bones.Length; i++)
				{
					Transform val = bones[i];
					if (!((Object)(object)val == (Object)null) && val.IsChildOf(hand) && ((Object)val).name.StartsWith("finger", StringComparison.OrdinalIgnoreCase))
					{
						if ((Object)(object)val.parent == (Object)(object)hand && ((Object)val).name.StartsWith("finger2."))
						{
							index = val;
						}
						if ((Object)(object)val.parent == (Object)(object)hand && ((Object)val).name.StartsWith("finger5."))
						{
							little = val;
						}
						int num = Array.IndexOf(bones, val.parent);
						if (num >= 0 && num < bindposes.Length && i < bindposes.Length)
						{
							digits.Add(val);
							saved.Add(Quaternion.identity);
							List<Quaternion> list = open;
							Matrix4x4 val2 = bindposes[num] * ((Matrix4x4)(ref bindposes[i])).inverse;
							list.Add(((Matrix4x4)(ref val2)).rotation);
						}
					}
				}
			}

			internal void ShapeHand(Transform body, Vector3 fingers, Vector3 thumb, float openness, float weight, bool openPalm = false)
			{
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_0034: Unknown result type (might be due to invalid IL or missing references)
				//IL_0040: Unknown result type (might be due to invalid IL or missing references)
				//IL_004a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0092: 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_00a2: 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_00b7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c7: 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_00d7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
				//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00de: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e3: 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_00e6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f7: 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_0102: Unknown result type (might be due to invalid IL or missing references)
				//IL_011f: Unknown result type (might be due to invalid IL or missing references)
				//IL_010d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0112: Unknown result type (might be due to invalid IL or missing references)
				//IL_0118: Unknown result type (might be due to invalid IL or missing references)
				//IL_0126: 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_013c: 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_014e: Unknown result type (might be due to invalid IL or missing references)
				for (int i = 0; i < digits.Count; i++)
				{
					saved[i] = digits[i].localRotation;
					digits[i].localRotation = Quaternion.Slerp(saved[i], open[i], openness * weight);
				}
				if (!((Object)(object)index == (Object)null) && !((Object)(object)little == (Object)null) && !(weight <= 0f))
				{
					Vector3 val = (index.position + little.position) * 0.5f - hand.position;
					Vector3 val2 = index.position - little.position;
					Quaternion val3 = Quaternion.LookRotation(val, val2);
					Quaternion val4 = Quaternion.LookRotation(body.TransformDirection(fingers), body.TransformDirection(thumb)) * Quaternion.Inverse(val3);
					hand.rotation = (openPalm ? val4 : Quaternion.RotateTowards(Quaternion.identity, val4, 95f)) * hand.rotation;
					hand.localRotation = Quaternion.Slerp(c, hand.localRotation, weight);
				}
			}

			internal Arm(Transform wrist)
			{
				hand = wrist;
				fore = wrist.parent;
				upper = fore.parent;
			}

			internal void Restore()
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				//IL_004a: Unknown result type (might be due to invalid IL or missing references)
				upper.localRotation = a;
				fore.localRotation = b;
				hand.localRotation = c;
				for (int i = 0; i < digits.Count; i++)
				{
					digits[i].localRotation = saved[i];
				}
			}

			internal void Pose(Transform body, Vector3 offset, Vector3 elbow, bool palm, float weight, bool sweep = false)
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				//IL_002e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0039: Unknown result type (might be due to invalid IL or missing references)
				//IL_003e: Unknown result type (might be due to invalid IL or missing references)
				//IL_003f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0046: Unknown result type (might be due to invalid IL or missing references)
				//IL_0057: Unknown result type (might be due to invalid IL or missing references)
				//IL_0062: Unknown result type (might be due to invalid IL or missing references)
				//IL_011f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0124: Unknown result type (might be due to invalid IL or missing references)
				//IL_0129: Unknown result type (might be due to invalid IL or missing references)
				//IL_016c: Unknown result type (might be due to invalid IL or missing references)
				//IL_016d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0172: 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_0178: 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_0183: Unknown result type (might be due to invalid IL or missing references)
				//IL_0184: Unknown result type (might be due to invalid IL or missing references)
				//IL_0187: Unknown result type (might be due to invalid IL or missing references)
				//IL_018c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0191: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b7: 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_01bb: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
				//IL_01de: 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_01f1: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
				//IL_020c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0217: Unknown result type (might be due to invalid IL or missing references)
				//IL_021c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0221: Unknown result type (might be due to invalid IL or missing references)
				//IL_0229: Unknown result type (might be due to invalid IL or missing references)
				//IL_022e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0233: Unknown result type (might be due to invalid IL or missing references)
				//IL_023e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0243: Unknown result type (might be due to invalid IL or missing references)
				//IL_0091: Unknown result type (might be due to invalid IL or missing references)
				//IL_0096: Unknown result type (might be due to invalid IL or missing references)
				//IL_0097: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
				//IL_0291: 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_029e: Unknown result type (might be due to invalid IL or missing references)
				//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
				//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
				//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
				//IL_02b9: 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_02c2: Unknown result type (might be due to invalid IL or missing references)
				//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
				//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
				//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
				//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
				//IL_02f2: 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_0257: 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_00d6: 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_00dd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
				//IL_0100: Unknown result type (might be due to invalid IL or missing references)
				//IL_0106: Unknown result type (might be due to invalid IL or missing references)
				//IL_010b: Unknown result type (might be due to invalid IL or missing references)
				//IL_010e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0113: Unknown result type (might be due to invalid IL or missing references)
				//IL_026c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0271: Unknown result type (might be due to invalid IL or missing references)
				//IL_027c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0281: Unknown result type (might be due to invalid IL or missing references)
				a = upper.localRotation;
				b = fore.localRotation;
				c = hand.localRotation;
				Vector3 position = upper.position;
				float num = Vector3.Distance(position, fore.position);
				float num2 = Vector3.Distance(fore.position, hand.position);
				if (!(num < 0.0001f) && !(num2 < 0.0001f))
				{
					if (sweep)
					{
						float num3 = num + num2;
						Vector3 val = body.InverseTransformDirection(hand.position - position) / num3;
						Vector3 val2 = default(Vector3);
						((Vector3)(ref val2))..ctor((elbow.x < 0f) ? (-0.55f) : 0.55f, 0.02f, 0.95f);
						offset = Vector3.Lerp(Vector3.Lerp(val, val2, weight), Vector3.Lerp(val2, offset, weight), weight);
						elbow = Vector3.Lerp(body.InverseTransformDirection(fore.position - position) / num, elbow, weight);
						weight = 1f;
					}
					Vector3 val3 = body.TransformDirection(((Vector3)(ref offset)).normalized);
					float num4 = Mathf.Clamp(((Vector3)(ref offset)).magnitude * (num + num2), Mathf.Abs(num - num2) + 0.0001f, num + num2 - 0.0001f);
					float num5 = (num * num - num2 * num2 + num4 * num4) / (2f * num4);
					Vector3 val4 = Vector3.ProjectOnPlane(body.TransformDirection(elbow), val3);
					Vector3 normalized = ((Vector3)(ref val4)).normalized;
					Vector3 val5 = position + val3 * num5 + normalized * Mathf.Sqrt(Mathf.Max(0f, num * num - num5 * num5));
					Vector3 val6 = position + val3 * num4;
					upper.rotation = Quaternion.FromToRotation(fore.position - position, val5 - position) * upper.rotation;
					fore.rotation = Quaternion.FromToRotation(hand.position - fore.position, val6 - fore.position) * fore.rotation;
					if (palm)
					{
						hand.rotation = Quaternion.AngleAxis((float)((elbow.x < 0f) ? (-50) : 50), body.forward) * hand.rotation;
					}
					Quaternion localRotation = upper.localRotation;
					Quaternion localRotation2 = fore.localRotation;
					Quaternion localRotation3 = hand.localRotation;
					upper.localRotation = Quaternion.Slerp(a, localRotation, weight);
					fore.localRotation = Quaternion.Slerp(b, localRotation2, weight);
					hand.localRotation = Quaternion.Slerp(c, localRotation3, weight);
				}
			}
		}

		private Arm left;

		private Arm right;

		private int style;

		private bool applied;

		private bool playing;

		private float start;

		private Transform spine;

		private Transform neck;

		private Quaternion savedSpine;

		private Quaternion savedNeck;

		private static readonly Dictionary<string, AudioClip> clips = new Dictionary<string, AudioClip>();

		private static readonly string[] folders = new string[3] { "Porcelain", "Grimace", "Fracture" };

		private static readonly int[] voiceCounts = new int[3] { 10, 10, 10 };

		private static readonly int[] blindCounts = new int[3] { 3, 3, 3 };

		private AudioSource speech;

		private AudioSource effects;

		private Action<int> announce;

		private int mask;

		private int lastLine = -1;

		private double nextLine;

		internal static ProxyReaction For(PlayerControllerB player)
		{
			return ((Component)player).GetComponent<ProxyReaction>() ?? ((Component)player).gameObject.AddComponent<ProxyReaction>();
		}

		private static AudioClip Clip(string name)
		{
			if (!clips.TryGetValue(name, out var value))
			{
				value = CameraStatic.LoadPcm(name);
				clips.Add(name, value);
			}
			return value;
		}

		private AudioSource Speaker(ref AudioSource source)
		{
			if ((Object)(object)source == (Object)null)
			{
				source = ((Component)this).gameObject.AddComponent<AudioSource>();
				source.playOnAwake = false;
				source.spatialBlend = 1f;
				source.maxDistance = 22f;
			}
			return source;
		}

		public void StartAudio(int skin, Action<int> send)
		{
			EndAudio();
			mask = skin;
			announce = send;
			lastLine = -1;
			nextLine = AudioSettings.dspTime;
		}

		internal static int NextIndex(int count, int last)
		{
			if (count <= 1)
			{
				return 0;
			}
			if (last < 0)
			{
				return Random.Range(0, count);
			}
			int num = Random.Range(0, count - 1);
			if (num < last)
			{
				return num;
			}
			return num + 1;
		}

		private void UpdateLines()
		{
			if (announce != null && voiceCounts[mask] != 0 && !(AudioSettings.dspTime < nextLine))
			{
				int num = NextIndex(voiceCounts[mask], lastLine);
				PlayLine(num);
				announce(10 + num);
			}
		}

		public void PlayLine(int index)
		{
			if (index >= 0 && index < voiceCounts[mask])
			{
				lastLine = index;
				PlayVocal(Clip(folders[mask] + "Voice" + (index + 1)), 0.0);
			}
		}

		private void PlayVocal(AudioClip clip, double minimum)
		{
			AudioSource obj = Speaker(ref speech);
			obj.Stop();
			obj.clip = clip;
			double num = AudioSettings.dspTime + 0.025;
			obj.PlayScheduled(num);
			nextLine = Math.Max(num + (double)clip.samples / (double)clip.frequency + 2.0, AudioSettings.dspTime + minimum);
		}

		public int BlindChoice(int skin)
		{
			return Random.Range(0, Mathf.Max(1, blindCounts[skin]));
		}

		public void Blind(int skin, int index)
		{
			if ((Object)(object)speech != (Object)null)
			{
				speech.Stop();
			}
			nextLine = AudioSettings.dspTime + 4.6;
			if (index >= 0 && index < blindCounts[skin])
			{
				PlayVocal(Clip(folders[skin] + "Blind" + (index + 1)), 4.6);
			}
			Stun(skin);
		}

		public void EndAudio()
		{
			announce = null;
			if ((Object)(object)speech != (Object)null)
			{
				speech.Stop();
				speech.clip = null;
			}
		}

		public void Hit(int index)
		{
			if (index >= 0 && index < 3)
			{
				Speaker(ref effects).PlayOneShot(Clip("ProxyPunchSound" + (index + 1)));
			}
		}

		public void Cough()
		{
			Speaker(ref effects).PlayOneShot(Clip("ProxyRecovery"));
		}

		private void OnDestroy()
		{
			if ((Object)(object)speech != (Object)null)
			{
				Object.Destroy((Object)(object)speech);
			}
			if ((Object)(object)effects != (Object)null)
			{
				Object.Destroy((Object)(object)effects);
			}
		}

		public void Stun(int skin)
		{
			Restore();
			PlayerControllerB component = ((Component)this).GetComponent<PlayerControllerB>();
			bool flag = (Object)(object)component == (Object)(object)GameNetworkManager.Instance.localPlayerController;
			SkinnedMeshRenderer val = (flag ? component.thisPlayerModelArms : component.thisPlayerModel);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			ProxyPunch component2 = ((Component)this).GetComponent<ProxyPunch>();
			if ((Object)(object)component2 != (Object)null)
			{
				component2.Cancel();
			}
			spine = (flag ? null : component.upperSpine);
			neck = null;
			left = null;
			right = null;
			Transform[] bones = val.bones;
			foreach (Transform val2 in bones)
			{
				if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val2.parent == (Object)null) && !((Object)(object)val2.parent.parent == (Object)null))
				{
					string text = ((Object)val2).name.ToLowerInvariant().Replace('_', '.').Replace(" ", "");
					if (!flag && text == "spine.004")
					{
						neck = val2;
					}
					if (text == "hand.r" || text == "hand.r1" || text.EndsWith("righthand"))
					{
						right = new Arm(val2);
					}
					if (text == "hand.l" || text == "hand.l1" || text.EndsWith("lefthand"))
					{
						left = new Arm(val2);
					}
				}
			}
			if (left != null)
			{
				left.BindFingers(val);
			}
			if (right != null)
			{
				right.BindFingers(val);
			}
			style = skin;
			start = Time.time;
			playing = true;
		}

		private void Restore()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			if (applied)
			{
				if ((Object)(object)spine != (Object)null)
				{
					spine.localRotation = savedSpine;
				}
				if ((Object)(object)neck != (Object)null)
				{
					neck.localRotation = savedNeck;
				}
				if (left != null)
				{
					left.Restore();
				}
				if (right != null)
				{
					right.Restore();
				}
				applied = false;
			}
		}

		private void Update()
		{
			Restore();
			UpdateLines();
		}

		private void OnDisable()
		{
			Restore();
			playing = false;
		}

		internal void StopPose()
		{
			Restore();
			playing = false;
		}

		private void LateUpdate()
		{
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: 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_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_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_034e: 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_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_0379: Unknown result type (might be due to invalid IL or missing references)
			//IL_0363: Unknown result type (might be due to invalid IL or missing references)
			//IL_030b: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_031b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0314: Unknown result type (might be due to invalid IL or missing references)
			//IL_0400: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
			if (!playing)
			{
				return;
			}
			float num = Time.time - start;
			if (num >= 1.85f)
			{
				playing = false;
				return;
			}
			float num2 = ((num < 0.6f) ? Mathf.SmoothStep(0f, 1f, num / 0.6f) : (1f - Mathf.SmoothStep(0f, 1f, (num - 1.6f) / 0.25f)));
			float num3 = ((num < 0.6f) ? Mathf.SmoothStep(0f, 1f, num / 0.32f) : num2);
			float weight = ((num < 0.6f) ? Mathf.SmoothStep(0f, 1f, (num - 0.065f) / 0.535f) : num2);
			bool flag = style == 1;
			bool flag2 = style == 2;
			if ((Object)(object)spine != (Object)null)
			{
				savedSpine = spine.localRotation;
				spine.rotation = Quaternion.AngleAxis((float)(flag ? 17 : (flag2 ? 5 : (-8))) * num3, ((Component)this).transform.right) * Quaternion.AngleAxis((float)(flag ? 11 : (flag2 ? (-13) : 6)) * num3, ((Component)this).transform.up) * spine.rotation;
			}
			if ((Object)(object)neck != (Object)null)
			{
				savedNeck = neck.localRotation;
				neck.rotation = Quaternion.AngleAxis((float)(flag ? 13 : (flag2 ? 9 : 4)) * num3, ((Component)this).transform.right) * Quaternion.AngleAxis((float)(flag ? (-9) : (flag2 ? 40 : (-12))) * num3, ((Component)this).transform.up) * neck.rotation;
			}
			Vector3 offset = (flag ? new Vector3(0.37f, 0.55f, 0.58f) : (flag2 ? new Vector3(0.35f, 0.39f, 0.78f) : new Vector3(0.3f, 0.25f, 0.44f)));
			Vector3 offset2 = (flag ? new Vector3(-0.29f, -0.06f, 0.84f) : (flag2 ? new Vector3(0.27f, -0.66f, 0.09f) : new Vector3(-0.31f, 0.34f, 0.53f)));
			if (left != null)
			{
				left.Pose(((Component)this).transform, offset, flag ? new Vector3(-1f, -0.5f, 0f) : new Vector3(-1f, -0.06f, 0.1f), palm: false, num2, flag);
				left.ShapeHand(((Component)this).transform, flag ? new Vector3(0.84f, -0.12f, 0.18f) : (flag2 ? new Vector3(0.92f, 0.2f, 0.15f) : new Vector3(0.85f, 0.46f, 0f)), flag ? Vector3.forward : Vector3.down, flag ? 0.85f : 1f, num2);
			}
			if (right != null)
			{
				right.Pose(((Component)this).transform, offset2, flag ? new Vector3(0.55f, -1f, 0f) : new Vector3(1f, -0.45f, 0.12f), palm: false, weight, flag);
				right.ShapeHand(((Component)this).transform, flag ? new Vector3(-0.2f, 0.98f, 0f) : (flag2 ? new Vector3(0.17f, -1f, 0.12f) : new Vector3(-0.62f, 0.74f, 0f)), (Vector3)(flag ? Vector3.left : (flag2 ? Vector3.forward : new Vector3(-0.8f, -0.5f, 0f))), flag2 ? 0.35f : 1f, weight, flag);
			}
			applied = true;
		}
	}
	public struct MaskWearClock
	{
		private float elapsed;

		public bool Step(bool held, float dt)
		{
			elapsed = (held ? (elapsed + dt) : 0f);
			return elapsed >= 3f;
		}

		public void Reset()
		{
			elapsed = 0f;
		}
	}
	public sealed class WearableMask : PhysicsProp
	{
		[SerializeField]
		internal int SkinIndex = -1;

		internal static HauntedMaskItem Template;

		private Vector3 homeScale;

		private Vector3 gripPosition;

		private Vector3 gripScale;

		private Quaternion gripRotation;

		private bool heldDown;

		private bool fitted;

		private Transform handGrip;

		private PlayerControllerB gripOwner;

		private MaskWearClock wearing;

		internal InputAction useAction;

		internal bool Wearing => heldDown;

		private void AlignIdleGrip(Transform model, bool local)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: 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_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: 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_0178: 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_0189: 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_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_01d6: 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_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			if (!local)
			{
				model.position += ((Component)((GrabbableObject)this).playerHeldBy).transform.right * 0.085f;
				return;
			}
			Camera gameplayCamera = ((GrabbableObject)this).playerHeldBy.gameplayCamera;
			if ((Object)(object)gripOwner != (Object)(object)((GrabbableObject)this).playerHeldBy)
			{
				gripOwner = ((GrabbableObject)this).playerHeldBy;
				handGrip = null;
				SkinnedMeshRenderer thisPlayerModelArms = ((GrabbableObject)this).playerHeldBy.thisPlayerModelArms;
				if ((Object)(object)thisPlayerModelArms != (Object)null)
				{
					Transform[] bones = thisPlayerModelArms.bones;
					foreach (Transform val in bones)
					{
						if (!((Object)(object)val == (Object)null))
						{
							string text = ((Object)val).name.ToLowerInvariant().Replace('_', '.');
							if (text == "hand.r" || text == "righthand")
							{
								handGrip = val;
							}
							if (text.Contains("index") && text.Contains(".r") && (text.Contains(".01") || text.Contains(".1.")))
							{
								handGrip = val;
								break;
							}
						}
					}
				}
			}
			model.position += ((Component)gameplayCamera).transform.right * 0.085f;
			if (!((Object)(object)handGrip == (Object)null))
			{
				Bounds localBounds = ((Renderer)((GrabbableObject)this).mainObjectRenderer).localBounds;
				Vector3 val2 = gameplayCamera.WorldToViewportPoint(model.TransformPoint(((Bounds)(ref localBounds)).center + Vector3.right * (float)((Vector3.Dot(model.right, ((Component)gameplayCamera).transform.right) >= 0f) ? 1 : (-1)) * ((Bounds)(ref localBounds)).extents.x * 0.88f));
				Vector3 val3 = gameplayCamera.WorldToViewportPoint(handGrip.position);
				if (!(val2.z <= 0f) && !(val3.z <= 0f))
				{
					Vector3 val4 = gameplayCamera.ViewportToWorldPoint(new Vector3(val3.x, val2.y, val2.z));
					model.position += ((Component)gameplayCamera).transform.right * Mathf.Clamp(Vector3.Dot(val4 - gameplayCamera.ViewportToWorldPoint(val2), ((Component)gameplayCamera).transform.right), -0.045f, 0.09f);
				}
			}
		}

		internal void CancelWear()
		{
			Lower();
		}

		internal static void CapturePress(PlayerControllerB __instance, CallbackContext __0)
		{
			WearableMask wearableMask = __instance.currentlyHeldObjectServer as WearableMask;
			if (!((Object)(object)wearableMask == (Object)null) && ((CallbackContext)(ref __0)).performed && !BlocksUse(__instance))
			{
				wearableMask.useAction = ((CallbackContext)(ref __0)).action;
				wearableMask.SetWear(down: true);
			}
		}

		private static bool BlocksUse(PlayerControllerB p)
		{
			if (!ProxySession.Transforming && p.isPlayerControlled && !p.isPlayerDead && !p.isTypingChat && !p.inTerminalMenu && !p.inSpecialMenu && !p.inSpecialInteractAnimation && (!((Object)(object)p.quickMenuManager != (Object)null) || !p.quickMenuManager.isMenuOpen))
			{
				return (Object)(object)p != (Object)(object)GameNetworkManager.Instance.localPlayerController;
			}
			return true;
		}

		internal static void CaptureRelease(PlayerControllerB __instance, CallbackContext __0)
		{
			WearableMask wearableMask = __instance.currentlyHeldObjectServer as WearableMask;
			if ((Object)(object)wearableMask != (Object)null && ((CallbackContext)(ref __0)).canceled)
			{
				wearableMask.CancelWear();
			}
		}

		private static Vector3 Axis(int i)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return (Vector3)(i switch
			{
				1 => Vector3.up, 
				0 => Vector3.right, 
				_ => Vector3.forward, 
			});
		}

		public override void Start()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).Start();
			homeScale = ((Component)((GrabbableObject)this).mainObjectRenderer).transform.localScale;
			Fit();
		}

		private void Fit()
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: 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_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0272: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_0287: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c4: 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)
			if ((Object)(object)Template == (Object)null)
			{
				Template = ((IEnumerable<HauntedMaskItem>)Resources.FindObjectsOfTypeAll<HauntedMaskItem>()).FirstOrDefault((Func<HauntedMaskItem, bool>)((HauntedMaskItem x) => (Object)(object)((GrabbableObject)x).itemProperties != (Object)null && ((GrabbableObject)x).itemProperties.itemName.IndexOf("comedy", StringComparison.OrdinalIgnoreCase) >= 0));
				if ((Object)(object)Template == (Object)null)
				{
					return;
				}
			}
			Item itemProperties = ((GrabbableObject)Template).itemProperties;
			((GrabbableObject)this).itemProperties.rotationOffset = itemProperties.rotationOffset;
			((GrabbableObject)this).itemProperties.positionOffset = itemProperties.positionOffset;
			((GrabbableObject)this).itemProperties.grabAnim = itemProperties.grabAnim;
			((GrabbableObject)this).itemProperties.twoHandedAnimation = itemProperties.twoHandedAnimation;
			((GrabbableObject)this).itemProperties.disableHandsOnWall = itemProperties.disableHandsOnWall;
			MeshRenderer val = ((GrabbableObject)Template).mainObjectRenderer;
			if ((Object)(object)val == (Object)null)
			{
				val = (from x in ((Component)Template).GetComponentsInChildren<MeshRenderer>(true)
					where (Object)(object)x != (Object)(object)Template.maskEyesFilled
					select x).OrderByDescending(delegate(MeshRenderer x)
				{
					//IL_0001: Unknown result type (might be due to invalid IL or missing references)
					//IL_0006: Unknown result type (might be due to invalid IL or missing references)
					//IL_0009: Unknown result type (might be due to invalid IL or missing references)
					//IL_000e: Unknown result type (might be due to invalid IL or missing references)
					Bounds bounds = ((Renderer)x).bounds;
					Vector3 size = ((Bounds)(ref bounds)).size;
					return ((Vector3)(ref size)).sqrMagnitude;
				}).FirstOrDefault();
			}
			if (!((Object)(object)val == (Object)null))
			{
				Transform tr = ((Component)val).transform;
				Transform transform = ((Component)Template).transform;
				Bounds localBounds = ((Renderer)val).localBounds;
				Vector3 sz = ((Bounds)(ref localBounds)).size;
				int[] array = new int[3] { 0, 1, 2 }.OrderBy(delegate(int i)
				{
					//IL_0013: Unknown result type (might be due to invalid IL or missing references)
					//IL_0018: Unknown result type (might be due to invalid IL or missing references)
					//IL_001d: Unknown result type (might be due to invalid IL or missing references)
					float num = ((Vector3)(ref sz))[i];
					Vector3 val7 = tr.TransformVector(Axis(i));
					return num * ((Vector3)(ref val7)).magnitude;
				}).ToArray();
				Vector3 val2;
				if (!((Object)(object)Template.maskEyesFilled != (Object)null))
				{
					val2 = Vector3.up;
				}
				else
				{
					Transform obj = tr;
					Transform transform2 = ((Component)Template.maskEyesFilled).transform;
					Bounds localBounds2 = ((Renderer)Template.maskEyesFilled).localBounds;
					val2 = obj.InverseTransformPoint(transform2.TransformPoint(((Bounds)(ref localBounds2)).center)) - ((Bounds)(ref localBounds)).center;
				}
				Vector3 val3 = val2;
				Vector3 val4 = tr.TransformDirection(Axis(array[2]) * (float)((!(((Vector3)(ref val3))[array[2]] < 0f)) ? 1 : (-1)));
				Vector3 val5 = tr.TransformDirection(Axis(array[0]) * (float)((!(((Vector3)(ref val3))[array[0]] < 0f)) ? 1 : (-1)));
				gripRotation = Quaternion.Inverse(transform.rotation) * Quaternion.LookRotation(-val5, val4);
				gripPosition = transform.InverseTransformPoint(tr.TransformPoint(((Bounds)(ref localBounds)).center));
				Vector3 val6 = transform.InverseTransformVector(tr.TransformVector(Axis(array[2]) * ((Vector3)(ref sz))[array[2]]));
				float magnitude = ((Vector3)(ref val6)).magnitude;
				gripScale = homeScale * (magnitude / 0.42f);
				fitted = true;
			}
		}

		public override void EquipItem()
		{
			Lower();
			useAction = null;
			if ((Object)(object)((GrabbableObject)this).mainObjectRenderer != (Object)null)
			{
				((Renderer)((GrabbableObject)this).mainObjectRenderer).forceRenderingOff = false;
			}
			if (!fitted && ((Vector3)(ref homeScale)).sqrMagnitude > 0f)
			{
				Fit();
			}
			((PhysicsProp)this).EquipItem();
		}

		public override void ItemActivate(bool used, bool down = true)
		{
			((GrabbableObject)this).ItemActivate(used, down);
			if (!((Object)(object)((GrabbableObject)this).playerHeldBy == (Object)null) && !((NetworkBehaviour)this).IsOwner)
			{
				SetWear(down);
			}
		}

		private void SetWear(bool down)
		{
			if (heldDown != down)
			{
				heldDown = down;
				wearing.Reset();
				if ((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null && (Object)(object)((GrabbableObject)this).playerHeldBy.playerBodyAnimator != (Object)null)
				{
					((GrabbableObject)this).playerHeldBy.playerBodyAnimator.SetBool("HoldMask", down);
				}
			}
		}

		private void Lower()
		{
			SetWear(down: false);
			wearing.Reset();
			((GrabbableObject)this).isBeingUsed = false;
		}

		public override void DiscardItem()
		{
			Lower();
			((GrabbableObject)this).DiscardItem();
			if ((Object)(object)((GrabbableObject)this).mainObjectRenderer != (Object)null)
			{
				((Renderer)((GrabbableObject)this).mainObjectRenderer).forceRenderingOff = false;
				((GrabbableObject)this).EnableItemMeshes(true);
			}
		}

		public override void PocketItem()
		{
			Lower();
			((GrabbableObject)this).PocketItem();
		}

		public override void LateUpdate()
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: 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)
			((GrabbableObject)this).LateUpdate();
			Transform transform = ((Component)((GrabbableObject)this).mainObjectRenderer).transform;
			bool flag = ((GrabbableObject)this).isHeld && !((GrabbableObject)this).isPocketed && (Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null;
			if (flag && !fitted)
			{
				Fit();
			}
			transform.localPosition = ((flag && fitted) ? gripPosition : Vector3.zero);
			transform.localRotation = ((flag && fitted) ? gripRotation : Quaternion.identity);
			transform.localScale = ((flag && fitted) ? gripScale : homeScale);
			bool flag2 = flag && ((NetworkBehaviour)this).IsOwner && (Object)(object)((GrabbableObject)this).playerHeldBy == (Object)(object)GameNetworkManager.Instance.localPlayerController;
			if (flag2 && heldDown && (useAction == null || !useAction.IsPressed() || !Application.isFocused || ((GrabbableObject)this).playerHeldBy.inSpecialMenu))
			{
				Lower();
			}
			if (flag && !heldDown)
			{
				Vector3 up = Vector3.up;
				Bounds localBounds = ((Renderer)((GrabbableObject)this).mainObjectRenderer).localBounds;
				Vector3 val = transform.TransformVector(up * ((Bounds)(ref localBounds)).size.y);
				float magnitude = ((Vector3)(ref val)).magnitude;
				float num = Mathf.Min(0.75f, 0.42f / Mathf.Max(0.001f, magnitude));
				transform.localScale *= num;
				transform.localPosition *= num;
				AlignIdleGrip(transform, flag2);
			}
			if (!flag2 || !heldDown || ((GrabbableObject)this).playerHeldBy.isPlayerDead || StartOfRound.Instance.inShipPhase)
			{
				wearing.Reset();
			}
			else
			{
				AdvanceWear(Time.deltaTime);
			}
		}

		internal void AdvanceWear(float dt)
		{
			if (!heldDown || !wearing.Step(held: true, dt))
			{
				return;
			}
			if (ProxySession.Begin(((GrabbableObject)this).playerHeldBy, SkinIndex))
			{
				Lower();
				return;
			}
			Lower();
			Debug.LogWarning((object)("[SlenderPages] Could not begin possession: skin=" + SkinIndex + ", wearer=" + ((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null) + ", active=" + ProxySession.Transforming));
			if ((Object)(object)HUDManager.Instance != (Object)null)
			{
				HUDManager.Instance.DisplayTip("Proxy mask", "Possession could not start. See the SlenderPages log.", false, false, "LC_Tip1");
			}
		}
	}
	public sealed class ProxyTintDeadline : MonoBehaviour
	{
		internal float Deadline;

		private void Update()
		{
			if (Time.realtimeSinceStartup >= Deadline)
			{
				((Component)this).gameObject.SetActive(false);
			}
		}
	}
	public sealed class ProxySession : MonoBehaviour
	{
		private struct MoveScope
		{
			internal bool applied;

			internal bool previous;
		}

		private sealed class Face
		{
			public GameObject model;

			public float until;

			public PlayerControllerB player;

			public Renderer hidden;

			public int skin;
		}

		private struct Crossing
		{
			internal Vector3 entry;

			internal Vector3 landing;

			internal bool climb;

			internal Transform rail;

			internal Crossing(Vector3 a, Vector3 b, bool ladder)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_0009: Unknown result type (might be due to invalid IL or missing references)
				entry = a;
				landing = b;
				climb = ladder;
				rail = null;
			}
		}

		internal sealed class ProgressWatch
		{
			private Vector3 last;

			private Vector3 origin;

			private float movedAt;

			private float leftAreaAt;

			internal void Reset(Vector3 feet, float now)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				//IL_0004: Unknown result type (might be due to invalid IL or missing references)
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				last = (origin = feet);
				movedAt = (leftAreaAt = now);
			}

			internal int Check(Vector3 feet, float now)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				//IL_002b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				//IL_0035: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0045: Unknown result type (might be due to invalid IL or missing references)
				//IL_0046: Unknown result type (might be due to invalid IL or missing references)
				Vector3 val = feet - last;
				if (((Vector3)(ref val)).sqrMagnitude > 0.0324f)
				{
					last = feet;
					movedAt = now;
				}
				val = feet - origin;
				if (((Vector3)(ref val)).sqrMagnitude > 126.5625f)
				{
					origin = feet;
					leftAreaAt = now;
				}
				if (!(now - leftAreaAt >= 10f))
				{
					return (now - movedAt >= 2f) ? 1 : 0;
				}
				return 2;
			}

			internal void AfterShort(Vector3 feet, float now)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				last = feet;
				movedAt = now;
			}
		}

		private const string Channel = "SlenderCompany.Proxy.22";

		private static ProxySession self;

		private static PlayerControllerB owner;

		private static float activeUntil;

		private static float warningUntil;

		private int gazeSkin;

		private WearableMask wornItem;

		private GameObject grading;

		private VolumeProfile profile;

		private float nextHit;

		private float nextPath;

		private float fleeUntil;

		private float nextHeal;

		private float emptyUntil;

		private int healthBefore;

		private int healGoal;

		private Vector3 waypoint;

		private PlayerControllerB target;

		private NavMeshPath route;

		private EntranceTeleport[] exits;

		private bool hitAnyone;

		private Vector3 lightPosition;

		private float stunnedUntil;

		private PlayerControllerB recoveryPlayer;

		private CustomMessagingManager bus;

		private readonly Dictionary<ulong, Face> faces = new Dictionary<ulong, Face>();

		private static bool controlsPatched;

		private PlayerControllerB punchTarget;

		private float impactAt;

		private float nextLightCheck;

		private float flinchUntil;

		internal const float PossessionSeconds = 25f;

		private ProxyVoice voice;

		private bool flashLatched;

		private NavMeshQueryFilter travelFilter;

		private NavMeshAgent guide;

		private Vector3 lastDestination;

		private bool destinationSet;

		private float nextRotation;

		private static readonly Action<PlayerControllerB, short, short> SendLook = (Action<PlayerControllerB, short, short>)Delegate.CreateDelegate(typeof(Action<PlayerControllerB, short, short>), AccessTools.Method(typeof(PlayerControllerB), "UpdatePlayerRotationServerRpc", (Type[])null, (Type[])null));

		private Vector3 sampleProgress;

		private float sampleAt;

		private float stuckUntil;

		private readonly List<Crossing> fixedCrossings = new List<Crossing>();

		private Crossing selected;

		private bool hasCrossing;

		private bool traversing;

		private float started;

		private float nextSearch;

		private float avoidUntil;

		private Vector3 depart;

		private Vector3 lastGoal;

		private Vector3 avoidEntry;

		private int crossingPhase;

		private Vector3 dismount;

		private Vector3 lastMotion;

		private float lastMotionAt;

		private readonly ProgressWatch progressWatch = new ProgressWatch();

		private Vector3? recoveryGoal;

		private float nextRecovery;

		private NavMeshPath recoveryPath;

		private static readonly float[] retreatAngles = new float[7] { 0f, 35f, -35f, 65f, -65f, 90f, -90f };

		internal static bool Transforming
		{
			get
			{
				if (!(activeUntil > 0f))
				{
					return warningUntil > 0f;
				}
				return true;
			}
		}

		internal static bool Blocks(PlayerControllerB p)
		{
			if ((Object)(object)owner == (Object)(object)p && (Object)(object)p != (Object)null)
			{
				return Time.realtimeSinceStartup < activeUntil;
			}
			return false;
		}

		private static void BlockMovement(PlayerControllerB __instance, out MoveScope __state)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			__state = default(MoveScope);
			if (Blocks(__instance) || Stunned(__instance))
			{
				__state.applied = true;
				__state.previous = __instance.disableMoveInput;
				__instance.disableMoveInput = true;
				__instance.moveInputVector = Vector2.zero;
			}
		}

		private static void RestoreMovement(PlayerControllerB __instance, MoveScope __state)
		{
			if (__state.applied)
			{
				__instance.disableMoveInput = __state.previous;
			}
		}

		private static bool Stunned(PlayerControllerB p)
		{
			if ((Object)(object)self != (Object)null && (Object)(object)self.recoveryPlayer == (Object)(object)p && (Object)(object)p != (Object)null && !p.isPlayerDead)
			{
				return Time.realtimeSinceStartup < self.stunnedUntil;
			}
			return false;
		}

		private void Awake()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Expected O, but got Unknown
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Expected O, but got Unknown
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Expected O, but got Unknown
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Expected O, but got Unknown
			//IL_0119: Expected O, but got Unknown
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Expected O, but got Unknown
			self = this;
			GazeMonitor.ProxyThresholdReached += Warn;
			if (!controlsPatched)
			{
				controlsPatched = true;
				Harmony val = new Harmony("slendercompany.proxy.controls");
				val.Patch((MethodBase)AccessTools.PropertySetter(typeof(DissonanceComms), "IsMuted"), new HarmonyMethod(typeof(ProxyVoice), "PreserveMute", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				val.Patch((MethodBase)AccessTools.Method(typeof(PlayerControllerB), "ActivateItem_performed", (Type[])null, (Type[])null), new HarmonyMethod(typeof(WearableMask), "CapturePress", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				val.Patch((MethodBase)AccessTools.Method(typeof(PlayerControllerB), "ActivateItem_canceled", (Type[])null, (Type[])null), new HarmonyMethod(typeof(WearableMask), "CaptureRelease", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				val.Patch((MethodBase)AccessTools.Method(typeof(PlayerControllerB), "Update", (Type[])null, (Type[])null), new HarmonyMethod(typeof(ProxySession), "BlockMovement", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(ProxySession), "RestoreMovement", (Type[])null), (HarmonyMethod)null);
				string[] array = new string[14]
				{
					"PlayerLookInput", "ActivateItem_performed", "ScrollMouse_performed", "UseUtilitySlot_performed", "InspectItem_performed", "QEItemInteract_performed", "ItemSecondaryUse_performed", "ItemTertiaryUse_performed", "Interact_performed", "Discard_performed",
					"Jump_performed", "Crouch_performed", "Emote1_performed", "Emote2_performed"
				};
				foreach (string text in array)
				{
					val.Patch((MethodBase)AccessTools.Method(typeof(PlayerControllerB), text, (Type[])null, (Type[])null), new HarmonyMethod(typeof(ProxySession), "AllowInput", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				}
			}
		}

		private static bool AllowInput(PlayerControllerB __instance)
		{
			return !Blocks(__instance);
		}

		private void Warn(PlayerControllerB p)
		{
			if (!((Object)(object)self != (Object)(object)this) && ((Behaviour)this).isActiveAndEnabled && !((Object)(object)owner != (Object)null))
			{
				owner = p;
				gazeSkin = Random.Range(0, 3);
				warningUntil = Time.time + 3f;
			}
		}

		public static bool Begin(PlayerControllerB p, int skin)
		{
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: 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)
			if ((Object)(object)p == (Object)null || p.isPlayerDead || skin < 0 || skin >= ProxyMasks.Items.Length)
			{
				return false;
			}
			if ((Object)(object)self == (Object)null || !((Behaviour)self).isActiveAndEnabled)
			{
				StartOfRound instance = StartOfRound.Instance;
				if ((Object)(object)instance == (Object)null)
				{
					return false;
				}
				if ((Object)(object)self != (Object)null)
				{
					((Behaviour)self).enabled = false;
				}
				self = ((Component)instance).GetComponent<ProxySession>() ?? ((Component)instance).gameObject.AddComponent<ProxySession>();
				((Behaviour)self).enabled = true;
			}
			if (activeUntil > 0f)
			{
				return false;
			}
			warningUntil = 0f;
			owner = p;
			activeUntil = Time.realtimeSinceStartup + 25f;
			self.wornItem = p.currentlyHeldObjectServer as WearableMask;
			if ((Object)(object)self.wornItem != (Object)null)
			{
				skin = self.wornItem.SkinIndex;
			}
			self.healthBefore = p.health;
			self.healGoal = 0;
			p.moveInputVector = Vector2.zero;
			self.nextPath = 0f;
			self.nextHit = 0f;
			self.fleeUntil = 0f;
			self.waypoint = ((Component)p).transform.position;
			self.target = null;
			self.exits = Object.FindObjectsOfType<EntranceTeleport>();
			self.recoveryGoal = null;
			self.progressWatch.Reset(Feet(p), Time.time);
			self.DiscoverCrossings();
			self.sampleProgress = Feet(p);
			self.sampleAt = Time.time + 0.65f;
			self.stuckUntil = 0f;
			self.punchTarget = null;
			self.nextLightCheck = (self.flinchUntil = 0f);
			self.flashLatched = false;
			self.fleeUntil = 0f;
			self.hitAnyone = false;
			self.recoveryPlayer = null;
			self.voice = ((Component)p).gameObject.AddComponent<ProxyVoice>();
			self.voice.StartSession();
			self.ColorGrade();
			self.ShowFace(p, skin);
			self.Send(p.actualClientId, skin);
			Debug.Log((object)("[SlenderPages] Proxy possession started, skin=" + skin + " duration=25s"));
			return true;
		}

		private void ColorGrade()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			grading = new GameObject("Proxy monochrome");
			grading.AddComponent<ProxyTintDeadline>().Deadline = activeUntil;
			Volume val = ((IEnumerable<Volume>)Object.FindObjectsOfType<Volume>()).FirstOrDefault((Func<Volume, bool>)((Volume v) => v.isGlobal && ((Behaviour)v).enabled));
			if ((Object)(object)val != (Object)null)
			{
				grading.layer = ((Component)val).gameObject.layer;
			}
			Volume obj = grading.AddComponent<Volume>();
			obj.isGlobal = true;
			obj.priority = 10000f;
			profile = ScriptableObject.CreateInstance<VolumeProfile>();
			obj.sharedProfile = profile;
			((VolumeParameter<float>)(object)profile.Add<ColorAdjustments>(false).saturation).Override(-100f);
		}

		private void ShowFace(PlayerControllerB p, int skin)
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: 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_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: 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_02bd: 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_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: 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_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: 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_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: 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_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: 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)
			RemoveFace(p.actualClientId);
			if (skin < 0)
			{
				return;
			}
			MeshRenderer mainObjectRenderer = ProxyMasks.Items[skin].spawnPrefab.GetComponent<GrabbableObject>().mainObjectRenderer;
			Face face = new Face
			{
				skin = skin,
				model = new GameObject("Worn Proxy mask"),
				player = p,
				until = Time.realtimeSinceStartup + 25f
			};
			face.model.AddComponent<MeshFilter>().sharedMesh = ((Component)mainObjectRenderer).GetComponent<MeshFilter>().sharedMesh;
			MeshRenderer val = face.model.AddComponent<MeshRenderer>();
			((Renderer)val).sharedMaterials = ((Renderer)mainObjectRenderer).sharedMaterials;
			HauntedMaskItem val2 = WearableMask.Template;
			if ((Object)(object)val2 == (Object)null)
			{
				val2 = ((IEnumerable<HauntedMaskItem>)Resources.FindObjectsOfTypeAll<HauntedMaskItem>()).FirstOrDefault((Func<HauntedMaskItem, bool>)((HauntedMaskItem n) => (Object)(object)n.headMaskPrefab != (Object)null));
			}
			MeshRenderer val3 = (((Object)(object)val2 != (Object)null && (Object)(object)val2.headMaskPrefab != (Object)null) ? val2.headMaskPrefab.GetComponentInChildren<MeshRenderer>(true) : null);
			bool flag = (Object)(object)p == (Object)(object)GameNetworkManager.Instance.localPlayerController;
			Transform val4 = (((Object)(object)p.playerGlobalHead != (Object)null) ? p.playerGlobalHead : ((Component)p.gameplayCamera).transform);
			face.model.transform.SetParent(val4, false);
			Vector3 val5 = default(Vector3);
			((Vector3)(ref val5))..ctor(0f, 0f, 0.18f);
			float num = 0.42f;
			Bounds localBounds;
			if ((Object)(object)val3 != (Object)null)
			{
				Transform transform = val2.headMaskPrefab.transform;
				Transform transform2 = ((Component)val3).transform;
				localBounds = ((Renderer)val3).localBounds;
				Vector3 val6 = transform.InverseTransformPoint(transform2.TransformPoint(((Bounds)(ref localBounds)).center));
				val5 = val2.headPositionOffset + Quaternion.Euler(val2.headRotationOffset) * Vector3.Scale(val6, transform.localScale);
				localBounds = ((Renderer)val3).localBounds;
				Vector3 val7 = Vector3.Scale(((Bounds)(ref localBounds)).size, ((Component)val3).transform.lossyScale);
				num = Mathf.Max(new float[3]
				{
					Mathf.Abs(val7.x),
					Mathf.Abs(val7.y),
					Mathf.Abs(val7.z)
				});
			}
			val5 += Vector3.up * 0.25f;
			Transform transform3 = face.model.transform;
			transform3.localPosition = val5;
			transform3.localRotation = Quaternion.Euler(0f, 180f, 0f);
			float num2 = num;
			localBounds = ((Renderer)mainObjectRenderer).localBounds;
			float num3 = num2 / ((Bounds)(ref localBounds)).size.y;
			Vector3 lossyScale = val4.lossyScale;
			transform3.localScale = new Vector3(num3 / lossyScale.x, num3 / lossyScale.y, num3 / lossyScale.z);
			if (flag)
			{
				((Renderer)val).shadowCastingMode = (ShadowCastingMode)((!((Object)(object)p.thisPlayerModel != (Object)null)) ? 3 : ((int)((Renderer)p.thisPlayerModel).shadowCastingMode));
			}
			WearableMask wearableMask = p.currentlyHeldObjectServer as WearableMask;
			if ((Object)(object)wearableMask != (Object)null)
			{
				face.hidden = (Renderer)(object)((GrabbableObject)wearableMask).mainObjectRenderer;
				face.hidden.forceRenderingOff = true;
			}
			faces[p.actualClientId] = face;
			ProxyReaction.For(p).StartAudio(skin, flag ? ((Action<int>)delegate(int code)
			{
				Send(p.actualClientId, code);
			}) : null);
		}

		private void RemoveFace(ulong id)
		{
			if (!faces.TryGetValue(id, out var value))
			{
				return;
			}
			if ((Object)(object)value.player != (Object)null)
			{
				ProxyReaction component = ((Component)value.player).GetComponent<ProxyReaction>();
				if ((Object)(object)component != (Object)null)
				{
					component.EndAudio();
					component.StopPose();
				}
			}
			if ((Object)(object)value.hidden != (Object)null)
			{
				value.hidden.forceRenderingOff = false;
			}
			if ((Object)(object)value.model != (Object)null)
			{
				Object.Destroy((Object)(object)value.model);
			}
			faces.Remove(id);
		}

		private unsafe void Send(ulong id, int skin)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager singleton = NetworkManager.Singleton;
			if (bus == null || (Object)(object)singleton == (Object)null || !singleton.IsListening)
			{
				return;
			}
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(24, (Allocator)2, -1);
			try
			{
				((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref id, default(ForPrimitives));
				((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref skin, default(ForPrimitives));
				if (singleton.IsServer)
				{
					foreach (ulong connectedClientsId in singleton.ConnectedClientsIds)
					{
						if (connectedClientsId != singleton.LocalClientId && connectedClientsId != id)
						{
							bus.SendNamedMessage("SlenderCompany.Proxy.22", connectedClientsId, val, (NetworkDelivery)3);
						}
					}
					return;
				}
				bus.SendNamedMessage("SlenderCompany.Proxy.22", 0uL, val, (NetworkDelivery)3);
			}
			finally
			{
				((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose();
			}
		}

		private void Receive(ulong from, FastBufferReader data)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			ulong id = default(ulong);
			((FastBufferReader)(ref data)).ReadValueSafe<ulong>(ref id, default(ForPrimitives));
			int num = default(int);
			((FastBufferReader)(ref data)).ReadValueSafe<int>(ref num, default(ForPrimitives));
			NetworkManager singleton = NetworkManager.Singleton;
			bool flag = num >= 10 && num < 20;
			bool flag2 = num >= 30 && num < 33;
			bool flag3 = num >= 40 && num < 43;
			if (!(flag || flag2 || flag3))
			{
				switch (num)
				{
				case -5:
				case -3:
				case -2:
				case -1:
				case 0:
				case 1:
				case 2:
					break;
				default:
					return;
				}
			}
			if (singleton.IsServer ? (from != id) : (from != 0))
			{
				return;
			}
			PlayerControllerB val = ((IEnumerable<PlayerControllerB>)StartOfRound.Instance.allPlayerScripts).FirstOrDefault((Func<PlayerControllerB, bool>)((PlayerControllerB x) => (Object)(object)x != (Object)null && x.actualClientId == id && x.isPlayerControlled));
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			if (flag || flag2 || flag3 || num == -2)
			{
				if (!faces.TryGetValue(id, out var value))
				{
					return;
				}
				ProxyReaction proxyReaction = ProxyReaction.For(val);
				if (flag)
				{
					proxyReaction.PlayLine(num - 10);
				}
				else if (flag2)
				{
					proxyReaction.Blind(value.skin, num - 30);
				}
				else if (flag3)
				{
					proxyReaction.Hit(num - 40);
				}
				else
				{
					Punch(val);
				}
			}
			else if (num < 0)
			{
				if (singleton.IsServer && num == -3)
				{
					DropGazeMask(val);
				}
				RemoveFace(id);
				if (num == -3 || num == -5)
				{
					ProxyReaction.For(val).Cough();
				}
			}
			else
			{
				ShowFace(val, num);
			}
			if (singleton.IsServer)
			{
				Send(id, num);
			}
		}

		private void Finish(bool completed)
		{
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: 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)
			PlayerControllerB val = owner;
			owner = null;
			warningUntil = 0f;
			if (activeUntil <= 0f)
			{
				return;
			}
			activeUntil = 0f;
			StopGuide();
			if ((Object)(object)voice != (Object)null)
			{
				((Behaviour)voice).enabled = false;
				Object.Destroy((Object)(object)voice);
				voice = null;
			}
			if ((Object)(object)grading != (Object)null)
			{
				grading.SetActive(false);
				Object.Destroy((Object)(object)grading);
				grading = null;
			}
			if ((Object)(object)profile != (Object)null)
			{
				foreach (VolumeComponent component2 in profile.components)
				{
					Object.Destroy((Object)(object)component2);
				}
				Object.Destroy((Object)(object)profile);
				profile = null;
			}
			WearableMask wearableMask = wornItem;
			wornItem = null;
			if ((Object)(object)wearableMask != (Object)null)
			{
				wearableMask.CancelWear();
				((Renderer)((GrabbableObject)wearableMask).mainObjectRenderer).forceRenderingOff = false;
			}
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			bool flag = completed && (Object)(object)wearableMask == (Object)null;
			if (flag && (Object)(object)NetworkManager.Singleton != (Object)null && NetworkManager.Singleton.IsServer)
			{
				DropGazeMask(val);
			}
			Send(val.actualClientId, flag ? (-3) : (completed ? (-5) : (-1)));
			RemoveFace(val.actualClientId);
			if (completed)
			{
				ProxyReaction.For(val).Cough();
			}
			val.activatingItem = false;
			if ((Object)(object)val.playerBodyAnimator != (Object)null)
			{
				val.playerBodyAnimator.SetBool("HoldMask", false);
			}
			if (completed && (Object)(object)wearableMask != (Object)null && (Object)(object)val.currentlyHeldObjectServer == (Object)(object)wearableMask)
			{
				val.DiscardHeldObject(false, (NetworkObject)null, default(Vector3), true);
				if (!((GrabbableObject)wearableMask).isPocketed)
				{
					((GrabbableObject)wearableMask).EnableItemMeshes(true);
				}
			}
			GazeMonitor component = ((Component)this).GetComponent<GazeMonitor>();
			if ((Object)(object)component != (Object)null)
			{
				component.ResetExposure();
			}
			if (completed)
			{
				if (!hitAnyone)
				{
					recoveryPlayer = val;
					stunnedUntil = Time.realtimeSinceStartup + 0.7f;
				}
				if (val.health > 50)
				{
					val.DamagePlayer(val.health - 50, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
				}
				healGoal = ((healthBefore >= 50) ? healthBefore : 0);
				emptyUntil = Time.realtimeSinceStartup + 5f;
				nextHeal = Time.time;
				val.sprintMeter = 0f;
			}
		}

		private void Update()
		{
			if (activeUntil > 0f && Time.realtimeSinceStartup >= activeUntil)
			{
				bool completed = (Object)(object)owner != (Object)null && !owner.isPlayerDead && (Object)(object)StartOfRound.Instance != (Object)null && !StartOfRound.Instance.inShipPhase;
				Finish(completed);
			}
		}

		private void OnDisable()
		{
			if ((Object)(object)self == (Object)(object)this)
			{
				Finish(completed: false);
			}
		}

		private void LateUpdate()
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			NetworkManager singleton = NetworkManager.Singleton;
			CustomMessagingManager val = (((Object)(object)singleton != (Object)null && singleton.IsListening) ? singleton.CustomMessagingManager : null);
			if (bus != val)
			{
				if (bus != null)
				{
					bus.UnregisterNamedMessageHandler("SlenderCompany.Proxy.22");
				}
				bus = val;
				if (bus != null)
				{
					bus.RegisterNamedMessageHandler("SlenderCompany.Proxy.22", new HandleNamedMessageDelegate(Receive));
				}
			}
			GameNetworkManager instance = GameNetworkManager.Instance;
			PlayerControllerB val2 = (((Object)(object)instance != (Object)null) ? instance.localPlayerController : null);
			ulong[] array;
			if ((Object)(object)val2 == (Object)null || (Object)(object)StartOfRound.Instance == (Object)null || StartOfRound.Instance.inShipPhase)
			{
				Finish(completed: false);
				healGoal = 0;
				emptyUntil = 0f;
				array = faces.Keys.ToArray();
				foreach (ulong id in array)
				{
					RemoveFace(id);
				}
				return;
			}
			array = faces.Keys.ToArray();
			foreach (ulong num in array)
			{
				Face face = faces[num];
				if ((Object)(object)face.player == (Object)null || face.player.isPlayerDead || !face.player.isPlayerControlled || Time.realtimeSinceStartup >= face.until + 5f)
				{
					RemoveFace(num);
				}
			}
			if (val2.isPlayerDead)
			{
				Finish(completed: false);
				healGoal = 0;
				emptyUntil = 0f;
				return;
			}
			if (warningUntil > 0f && Time.time >= warningUntil)
			{
				Begin(val2, gazeSkin);
			}
			if (activeUntil > 0f && (Object)(object)owner == (Object)(object)val2)
			{
				Hunt(val2);
				SyncHeading(val2);
				ResolvePunch(val2);
			}
			if (Time.realtimeSinceStartup < emptyUntil)
			{
				val2.sprintMeter = 0f;
			}
			if (healGoal > val2.health && Time.time >= nextHeal)
			{
				val2.health = Mathf.Min(healGoal, val2.health + 1);
				if ((Object)(object)HUDManager.Instance != (Object)null)
				{
					HUDManager.Instance.UpdateHealthUI(val2.health, false);
				}
				nextHeal = Time.time + 0.6f;
			}
			if (val2.health >= healGoal)
			{
				healGoal = 0;
			}
		}

		private void DropGazeMask(PlayerControllerB p)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			if (faces.TryGetValue(p.actualClientId, out var value) && !((Object)(object)value.hidden != (Object)null) && !((Object)(object)RoundManager.Instance == (Object)null))
			{
				ProxyMasks.Spawn(value.skin, ((Component)p).transform.position + ((Component)p).transform.forward * 0.4f + Vector3.up * 0.25f, RoundManager.Instance, p.isInsideFactory);
			}
		}

		internal static void Punch(PlayerControllerB p)
		{
			(((Component)p).GetComponent<ProxyPunch>() ?? ((Component)p).gameObject.AddComponent<ProxyPunch>()).Play(p);
		}

		internal static bool FaceInBeam(Vector3 beam, Vector3 faceForward, Vector3 toFace)
		{
			//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)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			if (((Vector3)(ref toFace)).sqrMagnitude <= 144f && ((Vector3)(ref toFace)).sqrMagnitude > 0.001f && Vector3.Angle(beam, toFace) <= 18f)
			{
				return Vector3.Angle(faceForward, -toFace) <= 75f;
			}
			return false;
		}

		private void CheckFlashlights(PlayerControllerB p)
		{
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: 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)
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if ((Object)(object)val == (Object)null || (Object)(object)val == (Object)(object)p || !val.isPlayerControlled || val.isPlayerDead || val.isInsideFactory != p.isInsideFactory || (Object)(object)val.gameplayCamera == (Object)null)
				{
					continue;
				}
				GrabbableObject currentlyHeldObjectServer = val.currentlyHeldObjectServer;
				FlashlightItem val2 = (FlashlightItem)(object)((currentlyHeldObjectServer is FlashlightItem) ? currentlyHeldObjectServer : null);
				GrabbableObject pocketedFlashlight = val.pocketedFlashlight;
				FlashlightItem val3 = (FlashlightItem)(object)((pocketedFlashlight is FlashlightItem) ? pocketedFlashlight : null);
				if (((Object)(object)val2 == (Object)null || !((GrabbableObject)val2).isBeingUsed) && ((Object)(object)val3 == (Object)null || !((GrabbableObject)val3).isBeingUsed))
				{
					continue;
				}
				Transform transform = ((Component)val.gameplayCamera).transform;
				Transform transform2 = ((Component)p.gameplayCamera).transform;
				if (!FaceInBeam(transform.forward, ((Component)p).transform.forward, transform2.position - transform.position) || WatcherBody.Blocked(transform.position, transform2.position))
				{
					continue;
				}
				if (!flashLatched && Time.time >= fleeUntil)
				{
					flinchUntil = Time.time + 1.6f;
					fleeUntil = flinchUntil + 3f;
					if (faces.TryGetValue(p.actualClientId, out var value))
					{
						ProxyReaction proxyReaction = ProxyReaction.For(p);
						int num = proxyReaction.BlindChoice(value.skin);
						proxyReaction.Blind(value.skin, num);
						Send(p.actualClientId, 30 + num);
					}
					lightPosition = transform.position;
					target = null;
					punchTarget = null;
					nextPath = 0f;
					StopGuide();
				}
				flashLatched = true;
				return;
			}
			flashLatched = false;
		}

		private void StopGuide()
		{
			if ((Object)(object)guide != (Object)null)
			{
				((Component)guide).gameObject.SetActive(false);
				Object.Destroy((Object)(object)((Component)guide).gameObject);
				guide = null;
			}
			destinationSet = false;
		}

		private Vector3 Travel(PlayerControllerB p)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: 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_0084: Expected O, but got Unknown
			//IL_0093: 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_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: 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_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: 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_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: 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_0290: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = Feet(p);
			NavMeshHit val2 = default(NavMeshHit);
			NavMeshHit val3 = default(NavMeshHit);
			if (!NavMesh.SamplePosition(val, ref val2, 1.8f, travelFilter) || !NavMesh.SamplePosition(waypoint, ref val3, 1.8f, travelFilter))
			{
				return Vector3.zero;
			}
			if ((Object)(object)guide != (Object)null && guide.agentTypeID != ((NavMeshQueryFilter)(ref travelFilter)).agentTypeID)
			{
				StopGuide();
			}
			if ((Object)(object)guide == (Object)null)
			{
				GameObject val4 = new GameObject("Proxy navigation");
				val4.SetActive(false);
				val4.transform.position = ((NavMeshHit)(ref val2)).position;
				guide = val4.AddComponent<NavMeshAgent>();
				guide.agentTypeID = ((NavMeshQueryFilter)(ref travelFilter)).agentTypeID;
				guide.updatePosition = false;
				guide.updateRotation = false;
				guide.autoTraverseOffMeshLink = false;
				guide.radius = p.thisController.radius;
				guide.height = p.thisController.height;
				guide.acceleration = 32f;
				guide.stoppingDistance = 0.05f;
				guide.autoBraking = false;
				val4.SetActive(true);
			}
			Vector3 val5;
			if (guide.isOnNavMesh)
			{
				val5 = guide.nextPosition - ((NavMeshHit)(ref val2)).position;
				if (!(((Vector3)(ref val5)).sqrMagnitude > 4f))
				{
					goto IL_0197;
				}
			}
			if (!guide.Warp(((NavMeshHit)(ref val2)).position))
			{
				return Vector3.zero;
			}
			destinationSet = false;
			goto IL_0197;
			IL_0295:
			return Vector3.ProjectOnPlane(guide.desiredVelocity, Vector3.up);
			IL_0197:
			if (guide.isOnOffMeshLink)
			{
				OffMeshLinkData currentOffMeshLinkData = guide.currentOffMeshLinkData;
				selected = new Crossing(val, ((OffMeshLinkData)(ref currentOffMeshLinkData)).endPos, ladder: false);
				depart = val;
				started = (lastMotionAt = Time.time);
				traversing = true;
				hasCrossing = false;
				crossingPhase = 0;
				lastMotion = val;
				dismount = ((OffMeshLinkData)(ref currentOffMeshLinkData)).endPos;
				StopGuide();
				return Vector3.zero;
			}
			guide.nextPosition = ((NavMeshHit)(ref val2)).position;
			guide.speed = p.movementSpeed * 2.25f * 0.8f;
			if (destinationSet)
			{
				val5 = ((NavMeshHit)(ref val3)).position - lastDestination;
				if (!(((Vector3)(ref val5)).sqrMagnitude > 0.04f))
				{
					goto IL_0295;
				}
			}
			destinationSet = guide.SetDestination(((NavMeshHit)(ref val3)).position);
			lastDestination = ((NavMeshHit)(ref val3)).position;
			goto IL_0295;
		}

		private void SyncHeading(PlayerControllerB p)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			if (!(Time.unscaledTime < nextRotation))
			{
				nextRotation = Time.unscaledTime + 0.1f;
				SendLook(p, (short)Mathf.DeltaAngle(0f, ((Component)p.gameplayCamera).transform.localEulerAngles.x), (short)p.thisPlayerBody.localEulerAngles.y);
			}
		}

		private void Hunt(PlayerControllerB p)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: 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_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			if (Time.time >= nextLightCheck)
			{
				nextLightCheck = Time.time + 0.075f;
				CheckFlashlights(p);
			}
			if (Time.time < flinchUntil)
			{
				progressWatch.Reset(Feet(p), Time.time);
				if ((Object)(object)p.playerBodyAnimator != (Object)null)
				{
					p.playerBodyAnimator.SetBool("Walking", false);
					p.playerBodyAnimator.SetBool("Sprinting", false);
				}
			}
			else
			{
				if (RecoverIfStuck(p) || AdvanceCrossing(p))
				{
					return;
				}
				if (Time.time >= nextPath)
				{
					nextPath = Time.time + 0.22f;
					Plan(p);
					if (AdvanceCrossing(p))
					{
						return;
					}
				}
				Vector3 val = Travel(p);
				if (((Vector3)(ref val)).sqrMagnitude > 0.015f && (Object)(object)p.thisController != (Object)null && ((Collider)p.thisController).enabled)
				{
					((Component)p).transform.rotation = Quaternion.RotateTowards(((Component)p).transform.rotation, Quaternion.LookRotation(val), Time.deltaTime * 440f);
					p.thisController.Move(val * Time.deltaTime);
				}
				if ((Object)(object)p.playerBodyAnimator != (Object)null)
				{
					bool flag = ((Vector3)(ref val)).sqrMagnitude > 0.05f;
					p.playerBodyAnimator.SetBool("Walking", flag);
					p.playerBodyAnimator.SetBool("Sprinting", flag);
				}
				if ((Object)(object)target != (Object)null && fleeUntil <= Time.time && Time.time >= nextHit && !target.isPlayerDead && Vector3.Distance(((Component)p).transform.position, ((Component)target).transform.position) < 1.8f && ClearSight(p, target))
				{
					nextHit = Time.time + 3f;
					punchTarget = target;
					impactAt = Time.time + 0.64f;
					Vector3 val2 = Vector3.ProjectOnPlane(((Component)target).transform.position - ((Component)p).transform.position, Vector3.up);
					if (((Vector3)(ref val2)).sqrMagnitude > 0.001f)
					{
						((Component)p).transform.rotation = Quaternion.LookRotation(val2);
					}
					Punch(p);
					Send(p.actualClientId, -2);
				}
			}
		}

		private void ResolvePunch(PlayerControllerB p)
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)punchTarget == (Object)null) && !(Time.time < impactAt))
			{
				PlayerControllerB val = punchTarget;
				punchTarget = null;
				if (val.isPlayerControlled && !val.isPlayerDead && !StalkingDirector.Sheltered(val) && val.isInsideFactory == p.isInsideFactory && !(Vector3.Distance(((Component)p).transform.position, ((Component)val).transform.position) > 1.9f) && ClearSight(p, val) && !(Time.time < fleeUntil))
				{
					val.DamagePlayerFromOtherClientServerRpc(20, ((Component)p).transform.forward, (int)p.playerClientId);
					int num = Random.Range(0, 3);
					ProxyReaction.For(p).Hit(num);
					Send(p.actualClientId, 40 + num);
					hitAnyone = true;
				}
			}
		}

		private static bool ClearSight(PlayerControllerB a, PlayerControllerB b)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			return !Physics.Linecast(((Component)a.gameplayCamera).transform.position, ((Component)b.gameplayCamera).transform.position, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1);
		}

		private void Plan(PlayerControllerB p)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: 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_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0467: Unknown result type (might be due to invalid IL or missing references)
			//IL_046c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0474: Unknown result type (might be due to invalid IL or missing references)
			//IL_0479: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_0494: Unknown result type (might be due to invalid IL or missing references)
			//IL_0499: Unknown result type (might be due to invalid IL or missing references)
			//IL_0352: Unknown result type (might be due to invalid IL or missing references)
			//IL_0359: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e9: Unknown