Decompiled source of SkibidiJester v1.0.0

Assembly-CSharp.dll

Decompiled 7 months ago
using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using DigitalRuby.ThunderAndLightning;
using Discord;
using Dissonance;
using Dissonance.Audio.Playback;
using Dissonance.Datastructures;
using Dissonance.Extensions;
using Dissonance.Integrations.Unity_NFGO;
using Dissonance.Networking;
using DunGen;
using DunGen.Analysis;
using DunGen.Graph;
using DunGen.Tags;
using GameNetcodeStuff;
using JetBrains.Annotations;
using Netcode.Transports.Facepunch;
using Steamworks;
using Steamworks.Data;
using Steamworks.ServerList;
using TMPro;
using Unity.AI.Navigation;
using Unity.Collections;
using Unity.Netcode;
using Unity.Netcode.Components;
using Unity.Netcode.Samples;
using Unity.Netcode.Transports.UTP;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Animations.Rigging;
using UnityEngine.Audio;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.InputSystem.Utilities;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
using UnityEngine.SceneManagement;
using UnityEngine.Serialization;
using UnityEngine.Tilemaps;
using UnityEngine.UI;
using UnityEngine.VFX;
using UnityEngine.Video;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyVersion("0.0.0.0")]
public class ActivateObjectAfterSceneLoad : MonoBehaviour
{
	private GameObject activateObject;

	private void Start()
	{
	}

	private IEnumerator waitForNavMeshBake()
	{
		yield return (object)new WaitUntil((Func<bool>)(() => RoundManager.Instance.bakedNavMesh));
		activateObject.SetActive(true);
	}

	public void SetInitialState()
	{
	}
}
public class AlarmButton : MonoBehaviour
{
	private Animator buttonAnimator;

	public float timeSincePushing;

	public void PushAlarmButton()
	{
		if (!(timeSincePushing < 1f))
		{
			buttonAnimator.SetTrigger("press");
			HUDManager.Instance.TriggerAlarmHornEffect();
		}
	}

	private void Update()
	{
		if (timeSincePushing <= 5f)
		{
			timeSincePushing += Time.deltaTime;
		}
	}
}
public class AnimatedItem : GrabbableObject
{
	public string grabItemBoolString;

	public string dropItemTriggerString;

	public bool makeAnimationWhenDropping;

	public Animator itemAnimator;

	public AudioSource itemAudio;

	public AudioClip grabAudio;

	public AudioClip dropAudio;

	public bool loopGrabAudio;

	public bool loopDropAudio;

	[Range(0f, 100f)]
	public int chanceToTriggerAnimation = 100;

	public int chanceToTriggerAlternateMesh;

	public Mesh alternateMesh;

	private Mesh normalMesh;

	private Random itemRandomChance;

	public float noiseRange;

	public float noiseLoudness;

	private int timesPlayedInOneSpot;

	private float makeNoiseInterval;

	private Vector3 lastPosition;

	public AudioLowPassFilter itemAudioLowPassFilter;

	private bool wasInPocket;

	public override void Start()
	{
		base.Start();
		itemRandomChance = new Random(StartOfRound.Instance.randomMapSeed + StartOfRound.Instance.currentLevelID + itemProperties.itemId);
		if (chanceToTriggerAlternateMesh > 0)
		{
			normalMesh = ((Component)this).gameObject.GetComponent<MeshFilter>().mesh;
		}
	}

	public override void EquipItem()
	{
		base.EquipItem();
		if ((Object)(object)itemAudioLowPassFilter != (Object)null)
		{
			itemAudioLowPassFilter.cutoffFrequency = 20000f;
		}
		itemAudio.volume = 1f;
		if (chanceToTriggerAlternateMesh > 0)
		{
			if (itemRandomChance.Next(0, 100) < chanceToTriggerAlternateMesh)
			{
				((Component)this).gameObject.GetComponent<MeshFilter>().mesh = alternateMesh;
				itemAudio.Stop();
				return;
			}
			((Component)this).gameObject.GetComponent<MeshFilter>().mesh = normalMesh;
		}
		if (!wasInPocket)
		{
			if (itemRandomChance.Next(0, 100) > chanceToTriggerAnimation)
			{
				itemAudio.Stop();
				return;
			}
		}
		else
		{
			wasInPocket = false;
		}
		if ((Object)(object)itemAnimator != (Object)null)
		{
			itemAnimator.SetBool(grabItemBoolString, true);
		}
		if ((Object)(object)itemAudio != (Object)null)
		{
			itemAudio.clip = grabAudio;
			itemAudio.loop = loopGrabAudio;
			itemAudio.Play();
		}
	}

	public override void DiscardItem()
	{
		base.DiscardItem();
		if ((Object)(object)itemAnimator != (Object)null)
		{
			itemAnimator.SetBool(grabItemBoolString, false);
		}
		if (chanceToTriggerAlternateMesh > 0)
		{
			((Component)this).gameObject.GetComponent<MeshFilter>().mesh = normalMesh;
		}
		if (!makeAnimationWhenDropping)
		{
			itemAudio.Stop();
			return;
		}
		if (itemRandomChance.Next(0, 100) < chanceToTriggerAnimation)
		{
			itemAudio.Stop();
			return;
		}
		if ((Object)(object)itemAnimator != (Object)null)
		{
			itemAnimator.SetTrigger(dropItemTriggerString);
		}
		if ((Object)(object)itemAudio != (Object)null)
		{
			itemAudio.loop = loopDropAudio;
			itemAudio.clip = dropAudio;
			itemAudio.Play();
			if ((Object)(object)itemAudioLowPassFilter != (Object)null)
			{
				itemAudioLowPassFilter.cutoffFrequency = 20000f;
			}
			itemAudio.volume = 1f;
		}
	}

	public override void PocketItem()
	{
		base.PocketItem();
		wasInPocket = true;
		if ((Object)(object)itemAudio != (Object)null)
		{
			if ((Object)(object)itemAudioLowPassFilter != (Object)null)
			{
				itemAudioLowPassFilter.cutoffFrequency = 1700f;
			}
			itemAudio.volume = 0.5f;
		}
	}

	public override void Update()
	{
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		base.Update();
		if ((Object)(object)itemAudio == (Object)null || !itemAudio.isPlaying)
		{
			return;
		}
		if (makeNoiseInterval <= 0f)
		{
			makeNoiseInterval = 0.75f;
			if (Vector3.Distance(lastPosition, ((Component)this).transform.position) < 4f)
			{
				timesPlayedInOneSpot++;
			}
			else
			{
				timesPlayedInOneSpot = 0;
			}
			if (isPocketed)
			{
				RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, noiseRange / 2f, noiseLoudness / 2f, timesPlayedInOneSpot, isInElevator && StartOfRound.Instance.hangarDoorsClosed);
			}
			else
			{
				RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, noiseRange, noiseLoudness, timesPlayedInOneSpot, isInElevator && StartOfRound.Instance.hangarDoorsClosed);
			}
		}
		else
		{
			makeNoiseInterval -= Time.deltaTime;
		}
	}

	protected override void __initializeVariables()
	{
		base.__initializeVariables();
	}

	protected internal override string __getTypeName()
	{
		return "AnimatedItem";
	}
}
public class AnimatedObjectFloatSetter : MonoBehaviour
{
	public AnimatedObjectTrigger animatedObjectTrigger;

	public string animatorFloatName;

	private float animatorFloatValue = 1f;

	public float valueChangeSpeed;

	public GameObject[] conditionalObjects;

	private int currentFifth = -1;

	private bool boolWasTrue;

	private bool completed;

	public AudioSource thisAudio;

	public AudioClip trueAudio;

	public AudioClip falseAudio;

	public AudioClip completionTrueAudio;

	public AudioClip completionFalseAudio;

	public Transform killPlayerPoint;

	public bool ignoreVerticalDistance = true;

	public float killRange;

	private bool deactivated = true;

