plugins/Reiko888.Jinn.dll

Decompiled 2 hours ago
#define DEBUG
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using Dawn.Utils;
using Dusk;
using GameNetcodeStuff;
using HarmonyLib;
using Jinn;
using Microsoft.CodeAnalysis;
using Reiko888.Jinn.NetcodePatcher;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Video;

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

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
public class GramophoneProp : NetworkBehaviour
{
	public InteractTrigger windingTrigger;

	public AudioSource windingAudioSource;

	public AudioClip windingLoopSFX;

	public Animator gramophoneAnimator;

	private bool isDefeated = false;

	public void OnWindingStarted()
	{
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		if (!isDefeated)
		{
			SetWindingStateServerRpc(isWinding: true);
			JinnAI jinnAI = Object.FindObjectOfType<JinnAI>();
			if ((Object)(object)jinnAI != (Object)null)
			{
				jinnAI.HearGramophoneServerRpc(((Component)this).transform.position);
			}
		}
	}

	public void OnWindingStopped()
	{
		if (!isDefeated)
		{
			SetWindingStateServerRpc(isWinding: false);
		}
	}

	public void OnWindingComplete(PlayerControllerB playerWhoWoundIt)
	{
		if (!isDefeated)
		{
			isDefeated = true;
			CompleteWindingServerRpc();
		}
	}

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

