Decompiled source of SCP4666 v1.2.0

plugins/ProjectSCP.SCP4666.dll

Decompiled 2 weeks 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.Logging;
using Dawn;
using Dawn.Utils;
using Dusk;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using PSCPLibrary;
using PSCPLibrary.Interfaces;
using ProjectSCP.SCP4666.NetcodePatcher;
using SCP4666.Enemies;
using SCP4666.Items;
using SnowyLib;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Events;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ClientNetworkTransform")]
[assembly: IgnoresAccessChecksTo("com.olegknyazev.softmask")]
[assembly: IgnoresAccessChecksTo("DissonanceVoip")]
[assembly: IgnoresAccessChecksTo("DunGen")]
[assembly: IgnoresAccessChecksTo("DunGen.Integration.ASPP")]
[assembly: IgnoresAccessChecksTo("DunGen.Integration.UnityNav")]
[assembly: IgnoresAccessChecksTo("EasyTextEffects")]
[assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Jobs")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")]
[assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")]
[assembly: IgnoresAccessChecksTo("Unity.Services.QoS")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Relay")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.XR.CoreUtils")]
[assembly: IgnoresAccessChecksTo("Unity.XR.Management")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.ConformanceAutomation")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.MetaQuestSupport")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.MockRuntime")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.OculusQuestSupport")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.RuntimeDebugger")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.SpatialTracking")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: IgnoresAccessChecksTo("UnityEngine.XR.LegacyInputHelpers")]
[assembly: AssemblyCompany("ProjectSCP.SCP4666")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: AssemblyInformationalVersion("1.2.0+22f0e00cd348a5dc69f58aeae5db723d46130961")]
[assembly: AssemblyProduct("SCP4666")]
[assembly: AssemblyTitle("ProjectSCP.SCP4666")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[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]
	[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
{
	[BepInPlugin("ProjectSCP.SCP4666", "SCP4666", "1.2.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		private readonly Harmony harmony = new Harmony("ProjectSCP.SCP4666");

		public static Plugin PluginInstance { get; private set; }

		public static ManualLogSource logger { get; private set; }

		public static DuskMod Mod { get; private set; }

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

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

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

		private void Awake()
		{
			if ((Object)(object)PluginInstance == (Object)null)
			{
				PluginInstance = this;
			}
			logger = ((BaseUnityPlugin)PluginInstance).Logger;
			harmony.PatchAll();
			AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "scp4666_mainassets"));
			Mod = DuskMod.RegisterMod((BaseUnityPlugin)(object)this, val);
			Mod.RegisterContentHandlers();
			SCPInfo val2 = ContentHandler<SCP4666ContentHandler>.Instance.SCP4666?.SCPInfo;
			if ((Object)(object)val2 != (Object)null)
			{
				SCPAPI.Register(val2);
			}
			InitializeNetworkBehaviours();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"ProjectSCP.SCP4666 v1.2.0 has loaded!");
		}

		private static void InitializeNetworkBehaviours()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
			logger.LogDebug((object)"Finished initializing network behaviours");
		}
	}
	public class SCP4666ContentHandler : ContentHandler<SCP4666ContentHandler>
	{
		public class SCP4666Assets : AssetBundleLoader<SCP4666Assets>
		{
			[LoadFromBundle("SCP4666Info.asset")]
			public SCPInfo SCPInfo { get; private set; } = null;

			[LoadFromBundle("EvilFleshDoll.prefab")]
			public GameObject EvilFleshDollPrefab { get; private set; } = null;

			public SCP4666Assets(DuskMod mod, string filePath)
				: base(mod, filePath)
			{
			}
		}

		public class ChildSackAssets : AssetBundleLoader<ChildSackAssets>
		{
			public ChildSackAssets(DuskMod mod, string filePath)
				: base(mod, filePath)
			{
			}
		}

		public class FleshDollAssets : AssetBundleLoader<FleshDollAssets>
		{
			public FleshDollAssets(DuskMod mod, string filePath)
				: base(mod, filePath)
			{
			}
		}

		public class YulemanKnifeAssets : AssetBundleLoader<YulemanKnifeAssets>
		{
			public YulemanKnifeAssets(DuskMod mod, string filePath)
				: base(mod, filePath)
			{
			}
		}

		public SCP4666Assets? SCP4666;

		public ChildSackAssets? ChildSack;

		public FleshDollAssets? FleshDoll;

		public YulemanKnifeAssets? YulemanKnife;

		public SCP4666ContentHandler(DuskMod mod)
			: base(mod)
		{
			((ContentHandler)this).RegisterContent<SCP4666Assets>("scp4666", ref SCP4666, false);
			((ContentHandler)this).RegisterContent<ChildSackAssets>("child_sack", ref ChildSack, false);
			((ContentHandler)this).RegisterContent<FleshDollAssets>("flesh_doll", ref FleshDoll, false);
			((ContentHandler)this).RegisterContent<YulemanKnifeAssets>("yuleman_knife", ref YulemanKnife, false);
		}
	}
	public static class SCP4666Keys
	{
		public const string Namespace = "scpfoursixsixsix";

		internal static NamespacedKey LastVersion = NamespacedKey.From("scpfoursixsixsix", "last_version");

		public static readonly NamespacedKey<DawnEnemyInfo> SCP4666 = NamespacedKey<DawnEnemyInfo>.From("scpfoursixsixsix", "scpfoursixsixsix");

		public static readonly NamespacedKey<DawnItemInfo> ChildSack = NamespacedKey<DawnItemInfo>.From("scpfoursixsixsix", "child_sack");

		public static readonly NamespacedKey<DawnItemInfo> FleshDoll = NamespacedKey<DawnItemInfo>.From("scpfoursixsixsix", "flesh_doll");

		public static readonly NamespacedKey<DawnItemInfo> YulemanKnife = NamespacedKey<DawnItemInfo>.From("scpfoursixsixsix", "yuleman_knife");
	}
	[HarmonyPatch]
	public static class TESTING
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(HUDManager), "PingScan_performed")]
		public static void PingScan_performedPostFix()
		{
			if (Utils.testing)
			{
			}
		}

		[StaticUpdate]
		public static void Update()
		{
			if (Utils.testing)
			{
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(HUDManager), "SubmitChat_performed")]
		public static void SubmitChat_performedPrefix(HUDManager __instance)
		{
			//IL_0069: 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_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (Utils.testing && Plugin.IsServerOrHost)
				{
					string text = __instance.chatTextField.text;
					string[] array = text.Split(" ");
					string text2 = array[0];
					string text3 = text2;
					if (text3 == "/spawndoll")
					{
						GameObject val = Object.Instantiate<GameObject>(ContentHandler<SCP4666ContentHandler>.Instance.SCP4666.EvilFleshDollPrefab, ((Component)Plugin.localPlayer).transform.position + ((Component)Plugin.localPlayer).transform.forward, Quaternion.identity);
						val.GetComponent<NetworkObject>().Spawn(false);
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.logger.LogError((object)ex);
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "ProjectSCP.SCP4666";

		public const string PLUGIN_NAME = "SCP4666";

		public const string PLUGIN_VERSION = "1.2.0";
	}
}
namespace SCP4666.Items
{
	public class ChildSackBehavior : PhysicsProp
	{
		public static bool localPlayerSizeChangedFromSack;

		private const float minSize = 0.6f;

		private const float maxSize = 0.8f;

		private const bool allowManualActivation = true;

		public const bool activateOnTeamWipe = true;

		private const bool shrinkPlayerOnRevive = false;

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

		public override void Start()
		{
			((GrabbableObject)this).Start();
			Instances.Add(this);
		}

		public override void OnDestroy()
		{
			Instances.Remove(this);
			((GrabbableObject)this).OnDestroy();
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			if (buttonDown)
			{
				((GrabbableObject)this).playerHeldBy.DiscardHeldObject(false, (NetworkObject)null, default(Vector3), true);
				ActivateServerRpc();
			}
		}

		public void Activate(float delay = 0f)
		{
			if (((NetworkBehaviour)this).IsServer)
			{
				((MonoBehaviour)this).StartCoroutine(ActivateCoroutine(delay));
			}
			IEnumerator ActivateCoroutine(float num)
			{
				yield return null;
				yield return (object)new WaitForSeconds(num);
				int playersRespawned = 0;
				PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
				foreach (PlayerControllerB player in allPlayerScripts)
				{
					if (player.isPlayerDead && !player.isPlayerControlled)
					{
						if (playersRespawned == 0)
						{
							DoALotOfShitToRevivePlayerClientRpc(playerSize: Random.Range(0.6f, 0.8f), clientId: player.actualClientId);
							playersRespawned++;
						}
						else if (Random.Range(0, 2) == 0)
						{
							DoALotOfShitToRevivePlayerClientRpc(playerSize: Random.Range(0.6f, 0.8f), clientId: player.actualClientId);
							playersRespawned++;
						}
						else
						{
							Utils.SpawnItem(ItemKeys.Gift, ((Component)this).transform.position, default(Quaternion), (Transform)null, false);
						}
					}
				}
				((NetworkBehaviour)this).NetworkObject.Despawn(true);
			}
		}

		public static void OnPlayerDeath(PlayerControllerB player)
		{
			try
			{
				if (localPlayerSizeChangedFromSack)
				{
					Plugin.logger.LogDebug((object)"Changing player size back to default size");
					localPlayerSizeChangedFromSack = false;
					NetworkHandler.Instance.ChangePlayerSizeRpc(player.actualClientId, 1f);
				}
			}
			catch (Exception ex)
			{
				Plugin.logger.LogError((object)ex);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void ActivateServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val2 = default(ServerRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(1407334342u, val2, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendServerRpc(ref val, 1407334342u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				if (((NetworkBehaviour)this).IsServer)
				{
					Activate();
				}
			}
		}

		[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_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02da: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val2 = default(ClientRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(1510416635u, val2, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val, clientId);
				((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref playerSize, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 1510416635u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			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.logger.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);
			bool flag = true;
		}

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

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(1407334342u, new RpcReceiveHandler(__rpc_handler_1407334342), "ActivateServerRpc");
			((NetworkBehaviour)this).__registerRpc(1510416635u, new RpcReceiveHandler(__rpc_handler_1510416635), "DoALotOfShitToRevivePlayerClientRpc");
			((PhysicsProp)this).__initializeRpcs();
		}

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

		private static void __rpc_handler_1510416635(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)1;
				((ChildSackBehavior)(object)target).DoALotOfShitToRevivePlayerClientRpc(clientId, playerSize);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "ChildSackBehavior";
		}
	}
	[HarmonyPatch]
	internal static class ChildSackPatches
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerControllerB), "KillPlayer")]
		public static void KillPlayerPostfix(PlayerControllerB __instance)
		{
			ChildSackBehavior.OnPlayerDeath(__instance);
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(StartOfRound), "ShipLeaveAutomatically")]
		public static bool ShipLeaveAutomaticallyPrefix(bool leavingOnMidnight)
		{
			try
			{
				if (leavingOnMidnight)
				{
					return true;
				}
				Plugin.logger.LogDebug((object)"Ship trying to leave automatically.");
				ChildSackBehavior childSackBehavior = (from x in Object.FindObjectsOfType<ChildSackBehavior>()
					where ((GrabbableObject)x).isInShipRoom
					select x).FirstOrDefault();
				if ((Object)(object)childSackBehavior == (Object)null)
				{
					return true;
				}
				Plugin.logger.LogDebug((object)"Sack found, attempting to stop ship leave and revive players");
				StartOfRound.Instance.allPlayersDead = false;
				if (!Plugin.IsServerOrHost)
				{
					return false;
				}
				childSackBehavior.Activate();
				return false;
			}
			catch (Exception ex)
			{
				Plugin.logger.LogError((object)ex);
				return true;
			}
		}
	}
	public class FleshDollBehavior : PhysicsProp
	{
		public SmartAgentNavigator nav = null;

		public Transform holdItemPosition = null;

		public Collider collider = null;

		public Animator animator = null;

		public AnimationCurve grenadeFallCurve = null;

		public AnimationCurve grenadeVerticalFallCurveNoBounce = null;

		public AnimationCurve grenadeVerticalFallCurve = null;

		public static HashSet<FleshDollBehavior> Instances = new HashSet<FleshDollBehavior>();

		public Vector3 destination;

		private const float AIIntervalTime = 0.2f;

		private float timeSinceIntervalUpdate;

		private GrabbableObject? heldObject;

		private bool isThrown;

		private bool landing;

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

		private Ray grenadeThrowRay;

		private RaycastHit grenadeHit;

		private const int stunGrenadeMask = 268437761;

		private Vector3 shipNode;

		private PlayerControllerB? previousPlayerHeldBy;

		private int hashSpeed;

		private int hashCarrying;

		private int hashSit;

		private float currentSpeed;

		private Vector3 lastPosition;

		private bool isOutside => nav.IsAgentOutside();

		private bool isInsideFactory => !isOutside;

		public override void Start()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).Start();
			Instances.Add(this);
			nav.SetAllValues(Vector3Extensions.IsOutside(((Component)this).transform.position));
			hashSpeed = Animator.StringToHash("speed");
			hashCarrying = Animator.StringToHash("carrying");
			hashSit = Animator.StringToHash("sit");
		}

		public override void OnDestroy()
		{
			Instances.Remove(this);
			((GrabbableObject)this).OnDestroy();
		}

		public override void Update()
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)heldObject != (Object)null && (Object)(object)heldObject.playerHeldBy != (Object)null && ((NetworkBehaviour)this).IsServer)
			{
				nav.StopAgent();
				DropItemClientRpc(((Component)this).transform.position);
			}
			if ((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null)
			{
				previousPlayerHeldBy = ((GrabbableObject)this).playerHeldBy;
				nav.SetAllValues(!((GrabbableObject)this).playerHeldBy.isInsideFactory);
			}
			if (((GrabbableObject)this).isHeld || ((GrabbableObject)this).isHeldByEnemy || !((GrabbableObject)this).reachedFloorTarget || ((GrabbableObject)this).fallTime < 1f || ((GrabbableObject)this).isInElevator)
			{
				((GrabbableObject)this).Update();
			}
			else if (((NetworkBehaviour)this).IsServer)
			{
				timeSinceIntervalUpdate += Time.deltaTime;
				if (timeSinceIntervalUpdate > 0.2f)
				{
					timeSinceIntervalUpdate = 0f;
					DoAIInterval();
				}
			}
		}

		public void DoAIInterval()
		{
			//IL_0037: 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_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			((Behaviour)nav.agent).enabled = (Object)(object)heldObject != (Object)null;
			if (!((Object)(object)heldObject == (Object)null))
			{
				if (Vector3.Distance(((Component)this).transform.position, shipNode) < 1f)
				{
					nav.StopAgent();
					DropItemClientRpc(((Component)this).transform.position);
				}
				else
				{
					nav.DoPathingToDestination(shipNode);
				}
			}
		}

		public void RepositionAgent()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			Vector3 navMeshPosition = RoundManager.Instance.GetNavMeshPosition(((Component)this).transform.position, RoundManager.Instance.navHit, 5f, -1);
			nav.agent.Warp(navMeshPosition);
			if (!((Object)(object)previousPlayerHeldBy == (Object)null))
			{
				nav.SetAllValues(!previousPlayerHeldBy.isInsideFactory);
			}
		}

		public override void LateUpdate()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: 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_006f: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)((GrabbableObject)this).parentObject != (Object)null)
			{
				((Component)this).transform.rotation = ((GrabbableObject)this).parentObject.rotation;
				((Component)this).transform.Rotate(((GrabbableObject)this).itemProperties.rotationOffset);
				((Component)this).transform.position = ((GrabbableObject)this).parentObject.position;
				Vector3 positionOffset = ((GrabbableObject)this).itemProperties.positionOffset;
				positionOffset = ((GrabbableObject)this).parentObject.rotation * positionOffset;
				Transform transform = ((Component)this).transform;
				transform.position += positionOffset;
			}
			if ((Object)(object)((GrabbableObject)this).radarIcon != (Object)null)
			{
				((GrabbableObject)this).radarIcon.position = ((Component)this).transform.position;
			}
			if ((Object)(object)heldObject != (Object)null)
			{
				((Component)heldObject).transform.position = holdItemPosition.position;
			}
			if (isThrown && (double)((GrabbableObject)this).fallTime > 0.75 && !landing)
			{
				landing = true;
				animator.SetTrigger("land");
			}
			Vector3 val = ((Component)this).transform.position - lastPosition;
			currentSpeed = ((Vector3)(ref val)).magnitude / Time.deltaTime;
			lastPosition = ((Component)this).transform.position;
			animator.SetFloat(hashSpeed, currentSpeed);
			animator.SetBool(hashSit, ((GrabbableObject)this).isHeldByEnemy);
			animator.SetBool(hashCarrying, (Object)(object)heldObject != (Object)null);
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			if (buttonDown)
			{
				ItemActivateRpc();
			}
		}

		public Vector3 GetGrenadeThrowDestination()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: 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_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: 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_008e: 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_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = ((Component)this).transform.position;
			grenadeThrowRay = new Ray(((Component)((GrabbableObject)this).playerHeldBy.gameplayCamera).transform.position, ((Component)((GrabbableObject)this).playerHeldBy.gameplayCamera).transform.forward);
			position = ((!Physics.Raycast(grenadeThrowRay, ref grenadeHit, 12f, 268437761, (QueryTriggerInteraction)1)) ? ((Ray)(ref grenadeThrowRay)).GetPoint(10f) : ((Ray)(ref grenadeThrowRay)).GetPoint(((RaycastHit)(ref grenadeHit)).distance - 0.05f));
			grenadeThrowRay = new Ray(position, Vector3.down);
			if (Physics.Raycast(grenadeThrowRay, ref grenadeHit, 30f, 268437761, (QueryTriggerInteraction)1))
			{
				return ((RaycastHit)(ref grenadeHit)).point + Vector3.up * 0.05f;
			}
			return ((Ray)(ref grenadeThrowRay)).GetPoint(30f);
		}

		public override void FallWithCurve()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: 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_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: 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_012e: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = ((GrabbableObject)this).startFallingPosition - ((GrabbableObject)this).targetFloorPosition;
			float magnitude = ((Vector3)(ref val)).magnitude;
			((Component)this).transform.rotation = Quaternion.Lerp(((Component)this).transform.rotation, Quaternion.Euler(((GrabbableObject)this).itemProperties.restingRotation.x, ((Component)this).transform.eulerAngles.y, ((GrabbableObject)this).itemProperties.restingRotation.z), 14f * Time.deltaTime / magnitude);
			((Component)this).transform.localPosition = Vector3.Lerp(((GrabbableObject)this).startFallingPosition, ((GrabbableObject)this).targetFloorPosition, grenadeFallCurve.Evaluate(((GrabbableObject)this).fallTime));
			if (magnitude > 5f)
			{
				((Component)this).transform.localPosition = Vector3.Lerp(new Vector3(((Component)this).transform.localPosition.x, ((GrabbableObject)this).startFallingPosition.y, ((Component)this).transform.localPosition.z), new Vector3(((Component)this).transform.localPosition.x, ((GrabbableObject)this).targetFloorPosition.y, ((Component)this).transform.localPosition.z), grenadeVerticalFallCurveNoBounce.Evaluate(((GrabbableObject)this).fallTime));
			}
			else
			{
				((Component)this).transform.localPosition = Vector3.Lerp(new Vector3(((Component)this).transform.localPosition.x, ((GrabbableObject)this).startFallingPosition.y, ((Component)this).transform.localPosition.z), new Vector3(((Component)this).transform.localPosition.x, ((GrabbableObject)this).targetFloorPosition.y, ((Component)this).transform.localPosition.z), grenadeVerticalFallCurve.Evaluate(((GrabbableObject)this).fallTime));
			}
			((GrabbableObject)this).fallTime = ((GrabbableObject)this).fallTime + Mathf.Abs(Time.deltaTime * 12f / magnitude);
		}

		public override void OnHitGround()
		{
			//IL_0067: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			Plugin.logger.LogDebug((object)"OnHitGround");
			if (((NetworkBehaviour)this).IsServer && isThrown && StartOfRound.Instance.shipHasLanded)
			{
				heldObject = GetClosestItem(1f);
				if ((Object)(object)heldObject != (Object)null)
				{
					shipNode = RoundManager.Instance.GetNavMeshPosition(StartOfRound.Instance.insideShipPositions[5].position, RoundManager.Instance.navHit, 5f, -1);
					GrabItemClientRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)heldObject).NetworkObject));
				}
			}
			landing = false;
			isThrown = false;
		}

		private GrabbableObject? GetClosestItem(float maxDistance)
		{
			//IL_005c: 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_00e3: 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)
			float num = maxDistance;
			GrabbableObject val = null;
			GrabbableObject[] array = Object.FindObjectsOfType<GrabbableObject>();
			foreach (GrabbableObject val2 in array)
			{
				if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val2 == (Object)(object)this) && val2.grabbable && val2.grabbableToEnemies && !((GrabbableObject)this).isHeld && !((GrabbableObject)this).isHeldByEnemy)
				{
					float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)val2).transform.position);
					if (num2 < num)
					{
						num = num2;
						val = val2;
					}
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				foreach (FleshDollBehavior instance in Instances)
				{
					if (!((Object)(object)instance == (Object)null) && !((Object)(object)instance == (Object)(object)this))
					{
						float num3 = Vector3.Distance(((Component)this).transform.position, ((Component)instance).transform.position);
						if (num3 < num)
						{
							num = num3;
							val = (GrabbableObject)(object)instance;
						}
					}
				}
			}
			return val;
		}

		[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_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val2 = default(ServerRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(1582171592u, val2, (RpcDelivery)0);
				bool flag = animationName != null;
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val)).WriteValueSafe(animationName, false);
				}
				((NetworkBehaviour)this).__endSendServerRpc(ref val, 1582171592u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				if (((NetworkBehaviour)this).IsServer)
				{
					DoAnimationClientRpc(animationName);
				}
			}
		}

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

		[ClientRpc]
		public void GrabItemClientRpc(NetworkObjectReference netRef)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val2 = default(ClientRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(1331613493u, val2, (RpcDelivery)0);
				((FastBufferWriter)(ref val)).WriteValueSafe<NetworkObjectReference>(ref netRef, default(ForNetworkSerializable));
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 1331613493u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			if (!((Object)(object)heldObject != (Object)null))
			{
				NetworkObject val3 = default(NetworkObject);
				if (!((NetworkObjectReference)(ref netRef)).TryGet(ref val3, (NetworkManager)null))
				{
					Plugin.logger.LogError((object)"Couldnt get netObj from NetworkObjectReference in GrabItemClientRpc");
					return;
				}
				GrabbableObject val4 = default(GrabbableObject);
				if (!((Component)val3).TryGetComponent<GrabbableObject>(ref val4))
				{
					Plugin.logger.LogError((object)"Couldnt get GrabbableObject from NetworkObject in GrabItemClientRpc");
					return;
				}
				heldObject = val4;
				heldObject.parentObject = holdItemPosition;
				heldObject.hasHitGround = false;
				heldObject.isHeldByEnemy = true;
				HoarderBugAI.grabbableObjectsInMap.Remove(((Component)heldObject).gameObject);
				HoarderBugAI.grabbableObjectsInMap.Remove(((Component)this).gameObject);
				((GrabbableObject)this).grabbable = false;
				heldObject.grabbable = true;
				((GrabbableObject)this).grabbableToEnemies = false;
				heldObject.grabbableToEnemies = false;
				collider.enabled = false;
			}
		}

		[ClientRpc]
		public void DropItemClientRpc(Vector3 targetFloorPosition)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val2 = default(ClientRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(2508272208u, val2, (RpcDelivery)0);
				((FastBufferWriter)(ref val)).WriteValueSafe(ref targetFloorPosition);
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 2508272208u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				if (!((Object)(object)heldObject == (Object)null))
				{
					GrabbableObject val3 = heldObject;
					val3.parentObject = null;
					((Component)val3).transform.SetParent(StartOfRound.Instance.propsContainer, true);
					val3.fallTime = 0f;
					val3.startFallingPosition = ((Component)val3).transform.parent.InverseTransformPoint(((Component)val3).transform.position);
					val3.targetFloorPosition = ((Component)val3).transform.parent.InverseTransformPoint(targetFloorPosition);
					val3.floorYRot = -1;
					val3.DiscardItemFromEnemy();
					val3.isHeldByEnemy = false;
					val3.grabbable = true;
					val3.grabbableToEnemies = true;
					HoarderBugAI.grabbableObjectsInMap.Add(((Component)val3).gameObject);
					HoarderBugAI.grabbableObjectsInMap.Add(((Component)this).gameObject);
					heldObject = null;
					((GrabbableObject)this).grabbable = true;
					((GrabbableObject)this).grabbableToEnemies = true;
					collider.enabled = true;
				}
			}
		}

		[Rpc(/*Could not decode attribute arguments.*/)]
		public void ItemActivateRpc()
		{
			//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_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1)
			{
				RpcAttributeParams val = default(RpcAttributeParams);
				RpcParams val3 = default(RpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(684818736u, val3, val, (SendTo)6, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendRpc(ref val2, 684818736u, val3, val, (SendTo)6, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1)
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				nav.SetAllValues(!((GrabbableObject)this).playerHeldBy.isInsideFactory);
				if (((NetworkBehaviour)this).IsOwner)
				{
					((GrabbableObject)this).playerHeldBy.DiscardHeldObject(true, (NetworkObject)null, GetGrenadeThrowDestination(), true);
				}
				animator.SetTrigger("fall");
				isThrown = true;
			}
		}

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

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(1582171592u, new RpcReceiveHandler(__rpc_handler_1582171592), "DoAnimationServerRpc");
			((NetworkBehaviour)this).__registerRpc(441340134u, new RpcReceiveHandler(__rpc_handler_441340134), "DoAnimationClientRpc");
			((NetworkBehaviour)this).__registerRpc(1331613493u, new RpcReceiveHandler(__rpc_handler_1331613493), "GrabItemClientRpc");
			((NetworkBehaviour)this).__registerRpc(2508272208u, new RpcReceiveHandler(__rpc_handler_2508272208), "DropItemClientRpc");
			((NetworkBehaviour)this).__registerRpc(684818736u, new RpcReceiveHandler(__rpc_handler_684818736), "ItemActivateRpc");
			((PhysicsProp)this).__initializeRpcs();
		}

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

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

		private static void __rpc_handler_1331613493(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkObjectReference netRef = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref netRef, default(ForNetworkSerializable));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((FleshDollBehavior)(object)target).GrabItemClientRpc(netRef);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2508272208(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				Vector3 targetFloorPosition = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref targetFloorPosition);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((FleshDollBehavior)(object)target).DropItemClientRpc(targetFloorPosition);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

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

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "FleshDollBehavior";
		}
	}
	public class YulemanKnifeBehavior : PhysicsProp
	{
		public AudioSource audioSource = null;

		public AudioClip[] sliceSFX = null;

		public AudioClip[] tearSFX = null;

		public AudioClip chargeSFX = null;

		public Transform knifeTip = null;

		public GameObject throwingKnifePrefab = null;

		public GameObject knifeMesh = null;

		public GameObject runeMesh = null;

		public ScanNodeProperties scanNode = null;

		private List<Collider> EntitiesHitByKnife = new List<Collider>();

		public ThrownKnifeScript? thrownKnifeScript;

		private readonly Vector3 PositionOffsetStab = new Vector3(-0.2f, 0.26f, -0.02f);

		private readonly Vector3 PositionOffsetThrow = new Vector3(0.18f, 0.035f, -0.08f);

		private readonly Vector3 RotationOffsetStab = new Vector3(-30f, -90f, 90f);

		private readonly Vector3 RotationOffsetThrow = new Vector3(30f, 100f, -90f);

		private const int knifeMask = 1084754248;

		private const int defaultExcludeMask = -2621449;

		private bool isCharged;

		private Coroutine? chargeCoroutine;

		private RaycastHit[]? objectsHitByKnife;

		private List<RaycastHit> objectsHitByKnifeList = new List<RaycastHit>();

		private float timeAtLastDamageDealt;

		public PlayerControllerB? previousPlayerHeldBy;

		private bool callingKnife;

		private bool isThrown;

		private Vector3 rotationOffset = new Vector3(-30f, -90f, 90f);

		private Vector3 positionOffset = new Vector3(-0.2f, 0.26f, -0.02f);

		private const float chargeTime = 1f;

		public const int knifeHitForceEnemy = 1;

		public const int knifeHitForcePlayer = 25;

		public override void Start()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: 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_0044: Expected O, but got Unknown
			((GrabbableObject)this).Start();
			thrownKnifeScript = Object.Instantiate<GameObject>(throwingKnifePrefab, Vector3.zero, Quaternion.identity).GetComponent<ThrownKnifeScript>();
			((UnityEvent)thrownKnifeScript.KnifeReturnedEvent).AddListener(new UnityAction(KnifeReturned));
		}

		public override void OnDestroy()
		{
			ThrownKnifeScript? obj = thrownKnifeScript;
			Object.Destroy((Object)(object)((obj != null) ? ((Component)obj).gameObject : null));
			((GrabbableObject)this).OnDestroy();
		}

		public override void Update()
		{
			((GrabbableObject)this).Update();
			if ((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null)
			{
				previousPlayerHeldBy = ((GrabbableObject)this).playerHeldBy;
			}
		}

		public override void LateUpdate()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: 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_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)((GrabbableObject)this).parentObject != (Object)null)
			{
				((Component)this).transform.rotation = ((GrabbableObject)this).parentObject.rotation;
				((Component)this).transform.Rotate(rotationOffset);
				((Component)this).transform.position = ((GrabbableObject)this).parentObject.position;
				Vector3 val = positionOffset;
				val = ((GrabbableObject)this).parentObject.rotation * val;
				Transform transform = ((Component)this).transform;
				transform.position += val;
			}
			if ((Object)(object)((GrabbableObject)this).radarIcon != (Object)null)
			{
				((GrabbableObject)this).radarIcon.position = ((Component)this).transform.position;
			}
		}

		public void ThrowKnife(Vector3 throwDirection)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			MakeKnifeVisible(value: false);
			((GrabbableObject)this).playerHeldBy.activatingItem = true;
			isThrown = true;
			thrownKnifeScript?.ThrowKnife(((GrabbableObject)this).playerHeldBy, ((Component)this).transform, throwDirection);
		}

		public void KnifeReturned()
		{
			Plugin.logger.LogDebug((object)"Knife returned");
			callingKnife = false;
			isThrown = false;
			previousPlayerHeldBy.activatingItem = false;
			MakeKnifeVisible(value: true);
		}

		public override void PocketItem()
		{
			((GrabbableObject)this).PocketItem();
			ChargeCancel();
			HitKnife(cancel: true);
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			if (isThrown)
			{
				Plugin.logger.LogDebug((object)"Knife is thrown");
				if (!callingKnife)
				{
					Plugin.logger.LogDebug((object)"Calling knife");
					CallKnife();
				}
				return;
			}
			if (buttonDown)
			{
				chargeCoroutine = ((MonoBehaviour)this).StartCoroutine(ChargeKnife());
				return;
			}
			((MonoBehaviour)this).StopCoroutine(chargeCoroutine);
			((GrabbableObject)this).playerHeldBy.playerBodyAnimator.SetTrigger("UseHeldItem1");
			if (isCharged)
			{
				ThrowKnife(((Component)((GrabbableObject)this).playerHeldBy.playerEye).transform.forward);
			}
			else
			{
				RoundManager.PlayRandomClip(audioSource, sliceSFX, true, 1f, 0, 1000);
				HitKnife();
			}
			ChargeCancel();
		}

		private IEnumerator ChargeKnife()
		{
			yield return (object)new WaitForSecondsRealtime(1f);
			rotationOffset = RotationOffsetThrow;
			positionOffset = PositionOffsetThrow;
			audioSource.PlayOneShot(chargeSFX, 1f);
			WalkieTalkie.TransmitOneShotAudio(audioSource, chargeSFX, 1f);
			RoundManager.Instance.PlayAudibleNoise(((Component)previousPlayerHeldBy).transform.position, audioSource.maxDistance, 0.5f, 0, previousPlayerHeldBy.isInHangarShipRoom, 0);
			isCharged = true;
			Plugin.logger.LogDebug((object)"Knife is charged");
		}

		private void ChargeCancel()
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: 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_0047: Unknown result type (might be due to invalid IL or missing references)
			Plugin.logger.LogDebug((object)"ChargeCancel");
			if (chargeCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(chargeCoroutine);
			}
			isCharged = false;
			rotationOffset = RotationOffsetStab;
			positionOffset = PositionOffsetStab;
		}

		public void HitKnife(bool cancel = false)
		{
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: 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_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0465: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0352: Unknown result type (might be due to invalid IL or missing references)
			//IL_0357: Unknown result type (might be due to invalid IL or missing references)
			//IL_0390: Unknown result type (might be due to invalid IL or missing references)
			if (!((NetworkBehaviour)this).IsOwner)
			{
				return;
			}
			if ((Object)(object)previousPlayerHeldBy == (Object)null)
			{
				Debug.LogError((object)"Previousplayerheldby is null on this client when HitShovel is called.");
				return;
			}
			previousPlayerHeldBy.activatingItem = false;
			bool flag = false;
			bool flag2 = false;
			int num = -1;
			bool flag3 = false;
			if (!cancel && Time.realtimeSinceStartup - timeAtLastDamageDealt > 0.43f)
			{
				previousPlayerHeldBy.twoHanded = false;
				objectsHitByKnife = Physics.SphereCastAll(((Component)previousPlayerHeldBy.gameplayCamera).transform.position + ((Component)previousPlayerHeldBy.gameplayCamera).transform.right * 0.1f, 0.3f, ((Component)previousPlayerHeldBy.gameplayCamera).transform.forward, 0.75f, 1084754248, (QueryTriggerInteraction)2);
				objectsHitByKnifeList = objectsHitByKnife.OrderBy((RaycastHit x) => ((RaycastHit)(ref x)).distance).ToList();
				List<EnemyAI> list = new List<EnemyAI>();
				IHittable val2 = default(IHittable);
				for (int num2 = 0; num2 < objectsHitByKnifeList.Count; num2++)
				{
					RaycastHit val = objectsHitByKnifeList[num2];
					string text = LayerMask.LayerToName(((Component)((RaycastHit)(ref val)).transform).gameObject.layer);
					val = objectsHitByKnifeList[num2];
					if (((Component)((RaycastHit)(ref val)).transform).gameObject.layer != 8)
					{
						val = objectsHitByKnifeList[num2];
						if (((Component)((RaycastHit)(ref val)).transform).gameObject.layer != 11)
						{
							val = objectsHitByKnifeList[num2];
							if (!((Component)((RaycastHit)(ref val)).transform).TryGetComponent<IHittable>(ref val2))
							{
								continue;
							}
							val = objectsHitByKnifeList[num2];
							if ((Object)(object)((RaycastHit)(ref val)).transform == (Object)(object)((Component)previousPlayerHeldBy).transform)
							{
								continue;
							}
							val = objectsHitByKnifeList[num2];
							if (!(((RaycastHit)(ref val)).point == Vector3.zero))
							{
								Vector3 position = ((Component)previousPlayerHeldBy.gameplayCamera).transform.position;
								RaycastHit val3 = objectsHitByKnifeList[num2];
								if (Physics.Linecast(position, ((RaycastHit)(ref val3)).point, ref val, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1))
								{
									continue;
								}
							}
							flag = true;
							Vector3 forward = ((Component)previousPlayerHeldBy.gameplayCamera).transform.forward;
							try
							{
								int num3 = 1;
								val = objectsHitByKnifeList[num2];
								EnemyAICollisionDetect component = ((Component)((RaycastHit)(ref val)).transform).GetComponent<EnemyAICollisionDetect>();
								if ((Object)(object)component != (Object)null)
								{
									if ((Object)(object)component.mainScript != (Object)null && !list.Contains(component.mainScript))
									{
										goto IL_038b;
									}
									continue;
								}
								val = objectsHitByKnifeList[num2];
								if (!((Object)(object)((Component)((RaycastHit)(ref val)).transform).GetComponent<PlayerControllerB>() != (Object)null))
								{
									num3 = 1;
									goto IL_038b;
								}
								if (!flag3)
								{
									flag3 = true;
									goto IL_038b;
								}
								goto end_IL_02e9;
								IL_038b:
								bool flag4 = val2.Hit(num3, forward, previousPlayerHeldBy, true, 5);
								if (flag4 && (Object)(object)component != (Object)null)
								{
									list.Add(component.mainScript);
								}
								if (!flag2 && flag4)
								{
									flag2 = true;
									timeAtLastDamageDealt = Time.realtimeSinceStartup;
									RoundManager.PlayRandomClip(audioSource, tearSFX, true, 1f, 0, 1000);
								}
								end_IL_02e9:;
							}
							catch (Exception arg)
							{
								Debug.Log((object)$"Exception caught when hitting object with shovel from player #{previousPlayerHeldBy.playerClientId}: {arg}");
							}
							continue;
						}
					}
					flag = true;
					val = objectsHitByKnifeList[num2];
					string tag = ((Component)((RaycastHit)(ref val)).collider).gameObject.tag;
					for (int num4 = 0; num4 < StartOfRound.Instance.footstepSurfaces.Length; num4++)
					{
						if (StartOfRound.Instance.footstepSurfaces[num4].surfaceTag == tag)
						{
							num = num4;
							break;
						}
					}
				}
			}
			if (flag)
			{
				Object.FindObjectOfType<RoundManager>().PlayAudibleNoise(((Component)this).transform.position, 17f, 0.8f, 0, false, 0);
				if (!flag2 && num != -1)
				{
					audioSource.PlayOneShot(StartOfRound.Instance.footstepSurfaces[num].hitSurfaceSFX);
					WalkieTalkie.TransmitOneShotAudio(audioSource, StartOfRound.Instance.footstepSurfaces[num].hitSurfaceSFX, 1f);
				}
				HitShovelServerRpc(num);
			}
		}

		private void HitSurfaceWithKnife(int hitSurfaceID)
		{
			audioSource.PlayOneShot(StartOfRound.Instance.footstepSurfaces[hitSurfaceID].hitSurfaceSFX);
			WalkieTalkie.TransmitOneShotAudio(audioSource, StartOfRound.Instance.footstepSurfaces[hitSurfaceID].hitSurfaceSFX, 1f);
		}

		public void CallKnife()
		{
			callingKnife = true;
			thrownKnifeScript?.CallKnife();
		}

		public void MakeKnifeVisible(bool value)
		{
			knifeMesh.SetActive(value);
			runeMesh.SetActive(!value);
		}

		[ServerRpc(RequireOwnership = false)]
		private void HitShovelServerRpc(int hitSurfaceID)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val2 = default(ServerRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(2490491574u, val2, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val, hitSurfaceID);
					((NetworkBehaviour)this).__endSendServerRpc(ref val, 2490491574u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					HitShovelClientRpc(hitSurfaceID);
				}
			}
		}

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

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

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(2490491574u, new RpcReceiveHandler(__rpc_handler_2490491574), "HitShovelServerRpc");
			((NetworkBehaviour)this).__registerRpc(243495575u, new RpcReceiveHandler(__rpc_handler_243495575), "HitShovelClientRpc");
			((PhysicsProp)this).__initializeRpcs();
		}

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

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

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "YulemanKnifeBehavior";
		}
	}
	public class ThrownKnifeScript : MonoBehaviour
	{
		public AudioSource audioSource = null;

		public AudioClip[] tearSFX = null;

		public AudioClip knifeImpactSFX = null;

		public AudioClip knifeWallPullSFX = null;

		public Transform knifeTip = null;

		public GameObject knifeMesh = null;

		private Transform? knifeThrownBy;

		private PlayerControllerB? playerThrownBy;

		public SimpleEvent KnifeReturnedEvent = new SimpleEvent();

		private List<Collider> EntitiesHitByKnife = new List<Collider>();

		private bool isThrown;

		private bool returning;

		private bool inWall;

		private Vector3 postThrowPosition;

		private float returnTime;

		public const float timeToReturn = 1f;

		public static float throwForce = 100f;

		private const float maxThrowDistance = 400f;

		private const float returnSpeed = 1f;

		public void OnEnable()
		{
			knifeMesh.SetActive(true);
		}

		public void OnDisable()
		{
			knifeMesh.SetActive(false);
			returning = false;
			isThrown = false;
			inWall = false;
			EntitiesHitByKnife.Clear();
			returnTime = 0f;
		}

		public void Start()
		{
			((Behaviour)this).enabled = false;
		}

		public void Update()
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			if (returning)
			{
				returnTime += Time.deltaTime * 1f;
				returnTime = Mathf.Clamp01(returnTime);
				((Component)this).transform.position = Vector3.Lerp(postThrowPosition, knifeThrownBy.position, returnTime);
				if (returnTime >= 1f)
				{
					((UnityEvent)KnifeReturnedEvent).Invoke();
					((Behaviour)this).enabled = false;
				}
			}
		}

		public void FixedUpdate()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			if (isThrown)
			{
				Vector3 val = ((Component)this).transform.position + ((Component)this).transform.forward * throwForce * Time.fixedDeltaTime;
				if (Physics.Raycast(((Component)this).transform.position, val - ((Component)this).transform.position, throwForce * Time.fixedDeltaTime, StartOfRound.Instance.collidersAndRoomMask))
				{
					Plugin.logger.LogDebug((object)"Knife hit wall, stopping");
					isThrown = false;
					StopKnife(hitWall: true);
				}
				else
				{
					((Component)this).transform.position = val;
				}
			}
		}

		public void ThrowKnife(PlayerControllerB _playerThrownBy, Transform _knifeThrownBy, Vector3 throwDirection)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			playerThrownBy = _playerThrownBy;
			ThrowKnife(_knifeThrownBy, throwDirection);
		}

		public void ThrowKnife(Transform _knifeThrownBy, Vector3 throwDirection)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			((Behaviour)this).enabled = true;
			knifeThrownBy = _knifeThrownBy;
			((Component)this).transform.position = knifeThrownBy.position + ((Component)this).transform.forward;
			((Component)this).transform.rotation = Quaternion.LookRotation(throwDirection, knifeTip.up);
			postThrowPosition = GetKnifeEndPoint();
			isThrown = true;
		}

		private Vector3 GetKnifeEndPoint()
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: 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_0093: 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_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			Ray val = default(Ray);
			((Ray)(ref val))..ctor(((Component)this).transform.position, ((Component)this).transform.forward);
			RaycastHit val2 = default(RaycastHit);
			if (Physics.Raycast(val, ref val2, 400f, StartOfRound.Instance.collidersAndRoomMask))
			{
				float num = Vector3.Distance(knifeTip.position, ((Component)this).transform.position);
				return ((RaycastHit)(ref val2)).point - ((Component)this).transform.forward * num;
			}
			Plugin.logger.LogDebug((object)"Couldnt find wall");
			return ((Ray)(ref val)).GetPoint(400f);
		}

		private void StopKnife(bool hitWall)
		{
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			Plugin.logger.LogDebug((object)"Stopping knife");
			isThrown = false;
			EntitiesHitByKnife.Clear();
			if (hitWall)
			{
				inWall = true;
				((Component)this).transform.position = postThrowPosition;
				RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, 10f, 0.5f, 0, false, 0);
				audioSource.PlayOneShot(knifeImpactSFX);
				WalkieTalkie.TransmitOneShotAudio(audioSource, knifeImpactSFX, 0.5f);
			}
			else
			{
				postThrowPosition = ((Component)this).transform.position;
			}
		}

		public void CallKnife()
		{
			if (isThrown)
			{
				StopKnife(hitWall: false);
			}
			if (inWall)
			{
				audioSource.PlayOneShot(knifeWallPullSFX);
				WalkieTalkie.TransmitOneShotAudio(audioSource, knifeWallPullSFX, 0.5f);
			}
			isThrown = false;
			returning = true;
		}

		public void OnTriggerStay(Collider other)
		{
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			IHittable val = default(IHittable);
			if (!isThrown || EntitiesHitByKnife.Contains(other) || !((Component)((Component)other).transform).TryGetComponent<IHittable>(ref val))
			{
				return;
			}
			Plugin.logger.LogDebug((object)"Hit");
			PlayerControllerB val2 = default(PlayerControllerB);
			if (((Component)other).gameObject.TryGetComponent<PlayerControllerB>(ref val2))
			{
				if ((Object)(object)val2 == (Object)(object)playerThrownBy || !val2.isPlayerControlled)
				{
					EntitiesHitByKnife.Add(other);
					return;
				}
				if ((Object)(object)Plugin.localPlayer == (Object)(object)val2)
				{
					EvilFleshDollAI.onThisDamagingLocalPlayer.Invoke();
					Plugin.localPlayer.DamagePlayer(25, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
				}
			}
			else
			{
				SCP4666AI sCP4666AI = default(SCP4666AI);
				if (((Component)other).gameObject.TryGetComponent<SCP4666AI>(ref sCP4666AI) && (Object)(object)sCP4666AI != (Object)null)
				{
					EntitiesHitByKnife.Add(other);
					return;
				}
				if (!val.Hit(1, ((Component)knifeTip).transform.forward, playerThrownBy, true, 5))
				{
					Plugin.logger.LogDebug((object)"Hit unsuccessful");
					return;
				}
			}
			EntitiesHitByKnife.Add(other);
			RoundManager.PlayRandomClip(audioSource, tearSFX, true, 1f, 0, 1000);
		}
	}
}
namespace SCP4666.Enemies
{
	public class SCP4666AI : EnemyAI, ISCP
	{
		public enum State
		{
			Spawning,
			Chasing,
			Abducting
		}

