Decompiled source of SCP4666 v1.0.0

SCP4666/ProjectSCP.SCP4666.dll

Decompiled 5 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using ProjectSCP.SCP4666.NetcodePatcher;
using SCP4666.YulemanKnife;
using TMPro;
using Unity.Netcode;
using Unity.Netcode.Components;
using UnityEngine;
using UnityEngine.AI;

[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("DissonanceVoip")]
[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.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.SCP4666")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+e940610318794e04d9c3933fa511e2ad5e73bbe7")]
[assembly: AssemblyProduct("SCP4666")]
[assembly: AssemblyTitle("ProjectSCP.SCP4666")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.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 SCP4666
{
	public class ChildSackBehavior : PhysicsProp
	{
		public static bool localPlayerSizeChangedFromSack;

		private bool makePlayersChildOnRevive = true;

		private float minSize = 0.6f;

		private float maxSize = 0.8f;

		private bool usingRandomMode = false;

		public override void Start()
		{
			((GrabbableObject)this).Start();
			usingRandomMode = Plugin.configRandomSack.Value;
			makePlayersChildOnRevive = Plugin.configMakePlayersChildOnRevive.Value;
			minSize = Plugin.configChildMinSize.Value;
			maxSize = Plugin.configChildMaxSize.Value;
		}

		public void Activate()
		{
			((MonoBehaviour)this).StartCoroutine(ActivateCoroutine());
		}

		public IEnumerator ActivateCoroutine()
		{
			Plugin.LoggerInstance.LogDebug((object)"In Activate()");
			yield return (object)new WaitForSeconds(5f);
			if ((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null)
			{
				((GrabbableObject)this).playerHeldBy.DropAllHeldItemsAndSync();
			}
			if (usingRandomMode)
			{
				Plugin.LoggerInstance.LogDebug((object)"Using random mode for child sack");
				int playersRespawned = 0;
				PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
				foreach (PlayerControllerB player2 in allPlayerScripts)
				{
					if (player2.isPlayerDead)
					{
						if (playersRespawned == 0)
						{
							DoALotOfShitToRevivePlayerClientRpc(playerSize: Random.Range(minSize, maxSize), clientId: player2.actualClientId);
							playersRespawned++;
						}
						else if (Random.Range(0, 2) == 0)
						{
							DoALotOfShitToRevivePlayerClientRpc(playerSize: Random.Range(minSize, maxSize), clientId: player2.actualClientId);
							playersRespawned++;
						}
						else
						{
							SpawnPresent();
						}
					}
				}
			}
			else
			{
				Plugin.LoggerInstance.LogDebug((object)"Reviving dead players");
				PlayerControllerB[] allPlayerScripts2 = StartOfRound.Instance.allPlayerScripts;
				foreach (PlayerControllerB player in allPlayerScripts2)
				{
					if (player.isPlayerDead)
					{
						DoALotOfShitToRevivePlayerClientRpc(playerSize: Random.Range(minSize, maxSize), clientId: player.actualClientId);
					}
				}
			}
			((NetworkBehaviour)this).NetworkObject.Despawn(true);
		}

		public void SpawnPresent()
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			Item val = StartOfRound.Instance.allItemsList.itemsList.Where((Item x) => ((Object)x).name == "GiftBox").FirstOrDefault();
			GiftBoxItem componentInChildren = Object.Instantiate<GameObject>(val.spawnPrefab, ((Component)this).transform.position, Quaternion.identity).GetComponentInChildren<GiftBoxItem>();
			((NetworkBehaviour)componentInChildren).NetworkObject.Spawn(false);
		}

		[ClientRpc]
		private void DoALotOfShitToRevivePlayerClientRpc(ulong clientId, float playerSize = 1f)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04df: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3148037036u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, clientId);
				((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref playerSize, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3148037036u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			PlayerControllerB val3 = Plugin.PlayerFromId(clientId);
			DeadBodyInfo deadBody = val3.deadBody;
			val3.isInsideFactory = false;
			val3.isInElevator = true;
			val3.isInHangarShipRoom = true;
			val3.ResetPlayerBloodObjects(val3.isPlayerDead);
			val3.health = 5;
			val3.isClimbingLadder = false;
			val3.clampLooking = false;
			val3.inVehicleAnimation = false;
			val3.disableMoveInput = false;
			val3.disableLookInput = false;
			val3.disableInteract = false;
			val3.ResetZAndXRotation();
			((Collider)val3.thisController).enabled = true;
			if (val3.isPlayerDead)
			{
				Plugin.LoggerInstance.LogDebug((object)"playerInital is dead, reviving them.");
				((Collider)val3.thisController).enabled = true;
				val3.isPlayerDead = false;
				val3.isPlayerControlled = true;
				val3.health = 5;
				val3.hasBeenCriticallyInjured = false;
				val3.criticallyInjured = false;
				val3.playerBodyAnimator.SetBool("Limp", false);
				val3.TeleportPlayer(((Component)this).transform.position, false, 0f, false, true);
				val3.parentedToElevatorLastFrame = false;
				val3.overrideGameOverSpectatePivot = null;
				StartOfRound.Instance.SetPlayerObjectExtrapolate(false);
				val3.setPositionOfDeadPlayer = false;
				val3.DisablePlayerModel(((Component)val3).gameObject, true, true);
				((Behaviour)val3.helmetLight).enabled = false;
				val3.Crouch(false);
				if ((Object)(object)val3.playerBodyAnimator != (Object)null)
				{
					val3.playerBodyAnimator.SetBool("Limp", false);
				}
				val3.bleedingHeavily = true;
				val3.deadBody = null;
				val3.activatingItem = false;
				val3.twoHanded = false;
				val3.inShockingMinigame = false;
				val3.inSpecialInteractAnimation = false;
				val3.freeRotationInInteractAnimation = false;
				val3.disableSyncInAnimation = false;
				val3.inAnimationWithEnemy = null;
				val3.holdingWalkieTalkie = false;
				val3.speakingToWalkieTalkie = false;
				val3.isSinking = false;
				val3.isUnderwater = false;
				val3.sinkingValue = 0f;
				val3.statusEffectAudio.Stop();
				val3.DisableJetpackControlsLocally();
				val3.mapRadarDotAnimator.SetBool("dead", false);
				val3.hasBegunSpectating = false;
				val3.externalForceAutoFade = Vector3.zero;
				val3.hinderedMultiplier = 1f;
				val3.isMovementHindered = 0;
				val3.sourcesCausingSinking = 0;
				val3.reverbPreset = StartOfRound.Instance.shipReverb;
				SoundManager.Instance.earsRingingTimer = 0f;
				val3.voiceMuffledByEnemy = false;
				SoundManager.Instance.playerVoicePitchTargets[Array.IndexOf(StartOfRound.Instance.allPlayerScripts, val3)] = 1f;
				SoundManager.Instance.SetPlayerPitch(1f, Array.IndexOf(StartOfRound.Instance.allPlayerScripts, val3));
				if ((Object)(object)val3.currentVoiceChatIngameSettings == (Object)null)
				{
					StartOfRound.Instance.RefreshPlayerVoicePlaybackObjects();
				}
				if ((Object)(object)val3.currentVoiceChatIngameSettings != (Object)null)
				{
					if ((Object)(object)val3.currentVoiceChatIngameSettings.voiceAudio == (Object)null)
					{
						val3.currentVoiceChatIngameSettings.InitializeComponents();
					}
					if ((Object)(object)val3.currentVoiceChatIngameSettings.voiceAudio == (Object)null)
					{
						return;
					}
					((Component)val3.currentVoiceChatIngameSettings.voiceAudio).GetComponent<OccludeAudio>().overridingLowPass = false;
				}
			}
			if ((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)(object)val3)
			{
				val3.bleedingHeavily = false;
				val3.criticallyInjured = false;
				val3.health = 5;
				HUDManager.Instance.UpdateHealthUI(5, true);
				Animator playerBodyAnimator = val3.playerBodyAnimator;
				if (playerBodyAnimator != null)
				{
					playerBodyAnimator.SetBool("Limp", false);
				}
				val3.spectatedPlayerScript = null;
				StartOfRound.Instance.SetSpectateCameraToGameOverMode(false, val3);
				StartOfRound.Instance.SetPlayerObjectExtrapolate(false);
				((Behaviour)HUDManager.Instance.audioListenerLowPass).enabled = false;
				HUDManager.Instance.gasHelmetAnimator.SetBool("gasEmitting", false);
				HUDManager.Instance.RemoveSpectateUI();
				HUDManager.Instance.gameOverAnimator.SetTrigger("revive");
				localPlayerSizeChangedFromSack = true;
			}
			StartOfRound.Instance.allPlayersDead = false;
			StartOfRound instance = StartOfRound.Instance;
			instance.livingPlayers++;
			StartOfRound.Instance.UpdatePlayerVoiceEffects();
			deadBody.DeactivateBody(false);
			val3.thisPlayerBody.localScale = new Vector3(playerSize, playerSize, playerSize);
		}

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

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

		private static void __rpc_handler_3148037036(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ulong clientId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref clientId);
				float playerSize = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref playerSize, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((ChildSackBehavior)(object)target).DoALotOfShitToRevivePlayerClientRpc(clientId, playerSize);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "ChildSackBehavior";
		}
	}
	public class NetworkHandlerSCP4666 : NetworkBehaviour
	{
		private static ManualLogSource logger = Plugin.LoggerInstance;

		public static NetworkHandlerSCP4666? Instance { get; private set; }

		public override void OnNetworkSpawn()
		{
			if (Plugin.IsServerOrHost && (Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this)
			{
				((Component)Instance).gameObject.GetComponent<NetworkObject>().Despawn(true);
				Plugin.log("Despawned network object");
			}
			((Object)this).hideFlags = (HideFlags)61;
			Instance = this;
			Plugin.log("set instance to this");
			((NetworkBehaviour)this).OnNetworkSpawn();
			Plugin.log("base.OnNetworkSpawn");
		}

		public override void OnNetworkDespawn()
		{
			((NetworkBehaviour)this).OnNetworkDespawn();
			if ((Object)(object)Instance == (Object)(object)this)
			{
				Instance = null;
			}
		}

		[ClientRpc]
		private void ChangePlayerSizeClientRpc(ulong clientId, float size)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1820857783u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, clientId);
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref size, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1820857783u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					Plugin.log("ChangePlayerSizeClientRpc() called");
					PlayerControllerB val3 = Plugin.PlayerFromId(clientId);
					val3.thisPlayerBody.localScale = new Vector3(size, size, size);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void ChangePlayerSizeServerRpc(ulong clientId, float size)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2312655225u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, clientId);
				((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref size, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2312655225u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				Plugin.log("ChangePlayerSizeServerRpc() called");
				if (Plugin.IsServerOrHost)
				{
					ChangePlayerSizeClientRpc(clientId, size);
				}
			}
		}

		public IEnumerator AllowPlayerDeathAfterDelay(float delay)
		{
			yield return (object)new WaitForSeconds(delay);
			StartOfRound.Instance.allowLocalPlayerDeath = true;
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_NetworkHandlerSCP4666()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(1820857783u, new RpcReceiveHandler(__rpc_handler_1820857783));
			NetworkManager.__rpc_func_table.Add(2312655225u, new RpcReceiveHandler(__rpc_handler_2312655225));
		}

		private static void __rpc_handler_1820857783(NetworkBehaviour? target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ulong clientId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref clientId);
				float size = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref size, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((NetworkHandlerSCP4666)(object)target).ChangePlayerSizeClientRpc(clientId, size);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2312655225(NetworkBehaviour? target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ulong clientId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref clientId);
				float size = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref size, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((NetworkHandlerSCP4666)(object)target).ChangePlayerSizeServerRpc(clientId, size);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string? __getTypeName()
		{
			return "NetworkHandlerSCP4666";
		}
	}
	[HarmonyPatch]
	public class NetworkObjectManager
	{
		private static GameObject networkPrefab;

		private static ManualLogSource logger = Plugin.LoggerInstance;

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameNetworkManager), "Start")]
		public static void Init()
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Expected O, but got Unknown
			Plugin.log("Initializing network prefab...");
			if (!((Object)(object)networkPrefab != (Object)null))
			{
				if ((Object)(object)Plugin.ModAssets == (Object)null)
				{
					logger.LogError((object)"Couldnt get ModAssets to create network handler");
					return;
				}
				networkPrefab = (GameObject)Plugin.ModAssets.LoadAsset("Assets/ModAssets/NetworkHandlerSCP4666.prefab");
				Plugin.log("Got networkPrefab");
				NetworkManager.Singleton.AddNetworkPrefab(networkPrefab);
				Plugin.log("Added networkPrefab");
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(StartOfRound), "Awake")]
		private static void SpawnNetworkHandler()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			if (Plugin.IsServerOrHost)
			{
				GameObject val = Object.Instantiate<GameObject>(networkPrefab, Vector3.zero, Quaternion.identity);
				Plugin.log("Instantiated networkHandlerHost");
				val.GetComponent<NetworkObject>().Spawn(false);
				Plugin.log("Spawned network object");
			}
		}
	}
	internal class TESTING : MonoBehaviour
	{
		private static ManualLogSource logger = Plugin.LoggerInstance;

		private static bool toggle;

		[HarmonyPostfix]
		[HarmonyPatch(typeof(HUDManager), "PingScan_performed")]
		public static void PingScan_performedPostFix()
		{
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(HUDManager), "SubmitChat_performed")]
		public static void SubmitChat_performedPrefix(HUDManager __instance)
		{
			try
			{
				string text = __instance.chatTextField.text;
				string[] array = text.Split(" ");
				switch (array[0])
				{
				case "/force":
					ThrownKnifeScript.throwForce = float.Parse(array[1]);
					break;
				case "/size":
					toggle = !toggle;
					if (toggle)
					{
						ChangePlayerSize(0.8f);
						HUDManager.Instance.DisplayTip("/size", "Making player small", false, false, "LC_Tip1");
					}
					else
					{
						ChangePlayerSize(1f);
						HUDManager.Instance.DisplayTip("/size", "Making player normal", false, false, "LC_Tip1");
					}
					break;
				case "/refresh":
					RoundManager.Instance.RefreshEnemiesList();
					HoarderBugAI.RefreshGrabbableObjectsInMapList();
					break;
				case "/levels":
				{
					SelectableLevel[] levels = StartOfRound.Instance.levels;
					foreach (SelectableLevel val2 in levels)
					{
						logger.LogDebug((object)((Object)val2).name);
					}
					break;
				}
				case "/dungeon":
					Plugin.log(((Object)RoundManager.Instance.dungeonGenerator.Generator.DungeonFlow).name);
					break;
				case "/dungeons":
				{
					IndoorMapType[] dungeonFlowTypes = RoundManager.Instance.dungeonFlowTypes;
					foreach (IndoorMapType val in dungeonFlowTypes)
					{
						Plugin.log(((Object)val.dungeonFlow).name);
					}
					break;
				}
				}
			}
			catch (Exception ex)
			{
				logger.LogError((object)"Invalid chat command");
				logger.LogError((object)ex);
			}
		}

		public static void ChangePlayerSize(float size)
		{
			NetworkHandlerSCP4666.Instance.ChangePlayerSizeServerRpc(Plugin.localPlayer.actualClientId, size);
		}
	}
	[BepInPlugin("ProjectSCP.SCP4666", "SCP4666", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public static Plugin PluginInstance;

		public static ManualLogSource LoggerInstance;

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

		public static AssetBundle? ModAssets;

		public GameObject BlackScreenOverlay;

		public static ConfigEntry<bool> configEnableExtendedLogging;

		public static ConfigEntry<bool> configEnableSCP4666;

		public static ConfigEntry<string> config4666LevelRarities;

		public static ConfigEntry<string> config4666CustomLevelRarities;

		public static ConfigEntry<int> configMinPresentCount;

		public static ConfigEntry<int> configMaxPresentCount;

		public static ConfigEntry<float> configTeleportCooldown;

		public static ConfigEntry<float> configKnifeThrowCooldown;

		public static ConfigEntry<float> configKnifeReturnCooldown;

		public static ConfigEntry<float> configKnifeThrowMinDistance;

		public static ConfigEntry<float> configKnifeThrowMaxDistance;

		public static ConfigEntry<float> configTeleportDistance;

		public static ConfigEntry<int> configSliceDamage;

		public static ConfigEntry<int> configSlapDamage;

		public static ConfigEntry<int> configHitAmountToDropPlayer;

		public static ConfigEntry<bool> configMakeScreenBlackAbduct;

		public static ConfigEntry<int> configKnifeMinValue;

		public static ConfigEntry<int> configKnifeMaxValue;

		public static ConfigEntry<float> configChargeTime;

		public static ConfigEntry<int> configKnifeHitForce;

		public static ConfigEntry<float> configThrowForce;

		public static ConfigEntry<int> configKnifeHitForceYuleman;

		public static ConfigEntry<int> configSackMinValue;

		public static ConfigEntry<int> configSackMaxValue;

		public static ConfigEntry<bool> configRandomSack;

		public static ConfigEntry<bool> configMakePlayersChildOnRevive;

		public static ConfigEntry<float> configChildMinSize;

		public static ConfigEntry<float> configChildMaxSize;

		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).First();
		}

		private void Awake()
		{
			if ((Object)(object)PluginInstance == (Object)null)
			{
				PluginInstance = this;
			}
			LoggerInstance = ((BaseUnityPlugin)PluginInstance).Logger;
			harmony.PatchAll();
			InitializeNetworkBehaviours();
			configEnableExtendedLogging = ((BaseUnityPlugin)this).Config.Bind<bool>("Debugging", "Enable Extended Logging", false, "Shows more logging in the console for debugging/testing");
			configEnableSCP4666 = ((BaseUnityPlugin)this).Config.Bind<bool>("SCP-4666", "Enable SCP-4666", true, "Set to false to disable spawning SCP-4666. Use this in combination with configKnifeLevelRarities and configKnifeCustomLevelRarities if you just want to use the knife.");
			config4666LevelRarities = ((BaseUnityPlugin)this).Config.Bind<string>("SCP-4666 Rarities", "Level Rarities", "ExperimentationLevel:5, AssuranceLevel:6, VowLevel:9, OffenseLevel:10, AdamanceLevel:20, MarchLevel:10, RendLevel:100, DineLevel:100, TitanLevel:75, ArtificeLevel:20, EmbrionLevel:25", "Rarities for each level. See default for formatting.");
			config4666CustomLevelRarities = ((BaseUnityPlugin)this).Config.Bind<string>("SCP-4666 Rarities", "Custom Level Rarities", "Secret LabsLevel:100, CrestLevel:100, Winter LodgeLevel:100, SummitLevel:100, PolarusLevel:100, FilitriosLevel:100, MotraLevel:100", "Rarities for modded levels. Same formatting as level rarities.");
			configMinPresentCount = ((BaseUnityPlugin)this).Config.Bind<int>("SCP-4666", "Minimum Present Count", 3, "Minimum number of presents spawned by SCP-4666.");
			configMaxPresentCount = ((BaseUnityPlugin)this).Config.Bind<int>("SCP-4666", "Maximum Present Count", 5, "Maximum number of presents spawned by SCP-4666.");
			configTeleportCooldown = ((BaseUnityPlugin)this).Config.Bind<float>("SCP-4666", "Teleport Cooldown", 15f, "Cooldown (in seconds) between SCP-4666 teleport actions.");
			configKnifeThrowCooldown = ((BaseUnityPlugin)this).Config.Bind<float>("SCP-4666", "Knife Throw Cooldown", 10f, "Cooldown (in seconds) before SCP-4666 can throw the knife again.");
			configKnifeReturnCooldown = ((BaseUnityPlugin)this).Config.Bind<float>("SCP-4666", "Knife Return Cooldown", 5f, "Cooldown (in seconds) before SCP-4666 can call the knife back.");
			configKnifeThrowMinDistance = ((BaseUnityPlugin)this).Config.Bind<float>("SCP-4666", "Knife Throw Minimum Distance", 5f, "Minimum distance SCP-4666 can throw the knife.");
			configKnifeThrowMaxDistance = ((BaseUnityPlugin)this).Config.Bind<float>("SCP-4666", "Knife Throw Maximum Distance", 10f, "Maximum distance SCP-4666 can throw the knife.");
			configTeleportDistance = ((BaseUnityPlugin)this).Config.Bind<float>("SCP-4666", "Teleport Distance", 15f, "Distance SCP-4666 needs to be from the player to allow him to teleport.");
			configSliceDamage = ((BaseUnityPlugin)this).Config.Bind<int>("SCP-4666", "Slice Damage", 25, "Damage dealt by SCP-4666's knife slice.");
			configSlapDamage = ((BaseUnityPlugin)this).Config.Bind<int>("SCP-4666", "Slap Damage", 10, "Damage dealt by SCP-4666's slap attack. (When his knife is stolen)");
			configHitAmountToDropPlayer = ((BaseUnityPlugin)this).Config.Bind<int>("SCP-4666", "Hit Amount to Drop Player", 5, "Number of hits required to make SCP-4666 drop a player.");
			configMakeScreenBlackAbduct = ((BaseUnityPlugin)this).Config.Bind<bool>("SCP-4666", "Make Screen Black on Abduction", true, "Set to true to make the player's screen black during abduction.");
			configKnifeMinValue = ((BaseUnityPlugin)this).Config.Bind<int>("Enchanted Knife", "Min Value", 100, "Minimum scrap value of enchanted knife.");
			configKnifeMaxValue = ((BaseUnityPlugin)this).Config.Bind<int>("Enchanted Knife", "Max Value", 200, "Maximum scrap value of enchanted knife.");
			configChargeTime = ((BaseUnityPlugin)this).Config.Bind<float>("Enchanted Knife", "Charge Time", 1f, "Time required to charge the throw attack for the knife.");
			configKnifeHitForce = ((BaseUnityPlugin)this).Config.Bind<int>("Enchanted Knife", "Knife Hit Force", 1, "Damage applied when the knife hits a enemy.");
			configThrowForce = ((BaseUnityPlugin)this).Config.Bind<float>("Enchanted Knife", "Throw Force", 100f, "How fast the knife will go when thrown");
			configKnifeHitForceYuleman = ((BaseUnityPlugin)this).Config.Bind<int>("Enchanted Knife", "Knife Hit Force (Player)", 25, "Damage applied when the knife hits a player. This also applies to when the yuleman throws it.");
			configSackMinValue = ((BaseUnityPlugin)this).Config.Bind<int>("Child Sack", "Min Value", 100, "Minimum scrap value of the sack the yuleman drops.");
			configSackMaxValue = ((BaseUnityPlugin)this).Config.Bind<int>("Child Sack", "Max Value", 200, "Maximum scrap value of sack the yuleman drops.");
			configRandomSack = ((BaseUnityPlugin)this).Config.Bind<bool>("Child Sack", "Random sack", false, "If set to true, instead of reviving all players on team wipe, it will have a 50/50 chance to either revive a player or spawn a present, with 1 player revive guranteed.");
			configMakePlayersChildOnRevive = ((BaseUnityPlugin)this).Config.Bind<bool>("Child Sack", "Make Players Child On Revive", true, "Should the players size be changed when being revived by the child sack?");
			configChildMinSize = ((BaseUnityPlugin)this).Config.Bind<float>("Child Sack", "Child Min Size", 0.6f, "Min size to make the player when revived as a child. Default vanilla size of the player is 1.");
			configChildMaxSize = ((BaseUnityPlugin)this).Config.Bind<float>("Child Sack", "Child Max Size", 0.8f, "Max size to make the player when revived as a child. Default vanilla size of the player is 1.");
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			ModAssets = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "scp4666_assets"));
			if ((Object)(object)ModAssets == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load custom assets.");
				return;
			}
			LoggerInstance.LogDebug((object)("Got AssetBundle at: " + Path.Combine(directoryName, "scp4666_assets")));
			Item val = ModAssets.LoadAsset<Item>("Assets/ModAssets/YulemanKnifeItem.asset");
			if ((Object)(object)val == (Object)null)
			{
				LoggerInstance.LogError((object)"Error: Couldnt get YulemanKnifeItem from assets");
				return;
			}
			LoggerInstance.LogDebug((object)"Got YulemanKnife prefab");
			val.minValue = configKnifeMinValue.Value;
			val.maxValue = configKnifeMaxValue.Value;
			NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
			Utilities.FixMixerGroups(val.spawnPrefab);
			Items.RegisterScrap(val, (Dictionary<LevelTypes, int>)null, (Dictionary<string, int>)null);
			Item val2 = ModAssets.LoadAsset<Item>("Assets/ModAssets/ChildSackItem.asset");
			if ((Object)(object)val2 == (Object)null)
			{
				LoggerInstance.LogError((object)"Error: Couldnt get ChildSackItem from assets");
				return;
			}
			LoggerInstance.LogDebug((object)"Got ChildSack prefab");
			val2.minValue = configSackMinValue.Value;
			val2.maxValue = configSackMaxValue.Value;
			NetworkPrefabs.RegisterNetworkPrefab(val2.spawnPrefab);
			Utilities.FixMixerGroups(val2.spawnPrefab);
			Items.RegisterScrap(val2, (Dictionary<LevelTypes, int>)null, (Dictionary<string, int>)null);
			if (configEnableSCP4666.Value)
			{
				EnemyType val3 = ModAssets.LoadAsset<EnemyType>("Assets/ModAssets/SCP4666Enemy.asset");
				if ((Object)(object)val3 == (Object)null)
				{
					LoggerInstance.LogError((object)"Error: Couldnt get SCP-4666 from assets");
					return;
				}
				LoggerInstance.LogDebug((object)"Got SCP-4666 prefab");
				TerminalNode val4 = ModAssets.LoadAsset<TerminalNode>("Assets/ModAssets/Bestiary/SCP4666TN.asset");
				TerminalKeyword val5 = ModAssets.LoadAsset<TerminalKeyword>("Assets/ModAssets/Bestiary/SCP4666TK.asset");
				LoggerInstance.LogDebug((object)"Registering enemy network prefab...");
				NetworkPrefabs.RegisterNetworkPrefab(val3.enemyPrefab);
				LoggerInstance.LogDebug((object)"Registering enemy...");
				Enemies.RegisterEnemy(val3, GetLevelRarities(config4666LevelRarities.Value), GetCustomLevelRarities(config4666CustomLevelRarities.Value), val4, val5);
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)"ProjectSCP.SCP4666 v1.0.0 has loaded!");
		}

		public Dictionary<LevelTypes, int> GetLevelRarities(string levelsString)
		{
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Dictionary<LevelTypes, int> dictionary = new Dictionary<LevelTypes, int>();
				if (levelsString != null && levelsString != "")
				{
					string[] array = levelsString.Split(',');
					string[] array2 = array;
					foreach (string text in array2)
					{
						string[] array3 = text.Split(':');
						if (array3.Length == 2)
						{
							string text2 = array3[0].Trim();
							string text3 = array3[1].Trim();
							if (Enum.TryParse<LevelTypes>(text2, out LevelTypes result) && int.TryParse(text3, out var result2))
							{
								dictionary.Add(result, result2);
							}
							else
							{
								LoggerInstance.LogError((object)("Error: Invalid level rarity: " + text2 + ":" + text3));
							}
						}
					}
				}
				return dictionary;
			}
			catch (Exception arg)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)$"Error: {arg}");
				return null;
			}
		}

		public Dictionary<string, int> GetCustomLevelRarities(string levelsString)
		{
			try
			{
				Dictionary<string, int> dictionary = new Dictionary<string, int>();
				if (levelsString != null)
				{
					string[] array = levelsString.Split(',');
					string[] array2 = array;
					foreach (string text in array2)
					{
						string[] array3 = text.Split(':');
						if (array3.Length == 2)
						{
							string text2 = array3[0].Trim();
							string text3 = array3[1].Trim();
							if (int.TryParse(text3, out var result))
							{
								dictionary.Add(text2, result);
							}
							else
							{
								LoggerInstance.LogError((object)("Error: Invalid level rarity: " + text2 + ":" + text3));
							}
						}
					}
				}
				return dictionary;
			}
			catch (Exception arg)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)$"Error: {arg}");
				return null;
			}
		}

		public static void log(string message)
		{
			if (configEnableExtendedLogging.Value)
			{
				LoggerInstance.LogDebug((object)message);
			}
		}

		public static void FreezePlayer(PlayerControllerB player, bool value)
		{
			player.disableInteract = value;
			player.disableLookInput = value;
			player.disableMoveInput = value;
		}

		public static void MakePlayerInvisible(PlayerControllerB player, bool value)
		{
			GameObject gameObject = ((Component)((Component)player).gameObject.transform.Find("ScavengerModel")).gameObject;
			if ((Object)(object)gameObject == (Object)null)
			{
				LoggerInstance.LogError((object)"ScavengerModel not found");
				return;
			}
			((Component)gameObject.transform.Find("LOD1")).gameObject.SetActive(!value);
			((Component)gameObject.transform.Find("LOD2")).gameObject.SetActive(!value);
			((Component)gameObject.transform.Find("LOD3")).gameObject.SetActive(!value);
			((Component)player.playerBadgeMesh).gameObject.SetActive(value);
		}

		public static bool IsPlayerChild(PlayerControllerB player)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return player.thisPlayerBody.localScale.y < 1f;
		}

		public static bool CalculatePath(Vector3 fromPos, Vector3 toPos)
		{
			//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_0022: 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_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected O, but got Unknown
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: 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)
			Vector3 navMeshPosition = RoundManager.Instance.GetNavMeshPosition(fromPos, RoundManager.Instance.navHit, 1.75f, -1);
			Vector3 navMeshPosition2 = RoundManager.Instance.GetNavMeshPosition(toPos, RoundManager.Instance.navHit, 1.75f, -1);
			NavMeshPath val = new NavMeshPath();
			return NavMesh.CalculatePath(navMeshPosition, navMeshPosition2, -1, val) && Vector3.Distance(val.corners[val.corners.Length - 1], RoundManager.Instance.GetNavMeshPosition(navMeshPosition2, RoundManager.Instance.navHit, 2.7f, -1)) <= 1.55f;
		}

		public static Vector3 GetPositionFrontOfPlayer(PlayerControllerB player, float distance = 1f)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			return ((Component)player.playerEye).transform.position + ((Component)player.playerEye).transform.forward * distance;
		}

		public static void GrabGrabbableObjectOnClient(GrabbableObject obj)
		{
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			((Component)obj).transform.root.SetParent((Transform)null);
			obj.isHeldByEnemy = false;
			localPlayer.currentlyGrabbingObject = obj;
			localPlayer.currentlyGrabbingObject.InteractItem();
			if (localPlayer.currentlyGrabbingObject.grabbable && localPlayer.FirstEmptyItemSlot() != -1)
			{
				localPlayer.playerBodyAnimator.SetBool("GrabInvalidated", false);
				localPlayer.playerBodyAnimator.SetBool("GrabValidated", false);
				localPlayer.playerBodyAnimator.SetBool("cancelHolding", false);
				localPlayer.playerBodyAnimator.ResetTrigger("Throw");
				((Behaviour)localPlayer.cursorIcon).enabled = false;
				((TMP_Text)localPlayer.cursorTip).text = "";
				localPlayer.twoHanded = localPlayer.currentlyGrabbingObject.itemProperties.twoHanded;
				localPlayer.carryWeight = Mathf.Clamp(localPlayer.carryWeight + (localPlayer.currentlyGrabbingObject.itemProperties.weight - 1f), 1f, 10f);
				if (localPlayer.currentlyGrabbingObject.itemProperties.grabAnimationTime > 0f)
				{
					localPlayer.grabObjectAnimationTime = localPlayer.currentlyGrabbingObject.itemProperties.grabAnimationTime;
				}
				localPlayer.GrabObjectServerRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)obj).NetworkObject));
				if (localPlayer.grabObjectCoroutine != null)
				{
					((MonoBehaviour)localPlayer).StopCoroutine(localPlayer.grabObjectCoroutine);
				}
				localPlayer.grabObjectCoroutine = ((MonoBehaviour)localPlayer).StartCoroutine(localPlayer.GrabObject());
			}
		}

		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);
					}
				}
			}
			LoggerInstance.LogDebug((object)"Finished initializing network behaviours");
		}
	}
	internal class SCP4666AI : EnemyAI
	{
		public enum State
		{
			Spawning,
			Chasing,
			Abducting
		}

		private static ManualLogSource logger = Plugin.LoggerInstance;

		public NetworkAnimator networkAnimator;

		public Transform RightHandTransform;

		public Transform ChildSackTransform;

		public GameObject ChildSackPrefab;

		public GameObject YulemanKnifePrefab;

		public AudioClip FootstepSFX;

		public AudioClip TeleportSFX;

		public AudioClip LaughSFX;

		public AudioClip RoarSFX;

		public GameObject YulemanMesh;

		public Transform turnCompass;

		public ThrownKnifeScript thrownKnifeScript;

		public YulemanKnifeBehavior KnifeScript;

		private Vector3 mainEntranceOutsidePosition;

		private Vector3 mainEntrancePosition;

		private List<PlayerControllerB> TargetPlayers = new List<PlayerControllerB>();

		private bool localPlayerHasSeenYuleman;

		private bool spawnedAndVisible;

		private bool isGrabbingPlayer;

		private bool isPlayerInSack;

		private float timeSinceDamagePlayer;

		private float timeSinceTeleport;

		private float timeSinceKnifeThrown;

		private float timeSinceGrabPlayer;

		private bool teleporting;

		private bool callingKnifeBack;

		private bool isAngry;

		private int timesHitWhileAbducting;

		private readonly Vector3 insideScale = new Vector3(1.5f, 1.5f, 1.5f);

		private readonly Vector3 outsideScale = new Vector3(2f, 2f, 2f);

		private readonly float attackRange = 5f;

		private readonly float attackAngle = 45f;

		public static SCP4666AI? Instance { get; private set; }

		public override void Start()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Start();
			Plugin.log("SCP-4666 Spawned");
			base.currentBehaviourStateIndex = 0;
			mainEntrancePosition = RoundManager.FindMainEntrancePosition(false, false);
			mainEntranceOutsidePosition = RoundManager.FindMainEntrancePosition(false, true);
			if (Plugin.IsServerOrHost)
			{
				int amount = Random.Range(Plugin.configMinPresentCount.Value, Plugin.configMaxPresentCount.Value + 1);
				SpawnPresents(amount);
			}
		}

		public override void OnNetworkSpawn()
		{
			((NetworkBehaviour)this).OnNetworkSpawn();
			if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this)
			{
				Plugin.log("There is already a SCP-4666 in the scene. Removing this one.");
				if (Plugin.IsServerOrHost)
				{
					((NetworkBehaviour)this).NetworkObject.Despawn(true);
				}
			}
			else
			{
				Instance = this;
				Plugin.log("Finished spawning SCP-4666");
			}
		}

		public override void OnNetworkDespawn()
		{
			((NetworkBehaviour)this).OnNetworkDespawn();
			if ((Object)(object)Instance == (Object)(object)this)
			{
				Instance = null;
				Plugin.PluginInstance.BlackScreenOverlay.SetActive(false);
			}
		}

		public void SpawnPresents(int amount)
		{
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: 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)
			Random random = new Random(StartOfRound.Instance.randomMapSeed + base.thisEnemyIndex);
			for (int i = 0; i < amount; i++)
			{
				Item val = StartOfRound.Instance.allItemsList.itemsList.Where((Item x) => ((Object)x).name == "GiftBox").FirstOrDefault();
				Vector3 randomPositionInRadius = RoundManager.Instance.GetRandomPositionInRadius(((Component)this).transform.position, 1f, 1.5f, random);
				GiftBoxItem componentInChildren = Object.Instantiate<GameObject>(val.spawnPrefab, randomPositionInRadius, Quaternion.identity).GetComponentInChildren<GiftBoxItem>();
				((NetworkBehaviour)componentInChildren).NetworkObject.Spawn(false);
			}
		}

		public override void Update()
		{
			//IL_009e: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: 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_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Update();
			if (base.isEnemyDead || StartOfRound.Instance.allPlayersDead || !spawnedAndVisible)
			{
				return;
			}
			timeSinceDamagePlayer += Time.deltaTime;
			timeSinceTeleport += Time.deltaTime;
			timeSinceKnifeThrown += Time.deltaTime;
			timeSinceGrabPlayer += Time.deltaTime;
			if (base.currentBehaviourStateIndex == 0)
			{
				turnCompass.LookAt(((Component)Plugin.localPlayer.gameplayCamera).transform.position);
				((Component)this).transform.rotation = Quaternion.Lerp(((Component)this).transform.rotation, Quaternion.Euler(new Vector3(0f, turnCompass.eulerAngles.y - 90f, 0f)), 10f * Time.deltaTime);
			}
			if ((Object)(object)Plugin.localPlayer != (Object)(object)base.inSpecialAnimationWithPlayer && Plugin.localPlayer.HasLineOfSightToPosition(((Component)this).transform.position, 45f, 60, -1f))
			{
				Plugin.localPlayer.IncreaseFearLevelOverTime(0.1f, 0.5f);
				if (!localPlayerHasSeenYuleman)
				{
					localPlayerHasSeenYuleman = true;
					AddTargetPlayerServerRpc(Plugin.localPlayer.actualClientId);
				}
			}
			if ((Object)(object)base.inSpecialAnimationWithPlayer != (Object)null && isGrabbingPlayer)
			{
				((Component)base.inSpecialAnimationWithPlayer).transform.position = RightHandTransform.position;
				base.inSpecialAnimationWithPlayer.takingFallDamage = false;
			}
			if ((Object)(object)base.inSpecialAnimationWithPlayer != (Object)null && isPlayerInSack)
			{
				((Component)base.inSpecialAnimationWithPlayer).transform.position = ChildSackTransform.position;
				base.inSpecialAnimationWithPlayer.takingFallDamage = false;
			}
			if (base.stunNormalizedTimer > 0f || base.inSpecialAnimation)
			{
				base.agent.speed = 0f;
			}
		}

		public override void DoAIInterval()
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_03be: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0474: Unknown result type (might be due to invalid IL or missing references)
			//IL_047a: Unknown result type (might be due to invalid IL or missing references)
			//IL_043b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_049e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0359: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_032a: Unknown result type (might be due to invalid IL or missing references)
			if (base.isEnemyDead || StartOfRound.Instance.allPlayersDead || base.stunNormalizedTimer > 0f)
			{
				return;
			}
			if (base.moveTowardsDestination)
			{
				base.agent.SetDestination(base.destination);
			}
			switch (base.currentBehaviourStateIndex)
			{
			case 0:
				base.agent.speed = 0f;
				if (!spawnedAndVisible && !InLineOfSight())
				{
					spawnedAndVisible = true;
					BecomeVisibleClientRpc();
				}
				break;
			case 1:
				base.agent.speed = (isAngry ? 7f : 5f);
				if (!TargetClosestPlayer())
				{
					((EnemyAI)this).SwitchToBehaviourClientRpc(2);
					break;
				}
				if ((timeSinceTeleport > Plugin.configTeleportCooldown.Value && Vector3.Distance(((Component)base.targetPlayer).transform.position, ((Component)this).transform.position) > Plugin.configTeleportDistance.Value) || (isAngry && timeSinceTeleport > Plugin.configTeleportCooldown.Value / 2f && Vector3.Distance(((Component)base.targetPlayer).transform.position, ((Component)this).transform.position) > Plugin.configTeleportDistance.Value / 2f))
				{
					Plugin.log("can teleport");
					if (!KnifeScript.isThrown && !callingKnifeBack && !base.inSpecialAnimation && !teleporting)
					{
						Plugin.log("teleporting");
						timeSinceTeleport = 0f;
						teleporting = true;
						TeleportToTargetPlayer();
						break;
					}
				}
				if (!base.inSpecialAnimation)
				{
					if (KnifeScript.isThrown && !callingKnifeBack && timeSinceKnifeThrown > Plugin.configKnifeReturnCooldown.Value)
					{
						Plugin.log("KnifeThrown: " + KnifeScript.isThrown);
						callingKnifeBack = true;
						networkAnimator.SetTrigger("grab");
						break;
					}
					if (!KnifeScript.isThrown && !callingKnifeBack && !teleporting && timeSinceKnifeThrown > Plugin.configKnifeThrowCooldown.Value)
					{
						float num = Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position);
						if (num > Plugin.configKnifeThrowMinDistance.Value && num < Plugin.configKnifeThrowMaxDistance.Value)
						{
							timeSinceKnifeThrown = 0f;
							base.inSpecialAnimation = true;
							((Component)this).transform.LookAt(((Component)base.targetPlayer).transform.position);
							networkAnimator.SetTrigger("throw");
							break;
						}
					}
				}
				((EnemyAI)this).SetDestinationToPosition(((Component)base.targetPlayer).transform.position, false);
				break;
			case 2:
				base.agent.speed = 4f;
				if (!isPlayerInSack && TargetClosestPlayer())
				{
					((EnemyAI)this).SwitchToBehaviourClientRpc(1);
				}
				else if (base.isOutside)
				{
					base.targetNode = ((EnemyAI)this).ChooseFarthestNodeFromPosition(mainEntranceOutsidePosition, false, 0, false, 50, false);
					if (Vector3.Distance(((Component)this).transform.position, base.targetNode.position) < 1f)
					{
						if (isPlayerInSack && (Object)(object)base.inSpecialAnimationWithPlayer != (Object)null)
						{
							KillPlayerInSackClientRpc();
						}
						((NetworkBehaviour)this).NetworkObject.Despawn(true);
					}
					else if (!((EnemyAI)this).SetDestinationToPosition(base.targetNode.position, true))
					{
						logger.LogWarning((object)"Unable to reach escape node");
					}
				}
				else if (!teleporting && Vector3.Distance(((Component)this).transform.position, mainEntrancePosition) < 1f)
				{
					teleporting = true;
					Teleport(mainEntranceOutsidePosition, outside: true);
				}
				else if (!teleporting && !((EnemyAI)this).SetDestinationToPosition(mainEntrancePosition, true))
				{
					teleporting = true;
					Teleport(mainEntranceOutsidePosition, outside: true);
				}
				break;
			default:
				logger.LogWarning((object)("Invalid state: " + base.currentBehaviourStateIndex));
				break;
			}
		}

		public void Teleport(Vector3 position, bool outside)
		{
			//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_0024: Unknown result type (might be due to invalid IL or missing references)
			position = RoundManager.Instance.GetNavMeshPosition(position, RoundManager.Instance.navHit, 5f, -1);
			base.agent.Warp(position);
			SetEnemyOutsideClientRpc(outside);
			teleporting = false;
		}

		public void TeleportToTargetPlayer()
		{
			((MonoBehaviour)this).StartCoroutine(TeleportCoroutine());
		}

		private IEnumerator TeleportCoroutine()
		{
			if (!GetTeleportNode())
			{
				teleporting = false;
				yield break;
			}
			PlayTeleportSFXClientRpc();
			yield return (object)new WaitForSeconds(2f);
			Vector3 pos = RoundManager.Instance.GetNavMeshPosition(base.targetNode.position, RoundManager.Instance.navHit, 5f, -1);
			base.agent.Warp(pos);
			PlayLaughSFXClientRpc();
			teleporting = false;
		}

		private bool GetTeleportNode()
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: 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_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: 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_0104: Unknown result type (might be due to invalid IL or missing references)
			base.targetNode = null;
			GameObject[] array = (base.targetPlayer.isInsideFactory ? RoundManager.Instance.insideAINodes : RoundManager.Instance.outsideAINodes);
			float num = Vector3.Distance(((Component)base.targetPlayer).transform.position, ((Component)this).transform.position);
			GameObject[] array2 = array;
			foreach (GameObject val in array2)
			{
				if (!((Object)(object)val == (Object)null) && !base.targetPlayer.HasLineOfSightToPosition(val.transform.position + Vector3.up * 0.25f, 68f, 60, 1f) && !base.targetPlayer.HasLineOfSightToPosition(val.transform.position + Vector3.up * 1.6f, 68f, 60, 1f))
				{
					float num2 = Vector3.Distance(val.transform.position, ((Component)base.targetPlayer).transform.position);
					if (num2 < num)
					{
						num = num2;
						base.targetNode = val.transform;
					}
				}
			}
			return (Object)(object)base.targetNode != (Object)null;
		}

		private bool InLineOfSight()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if (PlayerIsTargetable(val) && val.HasLineOfSightToPosition(((Component)this).transform.position + Vector3.up * 2f, 45f, 60, -1f))
				{
					return true;
				}
			}
			return false;
		}

		public bool TargetClosestPlayer(float bufferDistance = 1.5f, bool requireLineOfSight = false, float viewWidth = 70f)
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			base.mostOptimalDistance = 2000f;
			PlayerControllerB targetPlayer = base.targetPlayer;
			base.targetPlayer = null;
			foreach (PlayerControllerB item in TargetPlayers.ToList())
			{
				if (PlayerIsTargetable(item))
				{
					base.tempDist = Vector3.Distance(((Component)this).transform.position, ((Component)item).transform.position);
					if (base.tempDist < base.mostOptimalDistance)
					{
						base.mostOptimalDistance = base.tempDist;
						base.targetPlayer = item;
					}
				}
			}
			if ((Object)(object)base.targetPlayer != (Object)null && bufferDistance > 0f && (Object)(object)targetPlayer != (Object)null && Mathf.Abs(base.mostOptimalDistance - Vector3.Distance(((Component)this).transform.position, ((Component)targetPlayer).transform.position)) < bufferDistance)
			{
				base.targetPlayer = targetPlayer;
			}
			return (Object)(object)base.targetPlayer != (Object)null;
		}

		public override void KillEnemy(bool destroy = false)
		{
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			Plugin.log("In KillEnemy()");
			if ((Object)(object)KnifeScript.thrownKnifeScript != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)KnifeScript.thrownKnifeScript).gameObject);
				KnifeScript.thrownKnifeScript = null;
			}
			MakeKnifeInvisible();
			if (Plugin.IsServerOrHost && !base.daytimeEnemyLeaving)
			{
				YulemanKnifeBehavior componentInChildren = Object.Instantiate<GameObject>(YulemanKnifePrefab, RightHandTransform.position, Quaternion.identity, StartOfRound.Instance.propsContainer).GetComponentInChildren<YulemanKnifeBehavior>();
				((NetworkBehaviour)componentInChildren).NetworkObject.Spawn(false);
				int value = Random.Range(Plugin.configKnifeMinValue.Value, Plugin.configKnifeMaxValue.Value + 1);
				SetKnifeValueClientRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)componentInChildren).NetworkObject), value);
				ChildSackBehavior componentInChildren2 = Object.Instantiate<GameObject>(ChildSackPrefab, RightHandTransform.position, Quaternion.identity, StartOfRound.Instance.propsContainer).GetComponentInChildren<ChildSackBehavior>();
				((NetworkBehaviour)componentInChildren2).NetworkObject.Spawn(false);
				int value2 = Random.Range(Plugin.configSackMinValue.Value, Plugin.configSackMaxValue.Value + 1);
				SetSackValueClientRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)componentInChildren2).NetworkObject), value2);
			}
			((EnemyAI)this).KillEnemy(destroy);
		}

		public override void HitEnemy(int force = 0, PlayerControllerB playerWhoHit = null, bool playHitSFX = true, int hitID = -1)
		{
			Plugin.log("In HitEnemy()");
			if (base.isEnemyDead)
			{
				Plugin.log("Yuleman is dead");
				return;
			}
			base.enemyHP -= force;
			if (base.enemyHP <= 0)
			{
				((EnemyAI)this).KillEnemyOnOwnerClient(false);
			}
			else if ((Object)(object)base.inSpecialAnimationWithPlayer != (Object)null)
			{
				timesHitWhileAbducting++;
				Plugin.log($"Yuleman hit {timesHitWhileAbducting} times");
				if (timesHitWhileAbducting >= Plugin.configHitAmountToDropPlayer.Value)
				{
					timesHitWhileAbducting = 0;
					Plugin.log("Dropping player in sack");
					((EnemyAI)this).CancelSpecialAnimationWithPlayer();
					base.inSpecialAnimation = true;
					base.creatureAnimator.SetTrigger("roar");
					isAngry = true;
					((EnemyAI)this).SwitchToBehaviourStateOnLocalClient(1);
				}
			}
		}

		public override void OnCollideWithPlayer(Collider other)
		{
			((EnemyAI)this).OnCollideWithPlayer(other);
			if (base.isEnemyDead || timeSinceDamagePlayer < 3f || base.inSpecialAnimation)
			{
				return;
			}
			PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
			if ((Object)(object)component == (Object)null || !PlayerIsTargetable(component) || (Object)(object)component != (Object)(object)Plugin.localPlayer || ((Object)(object)base.inSpecialAnimationWithPlayer != (Object)null && (Object)(object)base.inSpecialAnimationWithPlayer == (Object)(object)component))
			{
				return;
			}
			timeSinceDamagePlayer = 0f;
			if (Plugin.IsPlayerChild(component) && timeSinceGrabPlayer > 10f && !isPlayerInSack && !isGrabbingPlayer && !KnifeScript.isThrown && !callingKnifeBack && !teleporting)
			{
				timeSinceGrabPlayer = 0f;
				base.inSpecialAnimation = true;
				component.DropAllHeldItemsAndSync();
				Plugin.FreezePlayer(component, value: true);
				GrabPlayerServerRpc(component.actualClientId);
			}
			else
			{
				if (!KnifeScript.isThrown)
				{
					DoAnimationServerRpc("slash");
				}
				else
				{
					DoAnimationServerRpc("slap");
				}
				Plugin.log("Finished OnCollideWithPlayer()");
			}
		}

		public override void CancelSpecialAnimationWithPlayer()
		{
			Plugin.log("In CancelSpecialAnimationWithPlayer()");
			if (isPlayerInSack)
			{
				((Component)base.inSpecialAnimationWithPlayer.playerCollider).gameObject.SetActive(true);
				base.inSpecialAnimationWithPlayer.voiceMuffledByEnemy = false;
				Plugin.MakePlayerInvisible(base.inSpecialAnimationWithPlayer, value: false);
				base.creatureAnimator.SetBool("bagWalk", false);
				if ((Object)(object)Plugin.localPlayer == (Object)(object)base.inSpecialAnimationWithPlayer)
				{
					Plugin.PluginInstance.BlackScreenOverlay.SetActive(false);
				}
			}
			if ((Object)(object)Plugin.localPlayer == (Object)(object)base.inSpecialAnimationWithPlayer)
			{
				Plugin.FreezePlayer(Plugin.localPlayer, value: false);
				((MonoBehaviour)this).StartCoroutine(NetworkHandlerSCP4666.Instance.AllowPlayerDeathAfterDelay(5f));
			}
			if ((Object)(object)base.inSpecialAnimationWithPlayer != (Object)null)
			{
				((Component)base.inSpecialAnimationWithPlayer).transform.SetParent((Transform)null);
			}
			isGrabbingPlayer = false;
			isPlayerInSack = false;
			timesHitWhileAbducting = 0;
			timeSinceGrabPlayer = 0f;
			timeSinceDamagePlayer = 0f;
			timeSinceKnifeThrown = 0f;
			timeSinceTeleport = 0f;
			((EnemyAI)this).CancelSpecialAnimationWithPlayer();
			Plugin.log("Finished CancelSpecialAnimationWithPlayer()");
		}

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

		public void DoSlashDamageAnimation()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: 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_00e9: 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)
			PlayerControllerB localPlayer = Plugin.localPlayer;
			if (!((Object)(object)localPlayer == (Object)null) && PlayerIsTargetable(localPlayer) && !(Vector3.Distance(RightHandTransform.position, ((Component)localPlayer).transform.position) > attackRange))
			{
				Vector3 val = ((Component)localPlayer).transform.position - ((Component)this).transform.position;
				Vector3 normalized = ((Vector3)(ref val)).normalized;
				float num = Vector3.Dot(((Component)this).transform.forward, normalized);
				float num2 = Mathf.Acos(num) * 57.29578f;
				if (num2 <= attackAngle)
				{
					Plugin.log("Damaging " + localPlayer.playerUsername);
					int num3 = ((Random.Range(0, 2) == 1) ? 7 : 0);
					int value = Plugin.configSliceDamage.Value;
					val = default(Vector3);
					localPlayer.DamagePlayer(value, true, true, (CauseOfDeath)14, num3, false, val);
				}
			}
		}

		public void DoSlapDamageAnimation()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: 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_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB localPlayer = Plugin.localPlayer;
			if (!((Object)(object)localPlayer == (Object)null) && PlayerIsTargetable(localPlayer) && !(Vector3.Distance(RightHandTransform.position, ((Component)localPlayer).transform.position) > attackRange))
			{
				Vector3 val = ((Component)localPlayer).transform.position - ((Component)this).transform.position;
				Vector3 normalized = ((Vector3)(ref val)).normalized;
				float num = Vector3.Dot(((Component)this).transform.forward, normalized);
				float num2 = Mathf.Acos(num) * 57.29578f;
				if (num2 <= attackAngle)
				{
					Plugin.log("Damaging " + localPlayer.playerUsername);
					localPlayer.DamagePlayer(Plugin.configSlapDamage.Value, true, true, (CauseOfDeath)6, 0, false, ((Component)this).transform.position + ((Component)this).transform.forward * 5f);
				}
			}
		}

		public void SetInSpecialAnimation()
		{
			base.inSpecialAnimation = true;
		}

		public void UnsetInSpecialAnimation()
		{
			base.inSpecialAnimation = false;
		}

		public void CallKnifeBack()
		{
			base.inSpecialAnimation = true;
			Plugin.log("CallKnifeBack() called");
			KnifeScript.CallKnife();
		}

		public void CheckForKnife()
		{
			Plugin.log("CheckForKnife() called");
			callingKnifeBack = false;
			GrabKnife();
		}

		public void GrabKnife()
		{
			Plugin.log("GrabKnife() called");
			timeSinceKnifeThrown = 0f;
			MakeKnifeVisible();
			isAngry = false;
			Plugin.log("Grabbed knife");
		}

		public void ThrowKnife()
		{
			Plugin.log("ThrowKnife() called");
			if (!KnifeScript.isThrown)
			{
				MakeKnifeInvisible();
				if (Plugin.IsServerOrHost)
				{
					ThrowKnifeClientRpc(base.targetPlayer.actualClientId);
				}
			}
		}

		public void MakeKnifeVisible()
		{
			Plugin.log("MakeKnifeVisible() called");
			KnifeScript.MakeKnifeVisible(value: true);
		}

		public void MakeKnifeInvisible()
		{
			Plugin.log("MakeKnifeInvisible() called");
			KnifeScript.MakeKnifeVisible(value: false);
		}

		public void PlayRoarSFX()
		{
			base.creatureVoice.PlayOneShot(RoarSFX);
		}

		public void PlayFootstepSFX()
		{
			base.creatureSFX.PlayOneShot(FootstepSFX);
		}

		public void GrabPlayer()
		{
			Plugin.log("GrabPlayer() called");
			if ((Object)(object)base.inSpecialAnimationWithPlayer == (Object)null)
			{
				logger.LogError((object)"inSpecialAnimationWithPlayer is null in GrabPlayer()");
				return;
			}
			base.inSpecialAnimation = true;
			((Component)base.inSpecialAnimationWithPlayer).transform.SetParent(RightHandTransform);
			isGrabbingPlayer = true;
		}

		public void PutPlayerInSack()
		{
			Plugin.log("PutPlayerInSack() called");
			base.inSpecialAnimation = false;
			isGrabbingPlayer = false;
			if ((Object)(object)base.inSpecialAnimationWithPlayer == (Object)null)
			{
				logger.LogError((object)"inSpecialAnimationWithPlayer is null in PutPlayerInSack()");
				return;
			}
			TargetPlayers.Remove(base.inSpecialAnimationWithPlayer);
			((Component)base.inSpecialAnimationWithPlayer).transform.SetParent(ChildSackTransform);
			isPlayerInSack = true;
			base.creatureVoice.PlayOneShot(LaughSFX);
			base.creatureAnimator.SetBool("bagWalk", true);
			if ((Object)(object)Plugin.localPlayer == (Object)(object)base.inSpecialAnimationWithPlayer)
			{
				Plugin.PluginInstance.BlackScreenOverlay.SetActive(true);
				StartOfRound.Instance.allowLocalPlayerDeath = false;
			}
			Plugin.MakePlayerInvisible(base.inSpecialAnimationWithPlayer, value: true);
			base.inSpecialAnimationWithPlayer.voiceMuffledByEnemy = true;
			((Component)base.inSpecialAnimationWithPlayer.playerCollider).gameObject.SetActive(false);
			((EnemyAI)this).SwitchToBehaviourStateOnLocalClient(2);
			Plugin.log(base.inSpecialAnimationWithPlayer.playerUsername + " put in yulemans sack");
		}

		public void FinishStartAnimation()
		{
			Plugin.log("In FinishStartAnimation()");
			if (Plugin.IsServerOrHost)
			{
				((EnemyAI)this).SwitchToBehaviourClientRpc(1);
			}
			base.inSpecialAnimation = false;
		}

		[ClientRpc]
		public void BecomeVisibleClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(4110616792u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4110616792u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					spawnedAndVisible = true;
					YulemanMesh.SetActive(true);
				}
			}
		}

		[ClientRpc]
		public void ThrowKnifeClientRpc(ulong clientId)
		{
			//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_00d8: 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_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(649542142u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, clientId);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 649542142u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					PlayerControllerB val3 = Plugin.PlayerFromId(clientId);
					Vector3 val4 = val3.bodyParts[5].position - RightHandTransform.position;
					Vector3 normalized = ((Vector3)(ref val4)).normalized;
					KnifeScript.ThrowKnife(normalized);
					Plugin.log("Knife was thrown");
				}
			}
		}

		[ClientRpc]
		public void KillPlayerInSackClientRpc()
		{
			//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_010f: 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_011f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3891888412u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3891888412u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			Plugin.log("In KillPlayerInSackClientRpc()");
			if ((Object)(object)base.inSpecialAnimationWithPlayer == (Object)null)
			{
				logger.LogError((object)"inSpecialAnimationWithPlayer is null in KillPlayerInSackClientRpc()");
				return;
			}
			PlayerControllerB inSpecialAnimationWithPlayer = base.inSpecialAnimationWithPlayer;
			((EnemyAI)this).CancelSpecialAnimationWithPlayer();
			if (!((Object)(object)Plugin.localPlayer != (Object)(object)inSpecialAnimationWithPlayer))
			{
				Plugin.localPlayer.KillPlayer(Vector3.zero, false, (CauseOfDeath)0, 0, default(Vector3));
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void DoAnimationServerRpc(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_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 = ((NetworkBehaviour)this).__beginSendServerRpc(3294425755u, 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).__endSendServerRpc(ref val2, 3294425755u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost) && Plugin.IsServerOrHost)
			{
				Plugin.log("Doing " + animationName + " animation");
				networkAnimator.SetTrigger(animationName);
			}
		}

		[ClientRpc]
		public void PlayTeleportSFXClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2328258430u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2328258430u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					base.creatureVoice.PlayOneShot(TeleportSFX);
				}
			}
		}

		[ClientRpc]
		public void PlayLaughSFXClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(4132615531u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4132615531u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					base.creatureVoice.PlayOneShot(LaughSFX);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void GrabPlayerServerRpc(ulong clientId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2974407871u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, clientId);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2974407871u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost) && Plugin.IsServerOrHost)
				{
					base.inSpecialAnimation = true;
					base.inSpecialAnimationWithPlayer = Plugin.PlayerFromId(clientId);
					GrabPlayerClientRpc(clientId);
				}
			}
		}

		[ClientRpc]
		public void GrabPlayerClientRpc(ulong clientId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(54373338u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, clientId);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 54373338u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					base.inSpecialAnimation = true;
					base.inSpecialAnimationWithPlayer = Plugin.PlayerFromId(clientId);
					base.inSpecialAnimationWithPlayer.inSpecialInteractAnimation = true;
					base.inSpecialAnimationWithPlayer.snapToServerPosition = true;
					base.inSpecialAnimationWithPlayer.inAnimationWithEnemy = (EnemyAI)(object)this;
					base.creatureAnimator.SetTrigger("grabPlayer");
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void AddTargetPlayerServerRpc(ulong clientId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3872295241u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, clientId);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3872295241u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost) || !Plugin.IsServerOrHost)
			{
				return;
			}
			PlayerControllerB val3 = Plugin.PlayerFromId(clientId);
			if (base.currentBehaviourStateIndex == 0)
			{
				networkAnimator.SetTrigger("start");
			}
			if (!TargetPlayers.Contains(val3))
			{
				TargetPlayers.Add(val3);
				if (base.currentBehaviourStateIndex == 2)
				{
					((EnemyAI)this).SwitchToBehaviourClientRpc(1);
				}
				Plugin.log("Added " + val3.playerUsername + " to targeted players");
			}
		}

		[ClientRpc]
		public void SetEnemyOutsideClientRpc(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_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_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(88723183u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref value, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 88723183u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					((EnemyAI)this).SetEnemyOutside(value);
					((Component)this).transform.localScale = (value ? outsideScale : insideScale);
				}
			}
		}

		[ClientRpc]
		public void SetKnifeValueClientRpc(NetworkObjectReference netRef, int value)
		{
			//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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(118440067u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref netRef, default(ForNetworkSerializable));
					BytePacker.WriteValueBitPacked(val2, value);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 118440067u, val, (RpcDelivery)0);
				}
				NetworkObject val3 = default(NetworkObject);
				YulemanKnifeBehavior yulemanKnifeBehavior = default(YulemanKnifeBehavior);
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && ((NetworkObjectReference)(ref netRef)).TryGet(ref val3, (NetworkManager)null) && ((Component)val3).TryGetComponent<YulemanKnifeBehavior>(ref yulemanKnifeBehavior))
				{
					((GrabbableObject)yulemanKnifeBehavior).SetScrapValue(value);
					((GrabbableObject)yulemanKnifeBehavior).FallToGround(false);
				}
			}
		}

		[ClientRpc]
		public void SetSackValueClientRpc(NetworkObjectReference netRef, int value)
		{
			//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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1202075019u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref netRef, default(ForNetworkSerializable));
					BytePacker.WriteValueBitPacked(val2, value);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1202075019u, val, (RpcDelivery)0);
				}
				NetworkObject val3 = default(NetworkObject);
				ChildSackBehavior childSackBehavior = default(ChildSackBehavior);
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && ((NetworkObjectReference)(ref netRef)).TryGet(ref val3, (NetworkManager)null) && ((Component)val3).TryGetComponent<ChildSackBehavior>(ref childSackBehavior))
				{
					((GrabbableObject)childSackBehavior).SetScrapValue(value);
					((GrabbableObject)childSackBehavior).FallToGround(false);
				}
			}
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_SCP4666AI()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_007d