	private void KillPlayerAtPoint()
	{
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)killPlayerPoint == (Object)null) && !GameNetworkManager.Instance.localPlayerController.isPlayerDead)
		{
			Vector3 position = killPlayerPoint.position;
			if (ignoreVerticalDistance)
			{
				position.y = ((Component)GameNetworkManager.Instance.localPlayerController).transform.position.y;
			}
			if (Vector3.Distance(((Component)GameNetworkManager.Instance.localPlayerController).transform.position, position) < killRange)
			{
				GameNetworkManager.Instance.localPlayerController.KillPlayer(Vector3.zero, spawnBody: true, CauseOfDeath.Crushing);
			}
		}
	}

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

	private IEnumerator waitForNavMeshBake()
	{
		yield return (object)new WaitUntil((Func<bool>)(() => RoundManager.Instance.bakedNavMesh));
		yield return (object)new WaitForSeconds(2f);
		deactivated = false;
	}

	private void Update()
	{
		if (deactivated || !animatedObjectTrigger.isBool)
		{
			return;
		}
		if (animatedObjectTrigger.boolValue)
		{
			if (!boolWasTrue)
			{
				boolWasTrue = true;
				thisAudio.clip = trueAudio;
				thisAudio.Play();
			}
			animatorFloatValue = Mathf.Min(animatorFloatValue + valueChangeSpeed * Time.deltaTime, 1f);
			if (animatorFloatValue == 1f && !completed)
			{
				completed = true;
				thisAudio.Stop();
				thisAudio.PlayOneShot(completionTrueAudio);
			}
		}
		else
		{
			if (boolWasTrue)
			{
				boolWasTrue = false;
				thisAudio.clip = falseAudio;
				thisAudio.Play();
			}
			animatorFloatValue = Mathf.Max(animatorFloatValue - valueChangeSpeed * Time.deltaTime, 0f);
			if (animatorFloatValue == 0f && completed)
			{
				completed = false;
				thisAudio.Stop();
				thisAudio.PlayOneShot(completionFalseAudio);
				KillPlayerAtPoint();
			}
		}
		animatedObjectTrigger.triggerAnimator.SetFloat(animatorFloatName, animatorFloatValue);
		if (conditionalObjects.Length >= 5 && RoundManager.Instance.bakedNavMesh)
		{
			SetObjectBasedOnAnimatorFloat();
		}
	}

	public void SetObjectBasedOnAnimatorFloat()
	{
		int num = -1;
		num = ((!(animatorFloatValue < 0.125f)) ? ((animatorFloatValue < 0.375f) ? 1 : ((animatorFloatValue < 0.625f) ? 2 : ((!(animatorFloatValue < 0.875f)) ? 4 : 3))) : 0);
		if (num != currentFifth)
		{
			conditionalObjects[num].SetActive(true);
			if (currentFifth != -1)
			{
				conditionalObjects[currentFifth].SetActive(false);
			}
			currentFifth = num;
		}
	}
}
public class AnimatedTextureUV : MonoBehaviour
{
	private Material[] setMaterials;

	public MeshRenderer meshRenderer;

	public SkinnedMeshRenderer skinnedMeshRenderer;

	public int materialIndex;

	public int columns = 1;

	public int rows = 1;

	public float waitFrameTime = 0.005f;

	private float horizontalOffset;

	private float verticalOffset;

	private Coroutine animateMaterial;

	private bool skinnedMesh;

	private void OnEnable()
	{
		if (animateMaterial == null)
		{
			Debug.Log((object)"Animating material now");
			animateMaterial = ((MonoBehaviour)this).StartCoroutine(AnimateUV());
		}
	}

	private void OnDisable()
	{
		if (animateMaterial != null)
		{
			((MonoBehaviour)this).StopCoroutine(animateMaterial);
		}
	}

	private IEnumerator AnimateUV()
	{
		yield return null;
		if ((Object)(object)skinnedMeshRenderer != (Object)null)
		{
			setMaterials = ((Renderer)skinnedMeshRenderer).materials;
			skinnedMesh = true;
		}
		else
		{
			setMaterials = ((Renderer)meshRenderer).materials;
		}
		float maxVertical = 1f - 1f / (float)columns;
		float maxHorizontal = 1f - 1f / (float)rows;
		while (((Behaviour)this).enabled)
		{
			yield return (object)new WaitForSeconds(waitFrameTime);
			horizontalOffset += 1f / (float)rows;
			if (horizontalOffset > maxHorizontal)
			{
				horizontalOffset = 0f;
				verticalOffset += 1f / (float)columns;
				if (verticalOffset > maxVertical)
				{
					verticalOffset = 0f;
				}
			}
			setMaterials[materialIndex].SetTextureOffset("_BaseColorMap", new Vector2(horizontalOffset, verticalOffset));
			if (skinnedMesh)
			{
				((Renderer)skinnedMeshRenderer).materials = setMaterials;
			}
			else
			{
				((Renderer)skinnedMeshRenderer).materials = setMaterials;
			}
		}
	}
}
public class AnimationStopPoints : MonoBehaviour
{
	public bool canAnimationStop;

	public int animationPosition = 1;

	public void SetAnimationStopPosition1()
	{
		canAnimationStop = true;
		animationPosition = 1;
	}

	public void SetAnimationGo()
	{
		canAnimationStop = false;
	}

	public void SetAnimationStopPosition2()
	{
		canAnimationStop = true;
		animationPosition = 2;
	}
}
public class AudioReverbPresets : MonoBehaviour
{
	public AudioReverbTrigger[] audioPresets;
}
public class AutoParentToShip : NetworkBehaviour
{
	public bool disableObject;

	public Vector3 positionOffset;

	public Vector3 rotationOffset;

	[HideInInspector]
	public Vector3 startingPosition;

	[HideInInspector]
	public Vector3 startingRotation;

	public bool overrideOffset;

	private void Awake()
	{
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: 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)
		if (!overrideOffset)
		{
			positionOffset = StartOfRound.Instance.elevatorTransform.InverseTransformPoint(((Component)this).transform.position);
			rotationOffset = StartOfRound.Instance.elevatorTransform.InverseTransformDirection(((Component)this).transform.eulerAngles);
		}
		MoveToOffset();
		PlaceableShipObject component = ((Component)this).gameObject.GetComponent<PlaceableShipObject>();
		if ((Object)(object)component != (Object)null && (Object)(object)component.parentObjectSecondary != (Object)null)
		{
			startingPosition = component.parentObjectSecondary.position;
			startingRotation = component.parentObjectSecondary.eulerAngles;
		}
		else
		{
			startingPosition = positionOffset;
			startingRotation = rotationOffset;
		}
	}

	private void LateUpdate()
	{
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		if (!StartOfRound.Instance.suckingFurnitureOutOfShip)
		{
			if (disableObject)
			{
				((Component)this).transform.position = new Vector3(800f, -100f, 0f);
			}
			else
			{
				MoveToOffset();
			}
		}
	}

	public void StartSuckingOutOfShip()
	{
		((MonoBehaviour)this).StartCoroutine(SuckObjectOutOfShip());
	}

	private IEnumerator SuckObjectOutOfShip()
	{
		Vector3 dir = Vector3.Normalize((StartOfRound.Instance.middleOfSpaceNode.position - ((Component)this).transform.position) * 10000f);
		Debug.Log((object)dir);
		Quaternion randomRotation = Random.rotation;
		while (StartOfRound.Instance.suckingFurnitureOutOfShip)
		{
			yield return null;
			((Component)this).transform.position = ((Component)this).transform.position + dir * (Time.deltaTime * Mathf.Clamp(StartOfRound.Instance.suckingPower, 1.1f, 100f) * 17f);
			((Component)this).transform.rotation = Quaternion.Lerp(((Component)this).transform.rotation, ((Component)this).transform.rotation * randomRotation, Time.deltaTime * StartOfRound.Instance.suckingPower);
			Debug.DrawRay(((Component)this).transform.position + Vector3.up * 0.2f, StartOfRound.Instance.middleOfSpaceNode.position - ((Component)this).transform.position, Color.blue);
			Debug.DrawRay(((Component)this).transform.position, dir, Color.green);
		}
	}

	public void MoveToOffset()
	{
		//IL_0010: 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_003b: 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_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_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		((Component)this).transform.rotation = StartOfRound.Instance.elevatorTransform.rotation;
		((Component)this).transform.Rotate(rotationOffset);
		((Component)this).transform.position = StartOfRound.Instance.elevatorTransform.position;
		Vector3 val = positionOffset;
		val = StartOfRound.Instance.elevatorTransform.rotation * val;
		Transform transform = ((Component)this).transform;
		transform.position += val;
	}

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

	protected internal override string __getTypeName()
	{
		return "AutoParentToShip";
	}
}
public class BaboonBirdAI : EnemyAI, IVisibleThreat
{
	public Dictionary<Transform, Threat> threats = new Dictionary<Transform, Threat>();

	public Transform focusedThreatTransform;

	public Threat focusedThreat;

	public bool focusingOnThreat;

	public bool focusedThreatIsInView;

	private int focusLevel;

	private float fearLevel;

	private float fearLevelNoDistComparison;

	private Vector3 agentLocalVelocity;

	private float velX;

	private float velZ;

	private Vector3 previousPosition;

	public Transform animationContainer;

	public MultiAimConstraint headLookRig;

	public Transform headLookTarget;

	private Ray lookRay;

	public float fov;

	public float visionDistance;

	private int visibleThreatsMask = 524296;

	private int scrapMask = 64;

	private int leadershipLevel;

	private int previousBehaviourState = -1;

	public BaboonHawkGroup scoutingGroup;

	private float miscAnimationTimer;

	private int currentMiscAnimation;

	private Vector3 lookTarget;

	private Vector3 peekTarget;

	private float peekTimer;

	public AISearchRoutine scoutingSearchRoutine;