		private bool DEBUG_allowSpawnDolls = true;

		private bool DEBUG_allowGroundSlam = true;

		private bool DEBUG_allowThrowKnife = true;

		private bool DEBUG_allowTeleporting = true;

		private bool DEBUG_allowTargettingHost = true;

		private bool DEBUG_allowAbducting = false;

		public SCPInfo scpInfo = null;

		public Transform rightHandTransform = null;

		public Transform childSackTransform = null;

		public AudioSource musicAudioSource = null;

		public AudioClip footstepSFX = null;

		public AudioClip teleportSFX = null;

		public AudioClip laughSFX = null;

		public AudioClip roarSFX = null;

		public AudioClip groundSlamSFX = null;

		public GameObject yulemanMeshObj = null;

		public Transform turnCompass = null;

		public GameObject evilDollPrefab = null;

		public GameObject throwingKnifePrefab = null;

		public Collider collider = null;

		public GameObject knifeMeshObj = null;

		public ParticleSystem groundSlamParticles = null;

		[HideInInspector]
		public ThrownKnifeScript thrownKnifeScript = null;

		public SmartAgentNavigator nav = null;

		public Camera cameraSack = null;

		public static UnityEvent<PlayerControllerB> onPlayerGrabbed = new UnityEvent<PlayerControllerB>();

