Decompiled source of Surfaced v1.4.9

LC-Surfaced/Surfaced.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using On;
using On.GameNetcodeStuff;
using SolidLib;
using SolidLib.Components;
using SolidLib.Components.Sound;
using SolidLib.Registry;
using SolidLib.Utils;
using Surfaced;
using Surfaced.Configuration;
using Surfaced.NetcodePatcher;
using Surfaced.Patches;
using Unity.Mathematics;
using Unity.Netcode;
using Unity.Netcode.Components;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Events;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Surfaced")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Adds Aquatic themed content.")]
[assembly: AssemblyFileVersion("1.4.9.0")]
[assembly: AssemblyInformationalVersion("1.4.9+9aec5900c48bc067cd3a535ae754d34eae62b253")]
[assembly: AssemblyProduct("Surfaced")]
[assembly: AssemblyTitle("Surfaced")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.4.9.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
public class Bertha : NetworkBehaviour, IHittable
{
	public bool hasExploded;

	public GameObject BoomLight;

	public ParticleSystem explosionParticle;

	public AudioSource mineAudio;

	public AudioSource FarAudio;

	public AudioSource PingAudio;

	public AudioClip mineDetonate;

	public AudioClip mineTrigger;

	public AudioClip mineBeep;

	public AudioClip BerthaBoom;

	private Random random;

	private void Start()
	{
		random = new Random(StartOfRound.Instance.randomMapSeed + 23);
		((MonoBehaviour)this).StartCoroutine(StartIdleAnimation());
	}

	private IEnumerator StartIdleAnimation()
	{
		while (true)
		{
			yield return (object)new WaitForSeconds((float)random.Next(20, 40));
			PingAudio.PlayOneShot(mineBeep, 0.1f);
			mineAudio.pitch = (float)random.NextDouble() * 0.2f + 0.9f;
		}
	}

	private void OnTriggerEnter(Collider other)
	{
		if (hasExploded)
		{
			return;
		}
		if (((Component)other).CompareTag("Player"))
		{
			PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
			if ((Object)(object)component != (Object)null && !component.isPlayerDead && (Object)(object)component == (Object)(object)GameNetworkManager.Instance.localPlayerController)
			{
				TriggerMineOnLocalClientByExiting(Array.IndexOf(StartOfRound.Instance.allPlayerScripts, component));
			}
		}
		else if ((((Component)other).tag.StartsWith("PlayerRagdoll") || ((Component)other).CompareTag("PhysicsProp")) && !((Object)(object)((Component)other).GetComponent<DeadBodyInfo>() == (Object)null) && !((Object)(object)((Component)other).GetComponent<DeadBodyInfo>().playerScript != (Object)(object)GameNetworkManager.Instance.localPlayerController) && !((Object)(object)((Component)other).GetComponent<GrabbableObject>() == (Object)null) && ((NetworkBehaviour)((Component)other).GetComponent<GrabbableObject>()).NetworkObject.IsOwner)
		{
			TriggerMineOnLocalClientByExiting(-1);
		}
	}

	private void TriggerMineOnLocalClientByExiting(int playerIndex)
	{
		if (!hasExploded)
		{
			hasExploded = true;
			ExplodeMineServerRpc(playerIndex);
		}
	}

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

	[ClientRpc]
	public void ExplodeMineClientRpc(int playerIndex)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(355455692u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, playerIndex);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 355455692u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				hasExploded = true;
				SetOffMineAnimation((playerIndex <= -1) ? null : StartOfRound.Instance.allPlayerScripts[playerIndex]);
			}
		}
	}

	public void SetOffMineAnimation(PlayerControllerB playerWhoCollided = null)
	{
		mineAudio.PlayOneShot(mineTrigger, 1f);
		HUDManager.Instance.ShakeCamera((ScreenShakeType)2);
		((MonoBehaviour)this).StartCoroutine(DetonateDelay(playerWhoCollided));
	}

	private IEnumerator DetonateDelay(PlayerControllerB playerWhoCollided)
	{
		yield return (object)new WaitForSeconds(5f);
		Detonate(playerWhoCollided);
		BoomLight.SetActive(true);
		yield return (object)new WaitForSeconds(0.1f);
		((Component)((Component)((Component)this).transform.parent).transform.Find("BigBertha")).gameObject.SetActive(false);
		yield return (object)new WaitForSeconds(0.2f);
		BoomLight.SetActive(false);
		Collider[] componentsInChildren = ((Component)this).GetComponentsInChildren<Collider>();
		foreach (Collider val in componentsInChildren)
		{
			val.enabled = false;
		}
		yield return (object)new WaitForSeconds(10f);
		if (((NetworkBehaviour)this).IsServer)
		{
			((NetworkBehaviour)this).NetworkObject.Despawn(true);
		}
	}

	public void Detonate(PlayerControllerB playerWhoCollided = null)
	{
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		mineAudio.pitch = (float)random.NextDouble() * 0.14f + 0.93f;
		mineAudio.PlayOneShot(mineDetonate, 2f);
		FarAudio.PlayOneShot(BerthaBoom, 1f);
		HUDManager.Instance.ShakeCamera((ScreenShakeType)3);
		CreateExplosion(((Component)this).transform.position + Vector3.up, 33, 6, (CauseOfDeath)3, playerWhoCollided);
	}

	public void CreateExplosion(Vector3 explosionPosition, int damage = 20, int enemyHitForce = 6, CauseOfDeath causeOfDeath = 3, PlayerControllerB attacker = null)
	{
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: 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_0333: Unknown result type (might be due to invalid IL or missing references)
		//IL_0362: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_010c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0111: Unknown result type (might be due to invalid IL or missing references)
		//IL_0116: Unknown result type (might be due to invalid IL or missing references)
		//IL_011a: Unknown result type (might be due to invalid IL or missing references)
		//IL_011f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0126: 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_0132: Unknown result type (might be due to invalid IL or missing references)
		//IL_013d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0141: Unknown result type (might be due to invalid IL or missing references)
		//IL_027f: Unknown result type (might be due to invalid IL or missing references)
		//IL_016a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0399: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0299: Unknown result type (might be due to invalid IL or missing references)
		//IL_029f: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0181: Unknown result type (might be due to invalid IL or missing references)
		//IL_0188: Unknown result type (might be due to invalid IL or missing references)
		//IL_018d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0198: Unknown result type (might be due to invalid IL or missing references)
		//IL_019c: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01db: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0208: Unknown result type (might be due to invalid IL or missing references)
		//IL_020c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0222: Unknown result type (might be due to invalid IL or missing references)
		//IL_0227: Unknown result type (might be due to invalid IL or missing references)
		//IL_0229: Unknown result type (might be due to invalid IL or missing references)
		//IL_022e: Unknown result type (might be due to invalid IL or missing references)
		float value = Plugin.BoundConfig.Range1.Value;
		float value2 = Plugin.BoundConfig.Range2.Value;
		float value3 = Plugin.BoundConfig.Range3.Value;
		int num = 0;
		explosionParticle.Play();
		num = ((!Plugin.BoundConfig.KillEnemies.Value) ? StartOfRound.Instance.collidersRoomMaskDefaultAndPlayers : (StartOfRound.Instance.collidersRoomMaskDefaultAndPlayers | LayerMask.GetMask(new string[1] { "Enemies" })));
		Collider[] array = Physics.OverlapSphere(explosionPosition, value3, num, (QueryTriggerInteraction)2);
		List<PlayerControllerB> list = new List<PlayerControllerB>();
		Collider[] array2 = array;
		foreach (Collider val in array2)
		{
			float num2 = Vector3.Distance(explosionPosition, ((Component)val).transform.position);
			Vector3 val2;
			if (((Component)val).gameObject.layer == 3)
			{
				PlayerControllerB component = ((Component)val).GetComponent<PlayerControllerB>();
				if ((Object)(object)component != (Object)null && (Object)(object)component == (Object)(object)GameNetworkManager.Instance.localPlayerController)
				{
					list.Add(component);
					val2 = ((Component)component).transform.position - ((Component)this).transform.position;
					Vector3 normalized = ((Vector3)(ref val2)).normalized;
					if (num2 <= value)
					{
						normalized *= 500f;
						component.DamagePlayer(999, true, true, causeOfDeath, 6, false, normalized);
						HUDManager.Instance.ShakeCamera((ScreenShakeType)3);
						continue;
					}
					if (num2 <= value2 && MineHasLineOfSight(((Component)component.gameplayCamera).transform.position))
					{
						HUDManager.Instance.ShakeCamera((ScreenShakeType)3);
						normalized *= 400f;
						component.DamagePlayer(999, true, true, causeOfDeath, 6, false, normalized);
						continue;
					}
					if (num2 <= value3 && MineHasLineOfSight(((Component)component.gameplayCamera).transform.position))
					{
						normalized *= (float)Plugin.BoundConfig.Knockbackmultiplier.Value;
						HUDManager.Instance.ShakeCamera((ScreenShakeType)1);
						float num3 = 1f - Mathf.Clamp01(num2 / value3);
						component.DamagePlayer((int)((float)damage * num3), true, true, causeOfDeath, 6, false, normalized);
						if (!component.isPlayerDead)
						{
							component.externalForces += normalized;
						}
						continue;
					}
				}
			}
			if (((Component)val).gameObject.layer == 19)
			{
				EnemyAICollisionDetect componentInChildren = ((Component)val).GetComponentInChildren<EnemyAICollisionDetect>();
				if ((Object)(object)componentInChildren != (Object)null && ((NetworkBehaviour)componentInChildren.mainScript).IsOwner && num2 <= value2 && MineHasLineOfSight(((Component)val).transform.position))
				{
					EnemyAI mainScript = componentInChildren.mainScript;
					val2 = default(Vector3);
					mainScript.HitEnemyOnLocalClient(enemyHitForce, val2, attacker, false, -1);
				}
			}
			else if (((Component)val).gameObject.layer == 21)
			{
				Landmine componentInChildren2 = ((Component)val).GetComponentInChildren<Landmine>();
				if ((Object)(object)componentInChildren2 != (Object)null && !componentInChildren2.hasExploded && num2 <= value3 && MineHasLineOfSight(((Component)val).transform.position))
				{
					((MonoBehaviour)componentInChildren2).StartCoroutine(componentInChildren2.TriggerOtherMineDelayed(componentInChildren2));
				}
			}
		}
		Seamine[] array3 = Object.FindObjectsByType<Seamine>((FindObjectsSortMode)1);
		Seamine[] array4 = array3;
		foreach (Seamine seamine in array4)
		{
			float num4 = Vector3.Distance(explosionPosition, ((Component)seamine).transform.position);
			if (!seamine.hasExploded && num4 <= value2)
			{
				seamine.SetOffMineAnimation();
			}
		}
		Collider[] array5 = Physics.OverlapSphere(explosionPosition, value3, StartOfRound.Instance.collidersAndRoomMaskAndDefault);
		Collider[] array6 = array5;
		foreach (Collider val3 in array6)
		{
			Rigidbody component2 = ((Component)val3).GetComponent<Rigidbody>();
			if (component2 != null)
			{
				component2.AddExplosionForce(1000f, explosionPosition, value3);
			}
		}
	}

	public bool MineHasLineOfSight(Vector3 pos)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		RaycastHit val = default(RaycastHit);
		return !Physics.Linecast(((Component)this).transform.position, pos, ref val, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1);
	}

	bool IHittable.Hit(int force, Vector3 hitDirection, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
	{
		if ((Object)(object)playerWhoHit != (Object)(object)GameNetworkManager.Instance.localPlayerController)
		{
			return false;
		}
		ExplodeMineServerRpc(((Object)(object)playerWhoHit != (Object)null) ? Array.IndexOf(StartOfRound.Instance.allPlayerScripts, playerWhoHit) : (-1));
		return true;
	}

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

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

	private static void __rpc_handler_1478796614(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 playerIndex = default(int);
			ByteUnpacker.ReadValueBitPacked(reader, ref playerIndex);
			target.__rpc_exec_stage = (__RpcExecStage)1;
			((Bertha)(object)target).ExplodeMineServerRpc(playerIndex);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	private static void __rpc_handler_355455692(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 playerIndex = default(int);
			ByteUnpacker.ReadValueBitPacked(reader, ref playerIndex);
			target.__rpc_exec_stage = (__RpcExecStage)2;
			((Bertha)(object)target).ExplodeMineClientRpc(playerIndex);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	[MethodImpl(MethodImplOptions.NoInlining)]
	protected internal override string __getTypeName()
	{
		return "Bertha";
	}
}
public class Seamine : NetworkBehaviour, IHittable
{
	private bool mineActivated = true;

	public bool hasExploded;

	public ParticleSystem explosionParticle;

	public AudioSource mineAudio;

	public AudioSource mineFarAudio;

	public AudioClip mineDetonate;

	public AudioClip mineTrigger;

	public AudioClip mineBeep;

	public AudioClip mineDetonateFar;

	private bool sendingExplosionRPC;

	private RaycastHit hit;

	private void Start()
	{
		((MonoBehaviour)this).StartCoroutine(StartIdleAnimation());
	}

	private IEnumerator StartIdleAnimation()
	{
		while (true)
		{
			yield return (object)new WaitForSeconds((float)Random.Range(Plugin.BoundConfig.SeamineSoundMin.Value, Plugin.BoundConfig.SeamineSoundMax.Value));
			mineAudio.PlayOneShot(mineBeep, 0.1f);
			mineAudio.pitch = Random.Range(0.9f, 1.1f);
		}
	}

	private void OnTriggerEnter(Collider other)
	{
		if (hasExploded || !mineActivated)
		{
			return;
		}
		Debug.Log((object)((Object)other).name);
		if (((Component)other).CompareTag("Player"))
		{
			PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
			if ((Object)(object)component != (Object)null && !component.isPlayerDead && !((Object)(object)component != (Object)(object)GameNetworkManager.Instance.localPlayerController))
			{
				TriggerMineOnLocalClientByExiting();
			}
		}
		else
		{
			if (!((Component)other).tag.StartsWith("PlayerRagdoll") && !((Component)other).CompareTag("PhysicsProp"))
			{
				return;
			}
			if (Object.op_Implicit((Object)(object)((Component)other).GetComponent<DeadBodyInfo>()))
			{
				if ((Object)(object)((Component)other).GetComponent<DeadBodyInfo>().playerScript != (Object)(object)GameNetworkManager.Instance.localPlayerController)
				{
					return;
				}
			}
			else if (Object.op_Implicit((Object)(object)((Component)other).GetComponent<GrabbableObject>()) && !((NetworkBehaviour)((Component)other).GetComponent<GrabbableObject>()).NetworkObject.IsOwner)
			{
				return;
			}
			TriggerMineOnLocalClientByExiting();
		}
	}

	private void TriggerMineOnLocalClientByExiting()
	{
		if (!hasExploded)
		{
			SetOffMineAnimation();
			sendingExplosionRPC = true;
			ExplodeMineServerRpc();
		}
	}

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

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

	public void SetOffMineAnimation()
	{
		hasExploded = true;
		mineAudio.PlayOneShot(mineTrigger, 1f);
		((MonoBehaviour)this).StartCoroutine(DetonateDelay());
	}

	private IEnumerator DetonateDelay()
	{
		yield return (object)new WaitForSeconds(0.5f);
		Detonate();
		yield return (object)new WaitForSeconds(0.1f);
		if (((NetworkBehaviour)this).IsServer)
		{
			Object.Destroy((Object)(object)((Component)((Component)this).transform.parent).gameObject);
		}
	}

	private IEnumerator TriggerOtherMineDelayed(Landmine mine)
	{
		if (!mine.hasExploded)
		{
			mine.mineAudio.pitch = Random.Range(0.75f, 1.07f);
			mine.hasExploded = true;
			yield return (object)new WaitForSeconds(0.2f);
			mine.SetOffMineAnimation();
		}
	}

	public void Detonate()
	{
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		mineAudio.pitch = Random.Range(0.93f, 1.07f);
		mineAudio.PlayOneShot(mineDetonate, 1f);
		CreateExplosion(((Component)this).transform.position + Vector3.up, spawnExplosionEffect: true, 100, 5.7f, 6f, 6, (CauseOfDeath)3);
	}

	public void CreateExplosion(Vector3 explosionPosition, bool spawnExplosionEffect = false, int damage = 20, float minDamageRange = 0f, float maxDamageRange = 1f, int enemyHitForce = 6, CauseOfDeath causeOfDeath = 3, PlayerControllerB attacker = null)
	{
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0319: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: Unknown result type (might be due to invalid IL or missing references)
		//IL_010f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0348: Unknown result type (might be due to invalid IL or missing references)
		//IL_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0187: Unknown result type (might be due to invalid IL or missing references)
		//IL_018c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0191: Unknown result type (might be due to invalid IL or missing references)
		//IL_0195: 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_01a2: 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_01b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01be: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0206: Unknown result type (might be due to invalid IL or missing references)
		//IL_020a: 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_02d2: Unknown result type (might be due to invalid IL or missing references)
		Transform val = null;
		if ((Object)(object)RoundManager.Instance != (Object)null && (Object)(object)RoundManager.Instance.mapPropsContainer != (Object)null && (Object)(object)RoundManager.Instance.mapPropsContainer.transform != (Object)null)
		{
			val = RoundManager.Instance.mapPropsContainer.transform;
		}
		if (spawnExplosionEffect)
		{
			Object.Instantiate<GameObject>(StartOfRound.Instance.explosionPrefab, explosionPosition, Quaternion.Euler(-90f, 0f, 0f), val).SetActive(true);
		}
		float num = Vector3.Distance(((Component)GameNetworkManager.Instance.localPlayerController).transform.position, explosionPosition);
		if (num < 14f)
		{
			HUDManager.Instance.ShakeCamera((ScreenShakeType)1);
		}
		else if (num < 25f)
		{
			HUDManager.Instance.ShakeCamera((ScreenShakeType)0);
		}
		Collider[] array = Physics.OverlapSphere(explosionPosition, maxDamageRange, 2621448, (QueryTriggerInteraction)2);
		PlayerControllerB val2 = null;
		for (int i = 0; i < array.Length; i++)
		{
			float num2 = Vector3.Distance(explosionPosition, ((Component)array[i]).transform.position);
			if (num2 > 4f && Physics.Linecast(explosionPosition, ((Component)array[i]).transform.position + Vector3.up * 0.3f, 256, (QueryTriggerInteraction)1))
			{
				continue;
			}
			Vector3 val3;
			if (((Component)array[i]).gameObject.layer == 3)
			{
				val2 = ((Component)array[i]).gameObject.GetComponent<PlayerControllerB>();
				if ((Object)(object)val2 != (Object)null && ((NetworkBehaviour)val2).IsOwner)
				{
					float num3 = 1f - Mathf.Clamp01((num2 - minDamageRange) / (maxDamageRange - minDamageRange));
					val3 = ((Component)val2).transform.position - ((Component)this).transform.position;
					Vector3 normalized = ((Vector3)(ref val3)).normalized;
					((Component)val2).GetComponent<Rigidbody>().AddForce(normalized * 500f);
					Vector3 val4 = Vector3.Normalize((((Component)val2).transform.position + Vector3.up * 0.75f - ((Component)this).transform.position) * 100f) * 30f;
					val2.DamagePlayer((int)((float)damage * num3), true, true, causeOfDeath, 0, false, val4);
				}
			}
			else if (((Component)array[i]).gameObject.layer == 21)
			{
				Landmine componentInChildren = ((Component)array[i]).gameObject.GetComponentInChildren<Landmine>();
				if ((Object)(object)componentInChildren != (Object)null && !componentInChildren.hasExploded && num2 < 6f)
				{
					Debug.Log((object)"Setting off other mine");
					((MonoBehaviour)componentInChildren).StartCoroutine(componentInChildren.TriggerOtherMineDelayed(componentInChildren));
				}
			}
			else if (((Component)array[i]).gameObject.layer == 19)
			{
				EnemyAICollisionDetect componentInChildren2 = ((Component)array[i]).gameObject.GetComponentInChildren<EnemyAICollisionDetect>();
				if ((Object)(object)componentInChildren2 != (Object)null && ((NetworkBehaviour)componentInChildren2.mainScript).IsOwner && num2 < 4.5f)
				{
					EnemyAI mainScript = componentInChildren2.mainScript;
					val3 = default(Vector3);
					mainScript.HitEnemyOnLocalClient(enemyHitForce, val3, attacker, false, -1);
				}
			}
		}
		int num4 = ~LayerMask.GetMask(new string[1] { "Room" });
		num4 = ~LayerMask.GetMask(new string[1] { "Colliders" });
		array = Physics.OverlapSphere(explosionPosition, 10f, num4);
		for (int j = 0; j < array.Length; j++)
		{
			Rigidbody component = ((Component)array[j]).GetComponent<Rigidbody>();
			if ((Object)(object)component != (Object)null)
			{
				component.AddExplosionForce(70f, explosionPosition, 10f);
			}
		}
	}

	public bool MineHasLineOfSight(Vector3 pos)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		return !Physics.Linecast(((Component)this).transform.position, pos, ref hit, 256);
	}

	bool IHittable.Hit(int force, Vector3 hitDirection, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
	{
		SetOffMineAnimation();
		sendingExplosionRPC = true;
		ExplodeMineServerRpc();
		return true;
	}

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

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

	private static void __rpc_handler_711067059(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;
			((Seamine)(object)target).ExplodeMineServerRpc();
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	private static void __rpc_handler_3889305919(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)2;
			((Seamine)(object)target).ExplodeMineClientRpc();
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	[MethodImpl(MethodImplOptions.NoInlining)]
	protected internal override string __getTypeName()
	{
		return "Seamine";
	}
}
namespace Scary
{
	internal class ScaryAI : ExtendedEnemyAI
	{
		private enum State
		{
			MovingToPlayer,
			Teleporting
		}

		public Transform turnCompass;

		private float timeSinceHittingLocalPlayer;

		private float timeSinceLastProximitySound;

		private Random enemyRandom;

		private Coroutine? PerformTeleportCoroutine;

		private NavMeshAgent agent;

		private AudioSourceHandle scarySound;

		public AudioClip PoofSoundClip;

		public AudioClip ScareSoundClip;

		public ParticleSystem Poofps;

		private bool jumpscaring;

		private Vector3 lastPosition;

		private float inactivityTimer;

		[Header("SoundSets")]
		[SerializeField]
		private SoundSet LureSoundSet;

		private UniqueRandomizer LureRandomizer;

		[SerializeField]
		private Transform movementSource;

		[Conditional("DEBUG")]
		private void LogIfDebugBuild(string text)
		{
			Plugin.Logger.LogInfo((object)text);
		}

		public override void Start()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			((ExtendedEnemyAI)this).Start();
			Plugin.Logger.LogInfo((object)"IMPENDING DOOM APPROACHES...");
			LureRandomizer = new UniqueRandomizer(LureSoundSet);
			timeSinceHittingLocalPlayer = 0f;
			timeSinceLastProximitySound = 0f;
			enemyRandom = new Random(StartOfRound.Instance.randomMapSeed + ((EnemyAI)this).thisEnemyIndex);
			((EnemyAI)this).currentBehaviourStateIndex = 0;
			agent = ((Component)this).GetComponent<NavMeshAgent>();
		}

		public void PlayLureSound()
		{
			int nextStableRandomIndex = LureRandomizer.GetNextStableRandomIndex();
			((ExtendedEnemyAI)this).PlayCreatureSFXServerRpc(LureSoundSet.GetAudioClipName(nextStableRandomIndex), 0.6f, 1f, 25f, true, false);
			WalkieTalkieExtensions.TransmitOneShotAudio(movementSource, LureSoundSet.GetAudioClip(nextStableRandomIndex), 0.4f, 1f);
		}

		public override void Update()
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: 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)
			((EnemyAI)this).Update();
			timeSinceHittingLocalPlayer += Time.deltaTime;
			if (!jumpscaring)
			{
				timeSinceLastProximitySound += Time.deltaTime;
			}
			int currentBehaviourStateIndex = ((EnemyAI)this).currentBehaviourStateIndex;
			if ((Object)(object)((EnemyAI)this).targetPlayer != (Object)null && currentBehaviourStateIndex == 0)
			{
				turnCompass.LookAt(((Component)((EnemyAI)this).targetPlayer.gameplayCamera).transform.position);
				((Component)this).transform.rotation = Quaternion.Lerp(((Component)this).transform.rotation, Quaternion.Euler(new Vector3(0f, turnCompass.eulerAngles.y, 0f)), 4f * Time.deltaTime);
			}
			if (((NetworkBehaviour)this).IsHost && (Object)(object)((EnemyAI)this).targetPlayer != (Object)null)
			{
				float num = Vector3.Distance(((Component)((EnemyAI)this).targetPlayer).transform.position, ((Component)this).transform.position);
				if (num > 5f && !jumpscaring)
				{
					CheckInactivity();
				}
			}
		}

		public override void DoAIInterval()
		{
			((EnemyAI)this).DoAIInterval();
			if (!((EnemyAI)this).isEnemyDead && !StartOfRound.Instance.allPlayersDead)
			{
				switch (((EnemyAI)this).currentBehaviourStateIndex)
				{
				case 0:
					agent.speed = (jumpscaring ? 0f : 9f);
					MoveToClosestPlayer();
					break;
				case 1:
					agent.speed = 0f;
					TeleportToRandomNode();
					break;
				}
			}
		}

		private void MoveToClosestPlayer()
		{
			//IL_009c: 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_0021: Unknown result type (might be due to invalid IL or missing references)
			if (TargetClosestPlayerInAnyCase() && Vector3.Distance(((Component)this).transform.position, ((Component)((EnemyAI)this).targetPlayer).transform.position) < 3f)
			{
				if (timeSinceLastProximitySound >= (float)enemyRandom.Next(Plugin.BoundConfig.ScarySoundMin.Value, Plugin.BoundConfig.ScarySoundMax.Value))
				{
					PlayLureSound();
					timeSinceLastProximitySound = 0f;
				}
				if (PerformTeleportCoroutine == null)
				{
					PerformTeleportCoroutine = ((MonoBehaviour)this).StartCoroutine(PerformTeleportIfFacingPlayer());
				}
			}
			else
			{
				((EnemyAI)this).SetDestinationToPosition(((Component)((EnemyAI)this).targetPlayer).transform.position, false);
			}
		}

		private IEnumerator PerformTeleportIfFacingPlayer()
		{
			if ((Object)(object)((EnemyAI)this).targetPlayer != (Object)null)
			{
				Vector3 val = Vector3.Normalize(((Component)((EnemyAI)this).targetPlayer.gameplayCamera).transform.position - ((Component)this).transform.position);
				float num = Vector3.Distance(((Component)((EnemyAI)this).targetPlayer).transform.position, ((Component)this).transform.position);
				if (num < 5f && Vector3.Dot(val, ((Component)((EnemyAI)this).targetPlayer.gameplayCamera).transform.forward) < -0.9f)
				{
					inactivityTimer = 0f;
					Plugin.Logger.LogInfo((object)"JUMPSCARE");
					jumpscaring = true;
					((ExtendedEnemyAI)this).PlayCreatureSFXServerRpc(((Object)ScareSoundClip).name, 0.4f, 1f, 25f, true, false);
					yield return (object)new WaitForSeconds(5f);
					((ExtendedEnemyAI)this).PlayCreatureSFXServerRpc(((Object)PoofSoundClip).name, 0.4f, 1f, 25f, true, false);
					EmitPSClientRpc();
					yield return (object)new WaitForSeconds(0.35f);
					((EnemyAI)this).SwitchToBehaviourClientRpc(1);
					jumpscaring = false;
				}
			}
			PerformTeleportCoroutine = null;
		}

		private void TeleportToRandomNode()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			Vector3 randomAINodePosition = GetRandomAINodePosition();
			if (randomAINodePosition != Vector3.zero)
			{
				agent.Warp(randomAINodePosition);
				((EnemyAI)this).SwitchToBehaviourClientRpc(0);
			}
			else
			{
				((EnemyAI)this).SwitchToBehaviourClientRpc(0);
			}
		}

		private Vector3 GetRandomAINodePosition()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: 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_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: 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)
			GameObject[] insideAINodes = RoundManager.Instance.insideAINodes;
			List<Vector3> list = new List<Vector3>();
			GameObject[] array = insideAINodes;
			foreach (GameObject val in array)
			{
				list.Add(val.transform.position);
			}
			if (list.Count == 0)
			{
				return Vector3.zero;
			}
			Vector3 val2 = list[Random.Range(0, list.Count)];
			return RoundManager.Instance.GetRandomNavMeshPositionInRadius(val2, 3f, default(NavMeshHit));
		}

		private void CheckInactivity()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			if (Vector3.Distance(((Component)this).transform.position, lastPosition) < 0.01f)
			{
				inactivityTimer += Time.deltaTime;
				if (inactivityTimer >= 3f)
				{
					TeleportToRandomNode();
					inactivityTimer = 0f;
				}
			}
			else
			{
				inactivityTimer = 0f;
				lastPosition = ((Component)this).transform.position;
			}
		}

		private bool TargetClosestPlayerInAnyCase()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).mostOptimalDistance = 2000f;
			((EnemyAI)this).targetPlayer = null;
			for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++)
			{
				((EnemyAI)this).tempDist = Vector3.Distance(((Component)this).transform.position, ((Component)StartOfRound.Instance.allPlayerScripts[i]).transform.position);
				if (((EnemyAI)this).tempDist < ((EnemyAI)this).mostOptimalDistance)
				{
					((EnemyAI)this).mostOptimalDistance = ((EnemyAI)this).tempDist;
					((EnemyAI)this).targetPlayer = StartOfRound.Instance.allPlayerScripts[i];
				}
			}
			return (Object)(object)((EnemyAI)this).targetPlayer != (Object)null;
		}

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

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

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

		private static void __rpc_handler_2066374292(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)2;
				((ScaryAI)(object)target).EmitPSClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "ScaryAI";
		}
	}
}
namespace Surfaced
{
	internal class BellCrabAI : EnemyAI
	{
		private enum State
		{
			Idle,
			Running,
			Grabbed,
			Death
		}