	[ClientRpc]
	public void SetWindingStateClientRpc(bool isWinding)
	{
		//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)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
		{
			ClientRpcParams val = default(ClientRpcParams);
			FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1959246616u, val, (RpcDelivery)0);
			((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref isWinding, default(ForPrimitives));
			((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1959246616u, val, (RpcDelivery)0);
		}
		if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost))
		{
			return;
		}
		base.__rpc_exec_stage = (__RpcExecStage)0;
		if (isDefeated)
		{
			return;
		}
		if (isWinding)
		{
			if ((Object)(object)windingAudioSource != (Object)null && (Object)(object)windingLoopSFX != (Object)null)
			{
				windingAudioSource.clip = windingLoopSFX;
				windingAudioSource.loop = true;
				if (!windingAudioSource.isPlaying)
				{
					windingAudioSource.Play();
				}
			}
			if ((Object)(object)gramophoneAnimator != (Object)null)
			{
				gramophoneAnimator.SetBool("isWinding", true);
			}
		}
		else
		{
			if ((Object)(object)windingAudioSource != (Object)null && windingAudioSource.isPlaying)
			{
				windingAudioSource.Stop();
			}
			if ((Object)(object)gramophoneAnimator != (Object)null)
			{
				gramophoneAnimator.SetBool("isWinding", false);
			}
		}
	}

	[ServerRpc(RequireOwnership = false)]
	public void CompleteWindingServerRpc()
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0158: Unknown result type (might be due to invalid IL or missing references)
		//IL_0163: Unknown result type (might be due to invalid IL or missing references)
		//IL_0198: Unknown result type (might be due to invalid IL or missing references)
		//IL_019d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
		{
			ServerRpcParams val = default(ServerRpcParams);
			FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1629078729u, val, (RpcDelivery)0);
			((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1629078729u, val, (RpcDelivery)0);
		}
		if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
		{
			return;
		}
		base.__rpc_exec_stage = (__RpcExecStage)0;
		if (!((NetworkBehaviour)this).IsServer)
		{
			return;
		}
		JinnAI jinnAI = Object.FindObjectOfType<JinnAI>();
		Item val3 = null;
		foreach (Item items in StartOfRound.Instance.allItemsList.itemsList)
		{
			if (items.itemName == "Cursed Gramophone")
			{
				val3 = items;
				break;
			}
		}
		if ((Object)(object)val3 != (Object)null)
		{
			GameObject val4 = Object.Instantiate<GameObject>(val3.spawnPrefab, ((Component)this).transform.position, ((Component)this).transform.rotation, StartOfRound.Instance.propsContainer);
			GrabbableObject component = val4.GetComponent<GrabbableObject>();
			component.fallTime = 0f;
			component.targetFloorPosition = component.GetItemFloorPosition(((Component)this).transform.position);
			NetworkObject component2 = val4.GetComponent<NetworkObject>();
			component2.Spawn(false);
			int scrapValue = (int)((float)Random.Range(150, 350) * RoundManager.Instance.scrapValueMultiplier);
			component.SetScrapValue(scrapValue);
			if ((Object)(object)jinnAI != (Object)null)
			{
				jinnAI.SyncScrapValueClientRpc(NetworkObjectReference.op_Implicit(component2), scrapValue);
			}
		}
		if ((Object)(object)jinnAI != (Object)null)
		{
			jinnAI.DefeatObakeServerRpc();
		}
		((NetworkBehaviour)this).NetworkObject.Despawn(true);
	}

	protected override void __initializeVariables()
	{
		((NetworkBehaviour)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
		((NetworkBehaviour)this).__registerRpc(3505332847u, new RpcReceiveHandler(__rpc_handler_3505332847), "SetWindingStateServerRpc");
		((NetworkBehaviour)this).__registerRpc(1959246616u, new RpcReceiveHandler(__rpc_handler_1959246616), "SetWindingStateClientRpc");
		((NetworkBehaviour)this).__registerRpc(1629078729u, new RpcReceiveHandler(__rpc_handler_1629078729), "CompleteWindingServerRpc");
		((NetworkBehaviour)this).__initializeRpcs();
	}

	private static void __rpc_handler_3505332847(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_005e: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = target.NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			bool windingStateServerRpc = default(bool);
			((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref windingStateServerRpc, default(ForPrimitives));
			target.__rpc_exec_stage = (__RpcExecStage)1;
			((GramophoneProp)(object)target).SetWindingStateServerRpc(windingStateServerRpc);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	private static void __rpc_handler_1959246616(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_005e: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = target.NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			bool windingStateClientRpc = default(bool);
			((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref windingStateClientRpc, default(ForPrimitives));
			target.__rpc_exec_stage = (__RpcExecStage)1;
			((GramophoneProp)(object)target).SetWindingStateClientRpc(windingStateClientRpc);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	private static void __rpc_handler_1629078729(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;
			((GramophoneProp)(object)target).CompleteWindingServerRpc();
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	[MethodImpl(MethodImplOptions.NoInlining)]
	protected internal override string __getTypeName()
	{
		return "GramophoneProp";
	}
}
namespace Obake
{
	public class RapierItem : GrabbableObject
	{
		[CompilerGenerated]
		private sealed class <TraceAnimatorState>d__29 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public Animator anim;

			public int layerIndex;

			public RapierItem <>4__this;

			private int <i>5__1;

			private AnimatorStateInfo <stateInfo>5__2;

			private AnimatorClipInfo[] <clipInfo>5__3;

			private string <clipName>5__4;

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

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

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

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

			private bool MoveNext()
			{
				//IL_006d: 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_0120: Unknown result type (might be due to invalid IL or missing references)
				//IL_012a: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					Debug.Log((object)$"[RapierDebug-Trace] --- STARTING 1-SECOND ANIMATION TRACE ON LAYER {layerIndex} ---");
					<i>5__1 = 0;
					break;
				case 1:
					<>1__state = -1;
					<clipInfo>5__3 = null;
					<clipName>5__4 = null;
					<i>5__1++;
					break;
				}
				if (<i>5__1 < 10 && !((Object)(object)anim == (Object)null))
				{
					<stateInfo>5__2 = anim.GetCurrentAnimatorStateInfo(layerIndex);
					<clipInfo>5__3 = anim.GetCurrentAnimatorClipInfo(layerIndex);
					<clipName>5__4 = ((<clipInfo>5__3.Length != 0) ? ((Object)((AnimatorClipInfo)(ref <clipInfo>5__3[0])).clip).name : "NO CLIP (Empty State)");
					Debug.Log((object)$"[RapierDebug-Trace] +{(float)<i>5__1 * 0.1f}s | Clip: {<clipName>5__4} | Normalized Time: {((AnimatorStateInfo)(ref <stateInfo>5__2)).normalizedTime:F2} | Transitioning: {anim.IsInTransition(layerIndex)}");
					<>2__current = (object)new WaitForSeconds(0.1f);
					<>1__state = 1;
					return true;
				}
				Debug.Log((object)"[RapierDebug-Trace] --- TRACE FINISHED ---");
				return false;
			}

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

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

		public AudioSource rapierAudio;

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

		public PlayerControllerB previousPlayerHeldBy;

		private RaycastHit[] objectsHitByRapier;

		public int rapierHitForce = 1;

		public AudioClip[] hitSFX;

		public AudioClip[] swingSFX;

		private int rapierMask = 1084754248;

		private float timeAtLastDamageDealt;

		public ParticleSystem bloodParticle;

		public RuntimeAnimatorController rapierLocalAnimator;

		public RuntimeAnimatorController rapierRemoteAnimator;

		private static readonly Dictionary<ulong, RuntimeAnimatorController> _SAVED_ANIMATORS = new Dictionary<ulong, RuntimeAnimatorController>();

		private bool _animatorReplaced;

		private AnimatorStateInfo _savedState;

		private float _savedNormalizedTime;

		private bool _savedCrouching;

		private bool _savedWalking;

		private bool _savedJumping;

		private bool _savedSprinting;

		public override void EquipItem()
		{
			((GrabbableObject)this).EquipItem();
			previousPlayerHeldBy = base.playerHeldBy;
			if ((Object)(object)base.playerHeldBy != (Object)null)
			{
				previousPlayerHeldBy.equippedUsableItemQE = true;
				EnableRapierAnimator();
				base.playerHeldBy.playerBodyAnimator.SetBool(base.itemProperties.grabAnim, true);
			}
		}

		public override void GrabItem()
		{
			if ((Object)(object)base.playerHeldBy != (Object)null)
			{
				EnableRapierAnimator();
			}
			((GrabbableObject)this).GrabItem();
		}

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

		public override void DiscardItem()
		{
			((GrabbableObject)this).DiscardItem();
			DisableRapierAnimator();
		}

		private void EnableRapierAnimator()
		{
			Debug.Log((object)$"[RapierDebug] EnableRapierAnimator called. Current _animatorReplaced status: {_animatorReplaced}");
			if (_animatorReplaced)
			{
				return;
			}
			if ((Object)(object)base.playerHeldBy == (Object)null)
			{
				Debug.LogWarning((object)"[RapierDebug] EnableRapierAnimator failed: playerHeldBy is null.");
				return;
			}
			Debug.Log((object)$"[RapierDebug] Rapier animators in Inspector - Local: {(Object)(object)rapierLocalAnimator != (Object)null}, Remote: {(Object)(object)rapierRemoteAnimator != (Object)null}");
			if (!_SAVED_ANIMATORS.ContainsKey(base.playerHeldBy.playerClientId))
			{
				Debug.Log((object)$"[RapierDebug] Saving original animator for client {base.playerHeldBy.playerClientId}: {((Object)base.playerHeldBy.playerBodyAnimator.runtimeAnimatorController).name}");
				_SAVED_ANIMATORS[base.playerHeldBy.playerClientId] = base.playerHeldBy.playerBodyAnimator.runtimeAnimatorController;
			}
			SaveAnimatorState(base.playerHeldBy.playerBodyAnimator);
			if ((Object)(object)base.playerHeldBy == (Object)(object)GameNetworkManager.Instance.localPlayerController)
			{
				Debug.Log((object)"[RapierDebug] Applying LOCAL rapier animator.");
				base.playerHeldBy.playerBodyAnimator.runtimeAnimatorController = rapierLocalAnimator;
			}
			else
			{
				Debug.Log((object)"[RapierDebug] Applying REMOTE rapier animator.");
				base.playerHeldBy.playerBodyAnimator.runtimeAnimatorController = rapierRemoteAnimator;
			}
			Debug.Log((object)"[RapierDebug] Rebinding and Updating animator...");
			base.playerHeldBy.playerBodyAnimator.Rebind();
			base.playerHeldBy.playerBodyAnimator.Update(0f);
			RestoreAnimatorState(base.playerHeldBy.playerBodyAnimator, isEquipping: true);
			_animatorReplaced = true;
			Debug.Log((object)"[RapierDebug] EnableRapierAnimator finished successfully.");
		}

		private void DisableRapierAnimator()
		{
			Debug.Log((object)$"[RapierDebug] DisableRapierAnimator called. Current _animatorReplaced status: {_animatorReplaced}");
			if (!_animatorReplaced)
			{
				return;
			}
			PlayerControllerB val = (PlayerControllerB)(((Object)(object)base.playerHeldBy != (Object)null) ? ((object)base.playerHeldBy) : ((object)previousPlayerHeldBy));
			if ((Object)(object)val == (Object)null)
			{
				Debug.LogWarning((object)"[RapierDebug] DisableRapierAnimator failed: Both playerHeldBy and previousPlayerHeldBy are null.");
				return;
			}
			SaveAnimatorState(val.playerBodyAnimator);
			if (_SAVED_ANIMATORS.TryGetValue(val.playerClientId, out RuntimeAnimatorController value))
			{
				Debug.Log((object)$"[RapierDebug] Restoring original animator for client {val.playerClientId}: {((Object)value).name}");
				val.playerBodyAnimator.runtimeAnimatorController = value;
				_SAVED_ANIMATORS.Remove(val.playerClientId);
			}
			else
			{
				Debug.LogError((object)$"[RapierDebug] FATAL: Could not find original animator in dictionary for client {val.playerClientId}!");
			}
			Debug.Log((object)"[RapierDebug] Rebinding and Updating original animator...");
			val.playerBodyAnimator.Rebind();
			val.playerBodyAnimator.Update(0f);
			RestoreAnimatorState(val.playerBodyAnimator, isEquipping: false);
			_animatorReplaced = false;
			Debug.Log((object)"[RapierDebug] DisableRapierAnimator finished successfully.");
		}

		private void SaveAnimatorState(Animator anim)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			_savedState = anim.GetCurrentAnimatorStateInfo(0);
			_savedNormalizedTime = ((AnimatorStateInfo)(ref _savedState)).normalizedTime;
			_savedCrouching = anim.GetBool("crouching");
			_savedWalking = anim.GetBool("Walking");
			_savedJumping = anim.GetBool("Jumping");
			_savedSprinting = anim.GetBool("Sprinting");
			Debug.Log((object)$"[RapierDebug] Saved State -> Hash: {((AnimatorStateInfo)(ref _savedState)).fullPathHash}, Time: {_savedNormalizedTime}, Walk: {_savedWalking}, Crouch: {_savedCrouching}");
		}

		private void RestoreAnimatorState(Animator anim, bool isEquipping)
		{
			Debug.Log((object)$"[RapierDebug] Restoring Animator State. isEquipping: {isEquipping}");
			try
			{
				anim.Play(((AnimatorStateInfo)(ref _savedState)).fullPathHash, 0, _savedNormalizedTime);
				anim.SetBool("crouching", _savedCrouching);
				anim.SetBool("Walking", _savedWalking);
				anim.SetBool("Jumping", _savedJumping);
				anim.SetBool("Sprinting", _savedSprinting);
				if (isEquipping)
				{
					Debug.Log((object)"[RapierDebug] Forcing 'HoldRapier' on layer 2...");
					anim.Play("HoldRapier", 2, 0f);
				}
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("[RapierDebug] Exception during RestoreAnimatorState: " + ex.Message));
			}
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			Debug.Log((object)$"[RapierDebug-Attack] ItemActivate called. buttonDown: {buttonDown}, IsOwner: {((NetworkBehaviour)this).IsOwner}");
			if ((Object)(object)rapierAudio != (Object)null && swingSFX != null && swingSFX.Length != 0)
			{
				int num = Random.Range(0, swingSFX.Length);
				rapierAudio.PlayOneShot(swingSFX[num], 1f);
			}
			if ((Object)(object)base.playerHeldBy != (Object)null)
			{
				previousPlayerHeldBy = base.playerHeldBy;
				if (((NetworkBehaviour)base.playerHeldBy).IsOwner)
				{
					Debug.Log((object)"[RapierDebug-Attack] Triggering 'SwingRapier' on player animator.");
					base.playerHeldBy.playerBodyAnimator.SetTrigger("SwingRapier");
					((MonoBehaviour)this).StartCoroutine(TraceAnimatorState(base.playerHeldBy.playerBodyAnimator, 2));
				}
			}
			if (((NetworkBehaviour)this).IsOwner)
			{
				Debug.Log((object)"[RapierDebug-Attack] We are the owner. Calling HitRapier()...");
				HitRapier();
			}
		}

		[IteratorStateMachine(typeof(<TraceAnimatorState>d__29))]
		private IEnumerator TraceAnimatorState(Animator anim, int layerIndex)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <TraceAnimatorState>d__29(0)
			{
				<>4__this = this,
				anim = anim,
				layerIndex = layerIndex
			};
		}

		public void HitRapier(bool cancel = false)
		{
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0296: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0596: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0355: Unknown result type (might be due to invalid IL or missing references)
			//IL_035a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e8: 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_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0365: Unknown result type (might be due to invalid IL or missing references)
			//IL_036a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0418: Unknown result type (might be due to invalid IL or missing references)
			//IL_041d: Unknown result type (might be due to invalid IL or missing references)
			//IL_046d: Unknown result type (might be due to invalid IL or missing references)
			Debug.Log((object)$"[RapierDebug-Attack] HitRapier started. cancel: {cancel}");
			if ((Object)(object)previousPlayerHeldBy == (Object)null)
			{
				Debug.LogWarning((object)"[RapierDebug-Attack] HitRapier aborted: previousPlayerHeldBy is null.");
				return;
			}
			previousPlayerHeldBy.activatingItem = false;
			bool flag = false;
			bool flag2 = false;
			int num = -1;
			bool flag3 = false;
			float num2 = Time.realtimeSinceStartup - timeAtLastDamageDealt;
			if (!cancel && num2 > 0.43f)
			{
				Debug.Log((object)$"[RapierDebug-Attack] Swing valid. Cooldown cleared ({num2}s elapsed). Casting sphere...");
				previousPlayerHeldBy.twoHanded = false;
				objectsHitByRapier = Physics.SphereCastAll(((Component)previousPlayerHeldBy.gameplayCamera).transform.position + ((Component)previousPlayerHeldBy.gameplayCamera).transform.right * 0.1f, 0.3f, ((Component)previousPlayerHeldBy.gameplayCamera).transform.forward, 2f, rapierMask, (QueryTriggerInteraction)2);
				objectsHitByRapierList = objectsHitByRapier.OrderBy((RaycastHit x) => ((RaycastHit)(ref x)).distance).ToList();
				Debug.Log((object)$"[RapierDebug-Attack] SphereCast found {objectsHitByRapierList.Count} colliders.");
				List<EnemyAI> list = new List<EnemyAI>();
				IHittable val2 = default(IHittable);
				for (int i = 0; i < objectsHitByRapierList.Count; i++)
				{
					RaycastHit val = objectsHitByRapierList[i];
					GameObject gameObject = ((Component)((RaycastHit)(ref val)).collider).gameObject;
					if (gameObject.layer == 8 || gameObject.layer == 11)
					{
						val = objectsHitByRapierList[i];
						if (((RaycastHit)(ref val)).collider.isTrigger)
						{
							continue;
						}
						flag = true;
						Debug.Log((object)$"[RapierDebug-Attack] Hit surface: {((Object)gameObject).name} (Layer: {gameObject.layer})");
						string tag = gameObject.tag;
						for (int j = 0; j < StartOfRound.Instance.footstepSurfaces.Length; j++)
						{
							if (StartOfRound.Instance.footstepSurfaces[j].surfaceTag == tag)
							{
								num = j;
								break;
							}
						}
						continue;
					}
					Debug.Log((object)$"[RapierDebug-Attack] Hit potential entity: {((Object)gameObject).name} (Layer: {gameObject.layer})");
					val = objectsHitByRapierList[i];
					if (((Component)((RaycastHit)(ref val)).transform).TryGetComponent<IHittable>(ref val2))
					{
						val = objectsHitByRapierList[i];
						if (!((Object)(object)((RaycastHit)(ref val)).transform == (Object)(object)((Component)previousPlayerHeldBy).transform))
						{
							val = objectsHitByRapierList[i];
							if (!(((RaycastHit)(ref val)).point == Vector3.zero))
							{
								Vector3 position = ((Component)previousPlayerHeldBy.gameplayCamera).transform.position;
								RaycastHit val3 = objectsHitByRapierList[i];
								if (Physics.Linecast(position, ((RaycastHit)(ref val3)).point, ref val, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1))
								{
									goto IL_0321;
								}
							}
							flag = true;
							Vector3 forward = ((Component)previousPlayerHeldBy.gameplayCamera).transform.forward;
							try
							{
								val = objectsHitByRapierList[i];
								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) && (!StartOfRound.Instance.hangarDoorsClosed || component.mainScript.isInsidePlayerShip == previousPlayerHeldBy.isInHangarShipRoom))
									{
										Debug.Log((object)("[RapierDebug-Attack] Valid Enemy Hit: " + ((Object)((Component)component.mainScript).gameObject).name));
										goto IL_0464;
									}
									Debug.Log((object)"[RapierDebug-Attack] Enemy hit rejected (Already hit this swing, or ship door blocked).");
									continue;
								}
								val = objectsHitByRapierList[i];
								if (!((Object)(object)((Component)((RaycastHit)(ref val)).transform).GetComponent<PlayerControllerB>() != (Object)null))
								{
									Debug.Log((object)"[RapierDebug-Attack] Valid Object Hit (Turret, Mine, etc).");
									goto IL_0464;
								}
								if (!flag3)
								{
									flag3 = true;
									Debug.Log((object)"[RapierDebug-Attack] Valid Player Hit.");
									goto IL_0464;
								}
								goto end_IL_035c;
								IL_0464:
								bool flag4 = val2.Hit(rapierHitForce, forward, previousPlayerHeldBy, true, 5);
								if (flag4 && (Object)(object)component != (Object)null)
								{
									list.Add(component.mainScript);
								}
								if (!flag2 && flag4)
								{
									flag2 = true;
									timeAtLastDamageDealt = Time.realtimeSinceStartup;
									if ((Object)(object)bloodParticle != (Object)null)
									{
										bloodParticle.Play(true);
									}
								}
								end_IL_035c:;
							}
							catch (Exception)
							{
							}
							continue;
						}
					}
					goto IL_0321;
					IL_0321:
					Debug.Log((object)("[RapierDebug-Attack] Entity " + ((Object)gameObject).name + " rejected (No IHittable, is self, or blocked by wall)."));
				}
			}
			else if (cancel)
			{
			}
			if (!flag)
			{
				return;
			}
			if ((Object)(object)rapierAudio != (Object)null && hitSFX != null && hitSFX.Length != 0)
			{
				int num3 = Random.Range(0, hitSFX.Length);
				rapierAudio.PlayOneShot(hitSFX[num3], 1f);
			}
			if ((Object)(object)Object.FindObjectOfType<RoundManager>() != (Object)null)
			{
				Object.FindObjectOfType<RoundManager>().PlayAudibleNoise(((Component)this).transform.position, 17f, 0.8f, 0, false, 0);
			}
			if (!flag2 && num != -1)
			{
				if ((Object)(object)rapierAudio != (Object)null)
				{
					rapierAudio.PlayOneShot(StartOfRound.Instance.footstepSurfaces[num].hitSurfaceSFX);
				}
				if ((Object)(object)rapierAudio != (Object)null)
				{
					WalkieTalkie.TransmitOneShotAudio(rapierAudio, StartOfRound.Instance.footstepSurfaces[num].hitSurfaceSFX, 1f);
				}
			}
			HitRapierServerRpc(num);
		}

		[ServerRpc]
		public void HitRapierServerRpc(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_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Invalid comparison between Unknown and I4
			//IL_0114: 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_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: 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_0084: Invalid comparison between Unknown and I4
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1802279907u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, hitSurfaceID);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1802279907u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				HitRapierClientRpc(hitSurfaceID);
			}
		}

		[ClientRpc]
		public void HitRapierClientRpc(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 val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(31426271u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, hitSurfaceID);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 31426271u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			if (!((NetworkBehaviour)this).IsOwner)
			{
				if ((Object)(object)rapierAudio != (Object)null && hitSFX != null && hitSFX.Length != 0)
				{
					int num = Random.Range(0, hitSFX.Length);
					rapierAudio.PlayOneShot(hitSFX[num], 1f);
				}
				if (hitSurfaceID != -1 && (Object)(object)rapierAudio != (Object)null)
				{
					rapierAudio.PlayOneShot(StartOfRound.Instance.footstepSurfaces[hitSurfaceID].hitSurfaceSFX);
					WalkieTalkie.TransmitOneShotAudio(rapierAudio, StartOfRound.Instance.footstepSurfaces[hitSurfaceID].hitSurfaceSFX, 1f);
				}
			}
		}

		protected override void __initializeVariables()
		{
			((GrabbableObject)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(1802279907u, new RpcReceiveHandler(__rpc_handler_1802279907), "HitRapierServerRpc");
			((NetworkBehaviour)this).__registerRpc(31426271u, new RpcReceiveHandler(__rpc_handler_31426271), "HitRapierClientRpc");
			((GrabbableObject)this).__initializeRpcs();
		}

		private static void __rpc_handler_1802279907(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Invalid comparison between Unknown and I4
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
			}
			else
			{
				int hitSurfaceID = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref hitSurfaceID);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((RapierItem)(object)target).HitRapierServerRpc(hitSurfaceID);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_31426271(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;
				((RapierItem)(object)target).HitRapierClientRpc(hitSurfaceID);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "RapierItem";
		}
	}
}
namespace Jinn
{
	internal class JinnAI : EnemyAI
	{
		[CompilerGenerated]
		private sealed class <FlickerLightsDuringStun>d__72 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public JinnAI <>4__this;