		private Vector3 mainEntranceOutsidePosition;

		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 float timeSinceGroundSlam;

		private float timeSinceDollSpawning;

		private bool teleporting;

		private bool isThrowingKnife;

		private bool isCallingKnife;

		private int timesHitWhileAbducting;

		private int damageTakenWithoutDamaging;

		private int dollsToSpawn;

		private bool useBombDolls;

		private float timeSinceSwitchBehavior;

		private Vector3 lastPosition;

		private float currentSpeed;

		private float idleTime;

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

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

		private const float attackRange = 5f;

		private const float attackAngle = 45f;

		private const float teleportCooldown = 15f;

		private const float teleportDistance = 10f;

		private const float knifeReturnCooldown = 5f;

		private const float knifeThrowCooldown = 10f;

		private const float knifeThrowMinDistance = 5f;

		private const float knifeThrowMaxDistance = 10f;

		private const float hitAmountToDropPlayer = 5f;

		private const int slapDamage = 10;

		private const int minPresentsToSpawn = 3;

		private const int maxPresentsToSpawn = 6;

		private const int minDollsToDrop = 1;

		private const int maxDollsToDrop = 3;

		private const int minDollsToSpawn = 2;

		private const int maxDollsToSpawn = 5;

		private const float dollCountMultiplier = 0.2f;