		public InteractTrigger Interact_Script;

		[NonSerialized]
		public bool isAttached;

		[NonSerialized]
		public PlayerControllerB? playerHoldingCrab;

		public float BellCrabRunSpeed = 18f;

		private Random BellCrabRandom;

		private Random ScanNodeRandom;

		public AudioClip DeathSoundClip;

		public AudioClip BellLandSoundClip;

		public AudioClip[] SnipSoundClips;

		public AudioClip ScuttleSoundClip;

		public AudioClip PopInSoundClip;

		public AudioClip PopOutSoundClip;

		public AudioClip GrabbedSoundClip;

		public AudioClip PickupSoundClip;

		public ScanNodeProperties ScanNode;

		public NetworkTransform NetTransform;

		private Coroutine? recentlyDamagedCoroutine;

		private bool recentlyDamaged;

		private bool testBuild;

		private LineRenderer line;

		private int creatureID;

		private static int EnemyNodeType = 1;

		private static int ScrapNodeType = 2;

		public override void Start()
		{
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Start();
			creatureID = ScanNode.creatureScanID;
			ScanNode.creatureScanID = -1;
			isAttached = false;
			((Behaviour)base.agent).enabled = true;
			FindNextWanderPoint();
			((EnemyAI)this).SwitchToBehaviourStateOnLocalClient(1);
			base.creatureAnimator.SetInteger("State", 1);
			((Component)this).transform.localScale = new Vector3(1f, 1f, 1f);
			((UnityEvent<PlayerControllerB>)(object)Interact_Script.onInteract).AddListener((UnityAction<PlayerControllerB>)TriggerInteract);
			base.agent.speed = BellCrabRunSpeed;
			base.agent.acceleration = 100f;
			BellCrabRandom = new Random(StartOfRound.Instance.randomMapSeed);
			ScanNodeRandom = new Random(StartOfRound.Instance.randomMapSeed);
			((MonoBehaviour)this).StartCoroutine(DoPeakingCoroutine());
			SetScanNodeType(ScrapNodeType);
			Interact_Script.hoverTip = "Grab : [E]";
			if (testBuild)
			{
				line = ((Component)this).gameObject.AddComponent<LineRenderer>();
				line.widthMultiplier = 0.2f;
			}
		}

