Decompiled source of NeighborLab v0.1.2

Mods/NeighborLab.dll

Decompiled 13 hours ago
using System;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BoneLib;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSLZ.Marrow;
using Il2CppSLZ.Marrow.Interaction;
using Il2CppSLZ.Marrow.SceneStreaming;
using MelonLoader;
using Microsoft.CodeAnalysis;
using NeighborLab;
using UnityEngine;
using UnityEngine.AI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(Core), "NeighborLab", "0.1.0", "Elijoe", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: MelonAdditionalDependencies(new string[] { "BoneLib" })]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("NeighborLab")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("NeighborLab")]
[assembly: AssemblyTitle("NeighborLab")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
[RegisterTypeInIl2Cpp]
public class KeyPoints : MonoBehaviour
{
	public int tries;

	public Points[] keyPoints;

	public Door[] doors;

	public KeyPoints(IntPtr ptr)
		: base(ptr)
	{
	}

	private void Awake()
	{
		if (((Component)this).GetComponentsInChildren<Points>() == null)
		{
			MelonLogger.Error("Cant find points oufg");
			return;
		}
		keyPoints = Il2CppArrayBase<Points>.op_Implicit(((Component)this).GetComponentsInChildren<Points>());
		doors = Il2CppArrayBase<Door>.op_Implicit(Object.FindObjectsOfType<Door>());
	}

	private void Update()
	{
	}

	public void Caught()
	{
		tries++;
		for (int i = 0; i < keyPoints.Length; i++)
		{
			if (keyPoints[i].playerBeenNear)
			{
				keyPoints[i].playerBeenNear = false;
				keyPoints[i].likelyHood += 100f;
			}
			keyPoints[i].likelyHood = keyPoints[i].likelyHood / (float)tries;
		}
	}
}
[RegisterTypeInIl2Cpp]
public class PlayerRespawnPoint : MonoBehaviour
{
	public PlayerRespawnPoint(IntPtr ptr)
		: base(ptr)
	{
	}

	private void Start()
	{
	}

	private void Update()
	{
	}
}
[RegisterTypeInIl2Cpp]
public class Points : MonoBehaviour
{
	public float likelyHood;

	public bool beenToThisCycle;

	public bool playerBeenNear;

	public LayerMask targetMask = LayerMask.op_Implicit(16777472);

	public Points(IntPtr ptr)
		: base(ptr)
	{
	}//IL_0006: Unknown result type (might be due to invalid IL or missing references)
	//IL_000b: Unknown result type (might be due to invalid IL or missing references)


	private void FixedUpdate()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		if (Physics.CheckSphere(((Component)this).transform.position, 3.5f, LayerMask.op_Implicit(targetMask)))
		{
			playerBeenNear = true;
		}
	}
}
namespace NeighborLab
{
	public class Core : MelonMod
	{
		public static Instance ModConsole;

		public override void OnInitializeMelon()
		{
			ModConsole = ((MelonBase)this).LoggerInstance;
			((MelonBase)this).LoggerInstance.Msg("Initialized.");
			if (MelonBase.FindMelon("NoFusionBackdoor", "VeygaX") != null)
			{
				((MelonBase)this).LoggerInstance.Msg("honestly, I know that this was probably done so you can harass your audience of mostly children, so sincerly...\r\n\r\nscrew you veyga - Eli ;)");
				MelonBase.FindMelon("NoFusionBackdoor", "VeygaX").Unregister((string)null, false);
			}
		}

		private static void LoadModule()
		{
		}
	}
	[RegisterTypeInIl2Cpp]
	public class DisableIfHaveNeighborLab : MonoBehaviour
	{
		public DisableIfHaveNeighborLab(IntPtr ptr)
			: base(ptr)
		{
		}

		private void Awake()
		{
			((Component)this).gameObject.SetActive(false);
		}
	}
	[RegisterTypeInIl2Cpp]
	public class Distraction : MonoBehaviour
	{
		public bool isOn;

		public float distractionRadius;

		public float turnOffRadius;

		public LayerMask NeighborMask = LayerMask.op_Implicit(4096);