	public static Vector3 baboonCampPosition;

	public float scoutTimer;

	public float timeToScout;

	private float timeSinceRestWhileScouting;

	private float restingDuringScouting;

	private bool eyesClosed;

	private bool restingAtCamp;

	private float restAtCampTimer;

	private float chosenDistanceToCamp = 1f;

	private float timeSincePingingBirdInterest;

	private float timeSinceLastMiscAnimation;

	private int aggressiveMode;

	private int previousAggressiveMode;

	private float fightTimer;

	public AudioSource aggressionAudio;

	private Vector3 debugSphere;

	public Collider ownCollider;

	private float timeSinceAggressiveDisplay;

	private float timeSpentFocusingOnThreat;

	private float timeSinceFighting;

	private bool doingKillAnimation;

	private Coroutine killAnimCoroutine;

	private float timeSinceHitting;

	public Transform deadBodyPoint;

	public AudioClip[] cawScreamSFX;

	public AudioClip[] cawLaughSFX;

	private float noiseTimer;

	private float noiseInterval;

	public GrabbableObject focusedScrap;

	public GrabbableObject heldScrap;

	public bool movingToScrap;

	public Transform grabTarget;

	public TwoBoneIKConstraint leftArmRig;

	public TwoBoneIKConstraint rightArmRig;

	private bool oddAIInterval;

	private DeadBodyInfo killAnimationBody;

	private float timeSinceBeingAttackedByPlayer;

	private float timeSinceJoiningOrLeavingScoutingGroup;

	private BaboonBirdAI biggestBaboon;

	ThreatType IVisibleThreat.type => ThreatType.BaboonHawk;

	int IVisibleThreat.SendSpecialBehaviour(int id)
	{
		return 0;
	}

	int IVisibleThreat.GetThreatLevel(Vector3 seenByPosition)
	{
		int num = 0;
		num = 1;
		if (aggressiveMode == 2)
		{
			num++;
		}
		if (scoutingGroup != null && !scoutingGroup.isEmpty)
		{
			num++;
		}
		return num;
	}

	int IVisibleThreat.GetInterestLevel()
	{
		return 0;
	}

	Transform IVisibleThreat.GetThreatLookTransform()
	{
		return eye;
	}

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

	Vector3 IVisibleThreat.GetThreatVelocity()
	{
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		if (((NetworkBehaviour)this).IsOwner)
		{
			return agent.velocity;
		}
		return Vector3.zero;
	}

	float IVisibleThreat.GetVisibility()
	{
		if (isEnemyDead)
		{
			return 0f;
		}
		if (restingAtCamp)
		{
			return 0.6f;
		}
		return 1f;
	}

	public override void Start()
	{
		//IL_003a: 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_01a7: 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_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_010c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0180: Unknown result type (might be due to invalid IL or missing references)
		//IL_018f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0196: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0155: Unknown result type (might be due to invalid IL or missing references)
		//IL_015a: Unknown result type (might be due to invalid IL or missing references)
		base.Start();
		if (!((NetworkBehaviour)this).IsOwner)
		{
			return;
		}
		Random random = new Random(StartOfRound.Instance.randomMapSeed + thisEnemyIndex);
		leadershipLevel = random.Next(0, 500);
		if (baboonCampPosition == Vector3.zero)
		{
			EnemyAINestSpawnObject[] array = Object.FindObjectsByType<EnemyAINestSpawnObject>((FindObjectsInactive)0, (FindObjectsSortMode)0);
			bool flag = false;
			for (int i = 0; i < array.Length; i++)
			{
				if (!((Object)(object)array[i].enemyType != (Object)(object)enemyType))
				{
					baboonCampPosition = RoundManager.Instance.GetNavMeshPosition(((Component)array[i]).transform.position, default(NavMeshHit), 8f);
					if (RoundManager.Instance.GotNavMeshPositionResult)
					{
						flag = true;
					}
				}
			}
			if (!flag)
			{
				List<GameObject> list = new List<GameObject>();
				for (int j = 0; j < RoundManager.Instance.outsideAINodes.Length - 2; j += 2)
				{
					if (Vector3.Distance(RoundManager.Instance.outsideAINodes[j].transform.position, StartOfRound.Instance.elevatorTransform.position) > 30f && !PathIsIntersectedByLineOfSight(RoundManager.Instance.outsideAINodes[j].transform.position, calculatePathDistance: false, avoidLineOfSight: false))
					{
						list.Add(RoundManager.Instance.outsideAINodes[j]);
					}
				}
				if (list.Count == 0)
				{
					baboonCampPosition = ((Component)this).transform.position;
				}
				else
				{
					baboonCampPosition = RoundManager.Instance.GetRandomNavMeshPositionInBoxPredictable(list[random.Next(0, list.Count)].transform.position, 15f, RoundManager.Instance.navHit, random);
				}
			}
		}
		SyncInitialValuesServerRpc(leadershipLevel, baboonCampPosition);
	}