			private Light[] <allLights>5__1;

			private Dictionary<Light, float> <originalIntensities>5__2;

			private List<Light> <nearbyLights>5__3;

			private float <radiusSq>5__4;

			private Light[] <>s__5;

			private int <>s__6;

			private Light <l>5__7;

			private string <nameLower>5__8;

			private List<Light>.Enumerator <>s__9;

			private Light <l>5__10;

			private float <rand>5__11;

			private Dictionary<Light, float>.Enumerator <>s__12;

			private KeyValuePair<Light, float> <kvp>5__13;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<allLights>5__1 = null;
				<originalIntensities>5__2 = null;
				<nearbyLights>5__3 = null;
				<>s__5 = null;
				<l>5__7 = null;
				<nameLower>5__8 = null;
				<>s__9 = default(List<Light>.Enumerator);
				<l>5__10 = null;
				<>s__12 = default(Dictionary<Light, float>.Enumerator);
				<kvp>5__13 = default(KeyValuePair<Light, float>);
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_009c: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a2: Invalid comparison between Unknown and I4
				//IL_0113: Unknown result type (might be due to invalid IL or missing references)
				//IL_0123: Unknown result type (might be due to invalid IL or missing references)
				//IL_0128: Unknown result type (might be due to invalid IL or missing references)
				//IL_012d: Unknown result type (might be due to invalid IL or missing references)
				//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
				//IL_02ea: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>4__this.isFlickeringLights = true;
					<allLights>5__1 = Object.FindObjectsOfType<Light>();
					<originalIntensities>5__2 = new Dictionary<Light, float>();
					<nearbyLights>5__3 = new List<Light>();
					<radiusSq>5__4 = 100f;
					<>s__5 = <allLights>5__1;
					for (<>s__6 = 0; <>s__6 < <>s__5.Length; <>s__6++)
					{
						<l>5__7 = <>s__5[<>s__6];
						if (!((Object)(object)<l>5__7 == (Object)null) && (int)<l>5__7.type != 1)
						{
							<nameLower>5__8 = ((Object)((Component)<l>5__7).gameObject).name.ToLower();
							if (!<nameLower>5__8.Contains("helmet") && !<nameLower>5__8.Contains("visor") && !<nameLower>5__8.Contains("sun"))
							{
								Vector3 val = ((Component)<l>5__7).transform.position - ((Component)<>4__this).transform.position;
								if (((Vector3)(ref val)).sqrMagnitude <= <radiusSq>5__4)
								{
									<nearbyLights>5__3.Add(<l>5__7);
									<originalIntensities>5__2[<l>5__7] = <l>5__7.intensity;
								}
								<nameLower>5__8 = null;
								<l>5__7 = null;
							}
						}
					}
					<>s__5 = null;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if (((EnemyAI)<>4__this).stunNormalizedTimer > 0f && !((EnemyAI)<>4__this).isEnemyDead)
				{
					<>s__9 = <nearbyLights>5__3.GetEnumerator();
					try
					{
						while (<>s__9.MoveNext())
						{
							<l>5__10 = <>s__9.Current;
							if ((Object)(object)<l>5__10 != (Object)null && <originalIntensities>5__2.ContainsKey(<l>5__10))
							{
								<rand>5__11 = Random.value;
								if (<rand>5__11 > 0.8f)
								{
									<l>5__10.intensity = <originalIntensities>5__2[<l>5__10] * 2.5f;
								}
								else if (<rand>5__11 > 0.5f)
								{
									<l>5__10.intensity = <originalIntensities>5__2[<l>5__10] * 0.1f;
								}
								else
								{
									<l>5__10.intensity = <originalIntensities>5__2[<l>5__10];
								}
							}
							<l>5__10 = null;
						}
					}
					finally
					{
						((IDisposable)<>s__9).Dispose();
					}
					<>s__9 = default(List<Light>.Enumerator);
					<>2__current = (object)new WaitForSeconds(0.1f);
					<>1__state = 1;
					return true;
				}
				<>s__12 = <originalIntensities>5__2.GetEnumerator();
				try
				{
					while (<>s__12.MoveNext())
					{
						<kvp>5__13 = <>s__12.Current;
						if ((Object)(object)<kvp>5__13.Key != (Object)null)
						{
							<kvp>5__13.Key.intensity = <kvp>5__13.Value;
						}
						<kvp>5__13 = default(KeyValuePair<Light, float>);
					}
				}
				finally
				{
					((IDisposable)<>s__12).Dispose();
				}
				<>s__12 = default(Dictionary<Light, float>.Enumerator);
				<>4__this.isFlickeringLights = false;
				return false;
			}

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

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

