Decompiled source of SCP2006 v1.0.3

plugins/ProjectSCP.SCP2006.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using Dawn.Utils;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using ProjectSCP.SCP2006.NetcodePatcher;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Animations.Rigging;
using UnityEngine.Events;
using UnityEngine.UI;
using UnityEngine.Video;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ClientNetworkTransform")]
[assembly: IgnoresAccessChecksTo("com.github.teamxiaolan.dawnlib")]
[assembly: IgnoresAccessChecksTo("com.olegknyazev.softmask")]
[assembly: IgnoresAccessChecksTo("DissonanceVoip")]
[assembly: IgnoresAccessChecksTo("EasyTextEffects")]
[assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Jobs")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")]
[assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")]
[assembly: IgnoresAccessChecksTo("Unity.Services.QoS")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Relay")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: AssemblyCompany("ProjectSCP.SCP2006")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.3.0")]
[assembly: AssemblyInformationalVersion("1.0.3+d72387cdbb53ec93d08d22eec08bbb36dfba8ccb")]
[assembly: AssemblyProduct("SCP2006")]
[assembly: AssemblyTitle("ProjectSCP.SCP2006")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.3.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace SCP2006
{
	[HarmonyPatch]
	internal class Patches
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerControllerB), "KillPlayer")]
		public static void KillPlayerPostfix(PlayerControllerB __instance)
		{
			try
			{
				SCP2006AI.onPlayerDeath.Invoke(__instance.actualClientId);
			}
			catch
			{
			}
		}
	}
	[BepInPlugin("ProjectSCP.SCP2006", "SCP2006", "1.0.3")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public static Plugin PluginInstance;

		private readonly Harmony harmony = new Harmony("ProjectSCP.SCP2006");

		public static ManualLogSource logger => ((BaseUnityPlugin)PluginInstance).Logger;

		public static PlayerControllerB localPlayer => GameNetworkManager.Instance.localPlayerController;

		public static bool IsServerOrHost => NetworkManager.Singleton.IsServer || NetworkManager.Singleton.IsHost;

		public static PlayerControllerB? PlayerFromId(ulong id)
		{
			return StartOfRound.Instance.allPlayerScripts.Where((PlayerControllerB x) => x.actualClientId == id).FirstOrDefault();
		}

		private void Awake()
		{
			if ((Object)(object)PluginInstance == (Object)null)
			{
				PluginInstance = this;
			}
			harmony.PatchAll();
			InitializeNetworkBehaviours();
			logger.LogInfo((object)"ProjectSCP.SCP2006 v1.0.3 has loaded!");
		}

		private static void InitializeNetworkBehaviours()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
			logger.LogDebug((object)"Finished initializing network behaviours");
		}
	}
	[CreateAssetMenu(menuName = "SCP2006/ScareData")]
	public class ScareDef : ScriptableObject
	{
		public string enemyTypeName;

		public bool outside;

		public Sprite movieCover;

		public AudioClip[] scareSFX;

		public AudioClip[] baitSFX;

		public AudioClip[] encounterSFX;

		public string animState;

		public float animTime;

		public VideoClip video;
	}
	internal class ScareManager : NetworkBehaviour
	{
		private delegate void MethodDelegate();

		public SCP2006AI scp;

		private List<MethodDelegate> scareMethods = new List<MethodDelegate>();

		public bool scareFinished;

		private Coroutine? scareCoroutine;

		private Action? scareCleanup;

		private EnemyAI? mimicEnemy => scp.mimicEnemy;

		public ScareDef currentScareDef => scp.currentScareDef;

		public override void OnDestroy()
		{
			((MonoBehaviour)this).StopAllCoroutines();
		}

		public void Start()
		{
			scareMethods.Add(Centipede);
			scareMethods.Add(SandSpider);
			scareMethods.Add(HoarderBug);
			scareMethods.Add(Flowerman);
			scareMethods.Add(Crawler);
			scareMethods.Add(Blob);
			scareMethods.Add(DressGirl);
			scareMethods.Add(Puffer);
			scareMethods.Add(Nutcracker);
			scareMethods.Add(MouthDog);
			scareMethods.Add(ForestGiant);
			scareMethods.Add(SandWorm);
			scareMethods.Add(RadMech);
			scareMethods.Add(ClaySurgeon);
			scareMethods.Add(CaveDweller);
			scareMethods.Add(FlowerSnake);
			scareMethods.Add(GiantKiwi);
			scareMethods.Add(BaboonHawk);
			scareMethods.Add(SpringMan);
			scareMethods.Add(Jester);
			scareMethods.Add(MaskedPlayerEnemy);
			scareMethods.Add(Butler);
		}

		private void Centipede()
		{
		}

		private void SandSpider()
		{
		}

		private void HoarderBug()
		{
		}

		private void Flowerman()
		{
		}

		private void Crawler()
		{
		}

		private void Blob()
		{
		}

		private void DressGirl()
		{
		}

		private void Puffer()
		{
		}

		private void Nutcracker()
		{
		}

		private void MouthDog()
		{
		}

		private void ForestGiant()
		{
		}

		private void SandWorm()
		{
		}

		private void RadMech()
		{
		}

		private void ClaySurgeon()
		{
		}

		private void CaveDweller()
		{
		}

		private void FlowerSnake()
		{
		}

		private void GiantKiwi()
		{
		}

		private void BaboonHawk()
		{
		}

		private void SpringMan()
		{
		}

		private void Jester()
		{
		}

		private void MaskedPlayerEnemy()
		{
		}

		private void Butler()
		{
		}

		public void StartScare(ScareDef scareDef)
		{
			ScareDef scareDef2 = scareDef;
			scareFinished = false;
			scareMethods.Where((MethodDelegate x) => x.Method.Name == scareDef2.enemyTypeName).FirstOrDefault()?.Invoke();
		}

		public void StopScare()
		{
			((MonoBehaviour)this).StopCoroutine(scareCoroutine);
			scareCoroutine = null;
			scareCleanup?.Invoke();
			scareCleanup = null;
			if ((Object)(object)mimicEnemy != (Object)null)
			{
				scp.DespawnMimicEnemy();
			}
		}

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

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

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "ScareManager";
		}
	}
	internal class SCP2006AI : EnemyAI
	{
		public enum ReactionType
		{
			Yell,
			Sprint,
			FastTurn,
			Jump
		}

		public enum State
		{
			Roaming,
			Sneaking,
			Scaring,
			Reaction,
			Spotted,
			Wanting,
			Resting
		}

		public enum AudioArray
		{
			Bait,
			Scare,
			Hit,
			ReactionFailed,
			ReactionSuccess,
			Roaming,
			SeenSneaking,
			Sneaking,
			WatchingTape,
			Encounter,
			PlayerFollowing,
			PlayerKilledReaction,
			Bonus
		}

		[CompilerGenerated]
		private sealed class <<TryTestTransformationsIfDebugging>g__TestTransformations|113_0>d : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public SCP2006AI <>4__this;

			private ScareDef[] <>s__1;

			private int <>s__2;

			private ScareDef <scare>5__3;

			private int <index>5__4;

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

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

			[DebuggerHidden]
			public <<TryTestTransformationsIfDebugging>g__TestTransformations|113_0>d(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

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

			private bool MoveNext()
			{
				//IL_0187: Unknown result type (might be due to invalid IL or missing references)
				//IL_0191: Expected O, but got Unknown
				//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b6: Expected O, but got Unknown
				//IL_015b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0165: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = null;
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<>s__1 = <>4__this.scareDefs;
					<>s__2 = 0;
					break;
				case 2:
					<>1__state = -1;
					<index>5__4 = (((Object)(object)<>4__this.currentScareDef != (Object)null && <>4__this.currentScareDef.enemyTypeName != "") ? Random.Range(0, <>4__this.currentScareDef.scareSFX.Length) : Random.Range(0, <>4__this.scareSFX.Length));
					<>4__this.ScareClientRpc(<index>5__4, Plugin.localPlayer.actualClientId);
					<>2__current = (object)new WaitForSeconds(<>4__this.currentScareDef.animTime + 3f);
					<>1__state = 3;
					return true;
				case 3:
					<>1__state = -1;
					<>4__this.DespawnMimicEnemy();
					<>2__current = (object)new WaitForSeconds(3f);
					<>1__state = 4;
					return true;
				case 4:
					<>1__state = -1;
					<scare>5__3 = null;
					<>s__2++;
					break;
				}
				if (<>s__2 < <>s__1.Length)
				{
					<scare>5__3 = <>s__1[<>s__2];
					<>4__this.currentScareDef = <scare>5__3;
					<>4__this.SpawnMimicEnemy();
					<>2__current = (object)new WaitForSeconds(5f);
					<>1__state = 2;
					return true;
				}
				<>s__1 = null;
				return false;
			}

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

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

		public static int DEBUG_scareIndex = -1;

		public const bool DEBUG_testingTransformations = false;

		public static UnityEvent<ulong> onPlayerDeath = new UnityEvent<ulong>();

		public GameObject DEBUG_hudOverlay;

		public ScareManager scareManager;

		public SmartAgentNavigator nav;

		public ParticleSystem particleSystem;

		public ScareDef[] scareDefs;

		public Transform turnCompass;

		public Transform handTransform;

		public Collider tapeTriggerCollider;

		private static Dictionary<ScareDef, int> learnedScares;

		public ScareDef currentScareDef;

		public AudioClip laughSFX;

		public AudioClip tapeGivenSFX;

		public AudioClip obscureNicheThingSFX;

		private Terminal terminalScript;

		private HashSet<string> triggeredActions = new HashSet<string>();

		private int score = 0;

		private readonly Dictionary<string, int> points = new Dictionary<string, int>
		{
			{ "Yell", 4 },
			{ "CameraTurn", 1 },
			{ "Jump", 1 },
			{ "Run", 3 },
			{ "Attack", 2 },
			{ "NoLineOfSight", 3 }
		};

		private Vector3 mainEntranceOutsidePosition;

		private Vector3 mainEntranceInsidePosition;

		private List<EntranceTeleport> entrances = new List<EntranceTeleport>();

		private bool watchingTV;

		private VHSTapeBehavior? heldTape;

		private bool facePlayer;

		private float turnCompassSpeed = 30f;

		private float timeSinceLearnScare;

		private float timeSinceLastSeen;

		private float timeSinceSwitchBehavior;

		private float timeSinceLastHit;

		private float timeSinceStartResting;

		private float idleTime;

		private float tapeRefusalCooldown;

		private int hashSpeed;

		private EnemyAI? seenEnemy;

		public EnemyAI? mimicEnemy;

		private bool spottedByOtherPlayer;

		private int currentFootstepSurfaceIndex;

		private int previousFootstepClip;

		private Vector2 lastCameraAngles;

		private Vector3 lastPosition;

		private bool refusedTape;

		private List<GameObject> ignoredNodes = new List<GameObject>();

		private float currentSpeed;

		private bool waved;

		private bool annoyedByFollowingPlayer;

		private NetworkVariable<ulong> targetPlayerId = new NetworkVariable<ulong>(0uL, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		private PlayerControllerB? closestVisiblePlayer;

		private PlayerControllerB? closestPlayerVisibleTo;

		private PlayerControllerB? closestPlayer;

		private float targetPlayerDistance;

		private float closestPlayerDistance;

		private float timePlayerFollowing;

		private float timeInLOSWithPlayer;

		private float timeHasLOSToPlayer;

		private float timeHasLOSToTargetPlayer;

		private float timeTargetPlayerHasLOS;

		private bool hasLOSToTargetPlayer;

		private bool targetPlayerHasLOS;

		private bool firstTimeEasterEggTriggered;

		private const float learnScareCooldown = 5f;

		private const float distanceToStartScare = 10f;

		private const float distanceToStopScare = 15f;

		private const float spottedLOSCooldown = 10f;

		private const float timeToStopScare = 15f;

		private const float lineOfSightOffset = 2f;

		private const float playerScreamMinVolume = 0.9f;

		private const float reactionDelay = 1f;

		private const int scareSuccessfulScore = 5;

		private const float maxTurnSpeed = 1000f;

		private const float reactionTime = 5f;

		private const float maxWantingTime = 15f;

		private const float roamingVoiceLineCooldown = 20f;

		private const float maxTapeWatchingTime = 60f;

		private const float maxIdleTime = 10f;

		private float scareCooldown = 60f;

		private bool faceEnemy;

		private const float maxScareCooldown = 60f;

		private const float waveCooldownOffset = -10f;

		private const float learnScareCooldownOffset = -20f;

		private const float scareSuccessCooldownOffset = 60f;

		private const float scareFailCooldownOffset = 30f;

		private const float spottedCooldownOffset = 30f;

		private const float minPlayerInLOSTimeToScare = 3f;

		private const float timeInLOSToBeSpotted = 1f;

		private const float minSneakTimeToScare = 10f;

		private const float maxTapeRefusalCooldown = 15f;

		private const float playerIsFollowingDistance = 7.5f;

		private const float timePlayerFollowingToGetAnnoyed = 5f;

		private const float maxSneakSpeed = 15f;

		private const float minSneakSpeed = 8f;

		private const float minSpottedTimeToRoam = 10f;

		private const float timeToStopSneaking = 60f;

		public AudioClip[] baitSFX;

		public AudioClip[] scareSFX;

		public AudioClip[] hitSFX;

		public AudioClip[] reactionFailedSFX;

		public AudioClip[] reactionSuccessSFX;

		public AudioClip[] roamingSFX;

		public AudioClip[] seenSneakingSFX;

		public AudioClip[] sneakingSFX;

		public AudioClip[] watchingTapeSFX;

		public AudioClip[] encounterSFX;

		public AudioClip[] playerFollowingSFX;

		public AudioClip[] playerKilledReactionSFX;

		public AudioClip[] bonusSFX;

		private Random audioRandom;

		private float timeSinceLastVoiceLine;

		private Dictionary<AudioArray, AudioClip[]> audioMap = new Dictionary<AudioArray, AudioClip[]>();

		public static List<SCP2006AI> Instances { get; private set; } = new List<SCP2006AI>();


		private bool isInsideFactory => !isOutside;

		private bool isOutside => nav.IsAgentOutside();

		private PlayerControllerB? targetPlayer
		{
			get
			{
				return Plugin.PlayerFromId(targetPlayerId.Value);
			}
			set
			{
				targetPlayerId.Value = (((Object)(object)value != (Object)null) ? value.actualClientId : 0);
			}
		}

		private bool hasLOSToPlayer => (Object)(object)closestVisiblePlayer != (Object)null || hasLOSToTargetPlayer;

		private bool playerHasLOS => (Object)(object)closestPlayerVisibleTo != (Object)null || targetPlayerHasLOS;

		private bool inLOSWithPlayer => hasLOSToPlayer && (playerHasLOS || targetPlayerHasLOS);

		private void TryTestTransformationsIfDebugging()
		{
			if (!Utils.testing && false)
			{
				((MonoBehaviour)this).StartCoroutine(TestTransformations());
			}
			[IteratorStateMachine(typeof(<<TryTestTransformationsIfDebugging>g__TestTransformations|113_0>d))]
			IEnumerator TestTransformations()
			{
				//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
				return new <<TryTestTransformationsIfDebugging>g__TestTransformations|113_0>d(0)
				{
					<>4__this = this
				};
			}
		}

		public override void Start()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: 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_011d: Expected O, but got Unknown
			//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)
			((EnemyAI)this).Start();
			Plugin.logger.LogDebug((object)"SCP-2006 Spawned");
			mainEntranceInsidePosition = RoundManager.FindMainEntrancePosition(true, false);
			mainEntranceOutsidePosition = RoundManager.FindMainEntrancePosition(true, true);
			entrances = Object.FindObjectsOfType<EntranceTeleport>(false).ToList();
			InitializeAudioMap();
			audioRandom = new Random(StartOfRound.Instance.randomMapSeed + base.thisEnemyIndex);
			onPlayerDeath.AddListener((UnityAction<ulong>)OnPlayerDeath);
			ignoredNodes = new List<GameObject>();
			learnedScares = new Dictionary<ScareDef, int>();
			hashSpeed = Animator.StringToHash("speed");
			if (!learnedScares.ContainsKey(scareDefs[0]))
			{
				learnedScares.Add(scareDefs[0], 1);
			}
			if (!learnedScares.ContainsKey(scareDefs[1]))
			{
				learnedScares.Add(scareDefs[1], 1);
			}
			terminalScript = Object.FindObjectOfType<Terminal>();
			TVSetUnlockable.onTapeEjected.AddListener(new UnityAction(OnRestingInterupted));
			base.currentBehaviourStateIndex = 0;
			timeSinceSwitchBehavior = float.PositiveInfinity;
			nav.SetAllValues(false);
			nav.OnUseEntranceTeleport.AddListener((UnityAction<bool>)OnUseEntranceTeleport);
			nav.OnEnableOrDisableAgent.AddListener((UnityAction<bool>)OnEnableOrDisableAgent);
			if (Utils.isBeta)
			{
				Object.Instantiate<GameObject>(DEBUG_hudOverlay, Vector3.zero, Quaternion.identity);
			}
			TryTestTransformationsIfDebugging();
		}

		public override void OnNetworkSpawn()
		{
			((NetworkBehaviour)this).OnNetworkSpawn();
			if (!Instances.Contains(this))
			{
				Instances.Add(this);
			}
		}

		public override void OnNetworkDespawn()
		{
			((NetworkBehaviour)this).OnNetworkDespawn();
			Instances.Remove(this);
		}

		public void CustomEnemyAIUpdate()
		{
			if (base.inSpecialAnimation || StartOfRound.Instance.allPlayersDead)
			{
				nav.StopAgent();
				base.agent.speed = 0f;
			}
			else if (base.updateDestinationInterval >= 0f)
			{
				base.updateDestinationInterval -= Time.deltaTime;
			}
			else
			{
				((EnemyAI)this).DoAIInterval();
				base.updateDestinationInterval = base.AIIntervalTime + Random.Range(-0.015f, 0.015f);
			}
		}

		public override void Update()
		{
			if (!base.isEnemyDead && !StartOfRound.Instance.allPlayersDead)
			{
				timeSinceLearnScare += Time.deltaTime;
				timeSinceLastSeen += Time.deltaTime;
				timeSinceSwitchBehavior += Time.deltaTime;
				timeSinceLastHit += Time.deltaTime;
				timeSinceStartResting += Time.deltaTime;
				timeSinceLastVoiceLine += Time.deltaTime;
				CustomEnemyAIUpdate();
				timeInLOSWithPlayer = (inLOSWithPlayer ? (timeInLOSWithPlayer + Time.deltaTime) : 0f);
				timeHasLOSToPlayer = (hasLOSToPlayer ? (timeHasLOSToPlayer + Time.deltaTime) : 0f);
				timeHasLOSToTargetPlayer = (hasLOSToTargetPlayer ? (timeHasLOSToTargetPlayer + Time.deltaTime) : 0f);
				timeTargetPlayerHasLOS = (targetPlayerHasLOS ? (timeTargetPlayerHasLOS + Time.deltaTime) : 0f);
				if (scareCooldown > 0f)
				{
					scareCooldown -= Time.deltaTime;
				}
				if (tapeRefusalCooldown > 0f)
				{
					tapeRefusalCooldown -= Time.deltaTime;
				}
				else
				{
					refusedTape = false;
				}
				if (closestPlayerDistance <= 7.5f && (Object)(object)closestPlayer != (Object)(object)targetPlayer)
				{
					timePlayerFollowing += Time.deltaTime;
				}
				else
				{
					timePlayerFollowing = 0f;
				}
			}
		}

		public void LateUpdate()
		{
			//IL_01b4: 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_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_004b: 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_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: 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_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: 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_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			MimicEnemyUpdate();
			if (((NetworkBehaviour)this).IsServer)
			{
				if (facePlayer)
				{
					if ((Object)(object)targetPlayer != (Object)null)
					{
						turnCompass.LookAt(((Component)targetPlayer.gameplayCamera).transform.position);
						((Component)this).transform.rotation = Quaternion.Lerp(((Component)this).transform.rotation, Quaternion.Euler(new Vector3(0f, turnCompass.eulerAngles.y, 0f)), turnCompassSpeed * Time.deltaTime);
					}
					else if ((Object)(object)closestPlayer != (Object)null)
					{
						turnCompass.LookAt(((Component)closestPlayer.gameplayCamera).transform.position);
						((Component)this).transform.rotation = Quaternion.Lerp(((Component)this).transform.rotation, Quaternion.Euler(new Vector3(0f, turnCompass.eulerAngles.y, 0f)), turnCompassSpeed * Time.deltaTime);
					}
				}
				if (faceEnemy && (Object)(object)seenEnemy != (Object)null)
				{
					turnCompass.LookAt(seenEnemy.eye.position);
					((Component)this).transform.rotation = Quaternion.Lerp(((Component)this).transform.rotation, Quaternion.Euler(new Vector3(0f, turnCompass.eulerAngles.y, 0f)), turnCompassSpeed * Time.deltaTime);
				}
			}
			Vector3 val = ((Component)this).transform.position - lastPosition;
			currentSpeed = ((Vector3)(ref val)).magnitude / Time.deltaTime / 2f;
			base.creatureAnimator.SetFloat(hashSpeed, currentSpeed);
			lastPosition = ((Component)this).transform.position;
			idleTime = ((currentSpeed > 0.1f) ? 0f : (idleTime + Time.deltaTime));
			tapeTriggerCollider.enabled = currentSpeed < 0.1f && base.currentBehaviourStateIndex == 5;
		}

		public void MimicEnemyUpdate()
		{
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)mimicEnemy != (Object)null && ((Behaviour)mimicEnemy).enabled && (Object)(object)mimicEnemy.agent != (Object)null && ((Behaviour)mimicEnemy.agent).enabled)
			{
				mimicEnemy.agent.obstacleAvoidanceType = (ObstacleAvoidanceType)0;
				mimicEnemy.agent.speed = base.agent.speed;
				mimicEnemy.agent.angularSpeed = base.agent.angularSpeed;
				mimicEnemy.agent.acceleration = base.agent.acceleration;
				mimicEnemy.agent.stoppingDistance = base.agent.stoppingDistance;
				mimicEnemy.movingTowardsTargetPlayer = false;
				mimicEnemy.SetDestinationToPosition(((Component)this).transform.position, false);
			}
		}

		public override void DoAIInterval()
		{
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: 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_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_094d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b86: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b8b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b93: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b98: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aad: Unknown result type (might be due to invalid IL or missing references)
			//IL_0abc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c4b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b53: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b04: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b1f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0342: Unknown result type (might be due to invalid IL or missing references)
			//IL_048d: Unknown result type (might be due to invalid IL or missing references)
			if (base.currentBehaviourStateIndex == 3 && (Object)(object)targetPlayer != (Object)null && (Object)(object)Plugin.localPlayer == (Object)(object)targetPlayer)
			{
				if (targetPlayer.isSprinting && !triggeredActions.Contains("Run"))
				{
					Plugin.logger.LogDebug((object)"Running on client reaction triggered");
					TriggerReaction("Run");
					TriggerReactionServerRpc("Run");
				}
				if (targetPlayer.isJumping && !triggeredActions.Contains("Jump"))
				{
					Plugin.logger.LogDebug((object)"Jumping on client reaction triggered");
					TriggerReaction("Jump");
					TriggerReactionServerRpc("Jump");
				}
			}
			if (!((NetworkBehaviour)this).IsServer)
			{
				return;
			}
			targetPlayerHasLOS = (Object)(object)targetPlayer != (Object)null && targetPlayer.HasLineOfSightToPosition(((Component)this).transform.position + Vector3.up * 2f, 45f, 60, -1f);
			hasLOSToTargetPlayer = (Object)(object)targetPlayer != (Object)null && HasLineOfSightToPlayer(targetPlayer);
			targetPlayerDistance = (((Object)(object)targetPlayer != (Object)null) ? Vector3.Distance(((Component)this).transform.position, ((Component)targetPlayer).transform.position) : (-1f));
			closestPlayer = GetClosestPlayer();
			closestVisiblePlayer = GetClosestPlayer(requireLineOfSight: true);
			closestPlayerDistance = (((Object)(object)closestPlayer != (Object)null) ? Vector3.Distance(((Component)closestPlayer).transform.position, ((Component)this).transform.position) : (-1f));
			closestPlayerVisibleTo = GetClosestPlayerVisibleTo();
			if (playerHasLOS)
			{
				timeSinceLastSeen = 0f;
			}
			UpdateTestingHUD();
			switch (base.currentBehaviourStateIndex)
			{
			case 0:
				base.agent.speed = 5f;
				if ((Object)(object)heldTape != (Object)null && CanWatchTV() && timeSinceSwitchBehavior > 10f)
				{
					SwitchToBehaviourClientRpc(6);
					break;
				}
				CheckForPlayerWithTape();
				if (!waved && inLOSWithPlayer && closestPlayerDistance < 5f)
				{
					waved = true;
					base.inSpecialAnimation = true;
					facePlayer = true;
					DoAnimationClientRpc("wave");
					AddOffsetToScareCooldown(-10f);
					break;
				}
				if (scareCooldown <= 0f && !playerHasLOS)
				{
					targetPlayer = Utils.GetRandomPlayer();
					if ((Object)(object)targetPlayer != (Object)null && SmartCanPathToPoint(((Component)targetPlayer).transform.position))
					{
						currentScareDef = GetWeightedRandomScare();
						PlayRandomClipClientRpc(AudioArray.Sneaking, targetPlayer.actualClientId);
						SwitchToBehaviourClientRpc(1);
						break;
					}
				}
				if (timeSinceLearnScare > 5f)
				{
					GameObject val2 = ((EnemyAI)this).CheckLineOfSight(GetLearnableEnemies(), 45f, 60, -1f, (Transform)null, (int[])null);
					if ((Object)(object)val2 != (Object)null && val2.TryGetComponent<EnemyAI>(ref seenEnemy))
					{
						timeSinceLearnScare = 0f;
						ScareDef scareDef = scareDefs.Where((ScareDef x) => x.enemyTypeName == ((Object)seenEnemy.enemyType).name).FirstOrDefault();
						if ((Object)(object)scareDef == (Object)null)
						{
							break;
						}
						AddScarePoint(scareDef);
						faceEnemy = true;
						LearnScareClientRpc(scareDef.enemyTypeName);
						AddOffsetToScareCooldown(-20f);
					}
				}
				if (HasReachedTargetNode())
				{
					GameObject? randomNode = Utils.GetRandomNode(ignoredNodes.ToArray());
					base.targetNode = ((randomNode != null) ? randomNode.transform : null);
				}
				if ((Object)(object)base.targetNode != (Object)null && !SetDestinationToPosition(base.targetNode.position))
				{
					ignoredNodes.Add(((Component)base.targetNode).gameObject);
					base.targetNode = null;
				}
				else if (timeSinceLastVoiceLine > 20f)
				{
					timeSinceLastVoiceLine = 0f;
					PlayRandomClipClientRpc(AudioArray.Roaming);
				}
				break;
			case 1:
				facePlayer = true;
				if ((Object)(object)targetPlayer == (Object)null || !targetPlayer.isPlayerControlled)
				{
					targetPlayer = Utils.GetRandomPlayer();
					break;
				}
				if (timeTargetPlayerHasLOS > 1f && targetPlayerDistance < 15f)
				{
					Plugin.logger.LogDebug((object)"Spotted by target player");
					AddOffsetToScareCooldown(30f);
					SpottedClientRpc(AudioArray.SeenSneaking);
					break;
				}
				if (timeSinceSwitchBehavior > 10f && timeHasLOSToTargetPlayer > 3f && targetPlayerDistance <= 10f)
				{
					Plugin.logger.LogDebug((object)"Starting scare");
					SpawnMimicEnemy();
					SwitchToBehaviourClientRpc(2);
					break;
				}
				if (!annoyedByFollowingPlayer && timePlayerFollowing > 5f)
				{
					annoyedByFollowingPlayer = true;
					PlayRandomClipClientRpc(AudioArray.PlayerFollowing, targetPlayer.actualClientId, 0.5f);
				}
				SneakTargetPlayer();
				break;
			case 2:
				base.agent.speed = 5f;
				base.agent.stoppingDistance = 15f;
				facePlayer = true;
				if ((Object)(object)targetPlayer == (Object)null || !targetPlayer.isPlayerControlled)
				{
					DespawnMimicEnemy();
					SwitchToBehaviourClientRpc(0);
				}
				else if (targetPlayerHasLOS)
				{
					int scareSFXIndex = (((Object)(object)currentScareDef != (Object)null && currentScareDef.enemyTypeName != "") ? Random.Range(0, currentScareDef.scareSFX.Length) : Random.Range(0, scareSFX.Length));
					triggeredActions.Clear();
					score = 0;
					ScareClientRpc(scareSFXIndex, targetPlayer.actualClientId);
				}
				else if (targetPlayerDistance > 15f || timeSinceSwitchBehavior > 15f)
				{
					DespawnMimicEnemy();
					SwitchToBehaviourClientRpc(1);
				}
				break;
			case 3:
				base.agent.speed = 0f;
				facePlayer = true;
				if ((Object)(object)targetPlayer == (Object)null || (Object)(object)currentScareDef == (Object)null || !targetPlayer.isPlayerControlled)
				{
					SwitchToBehaviourClientRpc(4);
					break;
				}
				if (timeSinceSwitchBehavior > 1f)
				{
					TrackCameraMovement();
					if (!triggeredActions.Contains("NoLineOfSight") && !hasLOSToTargetPlayer)
					{
						TriggerReaction("NoLineOfSight");
					}
				}
				if (timeSinceSwitchBehavior - 1f > currentScareDef.animTime + 5f)
				{
					DespawnMimicEnemy();
					if (score >= 5)
					{
						AddScarePoint(currentScareDef);
						base.inSpecialAnimation = true;
						DoAnimationClientRpc("laugh");
						AddOffsetToScareCooldown(60f);
					}
					else
					{
						RemoveScarePoint(currentScareDef);
						PlayRandomClipClientRpc(AudioArray.ReactionFailed);
						AddOffsetToScareCooldown(30f);
					}
					SwitchToBehaviourClientRpc(4);
				}
				break;
			case 4:
				base.agent.speed = 8f;
				if ((timeSinceLastSeen > 10f && timeSinceSwitchBehavior > 10f) || (Object)(object)closestPlayer == (Object)null)
				{
					SwitchToBehaviourClientRpc(0);
					break;
				}
				CheckForPlayerWithTape();
				AvoidPlayer(closestPlayer);
				break;
			case 5:
			{
				base.agent.speed = 5f;
				base.agent.stoppingDistance = 5f;
				facePlayer = true;
				if (timeSinceSwitchBehavior > 15f || !GetClosestPlayerWithTape(10f, out PlayerControllerB playerWithTape) || !SetDestinationToPosition(((Component)playerWithTape).transform.position))
				{
					tapeRefusalCooldown = 15f;
					refusedTape = true;
					SwitchToBehaviourClientRpc(4);
				}
				break;
			}
			case 6:
			{
				base.agent.speed = 5f;
				if (watchingTV)
				{
					if ((Object)(object)TVSetUnlockable.Instance == (Object)null || (Object)(object)TVSetUnlockable.Instance.tapeInVHS == (Object)null)
					{
						watchingTV = false;
						((Behaviour)base.agent).enabled = true;
						RepositionAgent();
						TVSetUnlockable.Instance?.SetTVSetInUseClientRpc(value: false);
						SwitchToBehaviourClientRpc(4);
					}
					else if (timeSinceStartResting > 60f)
					{
						AddScarePoint(TVSetUnlockable.Instance.tapeInVHS.currentScareDef);
						watchingTV = false;
						((Behaviour)base.agent).enabled = true;
						RepositionAgent();
						TVSetUnlockable.Instance.SetTVSetInUseClientRpc(value: false);
						SwitchToBehaviourClientRpc(4);
						AddOffsetToScareCooldown(60f);
					}
					break;
				}
				if (!CanWatchTV())
				{
					SwitchToBehaviourClientRpc(0);
					break;
				}
				if ((Object)(object)TVSetUnlockable.Instance != (Object)null)
				{
					if (Vector3.Distance(((Component)this).transform.position, ((Component)TVSetUnlockable.Instance).transform.position) < 1f)
					{
						base.moveTowardsDestination = false;
						base.agent.ResetPath();
						((Behaviour)base.agent).enabled = false;
						((Component)this).transform.position = TVSetUnlockable.Instance.sitPositonSCP2006.position;
						((Component)this).transform.rotation = TVSetUnlockable.Instance.sitPositonSCP2006.rotation;
						WatchTapeClientRpc();
						watchingTV = true;
						timeSinceStartResting = 0f;
					}
					else if (!SetDestinationToPosition(((Component)TVSetUnlockable.Instance).transform.position))
					{
						SwitchToBehaviourClientRpc(0);
					}
					break;
				}
				Vector3 position = ((Component)terminalScript).transform.position;
				if (Vector3.Distance(((Component)this).transform.position, position) < 3f)
				{
					base.agent.ResetPath();
					UnlockableItem val = StartOfRound.Instance.unlockablesList.unlockables.Where((UnlockableItem x) => x.unlockableName == "TVSet").First();
					int num = StartOfRound.Instance.unlockablesList.unlockables.IndexOf(val);
					if (val.alreadyUnlocked || val.hasBeenUnlockedByPlayer)
					{
						StartOfRound.Instance.SpawnUnlockable(num, true);
					}
					else
					{
						StartOfRound.Instance.UnlockShipObject(num);
					}
				}
				else if (!SetDestinationToPosition(position))
				{
					SwitchToBehaviourClientRpc(0);
				}
				break;
			}
			default:
				Plugin.logger.LogWarning((object)("Invalid state: " + base.currentBehaviourStateIndex));
				break;
			}
		}

		private void UpdateTestingHUD()
		{
			if (Utils.isBeta && (Object)(object)TestingHUDOverlay.Instance != (Object)null)
			{
				TestingHUDOverlay.Instance.label1.text = "ScareCooldown: " + scareCooldown;
				Text label = TestingHUDOverlay.Instance.label2;
				State currentBehaviourStateIndex = (State)base.currentBehaviourStateIndex;
				label.text = currentBehaviourStateIndex.ToString();
				TestingHUDOverlay.Instance.label3.text = "ClosestPlayer: " + closestPlayer?.playerUsername;
				TestingHUDOverlay.Instance.toggle1.isOn = isOutside;
				TestingHUDOverlay.Instance.toggle1Label.text = "isOutside";
				TestingHUDOverlay.Instance.toggle2.isOn = base.inSpecialAnimation;
				TestingHUDOverlay.Instance.toggle2Label.text = "inSpecialAnimation";
			}
		}

		private void OnUseEntranceTeleport(bool setOutside)
		{
			Plugin.logger.LogDebug((object)("EntranceTeleport used. isOutside = " + setOutside));
		}

		private void OnEnableOrDisableAgent(bool agentEnabled)
		{
			Plugin.logger.LogDebug((object)("Agent enabled = " + agentEnabled));
		}

		public PlayerControllerB? GetClosestPlayer(bool requireLineOfSight = false)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB result = null;
			float num = float.PositiveInfinity;
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if (PlayerIsTargetable(val) && (!requireLineOfSight || !Physics.Linecast(((Component)this).transform.position + Vector3.up * 2f, ((Component)val).transform.position, 256)))
				{
					float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position);
					if (num2 < num)
					{
						num = num2;
						result = val;
					}
				}
			}
			return result;
		}

		public bool SetDestinationToPosition(Vector3 position)
		{
			//IL_0006: 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_0017: 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_001f: 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)
			position = RoundManager.Instance.GetNavMeshPosition(position, RoundManager.Instance.navHit, 5f, -1);
			if (!SmartCanPathToPoint(position))
			{
				return false;
			}
			return nav.DoPathingToDestination(position);
		}

		public bool SmartCanPathToPoint(Vector3 position)
		{
			//IL_000c: 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_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: 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_0104: 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: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: 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_0127: 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_013d: Unknown result type (might be due to invalid IL or missing references)
			Vector3 navMeshPosition = RoundManager.Instance.GetNavMeshPosition(((Component)this).transform.position, RoundManager.Instance.navHit, 5f, -1);
			position = RoundManager.Instance.GetNavMeshPosition(position, RoundManager.Instance.navHit, 5f, -1);
			if (nav.CanPathToPoint(navMeshPosition, position) > 0f)
			{
				return true;
			}
			foreach (EntranceTeleport entrance in entrances)
			{
				if (!(isInsideFactory ? (!entrance.isEntranceToBuilding) : entrance.isEntranceToBuilding))
				{
					continue;
				}
				Vector3 navMeshPosition2 = RoundManager.Instance.GetNavMeshPosition(entrance.entrancePoint.position, RoundManager.Instance.navHit, 5f, -1);
				if (!((Object)(object)entrance.exitPoint == (Object)null) || entrance.FindExitPoint())
				{
					Vector3 navMeshPosition3 = RoundManager.Instance.GetNavMeshPosition(entrance.exitPoint.position, RoundManager.Instance.navHit, 5f, -1);
					if (nav.CanPathToPoint(navMeshPosition, navMeshPosition2) > 0f && nav.CanPathToPoint(navMeshPosition3, position) > 0f)
					{
						return true;
					}
				}
			}
			return false;
		}

		private void RepositionAgent()
		{
			//IL_000c: 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_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			Vector3 navMeshPosition = RoundManager.Instance.GetNavMeshPosition(((Component)this).transform.position, RoundManager.Instance.navHit, 5f, -1);
			base.agent.Warp(navMeshPosition);
		}

		private Vector3 GetPointOnPathTowardsPlayer(Vector3 enemyPos, Vector3 playerPos, float offsetFromPlayer)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0007: 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_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: 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_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			NavMeshPath val = new NavMeshPath();
			if (!NavMesh.CalculatePath(enemyPos, playerPos, -1, val))
			{
				return playerPos;
			}
			float num = 0f;
			for (int i = 0; i < val.corners.Length - 1; i++)
			{
				num += Vector3.Distance(val.corners[i], val.corners[i + 1]);
			}
			float num2 = Mathf.Max(0f, num - offsetFromPlayer);
			float num3 = 0f;
			for (int j = 0; j < val.corners.Length - 1; j++)
			{
				float num4 = Vector3.Distance(val.corners[j], val.corners[j + 1]);
				if (num3 + num4 >= num2)
				{
					float num5 = num2 - num3;
					float num6 = num5 / num4;
					return Vector3.Lerp(val.corners[j], val.corners[j + 1], num6);
				}
				num3 += num4;
			}
			return playerPos;
		}

		private void CheckForPlayerWithTape()
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)heldTape == (Object)null && !refusedTape && CanWatchTV() && GetClosestPlayerWithTape(10f, out PlayerControllerB playerWithTape) && (Object)(object)playerWithTape != (Object)null && SetDestinationToPosition(((Component)playerWithTape).transform.position))
			{
				targetPlayer = playerWithTape;
				SwitchToBehaviourClientRpc(5);
			}
		}

		public void AvoidPlayer(PlayerControllerB playerToAvoid)
		{
			//IL_0022: 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)
			GameObject farthestGameObjectFromPosition = Utils.insideAINodes.Where((GameObject x) => !ignoredNodes.Contains(x)).ToList().GetFarthestGameObjectFromPosition(((Component)playerToAvoid).transform.position);
			if ((Object)(object)farthestGameObjectFromPosition == (Object)null)
			{
				Plugin.logger.LogDebug((object)"Farthest node is null in AvoidPlayer");
			}
			else if (!SetDestinationToPosition(farthestGameObjectFromPosition.transform.position))
			{
				ignoredNodes.Add(farthestGameObjectFromPosition);
			}
		}

		private void SneakTargetPlayer()
		{
			//IL_00c6: 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_00e0: 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_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: 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_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)targetPlayer == (Object)null)
			{
				return;
			}
			nav.AdjustSpeedBasedOnDistance(base.agent.stoppingDistance, 15f, 8f, 15f, 1f);
			if (isOutside)
			{
				if (ShouldStopBecauseClose())
				{
					nav.StopAgent();
				}
				else
				{
					SetDestinationToPosition(((Component)targetPlayer).transform.position);
				}
				return;
			}
			if (targetPlayer.isInsideFactory != isInsideFactory)
			{
				SetDestinationToPosition(((Component)targetPlayer).transform.position);
				return;
			}
			Vector3 val = GetPointOnPathTowardsPlayer(((Component)this).transform.position, ((Component)targetPlayer).transform.position, 3f) + Vector3.up * 2f;
			if (!targetPlayer.HasLineOfSightToPosition(val, 45f, 60, -1f))
			{
				if (ShouldStopBecauseClose())
				{
					nav.StopAgent();
				}
				else
				{
					SetDestinationToPosition(((Component)targetPlayer).transform.position);
				}
				return;
			}
			base.agent.speed = 15f;
			if (!targetPlayerHasLOS)
			{
				nav.StopAgent();
			}
			else
			{
				AvoidPlayer(targetPlayer);
			}
			bool ShouldStopBecauseClose()
			{
				return hasLOSToTargetPlayer && targetPlayerDistance < 9f;
			}
		}

		public PlayerControllerB? GetClosestPlayerVisibleTo()
		{
			//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_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_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB result = null;
			float num = float.PositiveInfinity;
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if (PlayerIsTargetable(val))
				{
					float num2 = Vector3.Distance(((Component)val).transform.position, ((Component)this).transform.position);
					if (!(num2 > num) && val.HasLineOfSightToPosition(((Component)this).transform.position + Vector3.up * 2f, 45f, 60, -1f))
					{
						num = num2;
						result = val;
					}
				}
			}
			return result;
		}

		private void AddOffsetToScareCooldown(float offset)
		{
			scareCooldown += offset;
			scareCooldown = Mathf.Min(scareCooldown, 60f);
		}

		private List<GameObject> GetLearnableEnemies()
		{
			List<GameObject> list = new List<GameObject>();
			foreach (EnemyAI enemy in RoundManager.Instance.SpawnedEnemies)
			{
				ScareDef scareDef = scareDefs.FirstOrDefault((ScareDef x) => x.enemyTypeName == ((Object)enemy.enemyType).name);
				if (!((Object)(object)scareDef == (Object)null) && !learnedScares.ContainsKey(scareDef))
				{
					list.Add(((Component)enemy).gameObject);
				}
			}
			return list;
		}

		public bool CanWatchTV()
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: 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 ((Object)(object)TVSetUnlockable.Instance != (Object)null && TVSetUnlockable.Instance.inUse)
			{
				return false;
			}
			TVSetUnlockable? instance = TVSetUnlockable.Instance;
			Vector3 position = ((instance != null) ? ((Component)instance).transform.position : ((Component)terminalScript).transform.position);
			return SmartCanPathToPoint(position);
		}

		private bool GetClosestPlayerWithTape(float distance, out PlayerControllerB? playerWithTape)
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			playerWithTape = null;
			float num = distance;
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if (!((Object)(object)val == (Object)null) && PlayerIsTargetable(val) && val.currentlyHeldObjectServer is VHSTapeBehavior)
				{
					float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position);
					if (!(num2 > num))
					{
						playerWithTape = val;
						num = num2;
					}
				}
			}
			return (Object)(object)playerWithTape != (Object)null;
		}

		public void TriggerReaction(string actionName)
		{
			if (!triggeredActions.Contains(actionName))
			{
				triggeredActions.Add(actionName);
				if (points.TryGetValue(actionName, out var value))
				{
					score += value;
				}
				Plugin.logger.LogDebug((object)$"Triggered {actionName}: +{points[actionName]} (total {score})");
			}
		}

		private void AddScarePoint(ScareDef scareDef)
		{
			if (!((Object)(object)scareDef == (Object)null))
			{
				if (!learnedScares.ContainsKey(scareDef))
				{
					learnedScares.Add(scareDef, 0);
				}
				learnedScares[scareDef]++;
				Plugin.logger.LogDebug((object)("Added scare point for: " + (object)scareDef));
			}
		}

		private void RemoveScarePoint(ScareDef scareDef)
		{
			if (learnedScares.ContainsKey(scareDef))
			{
				learnedScares[scareDef]--;
				if (learnedScares[scareDef] < 1)
				{
					learnedScares.Remove(scareDef);
				}
				Plugin.logger.LogDebug((object)("Removed scare point for: " + (object)scareDef));
			}
		}

		private ScareDef GetWeightedRandomScare()
		{
			if (Utils.testing && DEBUG_scareIndex >= 0)
			{
				return scareDefs[DEBUG_scareIndex];
			}
			Dictionary<ScareDef, int> dictionary = learnedScares.Where<KeyValuePair<ScareDef, int>>((KeyValuePair<ScareDef, int> x) => x.Key.enemyTypeName == "" || x.Key.outside == isOutside).ToDictionary((KeyValuePair<ScareDef, int> x) => x.Key, (KeyValuePair<ScareDef, int> x) => x.Value);
			ScareDef[] array = dictionary.Keys.ToArray();
			int[] weights = dictionary.Values.ToArray();
			int randomWeightedIndex = GetRandomWeightedIndex(weights);
			return array[randomWeightedIndex];
		}

		public int GetRandomWeightedIndex(int[] weights)
		{
			if (weights == null || weights.Length == 0)
			{
				Plugin.logger.LogDebug((object)"Could not get random weighted index; array is empty or null.");
				return -1;
			}
			int num = 0;
			for (int i = 0; i < weights.Length; i++)
			{
				if (weights[i] >= 0)
				{
					num += weights[i];
				}
			}
			if (num <= 0)
			{
				return Random.Range(0, weights.Length);
			}
			float num2 = Random.Range(0f, 1f);
			float num3 = 0f;
			for (int j = 0; j < weights.Length; j++)
			{
				if (!((float)weights[j] <= 0f))
				{
					num3 += (float)weights[j] / (float)num;
					if (num3 >= num2)
					{
						return j;
					}
				}
			}
			Plugin.logger.LogError((object)"Error while calculating random weighted index. Choosing randomly. Weights given:");
			for (int k = 0; k < weights.Length; k++)
			{
				Plugin.logger.LogError((object)$"{weights[k]},");
			}
			return Random.Range(0, weights.Length);
		}

		private bool HasReachedTargetNode()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)base.targetNode == (Object)null)
			{
				return true;
			}
			return Vector3.Distance(((Component)this).transform.position, base.targetNode.position) < 1f;
		}

		private bool HasLineOfSightToPlayer(PlayerControllerB player, float width = 45f, int range = 20, int proximityAwareness = -1)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Invalid comparison between Unknown and I4
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			if (isOutside && !base.enemyType.canSeeThroughFog && (int)TimeOfDay.Instance.currentLevelWeather == 3)
			{
				range = Mathf.Clamp(range, 0, 30);
			}
			Vector3 position = ((Component)player.gameplayCamera).transform.position;
			if (Vector3.Distance(position, base.eye.position) < (float)range && !Physics.Linecast(base.eye.position, position, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1))
			{
				Vector3 val = position - base.eye.position;
				if (Vector3.Angle(base.eye.forward, val) < width || (proximityAwareness != -1 && Vector3.Distance(base.eye.position, position) < (float)proximityAwareness))
				{
					return true;
				}
			}
			return false;
		}

		public override void DetectNoise(Vector3 noisePosition, float noiseLoudness, int timesPlayedInOneSpot = 0, int noiseID = 0)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).DetectNoise(noisePosition, noiseLoudness, timesPlayedInOneSpot, noiseID);
			if (base.currentBehaviourStateIndex == 3 && (Object)(object)targetPlayer != (Object)null && noiseLoudness >= 0.9f && noiseID == 75 && Vector3.Distance(((Component)targetPlayer).transform.position, noisePosition) < 1f)
			{
				TriggerReaction("Yell");
			}
		}

		private void TrackCameraMovement()
		{
			//IL_002f: 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_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			if (!triggeredActions.Contains("CameraTurn"))
			{
				Vector2 val = default(Vector2);
				((Vector2)(ref val))..ctor(((Component)targetPlayer.gameplayCamera).transform.eulerAngles.x, ((Component)targetPlayer.gameplayCamera).transform.eulerAngles.y);
				float num = Mathf.DeltaAngle(lastCameraAngles.x, val.x);
				float num2 = Mathf.DeltaAngle(lastCameraAngles.y, val.y);
				Vector2 val2 = new Vector2(num, num2);
				float num3 = ((Vector2)(ref val2)).magnitude / Time.deltaTime;
				lastCameraAngles = val;
				if (num3 > 1000f && timeSinceSwitchBehavior > 1f)
				{
					TriggerReaction("CameraTurn");
				}
			}
		}

		public bool PlayerIsTargetable(PlayerControllerB playerScript)
		{
			if ((Object)(object)playerScript != (Object)null && playerScript.isPlayerControlled && !playerScript.isPlayerDead && (Object)(object)playerScript.inAnimationWithEnemy == (Object)null && playerScript.sinkingValue < 0.73f)
			{
				return true;
			}
			return false;
		}

		private void GetCurrentMaterialStandingOn()
		{
			//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)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			Ray val = default(Ray);
			((Ray)(ref val))..ctor(((Component)this).transform.position + Vector3.up, -Vector3.up);
			RaycastHit val2 = default(RaycastHit);
			if (!Physics.Raycast(val, ref val2, 6f, StartOfRound.Instance.walkableSurfacesMask, (QueryTriggerInteraction)1) || ((Component)((RaycastHit)(ref val2)).collider).CompareTag(StartOfRound.Instance.footstepSurfaces[currentFootstepSurfaceIndex].surfaceTag))
			{
				return;
			}
			for (int i = 0; i < StartOfRound.Instance.footstepSurfaces.Length; i++)
			{
				if (((Component)((RaycastHit)(ref val2)).collider).CompareTag(StartOfRound.Instance.footstepSurfaces[i].surfaceTag))
				{
					currentFootstepSurfaceIndex = i;
					break;
				}
			}
		}

		public override void HitEnemy(int force = 0, PlayerControllerB? playerWhoHit = null, bool playHitSFX = true, int hitID = -1)
		{
			Plugin.logger.LogDebug((object)"In HitEnemy()");
			if (base.currentBehaviourStateIndex == 3)
			{
				TriggerReaction("Attack");
			}
			else
			{
				if (timeSinceLastHit < 3f || base.currentBehaviourStateIndex == 6)
				{
					return;
				}
				timeSinceLastHit = 0f;
				base.inSpecialAnimation = true;
				Plugin.logger.LogDebug((object)"DoAnimation: spotted");
				base.creatureAnimator.SetTrigger("spotted");
				PlayRandomClipOnLocalClient(AudioArray.Hit);
				if (((NetworkBehaviour)this).IsServer)
				{
					targetPlayer = null;
					if (base.currentBehaviourStateIndex != 4)
					{
						SwitchToBehaviourClientRpc(4);
					}
				}
			}
		}

		public void SetInSpecialAnimationFalse()
		{
			Plugin.logger.LogDebug((object)"inSpecialAnimation false");
			base.inSpecialAnimation = false;
		}

		public void PlayFootstepSFX()
		{
			if (base.currentBehaviourStateIndex != 1)
			{
				GetCurrentMaterialStandingOn();
				int num = Random.Range(0, StartOfRound.Instance.footstepSurfaces[currentFootstepSurfaceIndex].clips.Length);
				if (num == previousFootstepClip)
				{
					num = (num + 1) % StartOfRound.Instance.footstepSurfaces[currentFootstepSurfaceIndex].clips.Length;
				}
				base.creatureSFX.pitch = Random.Range(0.93f, 1.07f);
				base.creatureSFX.PlayOneShot(StartOfRound.Instance.footstepSurfaces[currentFootstepSurfaceIndex].clips[num], 0.6f);
				previousFootstepClip = num;
			}
		}

		public void PlayLaughSFX()
		{
			Plugin.logger.LogDebug((object)"PlayLaughSFX");
			base.creatureVoice.PlayOneShot(laughSFX);
		}

		public void FinishLaughAnimation()
		{
			Plugin.logger.LogDebug((object)"FinishLaughAnimation called");
			base.inSpecialAnimation = false;
			PlayRandomClipOnLocalClient(AudioArray.ReactionSuccess);
		}

		public void FinishWaveAnimation()
		{
			Plugin.logger.LogDebug((object)"FinishWaveAnimation called");
			base.inSpecialAnimation = false;
			facePlayer = false;
		}

		public void FinishThinkAnimation()
		{
			Plugin.logger.LogDebug((object)"FinishThinkAnimation called");
			base.inSpecialAnimation = false;
			faceEnemy = false;
		}

		public void GiveTape()
		{
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			GrabbableObject currentlyHeldObjectServer = Plugin.localPlayer.currentlyHeldObjectServer;
			if (!((Object)(object)currentlyHeldObjectServer == (Object)null) && ((NetworkBehaviour)currentlyHeldObjectServer).NetworkObject.IsSpawned)
			{
				if (((Object)currentlyHeldObjectServer.itemProperties).name == "EasterEgg")
				{
					TriggerEasterEggServerRpc();
				}
				else if (currentlyHeldObjectServer is VHSTapeBehavior)
				{
					Plugin.logger.LogDebug((object)"Giving tape to SCP-2006");
					Plugin.localPlayer.DiscardHeldObject(false, (NetworkObject)null, default(Vector3), true);
					GiveTapeServerRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)currentlyHeldObjectServer).NetworkObject));
				}
			}
		}

		public void SpawnMimicEnemy()
		{
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)mimicEnemy != (Object)null)
			{
				return;
			}
			if ((Object)(object)currentScareDef == (Object)null || currentScareDef.enemyTypeName == "")
			{
				SetDefaultScareClientRpc(Random.Range(0, baitSFX.Length));
				return;
			}
			SpawnableEnemyWithRarity val = (from x in Utils.GetEnemies()
				where ((Object)x.enemyType).name == currentScareDef.enemyTypeName
				select x).First();
			GameObject enemyPrefab = val.enemyType.enemyPrefab;
			GameObject val2 = Object.Instantiate<GameObject>(enemyPrefab, ((Component)this).transform.position, ((Component)this).transform.rotation, ((Component)this).transform);
			val2.GetComponent<NetworkObject>().Spawn(true);
			mimicEnemy = val2.GetComponent<EnemyAI>();
			SpawnMimicEnemyClientRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)mimicEnemy).NetworkObject), Random.Range(0, currentScareDef.baitSFX.Length));
		}

		public void DespawnMimicEnemy()
		{
			if (!((Object)(object)mimicEnemy == (Object)null) && ((NetworkBehaviour)mimicEnemy).NetworkObject.IsSpawned)
			{
				Plugin.logger.LogDebug((object)("Despawning mimic enemy " + ((Object)mimicEnemy.enemyType).name));
				((NetworkBehaviour)mimicEnemy).NetworkObject.Despawn(true);
				mimicEnemy = null;
				((EnemyAI)this).EnableEnemyMesh(true, false);
				DespawnMimicEnemyClientRpc();
			}
		}

		public void DropTapeOnLocalClient(Vector3 position)
		{
			//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_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)heldTape == (Object)null))
			{
				GrabbableObject val = (GrabbableObject)(object)heldTape;
				val.parentObject = null;
				((Component)val).transform.SetParent(StartOfRound.Instance.propsContainer, true);
				val.EnablePhysics(true);
				val.fallTime = 0f;
				val.startFallingPosition = ((Component)val).transform.parent.InverseTransformPoint(((Component)val).transform.position);
				val.targetFloorPosition = ((Component)val).transform.parent.InverseTransformPoint(position);
				val.floorYRot = -1;
				val.DiscardItemFromEnemy();
				val.isHeldByEnemy = false;
				HoarderBugAI.grabbableObjectsInMap.Add(((Component)val).gameObject);
				heldTape = null;
			}
		}

		public void OnRestingInterupted()
		{
			if (watchingTV && ((NetworkBehaviour)this).IsServer)
			{
				watchingTV = false;
				((Behaviour)base.agent).enabled = true;
				RepositionAgent();
				TVSetUnlockable.Instance?.SetTVSetInUseClientRpc(value: false);
				SwitchToBehaviourClientRpc(4);
			}
		}

		public void OnPlayerDeath(ulong clientId)
		{
			if (((NetworkBehaviour)this).IsServer)
			{
				scareManager.StopScare();
				SpottedClientRpc(AudioArray.PlayerKilledReaction);
			}
		}

		public void SwitchToBehaviourStateOnLocalClient(int stateIndex)
		{
			if (base.currentBehaviourStateIndex != stateIndex)
			{
				ManualLogSource logger = Plugin.logger;
				State state = (State)stateIndex;
				logger.LogDebug((object)("Switching behavior to " + state));
				base.previousBehaviourStateIndex = base.currentBehaviourStateIndex;
				base.currentBehaviourStateIndex = stateIndex;
				base.currentBehaviourState = base.enemyBehaviourStates[stateIndex];
				((EnemyAI)this).PlayAudioOfCurrentState();
				((EnemyAI)this).PlayAnimationOfCurrentState();
				timeSinceSwitchBehavior = 0f;
				base.creatureAnimator.SetBool("sneaking", base.currentBehaviourStateIndex == 1);
				base.creatureAnimator.SetBool("wanting", base.currentBehaviourStateIndex == 5);
				base.creatureAnimator.SetBool("running", base.currentBehaviourStateIndex == 4);
				BehaviourSwitchCleanUp();
			}
		}

		public void BehaviourSwitchCleanUp()
		{
			facePlayer = false;
			faceEnemy = false;
			spottedByOtherPlayer = false;
			ignoredNodes.Clear();
			waved = false;
			annoyedByFollowingPlayer = false;
			if (((NetworkBehaviour)this).IsServer)
			{
				((Behaviour)base.agent).enabled = true;
				base.agent.stoppingDistance = 0f;
			}
		}

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

		[ClientRpc]
		public void WatchTapeClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(46715836u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 46715836u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			if (!((Object)(object)heldTape == (Object)null) && !((Object)(object)TVSetUnlockable.Instance == (Object)null))
			{
				VHSTapeBehavior tape = heldTape;
				Plugin.logger.LogDebug((object)"DoAnimation: rest");
				base.creatureAnimator.SetTrigger("rest");
				PlayRandomClipOnLocalClient(AudioArray.WatchingTape);
				if (Object.op_Implicit((Object)(object)TVSetUnlockable.Instance.tapeInVHS))
				{
					TVSetUnlockable.Instance.EjectVHS();
				}
				DropTapeOnLocalClient(TVSetUnlockable.Instance.insertTapePosition.position);
				TVSetUnlockable.Instance.InsertVHS(tape);
				TVSetUnlockable.Instance.inUse = true;
			}
		}

		[ClientRpc]
		public void SpottedClientRpc(AudioArray voiceLine)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1152429834u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<AudioArray>(ref voiceLine, default(ForEnums));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1152429834u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					base.inSpecialAnimation = true;
					PlayRandomClipOnLocalClient(voiceLine);
					Plugin.logger.LogDebug((object)"DoAnimation: spotted");
					base.creatureAnimator.SetTrigger("spotted");
					SwitchToBehaviourStateOnLocalClient(4);
				}
			}
		}

		[ClientRpc]
		public void SetDefaultScareClientRpc(int clipIndex)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3555159912u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, clipIndex);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3555159912u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				currentScareDef = scareDefs.Where((ScareDef x) => x.enemyTypeName == "").First();
				base.creatureVoice.PlayOneShot(baitSFX[clipIndex]);
			}
		}

		[ClientRpc]
		public void SpawnMimicEnemyClientRpc(NetworkObjectReference netRef, int baitSFXIndex)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2907642434u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref netRef, default(ForNetworkSerializable));
				BytePacker.WriteValueBitPacked(val2, baitSFXIndex);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2907642434u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			NetworkObject val3 = default(NetworkObject);
			if (!((NetworkObjectReference)(ref netRef)).TryGet(ref val3, (NetworkManager)null))
			{
				Plugin.logger.LogError((object)"Couldnt find network object in SpawnMimicEnemyClientRpc");
			}
			else if (!((Component)val3).TryGetComponent<EnemyAI>(ref mimicEnemy))
			{
				Plugin.logger.LogError((object)"Couldnt find EnemyAI component in SpawnMimicEnemyClientRpc");
			}
			else if (!((Object)(object)mimicEnemy == (Object)null))
			{
				Collider[] componentsInChildren = ((Component)((Component)mimicEnemy).transform.root).gameObject.GetComponentsInChildren<Collider>();
				foreach (Collider val4 in componentsInChildren)
				{
					val4.enabled = false;
				}
				particleSystem.Play();
				((EnemyAI)this).EnableEnemyMesh(false, false);
				currentScareDef = scareDefs.Where((ScareDef x) => x.enemyTypeName == ((Object)mimicEnemy.enemyType).name).First();
				if (baitSFXIndex >= 0)
				{
					base.creatureVoice.pitch = Random.Range(0.94f, 1.06f);
					base.creatureVoice.PlayOneShot(currentScareDef.baitSFX[baitSFXIndex]);
				}
			}
		}

		[ClientRpc]
		public void DespawnMimicEnemyClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(4284887980u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4284887980u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					mimicEnemy = null;
					particleSystem.Play();
					((EnemyAI)this).EnableEnemyMesh(true, false);
					base.creatureVoice.Stop(true);
				}
			}
		}

		[ClientRpc]
		public void ScareClientRpc(int scareSFXIndex, ulong targetPlayerId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2214336419u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, scareSFXIndex);
				BytePacker.WriteValueBitPacked(val2, targetPlayerId);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2214336419u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			targetPlayer = Plugin.PlayerFromId(targetPlayerId);
			if ((Object)(object)targetPlayer == (Object)null)
			{
				Plugin.logger.LogError((object)"Couldnt get target player in ScareClientRpc");
				return;
			}
			if ((Object)(object)currentScareDef == (Object)null || currentScareDef.enemyTypeName == "")
			{
				PlayRandomClipOnLocalClient(AudioArray.Scare);
				Plugin.logger.LogDebug((object)"DoAnimation: scare");
				base.creatureAnimator.SetTrigger("scare");
			}
			else
			{
				base.creatureVoice.Stop(true);
				if (currentScareDef.animState != "")
				{
					EnemyAI? obj = mimicEnemy;
					if (obj != null)
					{
						obj.creatureAnimator.Play(currentScareDef.animState);
					}
				}
				if (currentScareDef.scareSFX.Length != 0)
				{
					base.creatureVoice.pitch = Random.Range(0.94f, 1.06f);
					base.creatureVoice.PlayOneShot(currentScareDef.scareSFX[scareSFXIndex]);
				}
			}
			triggeredActions.Clear();
			SwitchToBehaviourStateOnLocalClient(3);
		}

		[ClientRpc]
		public void DoAnimationClientRpc(string animationName, bool value)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3075340707u, val, (RpcDelivery)0);
				bool flag = animationName != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(animationName, false);
				}
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref value, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3075340707u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				base.creatureAnimator.SetBool(animationName, value);
				Plugin.logger.LogDebug((object)("DoAnimation: " + animationName + ": " + value));
			}
		}

		[ClientRpc]
		public void DoAnimationClientRpc(string animationName)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(4200062589u, val, (RpcDelivery)0);
				bool flag = animationName != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(animationName, false);
				}
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4200062589u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				base.creatureAnimator.SetTrigger(animationName);
				Plugin.logger.LogDebug((object)("DoAnimation: " + animationName));
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void GiveTapeServerRpc(NetworkObjectReference netRef)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1139598068u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref netRef, default(ForNetworkSerializable));
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1139598068u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				if (((NetworkBehaviour)this).IsServer)
				{
					GiveTapeClientRpc(netRef);
				}
			}
		}

		[ClientRpc]
		public void GiveTapeClientRpc(NetworkObjectReference netRef)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(321885874u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref netRef, default(ForNetworkSerializable));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 321885874u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				NetworkObject val3 = default(NetworkObject);
				if (!((NetworkObjectReference)(ref netRef)).TryGet(ref val3, (NetworkManager)null))
				{
					Plugin.logger.LogError((object)"Couldnt get network object from network object reference");
					return;
				}
				VHSTapeBehavior vHSTapeBehavior = default(VHSTapeBehavior);
				if (!((Component)val3).TryGetComponent<VHSTapeBehavior>(ref vHSTapeBehavior))
				{
					Plugin.logger.LogError((object)"Couldnt get VHSTapeBehavior component from network object");
					return;
				}
				((GrabbableObject)vHSTapeBehavior).parentObject = handTransform;
				((GrabbableObject)vHSTapeBehavior).hasHitGround = false;
				((GrabbableObject)vHSTapeBehavior).isHeldByEnemy = true;
				((GrabbableObject)vHSTapeBehavior).GrabItemFromEnemy((EnemyAI)(object)this);
				((GrabbableObject)vHSTapeBehavior).EnablePhysics(false);
				HoarderBugAI.grabbableObjectsInMap.Remove(((Component)vHSTapeBehavior).gameObject);
				heldTape = vHSTapeBehavior;
				base.creatureVoice.Stop(true);
				base.creatureVoice.PlayOneShot(tapeGivenSFX);
				SwitchToBehaviourStateOnLocalClient(6);
			}
		}

		[ClientRpc]
		public void DropTapeClientRpc(Vector3 position)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(505270414u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref position);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 505270414u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					DropTapeOnLocalClient(position);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void TriggerReactionServerRpc(string actionName)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((Net