	[ServerRpc]
	public void SyncInitialValuesServerRpc(int syncLeadershipLevel, Vector3 campPosition)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f6: Invalid comparison between Unknown and I4
		//IL_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Invalid comparison between Unknown and I4
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
		{
			if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
				return;
			}
			ServerRpcParams val = default(ServerRpcParams);
			FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3452382367u, val, (RpcDelivery)0);
			BytePacker.WriteValueBitPacked(val2, syncLeadershipLevel);
			((FastBufferWriter)(ref val2)).WriteValueSafe(ref campPosition);
			((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3452382367u, val, (RpcDelivery)0);
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
		{
			SyncInitialValuesClientRpc(syncLeadershipLevel, campPosition);
		}
	}

	[ClientRpc]
	public void SyncInitialValuesClientRpc(int syncLeadershipLevel, Vector3 campPosition)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_0110: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3856685904u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, syncLeadershipLevel);
				((FastBufferWriter)(ref val2)).WriteValueSafe(ref campPosition);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3856685904u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				leadershipLevel = syncLeadershipLevel;
				baboonCampPosition = campPosition;
				((Component)this).transform.localScale = ((Component)this).transform.localScale * Mathf.Max((float)leadershipLevel / 200f * 0.6f, 0.9f);
			}
		}
	}

	public void LateUpdate()
	{
		//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		if ((!inSpecialAnimation && ((Object)(object)focusedThreatTransform == (Object)null || currentBehaviourStateIndex != 2) && peekTimer < 0f) || isEnemyDead)
		{
			agent.angularSpeed = 300f;
			((RigConstraint<MultiAimConstraintJob, MultiAimConstraintData, MultiAimConstraintJobBinder<MultiAimConstraintData>>)(object)headLookRig).weight = Mathf.Lerp(((RigConstraint<MultiAimConstraintJob, MultiAimConstraintData, MultiAimConstraintJobBinder<MultiAimConstraintData>>)(object)headLookRig).weight, 0f, Time.deltaTime * 10f);
			return;
		}
		agent.angularSpeed = 0f;
		((RigConstraint<MultiAimConstraintJob, MultiAimConstraintData, MultiAimConstraintJobBinder<MultiAimConstraintData>>)(object)headLookRig).weight = Mathf.Lerp(((RigConstraint<MultiAimConstraintJob, MultiAimConstraintData, MultiAimConstraintJobBinder<MultiAimConstraintData>>)(object)headLookRig).weight, 1f, Time.deltaTime * 10f);
		if (peekTimer >= 0f)
		{
			peekTimer -= Time.deltaTime;
			AnimateLooking(peekTarget);
		}
		else
		{
			AnimateLooking(lookTarget);
		}
	}

	public override void OnCollideWithPlayer(Collider other)
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: 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_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_0181: Unknown result type (might be due to invalid IL or missing references)
		base.OnCollideWithPlayer(other);
		if (timeSinceHitting < 0.5f)
		{
			return;
		}
		Vector3 val = Vector3.Normalize(((Component)this).transform.position + Vector3.up * 0.7f - (((Component)other).transform.position + Vector3.up * 0.4f)) * 0.5f;
		if (Physics.Linecast(((Component)this).transform.position + Vector3.up * 0.7f + val, ((Component)other).transform.position + Vector3.up * 0.4f, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1))
		{
			return;
		}
		PlayerControllerB playerControllerB = MeetsStandardPlayerCollisionConditions(other, inSpecialAnimation || doingKillAnimation);
		if ((Object)(object)playerControllerB != (Object)null)
		{
			timeSinceHitting = 0f;
			playerControllerB.DamagePlayer(20);
			if (playerControllerB.isPlayerDead)
			{
				StabPlayerDeathAnimServerRpc((int)playerControllerB.playerClientId);
				return;
			}
			creatureAnimator.ResetTrigger("Hit");
			creatureAnimator.SetTrigger("Hit");
			creatureSFX.PlayOneShot(enemyType.audioClips[5]);
			WalkieTalkie.TransmitOneShotAudio(creatureSFX, enemyType.audioClips[5]);
			RoundManager.Instance.PlayAudibleNoise(((Component)creatureSFX).transform.position, 8f, 0.7f);
		}
	}

	public override void OnCollideWithEnemy(Collider other, EnemyAI enemyScript = null)
	{
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		base.OnCollideWithEnemy(other);
		if (!((Object)(object)enemyScript.enemyType == (Object)(object)enemyType) && !(timeSinceHitting < 0.75f) && ((NetworkBehaviour)this).IsOwner && enemyScript.enemyType.canDie)
		{
			timeSinceHitting = 0f;
			creatureAnimator.ResetTrigger("Hit");
			creatureAnimator.SetTrigger("Hit");
			creatureSFX.PlayOneShot(enemyType.audioClips[5]);
			WalkieTalkie.TransmitOneShotAudio(creatureSFX, enemyType.audioClips[5]);
			RoundManager.Instance.PlayAudibleNoise(((Component)creatureSFX).transform.position, 8f, 0.7f);
			enemyScript.HitEnemy(1, null, playHitSFX: true);
		}
	}

	public override void HitEnemy(int force = 1, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
	{
		base.HitEnemy(force, playerWhoHit, playHitSFX, hitID);
		if (isEnemyDead)
		{
			return;
		}
		creatureAnimator.SetTrigger("TakeDamage");
		if ((Object)(object)playerWhoHit != (Object)null)
		{
			timeSinceBeingAttackedByPlayer = 0f;
			if (threats.TryGetValue(((Component)playerWhoHit).transform, out var value))
			{
				value.hasAttacked = true;
				fightTimer = 7f;
			}
		}
		enemyHP -= force;
		if (((NetworkBehaviour)this).IsOwner && enemyHP <= 0 && !isEnemyDead)
		{
			KillEnemyOnOwnerClient();
		}
		StopKillAnimation();
	}

	public override void KillEnemy(bool destroy = false)
	{
		base.KillEnemy(destroy);
		creatureAnimator.SetBool("IsDead", true);
		if ((Object)(object)heldScrap != (Object)null && ((NetworkBehaviour)this).IsOwner)
		{
			DropHeldItemAndSync();
		}
		StopKillAnimation();
	}

	public void StopKillAnimation()
	{
		if (killAnimCoroutine != null)
		{
			((MonoBehaviour)this).StopCoroutine(killAnimCoroutine);
		}
		agent.acceleration = 17f;
		inSpecialAnimation = false;
		doingKillAnimation = false;
		if ((Object)(object)killAnimationBody != (Object)null)
		{
			killAnimationBody.attachedLimb = null;
			killAnimationBody.attachedTo = null;
			killAnimationBody = null;
		}
	}

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

	[ClientRpc]
	public void StabPlayerDeathAnimClientRpc(int playerObject)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
		{
			ClientRpcParams val = default(ClientRpcParams);
			FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3749667856u, val, (RpcDelivery)0);
			BytePacker.WriteValueBitPacked(val2, playerObject);
			((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3749667856u, val, (RpcDelivery)0);
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
		{
			doingKillAnimation = true;
			inSpecialAnimation = true;
			agent.acceleration = 70f;
			agent.speed = 0f;
			if (killAnimCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(killAnimCoroutine);
			}
			killAnimCoroutine = ((MonoBehaviour)this).StartCoroutine(killPlayerAnimation(playerObject));
		}
	}

	private IEnumerator killPlayerAnimation(int playerObject)
	{
		PlayerControllerB killedPlayer = StartOfRound.Instance.allPlayerScripts[playerObject];
		creatureAnimator.ResetTrigger("KillAnimation");
		creatureAnimator.SetTrigger("KillAnimation");
		creatureVoice.PlayOneShot(enemyType.audioClips[4]);
		WalkieTalkie.TransmitOneShotAudio(creatureVoice, enemyType.audioClips[4]);
		float startTime = Time.realtimeSinceStartup;
		yield return (object)new WaitUntil((Func<bool>)(() => Time.realtimeSinceStartup - startTime > 1f || (Object)(object)killedPlayer.deadBody != (Object)null));
		if ((Object)(object)killedPlayer.deadBody != (Object)null)
		{
			killAnimationBody = killedPlayer.deadBody;
			killAnimationBody.attachedLimb = killedPlayer.deadBody.bodyParts[5];
			killAnimationBody.attachedTo = deadBodyPoint;
			killAnimationBody.matchPositionExactly = true;
			killAnimationBody.canBeGrabbedBackByPlayers = false;
			yield return null;
			yield return (object)new WaitForSeconds(1.7f);
			killAnimationBody.attachedLimb = null;
			killAnimationBody.attachedTo = null;
		}
		agent.acceleration = 17f;
		inSpecialAnimation = false;
		doingKillAnimation = false;
	}

	private void InteractWithScrap()
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)heldScrap != (Object)null)
		{
			focusedScrap = null;
			if (Vector3.Distance(((Component)this).transform.position, baboonCampPosition) < Random.Range(1f, 7f) || heldScrap.isHeld)
			{
				DropHeldItemAndSync();
			}
		}
		else if ((Object)(object)focusedScrap != (Object)null)
		{
			if (debugEnemyAI)
			{
				Debug.DrawRay(((Component)focusedScrap).transform.position, Vector3.up * 3f, Color.yellow);
			}
			if (!CanGrabScrap(focusedScrap))
			{
				focusedScrap = null;
			}
			else if (Vector3.Distance(((Component)this).transform.position, ((Component)focusedScrap).transform.position) < 0.4f && !Physics.Linecast(((Component)this).transform.position, ((Component)focusedScrap).transform.position + Vector3.up * 0.5f, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1))
			{
				GrabItemAndSync(((NetworkBehaviour)focusedScrap).NetworkObject);
			}
		}
	}

	private bool CanGrabScrap(GrabbableObject scrap)
	{
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		if (scrap.itemProperties.itemId == 1531)
		{
			return false;
		}
		if (scrap.isInShipRoom && !isInsidePlayerShip)
		{
			return false;
		}
		if (isEnemyDead)
		{
			return false;
		}
		if (!scrap.heldByPlayerOnServer && !scrap.isHeld && ((Object)(object)scrap == (Object)(object)heldScrap || !scrap.isHeldByEnemy))
		{
			return Vector3.Distance(((Component)scrap).transform.position, baboonCampPosition) > 8f;
		}
		return false;
	}

	private void DropHeldItemAndSync()
	{
		//IL_006f: 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_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: 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_008b: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)heldScrap == (Object)null)
		{
			Debug.LogError((object)$"Baboon #{thisEnemyIndex} Error: DropItemAndSync called when baboon has no scrap!");
		}
		NetworkObject networkObject = ((NetworkBehaviour)heldScrap).NetworkObject;
		if ((Object)(object)networkObject == (Object)null)
		{
			Debug.LogError((object)$"Baboon #{thisEnemyIndex} Error: No network object in held scrap {((Object)((Component)heldScrap).gameObject).name}");
		}
		Vector3 itemFloorPosition = heldScrap.GetItemFloorPosition();
		DropScrap(networkObject, itemFloorPosition);
		DropScrapServerRpc(NetworkObjectReference.op_Implicit(networkObject), itemFloorPosition, (int)GameNetworkManager.Instance.localPlayerController.playerClientId);
	}

	[ServerRpc]
	public void DropScrapServerRpc(NetworkObjectReference item, Vector3 targetFloorPosition, int clientWhoSentRPC)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_0107: Unknown result type (might be due to invalid IL or missing references)
		//IL_0111: Invalid comparison between Unknown and I4
		//IL_0137: Unknown result type (might be due to invalid IL or missing references)
		//IL_0138: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Invalid comparison between Unknown and I4
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
		{
			if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
				return;
			}
			ServerRpcParams val = default(ServerRpcParams);
			FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1418775270u, val, (RpcDelivery)0);
			((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref item, default(ForNetworkSerializable));
			((FastBufferWriter)(ref val2)).WriteValueSafe(ref targetFloorPosition);
			BytePacker.WriteValueBitPacked(val2, clientWhoSentRPC);
			((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1418775270u, val, (RpcDelivery)0);
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
		{
			DropScrapClientRpc(item, targetFloorPosition, clientWhoSentRPC);
		}
	}

	[ClientRpc]
	public void DropScrapClientRpc(NetworkObjectReference item, Vector3 targetFloorPosition, int clientWhoSentRPC)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cb: 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_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0112: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
		{
			ClientRpcParams val = default(ClientRpcParams);
			FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1865475504u, val, (RpcDelivery)0);
			((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref item, default(ForNetworkSerializable));
			((FastBufferWriter)(ref val2)).WriteValueSafe(ref targetFloorPosition);
			BytePacker.WriteValueBitPacked(val2, clientWhoSentRPC);
			((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1865475504u, val, (RpcDelivery)0);
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && clientWhoSentRPC != (int)GameNetworkManager.Instance.localPlayerController.playerClientId)
		{
			NetworkObject item2 = default(NetworkObject);
			if (((NetworkObjectReference)(ref item)).TryGet(ref item2, (NetworkManager)null))
			{
				DropScrap(item2, targetFloorPosition);
			}
			else
			{
				Debug.LogError((object)$"Baboon #{thisEnemyIndex}; Error, was not able to get network object from dropped item client rpc");
			}
		}
	}

	private void DropScrap(NetworkObject item, Vector3 targetFloorPosition)
	{
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)heldScrap == (Object)null)
		{
			Debug.LogError((object)"Baboon: my held item is null when attempting to drop it!!");
			return;
		}
		if (heldScrap.isHeld)
		{
			heldScrap.DiscardItemFromEnemy();
			heldScrap.isHeldByEnemy = false;
			heldScrap = null;
			Debug.Log((object)$"Baboon #{thisEnemyIndex}: Dropped item which was held by a player");
			return;
		}
		heldScrap.parentObject = null;
		((Component)heldScrap).transform.SetParent(StartOfRound.Instance.propsContainer, true);
		heldScrap.EnablePhysics(enable: true);
		heldScrap.fallTime = 0f;
		heldScrap.startFallingPosition = ((Component)heldScrap).transform.parent.InverseTransformPoint(((Component)heldScrap).transform.position);
		heldScrap.targetFloorPosition = ((Component)heldScrap).transform.parent.InverseTransformPoint(targetFloorPosition);
		heldScrap.floorYRot = -1;
		heldScrap.DiscardItemFromEnemy();
		heldScrap.isHeldByEnemy = false;
		heldScrap = null;
		Debug.Log((object)$"Baboon #{thisEnemyIndex}: Dropped item");
	}

	private void GrabItemAndSync(NetworkObject item)
	{
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)heldScrap != (Object)null)
		{
			Debug.LogError((object)$"Baboon #{thisEnemyIndex} Error: GrabItemAndSync called when baboon is already carrying scrap!");
		}
		GrabScrap(item);
		GrabScrapServerRpc(NetworkObjectReference.op_Implicit(item), (int)GameNetworkManager.Instance.localPlayerController.playerClientId);
	}

	[ServerRpc]
	public void GrabScrapServerRpc(NetworkObjectReference item, int clientWhoSentRPC)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0104: Invalid comparison between Unknown and I4
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Invalid comparison between Unknown and I4
		//IL_016b: 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))
		{
			if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
				return;
			}
			ServerRpcParams val = default(ServerRpcParams);
			FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(869682226u, val, (RpcDelivery)0);
			((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref item, default(ForNetworkSerializable));
			BytePacker.WriteValueBitPacked(val2, clientWhoSentRPC);
			((NetworkBehaviour)this).__endSendServerRpc(ref val2, 869682226u, val, (RpcDelivery)0);
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
		{
			NetworkObject val3 = default(NetworkObject);
			if (!((NetworkObjectReference)(ref item)).TryGet(ref val3, (NetworkManager)null))
			{
				Debug.LogError((object)$"Baboon #{thisEnemyIndex} error: Could not get grabbed network object from reference on server");
			}
			else if (Object.op_Implicit((Object)(object)((Component)val3).GetComponent<GrabbableObject>()) && !((Component)val3).GetComponent<GrabbableObject>().heldByPlayerOnServer)
			{
				GrabScrapClientRpc(item, clientWhoSentRPC);
			}
		}
	}

	[ClientRpc]
	public void GrabScrapClientRpc(NetworkObjectReference item, int clientWhoSentRPC)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
		{
			ClientRpcParams val = default(ClientRpcParams);
			FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1564051222u, val, (RpcDelivery)0);
			((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref item, default(ForNetworkSerializable));
			BytePacker.WriteValueBitPacked(val2, clientWhoSentRPC);
			((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1564051222u, val, (RpcDelivery)0);
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && clientWhoSentRPC != (int)GameNetworkManager.Instance.localPlayerController.playerClientId)
		{
			NetworkObject item2 = default(NetworkObject);
			if (((NetworkObjectReference)(ref item)).TryGet(ref item2, (NetworkManager)null))
			{
				GrabScrap(item2);
			}
			else
			{
				Debug.LogError((object)$"Baboon #{thisEnemyIndex}; Error, was not able to get id from grabbed item client rpc");
			}
		}
	}

	private void GrabScrap(NetworkObject item)
	{
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)heldScrap != (Object)null)
		{
			Debug.Log((object)$"Baboon #{thisEnemyIndex}: Trying to grab another item ({((Object)((Component)item).gameObject).name}) while hands are already full with item ({((Object)((Component)heldScrap).gameObject).name}). Dropping the currently held one.");
			DropScrap(((Component)heldScrap).GetComponent<NetworkObject>(), heldScrap.GetItemFloorPosition());
		}
		GrabbableObject grabbableObject = (heldScrap = ((Component)item).gameObject.GetComponent<GrabbableObject>());
		grabbableObject.parentObject = grabTarget;
		grabbableObject.hasHitGround = false;
		grabbableObject.GrabItemFromEnemy(this);
		grabbableObject.isHeldByEnemy = true;
		grabbableObject.EnablePhysics(enable: false);
		Debug.Log((object)$"Baboon #{thisEnemyIndex}: Grabbing item!!! {((Object)((Component)heldScrap).gameObject).name}");
	}

	public override void ReachedNodeInSearch()
	{
		base.ReachedNodeInSearch();
		if (currentSearch.nodesEliminatedInCurrentSearch > 14 && timeSinceRestWhileScouting > 17f && timeSinceAggressiveDisplay > 6f)
		{
			timeSinceRestWhileScouting = 0f;
			restingDuringScouting = 12f;
		}
	}

	public override void DoAIInterval()
	{
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_017e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0486: Unknown result type (might be due to invalid IL or missing references)
		//IL_0477: Unknown result type (might be due to invalid IL or missing references)
		//IL_0498: Unknown result type (might be due to invalid IL or missing references)
		//IL_049d: Unknown result type (might be due to invalid IL or missing references)
		//IL_066b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0676: Unknown result type (might be due to invalid IL or missing references)
		//IL_0258: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0314: Unknown result type (might be due to invalid IL or missing references)
		//IL_0336: Unknown result type (might be due to invalid IL or missing references)
		//IL_034e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0363: Unknown result type (might be due to invalid IL or missing references)
		//IL_0398: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_08f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0904: Unknown result type (might be due to invalid IL or missing references)
		//IL_090e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0913: Unknown result type (might be due to invalid IL or missing references)
		//IL_0918: Unknown result type (might be due to invalid IL or missing references)
		//IL_091a: Unknown result type (might be due to invalid IL or missing references)
		//IL_091c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0926: Unknown result type (might be due to invalid IL or missing references)
		//IL_092b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0943: Unknown result type (might be due to invalid IL or missing references)
		//IL_0948: Unknown result type (might be due to invalid IL or missing references)
		//IL_0952: Unknown result type (might be due to invalid IL or missing references)
		//IL_0957: Unknown result type (might be due to invalid IL or missing references)
		//IL_0962: Unknown result type (might be due to invalid IL or missing references)
		//IL_0967: Unknown result type (might be due to invalid IL or missing references)
		//IL_0971: Unknown result type (might be due to invalid IL or missing references)
		//IL_0976: Unknown result type (might be due to invalid IL or missing references)
		//IL_097b: Unknown result type (might be due to invalid IL or missing references)
		//IL_097d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0987: Unknown result type (might be due to invalid IL or missing references)
		//IL_098c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0996: Unknown result type (might be due to invalid IL or missing references)
		//IL_079f: Unknown result type (might be due to invalid IL or missing references)
		//IL_07af: Unknown result type (might be due to invalid IL or missing references)
		//IL_07b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_07be: Unknown result type (might be due to invalid IL or missing references)
		//IL_07c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_07c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_07c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_07d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_07d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_07e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_09de: Unknown result type (might be due to invalid IL or missing references)
		//IL_09e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_09f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_09f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_09b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_09c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_09cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_09d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_08df: Unknown result type (might be due to invalid IL or missing references)
		//IL_09fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_09fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a01: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a16: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a2b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a2d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a21: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a23: Unknown result type (might be due to invalid IL or missing references)
		base.DoAIInterval();
		if (isEnemyDead)
		{
			agent.speed = 0f;
			if (scoutingSearchRoutine.inProgress)
			{
				StopSearch(scoutingSearchRoutine, clear: false);
			}
			return;
		}
		if (stunNormalizedTimer > 0f || miscAnimationTimer > 0f)
		{
			agent.speed = 0f;
			if (doingKillAnimation && stunNormalizedTimer >= 0f)
			{
				StopKillAnimation();
			}
			if ((Object)(object)heldScrap != (Object)null && ((NetworkBehaviour)this).IsOwner)
			{
				DropHeldItemAndSync();
			}
			if ((Object)(object)stunnedByPlayer != (Object)null)
			{
				PingBaboonInterest(((Component)stunnedByPlayer.gameplayCamera).transform.position, 4);
			}
		}
		if (inSpecialAnimation)
		{
			agent.speed = 0f;
			return;
		}
		if (!eyesClosed)
		{
			DoLOSCheck();
		}
		InteractWithScrap();
		switch (currentBehaviourStateIndex)
		{
		case 0:
			if (previousBehaviourState != currentBehaviourStateIndex)
			{
				timeToScout = Random.Range(25, 70);
				scoutTimer = 0f;
				restingAtCamp = false;
				restAtCampTimer = 0f;
				SetAggressiveMode(0);
				previousBehaviourState = currentBehaviourStateIndex;
			}
			if (!((NetworkBehaviour)this).IsOwner)
			{
				break;
			}
			if ((Object)(object)focusedScrap != (Object)null)
			{
				SetDestinationToPosition(((Component)focusedScrap).transform.position);
			}
			if (scoutingGroup == null || (Object)(object)scoutingGroup.leader == (Object)(object)this || !scoutingGroup.members.Contains(this))
			{
				_ = scoutingGroup;
				if (restingDuringScouting >= 0f)
				{
					if (scoutingSearchRoutine.inProgress)
					{
						StopSearch(scoutingSearchRoutine, clear: false);
					}
					if (!creatureAnimator.GetBool("sit"))
					{
						EnemyEnterRestModeServerRpc(sleep: false, atCamp: false);
					}
					creatureAnimator.SetBool("sit", true);
					restingDuringScouting -= AIIntervalTime;
					agent.speed = 0f;
				}
				else
				{
					if (!scoutingSearchRoutine.inProgress && (Object)(object)focusedScrap == (Object)null)
					{
						StartSearch(baboonCampPosition, scoutingSearchRoutine);
					}
					if (creatureAnimator.GetBool("sit"))
					{
						EnemyGetUpServerRpc();
						creatureAnimator.SetBool("sit", false);
					}
					agent.speed = 10f;
				}
			}
			else
			{
				if (scoutingSearchRoutine.inProgress)
				{
					StopSearch(scoutingSearchRoutine);
				}
				if (creatureAnimator.GetBool("sit"))
				{
					EnemyGetUpServerRpc();
					creatureAnimator.SetBool("sit", false);
				}
				agent.speed = 12f;
				if (Vector3.Distance(((Component)this).transform.position, ((Component)scoutingGroup.leader).transform.position) > 60f || PathIsIntersectedByLineOfSight(((Component)scoutingGroup.leader).transform.position, calculatePathDistance: false, avoidLineOfSight: false))
				{
					LeaveCurrentScoutingGroup(sync: true);
				}
				else if (Vector3.Distance(destination, ((Component)scoutingGroup.leader).transform.position) > 8f && (Object)(object)focusedScrap == (Object)null)
				{
					SetDestinationToPosition(RoundManager.Instance.GetRandomNavMeshPositionInRadiusSpherical(((Component)scoutingGroup.leader).transform.position, 6f, RoundManager.Instance.navHit));
				}
			}
			if (scoutTimer < timeToScout && (Object)(object)heldScrap == (Object)null)
			{
				scoutTimer += AIIntervalTime;
			}
			else
			{
				SwitchToBehaviourState(1);
			}
			break;
		case 1:
			if (previousBehaviourState != currentBehaviourStateIndex)
			{
				restingDuringScouting = 0f;
				scoutTimer = 0f;
				chosenDistanceToCamp = Random.Range(1f, 7f);
				LeaveCurrentScoutingGroup(sync: true);
				SetAggressiveMode(0);
				previousBehaviourState = currentBehaviourStateIndex;
			}
			if (scoutingSearchRoutine.inProgress)
			{
				StopSearch(scoutingSearchRoutine);
			}
			if ((Object)(object)focusedScrap != (Object)null)
			{
				SetDestinationToPosition(((Component)focusedScrap).transform.position);
			}
			else
			{
				SetDestinationToPosition(baboonCampPosition);
			}
			if (Vector3.Distance(((Component)this).transform.position, baboonCampPosition) < chosenDistanceToCamp && peekTimer < 0f)
			{
				if (!restingAtCamp)
				{
					restingAtCamp = true;
					restAtCampTimer = Random.Range(15f, 30f);
					if ((Object)(object)heldScrap != (Object)null)
					{
						DropHeldItemAndSync();
					}
					bool sleep = false;
					if (Random.Range(0, 100) < 35)
					{
						sleep = true;
					}
					EnemyEnterRestModeServerRpc(sleep, atCamp: true);
				}
				else if (restAtCampTimer <= 0f)
				{
					SwitchToBehaviourState(0);
				}
				else
				{
					restAtCampTimer -= AIIntervalTime;
				}
				agent.speed = 0f;
			}
			else
			{
				if (restingAtCamp)
				{
					restingAtCamp = false;
					EnemyGetUpServerRpc();
				}
				creatureAnimator.SetBool("sit", false);
				creatureAnimator.SetBool("sleep", false);
				agent.speed = 9f;
			}
			break;
		case 2:
		{
			if (previousBehaviourState != currentBehaviourStateIndex)
			{
				timeSpentFocusingOnThreat = 0f;
				creatureAnimator.SetBool("sleep", false);
				creatureAnimator.SetBool("sit", false);
				EnemyGetUpServerRpc();
				previousBehaviourState = currentBehaviourStateIndex;
			}
			if (focusedThreat == null || !focusingOnThreat)
			{
				StopFocusingThreat();
			}
			if (scoutingSearchRoutine.inProgress)
			{
				StopSearch(scoutingSearchRoutine, clear: false);
			}
			agent.speed = 9f;
			float num = fearLevelNoDistComparison * 2f;
			if (focusedThreat.interestLevel <= 0 || enemyHP <= 3)
			{
				num = Mathf.Max(num, 1f);
			}
			float num2 = GetComfortableDistanceToThreat(focusedThreat) + num;
			float num3 = Vector3.Distance(((Component)this).transform.position, focusedThreat.lastSeenPosition);
			bool flag = false;
			float num4 = Time.realtimeSinceStartup - focusedThreat.timeLastSeen;
			if (num4 > 5f)
			{
				SetThreatInView(inView: false);
				focusLevel = 0;
				StopFocusingThreat();
				break;
			}
			if (num4 > 3f)
			{
				SetThreatInView(inView: false);
				focusLevel = 1;
				if (num2 - num3 > 2f)
				{
					StopFocusingThreat();
					break;
				}
			}
			else if (num4 > 1f)
			{
				flag = true;
				focusedThreatIsInView = false;
				SetThreatInView(inView: false);
				focusLevel = 2;
				SetAggressiveMode(0);
			}
			else if (num4 < 0.55f)
			{
				flag = true;
				SetThreatInView(inView: true);
			}
			bool flag2 = (fearLevel > 0f && fearLevel < 4f) || focusedThreat.interestLevel > 0 || fearLevel < -6f || focusedThreat.hasAttacked;
			if (aggressiveMode == 2)
			{
				focusLevel = 3;
				if ((Object)(object)heldScrap != (Object)null)
				{
					DropHeldItemAndSync();
					focusedScrap = heldScrap;
				}
				Vector3 val = focusedThreat.threatScript.GetThreatTransform().position + focusedThreat.threatScript.GetThreatVelocity() * 10f;
				Debug.DrawRay(val, Vector3.up * 5f, Color.red, AIIntervalTime);
				SetDestinationToPosition(val, checkForPath: true);
				if (fightTimer > 4f || timeSinceBeingAttackedByPlayer < 4f || (fightTimer > 2f && (fearLevel >= 1f || !flag2)) || (enemyHP <= 3 && !flag2))
				{
					scoutTimer = timeToScout - 20f;
					fightTimer = -7f;
					SetAggressiveMode(1);
				}
				else if (num3 > 4f)
				{
					fightTimer += AIIntervalTime * 2f;
				}
				else if (num3 > 1f)
				{
					fightTimer += AIIntervalTime;
				}
				else
				{
					fightTimer += AIIntervalTime / 2f;
				}
				break;
			}
			bool flag3 = false;
			if ((Object)(object)focusedScrap != (Object)null && (!flag || fearLevel <= 2f))
			{
				SetDestinationToPosition(((Component)focusedScrap).transform.position);
				flag3 = true;
			}
			Vector3 val2 = focusedThreat.lastSeenPosition + focusedThreat.threatScript.GetThreatVelocity() * -17f;
			Debug.DrawRay(val2, Vector3.up * 3f, Color.red, AIIntervalTime);
			Ray val3 = default(Ray);
			((Ray)(ref val3))..ctor(((Component)this).transform.position + Vector3.up * 0.5f, Vector3.Normalize((((Component)this).transform.position + Vector3.up * 0.5f - val2) * 100f));
			RaycastHit val4 = default(RaycastHit);
			Vector3 val5 = ((!Physics.Raycast(val3, ref val4, num2 - num3, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1)) ? RoundManager.Instance.GetNavMeshPosition(((Ray)(ref val3)).GetPoint(num2 - num3), RoundManager.Instance.navHit, 8f) : RoundManager.Instance.GetNavMeshPosition(((RaycastHit)(ref val4)).point, RoundManager.Instance.navHit, 8f));
			Debug.DrawRay(val5, Vector3.up, Color.blue, AIIntervalTime);
			if (!flag3)
			{
				if (SetDestinationToPosition(val5, checkForPath: true))
				{
					debugSphere = val5;
				}
				else
				{
					debugSphere = val5;
				}
			}
			if (fightTimer > 7f && timeSinceFighting > 4f)
			{
				fightTimer = -6f;
				SetAggressiveMode(2);
				break;
			}
			bool flag4 = false;
			if (scoutingGroup != null)
			{
				for (int i = 0; i < scoutingGroup.members.Count; i++)
				{
					if (scoutingGroup.members[i].aggressiveMode == 2)
					{
						flag4 = true;
					}
				}
			}
			float num5 = GetComfortableDistanceToThreat(focusedThreat) - num3;
			if (fearLevel <= -5f)
			{
				if (noiseTimer >= noiseInterval)
				{
					noiseInterval = Random.Range(0.2f, 0.7f);
					noiseTimer = 0f;
					RoundManager.PlayRandomClip(creatureVoice, cawLaughSFX, randomize: true, 1f, 1105);
				}
				else
				{
					noiseTimer += Time.deltaTime;
				}
			}
			if ((flag && ((num5 > 8f && flag2) || num3 < 5f)) || timeSinceBeingAttackedByPlayer < 4f)
			{
				if (timeSinceFighting > 5f)
				{
					fightTimer += AIIntervalTime * 10.6f / (focusedThreat.distanceToThreat * 0.3f);
				}
				SetAggressiveMode(1);
			}
			else if (num5 > 4f && fearLevel < 3f && flag2)
			{
				fightTimer += AIIntervalTime * 7.4f / (focusedThreat.distanceToThreat * 0.3f);
				SetAggressiveMode(1);
			}
			else
			{
				if (!(num5 < 2f))
				{
					break;
				}
				if (timeSinceAggressiveDisplay > 2.5f)
				{
					SetAggressiveMode(0);
				}
				fightTimer -= Mathf.Max(-6f, AIIntervalTime * 0.2f);
				if (timeSpentFocusingOnThreat > 4f + (float)focusedThreat.interestLevel * 8f && !flag4)
				{
					if (fightTimer > 4f)
					{
						fightTimer -= Mathf.Max(-6f, AIIntervalTime * 0.5f * (focusedThreat.distanceToThreat * 0.1f));
					}
					else
					{
						StopFocusingThreat();
					}
				}
			}
			break;
		}
		}
	}

	private void StopFocusingThreat()
	{
		if (currentBehaviourStateIndex == 2)
		{
			aggressiveMode = 0;
			focusingOnThreat = false;
			focusedThreatIsInView = false;
			focusedThreatTransform = null;
			focusedThreat = null;
			if ((Object)(object)heldScrap == (Object)null)
			{
				SwitchToBehaviourStateOnLocalClient(0);
			}
			else
			{
				SwitchToBehaviourStateOnLocalClient(1);
			}
			StopFocusingThreatServerRpc((Object)(object)heldScrap == (Object)null);
		}
	}

	[ServerRpc]
	public void StopFocusingThreatServerRpc(bool enterScoutingMode)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f7: Invalid comparison between Unknown and I4
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Invalid comparison between Unknown and I4
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
		{
			if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
				return;
			}
			ServerRpcParams val = default(ServerRpcParams);
			FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1546030380u, val, (RpcDelivery)0);
			((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref enterScoutingMode, default(ForPrimitives));
			((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1546030380u, val, (RpcDelivery)0);
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
		{
			StopFocusingThreatClientRpc(enterScoutingMode);
		}
	}

	[ClientRpc]
	public void StopFocusingThreatClientRpc(bool enterScoutingMode)
	{
		//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)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
		{
			ClientRpcParams val = default(ClientRpcParams);
			FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3360048400u, val, (RpcDelivery)0);
			((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref enterScoutingMode, default(ForPrimitives));
			((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3360048400u, val, (RpcDelivery)0);
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && !((NetworkBehaviour)this).IsOwner)
		{
			aggressiveMode = 0;
			focusedThreatTransform = null;
			focusedThreat = null;
			if (enterScoutingMode)
			{
				SwitchToBehaviourStateOnLocalClient(0);
			}
			else
			{
				SwitchToBehaviourStateOnLocalClient(1);
			}
		}
	}

	private void SetAggressiveMode(int mode)
	{
		if (aggressiveMode != mode)
		{
			aggressiveMode = mode;
			SetAggressiveModeServerRpc(mode);
		}
	}

	[ServerRpc]
	public void SetAggressiveModeServerRpc(int mode)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e9: Invalid comparison between Unknown and I4
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Invalid comparison between Unknown and I4
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
		{
			if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
				return;
			}
			ServerRpcParams val = default(ServerRpcParams);
			FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(443869275u, val, (RpcDelivery)0);
			BytePacker.WriteValueBitPacked(val2, mode);
			((NetworkBehaviour)this).__endSendServerRpc(ref val2, 443869275u, val, (RpcDelivery)0);
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
		{
			SetAggressiveModeClientRpc(mode);
		}
	}

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

	private void SetThreatInView(bool inView)
	{
		if (focusedThreatIsInView != inView)
		{
			focusedThreatIsInView = inView;
			SetThreatInViewServerRpc(inView);
		}
	}

	[ServerRpc]
	public void SetThreatInViewServerRpc(bool inView)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f7: Invalid comparison between Unknown and I4
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Invalid comparison between Unknown and I4
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
		{
			if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
				return;
			}
			ServerRpcParams val = default(ServerRpcParams);
			FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3428942850u, val, (RpcDelivery)0);
			((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref inView, default(ForPrimitives));
			((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3428942850u, val, (RpcDelivery)0);
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
		{
			SetThreatInViewClientRpc(inView);
		}
	}

	[ClientRpc]
	public void SetThreatInViewClientRpc(bool inView)
	{
		//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)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2073937320u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref inView, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2073937320u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && !((NetworkBehaviour)this).IsOwner)
			{
				focusedThreatIsInView = inView;
			}
		}
	}

	[ServerRpc]
	public void EnemyEnterRestModeServerRpc(bool sleep, bool atCamp)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_0108: Unknown result type (might be due to invalid IL or missing references)
		//IL_0112: Invalid comparison between Unknown and I4
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Invalid comparison between Unknown and I4
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
		{
			if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
				return;
			}
			ServerRpcParams val = default(ServerRpcParams);
			FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1806580287u, val, (RpcDelivery)0);
			((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref sleep, default(ForPrimitives));
			((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref atCamp, default(ForPrimitives));
			((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1806580287u, val, (RpcDelivery)0);
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
		{
			EnemyEnterRestModeClientRpc(sleep, atCamp);
		}
	}

	[ClientRpc]
	public void EnemyEnterRestModeClientRpc(bool sleep, bool atCamp)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: 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_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
		{
			ClientRpcParams val = default(ClientRpcParams);
			FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1567928363u, val, (RpcDelivery)0);
			((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref sleep, default(ForPrimitives));
			((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref atCamp, default(ForPrimitives));
			((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1567928363u, val, (RpcDelivery)0);
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
		{
			restingAtCamp = atCamp;
			if (sleep)
			{
				eyesClosed = true;
				creatureAnimator.SetBool("sleep", true);
				creatureAnimator.SetBool("sit", false);
			}
			else
			{
				eyesClosed = false;
				creatureAnimator.SetBool("sleep", false);
				creatureAnimator.SetBool("sit", true);
			}
		}
	}

	[ServerRpc]
	public void EnemyGetUpServerRpc()
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: Invalid comparison between Unknown and I4
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Invalid comparison between Unknown and I4
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
		{
			if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
				return;
			}
			ServerRpcParams val = default(ServerRpcParams);
			FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3614203845u, val, (RpcDelivery)0);
			((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3614203845u, val, (RpcDelivery)0);
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
		{
			EnemyGetUpClientRpc();
		}
	}

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

	public override void OnDrawGizmos()
	{
		//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_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: 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_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		if (!debugEnemyAI)
		{
			return;
		}
		if (currentBehaviourStateIndex == 1)
		{
			Gizmos.DrawCube(((Component)this).transform.position + Vector3.up * 2f, new Vector3(0.2f, 0.2f, 0.2f));
		}
		else if (scoutingGroup != null)
		{
			if ((Object)(object)scoutingGroup.leader == (Object)(object)this)
			{
				Gizmos.DrawSphere(((Component)this).transform.position + Vector3.up * 2f, 0.6f);
				return;
			}
			Gizmos.DrawLine(((Component)scoutingGroup.leader).transform.position + Vector3.up * 2f, ((Component)this).transform.position + Vector3.up * 2f);
			Gizmos.DrawSphere(((Component)this).transform.position + Vector3.up * 2f, 0.1f);
		}
	}

	public override void DetectNoise(Vector3 noisePosition, float noiseLoudness, int timesPlayedInOneSpot = 0, int noiseID = 0)
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: 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_00f1: Unknown result type (might be due to invalid IL or missing references)
		if (!((NetworkBehaviour)this).IsOwner || isEnemyDead)
		{
			return;
		}
		base.DetectNoise(noisePosition, noiseLoudness, timesPlayedInOneSpot, noiseID);
		if (Vector3.Distance(noisePosition, ((Component)this).transform.position + Vector3.up * 0.4f) < 0.75f || noiseID == 1105 || noiseID == 24751)
		{
			return;
		}
		float num = Vector3.Distance(noisePosition, ((Component)this).transform.position);
		float num2 = noiseLoudness / num;
		if (eyesClosed)
		{
			num2 *= 0.75f;
		}
		if (num2 < 0.12f && peekTimer >= 0f && focusLevel > 0)
		{
			return;
		}
		if (focusLevel >= 3)
		{
			if (num > 3f || num2 <= 0.06f)
			{
				return;
			}
		}
		else if (focusLevel == 2)
		{
			if (num > 25f || num2 <= 0.05f)
			{
				return;
			}
		}
		else if (focusLevel == 1 && (num > 40f || num2 <= 0.05f))
		{
			return;
		}
		PingBaboonInterest(noisePosition, focusLevel);
	}

	private void AnimateLooking(Vector3 lookAtPosition)
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
		headLookTarget.position = Vector3.Lerp(headLookTarget.position, lookAtPosition, 15f * Time.deltaTime);
		Vector3 position = headLookTarget.position;
		position.y = ((Component)this).transform.position.y;
		if (Vector3.Angle(((Component)this).transform.forward, position - ((Component)this).transform.position) > 30f)
		{
			RoundManager.Instance.tempTransform.position = ((Component)this).transform.position;
			RoundManager.Instance.tempTransform.LookAt(position);
			((Component)this).transform.rotation = Quaternion.Lerp(((Component)this).transform.rotation, RoundManager.Instance.tempTransform.rotation, 4f * Time.deltaTime);
			((Component)this).transform.eulerAngles = new Vector3(0f, ((Component)this).transform.eulerAngles.y, 0f);
		}
	}

	public override void Update()
	{
		//IL_052a: Unknown result type (might be due to invalid IL or missing references)
		//IL_052f: Unknown result type (might be due to invalid IL or missing references)
		base.Update();
		if (isEnemyDead)
		{
			return;
		}
		timeSinceHitting += Time.deltaTime;
		if (stunNormalizedTimer > 0f || miscAnimationTimer > 0f)
		{
			agent.speed = 0f;
		}
		creatureAnimator.SetBool("stunned", stunNormalizedTimer > 0f);
		if (miscAnimationTimer <= 0f)
		{
			currentMiscAnimation = -1;
		}
		else
		{
			miscAnimationTimer -= Time.deltaTime;
		}
		CalculateAnimationDirection(2f);
		timeSinceLastMiscAnimation += Time.deltaTime;
		timeSincePingingBirdInterest += Time.deltaTime;
		timeSinceBeingAttackedByPlayer += Time.deltaTime;
		timeSinceJoiningOrLeavingScoutingGroup += Time.deltaTime;
		if (debugEnemyAI)
		{
			if (focusedThreat != null && focusingOnThreat)
			{
				HUDManager.Instance.SetDebugText(string.Format("{0}; {1}; \n Focused threat level: {2}", fearLevel.ToString("0.0"), fearLevelNoDistComparison.ToString("0.0"), focusedThreat.threatLevel));
			}
			else
			{
				HUDManager.Instance.SetDebugText(fearLevel.ToString("0.0") + "; " + fearLevelNoDistComparison.ToString("0.0"));
			}
		}
		if ((Object)(object)heldScrap != (Object)null && !isEnemyDead)
		{
			creatureAnimator.SetLayerWeight(1, Mathf.Lerp(creatureAnimator.GetLayerWeight(1), 1f, 12f * Time.deltaTime));
			((RigConstraint<TwoBoneIKConstraintJob, TwoBoneIKConstraintData, TwoBoneIKConstraintJobBinder<TwoBoneIKConstraintData>>)(object)rightArmRig).weight = Mathf.Lerp(((RigConstraint<TwoBoneIKConstraintJob, TwoBoneIKConstraintData, TwoBoneIKConstraintJobBinder<TwoBoneIKConstraintData>>)(object)rightArmRig).weight, 0f, 12f * Time.deltaTime);
			((RigConstraint<TwoBoneIKConstraintJob, TwoBoneIKConstraintData, TwoBoneIKConstraintJobBinder<TwoBoneIKConstraintData>>)(object)leftArmRig).weight = Mathf.Lerp(((RigConstraint<TwoBoneIKConstraintJob, TwoBoneIKConstraintData, TwoBoneIKConstraintJobBinder<TwoBoneIKConstraintData>>)(object)leftArmRig).weight, 0f, 12f * Time.deltaTime);
		}
		else
		{
			creatureAnimator.SetLayerWeight(1, Mathf.Lerp(creatureAnimator.GetLayerWeight(1), 0f, 12f * Time.deltaTime));
			((RigConstraint<TwoBoneIKConstraintJob, TwoBoneIKConstraintData, TwoBoneIKConstraintJobBinder<TwoBoneIKConstraintData>>)(object)rightArmRig).weight = Mathf.Lerp(((RigConstraint<TwoBoneIKConstraintJob, TwoBoneIKConstraintData, TwoBoneIKConstraintJobBinder<TwoBoneIKConstraintData>>)(object)rightArmRig).weight, 1f, 12f * Time.deltaTime);
			((RigConstraint<TwoBoneIKConstraintJob, TwoBoneIKConstraintData, TwoBoneIKConstraintJobBinder<TwoBo

TheWhistleJester.dll

Decompiled 7 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using TheWhistleJester.Patches;
using UnityEngine;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("TheWhistleJester")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TheWhistleJester")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("ee9f098d-b8a6-4cf0-acc1-7a8a58bc9b94")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace TheWhistleJester
{
	[BepInPlugin("Wrouid.WhistleJesterMod", "Whistle Jester Mod", "1.0.0")]
	public class WhistleJesterBase : BaseUnityPlugin
	{
		private const string modGUID = "Wrouid.WhistleJesterMod";

		private const string modName = "Whistle Jester Mod";

		private const string modVersion = "1.0.0";

		private readonly Harmony harmony = new Harmony("Wrouid.WhistleJesterMod");

		private static WhistleJesterBase Instance;

		internal ManualLogSource Mls;

		public static AudioClip Audio;

		public static bool ConstTimer = true;

		private void Awake()
		{
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Invalid comparison between Unknown and I4
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			Mls = Logger.CreateLogSource("Wrouid.WhistleJesterMod");
			Mls.LogInfo((object)"WhisteJester mod has started");
			ConstTimer = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ConstTimer", true, "Sets the Jester's popUpTimer field to line up with the song").Value;
			string text = ((BaseUnityPlugin)this).Info.Location.TrimEnd("TheWhistleJester.dll".ToCharArray());
			UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip("File://" + text + "WhistleJester.mp3", (AudioType)13);
			audioClip.SendWebRequest();
			while (!audioClip.isDone)
			{
			}
			if ((int)audioClip.result == 1)
			{
				Audio = DownloadHandlerAudioClip.GetContent(audioClip);
				new Harmony("WhistleJester").PatchAll(typeof(WhistleJesterPatch));
				Mls.LogInfo((object)"WhisteJester: Mod was loaded");
			}
			else
			{
				Mls.LogError((object)"WhisteJester: Could not load audiofile");
			}
			harmony.PatchAll(typeof(WhistleJesterBase));
		}
	}
}
namespace TheWhistleJester.Patches
{
	[HarmonyPatch(typeof(JesterAI))]
	internal class WhistleJesterPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void AudioPatch(JesterAI __instance)
		{
			__instance.popGoesTheWeaselTheme = WhistleJesterBase.Audio;
		}

		[HarmonyPatch("SetJesterInitialValues")]
		[HarmonyPostfix]
		public static void ForceTime(JesterAI __instance)
		{
			if (WhistleJesterBase.ConstTimer)
			{
				__instance.popUpTimer = 41.5f;
			}
		}
	}
}