		private Random enemyRandom = null;

		private int baseSpeed;

		private int attackCooldownSlow;

		private float minDistance;

		private float maxDistance;

		private bool canTeleport;

		private float teleportWarningDelay;

		private float maxDistanceAfterWarning;

		private float minDistanceAfterWarning;

		private bool canBeBurned;

		private bool burnLights;

		private int flashlightDrainPercentage;

		private int burnSlowdown;

		private int attackDamage;

		public SkinnedMeshRenderer skin;

		public Material[] thisMaterial;

		public GameObject BloodParticles;

		public GameObject TeleportSwirl;

		private GameObject currentNetworkSwirl;

		public GameObject GramophonePropPrefab;

		private bool hasHeardGramophone = false;

		private Vector3 lastPosition;

		private bool hasLOS;

		public float chaseTimer = 0f;

		private bool isPreparingTeleport = false;

		private float teleportWarningTimer = 0f;

		private Vector3 pendingTeleportPosition;

		private PlayerControllerB pendingTeleportTarget;

		private bool hasAttemptedLastDitchTp = false;

		private bool isManifesting = false;

		private bool isFlickeringLights = false;

		private bool wasBeingBurned = false;

		public bool isCurrentlyBurning = false;

		private bool isChasingPitch = false;

		public Renderer[] rapierRenderers;

