Decompiled source of JPOGTrex v1.1.7

plugins/JPOGTrex.dll

Decompiled 3 weeks ago
#define DEBUG
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Dawn;
using GameNetcodeStuff;
using JPOGTrex.Configuration;
using JPOGTrex.NetcodePatcher;
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("JPOGTrex")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.1.7.0")]
[assembly: AssemblyInformationalVersion("1.1.7+dc98c52f9bdb0500d6a33b45b91c2709c6007d86")]
[assembly: AssemblyProduct("JPOGTrex")]
[assembly: AssemblyTitle("JPOGTrex")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.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 JPOGTrex
{
	internal class JPOGTrexAI : EnemyAI, IVisibleThreat
	{
		internal enum State
		{
			SearchingForPlayer,
			SpottedPlayer,
			ChasingPlayer,
			Roaring,
			AttackingEntity,
			GrabPlayer,
			GrabbedPlayer,
			GrabbingPlayer,
			EatingPlayer,
			Eating,
			Idle
		}

		public Transform turnCompass = null;

		public Transform attackArea = null;

		public Transform mouthGrip = null;

		public SphereCollider? mouthBiteZone;

		public AudioSource trexRoarSFX = null;

		public AudioSource trexSubRoarSFX = null;

		private readonly NetworkVariable<int> visionRangeLength = new NetworkVariable<int>(70, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		private readonly NetworkVariable<int> visionRangeWidth = new NetworkVariable<int>(60, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		private readonly NetworkVariable<int> fearTargetId = new NetworkVariable<int>(-1, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)1);

		private readonly float fearWhenTargeted = 0.7f;

		private readonly float fearIncreaseWhileHunted = 1.4f;

		private readonly float fearRange = 40f;

		private bool wasLocalPlayerTargeted;

		private float timeSinceHittingLocalPlayer;

		private readonly float knockbackHorizontalForce = 10f;

		private readonly float knockbackUpwardForce = 5f;

		private bool isDeadAnimationDone;

		private float defaultSpeed = 6f;

		private readonly float chaseSpeedMultiplier = 2.25f;

		private State previousState = State.Idle;

		private bool roaring;

		private bool isRoaringStarted;

		private bool isSniffingStarted;

		private bool sniffing;

		private Coroutine? sniffCoroutine;

		private Coroutine? roarCoroutine;

		private float previousSpeed;

		private bool wasStunned;

		private float speedBeforeStun;

		internal TrexSuspicionHelper Suspicion { get; private set; } = null;

		internal TrexTargetingHelper Targeting { get; private set; } = null;

		internal TrexGrabHelper Grab { get; private set; } = null;

		internal TrexFeedingHelper Feeding { get; private set; } = null;

		internal TrexEnemyAttackHelper EnemyAttack { get; private set; } = null;

		internal TrexChaseHelper Chase { get; private set; } = null;

		internal Random EnemyRandom { get; private set; } = null;

		internal int VisionRangeLength => visionRangeLength.Value;

		internal int VisionRangeWidth => visionRangeWidth.Value;

		ThreatType IVisibleThreat.type => (ThreatType)4;

		public int GetThreatLevel(Vector3 seenByPosition)
		{
			return 18;
		}

		public int GetInterestLevel()
		{
			return 0;
		}

		public Transform GetThreatLookTransform()
		{
			return base.eye;
		}

		public Transform GetThreatTransform()
		{
			return ((Component)this).transform;
		}

		public Vector3 GetThreatVelocity()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			if (((NetworkBehaviour)this).IsOwner)
			{
				return base.agent.velocity;
			}
			return Vector3.zero;
		}

		public float GetVisibility()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			if (base.isEnemyDead)
			{
				return 0f;
			}
			Vector3 velocity = base.agent.velocity;
			if (((Vector3)(ref velocity)).sqrMagnitude > 0f)
			{
				return 1f;
			}
			return 0.75f;
		}

		public int SendSpecialBehaviour(int id)
		{
			return 0;
		}

		public GrabbableObject? GetHeldObject()
		{
			return null;
		}

		public bool IsThreatDead()
		{
			return base.isEnemyDead;
		}

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

		private void DisableUnusedColliders()
		{
			DisableColliders(mouthGrip);
			DisableColliders(attackArea);
			DisableColliders(((Object)(object)mouthBiteZone != (Object)null) ? ((Component)mouthBiteZone).transform : null);
		}

		private static void DisableColliders(Transform? target)
		{
			if (!((Object)(object)target == (Object)null))
			{
				Collider[] components = ((Component)target).GetComponents<Collider>();
				foreach (Collider val in components)
				{
					val.enabled = false;
				}
			}
		}

		private void CreateHelpers()
		{
			Suspicion = new TrexSuspicionHelper(this);
			Targeting = new TrexTargetingHelper(this);
			Grab = new TrexGrabHelper(this);
			Feeding = new TrexFeedingHelper(this);
			EnemyAttack = new TrexEnemyAttackHelper(this);
			Chase = new TrexChaseHelper(this);
		}

		private void AssignConfigVariables()
		{
			PluginConfig boundConfig = Plugin.BoundConfig;
			defaultSpeed = boundConfig.DefaultSpeed.Value;
			Suspicion.Configure(boundConfig.MaxSuspicionLevel.Value, boundConfig.SuspicionIncrement.Value, boundConfig.SuspicionDecrement.Value, boundConfig.SuspiciontDecreaseTime.Value);
			Targeting.Configure(VisionRangeLength - 20);
			Chase.Configure(defaultSpeed * chaseSpeedMultiplier);
		}

		public override void OnNetworkSpawn()
		{
			((NetworkBehaviour)this).OnNetworkSpawn();
			if (((NetworkBehaviour)this).IsServer)
			{
				visionRangeLength.Value = Plugin.BoundConfig.VisionRangeLength.Value;
				visionRangeWidth.Value = Plugin.BoundConfig.VisionRangeWidth.Value;
			}
		}

		public override void Start()
		{
			CreateHelpers();
			DisableUnusedColliders();
			AssignConfigVariables();
			base.agent.stoppingDistance = 0f;
			((EnemyAI)this).Start();
			LogIfDebugBuild("JPOGTrex Spawned");
			timeSinceHittingLocalPlayer = 0f;
			EnemyRandom = new Random(StartOfRound.Instance.randomMapSeed + base.thisEnemyIndex);
			isDeadAnimationDone = false;
			if (((NetworkBehaviour)this).IsOwner)
			{
				SetWalkingAnimationServerRpc(defaultSpeed);
				((EnemyAI)this).SwitchToBehaviourState(0);
			}
		}

		public override void Update()
		{
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: 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);
				}
				return;
			}
			Targeting.Tick(Time.deltaTime);
			timeSinceHittingLocalPlayer += Time.deltaTime;
			if (base.currentBehaviourStateIndex == 0)
			{
				Suspicion.TickLocalSightCheck(Time.deltaTime);
			}
			ScareLocalPlayerIfTargeted();
			if (!((NetworkBehaviour)this).IsOwner)
			{
				return;
			}
			int currentBehaviourStateIndex = base.currentBehaviourStateIndex;
			UpdateFearTarget(currentBehaviourStateIndex);
			if ((Object)(object)base.targetPlayer != (Object)null && (currentBehaviourStateIndex == 5 || currentBehaviourStateIndex == 6 || currentBehaviourStateIndex == 7 || currentBehaviourStateIndex == 8 || currentBehaviourStateIndex == 1))
			{
				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);
			}
			if (base.stunNormalizedTimer > 0f)
			{
				if (!wasStunned)
				{
					wasStunned = true;
					speedBeforeStun = base.agent.speed;
					base.agent.speed = 0f;
					SetWalkingAnimationServerRpc(base.agent.speed);
				}
			}
			else if (wasStunned)
			{
				wasStunned = false;
				base.agent.speed = speedBeforeStun;
				SetWalkingAnimationServerRpc(base.agent.speed);
			}
			if ((currentBehaviourStateIndex == 2 || currentBehaviourStateIndex == 5) && !wasStunned)
			{
				Chase.Tick();
			}
		}

		public override void DoAIInterval()
		{
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).DoAIInterval();
			if (base.isEnemyDead || StartOfRound.Instance.allPlayersDead)
			{
				return;
			}
			switch (base.currentBehaviourStateIndex)
			{
			case 0:
			{
				if (previousState != State.SearchingForPlayer)
				{
					StopSniffAndRoar();
					LogIfDebugBuild("JPOGTrex: Entered behaviourState [SearchingForPlayer]");
					base.movingTowardsTargetPlayer = false;
					Targeting.ResetLostPlayer();
					Grab.ResetMisses();
					base.agent.speed = defaultSpeed;
					base.agent.autoBraking = true;
					SetWalkingAnimationServerRpc(base.agent.speed);
					((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
					previousState = State.SearchingForPlayer;
				}
				if (HandleBodyStillInMouth())
				{
					break;
				}
				if (Targeting.FoundClosestPlayerInRange())
				{
					LogIfDebugBuild("JPOGTrex: Beginning chase for player in close proximity");
					((EnemyAI)this).StopSearch(base.currentSearch, true);
					((EnemyAI)this).SwitchToBehaviourState(1);
					break;
				}
				Suspicion.DecreaseSuspicion();
				if (Suspicion.TryTakeMovingPlayer(out PlayerControllerB player) && Targeting.IsValidNewTarget(player))
				{
					base.targetPlayer = player;
					((EnemyAI)this).StopSearch(base.currentSearch, true);
					((EnemyAI)this).SwitchToBehaviourState(1);
				}
				break;
			}
			case 1:
				if (previousState != State.SpottedPlayer && !isSniffingStarted)
				{
					LogIfDebugBuild("JPOGTrex: Entered behaviourState [SpottedPlayer]");
					base.agent.speed = 2f;
					sniffing = true;
					SetWalkingAnimationServerRpc(base.agent.speed);
					sniffCoroutine = ((MonoBehaviour)this).StartCoroutine(FoundPlayer());
					isSniffingStarted = true;
					previousState = State.SpottedPlayer;
				}
				if (!sniffing)
				{
					isSniffingStarted = false;
					((EnemyAI)this).SwitchToBehaviourState(3);
				}
				break;
			case 3:
				if (previousState != State.SpottedPlayer && previousState != State.Roaring)
				{
					LogIfDebugBuild("JPOGTrex: Entered behaviourState [Roaring]");
					base.agent.speed = 0f;
					SetWalkingAnimationServerRpc(base.agent.speed);
					previousState = State.Roaring;
				}
				if (previousState != State.Roaring && !isRoaringStarted)
				{
					roaring = true;
					LogIfDebugBuild("JPOGTrex: Roaring at Player!");
					roarCoroutine = ((MonoBehaviour)this).StartCoroutine(BeginChase(EnemyRandom.Next(1, 4)));
					isRoaringStarted = true;
				}
				if (!roaring)
				{
					isRoaringStarted = false;
					((EnemyAI)this).SwitchToBehaviourState(2);
				}
				break;
			case 2:
				if (previousState != State.ChasingPlayer)
				{
					LogIfDebugBuild("JPOGTrex: Entered behaviourState [ChasingPlayer]");
					base.agent.speed = defaultSpeed * chaseSpeedMultiplier;
					previousState = State.ChasingPlayer;
					base.movingTowardsTargetPlayer = false;
					SetWalkingAnimationServerRpc(base.agent.speed);
					Targeting.ResetLostPlayer();
					base.agent.autoBraking = false;
					Chase.Reset();
				}
				if (HandleBodyStillInMouth())
				{
					break;
				}
				if ((Object)(object)base.targetPlayer != (Object)null)
				{
					Targeting.UpdateUnreachableTimer();
					if (Targeting.IsInGrabRange() && Grab.CanGrab)
					{
						((EnemyAI)this).SwitchToBehaviourState(5);
						break;
					}
					if (base.targetPlayer.isInHangarShipRoom)
					{
						LogIfDebugBuild("JPOGTrex: TargetPlayer is inside the ship, stopping chase");
						StopChase();
						break;
					}
					if (Targeting.HasBeenUnreachableTooLong)
					{
						LogIfDebugBuild("JPOGTrex: TargetPlayer has been unreachable for too long!");
						StopChase();
						break;
					}
				}
				if (!Targeting.IsTargetTargetable())
				{
					StopChase();
				}
				else if (Targeting.IsTargetLostFromSight())
				{
					Targeting.StartMovingToLastKnownPosition();
				}
				else if (Targeting.HasSearchTimedOut)
				{
					LogIfDebugBuild("JPOGTrex: Spent to long trying to reach last know position. returning to searching for player");
					StopChase();
				}
				else if (Targeting.ReachedLastKnownPosition() && !Targeting.FoundClosestPlayerInRange())
				{
					LogIfDebugBuild("JPOGTrex: No players found. Return to searching for player.");
					StopChase();
				}
				else if ((Object)(object)base.targetPlayer == (Object)null && !Targeting.IsMovingTowardsLastKnownPosition)
				{
					LogIfDebugBuild("JPOGTrex: No players found in range. Return to searching for player.");
					StopChase();
				}
				break;
			case 4:
				previousState = State.AttackingEntity;
				DoAnimationServerRpc("attackEnemy");
				break;
			case 5:
				if (previousState != State.GrabPlayer)
				{
					LogIfDebugBuild("JPOGTrex: Entered behaviourState [GrabPlayer]");
					previousState = State.GrabPlayer;
					if ((Object)(object)base.targetPlayer != (Object)null && base.targetPlayer.isInHangarShipRoom)
					{
						LogIfDebugBuild("JPOGTrex: TargetPlayer is inside the ship, stopping chase");
						StopChase();
						break;
					}
					Grab.StartGrab();
				}
				if (Grab.BeginningGrab)
				{
					break;
				}
				if (Grab.ConsumeHitConnect())
				{
					LogIfDebugBuild("JPOGTrex: Hit connect, Switching to GrabbingPlayer");
					base.agent.speed = defaultSpeed / 2f;
					SetWalkingAnimationServerRpc(base.agent.speed);
					((EnemyAI)this).SwitchToBehaviourState(7);
				}
				else if (!Grab.InGrabAttack)
				{
					Grab.RegisterMiss();
					if (Grab.ConsecutiveMisses >= 3 && (Object)(object)base.targetPlayer != (Object)null && !Targeting.IsReachableByPath(base.targetPlayer))
					{
						LogIfDebugBuild("JPOGTrex: Missed too many bites at a player it can't walk to, stopping chase");
						StopChase();
					}
					else
					{
						LogIfDebugBuild("JPOGTrex: Hit did not connect, returning to chasingPlayer");
						((EnemyAI)this).SwitchToBehaviourState(2);
					}
				}
				break;
			case 6:
				DoAnimationServerRpc("grabbedPlayer");
				previousState = State.GrabbedPlayer;
				((EnemyAI)this).SwitchToBehaviourState(7);
				break;
			case 7:
				if (previousState != State.GrabbingPlayer)
				{
					LogIfDebugBuild("JPOGTrex: Entered behaviourState [GrabbingPlayer]");
					base.agent.speed = 0f;
					previousState = State.GrabbingPlayer;
					base.movingTowardsTargetPlayer = false;
					SetWalkingAnimationServerRpc(base.agent.speed);
					Feeding.BeginShakeLocal();
					ShakingBodiesServerRpc();
				}
				if (!Feeding.IsShaking)
				{
					if (Feeding.IsHungry && Feeding.HasEdibleBodyInMouth)
					{
						LogIfDebugBuild("JPOGTrex: Done shaking, switching to eat body");
						((EnemyAI)this).SwitchToBehaviourState(8);
						break;
					}
					LogIfDebugBuild($"JPOGTrex: Done shaking, not eating || isHungry = [{Feeding.IsHungry}] || hasEdibleBodyInMouth = [{Feeding.HasEdibleBodyInMouth}]");
					Feeding.DropCarriedBodies();
					DropcarriedBodyServerRpc();
					((EnemyAI)this).SwitchToBehaviourState(0);
				}
				break;
			case 8:
				if (previousState != State.EatingPlayer)
				{
					LogIfDebugBuild("JPOGTrex: Entered behaviourState [EatingPlayer]");
					base.agent.speed = 0f;
					SetWalkingAnimationServerRpc(base.agent.speed);
					previousState = State.EatingPlayer;
					if (Feeding.IsHungry && !Feeding.IsEating)
					{
						Feeding.BeginEatingLocal();
						EatPlayerServerRpc();
					}
				}
				if (Feeding.ConsumeDoneEating())
				{
					LogIfDebugBuild("JPOGTrex: Done eating, returning to SearchingForPlayer");
					Suspicion.SetPercent(20f);
					((EnemyAI)this).SwitchToBehaviourState(0);
				}
				break;
			case 10:
				switch (EnemyRandom.Next(4))
				{
				case 1:
					LogIfDebugBuild("JPOGTrex: Entered behaviourState [Idle]");
					base.agent.speed = 1f;
					DoAnimationServerRpc("lookingIdle");
					previousState = State.Idle;
					break;
				case 2:
					base.agent.speed = 1f;
					DoAnimationServerRpc("sniffingIdle");
					previousState = State.Idle;
					break;
				case 3:
					base.agent.speed = 0f;
					DoAnimationServerRpc("eatingIdle01");
					previousState = State.Idle;
					((EnemyAI)this).SwitchToBehaviourState(9);
					break;
				}
				break;
			case 9:
				DoAnimationServerRpc("eatingIdle02");
				previousState = State.Idle;
				((EnemyAI)this).SwitchToBehaviourState(9);
				break;
			default:
				LogIfDebugBuild("This Behavior State doesn't exist!");
				isRoaringStarted = false;
				((EnemyAI)this).SwitchToBehaviourState(0);
				break;
			}
		}

		private void UpdateFearTarget(int state)
		{
			int num = (((state == 1 || state == 3 || state == 2 || state == 5) && (Object)(object)base.targetPlayer != (Object)null && !base.targetPlayer.isPlayerDead) ? ((int)base.targetPlayer.playerClientId) : (-1));
			if (fearTargetId.Value != num)
			{
				fearTargetId.Value = num;
			}
		}

		private void ScareLocalPlayerIfTargeted()
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			bool flag = (Object)(object)localPlayerController != (Object)null && !localPlayerController.isPlayerDead && fearTargetId.Value == (int)localPlayerController.playerClientId;
			if (flag && !wasLocalPlayerTargeted)
			{
				localPlayerController.JumpToFearLevel(fearWhenTargeted, true);
			}
			if (flag && Vector3.Distance(((Component)this).transform.position, ((Component)localPlayerController).transform.position) < fearRange)
			{
				localPlayerController.IncreaseFearLevelOverTime(fearIncreaseWhileHunted, 1f);
			}
			wasLocalPlayerTargeted = flag;
		}

		private void StopChase()
		{
			base.targetPlayer = null;
			Targeting.ResetLostPlayer();
			Grab.ResetMisses();
			Suspicion.SetPercent(60f);
			((EnemyAI)this).SwitchToBehaviourState(0);
		}

		private bool HandleBodyStillInMouth()
		{
			if (!Feeding.HasBodyInMouth || Feeding.IsShaking || Feeding.IsEating)
			{
				return false;
			}
			LogIfDebugBuild("JPOGTrex: Still has a body in the mouth, switching to GrabbingPlayer");
			((EnemyAI)this).SwitchToBehaviourState(7);
			return true;
		}

		private void StopSniffAndRoar()
		{
			if (sniffCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(sniffCoroutine);
				sniffCoroutine = null;
			}
			if (roarCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(roarCoroutine);
				roarCoroutine = null;
			}
			sniffing = false;
			roaring = false;
			isSniffingStarted = false;
			isRoaringStarted = false;
		}

		public bool CheckIfInNotAnimation()
		{
			return !Grab.IsBusy && !Feeding.IsEating && !EnemyAttack.IsAttacking;
		}

		internal void ResetHitTimer()
		{
			timeSinceHittingLocalPlayer = 0f;
		}

		[ServerRpc(RequireOwnership = false)]
		internal void IncreaseSuspicionServerRpc(int playerId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//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(3912369504u, val2, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val, playerId);
					((NetworkBehaviour)this).__endSendServerRpc(ref val, 3912369504u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					IncreaseSuspicionClientRpc(playerId);
				}
			}
		}

		[ClientRpc]
		private void IncreaseSuspicionClientRpc(int playerId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//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(4015576473u, val2, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val, playerId);
					((NetworkBehaviour)this).__endSendClientRpc(ref val, 4015576473u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					Suspicion.OnPlayerSeenMoving(playerId);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void EatPlayerServerRpc()
		{
			//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(2761139281u, val2, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val, 2761139281u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					EatPlayerClientRpc();
				}
			}
		}

		[ClientRpc]
		private void EatPlayerClientRpc()
		{
			//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(1552663799u, val2, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val, 1552663799u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					Feeding.StartEating();
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void ShakingBodiesServerRpc()
		{
			//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(1138974225u, val2, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val, 1138974225u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					ShakingBodiesClientRpc();
				}
			}
		}

		[ClientRpc]
		private void ShakingBodiesClientRpc()
		{
			//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(1014053066u, val2, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val, 1014053066u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					Feeding.StartShake();
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void DropcarriedBodyServerRpc()
		{
			//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(1541272386u, val2, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val, 1541272386u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					DropcarriedBodyClientRpc();
				}
			}
		}

		[ClientRpc]
		public void DropcarriedBodyClientRpc()
		{
			//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(975871412u, val2, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val, 975871412u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					Feeding.DropCarriedBodies();
				}
			}
		}

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

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

		[ClientRpc]
		public void DoAnimationClientRpc(string animationName)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val2 = default(ClientRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(2366721070u, 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, 2366721070u, 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);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		internal void StartGrabCheckServerRpc()
		{
			//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(2585592854u, val2, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val, 2585592854u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					StartGrabCheckClientRpc();
				}
			}
		}

		[ClientRpc]
		private void StartGrabCheckClientRpc()
		{
			//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(142709209u, val2, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val, 142709209u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					Grab.OnStartGrabCheck();
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		internal void StopGrabCheckServerRpc()
		{
			//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(813321880u, val2, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val, 813321880u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					StopGrabCheckClientRpc();
				}
			}
		}

		[ClientRpc]
		private void StopGrabCheckClientRpc()
		{
			//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(179337775u, val2, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val, 179337775u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					Grab.OnStopGrabCheck();
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		internal void SetHitConnectToTrueServerRpc()
		{
			//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(448008859u, val2, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val, 448008859u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					SetHitConnectToTrueClientRpc();
				}
			}
		}

		[ClientRpc]
		private void SetHitConnectToTrueClientRpc()
		{
			//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(4090198766u, val2, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val, 4090198766u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					Grab.OnHitConnected();
				}
			}
		}

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

		[ClientRpc]
		public void KillPlayerClientRpc(int playerId, int deathAnimation)
		{
			//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_007e: 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)
			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(3611163554u, val2, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val, playerId);
					BytePacker.WriteValueBitPacked(val, deathAnimation);
					((NetworkBehaviour)this).__endSendClientRpc(ref val, 3611163554u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					Grab.StartKill(playerId, deathAnimation);
				}
			}
		}

		[ClientRpc]
		public void CancelKillAnimationWithPlayerClientRpc(int playerObjectId)
		{
			//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(402060824u, val2, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val, playerObjectId);
					((NetworkBehaviour)this).__endSendClientRpc(ref val, 402060824u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					LogIfDebugBuild("JPOGTrex: CancelKillAnimationWIthPlayer");
					StartOfRound.Instance.allPlayerScripts[playerObjectId].inAnimationWithEnemy = null;
				}
			}
		}

		public override void OnCollideWithPlayer(Collider other)
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: 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)
			((EnemyAI)this).OnCollideWithPlayer(other);
			if (timeSinceHittingLocalPlayer < 1f)
			{
				return;
			}
			PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, false, false);
			if ((Object)(object)val != (Object)null && !val.isInHangarShipRoom)
			{
				LogIfDebugBuild("JPOGTrex: Collision with Player!");
				timeSinceHittingLocalPlayer = 0f;
				Vector3 knockback = GetKnockback(val);
				if (!val.inVehicleAnimation)
				{
					val.externalForceAutoFade += knockback;
				}
				val.DamagePlayer(20, true, true, (CauseOfDeath)8, 0, false, knockback * 0.4f);
			}
		}

		private Vector3 GetKnockback(PlayerControllerB player)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = ((Component)player).transform.position - ((Component)this).transform.position;
			val.y = 0f;
			if (((Vector3)(ref val)).sqrMagnitude < 0.01f)
			{
				val = ((Component)this).transform.forward;
			}
			return ((Vector3)(ref val)).normalized * knockbackHorizontalForce + Vector3.up * knockbackUpwardForce;
		}

		public override void OnCollideWithEnemy(Collider other, EnemyAI? collidedEnemy = null)
		{
			((EnemyAI)this).OnCollideWithEnemy(other, collidedEnemy);
			if (((NetworkBehaviour)this).IsOwner && !base.isEnemyDead && !((Object)(object)collidedEnemy == (Object)null) && CheckIfInNotAnimation())
			{
				EnemyAttack.TryAttack(collidedEnemy);
			}
		}

		public override void HitEnemy(int force = 1, PlayerControllerB? playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
		{
			((EnemyAI)this).HitEnemy(force, playerWhoHit, playHitSFX, hitID);
			if (base.isEnemyDead)
			{
				return;
			}
			base.enemyHP -= force;
			if (base.enemyHP <= 0)
			{
				if (((NetworkBehaviour)this).IsOwner)
				{
					((EnemyAI)this).KillEnemyOnOwnerClient(false);
				}
			}
			else
			{
				if (!((NetworkBehaviour)this).IsOwner || (Object)(object)playerWhoHit == (Object)null)
				{
					return;
				}
				int currentBehaviourStateIndex = base.currentBehaviourStateIndex;
				if (currentBehaviourStateIndex != 8 && currentBehaviourStateIndex != 7 && currentBehaviourStateIndex != 5)
				{
					base.targetPlayer = playerWhoHit;
					if (currentBehaviourStateIndex != 2)
					{
						Suspicion.SetMax();
						((EnemyAI)this).SwitchToBehaviourState(2);
					}
				}
			}
		}

		public override void KillEnemy(bool destroy = false)
		{
			LogIfDebugBuild("JPOGTrex: T-rex has been killed");
			((MonoBehaviour)this).StopAllCoroutines();
			Feeding.DropCarriedBodies();
			if (((NetworkBehaviour)this).IsOwner)
			{
				SetWalkingAnimationServerRpc(0f);
			}
			base.creatureAnimator.SetTrigger("killEnemy");
			base.creatureVoice.Stop();
			base.creatureSFX.Stop();
			((EnemyAI)this).KillEnemy(destroy);
		}

		private void SetWalkingAnimation(float currentSpeed)
		{
			if (currentSpeed != previousSpeed)
			{
				previousSpeed = currentSpeed;
				if (currentSpeed == 0f)
				{
					DoAnimationClientRpc("stopWalk");
				}
				else if (currentSpeed <= 2f)
				{
					DoAnimationClientRpc("slowDown");
				}
				else if (currentSpeed <= 6f)
				{
					DoAnimationClientRpc("startWalk");
				}
				else if (currentSpeed <= 12f)
				{
					DoAnimationClientRpc("chasingRun");
				}
				else
				{
					DoAnimationClientRpc("speedUp");
				}
			}
		}

		private void ShakeCamera()
		{
			//IL_0012: 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)
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			float num = Vector3.Distance(((Component)this).transform.position, ((Component)localPlayerController).transform.position);
			if (!(num > 40f))
			{
				if (num <= 5f)
				{
					HUDManager.Instance.ShakeCamera((ScreenShakeType)3);
				}
				else if (num <= 20f)
				{
					HUDManager.Instance.ShakeCamera((ScreenShakeType)1);
				}
				else
				{
					HUDManager.Instance.ShakeCamera((ScreenShakeType)0);
				}
			}
		}

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

		private void PlayFootStepAudioClip(AudioClip audioClip)
		{
			base.creatureSFX.PlayOneShot(audioClip);
			WalkieTalkie.TransmitOneShotAudio(base.creatureSFX, audioClip, 1f);
			ShakeCamera();
		}

		private void PlayTrexRoarAudioClipt(AudioClip audioClip)
		{
			trexRoarSFX.PlayOneShot(audioClip, 2f);
			WalkieTalkie.TransmitOneShotAudio(trexRoarSFX, audioClip, 1f);
		}

		private void PlayTrexSubRoarAudioClipt(AudioClip audioClip)
		{
			trexSubRoarSFX.PlayOneShot(audioClip, 1f);
			WalkieTalkie.TransmitOneShotAudio(trexSubRoarSFX, audioClip, 1f);
		}

		private IEnumerator FoundPlayer()
		{
			previousState = State.SpottedPlayer;
			LogIfDebugBuild("JPOGTrex: Sniffing");
			DoAnimationServerRpc("foundPlayer");
			yield return (object)new WaitForSeconds(1.3f);
			LogIfDebugBuild("JPOGTrex: Sniffing finished");
			sniffing = false;
		}

		private IEnumerator BeginChase(int animationNumber)
		{
			previousState = State.SpottedPlayer;
			LogIfDebugBuild($"JPOGTrex: Roaring [{animationNumber}]");
			DoAnimationServerRpc("beginChase0" + animationNumber);
			float waitTime = ((animationNumber == 3) ? 3.6f : 3.1f);
			yield return (object)new WaitForSeconds(waitTime);
			LogIfDebugBuild("JPOGTrex: Roaring finished");
			roaring = false;
		}

		protected override void __initializeVariables()
		{
			if (visionRangeLength == null)
			{
				throw new Exception("JPOGTrexAI.visionRangeLength cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)visionRangeLength).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)visionRangeLength, "visionRangeLength");
			((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)visionRangeLength);
			if (visionRangeWidth == null)
			{
				throw new Exception("JPOGTrexAI.visionRangeWidth cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)visionRangeWidth).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)visionRangeWidth, "visionRangeWidth");
			((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)visionRangeWidth);
			if (fearTargetId == null)
			{
				throw new Exception("JPOGTrexAI.fearTargetId cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)fearTargetId).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)fearTargetId, "fearTargetId");
			((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)fearTargetId);
			((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
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Expected O, but got Unknown
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Expected O, but got Unknown
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Expected O, but got Unknown
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Expected O, but got Unknown
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Expected O, but got Unknown
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Expected O, but got Unknown
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Expected O, but got Unknown
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Expected O, but got Unknown
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(3912369504u, new RpcReceiveHandler(__rpc_handler_3912369504), "IncreaseSuspicionServerRpc");
			((NetworkBehaviour)this).__registerRpc(4015576473u, new RpcReceiveHandler(__rpc_handler_4015576473), "IncreaseSuspicionClientRpc");
			((NetworkBehaviour)this).__registerRpc(2761139281u, new RpcReceiveHandler(__rpc_handler_2761139281), "EatPlayerServerRpc");
			((NetworkBehaviour)this).__registerRpc(1552663799u, new RpcReceiveHandler(__rpc_handler_1552663799), "EatPlayerClientRpc");
			((NetworkBehaviour)this).__registerRpc(1138974225u, new RpcReceiveHandler(__rpc_handler_1138974225), "ShakingBodiesServerRpc");
			((NetworkBehaviour)this).__registerRpc(1014053066u, new RpcReceiveHandler(__rpc_handler_1014053066), "ShakingBodiesClientRpc");
			((NetworkBehaviour)this).__registerRpc(1541272386u, new RpcReceiveHandler(__rpc_handler_1541272386), "DropcarriedBodyServerRpc");
			((NetworkBehaviour)this).__registerRpc(975871412u, new RpcReceiveHandler(__rpc_handler_975871412), "DropcarriedBodyClientRpc");
			((NetworkBehaviour)this).__registerRpc(2878721726u, new RpcReceiveHandler(__rpc_handler_2878721726), "SetWalkingAnimationServerRpc");
			((NetworkBehaviour)this).__registerRpc(2790222398u, new RpcReceiveHandler(__rpc_handler_2790222398), "DoAnimationServerRpc");
			((NetworkBehaviour)this).__registerRpc(2366721070u, new RpcReceiveHandler(__rpc_handler_2366721070), "DoAnimationClientRpc");
			((NetworkBehaviour)this).__registerRpc(2585592854u, new RpcReceiveHandler(__rpc_handler_2585592854), "StartGrabCheckServerRpc");
			((NetworkBehaviour)this).__registerRpc(142709209u, new RpcReceiveHandler(__rpc_handler_142709209), "StartGrabCheckClientRpc");
			((NetworkBehaviour)this).__registerRpc(813321880u, new RpcReceiveHandler(__rpc_handler_813321880), "StopGrabCheckServerRpc");
			((NetworkBehaviour)this).__registerRpc(179337775u, new RpcReceiveHandler(__rpc_handler_179337775), "StopGrabCheckClientRpc");
			((NetworkBehaviour)this).__registerRpc(448008859u, new RpcReceiveHandler(__rpc_handler_448008859), "SetHitConnectToTrueServerRpc");
			((NetworkBehaviour)this).__registerRpc(4090198766u, new RpcReceiveHandler(__rpc_handler_4090198766), "SetHitConnectToTrueClientRpc");
			((NetworkBehaviour)this).__registerRpc(961814835u, new RpcReceiveHandler(__rpc_handler_961814835), "KillPlayerServerRpc");
			((NetworkBehaviour)this).__registerRpc(3611163554u, new RpcReceiveHandler(__rpc_handler_3611163554), "KillPlayerClientRpc");
			((NetworkBehaviour)this).__registerRpc(402060824u, new RpcReceiveHandler(__rpc_handler_402060824), "CancelKillAnimationWithPlayerClientRpc");
			((EnemyAI)this).__initializeRpcs();
		}

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

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

		private static void __rpc_handler_2761139281(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;
				((JPOGTrexAI)(object)target).EatPlayerServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1552663799(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;
				((JPOGTrexAI)(object)target).EatPlayerClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1138974225(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;
				((JPOGTrexAI)(object)target).ShakingBodiesServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1014053066(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;
				((JPOGTrexAI)(object)target).ShakingBodiesClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1541272386(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;
				((JPOGTrexAI)(object)target).DropcarriedBodyServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_975871412(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;
				((JPOGTrexAI)(object)target).DropcarriedBodyClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

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

		private static void __rpc_handler_2790222398(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;
				((JPOGTrexAI)(object)target).DoAnimationServerRpc(animationName);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2366721070(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;
				((JPOGTrexAI)(object)target).DoAnimationClientRpc(animationName);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2585592854(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;
				((JPOGTrexAI)(object)target).StartGrabCheckServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_142709209(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;
				((JPOGTrexAI)(object)target).StartGrabCheckClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_813321880(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;
				((JPOGTrexAI)(object)target).StopGrabCheckServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_179337775(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;
				((JPOGTrexAI)(object)target).StopGrabCheckClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_448008859(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;
				((JPOGTrexAI)(object)target).SetHitConnectToTrueServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_4090198766(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;
				((JPOGTrexAI)(object)target).SetHitConnectToTrueClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

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

		private static void __rpc_handler_3611163554(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: 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)
			{
				int playerId = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerId);
				int deathAnimation = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref deathAnimation);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((JPOGTrexAI)(object)target).KillPlayerClientRpc(playerId, deathAnimation);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_402060824(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 playerObjectId = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerObjectId);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((JPOGTrexAI)(object)target).CancelKillAnimationWithPlayerClientRpc(playerObjectId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

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

		public static readonly NamespacedKey<DawnEnemyInfo> TrexKey = NamespacedKey<DawnEnemyInfo>.From("jpog_trex", "trex");

		internal static PluginConfig BoundConfig { get; private set; } = null;

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			BoundConfig = new PluginConfig(((BaseUnityPlugin)this).Config);
			Logger.LogInfo((object)"Plugin [JPOGTrex] is loaded!");
		}
	}
	internal class TrexChaseHelper
	{
		private readonly JPOGTrexAI trexAI;

		private readonly float sprintSpeedThreshold = 6f;

		private readonly float sprintChaseRatio = 0.9f;

		private readonly float brakingStrength = 0.8f;

		private readonly float minChaseSpeed = 3f;

		private readonly float maxLeadTime = 0.4f;

		private readonly float leadFalloffDistance = 10f;

		private readonly float velocitySampleInterval = 0.2f;

		private readonly float destinationUpdateDistance = 0.5f;

		private readonly float pathUpdateInterval = 0.1f;

		private readonly float navMeshSnapRadius = 3f;

		private float maxChaseSpeed = 12f;

		private PlayerControllerB? trackedPlayer;

		private Vector3 lastSamplePosition;

		private float lastSampleTime;

		private Vector3 lastRequestedDestination;

		private float lastPathRequestTime = -100f;

		private float lastDebugLogTime;

		public Vector3 TargetVelocity { get; private set; }

		public TrexChaseHelper(JPOGTrexAI trexAI)
		{
			this.trexAI = trexAI;
		}

		public void Configure(float maxChaseSpeed)
		{
			this.maxChaseSpeed = maxChaseSpeed;
		}

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

		public void Reset()
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			trackedPlayer = null;
			TargetVelocity = Vector3.zero;
			lastPathRequestTime = -100f;
		}

		public void Tick()
		{
			//IL_0055: 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)
			//IL_00bf: 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_0113: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB targetPlayer = ((EnemyAI)trexAI).targetPlayer;
			if (!((Object)(object)targetPlayer == (Object)null) && !targetPlayer.isPlayerDead)
			{
				SampleTargetVelocity(targetPlayer);
				float mouthGap = GetMouthGap(targetPlayer);
				((EnemyAI)trexAI).agent.speed = GetChaseSpeed(mouthGap);
				MoveTowards(GetLeadPosition(targetPlayer, mouthGap));
				if (Time.time - lastDebugLogTime >= 1f)
				{
					lastDebugLogTime = Time.time;
					object[] obj = new object[6]
					{
						((EnemyAI)trexAI).agent.speed,
						null,
						null,
						null,
						null,
						null
					};
					Vector3 val = ((EnemyAI)trexAI).agent.velocity;
					obj[1] = ((Vector3)(ref val)).magnitude;
					val = TargetVelocity;
					obj[2] = ((Vector3)(ref val)).magnitude;
					obj[3] = mouthGap;
					obj[4] = ((EnemyAI)trexAI).agent.pathPending;
					obj[5] = ((EnemyAI)trexAI).agent.pathStatus;
					LogIfDebugBuild(string.Format("JPOGTrex: Chase || speed = [{0:0.0}] actual = [{1:0.0}] targetSpeed = [{2:0.0}] gap = [{3:0.0}] pathPending = [{4}] pathStatus = [{5}]", obj));
				}
			}
		}

		private float GetMouthGap(PlayerControllerB target)
		{
			//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_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: 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)
			trexAI.Grab.GetMouthSphere(out var center, out var radius);
			Vector3 val = ((Component)target).transform.position - center;
			val.y = 0f;
			Vector3 forward = ((Component)trexAI).transform.forward;
			forward.y = 0f;
			if (Vector3.Dot(forward, val) < 0f)
			{
				return 0f;
			}
			return Mathf.Max(0f, ((Vector3)(ref val)).magnitude - radius);
		}

		private float GetChaseSpeed(float gap)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			Vector3 targetVelocity = TargetVelocity;
			float magnitude = ((Vector3)(ref targetVelocity)).magnitude;
			float num = ((magnitude >= sprintSpeedThreshold) ? Mathf.Min(maxChaseSpeed, magnitude * sprintChaseRatio) : maxChaseSpeed);
			float num2 = Mathf.Sqrt(2f * ((EnemyAI)trexAI).agent.acceleration * brakingStrength * gap);
			float num3 = magnitude + num2;
			return Mathf.Clamp(num3, Mathf.Min(minChaseSpeed, num), num);
		}

		private Vector3 GetLeadPosition(PlayerControllerB target, float gap)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0035: Unknown result type (might be due to invalid IL or missing references)
			float num = maxLeadTime * Mathf.Clamp01(gap / leadFalloffDistance);
			return ((Component)target).transform.position + TargetVelocity * num;
		}

		private void MoveTowards(Vector3 position)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: 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_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: 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_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			NavMeshHit val = default(NavMeshHit);
			if (NavMesh.SamplePosition(position, ref val, navMeshSnapRadius, ((EnemyAI)trexAI).agent.areaMask))
			{
				position = ((NavMeshHit)(ref val)).position;
			}
			((EnemyAI)trexAI).destination = position;
			((EnemyAI)trexAI).moveTowardsDestination = true;
			bool flag = Vector3.Distance(position, lastRequestedDestination) >= destinationUpdateDistance;
			if (!((EnemyAI)trexAI).agent.hasPath || (flag && !(Time.time - lastPathRequestTime < pathUpdateInterval)))
			{
				lastRequestedDestination = position;
				lastPathRequestTime = Time.time;
				((EnemyAI)trexAI).agent.SetDestination(position);
			}
		}

		private void SampleTargetVelocity(PlayerControllerB target)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0086: 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_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = ((Component)target).transform.position;
			if ((Object)(object)target != (Object)(object)trackedPlayer)
			{
				trackedPlayer = target;
				lastSamplePosition = position;
				lastSampleTime = Time.time;
				TargetVelocity = Vector3.zero;
				return;
			}
			float num = Time.time - lastSampleTime;
			if (!(num < velocitySampleInterval))
			{
				Vector3 val = position - lastSamplePosition;
				val.y = 0f;
				TargetVelocity = Vector3.Lerp(TargetVelocity, val / num, 0.5f);
				lastSamplePosition = position;
				lastSampleTime = Time.time;
			}
		}
	}
	internal class TrexEnemyAttackHelper
	{
		private readonly JPOGTrexAI trexAI;

		private readonly float attackDelay = 1.2f;

		private EnemyAI? targetEntity;

		public bool IsAttacking { get; private set; }

		public TrexEnemyAttackHelper(JPOGTrexAI trexAI)
		{
			this.trexAI = trexAI;
		}

		public void TryAttack(EnemyAI collidedEnemy)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Invalid comparison between Unknown and I4
			if (!collidedEnemy.isEnemyDead)
			{
				targetEntity = collidedEnemy;
				trexAI.turnCompass.LookAt(((Component)targetEntity).transform.position);
				if ((int)collidedEnemy.enemyType.SizeLimit == 1)
				{
					((MonoBehaviour)trexAI).StartCoroutine(AttackEnemy("attackEnemyHigh", 10));
				}
				else
				{
					((MonoBehaviour)trexAI).StartCoroutine(AttackEnemy("attackEnemyLow", 15));
				}
			}
		}

		private IEnumerator AttackEnemy(string animationName, int damage)
		{
			IsAttacking = true;
			trexAI.DoAnimationServerRpc(animationName);
			yield return (object)new WaitForSeconds(attackDelay);
			if ((Object)(object)targetEntity != (Object)null && !targetEntity.isEnemyDead)
			{
				targetEntity.HitEnemyOnLocalClient(damage, default(Vector3), (PlayerControllerB)null, true, -1);
			}
			IsAttacking = false;
		}
	}
	internal class TrexFeedingHelper
	{
		private readonly JPOGTrexAI trexAI;

		private readonly List<DeadBodyInfo> carryingBodies = new List<DeadBodyInfo>();

		private readonly HashSet<DeadBodyInfo> inedibleBodies = new HashSet<DeadBodyInfo>();

		private readonly int maxPlayersToEat = 2;

		private readonly float shakeDuration = 2.6f;

		private readonly float eatDuration = 5.7f;

		private Coroutine? shakeCoroutine;

		private Coroutine? eatCoroutine;

		private bool doneEating;

		public bool IsShaking { get; private set; }

		public bool IsEating { get; private set; }

		public bool IsHungry { get; private set; } = true;

		public int PlayersEaten { get; private set; }

		public bool HasBodyInMouth => carryingBodies.Exists(IsStillInMouth);

		public bool HasEdibleBodyInMouth => carryingBodies.Exists((DeadBodyInfo body) => IsStillInMouth(body) && !inedibleBodies.Contains(body));

		public TrexFeedingHelper(JPOGTrexAI trexAI)
		{
			this.trexAI = trexAI;
		}

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

		public bool ConsumeDoneEating()
		{
			if (!doneEating)
			{
				return false;
			}
			doneEating = false;
			return true;
		}

		public void BeginShakeLocal()
		{
			IsShaking = true;
		}

		public void BeginEatingLocal()
		{
			IsEating = true;
		}

		public void StartShake()
		{
			IsShaking = true;
			if (shakeCoroutine != null)
			{
				((MonoBehaviour)trexAI).StopCoroutine(shakeCoroutine);
			}
			shakeCoroutine = ((MonoBehaviour)trexAI).StartCoroutine(ShakeGrabbedBody());
		}

		public void StartEating()
		{
			LogIfDebugBuild("JPOGTrex: beginning to eat player(s)");
			IsEating = true;
			if (eatCoroutine != null)
			{
				((MonoBehaviour)trexAI).StopCoroutine(eatCoroutine);
			}
			eatCoroutine = ((MonoBehaviour)trexAI).StartCoroutine(EatPlayerCoroutine());
		}

		public void TakeBodyInMouth(int playerId, bool canBeEaten)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			LogIfDebugBuild($"JPOGTrex: Taking boddy of player [{playerId}] in mouth");
			DeadBodyInfo deadBody = StartOfRound.Instance.allPlayerScripts[playerId].deadBody;
			if (!((Object)(object)deadBody == (Object)null))
			{
				LogIfDebugBuild($"JPOGTrex: deadbody of player cause of death: [{deadBody.causeOfDeath}]");
				deadBody.attachedTo = trexAI.mouthGrip;
				deadBody.attachedLimb = deadBody.bodyParts[5];
				deadBody.matchPositionExactly = true;
				deadBody.MakeCorpseBloody();
				SetHeldByEnemy(deadBody, heldByEnemy: true);
				carryingBodies.Add(deadBody);
				if (!canBeEaten)
				{
					inedibleBodies.Add(deadBody);
				}
				LogIfDebugBuild($"JPOGTrex: carryingBodies count = [{carryingBodies.Count}] || canBeEaten = [{canBeEaten}]");
			}
		}

		public void DropCarriedBodies()
		{
			LogIfDebugBuild($"JPOGTrex: Dropping [{carryingBodies.Count}] bodies from mouth");
			foreach (DeadBodyInfo carryingBody in carryingBodies)
			{
				if ((Object)(object)carryingBody != (Object)null)
				{
					SetHeldByEnemy(carryingBody, heldByEnemy: false);
				}
				if (IsStillInMouth(carryingBody))
				{
					carryingBody.speedMultiplier = 12f;
					carryingBody.attachedTo = null;
					carryingBody.attachedLimb = null;
					carryingBody.matchPositionExactly = false;
				}
			}
			carryingBodies.Clear();
			inedibleBodies.Clear();
		}

		private bool IsStillInMouth([NotNullWhen(true)] DeadBodyInfo? body)
		{
			return (Object)(object)body != (Object)null && !body.deactivated && (Object)(object)body.attachedTo == (Object)(object)trexAI.mouthGrip;
		}

		private void SetHeldByEnemy(DeadBodyInfo body, bool heldByEnemy)
		{
			if ((Object)(object)body.grabBodyObject != (Object)null)
			{
				body.grabBodyObject.isHeldByEnemy = heldByEnemy;
			}
		}

		private IEnumerator ShakeGrabbedBody()
		{
			((EnemyAI)trexAI).creatureAnimator.SetTrigger("grabbingPlayer");
			yield return (object)new WaitForSeconds(shakeDuration);
			IsShaking = false;
			shakeCoroutine = null;
		}

		private IEnumerator EatPlayerCoroutine()
		{
			((EnemyAI)trexAI).creatureAnimator.SetTrigger("eatingPlayer");
			yield return (object)new WaitForSeconds(eatDuration);
			IsEating = false;
			foreach (DeadBodyInfo carryingBody in carryingBodies)
			{
				if (IsStillInMouth(carryingBody) && !inedibleBodies.Contains(carryingBody))
				{
					LogIfDebugBuild($"JPOGTrex: Deactivating body = [{carryingBody.playerObjectId}]");
					SetHeldByEnemy(carryingBody, heldByEnemy: false);
					carryingBody.DeactivateBody(false);
					PlayersEaten++;
				}
			}
			DropCarriedBodies();
			IsHungry = PlayersEaten < maxPlayersToEat;
			doneEating = true;
			eatCoroutine = null;
		}
	}
	internal class TrexGrabHelper
	{
		private readonly JPOGTrexAI trexAI;

		private readonly List<int> hitPlayerIds = new List<int>();

		private readonly float grabDuration = 1.2f;

		private const int NormalDeathAnimation = 0;

		private const int HeadBurstDeathAnimation = 1;

		private const int SlicedInHalfDeathAnimation = 7;

		private readonly double slicedInHalfChance = 0.15;

		private readonly double headBurstChance = 0.05;

		private readonly float grabCooldown = 4f;

		private readonly HashSet<int> playersBeingKilled = new HashSet<int>();

		private const int PlayerLayer = 8;

		public const float MouthBiteRadius = 1.5f;

		private Coroutine? grabCheckCoroutine;

		private int activeKills;

		private bool hitConnect;

		private float lastHitTime = -100f;

		public bool BeginningGrab { get; private set; }

		public bool InGrabAttack { get; private set; }

		public bool InKillAnimation => activeKills > 0;

		public bool IsBusy => BeginningGrab || InGrabAttack || InKillAnimation;

		public bool CanGrab => Time.time - lastHitTime >= grabCooldown;

		public int ConsecutiveMisses { get; private set; }

		public TrexGrabHelper(JPOGTrexAI trexAI)
		{
			this.trexAI = trexAI;
		}

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

		public void StartGrab()
		{
			BeginningGrab = true;
			((MonoBehaviour)trexAI).StartCoroutine(BeginGrab());
		}

		public bool ConsumeHitConnect()
		{
			if (!hitConnect)
			{
				return false;
			}
			hitConnect = false;
			return true;
		}

		public void OnHitConnected()
		{
			hitConnect = true;
			lastHitTime = Time.time;
			ConsecutiveMisses = 0;
			LogIfDebugBuild($"JPOGTrex: hitConnect = [{hitConnect}]");
		}

		public void RegisterMiss()
		{
			ConsecutiveMisses++;
			LogIfDebugBuild($"JPOGTrex: Missed bites in a row = [{ConsecutiveMisses}]");
		}

		public void ResetMisses()
		{
			ConsecutiveMisses = 0;
		}

		public void OnStartGrabCheck()
		{
			hitPlayerIds.Clear();
			InGrabAttack = true;
			if (grabCheckCoroutine != null)
			{
				((MonoBehaviour)trexAI).StopCoroutine(grabCheckCoroutine);
			}
			grabCheckCoroutine = ((MonoBehaviour)trexAI).StartCoroutine(CheckIfGrabHitDuringAnimation());
		}

		public void OnStopGrabCheck()
		{
			LogIfDebugBuild("JPOGTrex: Stopping grab check Coroutine");
			InGrabAttack = false;
			if (grabCheckCoroutine != null)
			{
				((MonoBehaviour)trexAI).StopCoroutine(grabCheckCoroutine);
				grabCheckCoroutine = null;
			}
		}

		public bool TryBeginKill(int playerId)
		{
			bool flag = playersBeingKilled.Add(playerId);
			LogIfDebugBuild($"JPOGTrex: Trying to kill player [{playerId}] || canKill = [{flag}]");
			return flag;
		}

		public int ChooseDeathAnimation()
		{
			double num = trexAI.EnemyRandom.NextDouble();
			if (num < slicedInHalfChance)
			{
				return 7;
			}
			if (num < slicedInHalfChance + headBurstChance)
			{
				return 1;
			}
			return 0;
		}

		public void StartKill(int playerId, int deathAnimation)
		{
			LogIfDebugBuild($"JPOGTrex: s