Decompiled source of JPOGRaptor v1.0.7

plugins/JPOGRaptor.dll

Decompiled 2 weeks ago
#define DEBUG
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using JPOGRaptor.NetcodePatcher;
using JPOGRaptor.src;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("JPOGRaptor")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.7.0")]
[assembly: AssemblyInformationalVersion("1.0.7+147f80f5b24cd21364d07263ae53ba106c34893b")]
[assembly: AssemblyProduct("JPOGRaptor")]
[assembly: AssemblyTitle("JPOGRaptor")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.7.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace JPOGRaptor
{
	public class JPOGRaptorAI : EnemyAI
	{
		public enum State
		{
			SearchingForPlayer,
			StalkingPlayer,
			ChasingPlayer,
			RespondingToCall,
			AttackingPlayer,
			FleeingFromPlayer,
			HidingFromPlayer
		}

		public static List<JPOGRaptorAI> AllRaptors = new List<JPOGRaptorAI>();

		private static int nextRaptorId = 0;

		public Transform turnCompass = null;

		public Transform attackArea = null;

		public AudioSource RaptorcallVoice = null;

		public AudioSource RaptorStepsSFX = null;

		public Transform MouthBone = null;

		private float timeSinceHittingLocalPlayer;

		private float lastBlockedCollisionLogTime = float.NegativeInfinity;

		private float timeSinceHittingOtherEnemy;

		private bool isDeadAnimationDone;

		private bool inCallAnimation = false;

		private bool wasStunned = false;

		private bool isClimbing;

		public AudioClip FootstepClip1 = null;

		public AudioClip FootstepClip2 = null;

		private bool isNextStepClip1 = true;

		[HideInInspector]
		public NetworkVariable<float> CurrentSpeed = new NetworkVariable<float>(0f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)1);

		private RaptorPounceHelper raptorPounceHelper = null;

		private RaptorTargetingHelper raptorTargetingHelper = null;

		private const float MinTurnDistance = 1.2f;

		private bool respondingToHelpCall = false;

		private const float HelpCallRadius = 70f;

		private const float StalkChargeRange = 20f;

		private const float StalkSeenRange = 40f;

		private const float StalkSneakSpeed = 4f;

		private const float StalkChargeSpeed = 8f;

		private const float StalkTimeout = 40f;

		private const float CoverNodeSearchRadius = 35f;

		private const float CoverSearchInterval = 1f;

		private float stalkStartTime;

		private bool hasCoverPoint;

		private Vector3 coverPoint;

		private float nextCoverSearchTime;

		private const float StalkSpottedGraceTime = 2f;

		private float stalkSeenTime;

		private const float StalkUnreachableGraceTime = 2f;

		private float stalkUnreachableTime;

		private bool loggedSeenWhileSpotting;

		private float lastStalkTick;

		private const float HideNodeSearchRadius = 40f;

		private const float HideMinTime = 3f;

		private const float HideHiddenTime = 1f;

		private const float HideTimeout = 12f;

		private const float HideFallbackDistance = 25f;

		private const float HideSearchInterval = 1f;

		private float hideStartTime;

		private float lastHideTick;

		private float hiddenTime;

		private float nextHideSearchTime;

		private bool hasHidePoint;

		private Vector3 hidePoint;

		private Vector3 hideStartPosition;

		private const float FleeRaptorRadius = 10f;

		private const float FleeRaptorSearchRadius = 40f;

		private const float FleeToRaptorTimeout = 8f;

		private const float FleeAwayDistance = 50f;

		private const float FleeAwayTimeout = 15f;

		private const float FleePursuitRadius = 15f;

		private const float FleePursuitTime = 5f;

		private static readonly float[] FleeAngles = new float[7] { 0f, 35f, -35f, 70f, -70f, 110f, -110f };

		private const float StalkCooldownAfterFleeing = 5f;

		private float lastFleeTime = float.NegativeInfinity;

		private float fleeStartTime;

		private float lastFleeTick;

		private float pursuedTime;

		private bool hasFleePoint;

		private Vector3 fleePoint;

		private float lastHeardCallDistanceWhenHeard;

		private Vector3 noisePositionGuess;

		private readonly float noiseApproximation = 14f;

		private bool wasOnOffMeshLink;

		public DeadBodyInfo? CarryingKilledPlayerBody { get; private set; } = null;

		public int RaptorId { get; private set; }

		public RoundManager RoundManager { get; private set; } = null;

		public string ItemNameToDrop { get; private set; } = "Fancy lamp";

		public int NumberOfItemsToDrop { get; private set; } = 1;

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

		public override void Start()
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Start();
			AssignImportantValues();
			LogIfDebugBuild($"JPOGRaptor[{RaptorId}]: Spawned");
			timeSinceHittingLocalPlayer = 0f;
			timeSinceHittingOtherEnemy = 0f;
			base.currentBehaviourStateIndex = 0;
			SeMovementSpeedPerSate(State.SearchingForPlayer);
			((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
		}

		public override void OnDestroy()
		{
			AllRaptors.Remove(this);
			DropBodyInMouth();
			((EnemyAI)this).OnDestroy();
		}

		private void AssignImportantValues()
		{
			//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_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			AllRaptors.Add(this);
			RaptorId = nextRaptorId++;
			int length = Enum.GetValues(typeof(State)).Length;
			if (base.enemyBehaviourStates.Length < length)
			{
				int num = base.enemyBehaviourStates.Length;
				Array.Resize(ref base.enemyBehaviourStates, length);
				for (int i = num; i < length; i++)
				{
					EnemyBehaviourState[] enemyBehaviourStates = base.enemyBehaviourStates;
					int num2 = i;
					EnemyBehaviourState val = new EnemyBehaviourState();
					State state = (State)i;
					val.name = state.ToString();
					val.parameterString = "";
					enemyBehaviourStates[num2] = val;
				}
			}
			RoundManager = Object.FindObjectOfType<RoundManager>() ?? throw new Exception("JPOGRaptor: RoundManager not found!");
			raptorPounceHelper = new RaptorPounceHelper(this);
			raptorTargetingHelper = new RaptorTargetingHelper(this);
		}

		public override void Update()
		{
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: 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_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Update();
			if (base.isEnemyDead)
			{
				if (!isDeadAnimationDone)
				{
					LogIfDebugBuild("Stopping enemy voice with janky code.");
					isDeadAnimationDone = true;
					base.creatureVoice.Stop();
					base.creatureVoice.PlayOneShot(base.dieSFX);
					if (((NetworkBehaviour)this).IsServer)
					{
						DoAnimationClientRpc("stopBreath");
					}
				}
				return;
			}
			int currentBehaviourStateIndex = base.currentBehaviourStateIndex;
			if (((NetworkBehaviour)this).IsOwner)
			{
				CheckIfClimbing();
			}
			if (((NetworkBehaviour)this).IsOwner && !raptorPounceHelper.IsPouncing && !isClimbing)
			{
				Vector3 velocity = base.agent.velocity;
				float magnitude = ((Vector3)(ref velocity)).magnitude;
				if (Mathf.Abs(CurrentSpeed.Value - magnitude) > 0.1f)
				{
					CurrentSpeed.Value = magnitude;
				}
			}
			base.creatureAnimator.SetFloat("moveSpeed", CurrentSpeed.Value);
			if ((Object)(object)base.targetPlayer != (Object)null && currentBehaviourStateIndex != 0 && currentBehaviourStateIndex != 5 && currentBehaviourStateIndex != 6)
			{
				Vector3 val = ((Component)base.targetPlayer).transform.position - ((Component)this).transform.position;
				val.y = 0f;
				if (((Vector3)(ref val)).sqrMagnitude >= 1.44f)
				{
					turnCompass.LookAt(((Component)base.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);
				}
			}
			raptorPounceHelper.MoveRaptorDuringPounce(base.targetPlayer);
			if (base.stunNormalizedTimer > 0f)
			{
				base.agent.speed = 0f;
				wasStunned = true;
			}
			else if (wasStunned)
			{
				wasStunned = false;
				SeMovementSpeedPerSate((State)base.currentBehaviourStateIndex);
			}
			timeSinceHittingLocalPlayer += Time.deltaTime;
			timeSinceHittingOtherEnemy += Time.deltaTime;
			raptorPounceHelper.UpdateTimeSincePounceAttack();
			if (base.agent.speed < 0.1f && (Object)(object)base.targetPlayer != (Object)null && base.currentBehaviourStateIndex != 4)
			{
				LogIfDebugBuild($"[WARN] Raptor[{RaptorId}] has target but speed is zero! Current state: {(State)base.currentBehaviourStateIndex}");
			}
		}

		private void DropLoot()
		{
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			LogIfDebugBuild($"JPOGRaptor[{RaptorId}]: Dropping loot.");
			Item val = null;
			foreach (Item items in StartOfRound.Instance.allItemsList.itemsList)
			{
				if (items.itemName == ItemNameToDrop)
				{
					val = items;
					break;
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				Plugin.Logger.LogError((object)$"JPOGRaptor[{RaptorId}]: Item to drop '{ItemNameToDrop}' not found in allItemsList!");
				return;
			}
			GrabbableObject val4 = default(GrabbableObject);
			for (int i = 0; i < NumberOfItemsToDrop; i++)
			{
				Vector3 val2 = ((Component)this).transform.position + Random.insideUnitSphere * 1f;
				val2.y = ((Component)this).transform.position.y + 0.5f;
				GameObject val3 = Object.Instantiate<GameObject>(val.spawnPrefab, val2, Quaternion.identity);
				if (val3.TryGetComponent<GrabbableObject>(ref val4))
				{
					val4.fallTime = 0.5f;
					((NetworkBehaviour)val4).NetworkObject.Spawn(true);
					int scrapValue = Random.Range(20, 100);
					val4.scrapValue = scrapValue;
					Plugin.Logger.LogInfo((object)$"JPOGRaptor[{RaptorId}]: Dropped '{((Object)val).name}' with NetworkObjectId: {((NetworkBehaviour)val4).NetworkObjectId}");
					Plugin.Logger.LogInfo((object)$"JPOGRaptor[{RaptorId}]: Set scrapValue to: {val4.scrapValue}");
					continue;
				}
				Plugin.Logger.LogWarning((object)$"JPOGRaptor[{RaptorId}]: Spawned item '{((Object)val).name}' does not have a GrabbableObject component!");
				return;
			}
			LogIfDebugBuild($"JPOGRaptor[{RaptorId}]: Successfully dropped {NumberOfItemsToDrop} of '{val.itemName}'.");
		}

		public override void DoAIInterval()
		{
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d67: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d77: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d98: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d9d: Unknown result type (might be due to invalid IL or missing references)
			//IL_06bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e65: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e75: 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_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b65: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b71: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ed6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0907: Unknown result type (might be due to invalid IL or missing references)
			//IL_0913: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c4d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c5d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cdc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ce2: Unknown result type (might be due to invalid IL or missing references)
			//IL_045a: Unknown result type (might be due to invalid IL or missing references)
			//IL_046a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bd5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f56: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f5c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f92: Unknown result type (might be due to invalid IL or missing references)
			//IL_04dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_056c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fc4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fca: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_05af: Unknown result type (might be due to invalid IL or missing references)
			//IL_061a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0612: Unknown result type (might be due to invalid IL or missing references)
			//IL_1080: Unknown result type (might be due to invalid IL or missing references)
			//IL_1086: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).DoAIInterval();
			if (base.isEnemyDead || StartOfRound.Instance.allPlayersDead)
			{
				return;
			}
			raptorTargetingHelper.HandleTargetUnreachability();
			switch (base.currentBehaviourStateIndex)
			{
			case 0:
			{
				if (base.previousBehaviourStateIndex != 0)
				{
					LogIfDebugBuild($"JPOGRaptor[{RaptorId}]: Entered Searching for player");
					StateSwitchHelper(State.SearchingForPlayer);
					respondingToHelpCall = false;
					base.targetPlayer = null;
					((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
				}
				if (respondingToHelpCall)
				{
					break;
				}
				bool flag4 = RaptorRules.IsStalkOnCooldown(Time.time, lastFleeTime, 5f);
				switch (raptorTargetingHelper.TryAcquireTarget(!flag4))
				{
				case RaptorTargetingHelper.AcquireResult.TooClose:
					LogIfDebugBuild($"JPOGRaptor[{RaptorId}]: Player too close");
					if (!TryInstantPounce())
					{
						((EnemyAI)this).StopSearch(base.currentSearch, true);
						((EnemyAI)this).SwitchToBehaviourClientRpc(2);
					}
					break;
				case RaptorTargetingHelper.AcquireResult.Spotted:
					if (raptorTargetingHelper.IsSeenByAnyPlayer(40f))
					{
						if (!loggedSeenWhileSpotting)
						{
							loggedSeenWhileSpotting = true;
							LogIfDebugBuild($"JPOGRaptor[{RaptorId}]: Spotted a lone player at {Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position):F1} m, but is seen by a player, not stalking");
						}
						base.targetPlayer = null;
					}
					else
					{
						loggedSeenWhileSpotting = false;
						LogIfDebugBuild($"JPOGRaptor[{RaptorId}]: Spotted a lone player at {Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position):F1} m");
						((EnemyAI)this).StopSearch(base.currentSearch, true);
						((EnemyAI)this).SwitchToBehaviourClientRpc(1);
					}
					break;
				}
				break;
			}
			case 1:
			{
				if (base.previousBehaviourStateIndex != 1)
				{
					LogIfDebugBuild($"JPOGRaptor[{RaptorId}]: Entered Stalking Player");
					StateSwitchHelper(State.StalkingPlayer);
					stalkStartTime = Time.time;
					hasCoverPoint = false;
					nextCoverSearchTime = 0f;
					stalkSeenTime = 0f;
					stalkUnreachableTime = 0f;
					lastStalkTick = Time.time;
				}
				float deltaTime = Mathf.Min(Time.time - lastStalkTick, 1f);
				lastStalkTick = Time.time;
				if ((Object)(object)base.targetPlayer == (Object)null || !((EnemyAI)this).PlayerIsTargetable(base.targetPlayer, false, false, true))
				{
					LogIfDebugBuild(string.Format("JPOGRaptor[{0}]: Stalking > target lost ({1}), switching to SearchingForPlayer", RaptorId, ((Object)(object)base.targetPlayer == (Object)null) ? "no target" : "not targetable"));
					((EnemyAI)this).SwitchToBehaviourClientRpc(0);
					break;
				}
				RaptorTargetingHelper.Reachability reachability = raptorTargetingHelper.GetReachability(base.targetPlayer);
				stalkUnreachableTime = RaptorRules.UpdateTimer(stalkUnreachableTime, reachability != RaptorTargetingHelper.Reachability.Reachable, deltaTime);
				if (stalkUnreachableTime > 2f)
				{
					LogIfDebugBuild($"JPOGRaptor[{RaptorId}]: Stalking > target unreachable ({reachability}), switching to SearchingForPlayer");
					((EnemyAI)this).SwitchToBehaviourClientRpc(0);
				}
				else
				{
					if (TryInstantPounce())
					{
						break;
					}
					if (!raptorTargetingHelper.IsAlone(base.targetPlayer))
					{
						LogIfDebugBuild($"JPOGRaptor[{RaptorId}]: Stalking > target is no longer alone, calling for help and chasing");
						CallForHelp();
						((MonoBehaviour)this).StartCoroutine(PlayBark(longBark: true));
						((EnemyAI)this).SwitchToBehaviourClientRpc(2);
						break;
					}
					if (Time.time - stalkStartTime > 40f)
					{
						LogIfDebugBuild($"JPOGRaptor[{RaptorId}]: Stalking > took too long, switching to chasing player");
						((EnemyAI)this).SwitchToBehaviourClientRpc(2);
						break;
					}
					float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position);
					if (num2 <= 20f)
					{
						if (num2 < 10f)
						{
							LogIfDebugBuild($"JPOGRaptor[{RaptorId}]: Stalking > in range but cannot pounce, switching to chasing player");
							((EnemyAI)this).SwitchToBehaviourClientRpc(2);
						}
						else
						{
							base.agent.speed = 8f;
							((EnemyAI)this).SetDestinationToPosition(((Component)base.targetPlayer).transform.position, false);
						}
						break;
					}
					stalkSeenTime = RaptorRules.UpdateTimer(stalkSeenTime, raptorTargetingHelper.IsSeenByAnyPlayer(40f), deltaTime);
					if (stalkSeenTime > 2f)
					{
						LogIfDebugBuild($"JPOGRaptor[{RaptorId}]: Stalking > spotted by a player, hiding");
						((EnemyAI)this).SwitchToBehaviourClientRpc(6);
						break;
					}
					base.agent.speed = 4f;
					if (hasCoverPoint && !raptorTargetingHelper.IsHiddenFromAllPlayers(coverPoint, 40f))
					{
						hasCoverPoint = false;
						nextCoverSearchTime = 0f;
					}
					if ((!hasCoverPoint || Vector3.Distance(((Component)this).transform.position, coverPoint) < 2f) && Time.time >= nextCoverSearchTime)
					{
						nextCoverSearchTime = Time.time + 1f;
						hasCoverPoint = TryPickCoverPoint(out coverPoint);
					}
					((EnemyAI)this).SetDestinationToPosition(hasCoverPoint ? coverPoint : ((Component)base.targetPlayer).transform.position, false);
				}
				break;
			}
			case 2:
				if (base.previousBehaviourStateIndex != 2)
				{
					LogIfDebugBuild($"JPOGRaptor[{RaptorId}]: Entered Chasing Player");
					((EnemyAI)this).StopSearch(base.currentSearch, true);
					StateSwitchHelper(State.ChasingPlayer);
				}
				if (!raptorTargetingHelper.EnsureTarget())
				{
					LogIfDebugBuild($"Raptor[{RaptorId}]: No target found, switching to SearchingForPlayer");
					((EnemyAI)this).SwitchToBehaviourClientRpc(0);
					break;
				}
				((EnemyAI)this).SetDestinationToPosition(((Component)base.targetPlayer).transform.position, false);
				raptorTargetingHelper.UpdatePathTimeout(base.targetPlayer);
				if (!raptorTargetingHelper.CheckIfTargetPlayerIsReachable())
				{
					LogIfDebugBuild($"JPOGRaptor[{RaptorId}]: Cannot reach the target and timed out, looking for another target");
					raptorTargetingHelper.RetargetOrSearch();
					break;
				}
				raptorPounceHelper.CheckIfPlayersAreInRangeForPounceAttack();
				if (raptorPounceHelper.InRangeForPounceAttack)
				{
					((EnemyAI)this).SwitchToBehaviourServerRpc(4);
				}
				break;
			case 3:
				if (base.previousBehaviourStateIndex != 3)
				{
					LogIfDebugBuild($"JPOGRaptor[{RaptorId}]: Entered Responding To Call");
					StateSwitchHelper(State.RespondingToCall);
				}
				if ((Object)(object)base.targetPlayer != (Object)null && ((EnemyAI)this).PlayerIsTargetable(base.targetPlayer, false, false, true))
				{
					((EnemyAI)this).SetDestinationToPosition(((Component)base.targetPlayer).transform.position, false);
					if (Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position) < 15f)
					{
						LogIfDebugBuild($"JPOGRaptor[{RaptorId}]: Help response. Got close enough to the target player, switching to regular chase mode");
						respondingToHelpCall = false;
						((EnemyAI)this).SwitchToBehaviourServerRpc(2);
					}
				}
				else
				{
					respondingToHelpCall = false;
					((EnemyAI)this).SwitchToBehaviourServerRpc(0);
				}
				break;
			case 4:
				if (base.previousBehaviourStateIndex != 4)
				{
					LogIfDebugBuild($"JPOGRaptor[{RaptorId}]: Entered attacking Player");
					StateSwitchHelper(State.AttackingPlayer);
					if (!raptorPounceHelper.IsPouncing)
					{
						raptorPounceHelper.StartPounce();
					}
				}
				else
				{
					if (!raptorPounceHelper.PounceAttackComplete)
					{
						break;
					}
					if ((Object)(object)base.targetPlayer != (Object)null && base.targetPlayer.isPlayerControlled && !base.targetPlayer.isPlayerDead && (Object)(object)CarryingKilledPlayerBody == (Object)null)
					{
						JPOGRaptorAI jPOGRaptorAI = FindRaptorToFleeTo();
						if ((Object)(object)jPOGRaptorAI != (Object)null && RaptorRules.IsWithinRadius(Vector3.Distance(((Component)this).transform.position, ((Component)jPOGRaptorAI).transform.position), 10f))
						{
							LogIfDebugBuild($"JPOGRaptor[{RaptorId}]: Pounce missed, but raptor [{jPOGRaptorAI.RaptorId}] is close, chasing again");
							base.agent.speed = 8f;
							((EnemyAI)this).SwitchToBehaviourClientRpc(2);
						}
						else
						{
							LogIfDebugBuild($"JPOGRaptor[{RaptorId}]: Pounce missed, fleeing");
							base.agent.speed = 10f;
							((EnemyAI)this).SwitchToBehaviourClientRpc(5);
						}
					}
					else
					{
						LogIfDebugBuild($"JPOGRaptor[{RaptorId}]: Pounce Completed. Checking if switching to chase or search");
						if ((Object)(object)base.targetPlayer != (Object)null)
						{
							LogIfDebugBuild($"JPOGRaptor[{RaptorId}]: Pounce Completed. Target player != null, continue chasing player");
							base.agent.speed = 8f;
							((EnemyAI)this).SwitchToBehaviourClientRpc(2);
						}
						else
						{
							LogIfDebugBuild($"JPOGRaptor[{RaptorId}]: Pounce Completed. default, return to searching for player");
							base.agent.speed = 5f;
							((EnemyAI)this).SwitchToBehaviourClientRpc(0);
						}
					}
				}
				break;
			case 5:
			{
				if (base.previousBehaviourStateIndex != 5)
				{
					LogIfDebugBuild($"JPOGRaptor[{RaptorId}]: Entered Fleeing");
					StateSwitchHelper(State.FleeingFromPlayer);
					fleeStartTime = Time.time;
					lastFleeTick = Time.time;
					pursuedTime = 0f;
					hasFleePoint = false;
					CallForHelp();
					((MonoBehaviour)this).StartCoroutine(PlayBark(longBark: true));
				}
				if ((Object)(object)base.targetPlayer == (Object)null || !((EnemyAI)this).PlayerIsTargetable(base.targetPlayer, false, false, true))
				{
					LogIfDebugBuild($"JPOGRaptor[{RaptorId}]: Fleeing > target lost, switching to SearchingForPlayer");
					((EnemyAI)this).SwitchToBehaviourClientRpc(0);
					break;
				}
				float deltaTime2 = Time.time - lastFleeTick;
				lastFleeTick = Time.time;
				lastFleeTime = Time.time;
				JPOGRaptorAI jPOGRaptorAI2 = FindRaptorToFleeTo();
				if ((Object)(object)jPOGRaptorAI2 != (Object)null)
				{
					if (RaptorRules.IsWithinRadius(Vector3.Distance(((Component)this).transform.position, ((Component)jPOGRaptorAI2).transform.position), 10f) || Time.time - fleeStartTime > 8f)
					{
						LogIfDebugBuild($"JPOGRaptor[{RaptorId}]: Fleeing > reached another raptor (or timed out), chasing again");
						((EnemyAI)this).SwitchToBehaviourClientRpc(2);
					}
					else
					{
						((EnemyAI)this).SetDestinationToPosition(((Component)jPOGRaptorAI2).transform.position, false);
					}
					break;
				}
				if (!hasFleePoint)
				{
					hasFleePoint = TryFindFleePoint(out fleePoint, 50f);
					if (!hasFleePoint)
					{
						LogIfDebugBuild($"JPOGRaptor[{RaptorId}]: Fleeing > nowhere to run, chasing again");
						((EnemyAI)this).SwitchToBehaviourClientRpc(2);
						break;
					}
				}
				bool active = RaptorRules.IsWithinRadius(Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position), 15f);
				pursuedTime = RaptorRules.UpdateTimer(pursuedTime, active, deltaTime2);
				if (pursuedTime > 5f)
				{
					LogIfDebugBuild($"JPOGRaptor[{RaptorId}]: Fleeing > player keeps following, fighting back");
					if (!TryInstantPounce())
					{
						((EnemyAI)this).SwitchToBehaviourClientRpc(2);
					}
				}
				else if (Vector3.Distance(((Component)this).transform.position, fleePoint) < 3f || Time.time - fleeStartTime > 15f)
				{
					LogIfDebugBuild($"JPOGRaptor[{RaptorId}]: Fleeing > got away, giving up the chase");
					((EnemyAI)this).SwitchToBehaviourClientRpc(0);
				}
				break;
			}
			case 6:
			{
				if (base.previousBehaviourStateIndex != 6)
				{
					LogIfDebugBuild($"JPOGRaptor[{RaptorId}]: Entered Hiding, {Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position):F1} m from the target");
					hideStartPosition = ((Component)this).transform.position;
					StateSwitchHelper(State.HidingFromPlayer);
					hideStartTime = Time.time;
					lastHideTick = Time.time;
					hiddenTime = 0f;
					nextHideSearchTime = 0f;
					hasHidePoint = false;
				}
				if ((Object)(object)base.targetPlayer == (Object)null || !((EnemyAI)this).PlayerIsTargetable(base.targetPlayer, false, false, true))
				{
					LogIfDebugBuild($"JPOGRaptor[{RaptorId}]: Hiding > target lost, switching to SearchingForPlayer");
					((EnemyAI)this).SwitchToBehaviourClientRpc(0);
					break;
				}
				float num = Mathf.Min(Time.time - lastHideTick, 1f);
				lastHideTick = Time.time;
				lastFleeTime = Time.time;
				if (RaptorRules.IsWithinRadius(Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position), 5f))
				{
					LogIfDebugBuild($"JPOGRaptor[{RaptorId}]: Hiding > player too close, attacking");
					if (!TryInstantPounce())
					{
						((EnemyAI)this).SwitchToBehaviourClientRpc(2);
					}
					break;
				}
				bool flag = raptorTargetingHelper.IsHiddenFromAllPlayers(((Component)this).transform.position, 40f);
				hiddenTime = (flag ? (hiddenTime + num) : 0f);
				if (RaptorRules.IsHideComplete(Time.time - hideStartTime, hiddenTime, 3f, 1f, 12f))
				{
					LogIfDebugBuild($"JPOGRaptor[{RaptorId}]: Hiding > out of sight after {Time.time - hideStartTime:F1} s, moved {Vector3.Distance(((Component)this).transform.position, hideStartPosition):F1} m, switching to SearchingForPlayer");
					((EnemyAI)this).SwitchToBehaviourClientRpc(0);
					break;
				}
				if (hasHidePoint && !raptorTargetingHelper.IsHiddenFromAllPlayers(hidePoint, 40f))
				{
					hasHidePoint = false;
				}
				bool flag2 = hasHidePoint && Vector3.Distance(((Component)this).transform.position, hidePoint) < 2f;
				if ((!hasHidePoint || flag2) && !flag && Time.time >= nextHideSearchTime)
				{
					nextHideSearchTime = Time.time + 1f;
					bool flag3 = TryPickHidePoint(out hidePoint);
					hasHidePoint = flag3 || TryFindFleePoint(out hidePoint, 25f);
					if (hasHidePoint)
					{
						LogIfDebugBuild(string.Format("JPOGRaptor[{0}]: Hiding > going to {1} {2:F1} m away", RaptorId, flag3 ? "hidden node" : "fallback point", Vector3.Distance(((Component)this).transform.position, hidePoint)));
						break;
					}
					LogIfDebugBuild($"JPOGRaptor[{RaptorId}]: Hiding > nowhere to hide, switching to SearchingForPlayer");
					((EnemyAI)this).SwitchToBehaviourClientRpc(0);
				}
				break;
			}
			default:
				LogIfDebugBuild("This Behavior State doesn't exist!");
				break;
			}
		}

		public bool TryInstantPounce()
		{
			//IL_0066: 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)
			if (base.isEnemyDead || base.currentBehaviourStateIndex == 4 || raptorPounceHelper.IsPouncing)
			{
				return false;
			}
			raptorPounceHelper.CheckIfPlayersAreInRangeForPounceAttack();
			if (!raptorPounceHelper.InRangeForPounceAttack)
			{
				return false;
			}
			LogIfDebugBuild($"JPOGRaptor[{RaptorId}]: Instant pounce at {Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position):F1} m");
			((EnemyAI)this).StopSearch(base.currentSearch, true);
			respondingToHelpCall = false;
			((EnemyAI)this).SwitchToBehaviourServerRpc(4);
			return true;
		}

		private bool TryPickCoverPoint(out Vector3 point)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: 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_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = ((Component)base.targetPlayer).transform.position;
			float num = Vector3.Distance(((Component)this).transform.position, position);
			List<(Vector3, float)> list = new List<(Vector3, float)>();
			GameObject[] allAINodes = base.allAINodes;
			foreach (GameObject val in allAINodes)
			{
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				Vector3 position2 = val.transform.position;
				if (!(Vector3.Distance(((Component)this).transform.position, position2) > 35f))
				{
					float num2 = Vector3.Distance(position2, position);
					if (!(num2 >= num - 3f) && raptorTargetingHelper.IsHiddenFromAllPlayers(position2, 40f))
					{
						list.Add((position2, num2));
					}
				}
			}
			list.Sort(((Vector3 position, float distance) a, (Vector3 position, float distance) b) => a.distance.CompareTo(b.distance));
			for (int num3 = 0; num3 < list.Count && num3 < 5; num3++)
			{
				if (((EnemyAI)this).SetDestinationToPosition(list[num3].Item1, true))
				{
					point = list[num3].Item1;
					return true;
				}
			}
			point = default(Vector3);
			return false;
		}

		private JPOGRaptorAI? FindRaptorToFleeTo()
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			JPOGRaptorAI result = null;
			float num = 40f;
			foreach (JPOGRaptorAI allRaptor in AllRaptors)
			{
				if (!((Object)(object)allRaptor == (Object)null) && !((Object)(object)allRaptor == (Object)(object)this) && !((EnemyAI)allRaptor).isEnemyDead && ((EnemyAI)allRaptor).currentBehaviourStateIndex != 5)
				{
					float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)allRaptor).transform.position);
					if (num2 < num)
					{
						result = allRaptor;
						num = num2;
					}
				}
			}
			return result;
		}

		private bool TryPickHidePoint(out Vector3 point)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: 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_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = ((Component)base.targetPlayer).transform.position;
			float num = Vector3.Distance(((Component)this).transform.position, position);
			List<(Vector3, float)> list = new List<(Vector3, float)>();
			GameObject[] allAINodes = base.allAINodes;
			foreach (GameObject val in allAINodes)
			{
				if (!((Object)(object)val == (Object)null))
				{
					Vector3 position2 = val.transform.position;
					float num2 = Vector3.Distance(((Component)this).transform.position, position2);
					if (!(num2 > 40f) && !(Vector3.Distance(position2, position) < num - 2f) && raptorTargetingHelper.IsHiddenFromAllPlayers(position2, 40f))
					{
						list.Add((position2, num2));
					}
				}
			}
			list.Sort(((Vector3 position, float distance) a, (Vector3 position, float distance) b) => a.distance.CompareTo(b.distance));
			for (int num3 = 0; num3 < list.Count && num3 < 5; num3++)
			{
				if (((EnemyAI)this).SetDestinationToPosition(list[num3].Item1, true))
				{
					point = list[num3].Item1;
					return true;
				}
			}
			point = default(Vector3);
			return false;
		}

		private bool TryFindFleePoint(out Vector3 point, float distanceAway)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: 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_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: 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_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = ((Component)this).transform.position - ((Component)base.targetPlayer).transform.position;
			val.y = 0f;
			val = ((((Vector3)(ref val)).sqrMagnitude < 0.01f) ? (-((Component)this).transform.forward) : ((Vector3)(ref val)).normalized);
			float[] fleeAngles = FleeAngles;
			NavMeshHit val3 = default(NavMeshHit);
			foreach (float num in fleeAngles)
			{
				Vector3 val2 = ((Component)this).transform.position + Quaternion.Euler(0f, num, 0f) * val * distanceAway;
				if (NavMesh.SamplePosition(val2, ref val3, 15f, base.agent.areaMask) && Vector3.Distance(((NavMeshHit)(ref val3)).position, ((Component)this).transform.position) > distanceAway * 0.6f && ((EnemyAI)this).SetDestinationToPosition(((NavMeshHit)(ref val3)).position, true))
				{
					point = ((NavMeshHit)(ref val3)).position;
					return true;
				}
			}
			point = default(Vector3);
			return false;
		}

		private IEnumerator PlayBark(bool longBark)
		{
			if (longBark)
			{
				if (respondingToHelpCall)
				{
					yield return (object)new WaitForSeconds(0.5f);
				}
				DoAnimationClientRpc("barkCall");
				yield return (object)new WaitForSeconds(3f);
				inCallAnimation = false;
			}
			else
			{
				DoAnimationClientRpc("shortBark");
				yield return (object)new WaitForSeconds(1.3f);
				inCallAnimation = false;
			}
		}

		private void StateSwitchHelper(State state)
		{
			base.previousBehaviourStateIndex = (int)state;
			SeMovementSpeedPerSate(state);
		}

		private void SeMovementSpeedPerSate(State state)
		{
			LogIfDebugBuild($"JPOGRaptor[{RaptorId}]: Adjusting speed for state [{state}]");
			switch (state)
			{
			case State.SearchingForPlayer:
				base.agent.speed = 5f;
				break;
			case State.StalkingPlayer:
				base.agent.speed = 4f;
				break;
			case State.ChasingPlayer:
				base.agent.speed = 8f;
				break;
			case State.RespondingToCall:
				base.agent.speed = 10f;
				break;
			case State.AttackingPlayer:
				base.agent.speed = 0f;
				break;
			case State.FleeingFromPlayer:
				base.agent.speed = 10f;
				break;
			case State.HidingFromPlayer:
				base.agent.speed = 8f;
				break;
			}
		}

		public override void OnCollideWithPlayer(Collider other)
		{
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			if (timeSinceHittingLocalPlayer < 1.5f || inCallAnimation || raptorPounceHelper.IsPouncing)
			{
				if (Time.time - lastBlockedCollisionLogTime >= 1f)
				{
					lastBlockedCollisionLogTime = Time.time;
					LogIfDebugBuild($"JPOGRaptor[{RaptorId}]: Collision but can't do damage (since last hit {timeSinceHittingLocalPlayer:F1} s, calling animation {inCallAnimation}, pouncing {raptorPounceHelper.IsPouncing})");
				}
			}
			else
			{
				PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, false, false);
				if ((Object)(object)val != (Object)null)
				{
					LogIfDebugBuild($"JPOGRaptor[{RaptorId}]: Collision with Player! (state {(State)base.currentBehaviourStateIndex}), requesting the bite animation");
					timeSinceHittingLocalPlayer = 0f;
					val.DamagePlayer(30, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
					BiteAttackServerRpc(((NetworkBehaviour)val).NetworkObjectId);
				}
			}
		}

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

		public override void OnCollideWithEnemy(Collider other, EnemyAI? collidedEnemy = null)
		{
			if (((NetworkBehaviour)this).IsOwner && !(timeSinceHittingOtherEnemy < 5f) && !((Object)(object)collidedEnemy == (Object)null) && !(collidedEnemy is JPOGRaptorAI) && !base.isEnemyDead && !collidedEnemy.isEnemyDead && collidedEnemy.enemyType.canDie)
			{
				LogIfDebugBuild($"JPOGRaptor[{RaptorId}]: Collision with other valid enemy!");
				((EnemyAI)this).OnCollideWithEnemy(other, collidedEnemy);
				DoAnimationClientRpc("biteAttack");
				collidedEnemy.HitEnemy(3, (PlayerControllerB)null, true, -1);
				timeSinceHittingOtherEnemy = 0f;
			}
		}

		public override void HitEnemy(int force = 1, PlayerControllerB? playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
		{
			if (base.isEnemyDead)
			{
				return;
			}
			((EnemyAI)this).HitEnemy(force, playerWhoHit, playHitSFX, hitID);
			base.enemyHP -= force;
			if (((NetworkBehaviour)this).IsOwner && base.enemyHP <= 0 && !base.isEnemyDead)
			{
				raptorPounceHelper.CancelPounce();
				DropBodyInMouthServerRpc();
				if (base.searchCoroutine != null)
				{
					((MonoBehaviour)this).StopCoroutine(base.searchCoroutine);
					base.searchCoroutine = null;
				}
				((EnemyAI)this).KillEnemyOnOwnerClient(false);
			}
			else if (((NetworkBehaviour)this).IsOwner && (Object)(object)playerWhoHit != (Object)null)
			{
				raptorTargetingHelper.TargetPlayerWhoHit(playerWhoHit);
			}
		}

		public void CallForHelp()
		{
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			LogIfDebugBuild($"JPOGRaptor[{RaptorId}]: Raptor calling for help!");
			if ((Object)(object)base.targetPlayer == (Object)null)
			{
				return;
			}
			foreach (JPOGRaptorAI allRaptor in AllRaptors)
			{
				if ((Object)(object)allRaptor != (Object)null && (Object)(object)allRaptor != (Object)(object)this && !((EnemyAI)allRaptor).isEnemyDead && RaptorRules.IsWithinRadius(Vector3.Distance(((Component)this).transform.position, ((Component)allRaptor).transform.position), 70f))
				{
					allRaptor.ReactToHelpCall(base.targetPlayer, ((Component)this).transform.position, urgent: true);
				}
			}
		}

		public void ReactToHelpCall(PlayerControllerB playerToTarget, Vector3 needsHelpRaptorPosition, bool urgent)
		{
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: 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_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			LogIfDebugBuild($"JPOGRaptor[{RaptorId}]: Raptor Reacting to help call!");
			if (!respondingToHelpCall && base.currentBehaviourStateIndex == 0 && base.previousBehaviourStateIndex == 0)
			{
				respondingToHelpCall = true;
				inCallAnimation = true;
				if (urgent && (Object)(object)playerToTarget != (Object)null)
				{
					((MonoBehaviour)this).StartCoroutine(PlayBark(longBark: false));
					LogIfDebugBuild($"JPOGRaptor[{RaptorId}]: Help request was urgent, setting target player");
					base.targetPlayer = playerToTarget;
					((MonoBehaviour)this).StartCoroutine(ReachtToHelp());
				}
				else
				{
					((MonoBehaviour)this).StartCoroutine(PlayBark(longBark: true));
					LogIfDebugBuild($"JPOGRaptor[{RaptorId}]: Help request NOT urgent, moving towards call location");
					lastHeardCallDistanceWhenHeard = Vector3.Distance(((Component)this).transform.position, needsHelpRaptorPosition);
					noisePositionGuess = RoundManager.GetRandomNavMeshPositionInRadius(needsHelpRaptorPosition, lastHeardCallDistanceWhenHeard / noiseApproximation, default(NavMeshHit));
					((EnemyAI)this).SetDestinationToPosition(noisePositionGuess, false);
				}
			}
		}

		private IEnumerator ReachtToHelp()
		{
			yield return (object)new WaitForSeconds(1.5f);
			if (base.isEnemyDead || base.currentBehaviourStateIndex != 0)
			{
				respondingToHelpCall = false;
				inCallAnimation = false;
			}
			else
			{
				((EnemyAI)this).SwitchToBehaviourServerRpc(3);
			}
		}

		public void CheckIfClimbing()
		{
			if (base.agent.isOnOffMeshLink && !wasOnOffMeshLink)
			{
				wasOnOffMeshLink = true;
				isClimbing = true;
				SetAnimationBoolClientRPC("isClimbing", isClimbing);
				LogIfDebugBuild($"Raptor[{RaptorId}]: Started climbing.");
			}
			else if (!base.agent.isOnOffMeshLink && wasOnOffMeshLink)
			{
				wasOnOffMeshLink = false;
				isClimbing = false;
				SetAnimationBoolClientRPC("isClimbing", isClimbing);
				LogIfDebugBuild($"Raptor[{RaptorId}]: Finished climbing.");
			}
		}

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

		[ClientRpc]
		public void SetAnimationWalkingSpeedClientRPC()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val2 = default(ClientRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(3608829678u, val2, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val, 3608829678u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					Vector3 velocity = base.agent.velocity;
					float magnitude = ((Vector3)(ref velocity)).magnitude;
					base.creatureAnimator.SetFloat("moveSpeed", magnitude, 0.1f, Time.deltaTime);
				}
			}
		}

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

		public void PlayBarkClip(AudioClip audioClip)
		{
			RaptorcallVoice.PlayOneShot(audioClip);
			WalkieTalkie.TransmitOneShotAudio(RaptorcallVoice, audioClip, 1f);
		}

		public void PlayStepClip()
		{
			AudioClip val = ((!isNextStepClip1) ? FootstepClip2 : FootstepClip1);
			RaptorStepsSFX.PlayOneShot(val);
			isNextStepClip1 = !isNextStepClip1;
		}

		public void PlayVoiceClip(AudioClip audioClip)
		{
			base.creatureVoice.PlayOneShot(audioClip);
			WalkieTalkie.TransmitOneShotAudio(base.creatureVoice, audioClip, 1f);
		}

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

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

		private void TakeBodyInMouth(int playerId)
		{
			LogIfDebugBuild($"JPOGRaptor[{RaptorId}]: Taking boddy of player [{playerId}] in mouth");
			((MonoBehaviour)this).StartCoroutine(TakeBodyInMouthWhenReady(playerId));
		}

		private IEnumerator TakeBodyInMouthWhenReady(int playerId)
		{
			PlayerControllerB player = StartOfRound.Instance.allPlayerScripts[playerId];
			float timeout = 2f;
			while ((Object)(object)player.deadBody == (Object)null && timeout > 0f)
			{
				timeout -= Time.deltaTime;
				yield return null;
			}
			DeadBodyInfo killedPlayerBody = player.deadBody;
			if ((Object)(object)killedPlayerBody == (Object)null)
			{
				Plugin.Logger.LogWarning((object)$"JPOGRaptor[{RaptorId}]: deadbody of player [{playerId}] never appeared, cannot carry it.");
				yield break;
			}
			LogIfDebugBuild($"JPOGRaptor[{RaptorId}]: deadbody of player cause of death: [{killedPlayerBody.causeOfDeath}]");
			CarryingKilledPlayerBody = killedPlayerBody;
			killedPlayerBody.canBeGrabbedBackByPlayers = false;
			killedPlayerBody.attachedTo = MouthBone;
			killedPlayerBody.attachedLimb = killedPlayerBody.bodyParts[5];
			killedPlayerBody.matchPositionExactly = true;
			killedPlayerBody.MakeCorpseBloody();
		}

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

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

		private void DropBodyInMouth()
		{
			if ((Object)(object)CarryingKilledPlayerBody != (Object)null)
			{
				CarryingKilledPlayerBody.speedMultiplier = 3f;
				CarryingKilledPlayerBody.canBeGrabbedBackByPlayers = true;
				CarryingKilledPlayerBody.attachedTo = null;
				CarryingKilledPlayerBody.attachedLimb = null;
				CarryingKilledPlayerBody.matchPositionExactly = false;
				CarryingKilledPlayerBody = null;
			}
		}

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

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

		[ClientRpc]
		public void SpawnPlayerBloodOnClientRpc(ulong playerNetworkObjectId, Vector3 bloodDirection)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val2 = default(ClientRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(2632068254u, val2, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val, playerNetworkObjectId);
				((FastBufferWriter)(ref val)).WriteValueSafe(ref bloodDirection);
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 2632068254u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				PlayerControllerB val3 = default(PlayerControllerB);
				if ((Object)(object)NetworkManager.Singleton == (Object)null || !NetworkManager.Singleton.SpawnManager.SpawnedObjects.TryGetValue(playerNetworkObjectId, out var value))
				{
					Plugin.Logger.LogWarning((object)$"JPOGRaptor[{RaptorId}]: Could not find networked player object with ID {playerNetworkObjectId} to spawn blood.");
				}
				else if (((Component)value).TryGetComponent<PlayerControllerB>(ref val3))
				{
					val3.DropBlood(bloodDirection, true, false);
					LogIfDebugBuild($"JPOGRaptor[{RaptorId}]: Triggered DropBlood for player {val3.playerUsername} at {((Component)val3).transform.position}.");
				}
				else
				{
					Plugin.Logger.LogWarning((object)$"JPOGRaptor[{RaptorId}]: Found NetworkObject with ID {playerNetworkObjectId} but no PlayerControllerB component for blood.");
				}
			}
		}

		protected override void __initializeVariables()
		{
			if (CurrentSpeed == null)
			{
				throw new Exception("JPOGRaptorAI.CurrentSpeed cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)CurrentSpeed).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)CurrentSpeed, "CurrentSpeed");
			((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)CurrentSpeed);
			((EnemyAI)this).__initializeVariables();
		}

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Expected O, but got Unknown
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Expected O, but got Unknown
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Expected O, but got Unknown
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Expected O, but got Unknown
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Expected O, but got Unknown
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(3676221653u, new RpcReceiveHandler(__rpc_handler_3676221653), "BiteAttackServerRpc");
			((NetworkBehaviour)this).__registerRpc(3138070205u, new RpcReceiveHandler(__rpc_handler_3138070205), "DoAnimationClientRpc");
			((NetworkBehaviour)this).__registerRpc(3608829678u, new RpcReceiveHandler(__rpc_handler_3608829678), "SetAnimationWalkingSpeedClientRPC");
			((NetworkBehaviour)this).__registerRpc(1219365971u, new RpcReceiveHandler(__rpc_handler_1219365971), "SetAnimationBoolClientRPC");
			((NetworkBehaviour)this).__registerRpc(3217027902u, new RpcReceiveHandler(__rpc_handler_3217027902), "TakeBodyInMouthServerRpc");
			((NetworkBehaviour)this).__registerRpc(2831086148u, new RpcReceiveHandler(__rpc_handler_2831086148), "TakeBodyInMouthClientRpc");
			((NetworkBehaviour)this).__registerRpc(1709379253u, new RpcReceiveHandler(__rpc_handler_1709379253), "DropBodyInMouthServerRpc");
			((NetworkBehaviour)this).__registerRpc(1690123830u, new RpcReceiveHandler(__rpc_handler_1690123830), "DropBodyInMouthClientRpc");
			((NetworkBehaviour)this).__registerRpc(324893864u, new RpcReceiveHandler(__rpc_handler_324893864), "BeginPounceClientRpc");
			((NetworkBehaviour)this).__registerRpc(3223072178u, new RpcReceiveHandler(__rpc_handler_3223072178), "CheckRaptorPounceHitBoxesClientRPC");
			((NetworkBehaviour)this).__registerRpc(2632068254u, new RpcReceiveHandler(__rpc_handler_2632068254), "SpawnPlayerBloodOnClientRpc");
			((EnemyAI)this).__initializeRpcs();
		}

		private static void __rpc_handler_3676221653(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)
			{
				ulong playerNetworkObjectId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerNetworkObjectId);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((JPOGRaptorAI)(object)target).BiteAttackServerRpc(playerNetworkObjectId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

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

		private static void __rpc_handler_3608829678(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;
				((JPOGRaptorAI)(object)target).SetAnimationWalkingSpeedClientRPC();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1219365971(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_0067: 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_009a: 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 trigger = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref trigger, false);
				}
				bool value = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref value, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((JPOGRaptorAI)(object)target).SetAnimationBoolClientRPC(trigger, value);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3217027902(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 killPlayerId = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref killPlayerId);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((JPOGRaptorAI)(object)target).TakeBodyInMouthServerRpc(killPlayerId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2831086148(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 killPlayerId = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref killPlayerId);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((JPOGRaptorAI)(object)target).TakeBodyInMouthClientRpc(killPlayerId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1709379253(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;
				((JPOGRaptorAI)(object)target).DropBodyInMouthServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1690123830(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;
				((JPOGRaptorAI)(object)target).DropBodyInMouthClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_324893864(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 targetPlayerId = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref targetPlayerId);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((JPOGRaptorAI)(object)target).BeginPounceClientRpc(targetPlayerId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3223072178(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;
				((JPOGRaptorAI)(object)target).CheckRaptorPounceHitBoxesClientRPC();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2632068254(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ulong playerNetworkObjectId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerNetworkObjectId);
				Vector3 bloodDirection = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref bloodDirection);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((JPOGRaptorAI)(object)target).SpawnPlayerBloodOnClientRpc(playerNetworkObjectId, bloodDirection);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "JPOGRaptorAI";
		}
	}
	[BepInPlugin("JPOGRaptor", "JPOGRaptor", "1.0.7")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)"Plugin JPOGRaptor is loaded!");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "JPOGRaptor";

		public const string PLUGIN_NAME = "JPOGRaptor";

		public const string PLUGIN_VERSION = "1.0.7";
	}
}
namespace JPOGRaptor.src
{
	public class RaptorPounceHelper(JPOGRaptorAI jPOGRaptorAI)
	{
		public const float PounceRange = 10f;

		private Coroutine? pounceCoroutine;

		private readonly JPOGRaptorAI jpogRaptorAI = jPOGRaptorAI;

		private readonly float totalPounceTime = 4.5f;

		private readonly float pounceDamagePeriod = 2.5f;

		private readonly int raptorId = jPOGRaptorAI.RaptorId;

		private Vector3 pounceDirection;

		private bool localPlayerHitThisPounce = false;

		private int pounceTargetPlayerId = -1;

		private float hitBoxCheckTimer = 0f;

		private const float HitBoxCheckInterval = 0.1f;

		private Vector3 pounceTargetPlayerVelocity;

		private Vector3 pounceTargetPlayerlastPosition;

		private PlayerControllerB? velocityTrackedPlayer;

		private readonly float pouncePredictionTime = 1.5f;

		private const float LogThrottleSeconds = 2f;

		private float lastCooldownLogTime = float.NegativeInfinity;

		private float lastBlockedLineLogTime = float.NegativeInfinity;

		public bool IsPouncing { get; private set; } = false;

		public bool PounceAttackDamage { get; private set; } = false;

		public float TimeSincePounceAttack { get; private set; } = 10f;

		public bool PounceAttackComplete { get; private set; } = false;

		public float PounceTimer { get; private set; } = 0f;

		public float PounceDuration { get; private set; } = 1f;

		public float PounceSpeed { get; private set; } = 15f;

		public bool InRangeForPounceAttack { get; private set; } = false;

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

		[Conditional("DEBUG")]
		private void LogThrottled(ref float lastLogTime, string text)
		{
			if (!(Time.time - lastLogTime < 2f))
			{
				lastLogTime = Time.time;
				LogIfDebugBuild(text);
			}
		}

		public void StartPounce()
		{
			if (!IsPouncing)
			{
				pounceCoroutine = ((MonoBehaviour)jPOGRaptorAI).StartCoroutine(PounceRoutine());
			}
		}

		private IEnumerator PounceRoutine()
		{
			IsPouncing = true;
			PounceAttackDamage = true;
			PounceAttackComplete = false;
			TimeSincePounceAttack = Time.deltaTime;
			Vector3 predictedPosition = (((Object)(object)((EnemyAI)jPOGRaptorAI).targetPlayer != (Object)null) ? (((Component)((EnemyAI)jPOGRaptorAI).targetPlayer).transform.position + pounceTargetPlayerVelocity * pouncePredictionTime) : (((Component)jPOGRaptorAI).transform.forward * 5f));
			pounceDirection = predictedPosition - ((Component)jPOGRaptorAI).transform.position;
			pounceDirection.y = 0f;
			pounceDirection = ((Vector3)(ref pounceDirection)).normalized;
			int pounceTargetId = (((Object)(object)((EnemyAI)jPOGRaptorAI).targetPlayer != (Object)null) ? ((int)((EnemyAI)jPOGRaptorAI).targetPlayer.playerClientId) : (-1));
			jPOGRaptorAI.BeginPounceClientRpc(pounceTargetId);
			hitBoxCheckTimer = 0f;
			jPOGRaptorAI.DoAnimationClientRpc("pounceAttack");
			LogIfDebugBuild($"Raptor[{raptorId}]: Pounce started toward {predictedPosition}");
			yield return (object)new WaitForSeconds(pounceDamagePeriod);
			PounceAttackDamage = false;
			float timer = 0f;
			while (timer < totalPounceTime - pounceDamagePeriod && ((EnemyAI)jPOGRaptorAI).currentBehaviourStateIndex == 4)
			{
				timer += Time.deltaTime;
				yield return null;
			}
			if (((EnemyAI)jPOGRaptorAI).currentBehaviourStateIndex != 4)
			{
				LogIfDebugBuild($"Raptor[{raptorId}]: Pounce aborted because state changed");
				jPOGRaptorAI.DropBodyInMouthServerRpc();
				ResetPounceFlags();
			}
			else
			{
				jPOGRaptorAI.DropBodyInMouthServerRpc();
				ResetPounceFlags();
			}
		}

		private void ResetPounceFlags()
		{
			LogIfDebugBuild($"Raptor[{raptorId}]: resetting pounce flags");
			IsPouncing = false;
			PounceAttackDamage = false;
			PounceAttackComplete = true;
			PounceTimer = 0f;
			TimeSincePounceAttack = 0f;
			InRangeForPounceAttack = false;
			LogIfDebugBuild($"Raptor[{raptorId}]: Pounce flags reset");
		}

		public void CancelPounce()
		{
			if (pounceCoroutine != null)
			{
				((MonoBehaviour)jPOGRaptorAI).StopCoroutine(pounceCoroutine);
				pounceCoroutine = null;
			}
			IsPouncing = false;
		}

		private void PounceTargetting(PlayerControllerB? targetPlayer)
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)targetPlayer == (Object)null) && !(Time.deltaTime <= 0f))
			{
				if ((Object)(object)velocityTrackedPlayer != (Object)(object)targetPlayer)
				{
					velocityTrackedPlayer = targetPlayer;
					pounceTargetPlayerVelocity = Vector3.zero;
					pounceTargetPlayerlastPosition = ((Component)targetPlayer).transform.position;
				}
				else
				{
					pounceTargetPlayerVelocity = (((Component)targetPlayer).transform.position - pounceTargetPlayerlastPosition) / Time.deltaTime;
					pounceTargetPlayerlastPosition = ((Component)targetPlayer).transform.position;
				}
			}
		}

		private void UpdatePounceTimer()
		{
			PounceTimer += Time.deltaTime;
		}

		public void UpdateTimeSincePounceAttack()
		{
			if (!IsPouncing)
			{
				TimeSincePounceAttack += Time.deltaTime;
			}
		}

		public void MoveRaptorDuringPounce(PlayerControllerB? targetPlayer)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: 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_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)targetPlayer == (Object)null)
			{
				return;
			}
			PounceTargetting(targetPlayer);
			if (!IsPouncing)
			{
				return;
			}
			jPOGRaptorAI.turnCompass.LookAt(((Component)targetPlayer.gameplayCamera).transform.position);
			if (PounceAttackDamage)
			{
				hitBoxCheckTimer -= Time.deltaTime;
				if (hitBoxCheckTimer <= 0f)
				{
					hitBoxCheckTimer = 0.1f;
					jPOGRaptorAI.CheckRaptorPounceHitBoxesClientRPC();
				}
			}
			UpdatePounceTimer();
			if (PounceTimer < PounceDuration)
			{
				Vector3 val = pounceDirection * PounceSpeed * Time.deltaTime;
				Vector3 position = ((Component)jPOGRaptorAI).transform.position;
				NavMeshHit val2 = default(NavMeshHit);
				if (!NavMesh.Raycast(position, position + val, ref val2, ((EnemyAI)jPOGRaptorAI).agent.areaMask))
				{
					((Component)jPOGRaptorAI).transform.position = position + val;
				}
			}
		}

		public void CheckIfPlayersAreInRangeForPounceAttack()
		{
			//IL_002d: 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)
			InRangeForPounceAttack = false;
			if (!((Object)(object)((EnemyAI)jPOGRaptorAI).targetPlayer != (Object)null))
			{
				return;
			}
			float num = Vector3.Distance(((Component)jPOGRaptorAI).transform.position, ((Component)((EnemyAI)jPOGRaptorAI).targetPlayer).transform.position);
			if (num < 10f && HasClearLineToPlayer())
			{
				if (TimeSincePounceAttack >= 10f)
				{
					InRangeForPounceAttack = true;
					LogIfDebugBuild($"Raptor[{raptorId}]: Player in range and line clear for pounce!");
				}
				else
				{
					LogThrottled(ref lastCooldownLogTime, $"JPOGRaptor[{raptorId}]: target player was in pounce range, but pounce is on cooldown");
				}
			}
		}

		private bool HasClearLineToPlayer()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: 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)
			PlayerControllerB targetPlayer = ((EnemyAI)jPOGRaptorAI).targetPlayer;
			if ((Object)(object)targetPlayer == (Object)null)
			{
				return false;
			}
			Vector3 val = ((Component)jPOGRaptorAI).transform.position + Vector3.up * 1f;
			Vector3 val2 = ((Component)targetPlayer).transform.position + Vector3.up * 1f;
			RaycastHit val3 = default(RaycastHit);
			bool flag = Physics.Linecast(val, val2, ref val3, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1);
			if (flag)
			{
				LogThrottled(ref lastBlockedLineLogTime, $"Raptor[{raptorId}]: Line to player blocked by [{((Object)((RaycastHit)(ref val3)).collider).name}]");
			}
			return !flag;
		}

		public void BeginPounce(int targetPlayerId)
		{
			pounceTargetPlayerId = targetPlayerId;
			localPlayerHitThisPounce = false;
		}

		public void CheckRaptorPounceHitBoxes()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			if (localPlayerHitThisPounce)
			{
				return;
			}
			int num = 8;
			Collider[] array = Physics.OverlapBox(jPOGRaptorAI.attackArea.position, jPOGRaptorAI.attackArea.localScale, jPOGRaptorAI.attackArea.rotation, num);
			if (array.Length == 0)
			{
				return;
			}
			Collider[] array2 = array;
			foreach (Collider val in array2)
			{
				PlayerControllerB val2 = ((EnemyAI)jPOGRaptorAI).MeetsStandardPlayerCollisionConditions(val, false, false);
				if ((Object)(object)val2 != (Object)null && (int)val2.playerClientId == pounceTargetPlayerId)
				{
					localPlayerHitThisPounce = true;
					int num2 = ((!(Random.value < 0.9f)) ? 9 : 0);
					if ((Object)(object)jPOGRaptorAI.CarryingKilledPlayerBody == (Object)null)
					{
						int num3 = (int)val2.playerClientId;
						LogIfDebugBuild($"JPOGRaptor[{raptorId}]: Hit player [{num3}]");
						val2.KillPlayer(Vector3.zero, true, (CauseOfDeath)6, num2, default(Vector3), false);
						jPOGRaptorAI.TakeBodyInMouthServerRpc(num3);
					}
					else
					{
						val2.DamagePlayer(40, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
					}
				}
			}
		}
	}
	public static class RaptorRules
	{
		public static bool IsAlone(IEnumerable<float> distancesToOtherLivingPlayers, float groupRadius)
		{
			foreach (float distancesToOtherLivingPlayer in distancesToOtherLivingPlayers)
			{
				if (distancesToOtherLivingPlayer < groupRadius)
				{
					return false;
				}
			}
			return true;
		}

		public static bool IsWithinRadius(float distance, float radius)
		{
			return distance < radius;
		}

		public static bool IsStalkOnCooldown(float now, float lastFleeTime, float cooldown)
		{
			return now - lastFleeTime < cooldown;
		}

		public static float UpdateTimer(float timer, bool active, float deltaTime)
		{
			return active ? (timer + deltaTime) : Math.Max(0f, timer - deltaTime);
		}

		public static bool IsHideComplete(float timeSinceStart, float hiddenTime, float minTime, float hiddenRequired, float timeout)
		{
			return timeSinceStart >= timeout || (timeSinceStart >= minTime && hiddenTime >= hiddenRequired);
		}
	}
	public class RaptorTargetingHelper(JPOGRaptorAI jPOGRaptorAI)
	{
		public enum AcquireResult
		{
			None,
			Spotted,
			TooClose
		}

		public enum Reachability
		{
			Reachable,
			NoPath,
			ShipDoorClosed
		}

		private readonly JPOGRaptorAI jPOGRaptorAI = jPOGRaptorAI;

		private readonly int raptorId = jPOGRaptorAI.RaptorId;

		public const float SenseRange = 5f;

		private const float SpotRange = 40f;

		private const float GroupRadius = 10f;

		private const float SeenViewAngle = 45f;

		private float lastTimeoutUpdate;

		private bool lastPathReachable = true;

		public float MaxChaseDistance { get; private set; } = 45f;

		public float TimeWithoutPath { get; private set; } = 0f;

		public float MaxUnreachableTime { get; private set; } = 7f;

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

		public AcquireResult TryAcquireTarget(bool allowSpotting = true)
		{
			PlayerControllerB val = FindClosestPlayer(requireLOS: false, 5f);
			if ((Object)(object)val != (Object)null)
			{
				((EnemyAI)jPOGRaptorAI).targetPlayer = val;
				return AcquireResult.TooClose;
			}
			if (!allowSpotting)
			{
				return AcquireResult.None;
			}
			PlayerControllerB val2 = FindClosestPlayer(requireLOS: true, 40f, requireAlone: true);
			if ((Object)(object)val2 != (Object)null)
			{
				((EnemyAI)jPOGRaptorAI).targetPlayer = val2;
				return AcquireResult.Spotted;
			}
			return AcquireResult.None;
		}

		public bool IsAlone(PlayerControllerB player)
		{
			//IL_0057: 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)
			List<float> list = new List<float>();
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if (!((Object)(object)val == (Object)null) && !((Object)(object)val == (Object)(object)player) && val.isPlayerControlled && !val.isPlayerDead)
				{
					list.Add(Vector3.Distance(((Component)val).transform.position, ((Component)player).transform.position));
				}
			}
			return RaptorRules.IsAlone(list, 10f);
		}

		public bool IsSeenByAnyPlayer(float range)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: 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)
			Vector3 val = ((Component)jPOGRaptorAI).transform.position + Vector3.up * 1.2f;
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val2 in allPlayerScripts)
			{
				if (!((Object)(object)val2 == (Object)null) && val2.isPlayerControlled && !val2.isPlayerDead && val2.HasLineOfSightToPosition(val, 45f, (int)range, -1f, -1))
				{
					return true;
				}
			}
			return false;
		}

		public bool IsHiddenFromAllPlayers(Vector3 point, float range)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//