		private const float dollSpawningCooldown = 30f;

		private const float groundSlamCooldown = 15f;

		private const int maxDamageTakenToGroundSlam = 3;

		private const float groundSlamDistance = 5f;

		private const float groundSlamForce = 50f;

		private const int groundSlamDamage = 30;

		private const int maxHp = 30;

		private const float spawnTurnCompassSpeed = 20f;

		private const float LOSOffset = 2f;

		private const float grabPlayerCooldown = 10f;

		private const float damagePlayerCooldown = 2f;

		private const int playerKidnapChanceOffset = 100;

		private bool playBossMusic = true;

		private float bossMusicVolume = 0.3f;

		private bool canTeleport = true;

		private bool canSpawnDolls = true;

		private bool canThrowKnife = true;

		private bool canKidnap = true;

		private bool canGroundSlam = true;

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

		SCPInfo ISCP.SCPInfo => scpInfo;

		public bool isOutside => nav.IsAgentOutside();

		public bool isInsideFactory => !isOutside;

		public void DEBUG_DoGroundSlam()
		{
			Plugin.logger.LogDebug((object)"Performing ground slam");
			base.inSpecialAnimation = true;
			DoAnimationRpc("groundSlam");
		}

		public override void Start()
		{
			//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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Expected O, but got Unknown
			((EnemyAI)this).Start();
			Instances.Add(this);
			base.enemyHP = 30;
			base.currentBehaviourStateIndex = 0;
			nav.SetAllValues(true);
			mainEntranceOutsidePosition = RoundManager.FindMainEntrancePosition(false, true);
			thrownKnifeScript = Object.Instantiate<GameObject>(throwingKnifePrefab, Vector3.zero, Quaternion.identity).GetComponent<ThrownKnifeScript>();
			((UnityEvent)thrownKnifeScript.KnifeReturnedEvent).AddListener(new UnityAction(KnifeReturned));
			cameraSack.cullingMask = Plugin.localPlayer.gameplayCamera.cullingMask;
			if (((NetworkBehaviour)this).IsServer)
			{
				int amount = Random.Range(3, 6);
				SpawnPresents(amount);
				Plugin.logger.LogDebug((object)"SCP-4666 Spawned");
			}
		}