		private float gramoDash;

		private float timeSinceLastAttack;

		private float timeSinceSeen;

		private float timesinceHearingGramophone;

		private float tpRollTimer;

		private float continuousChaseTimer = 0f;

		public float teleportCooldown = 15f;

		private float teleportCooldownTimer = 0f;

		private Vector3 targetGramophonePos;

		public AudioSource movementAudio;

		public AudioClip unsheathSFX;

		public AudioClip laughSFX;

		public AudioClip swingSFX;

		public AudioClip[] teleportSFX;

		public AudioClip chargeUpTPSFX;

		public AudioClip creaturePainSFX;

		public ParticleSystem mistParticles;

		public ParticleSystem decayingMatterParticles;

		[Conditional("DEBUG")]
		private void LogIfDebugBuild(string text)
		{
			if (Plugin.Logger != null)
			{
				Plugin.Logger.LogInfo((object)text);
			}
			else
			{
				Debug.Log((object)("[Jinn] " + text));
			}
		}

		public override void Start()
		{
			((EnemyAI)this).Start();
			base.updatePositionThreshold = 0.5f;
			baseSpeed = ((AssetBundleLoader<JinnContentHandler.JinnAssets>)(object)ContentHandler<JinnContentHandler>.Instance.jinnAssets).GetConfig<int>("ConfigJinnBaseSpeed").Value;
			attackCooldownSlow = ((AssetBundleLoader<JinnContentHandler.JinnAssets>)(object)ContentHandler<JinnContentHandler>.Instance.jinnAssets).GetConfig<int>("ConfigJinnAttackCooldownSlow").Value;
			minDistance = ((AssetBundleLoader<JinnContentHandler.JinnAssets>)(object)ContentHandler<JinnContentHandler>.Instance.jinnAssets).GetConfig<float>("ConfigJinnMinVisibleDist").Value;
			maxDistance = ((AssetBundleLoader<JinnContentHandler.JinnAssets>)(object)ContentHandler<JinnContentHandler>.Instance.jinnAssets).GetConfig<float>("ConfigJinnMaxVisibleDist").Value;
			canTeleport = ((AssetBundleLoader<JinnContentHandler.JinnAssets>)(object)ContentHandler<JinnContentHandler>.Instance.jinnAssets).GetConfig<bool>("ConfigJinnCanTeleport").Value;
			teleportWarningDelay = ((AssetBundleLoader<JinnContentHandler.JinnAssets>)(object)ContentHandler<JinnContentHandler>.Instance.jinnAssets).GetConfig<float>("ConfigJinnTPWarnDelay").Value;
			maxDistanceAfterWarning = ((AssetBundleLoader<JinnContentHandler.JinnAssets>)(object)ContentHandler<JinnContentHandler>.Instance.jinnAssets).GetConfig<float>("ConfigJinnMaxDistAfterDelay").Value;
			minDistanceAfterWarning = ((AssetBundleLoader<JinnContentHandler.JinnAssets>)(object)ContentHandler<JinnContentHandler>.Instance.jinnAssets).GetConfig<float>("ConfigJinnMinnDistAfterDelay").Value;
			canBeBurned = ((AssetBundleLoader<JinnContentHandler.JinnAssets>)(object)ContentHandler<JinnContentHandler>.Instance.jinnAssets).GetConfig<bool>("ConfigJinnCanBeBurned").Value;
			burnLights = ((AssetBundleLoader<JinnContentHandler.JinnAssets>)(object)ContentHandler<JinnContentHandler>.Instance.jinnAssets).GetConfig<bool>("ConfigJinnBurnLights").Value;
			flashlightDrainPercentage = ((AssetBundleLoader<JinnContentHandler.JinnAssets>)(object)ContentHandler<JinnContentHandler>.Instance.jinnAssets).GetConfig<int>("ConfigJinnFlashlightConsumption").Value;
			burnSlowdown = ((AssetBundleLoader<JinnContentHandler.JinnAssets>)(object)ContentHandler<JinnContentHandler>.Instance.jinnAssets).GetConfig<int>("ConfigJinnBurnSlowdown").Value;
			attackDamage = ((AssetBundleLoader<JinnContentHandler.JinnAssets>)(object)ContentHandler<JinnContentHandler>.Instance.jinnAssets).GetConfig<int>("ConfigJinnAttackDamage").Value;
			List<Material> list = new List<Material>();
			if ((Object)(object)skin != (Object)null)
			{
				list.AddRange(((Renderer)skin).materials);
			}
			if (rapierRenderers != null)
			{
				Renderer[] array = rapierRenderers;
				foreach (Renderer val in array)
				{
					if ((Object)(object)val != (Object)null)
					{
						list.AddRange(val.materials);
					}
				}
			}
			thisMaterial = list.ToArray();
			((EnemyAI)this).GetAINodes();
			enemyRandom = new Random(StartOfRound.Instance.randomMapSeed + base.thisEnemyIndex);
			if ((Object)(object)base.creatureVoice != (Object)null)
			{
				base.creatureVoice.Play();
			}
			LogIfDebugBuild("Jinn Spawned");
			SpawnCursedGramophoneLocally();
		}

		private void OnEnable()
		{
			JinnEventManager.OnShipLeft += HandleShipLeft;
		}

		private void OnDisable()
		{
			JinnEventManager.OnShipLeft -= HandleShipLeft;
		}

		private void HandleShipLeft()
		{
			Plugin.Logger.LogInfo((object)"Ship is leaving! Cleaning up");
			if ((Object)(object)base.creatureVoice != (Object)null)
			{
				base.creatureVoice.Stop();
			}
			((EnemyAI)this).KillEnemy(true);
		}