		public void SetScanNodeType(int type)
		{
			ScanNode.nodeType = type;
			if (type == ScrapNodeType)
			{
				ScanNode.headerText = "Gift Box";
				ScanNode.scrapValue = ScanNodeRandom.Next((int)(30f * RoundManager.Instance.scrapValueMultiplier), (int)(70f * RoundManager.Instance.scrapValueMultiplier));
				ScanNode.subText = "Value: " + ScanNode.scrapValue;
			}
			else
			{
				ScanNode.headerText = "Gift Crab";
				ScanNode.subText = "";
			}
		}

		private void FindNextWanderPoint()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: 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)
			bool flag = false;
			for (int i = 0; i < 4; i++)
			{
				flag = ((EnemyAI)this).SetDestinationToPosition(RoundManager.Instance.GetRandomNavMeshPositionInRadius(((Component)this).transform.position, 30f, default(NavMeshHit)), true);
				if (flag)
				{
					break;
				}
			}
			if (!flag)
			{
				((EnemyAI)this).SetDestinationToPosition(RoundManager.Instance.GetRandomNavMeshPositionInRadius(((Component)this).transform.position, 30f, default(NavMeshHit)), false);
			}
		}

		public void TriggerInteract(PlayerControllerB player)
		{
			//IL_0014: 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)
			if (base.currentBehaviourStateIndex == 0 && Physics.Raycast(((Component)player.gameplayCamera).transform.position, ((Component)player.gameplayCamera).transform.forward, player.grabDistance, player.interactableObjectsMask))
			{
				player.SetHoverTipAndCurrentInteractTrigger();
				Interact_Script.interactable = false;
				Interact_Script.hasTriggered = true;
				if (!isAttached && (Object)(object)player == (Object)(object)GameNetworkManager.Instance.localPlayerController)
				{
					PickupCrabServerRpc(Array.IndexOf(StartOfRound.Instance.allPlayerScripts, player));
				}
			}
		}

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

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

		public IEnumerator PickupCrabDelay(int playerID)
		{
			yield return (object)new WaitForSeconds(0.12f);
			if (!recentlyDamaged)
			{
				PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[playerID];
				if ((Object)(object)playerHoldingCrab != (Object)null)
				{
					playerHoldingCrab.twoHanded = false;
					playerHoldingCrab = null;
					playerHoldingCrab.isHoldingObject = false;
				}
				if ((Object)(object)val != (Object)null)
				{
					val.inAnimationWithEnemy = (EnemyAI)(object)this;
					isAttached = true;
					((Behaviour)base.agent).enabled = false;
					base.agent.speed = 0f;
					Interact_Script.interactable = false;
					SetScanNodeType(EnemyNodeType);
					HUDManager.Instance.AttemptScanNewCreature(creatureID);
					playerHoldingCrab = val;
					playerHoldingCrab.twoHanded = true;
					playerHoldingCrab.isGrabbingObjectAnimation = true;
					playerHoldingCrab.isHoldingObject = true;
					playerHoldingCrab.hoveringOverTrigger = null;
					playerHoldingCrab.DropAllHeldItems(true, false);
					((EnemyAI)this).SwitchToBehaviourStateOnLocalClient(2);
					base.creatureAnimator.SetInteger("State", 2);
					PlayGrabbedSFX();
				}
			}
		}

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

		[ClientRpc]
		public void DropCrabClientRpc(int playerID)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(887584623u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerID);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 887584623u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					StartOfRound.Instance.allPlayerScripts[playerID].inAnimationWithEnemy = null;
					((MonoBehaviour)this).StartCoroutine(DropCrabDelay(playerID));
				}
			}
		}

		public void DropCrabOnLocalClient(PlayerControllerB? player = null)
		{
			if ((Object)(object)player == (Object)null)
			{
				player = playerHoldingCrab;
			}
			if (isAttached || (Object)(object)player != (Object)null)
			{
				PlayDropBellSFX();
			}
			if ((Object)(object)player != (Object)null)
			{
				player.SetHoverTipAndCurrentInteractTrigger();
			}
			isAttached = false;
			((Behaviour)base.agent).enabled = true;
			base.agent.speed = BellCrabRunSpeed;
			if ((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)(object)player)
			{
				HUDManager.Instance.ClearControlTips();
			}
			if ((Object)(object)player != (Object)null)
			{
				player.twoHanded = false;
				player.inAnimationWithEnemy = null;
				player.isHoldingObject = false;
				player.isGrabbingObjectAnimation = false;
			}
			Interact_Script.interactable = false;
			playerHoldingCrab = null;
			if (base.enemyHP > 0)
			{
				((EnemyAI)this).SwitchToBehaviourStateOnLocalClient(1);
				base.creatureAnimator.SetInteger("State", 1);
				return;
			}
			((Behaviour)base.agent).enabled = false;
			((EnemyAI)this).SwitchToBehaviourStateOnLocalClient(3);
			base.creatureAnimator.SetTrigger("Death");
			base.creatureAnimator.SetInteger("State", 3);
		}

		public IEnumerator DropCrabDelay(int playerID)
		{
			yield return (object)new WaitForSeconds(0.2f);
			PlayerControllerB player = StartOfRound.Instance.allPlayerScripts[playerID];
			DropCrabOnLocalClient(player);
		}

		public void snipPlayer()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)playerHoldingCrab != (Object)null)
			{
				playerHoldingCrab.DamagePlayer(Plugin.BoundConfig.BellCrabDamageValue.Value, true, true, (CauseOfDeath)17, 0, false, default(Vector3));
				playerHoldingCrab.DropAllHeldItems(true, false);
				PlayCreatureSound(SnipSoundClips[BellCrabRandom.Next(0, SnipSoundClips.Length)]);
			}
		}

		public IEnumerator DoPeakingCoroutine()
		{
			while (!base.isEnemyDead)
			{
				yield return (object)new WaitForSeconds((float)BellCrabRandom.NextDouble() * 10f + 10f);
				if (base.currentBehaviourStateIndex == 0)
				{
					base.creatureAnimator.SetTrigger("Peak");
				}
			}
		}

		public void PlayPopInSFX()
		{
			PlayCreatureSound(PopInSoundClip);
			base.agent.speed = 0f;
			Interact_Script.hasTriggered = false;
			SetScanNodeType(ScrapNodeType);
		}

		public void PlayPopOutSFX()
		{
			PlayCreatureSound(PopOutSoundClip);
			SetScanNodeType(EnemyNodeType);
		}

		public void PlayDeathSFX()
		{
			base.creatureSFX.Stop();
			base.creatureSFX.PlayOneShot(DeathSoundClip);
		}

		public void PlayDropBellSFX()
		{
			base.creatureSFX.PlayOneShot(BellLandSoundClip);
		}

		public void PlayFootstepSFX()
		{
			if ((Object)(object)base.creatureSFX.clip != (Object)(object)ScuttleSoundClip || !base.creatureSFX.isPlaying)
			{
				PlayCreatureSound(ScuttleSoundClip, loop: true);
				((MonoBehaviour)this).StartCoroutine(StopScuttleSound());
			}
		}

		public IEnumerator StopScuttleSound()
		{
			yield return (object)new WaitUntil((Func<bool>)(() => base.currentBehaviourStateIndex == 0));
			base.creatureSFX.Stop();
		}

		public void PlayGrabbedSFX()
		{
			base.creatureSFX.PlayOneShot(PickupSoundClip);
			base.creatureSFX.PlayOneShot(GrabbedSoundClip);
		}

		public void PlayCreatureSound(AudioClip clip, bool loop = false)
		{
			base.creatureSFX.loop = loop;
			base.creatureSFX.clip = clip;
			base.creatureSFX.Play();
		}

		public void spawnCrabScrap()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			if (base.enemyHP <= 0)
			{
				HideEnemyGameObject();
			}
			if (((NetworkBehaviour)this).IsServer && base.enemyHP <= 0)
			{
				SolidLibUtils.Instance.SpawnItem("Bell Crab Scrap", ((Component)this).transform.position, (Action<GameObject>)delegate
				{
				});
				((MonoBehaviour)this).StartCoroutine(delayDestroy());
			}
		}

		public void HideEnemyGameObject()
		{
			((Component)((Component)this).transform.Find("BellCrab")).gameObject.SetActive(false);
		}

		public IEnumerator delayDestroy()
		{
			yield return (object)new WaitForSeconds(0.8f);
			((NetworkBehaviour)this).NetworkObject.Despawn(true);
		}

		public override void HitEnemy(int force = 1, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
		{
			if (base.enemyHP > 1)
			{
				((EnemyAI)this).HitEnemy(force, playerWhoHit, true, hitID);
			}
			else
			{
				((EnemyAI)this).HitEnemy(force, playerWhoHit, false, hitID);
			}
			base.enemyHP -= force;
			Interact_Script.interactable = false;
			if ((Object)(object)playerWhoHit != (Object)null)
			{
				HUDManager.Instance.AttemptScanNewCreature(creatureID);
			}
			if (isAttached && (Object)(object)playerHoldingCrab != (Object)null && ((NetworkBehaviour)this).IsOwner)
			{
				DropCrabClientRpc(Array.IndexOf(StartOfRound.Instance.allPlayerScripts, playerHoldingCrab));
			}
			if (base.enemyHP > 0)
			{
				if (base.currentBehaviourStateIndex == 0)
				{
					base.creatureAnimator.SetTrigger("PopOut");
				}
				((EnemyAI)this).SwitchToBehaviourStateOnLocalClient(1);
				base.creatureAnimator.SetInteger("State", 1);
				if (recentlyDamagedCoroutine != null)
				{
					((MonoBehaviour)this).StopCoroutine(recentlyDamagedCoroutine);
				}
				recentlyDamagedCoroutine = ((MonoBehaviour)this).StartCoroutine(RecentlyDamagedCooldown());
			}
			else if (base.currentBehaviourStateIndex == 2)
			{
				((MonoBehaviour)this).StartCoroutine(DropCrabDelay(Array.IndexOf(StartOfRound.Instance.allPlayerScripts, playerHoldingCrab)));
			}
			else
			{
				((Behaviour)base.agent).enabled = false;
				((EnemyAI)this).SwitchToBehaviourStateOnLocalClient(3);
				base.creatureAnimator.SetTrigger("Death");
				base.creatureAnimator.SetInteger("State", 3);
			}
		}

		public IEnumerator RecentlyDamagedCooldown()
		{
			recentlyDamaged = true;
			yield return (object)new WaitForSeconds(1f);
			recentlyDamaged = false;
		}

		private bool HasReachedDestination()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			Vector3 velocity = base.agent.velocity;
			if ((double)((Vector3)(ref velocity)).magnitude <= 0.01)
			{
				return true;
			}
			return false;
		}

		[Conditional("DEBUG")]
		private void LogIfDebugBuild(string text)
		{
			Plugin.Logger.LogInfo((object)text);
		}

		public void AnimationEventCanRun()
		{
			base.agent.speed = BellCrabRunSpeed;
		}

		public override void Update()
		{
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Update();
			if (base.currentBehaviourStateIndex == 2 && (Object)(object)playerHoldingCrab == (Object)null)
			{
				playerHoldingCrab = (from x in StartOfRound.Instance.allPlayerScripts
					where ((NetworkBehaviour)x).IsSpawned && x.isPlayerControlled && !x.isPlayerDead
					select x into player
					select new
					{
						Player = player,
						Distance = Vector3.Distance(((Component)player).transform.position, ((Component)this).transform.position)
					} into x
					orderby x.Distance
					select x).FirstOrDefault().Player;
			}
			else if (base.currentBehaviourStateIndex == 2 && ((Object)(object)playerHoldingCrab.inAnimationWithEnemy != (Object)(object)this || !isAttached))
			{
				playerHoldingCrab.inAnimationWithEnemy = (EnemyAI)(object)this;
				isAttached = true;
			}
			if (base.isEnemyDead)
			{
				return;
			}
			if ((Object)(object)playerHoldingCrab != (Object)null)
			{
				((EnemyAI)this).SwitchToBehaviourStateOnLocalClient(2);
				base.creatureAnimator.SetInteger("State", 2);
				if (playerHoldingCrab.isPlayerDead && ((NetworkBehaviour)this).IsHost)
				{
					DropCrabServerRpc(Array.IndexOf(StartOfRound.Instance.allPlayerScripts, playerHoldingCrab));
				}
			}
			if (!isAttached && base.currentBehaviourStateIndex == 1)
			{
				PlayerControllerB val = FindClosestPlayer(20f);
				if ((Object)(object)val != (Object)null)
				{
					((Component)this).transform.rotation = Quaternion.LookRotation(Vector3.Normalize(((Component)this).transform.position - ((Component)val).transform.position), Vector3.up);
				}
			}
			if ((Object)(object)playerHoldingCrab != (Object)null && isAttached && playerHoldingCrab.health > 0)
			{
				playerHoldingCrab.playerBodyAnimator.SetLayerWeight(playerHoldingCrab.playerBodyAnimator.GetLayerIndex("HoldingItemsBothHands"), 1f);
				((Component)this).transform.position = ((Component)playerHoldingCrab.bodyParts[5]).transform.position;
				Transform transform = ((Component)this).transform;
				transform.position += ((Component)this).transform.forward * 0.7f;
				((Component)this).transform.rotation = ((Component)playerHoldingCrab).transform.rotation;
			}
		}

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

		[ClientRpc]
		public void HandleGoingFromRunningToIdleClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2496658613u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2496658613u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					((Component)this).transform.rotation = Quaternion.identity;
					base.creatureAnimator.SetTrigger("PopIn");
					Interact_Script.interactable = true;
					Interact_Script.hoverTip = "Grab : [E]";
					((EnemyAI)this).SwitchToBehaviourStateOnLocalClient(0);
					ScanNode.creatureScanID = -1;
					base.creatureAnimator.SetInteger("State", 0);
					FindNextWanderPoint();
				}
			}
		}

		public override void DoAIInterval()
		{
			if (testBuild)
			{
				((MonoBehaviour)this).StartCoroutine(DrawPath(line, base.agent));
			}
			((EnemyAI)this).DoAIInterval();
			if (base.isEnemyDead || !((NetworkBehaviour)this).IsHost)
			{
				return;
			}
			switch (base.currentBehaviourStateIndex)
			{
			case 1:
				if (HasReachedDestination() && !recentlyDamaged)
				{
					HandleGoingFromRunningToIdleServerRpc();
				}
				break;
			case 0:
			case 2:
				break;
			}
		}

		public static IEnumerator DrawPath(LineRenderer line, NavMeshAgent agent)
		{
			if (((Behaviour)agent).enabled)
			{
				yield return (object)new WaitForEndOfFrame();
				line.SetPosition(0, ((Component)agent).transform.position);
				line.positionCount = agent.path.corners.Length;
				for (int i = 1; i < agent.path.corners.Length; i++)
				{
					line.SetPosition(i, agent.path.corners[i]);
				}
			}
		}

		public PlayerControllerB FindClosestPlayer(float maxDistance = 10f)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB result = null;
			float num = float.MaxValue;
			for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++)
			{
				PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[i];
				float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position);
				if (num2 < num && num2 <= maxDistance)
				{
					num = num2;
					result = val;
				}
			}
			return result;
		}

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

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_BellCrabAI()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(487414722u, new RpcReceiveHandler(__rpc_handler_487414722));
			NetworkManager.__rpc_func_table.Add(1614733662u, new RpcReceiveHandler(__rpc_handler_1614733662));
			NetworkManager.__rpc_func_table.Add(510543919u, new RpcReceiveHandler(__rpc_handler_510543919));
			NetworkManager.__rpc_func_table.Add(887584623u, new RpcReceiveHandler(__rpc_handler_887584623));
			NetworkManager.__rpc_func_table.Add(789925258u, new RpcReceiveHandler(__rpc_handler_789925258));
			NetworkManager.__rpc_func_table.Add(2496658613u, new RpcReceiveHandler(__rpc_handler_2496658613));
			NetworkManager.__rpc_func_table.Add(4015559398u, new RpcReceiveHandler(__rpc_handler_4015559398));
		}

		private static void __rpc_handler_487414722(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 playerID = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerID);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((BellCrabAI)(object)target).PickupCrabServerRpc(playerID);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1614733662(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 playerID = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerID);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((BellCrabAI)(object)target).PickupCrabClientRpc(playerID);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_510543919(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 playerID = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerID);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((BellCrabAI)(object)target).DropCrabServerRpc(playerID);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_887584623(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 playerID = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerID);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((BellCrabAI)(object)target).DropCrabClientRpc(playerID);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_789925258(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;
				((BellCrabAI)(object)target).HandleGoingFromRunningToIdleServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2496658613(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)2;
				((BellCrabAI)(object)target).HandleGoingFromRunningToIdleClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

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

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "BellCrabAI";
		}
	}
	public class BruceAI : ExtendedEnemyAI
	{
		private enum Detection
		{
			None,
			Small,
			Medium,
			BIG
		}

		private enum State
		{
			Roaming,
			Chasing,
			Biting
		}

		public Transform attackArea;

		private Vector3 StalkPos;

		public Random enemyRandom;

		private bool isDeadAnimationDone;

		[SerializeField]
		private Transform jawTransform;

		private DeadBodyInfo carryingBody;

		private Vector3 wanderTarget;

		private float biteDistance = 9f;

		private float wanderRadius = 25f;

		private Bounds SmellTargetShipBounds;

		private Bounds WanderPaddedShipBounds;

		[SerializeField]
		private Collider bruceSaddleCollider;

		private bool inKillAnimation;

		private float roamingCooldown = 10f;

		private float lastRoamingTime;

		[Header("SoundSets")]
		[SerializeField]
		private SoundSet swimSet;

		[SerializeField]
		private SoundSet biteSet;

		private UniqueRandomizer swimRandomizer;

		private UniqueRandomizer biteRandomizer;

		[SerializeField]
		private Material bruceMaterial;

		[SerializeField]
		private Material blahajMaterial;

		private Coroutine killPlayerCoroutine;

		public override void Start()
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: 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_00f5: Expected O, but got Unknown
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Expected O, but got Unknown
			((ExtendedEnemyAI)this).Start();
			((Renderer)((EnemyAI)this).skinnedMeshRenderers[0]).material = (Plugin.BoundConfig.BruceBlahaj.Value ? blahajMaterial : bruceMaterial);
			WanderPaddedShipBounds = StartOfRound.Instance.shipBounds.bounds;
			((Bounds)(ref WanderPaddedShipBounds)).Expand(10f);
			SmellTargetShipBounds = StartOfRound.Instance.shipBounds.bounds;
			Vector3 extents = ((Bounds)(ref SmellTargetShipBounds)).extents;
			((Bounds)(ref SmellTargetShipBounds)).extents = new Vector3(extents.x, extents.y + 6f, extents.z);
			Vector3 center = ((Bounds)(ref SmellTargetShipBounds)).center;
			((Bounds)(ref SmellTargetShipBounds)).center = new Vector3(center.x, center.y + 2f, center.z);
			((EnemyAI)this).agent.areaMask = 877;
			swimRandomizer = new UniqueRandomizer(swimSet);
			biteRandomizer = new UniqueRandomizer(biteSet);
			((ExtendedEnemyAI)this).LogIfDebugBuild("Who fished with a Truffle worm!?");
			enemyRandom = new Random(StartOfRound.Instance.randomMapSeed + ((EnemyAI)this).thisEnemyIndex);
			isDeadAnimationDone = false;
			((EnemyAI)this).currentBehaviourStateIndex = 0;
		}

		public void PlaySwimSound()
		{
			int nextStableRandomIndex = swimRandomizer.GetNextStableRandomIndex();
			((ExtendedEnemyAI)this).PlayMovementAudioServerRpc(swimSet.GetAudioClipName(nextStableRandomIndex), 0.4f, Random.Range(0.9f, 1.1f), 30f);
			WalkieTalkie.TransmitOneShotAudio(((EnemyAI)this).creatureSFX, swimSet.GetAudioClip(nextStableRandomIndex), 0.4f);
		}

		public override void AnimationEventA()
		{
			((EnemyAI)this).AnimationEventA();
			PlaySwimSound();
		}

		public override void Update()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Update();
			Animator creatureAnimator = ((EnemyAI)this).creatureAnimator;
			Vector3 velocity = ((EnemyAI)this).agent.velocity;
			creatureAnimator.SetFloat("Speed", ((Vector3)(ref velocity)).magnitude);
			((ExtendedEnemyAI)this).LogIfDebugBuild(((EnemyAI)this).stunNormalizedTimer.ToString());
			if (((EnemyAI)this).stunNormalizedTimer > 0f)
			{
				((EnemyAI)this).agent.speed = 0f;
				((EnemyAI)this).SwitchToBehaviourClientRpc(0);
				((ExtendedEnemyAI)this).LogIfDebugBuild("You goofy ahh");
			}
		}

		public override void DoAIInterval()
		{
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: 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)
			((EnemyAI)this).DoAIInterval();
			if (!((NetworkBehaviour)this).IsHost || ((EnemyAI)this).isEnemyDead || StartOfRound.Instance.allPlayersDead || ((EnemyAI)this).stunNormalizedTimer > 0f)
			{
				return;
			}
			switch (((EnemyAI)this).currentBehaviourStateIndex)
			{
			case 0:
			{
				((EnemyAI)this).agent.speed = 4f;
				((EnemyAI)this).agent.angularSpeed = 300f;
				((EnemyAI)this).agent.acceleration = 6f;
				PickleOnStickItem pickleStick;
				if (TargetClosestPlayerThatSmells())
				{
					((ExtendedEnemyAI)this).LogIfDebugBuild("Dun Dun...");
					((EnemyAI)this).StopSearch(((EnemyAI)this).currentSearch, true);
					((EnemyAI)this).SwitchToBehaviourClientRpc(1);
				}
				else if (IsThereAPlayerHoldingPickleStick(out pickleStick))
				{
					if (!((Object)(object)pickleStick == (Object)null))
					{
						SetDestinationNotAllowedInShip(RoundManager.Instance.GetNavMeshPosition(pickleStick.pickleTransform.position + Vector3.down, default(NavMeshHit), 5f, -1));
					}
				}
				else if (Time.time - lastRoamingTime > roamingCooldown)
				{
					Wander();
					lastRoamingTime = Time.time;
				}
				break;
			}
			case 1:
				((EnemyAI)this).agent.speed = 5f;
				((EnemyAI)this).agent.angularSpeed = 50f;
				((EnemyAI)this).agent.acceleration = 10f;
				if (!TargetClosestPlayerThatSmells())
				{
					((ExtendedEnemyAI)this).LogIfDebugBuild("Lost smell of player");
					((EnemyAI)this).SwitchToBehaviourClientRpc(0);
					Wander();
				}
				else
				{
					PositionAroundPlayer();
				}
				break;
			case 2:
				((EnemyAI)this).agent.speed = 5.3f;
				PositionAroundPlayer();
				break;
			default:
				((ExtendedEnemyAI)this).LogIfDebugBuild("This Behavior State doesn't exist!");
				break;
			}
		}

		private bool IsThereAPlayerHoldingPickleStick(out PickleOnStickItem pickleStick)
		{
			//IL_0036: 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)
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			float num = float.MaxValue;
			PickleOnStickItem pickleOnStickItem = null;
			for (int i = 0; i < allPlayerScripts.Length; i++)
			{
				PickleOnStickItem pickleOnStickItem2 = allPlayerScripts[i].currentlyHeldObjectServer as PickleOnStickItem;
				if (!((Object)(object)pickleOnStickItem2 == (Object)null))
				{
					float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)allPlayerScripts[i]).transform.position);
					if (num2 < num && num2 < Plugin.BoundConfig.BrucePickleRange.Value)
					{
						num = num2;
						pickleOnStickItem = pickleOnStickItem2;
					}
				}
			}
			pickleStick = pickleOnStickItem;
			return (Object)(object)pickleStick != (Object)null;
		}

		public bool TargetClosestPlayerThatSmells(float bufferDistance = 1.5f)
		{
			//IL_0066: 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_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Expected O, but got Unknown
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).mostOptimalDistance = 2000f;
			PlayerControllerB targetPlayer = ((EnemyAI)this).targetPlayer;
			((EnemyAI)this).targetPlayer = null;
			Detection detection = Detection.None;
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			NavMeshHit val2 = default(NavMeshHit);
			for (int i = 0; i < allPlayerScripts.Length; i++)
			{
				int health = allPlayerScripts[i].health;
				Detection detectionLevel = GetDetectionLevel(health);
				if (detectionLevel == Detection.None || !((EnemyAI)this).PlayerIsTargetable(allPlayerScripts[i], false, false) || ((Bounds)(ref SmellTargetShipBounds)).Contains(((Component)allPlayerScripts[i]).transform.position))
				{
					continue;
				}
				float detectionRadius = GetDetectionRadius(detectionLevel);
				((EnemyAI)this).tempDist = Vector3.Distance(((Component)this).transform.position, ((Component)allPlayerScripts[i]).transform.position);
				if (!(((EnemyAI)this).tempDist <= detectionRadius) || (detectionLevel <= detection && (detectionLevel != detection || !(((EnemyAI)this).tempDist < ((EnemyAI)this).mostOptimalDistance))))
				{
					continue;
				}
				NavMeshPath val = new NavMeshPath();
				if (NavMesh.SamplePosition(((Component)allPlayerScripts[i]).transform.position, ref val2, 3.5f, -1))
				{
					((EnemyAI)this).agent.CalculatePath(((NavMeshHit)(ref val2)).position, val);
					if ((int)val.status == 0)
					{
						((EnemyAI)this).mostOptimalDistance = ((EnemyAI)this).tempDist;
						((EnemyAI)this).targetPlayer = allPlayerScripts[i];
						detection = detectionLevel;
					}
				}
			}
			if ((Object)(object)((EnemyAI)this).targetPlayer != (Object)null && bufferDistance > 0f && (Object)(object)targetPlayer != (Object)null && Mathf.Abs(((EnemyAI)this).mostOptimalDistance - Vector3.Distance(((Component)this).transform.position, ((Component)targetPlayer).transform.position)) < bufferDistance)
			{
				((EnemyAI)this).targetPlayer = targetPlayer;
			}
			return (Object)(object)((EnemyAI)this).targetPlayer != (Object)null;
		}

		private Detection GetDetectionLevel(int health)
		{
			if (health <= Plugin.BoundConfig.BruceBigRangeHealthThreshold.Value)
			{
				return Detection.BIG;
			}
			if (health <= Plugin.BoundConfig.BruceMediumRangeHealthThreshold.Value)
			{
				return Detection.Medium;
			}
			if (health <= Plugin.BoundConfig.BruceSmallRangeHealthThreshold.Value)
			{
				return Detection.Small;
			}
			return Detection.None;
		}

		private float GetDetectionRadius(Detection detection)
		{
			return detection switch
			{
				Detection.Small => Plugin.BoundConfig.BruceSmallRange.Value, 
				Detection.Medium => Plugin.BoundConfig.BruceMediumRange.Value, 
				Detection.BIG => Plugin.BoundConfig.BruceBigRange.Value, 
				_ => 0f, 
			};
		}

		private void PositionAroundPlayer()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: 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_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: 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_00b8: 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)
			if ((Object)(object)((EnemyAI)this).targetPlayer == (Object)null || !((NetworkBehaviour)this).IsOwner)
			{
				return;
			}
			if (!((EnemyAI)this).SetDestinationToPosition(((Component)((EnemyAI)this).targetPlayer).transform.position, true))
			{
				NavMeshHit val = default(NavMeshHit);
				if (NavMesh.SamplePosition(((Component)((EnemyAI)this).targetPlayer).transform.position, ref val, 3.5f, -1))
				{
					((EnemyAI)this).SetDestinationToPosition(((NavMeshHit)(ref val)).position, true);
				}
				else
				{
					((EnemyAI)this).SetDestinationToPosition(((Component)((EnemyAI)this).targetPlayer).transform.position, false);
				}
			}
			float num = Vector3.Distance(attackArea.position, ((Component)((EnemyAI)this).targetPlayer).transform.position);
			if (num <= biteDistance && ((EnemyAI)this).currentBehaviourStateIndex != 2 && math.dot(float3.op_Implicit(((Component)this).transform.forward), float3.op_Implicit(((Component)((EnemyAI)this).targetPlayer).transform.forward)) < -0.85f)
			{
				((EnemyAI)this).SwitchToBehaviourClientRpc(2);
				((MonoBehaviour)this).StartCoroutine(BiteAttackCoroutine());
			}
		}

		private IEnumerator BiteAttackCoroutine()
		{
			Collider attackCollider = ((Component)attackArea).GetComponent<Collider>();
			if ((Object)(object)attackCollider == (Object)null)
			{
				yield break;
			}
			int nextStableRandomIndex = biteRandomizer.GetNextStableRandomIndex();
			((ExtendedEnemyAI)this).PlayCreatureSFXClientRpc(((Object)biteSet.sounds[nextStableRandomIndex]).name, 1f, 1f, 30f, true, false);
			WalkieTalkieExtensions.TransmitOneShotAudio(jawTransform, biteSet.GetAudioClip(nextStableRandomIndex), 1.5f, 1f);
			DoAnimationClientRpc("Bite");
			yield return (object)new WaitForSeconds(0.5f);
			float biteDuration = 0.4f;
			float startTime = Time.time;
			while (Time.time - startTime < biteDuration)
			{
				if (((EnemyAI)this).stunNormalizedTimer > 0f)
				{
					yield break;
				}
				Bounds bounds = attackCollider.bounds;
				Vector3 center = ((Bounds)(ref bounds)).center;
				bounds = attackCollider.bounds;
				Collider[] array = Physics.OverlapBox(center, ((Bounds)(ref bounds)).extents, ((Component)attackCollider).transform.rotation);
				bool flag = false;
				Collider[] array2 = array;
				foreach (Collider val in array2)
				{
					PlayerControllerB component = ((Component)val).GetComponent<PlayerControllerB>();
					if ((Object)(object)component != (Object)null)
					{
						flag = true;
						component.inAnimationWithEnemy = (EnemyAI)(object)this;
						KillPlayerServerRpc((int)component.playerClientId);
						((EnemyAI)this).targetPlayer = null;
						break;
					}
				}
				if (flag)
				{
					yield break;
				}
				yield return null;
			}
			yield return (object)new WaitForSeconds(0.8f);
			if ((Object)(object)((EnemyAI)this).targetPlayer == (Object)null)
			{
				if (TargetClosestPlayerThatSmells())
				{
					((EnemyAI)this).SwitchToBehaviourClientRpc(1);
				}
				else
				{
					((EnemyAI)this).SwitchToBehaviourClientRpc(0);
				}
			}
			else
			{
				((EnemyAI)this).SwitchToBehaviourClientRpc(1);
			}
			Plugin.Logger.LogInfo((object)"Finish Bite");
		}

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

		private void TakeBodyInMouth(DeadBodyInfo body)
		{
			carryingBody = body;
			carryingBody.attachedTo = jawTransform;
			carryingBody.attachedLimb = body.bodyParts[5];
			carryingBody.matchPositionExactly = true;
		}

		private void DropCarriedBody()
		{
			if (!((Object)(object)carryingBody == (Object)null