		public GameObject TurnOnEvent;

		public GameObject TurnOffEvent;

		private bool turnedOffThisFrame;

		public Distraction(IntPtr ptr)
			: base(ptr)
		{
		}//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)


		private void Start()
		{
		}

		public void Toggle()
		{
			if (isOn)
			{
				TurnOff();
			}
			else
			{
				TurnOn();
			}
		}

		public void SetUpValues(float distRadius, float turnOffRad)
		{
			distractionRadius = distRadius;
			turnOffRadius = turnOffRad;
		}

		public void SetUpOn(GameObject turnOnEv)
		{
			TurnOnEvent = turnOnEv;
		}

		public void SetUpOff(GameObject turnOffEv)
		{
			TurnOffEvent = turnOffEv;
		}

		public void TurnOn()
		{
			TurnOnEvent.gameObject.SetActive(true);
			TurnOffEvent.gameObject.SetActive(false);
			isOn = true;
		}

		public void TurnOff()
		{
			TurnOnEvent.gameObject.SetActive(false);
			TurnOffEvent.gameObject.SetActive(true);
			isOn = false;
			turnedOffThisFrame = false;
		}

		private void Update()
		{
			//IL_0026: 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_00a5: 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)
			if (isOn && (Object)(object)TurnOnEvent != (Object)null)
			{
				Collider[] array = Il2CppArrayBase<Collider>.op_Implicit((Il2CppArrayBase<Collider>)(object)Physics.OverlapSphere(((Component)this).transform.position, distractionRadius, LayerMask.op_Implicit(NeighborMask)));
				if (array.Length != 0)
				{
					Collider[] array2 = array;
					foreach (Collider val in array2)
					{
						if (Object.op_Implicit((Object)(object)((Component)val).GetComponent<NeighborAI>()))
						{
							NeighborAI component = ((Component)val).GetComponent<NeighborAI>();
							if ((Object)(object)component.distraction == (Object)null)
							{
								component.distraction = this;
							}
							if (Vector3.Distance(((Component)this).transform.position, ((Component)component).transform.position) <= turnOffRadius)
							{
								component.huntTimeLeft = 15f;
								turnedOffThisFrame = true;
								isOn = false;
							}
						}
					}
				}
			}
			if (turnedOffThisFrame)
			{
				TurnOff();
			}
		}