		private Vector3 GetFloorPosition(Vector3 startPos)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: 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_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: 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_003b: 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_0047: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = startPos + Vector3.up * 0.5f;
			RaycastHit val2 = default(RaycastHit);
			if (Physics.Raycast(val, Vector3.down, ref val2, 10f, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1))
			{
				return ((RaycastHit)(ref val2)).point;
			}
			return startPos;
		}

		public void SpawnCursedGramophoneLocally()
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: 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_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			if (!((NetworkBehaviour)this).IsServer)
			{
				return;
			}
			if ((Object)(object)GramophonePropPrefab == (Object)null)
			{
				LogIfDebugBuild("GramophonePropPrefab is missing! Cannot spawn the prop.");
				return;
			}
			Vector3 startPos = ((Component)this).transform.position + Vector3.up * 1.5f;
			bool flag = false;
			RandomScrapSpawn[] array = Object.FindObjectsOfType<RandomScrapSpawn>();
			if (array != null && array.Length != 0 && base.allAINodes != null && base.allAINodes.Length != 0)
			{
				for (int i = 0; i < 15; i++)
				{
					RandomScrapSpawn val = array[enemyRandom.Next(0, array.Length)];
					bool flag2 = false;
					GameObject[] allAINodes = base.allAINodes;
					foreach (GameObject val2 in allAINodes)
					{
						if ((Object)(object)val2 != (Object)null && Vector3.Distance(((Component)val).transform.position, val2.transform.position) <= 15f)
						{
							flag2 = true;
							break;
						}
					}
					if (flag2)
					{
						Vector3 navMeshPosition = RoundManager.Instance.GetNavMeshPosition(((Component)val).transform.position, RoundManager.Instance.navHit, 3f, -1);
						if (RoundManager.Instance.GotNavMeshPositionResult)
						{
							startPos = navMeshPosition;
							flag = true;
							break;
						}
					}
				}
			}
			if (!flag && base.allAINodes != null && base.allAINodes.Length != 0)
			{
				GameObject val3 = base.allAINodes[enemyRandom.Next(0, base.allAINodes.Length)];
				if ((Object)(object)val3 != (Object)null)
				{
					startPos = val3.transform.position;
					LogIfDebugBuild("Failed to find valid scrap node. Falling back to an AI Node");
				}
			}
			startPos = GetFloorPosition(startPos);
			GameObject val4 = Object.Instantiate<GameObject>(GramophonePropPrefab, startPos, Quaternion.identity);
			val4.GetComponent<NetworkObject>().Spawn(false);
			LogIfDebugBuild("Dropped Gramophone PROP at valid node, snapped to the floor!");
		}

		public void SpawnRapierLocally()
		{
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: 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_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: 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_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			if (!((NetworkBehaviour)this).IsServer)
			{
				return;
			}
			Item val = null;
			foreach (Item items in StartOfRound.Instance.allItemsList.itemsList)
			{
				if (items.itemName == "Rapier")
				{
					val = items;
					break;
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				LogIfDebugBuild("Rapier item not found in allItemsList!");
				return;
			}
			Vector3 val2 = ((Component)this).transform.position + Vector3.up * 1.5f;
			Vector3 val3 = RoundManager.Instance.GetNavMeshPosition(val2, RoundManager.Instance.navHit, 5f, -1);
			if (!RoundManager.Instance.GotNavMeshPositionResult)
			{
				val3 = val2;
			}
			GameObject val4 = Object.Instantiate<GameObject>(val.spawnPrefab, val3, Quaternion.identity, StartOfRound.Instance.propsContainer);
			GrabbableObject component = val4.GetComponent<GrabbableObject>();
			component.fallTime = 0f;
			component.targetFloorPosition = component.GetItemFloorPosition(val3);
			int scrapValue = (int)((float)Random.Range(val.minValue, val.maxValue) * RoundManager.Instance.scrapValueMultiplier);
			component.SetScrapValue(scrapValue);
			NetworkObject component2 = val4.GetComponent<NetworkObject>();
			component2.Spawn(false);
			SyncScrapValueClientRpc(NetworkObjectReference.op_Implicit(component2), scrapValue);
			component.EnableItemMeshes(true);
			LogIfDebugBuild("Dropped Rapier item upon Jinn defeat");
		}

		[ClientRpc]
		public void SyncScrapValueClientRpc(NetworkObjectReference netObjRef, int scrapValue)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3032411812u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref netObjRef, default(ForNetworkSerializable));
				BytePacker.WriteValueBitPacked(val2, scrapValue);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3032411812u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			NetworkObject val3 = default(NetworkObject);
			if (((NetworkObjectReference)(ref netObjRef)).TryGet(ref val3, (NetworkManager)null))
			{
				GrabbableObject component = ((Component)val3).GetComponent<GrabbableObject>();
				if ((Object)(object)component != (Object)null)
				{
					component.SetScrapValue(scrapValue);
				}
			}
		}

		public override void Update()
		{
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Update();
			timeSinceLastAttack += Time.deltaTime;
			if (isCurrentlyBurning)
			{
				base.stunNormalizedTimer = 1f;
			}
			SetVisibility();
			DrainLocalFlashlightBattery();
			if ((Object)(object)base.creatureVoice != (Object)null)
			{
				float num = (isChasingPitch ? 0.8f : 1f);
				base.creatureVoice.pitch = Mathf.Lerp(base.creatureVoice.pitch, num, Time.deltaTime * 0.8f);
			}
			if (base.isEnemyDead || StartOfRound.Instance.allPlayersDead)
			{
				return;
			}
			if (!hasLOS && chaseTimer > 0f)
			{
				chaseTimer -= Time.deltaTime;
			}
			if (!((NetworkBehaviour)this).IsOwner)
			{
				return;
			}
			timeSinceSeen += Time.deltaTime;
			timesinceHearingGramophone += Time.deltaTime;
			if (IsBeingBurnedByFlashlight())
			{
				base.agent.speed = burnSlowdown;
				if (!wasBeingBurned)
				{
					wasBeingBurned = true;
					SetBurningStateClientRpc(isBurning: true);
				}
			}
			else if (wasBeingBurned)
			{
				wasBeingBurned = false;
				SetBurningStateClientRpc(isBurning: false);
			}
			if (base.stunNormalizedTimer > 0f && !isFlickeringLights && !base.isEnemyDead)
			{
				((MonoBehaviour)this).StartCoroutine(FlickerLightsDuringStun());
			}
			if ((Object)(object)base.targetPlayer != (Object)null)
			{
				float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position);
				if (num2 <= maxDistance && !isManifesting)
				{
					isManifesting = true;
					SetManifestingStateServerRpc(manifesting: true);
				}
				else if (num2 > maxDistance + 5f && isManifesting)
				{
					isManifesting = false;
				}
			}
			else
			{
				isManifesting = false;
			}
			if (isPreparingTeleport)
			{
				teleportWarningTimer -= Time.deltaTime;
				if (teleportWarningTimer <= 0f)
				{
					ExecuteDelayedTeleport();
				}
			}
			if (base.isEnemyDead)
			{
				base.agent.speed = 0f;
				return;
			}
			if (teleportCooldownTimer > 0f)
			{
				teleportCooldownTimer -= Time.deltaTime;
			}
			if ((Object)(object)base.targetPlayer != (Object)null)
			{
				continuousChaseTimer += Time.deltaTime;
				if (continuousChaseTimer >= 5f && !isPreparingTeleport && teleportCooldownTimer <= 0f)
				{
					tpRollTimer += Time.deltaTime;
					if (tpRollTimer >= 5f)
					{
						tpRollTimer = 0f;
						if (Random.value <= 0.8f)
						{
							LogIfDebugBuild("Teleport has been accepted");
							TpNearestNode(base.targetPlayer);
						}
						else
						{
							LogIfDebugBuild("Teleport denied. Will try again in 5 seconds.");
						}
					}
				}
			}
			else
			{
				continuousChaseTimer = 0f;
				tpRollTimer = 0f;
			}
			if (hasHeardGramophone)
			{
				base.agent.speed = gramoDash;
				if (timesinceHearingGramophone > 35f)
				{
					hasHeardGramophone = false;
					LogIfDebugBuild("Gramophone timeout reached. Baclk to normal speed.");
				}
			}
			else if (timeSinceLastAttack < 2f)
			{
				base.agent.speed = attackCooldownSlow;
			}
			else
			{
				base.agent.speed = baseSpeed;
			}
			base.syncMovementSpeed = base.agent.speed;
		}

		public override 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_00a8: 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_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_032b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).DoAIInterval();
			if (base.isEnemyDead || StartOfRound.Instance.allPlayersDead)
			{
				return;
			}
			if (hasHeardGramophone)
			{
				if (!(Vector3.Distance(((Component)this).transform.position, targetGramophonePos) <= 3f))
				{
					base.moveTowardsDestination = true;
					((EnemyAI)this).SetDestinationToPosition(targetGramophonePos, true);
					return;
				}
				hasHeardGramophone = false;
				CancelGramophoneServerRpc();
			}
			if ((Object)(object)base.targetPlayer != (Object)null)
			{
				if (((EnemyAI)this).CheckLineOfSightForPosition(((Component)base.targetPlayer.gameplayCamera).transform.position, 120f, 60, -1f, (Transform)null))
				{
					hasLOS = true;
					if (!isChasingPitch)
					{
						SetPitchStateServerRpc(chasing: true);
					}
					timeSinceSeen = 0f;
					chaseTimer = 10f;
					lastPosition = ((Component)base.targetPlayer).transform.position;
					hasAttemptedLastDitchTp = false;
					if (base.currentSearch != null && base.currentSearch.inProgress)
					{
						((EnemyAI)this).StopSearch(base.currentSearch, true);
					}
					((EnemyAI)this).SetMovingTowardsTargetPlayer(base.targetPlayer);
					return;
				}
				hasLOS = false;
				if (chaseTimer <= 0f)
				{
					if (isChasingPitch)
					{
						SetPitchStateServerRpc(chasing: false);
					}
					CheckAndFireLastDitchTeleport();
					base.targetPlayer = null;
					if (base.currentSearch == null || !base.currentSearch.inProgress)
					{
						((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
					}
				}
				else
				{
					((EnemyAI)this).SetDestinationToPosition(lastPosition, false);
					if (Vector3.Distance(((Component)this).transform.position, lastPosition) <= 2f)
					{
						CheckAndFireLastDitchTeleport();
						chaseTimer = 0f;
					}
					else if (chaseTimer <= 7f)
					{
						CheckAndFireLastDitchTeleport();
					}
				}
				return;
			}
			hasLOS = false;
			if (((EnemyAI)this).TargetClosestPlayer(5f, true, 120f, false, false, true))
			{
				hasLOS = true;
				if (!isChasingPitch)
				{
					SetPitchStateServerRpc(chasing: true);
				}
				timeSinceSeen = 0f;
				chaseTimer = 10f;
				lastPosition = ((Component)base.targetPlayer).transform.position;
				hasAttemptedLastDitchTp = false;
				if (base.currentSearch != null && base.currentSearch.inProgress)
				{
					((EnemyAI)this).StopSearch(base.currentSearch, true);
				}
				((EnemyAI)this).SetMovingTowardsTargetPlayer(base.targetPlayer);
			}
			else if (base.currentSearch == null || !base.currentSearch.inProgress)
			{
				if (isChasingPitch)
				{
					SetPitchStateServerRpc(chasing: false);
				}
				((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
			}
		}

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

		[ClientRpc]
		public void SetPitchStateClientRpc(bool chasing)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(4086901024u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref chasing, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4086901024u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					isChasingPitch = chasing;
				}
			}
		}

		private void CheckAndFireLastDitchTeleport()
		{
			if (!hasAttemptedLastDitchTp && !isPreparingTeleport && (Object)(object)base.targetPlayer != (Object)null && teleportCooldownTimer <= 0f)
			{
				hasAttemptedLastDitchTp = true;
				if (Random.value <= 0.75f)
				{
					LogIfDebugBuild("Lost target, attempting TP.");
					TpToCutoffNode(base.targetPlayer);
				}
			}
		}

		private void TpToCutoffNode(PlayerControllerB targetPlayer)
		{
			//IL_004c: 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_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: 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_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			if (!canTeleport || (Object)(object)targetPlayer == (Object)null || targetPlayer.isPlayerDead || base.allAINodes == null || base.allAINodes.Length == 0)
			{
				return;
			}
			Vector3 velocity = targetPlayer.thisController.velocity;
			if (((Vector3)(ref velocity)).sqrMagnitude < 1f)
			{
				LogIfDebugBuild("Player is standing still. Falling back to normal LDTp.");
				TpNearestNode(targetPlayer);
				return;
			}
			Vector3 val = ((Component)targetPlayer).transform.position + ((Vector3)(ref velocity)).normalized * 15f;
			List<GameObject> list = new List<GameObject>();
			float num = 12f;
			GameObject[] allAINodes = base.allAINodes;
			foreach (GameObject val2 in allAINodes)
			{
				if (!((Object)(object)val2 == (Object)null) && Vector3.Distance(val2.transform.position, val) <= num)
				{
					list.Add(val2);
				}
			}
			if (list.Count > 0)
			{
				GameObject val3 = list[enemyRandom.Next(0, list.Count)];
				pendingTeleportPosition = val3.transform.position;
				pendingTeleportTarget = targetPlayer;
				teleportWarningTimer = teleportWarningDelay;
				isPreparingTeleport = true;
				if ((Object)(object)movementAudio != (Object)null && (Object)(object)chargeUpTPSFX != (Object)null)
				{
					movementAudio.PlayOneShot(chargeUpTPSFX, 0.8f);
				}
				if (!((NetworkBehaviour)this).IsServer || !((Object)(object)TeleportSwirl != (Object)null))
				{
					return;
				}
				Vector3 val4 = pendingTeleportPosition + Vector3.up * 1.5f;
				currentNetworkSwirl = Object.Instantiate<GameObject>(TeleportSwirl, val4, Quaternion.identity);
				if ((Object)(object)currentNetworkSwirl != (Object)null)
				{
					NetworkObject component = currentNetworkSwirl.GetComponent<NetworkObject>();
					if ((Object)(object)component != (Object)null)
					{
						component.Spawn(true);
					}
				}
			}
			else
			{
				LogIfDebugBuild("No nodes found ahead of the player. Falling back to normal LDTp.");
				TpNearestNode(targetPlayer);
			}
		}

		private bool IsBeingBurnedByFlashlight()
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			if (!canBeBurned)
			{
				return false;
			}
			PlayerControllerB[] allPlayersInLineOfSight = ((EnemyAI)this).GetAllPlayersInLineOfSight(360f, 15, (Transform)null, -1f, -1);
			if (allPlayersInLineOfSight == null || allPlayersInLineOfSight.Length == 0)
			{
				return false;
			}
			PlayerControllerB[] array = allPlayersInLineOfSight;
			foreach (PlayerControllerB val in array)
			{
				Vector3 val2 = ((Component)this).transform.position - ((Component)val).transform.position;
				float num = Vector3.Angle(((Component)val).transform.forward, val2);
				if (Mathf.Abs(num) > 30f)
				{
					continue;
				}
				if ((Object)(object)val.pocketedFlashlight != (Object)null && val.pocketedFlashlight.isBeingUsed && val.pocketedFlashlight.insertedBattery != null && val.pocketedFlashlight.insertedBattery.charge > 0f)
				{
					return true;
				}
				GrabbableObject currentlyHeldObjectServer = val.currentlyHeldObjectServer;
				if (val.isHoldingObject && (Object)(object)currentlyHeldObjectServer != (Object)null)
				{
					FlashlightItem val3 = (FlashlightItem)(object)((currentlyHeldObjectServer is FlashlightItem) ? currentlyHeldObjectServer : null);
					if (val3 != null && ((GrabbableObject)val3).isBeingUsed && ((GrabbableObject)val3).insertedBattery != null && ((GrabbableObject)val3).insertedBattery.charge > 0f)
					{
						return true;
					}
				}
			}
			return false;
		}

		[ClientRpc]
		public void SetBurningStateClientRpc(bool isBurning)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1937438416u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref isBurning, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1937438416u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			isCurrentlyBurning = isBurning;
			base.creatureAnimator.SetBool("isBeingBurned", isBurning);
			if (isBurning)
			{
				LogIfDebugBuild("Jinn is being burned");
				if ((Object)(object)base.creatureVoice != (Object)null)
				{
					base.creatureVoice.Pause();
				}
				if ((Object)(object)base.creatureSFX != (Object)null && (Object)(object)creaturePainSFX != (Object)null)
				{
					base.creatureSFX.PlayOneShot(creaturePainSFX);
				}
				if (burnLights && !isFlickeringLights && !base.isEnemyDead)
				{
					((MonoBehaviour)this).StartCoroutine(FlickerLightsDuringStun());
				}
			}
			else if ((Object)(object)base.creatureVoice != (Object)null)
			{
				base.creatureVoice.Play();
			}
		}

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

		[ClientRpc]
		public void SetManifestingStateClientRpc(bool manifesting)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1475831853u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref manifesting, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1475831853u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					base.creatureAnimator.SetTrigger("isManifesting");
					base.creatureSFX.PlayOneShot(unsheathSFX);
				}
			}
		}

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

		private void TpNearestNode(PlayerControllerB targetPlayer)
		{
			//IL_007b: 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_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			if (!canTeleport || (Object)(object)targetPlayer == (Object)null || targetPlayer.isPlayerDead || base.allAINodes == null || base.allAINodes.Length == 0)
			{
				return;
			}
			List<GameObject> list = new List<GameObject>();
			float num = 10f;
			GameObject[] allAINodes = base.allAINodes;
			foreach (GameObject val in allAINodes)
			{
				if (!((Object)(object)val == (Object)null) && Vector3.Distance(val.transform.position, ((Component)targetPlayer).transform.position) <= num)
				{
					list.Add(val);
				}
			}
			if (list.Count > 0)
			{
				GameObject val2 = list[enemyRandom.Next(0, list.Count)];
				pendingTeleportPosition = val2.transform.position;
				pendingTeleportTarget = targetPlayer;
				teleportWarningTimer = teleportWarningDelay;
				isPreparingTeleport = true;
				teleportCooldownTimer = teleportCooldown;
				if ((Object)(object)movementAudio != (Object)null && (Object)(object)chargeUpTPSFX != (Object)null)
				{
					movementAudio.PlayOneShot(chargeUpTPSFX, 0.8f);
				}
				LogIfDebugBuild($"Found {list.Count} nodes. Spawning warning swirl and starting timer");
				if (!((NetworkBehaviour)this).IsServer || !((Object)(object)TeleportSwirl != (Object)null))
				{
					return;
				}
				Vector3 val3 = pendingTeleportPosition + Vector3.up * 1.5f;
				currentNetworkSwirl = Object.Instantiate<GameObject>(TeleportSwirl, val3, Quaternion.identity);
				if (!((Object)(object)currentNetworkSwirl != (Object)null))
				{
					return;
				}
				NetworkObject component = currentNetworkSwirl.GetComponent<NetworkObject>();
				if ((Object)(object)component != (Object)null)
				{
					try
					{
						component.Spawn(true);
					}
					catch (Exception ex)
					{
						LogIfDebugBuild("DEBUG CRITICAL ERROR: Netcode threw an exception during Spawn()! " + ex.Message + "\n" + ex.StackTrace);
					}
				}
			}
			else
			{
				LogIfDebugBuild("No AI nodes found within 10 units. Teleport cancelled");
			}
		}

		private void ExecuteDelayedTeleport()
		{
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			isPreparingTeleport = false;
			tpRollTimer = 0f;
			if (((NetworkBehaviour)this).IsServer && (Object)(object)currentNetworkSwirl != (Object)null)
			{
				currentNetworkSwirl.GetComponent<NetworkObject>().Despawn(true);
				currentNetworkSwirl = null;
			}
			if ((Object)(object)pendingTeleportTarget == (Object)null || pendingTeleportTarget.isPlayerDead)
			{
				LogIfDebugBuild("Target lost, no tp for me :(");
				return;
			}
			float num = Vector3.Distance(((Component)this).transform.position, ((Component)pendingTeleportTarget).transform.position);
			float num2 = Vector3.Distance(pendingTeleportPosition, ((Component)pendingTeleportTarget).transform.position);
			if (num <= 4f)
			{
				LogIfDebugBuild($"Player is only {num} units away from Obake. Canceling teleport to attack");
			}
			else if (num <= num2)
			{
				LogIfDebugBuild($"Obake ({num}u) is closer than smoke ({num2}u). Cancelling teleport");
			}
			else if (num2 <= maxDistanceAfterWarning && num2 >= minDistanceAfterWarning)
			{
				LogIfDebugBuild($"Player is {num2} units away from Swirl. I am tp'ing!!");
				if (((NetworkBehaviour)this).IsServer)
				{
					TeleportObakeClientRpc(pendingTeleportPosition);
				}
				else
				{
					TeleportObakeServerRpc(pendingTeleportPosition);
				}
			}
			else
			{
				LogIfDebugBuild($"Player too far from TP smoke! They are {num2} units away from Swirl.");
			}
		}

		private void TeleportObakeLocally(Vector3 newPos)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			((Behaviour)base.agent).enabled = false;
			((Component)this).transform.position = newPos;
			((Behaviour)base.agent).enabled = true;
			if (base.agent.isOnNavMesh)
			{
				base.agent.Warp(newPos);
			}
			base.serverPosition = newPos;
			if ((Object)(object)base.creatureSFX != (Object)null && teleportSFX != null)
			{
				AudioClip val = ((teleportSFX.Length != 0) ? teleportSFX[enemyRandom.Next(teleportSFX.Length)] : null);
				if ((Object)(object)val != (Object)null)
				{
					base.creatureSFX.PlayOneShot(val);
				}
			}
			if ((Object)(object)base.creatureSFX != (Object)null && (Object)(object)laughSFX != (Object)null)
			{
				base.creatureSFX.PlayOneShot(laughSFX);
			}
		}

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

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

		private void DrainLocalFlashlightBattery()
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)GameNetworkManager.Instance == (Object)null || base.isEnemyDead)
			{
				return;
			}
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			if ((Object)(object)localPlayerController == (Object)null || localPlayerController.isPlayerDead)
			{
				return;
			}
			float num = Vector3.Distance(((Component)this).transform.position, ((Component)localPlayerController).transform.position);
			FlashlightItem val = null;
			if ((Object)(object)localPlayerController.pocketedFlashlight != (Object)null)
			{
				GrabbableObject pocketedFlashlight = localPlayerController.pocketedFlashlight;
				FlashlightItem val2 = (FlashlightItem)(object)((pocketedFlashlight is FlashlightItem) ? pocketedFlashlight : null);
				if (val2 != null)
				{
					val = val2;
					goto IL_00c9;
				}
			}
			if ((Object)(object)localPlayerController.currentlyHeldObjectServer != (Object)null)
			{
				GrabbableObject currentlyHeldObjectServer = localPlayerController.currentlyHeldObjectServer;
				FlashlightItem val3 = (FlashlightItem)(object)((currentlyHeldObjectServer is FlashlightItem) ? currentlyHeldObjectServer : null);
				if (val3 != null)
				{
					val = val3;
				}
			}
			goto IL_00c9;
			IL_00c9:
			if (!((Object)(object)val != (Object)null))
			{
				return;
			}
			if (num > 30f || !((GrabbableObject)val).isBeingUsed)
			{
				if (val.flashlightInterferenceLevel == 1)
				{
					val.flashlightInterferenceLevel = 0;
				}
			}
			else if (((GrabbableObject)val).insertedBattery != null && ((GrabbableObject)val).insertedBattery.charge > 0f)
			{
				float num2 = (float)flashlightDrainPercentage / 100f;
				Battery in