		private void SetConfigs()
		{
			try
			{
				SCP4666ContentHandler.SCP4666Assets sCP = ContentHandler<SCP4666ContentHandler>.Instance.SCP4666;
				if (sCP != null)
				{
					playBossMusic = ((AssetBundleLoader<SCP4666ContentHandler.SCP4666Assets>)(object)sCP).GetConfig<bool>("Play Boss Music").Value;
					bossMusicVolume = ((AssetBundleLoader<SCP4666ContentHandler.SCP4666Assets>)(object)sCP).GetConfig<float>("Boss Music Volume").Value;
					canTeleport = ((AssetBundleLoader<SCP4666ContentHandler.SCP4666Assets>)(object)sCP).GetConfig<bool>("Can Teleport").Value;
					canSpawnDolls = ((AssetBundleLoader<SCP4666ContentHandler.SCP4666Assets>)(object)sCP).GetConfig<bool>("Can Spawn Dolls").Value;
					canThrowKnife = ((AssetBundleLoader<SCP4666ContentHandler.SCP4666Assets>)(object)sCP).GetConfig<bool>("Can Throw Knife").Value;
					canKidnap = ((AssetBundleLoader<SCP4666ContentHandler.SCP4666Assets>)(object)sCP).GetConfig<bool>("Can Kidnap").Value;
					canGroundSlam = ((AssetBundleLoader<SCP4666ContentHandler.SCP4666Assets>)(object)sCP).GetConfig<bool>("Can Ground Slam").Value;
				}
			}
			catch
			{
				Plugin.logger.LogError((object)"Couldnt load configs");
			}
		}

		public override void OnDestroy()
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB inSpecialAnimationWithPlayer = base.inSpecialAnimationWithPlayer;
			((EnemyAI)this).CancelSpecialAnimationWithPlayer();
			if ((Object)(object)inSpecialAnimationWithPlayer != (Object)null && (Object)(object)Plugin.localPlayer == (Object)(object)inSpecialAnimationWithPlayer)
			{
				StartOfRound.Instance.allowLocalPlayerDeath = true;
				inSpecialAnimationWithPlayer.KillPlayer(Vector3.zero, false, (CauseOfDeath)0