		private void OnDrawGizmosSelected()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			Gizmos.DrawWireSphere(((Component)this).transform.position, distractionRadius);
		}
	}
	[RegisterTypeInIl2Cpp]
	public class Door : MonoBehaviour
	{
		public bool open;

		public bool Locked;

		public NavMeshObstacle obst;

		public bool close;

		public bool openedByNeighbor;

		public GameObject openEvent;

		public GameObject closeEvent;

		public GameObject Neighbor;

		private Quaternion defaultrot;

		private float timeLeft;

		private Rigidbody rb;

		public Door(IntPtr ptr)
			: base(ptr)
		{
		}

		private void Start()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)((Component)this).gameObject.GetComponent<NavMeshObstacle>() != (Object)null)
			{
				obst = ((Component)this).gameObject.GetComponent<NavMeshObstacle>();
			}
			defaultrot = ((Component)this).transform.rotation;
			rb = ((Component)this).GetComponent<Rigidbody>();
			if ((Object)(object)Object.FindObjectOfType<NeighborAI>() != (Object)null)
			{
				Neighbor = ((Component)Object.FindObjectOfType<NeighborAI>()).gameObject;
			}
		}

		public void EventAssigners(GameObject openEv, GameObject closeEv)
		{
			openEvent = openEv;
			closeEvent = closeEv;
		}

		public void LockAndUnlock()
		{
			Locked = !Locked;
		}

		private void Update()
		{
			//IL_00a5: 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_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Neighbor == (Object)null && (Object)(object)Object.FindObjectOfType<NeighborAI>() != (Object)null)
			{
				Neighbor = ((Component)Object.FindObjectOfType<NeighborAI>()).gameObject;
			}
			if (Locked && (Object)(object)obst != (Object)null)
			{
				((Behaviour)obst).enabled = true;
			}
			else if ((Object)(object)obst != (Object)null)
			{
				((Behaviour)obst).enabled = false;
			}
			if (open)
			{
				if (close)
				{
					((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, defaultrot, 0.1f);
				}
				if ((Object)(object)Neighbor != (Object)null && Vector3.Distance(((Component)this).transform.position, Neighbor.transform.position) >= 3f && openedByNeighbor)
				{
					close = true;
					openedByNeighbor = false;
				}
				timeLeft -= Time.deltaTime;
				if (Quaternion.Angle(((Component)this).transform.rotation, defaultrot) <= 2.5f && timeLeft <= 0f)
				{
					rb.isKinematic = true;
					openedByNeighbor = false;
					((Component)this).transform.rotation = defaultrot;
					open = false;
					closeEvent.gameObject.SetActive(true);
					openEvent.gameObject.SetActive(false);
					close = false;
				}
			}
			else
			{
				close = false;
				openedByNeighbor = false;
			}
		}

		public void Open()
		{
			if (!Locked && !open)
			{
				open = true;
				rb.isKinematic = false;
				closeEvent.gameObject.SetActive(false);
				openEvent.gameObject.SetActive(true);
				timeLeft = 2f;
			}
		}
	}
	[RegisterTypeInIl2Cpp]
	public class FieldOfView : MonoBehaviour
	{
		public float radius = 30f;

		public float angle = 170f;

		public GameObject playerRef;

		public LayerMask targetMask = LayerMask.op_Implicit(16777472);

		public LayerMask obstructionMask = LayerMask.op_Implicit(512656497);

		public bool canSeePlayer;

		public FieldOfView(IntPtr ptr)
			: base(ptr)
		{
		}//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)


		private void Awake()
		{
			MelonCoroutines.Start(FOVRoutine());
		}

		private IEnumerator FOVRoutine()
		{
			WaitForSeconds wait = new WaitForSeconds(0.2f);
			while (true)
			{
				yield return wait;
				FieldOfViewCheck();
			}
		}

		private void FieldOfViewCheck()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: 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_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			Collider[] array = Il2CppArrayBase<Collider>.op_Implicit((Il2CppArrayBase<Collider>)(object)Physics.OverlapSphere(((Component)this).transform.position, radius, LayerMask.op_Implicit(targetMask)));
			if (array.Length != 0)
			{
				Transform head = ((Rig)Player.PhysicsRig).m_head;
				Vector3 val = head.position - ((Component)this).transform.position;
				Vector3 normalized = ((Vector3)(ref val)).normalized;
				if (Vector3.Angle(((Component)this).transform.forward, normalized) <= angle / 2f)
				{
					float num = Vector3.Distance(((Component)this).transform.position, head.position);
					RaycastHit val2 = default(RaycastHit);
					if (!Physics.Raycast(((Component)this).transform.position, normalized, ref val2, num, LayerMask.op_Implicit(obstructionMask)))
					{
						canSeePlayer = true;
						playerRef = ((Component)head).gameObject;
					}
					else if (((Component)((RaycastHit)(ref val2)).collider).gameObject.layer == 8)
					{
						canSeePlayer = true;
						playerRef = ((Component)head).gameObject;
					}
					else
					{
						canSeePlayer = false;
					}
				}
				else
				{
					canSeePlayer = false;
				}
			}
			else if (canSeePlayer)
			{
				canSeePlayer = false;
			}
		}
	}
	[RegisterTypeInIl2Cpp]
	public class NeighborAI : MonoBehaviour
	{
		public bool findPlayer;

		public Animator animator;

		public TaskManager taskManager;

		public NavMeshAgent agent;

		public FieldOfView fieldOfView;

		public Transform target;

		public Transform eyes;

		public GameObject debugSphere;

		public bool Hunt;

		public bool Chase;

		public bool Idle;

		public LayerMask layer;

		public float WalkingSpeed = 1.5f;

		public float RunningSpeed = 5f;

		public bool walking;

		public bool running;

		private bool stunned;

		private float stunnedTimer;

		public Distraction distraction;

		public Tasks currentTask;

		private Tasks previousTask;

		public float huntTimeLeft;

		private float taskTimeLeft;

		private float exitTimeLeft;

		private float chaseTimeLeft;

		private float lookingTimeLeft;

		private bool taskAnimTriggered;

		private bool goingToRandomLoc;

		private bool catching;

		private Points randLoc;

		private Vector3 spawnPointFr;

		private KeyPoints keyPoints;

		private int pointsCount;

		private int closest;

		private int lastClosest;

		private Points[] probablePoints;

		private Vector3 lastSeenPosition;

		public NeighborAI(IntPtr ptr)
			: base(ptr)
		{
		}

		public void SetFindPlayer(bool FindPlayer)
		{
			findPlayer = FindPlayer;
		}

		public static NeighborAI CurrentAI()
		{
			return Object.FindObjectOfType<NeighborAI>();
		}

		public void DisableThisObjectIfHaveNeighbor(GameObject objectd)
		{
			objectd.SetActive(false);
		}

		public void toggleBool()
		{
			findPlayer = !findPlayer;
		}

		private void Awake()
		{
			//IL_0051: 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)
			animator = ((Component)this).GetComponentInChildren<Animator>();
			taskManager = Object.FindObjectOfType<TaskManager>();
			agent = ((Component)this).GetComponent<NavMeshAgent>();
			fieldOfView = ((Component)this).GetComponentInChildren<FieldOfView>();
			eyes = ((Component)this).transform.Find("NEyes");
			spawnPointFr = ((Component)Object.FindObjectOfType<PlayerMarker>()).transform.position;
			keyPoints = Object.FindObjectOfType<KeyPoints>();
		}

		private void fusionSync()
		{
		}

		private void LateUpdate()
		{
			//IL_006a: 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_00c2: 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_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0742: Unknown result type (might be due to invalid IL or missing references)
			//IL_0753: Unknown result type (might be due to invalid IL or missing references)
			//IL_075e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0839: Unknown result type (might be due to invalid IL or missing references)
			//IL_083f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0940: Unknown result type (might be due to invalid IL or missing references)
			//IL_0951: Unknown result type (might be due to invalid IL or missing references)
			//IL_0957: Invalid comparison between Unknown and I4
			//IL_0825: Unknown result type (might be due to invalid IL or missing references)
			//IL_082a: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_087b: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
			if (animator.GetBool("Walking") != walking)
			{
				animator.SetBool("Walking", walking);
			}
			if (findPlayer && Chase && !catching && Vector3.Distance(fieldOfView.playerRef.transform.position, ((Component)this).transform.position) <= 2.5f)
			{
				catching = true;
				MelonCoroutines.Start(CaughtPlayer());
			}
			RaycastHit val = default(RaycastHit);
			if ((walking || running) && Physics.Raycast(((Component)this).transform.position, ((Component)this).transform.forward, ref val, 1f) && (Object)(object)((RaycastHit)(ref val)).collider != (Object)null && (Object)(object)((RaycastHit)(ref val)).collider.attachedRigidbody != (Object)null && (Object)(object)((Component)((RaycastHit)(ref val)).collider.attachedRigidbody).GetComponent<Door>() != (Object)null)
			{
				((Component)((RaycastHit)(ref val)).collider.attachedRigidbody).GetComponent<Door>().close = false;
				((Component)((RaycastHit)(ref val)).collider.attachedRigidbody).GetComponent<Door>().openedByNeighbor = true;
				((Component)((RaycastHit)(ref val)).collider.attachedRigidbody).GetComponent<Door>().Open();
				((RaycastHit)(ref val)).collider.attachedRigidbody.AddForce(((Component)this).transform.forward * 25f);
			}
			if (!Hunt && !Chase)
			{
				fieldOfView.angle = 70f;
				fieldOfView.radius = 10f;
				if ((Object)(object)currentTask != (Object)null)
				{
					if (Object.op_Implicit((Object)(object)distraction))
					{
						if ((Object)(object)currentTask.eventDoing != (Object)null)
						{
							currentTask.eventDoing.SetActive(false);
						}
						if ((Object)(object)currentTask.eventExiting != (Object)null)
						{
							currentTask.eventExiting.SetActive(true);
						}
						((Behaviour)agent).enabled = true;
						((Behaviour)fieldOfView).enabled = true;
						currentTask = null;
					}
					if ((Object)(object)currentTask == (Object)(object)previousTask)
					{
						currentTask = null;
						return;
					}
					if ((Object)(object)currentTask != (Object)null)
					{
						target = ((Component)currentTask).transform;
					}
					if (!walking && Vector3.Distance(((Component)this).transform.position, ((Component)currentTask).transform.position) <= 0.1f)
					{
						if ((Object)(object)currentTask.eventExiting != (Object)null)
						{
							currentTask.eventExiting.SetActive(false);
						}
						if ((Object)(object)currentTask.eventDoing != (Object)null)
						{
							currentTask.eventDoing.SetActive(true);
						}
						if (!taskAnimTriggered)
						{
							animator.SetTrigger(currentTask.animationTrigger);
							taskAnimTriggered = true;
						}
						if ((Object)(object)currentTask != (Object)null)
						{
							if (currentTask.distracted)
							{
								((Behaviour)fieldOfView).enabled = false;
							}
							if (currentTask.setRotation)
							{
								((Behaviour)agent).enabled = false;
								((Component)this).transform.rotation = ((Component)currentTask).transform.rotation;
							}
						}
						taskTimeLeft -= Time.deltaTime;
						if (taskTimeLeft <= 0f)
						{
							if ((Object)(object)currentTask.eventDoing != (Object)null)
							{
								currentTask.eventDoing.SetActive(false);
							}
							if ((Object)(object)currentTask.eventExiting != (Object)null)
							{
								currentTask.eventExiting.SetActive(true);
							}
							exitTimeLeft = currentTask.exitTime;
							previousTask = currentTask;
							currentTask = null;
							((Behaviour)fieldOfView).enabled = true;
							((Behaviour)agent).enabled = true;
							animator.SetTrigger("Exiting");
						}
					}
				}
				else
				{
					exitTimeLeft -= Time.deltaTime;
					if (exitTimeLeft <= 0f)
					{
						taskAnimTriggered = false;
						walking = true;
						if ((Object)(object)agent != (Object)null)
						{
							((Behaviour)agent).enabled = true;
						}
						target = null;
						if ((Object)(object)taskManager != (Object)null)
						{
							currentTask = taskManager.tasks[Random.Range(0, taskManager.tasks.Length)];
						}
						if ((Object)(object)currentTask != (Object)null)
						{
							taskTimeLeft = currentTask.time;
						}
					}
				}
			}
			else
			{
				fieldOfView.angle = 110f;
				fieldOfView.radius = 30f;
				if ((Object)(object)agent != (Object)null)
				{
					((Behaviour)agent).enabled = true;
				}
			}
			if ((Object)(object)fieldOfView != (Object)null)
			{
				if (fieldOfView.canSeePlayer && findPlayer)
				{
					target = Player.PhysicsRig.feet.transform;
					Chase = true;
					chaseTimeLeft = 8f;
				}
				else
				{
					chaseTimeLeft -= Time.deltaTime;
					if (chaseTimeLeft <= 0f)
					{
						if (Chase)
						{
							Chase = false;
							Hunt = true;
							huntTimeLeft = Random.Range(100f, 200f);
						}
						running = false;
					}
				}
			}
			if (walking)
			{
				if ((Object)(object)animator != (Object)null)
				{
					animator.SetBool("Walking", true);
				}
				if ((Object)(object)agent != (Object)null)
				{
					if (Hunt)
					{
						agent.speed = RunningSpeed;
					}
					else
					{
						agent.speed = WalkingSpeed;
					}
				}
				if ((Object)(object)target != (Object)null)
				{
					agent.destination = target.position;
					if (Vector3.Distance(((Component)this).transform.position, target.position) <= 0.1f)
					{
						walking = false;
					}
				}
			}
			else if ((Object)(object)animator != (Object)null)
			{
				animator.SetBool("Walking", false);
			}
			if (Chase)
			{
				if (fieldOfView.canSeePlayer)
				{
					if ((Object)(object)agent != (Object)null)
					{
						agent.destination = Player.PhysicsRig.feet.transform.position;
						agent.speed = RunningSpeed;
					}
					lastSeenPosition = Player.PhysicsRig.feet.transform.position;
				}
				else
				{
					if (Vector3.Distance(((Component)this).transform.position, lastSeenPosition) <= 0.1f && !fieldOfView.canSeePlayer)
					{
						Chase = false;
						return;
					}
					agent.destination = lastSeenPosition;
				}
				if (!findPlayer)
				{
					Chase = false;
					return;
				}
				running = true;
				walking = false;
				if ((Object)(object)animator != (Object)null)
				{
					animator.SetBool("Chase", true);
				}
			}
			else
			{
				if ((Object)(object)animator != (Object)null)
				{
					animator.SetBool("Chase", false);
				}
				if ((Object)(object)distraction != (Object)null)
				{
					Hunt = true;
					target = ((Component)distraction).transform;
					agent.SetDestination(((Component)distraction).transform.position);
					if ((int)agent.pathStatus == 2)
					{
						distraction = null;
						return;
					}
					if (!distraction.isOn)
					{
						distraction = null;
					}
				}
			}
			if ((Object)(object)animator != (Object)null)
			{
				animator.SetBool("Running", running);
			}
			if (Hunt)
			{
				hunt();
			}
			else
			{
				animator.SetBool("Hunt", false);
				animator.SetBool("LookingAround", false);
				goingToRandomLoc = false;
			}
			if (!stunned)
			{
				return;
			}
			stunnedTimer -= Time.deltaTime;
			if (stunnedTimer <= 0f)
			{
				stunned = false;
				animator.SetBool("Stunned", false);
				agent.Resume();
				if (!Chase)
				{
					walking = true;
					Hunt = true;
					currentTask = null;
					hunt();
				}
			}
			else
			{
				agent.Stop();
			}
		}

		public Vector3 RandomNavMeshLocation()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0028: 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_0045: 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_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_004a: Unknown result type (might be due to invalid IL or missing references)
			Vector3 result = Vector3.zero;
			Vector3 val = Random.insideUnitSphere * 2f;
			val += ((Component)this).transform.position;
			NavMeshHit val2 = default(NavMeshHit);
			if (NavMesh.SamplePosition(val, ref val2, 2f, 1))
			{
				result = ((NavMeshHit)(ref val2)).position;
			}
			return result;
		}

		private void OnCollisionEnter(Collision collision)
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)collision.rigidbody != (Object)null && (Object)(object)((Component)collision.rigidbody).gameObject.GetComponent<Door>() != (Object)null)
			{
				((Component)collision.rigidbody).gameObject.GetComponent<Door>().Open();
				((Component)collision.rigidbody).gameObject.GetComponent<Door>().openedByNeighbor = true;
			}
			Vector3 relativeVelocity = collision.relativeVelocity;
			if (((Vector3)(ref relativeVelocity)).magnitude >= 5f)
			{
				stunned = true;
				stunnedTimer = 5f;
				animator.SetBool("Stunned", true);
			}
		}

		public void TeleportPlayerTo(Transform position)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			Player.PhysicsRig.ResetHands((Handedness)3);
			Player.RigManager.Teleport(position.position, true);
		}

		public static GameObject findComponentName(string name)
		{
			return GameObject.Find(name);
		}

		private IEnumerator CaughtPlayer()
		{
			agent.isStopped = true;
			animator.SetTrigger("Caught");
			yield return (object)new WaitForSeconds(1f);
			Player.PhysicsRig.EnableBallLoco();
			chaseTimeLeft = 0f;
			Chase = false;
			Hunt = true;
			currentTask = null;
			if ((Object)(object)distraction != (Object)null)
			{
				distraction.TurnOff();
			}
			distraction = null;
			Player.PhysicsRig.ResetHands((Handedness)3);
			Player.RigManager.Teleport(spawnPointFr, true);
			goingToRandomLoc = false;
			randLoc = null;
			target = null;
			walking = true;
			agent.isStopped = false;
			catching = false;
			keyPoints.Caught();
		}

		private void hunt()
		{
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: 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)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: 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_00ce: Unknown result type (might be due to invalid IL or missing references)
			animator.SetBool("Hunt", true);
			if ((Object)(object)distraction == (Object)null)
			{
				if (!goingToRandomLoc)
				{
					lastClosest = closest;
					for (int i = 0; i < keyPoints.keyPoints.Length; i++)
					{
						if (Vector3.Distance(((Component)keyPoints.keyPoints[i]).transform.position, ((Component)this).transform.position) <= 20f && (Vector3.Distance(((Component)keyPoints.keyPoints[i]).transform.position, ((Component)this).transform.position) < Vector3.Distance(((Component)keyPoints.keyPoints[closest]).transform.position, ((Component)this).transform.position) || closest == lastClosest) && !keyPoints.keyPoints[i].beenToThisCycle)
						{
							closest = i;
							keyPoints.keyPoints[i].beenToThisCycle = true;
						}
					}
					if (closest == lastClosest)
					{
						huntTimeLeft = 0f;
					}
					pointsCount = closest;
					randLoc = keyPoints.keyPoints[closest];
				}
				huntTimeLeft -= Time.deltaTime;
				if (huntTimeLeft <= 0f && !goingToRandomLoc)
				{
					for (int j = 0; j < keyPoints.keyPoints.Length; j++)
					{
						if (keyPoints.keyPoints[j].beenToThisCycle)
						{
							keyPoints.keyPoints[j].beenToThisCycle = false;
						}
					}
					goingToRandomLoc = false;
					Hunt = false;
					walking = true;
				}
			}
			target = null;
			if (!goingToRandomLoc)
			{
				walking = true;
				if (!Object.op_Implicit((Object)(object)distraction))
				{
					goingToRandomLoc = true;
					agent.SetDestination(((Component)randLoc).transform.position);
					lookingTimeLeft = 4.5f;
				}
			}
			else if (Vector3.Distance(((Component)this).transform.position, ((Component)randLoc).transform.position) <= 0.1f)
			{
				walking = false;
				animator.SetBool("LookingAround", true);
				lookingTimeLeft -= Time.deltaTime;
				if (lookingTimeLeft <= 0f)
				{
					goingToRandomLoc = false;
				}
			}
			else
			{
				walking = true;
				animator.SetBool("LookingAround", false);
			}
		}
	}
	[RegisterTypeInIl2Cpp]
	public class TaskManager : MonoBehaviour
	{
		public Tasks[] tasks;

		public TaskManager(IntPtr ptr)
			: base(ptr)
		{
		}

		private void Start()
		{
			tasks = Il2CppArrayBase<Tasks>.op_Implicit(Object.FindObjectsOfType<Tasks>());
		}

		private void Update()
		{
		}
	}
	[RegisterTypeInIl2Cpp]
	public class Tasks : MonoBehaviour
	{
		public string animationTrigger = "Admire";

		public float time = 10f;

		public float exitTime;

		public bool distracted;

		public bool setRotation;

		public GameObject eventDoing;

		public GameObject eventExiting;

		public Tasks(IntPtr ptr)
			: base(ptr)
		{
		}

		private void Awake()
		{
		}

		private void Update()
		{
		}

		public void SetUp(string AnimationTrigger, float Timer, float ExitTime, bool Distracted, bool SetRotation, GameObject doingEvent, GameObject ExitingEvent)
		{
			animationTrigger = AnimationTrigger;
			time = Timer;
			exitTime = ExitTime;
			distracted = Distracted;
			setRotation = SetRotation;
			if ((Object)(object)doingEvent != (Object)null)
			{
				eventDoing = doingEvent;
			}
			if ((Object)(object)ExitingEvent != (Object)null)
			{
				eventExiting = ExitingEvent;
			}
		}
	}
}