Decompiled source of NeighborLab v0.2.0

Mods/NeighborLab.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
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.SceneStreaming;
using MelonLoader;
using Microsoft.CodeAnalysis;
using NeighborLab;
using NeighborLab.AI;
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", "1.0.0", "Elijoe", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[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+a735171592de38c3dda4d52e4619369e93069082")]
[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 KeyPoint : MonoBehaviour
{
	public float likelyHood;

	public int amountGone;

	public bool beenToThisLife;

	public KeyPoint(IntPtr intPtr)
		: base(intPtr)
	{
	}

	private void OnTriggerEnter(Collider other)
	{
		if (((Component)other.attachedRigidbody).gameObject.layer == 8)
		{
			beenToThisLife = true;
		}
	}
}
[RegisterTypeInIl2Cpp]
public class PlayerTeleporter : MonoBehaviour
{
	public PlayerTeleporter(IntPtr intPtr)
		: base(intPtr)
	{
	}

	public void TeleportPlayer(Transform position)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		Player.RigManager.Teleport(position.position, position.forward, true);
	}
}
[RegisterTypeInIl2Cpp]
public class PointManager : MonoBehaviour
{
	public static PointManager instance;

	public int DeathAmount;

	public KeyPoint[] keyPoints;

	public List<KeyPoint> mostLikely = new List<KeyPoint>();

	public PointManager(IntPtr intPtr)
		: base(intPtr)
	{
	}

	private void Start()
	{
		instance = this;
		keyPoints = Il2CppArrayBase<KeyPoint>.op_Implicit(Object.FindObjectsOfType<KeyPoint>());
	}

	private void Update()
	{
	}

	public void OnPlayerCaught()
	{
		DeathAmount++;
		KeyPoint[] array = keyPoints;
		foreach (KeyPoint keyPoint in array)
		{
			if (keyPoint.beenToThisLife)
			{
				keyPoint.amountGone++;
			}
			keyPoint.likelyHood = keyPoint.amountGone / DeathAmount;
		}
		float num = 0f;
		KeyPoint[] array2 = keyPoints;
		foreach (KeyPoint keyPoint2 in array2)
		{
			if (keyPoint2.likelyHood == num)
			{
				mostLikely.Add(keyPoint2);
			}
			if (keyPoint2.likelyHood > num)
			{
				mostLikely.Clear();
				mostLikely.Add(keyPoint2);
			}
		}
	}
}
namespace NeighborLab
{
	public class Core : MelonMod
	{
		public override void OnInitializeMelon()
		{
			((MelonBase)this).LoggerInstance.Msg("Initialized.");
		}
	}
	[RegisterTypeInIl2Cpp]
	public class Door : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <NeighborOpen>d__17 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public Door <>4__this;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <NeighborOpen>d__17(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b3: Expected O, but got Unknown
				//IL_00c9: 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_007d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0087: Expected O, but got Unknown
				//IL_0102: Unknown result type (might be due to invalid IL or missing references)
				//IL_010c: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					if (!<>4__this.locked)
					{
						<>4__this.closed = false;
						<>4__this.lockJoint.angularZMotion = (ConfigurableJointMotion)1;
						<>4__this.neighborOpen = true;
						<>2__current = (object)new WaitForSeconds(0.1f);
						<>1__state = 1;
						return true;
					}
					break;
				case 1:
					<>1__state = -1;
					<>4__this.neighborOpen = false;
					<>2__current = (object)new WaitForSeconds(2f);
					<>1__state = 2;
					return true;
				case 2:
					<>1__state = -1;
					if (!(Quaternion.Angle(<>4__this.defaultDoorRot, <>4__this.door.localRotation) <= 2f))
					{
						<>4__this.neighborClose = true;
					}
					<>2__current = (object)new WaitForSeconds(2f);
					<>1__state = 3;
					return true;
				case 3:
					<>1__state = -1;
					<>4__this.neighborClose = false;
					break;
				}
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		public Transform handle;

		public Transform door;

		public ConfigurableJoint lockJoint;

		public Quaternion defaultDoorRot;

		public Quaternion defaultHandleRot;

		private bool neighborOpen;

		private bool neighborClose;

		private bool doorHandlePushed;

		public bool closed;

		public bool locked;

		public List<DoorLocks> doorLocks = new List<DoorLocks>();

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

		private void Awake()
		{
		}

		private void Start()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//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)
			defaultDoorRot = door.localRotation;
			defaultHandleRot = handle.localRotation;
			doorLocks = new List<DoorLocks>();
		}

		public void SetUpDoorLocks(DoorLocks locker)
		{
			MelonLogger.Msg("Door lock");
			doorLocks.Add(locker);
			locker.door = this;
		}

		private void Update()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: 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)
			locked = doorLocks.Count > 0;
			doorHandlePushed = Quaternion.Angle(defaultHandleRot, handle.localRotation) >= 30f;
			if (locked && !closed)
			{
				CloseDoor();
			}
			if (doorHandlePushed && !locked && closed)
			{
				OpenDoor();
			}
			if (neighborClose)
			{
				door.rotation = Quaternion.Lerp(door.rotation, defaultDoorRot, 0.1f);
			}
			if (!doorHandlePushed && !closed && Quaternion.Angle(defaultDoorRot, door.localRotation) <= 2f && !neighborOpen)
			{
				neighborClose = false;
				CloseDoor();
			}
		}

		public void OpenDoor()
		{
			if (!locked)
			{
				closed = false;
				lockJoint.angularZMotion = (ConfigurableJointMotion)1;
			}
		}

		[IteratorStateMachine(typeof(<NeighborOpen>d__17))]
		public IEnumerator NeighborOpen()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <NeighborOpen>d__17(0)
			{
				<>4__this = this
			};
		}

		public void CloseDoor()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			closed = true;
			door.localRotation = defaultDoorRot;
			lockJoint.angularZMotion = (ConfigurableJointMotion)0;
		}

		public void SetUp(Transform Handle, Transform Door, ConfigurableJoint LockJoint)
		{
			handle = Handle;
			door = Door;
			lockJoint = LockJoint;
		}
	}
	[RegisterTypeInIl2Cpp]
	public class DoorLocks : MonoBehaviour
	{
		public Door door;

		public DoorLocks(IntPtr intPtr)
			: base(intPtr)
		{
		}

		public void Unlock()
		{
			door.doorLocks.Remove(this);
		}
	}
	[RegisterTypeInIl2Cpp]
	public class NeighborMusic : MonoBehaviour
	{
		private GameObject chase;

		private GameObject catching;

		private Neighbor neighbor;

		public NeighborMusic(IntPtr intPtr)
			: base(intPtr)
		{
		}

		private void Awake()
		{
			neighbor = ((Component)this).GetComponent<Neighbor>();
		}

		public void setUpChase(GameObject Chase)
		{
			chase = Chase;
		}

		public void setUpCatch(GameObject value)
		{
			catching = value;
		}

		private void Update()
		{
			chase.SetActive(neighbor.alertState == NeighborState.Chase);
			if (neighbor.alertState == NeighborState.Catching && !catching.GetComponent<AudioSource>().isPlaying)
			{
				catching.GetComponent<AudioSource>().Play();
			}
		}
	}
}
namespace NeighborLab.AI
{
	[RegisterTypeInIl2Cpp]
	public class Distraction : MonoBehaviour
	{
		public bool activated;

		public float range;

		private Neighbor neighbor;

		private Animator animator;

		public Distraction(IntPtr intPtr)
			: base(intPtr)
		{
		}

		private void Start()
		{
			try
			{
				neighbor = Neighbor.singleton;
			}
			catch
			{
			}
		}

		public void setUp(float Range, Animator Animator)
		{
			animator = Animator;
			range = Range;
		}

		public void setUp(float Range)
		{
			range = Range;
		}

		public void toggleActive()
		{
			activated = !activated;
		}

		private void Update()
		{
			//IL_006f: 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)
			try
			{
				animator.SetBool("Active", activated);
			}
			catch
			{
			}
			try
			{
				if ((Object)(object)neighbor == (Object)null)
				{
					neighbor = Neighbor.singleton;
				}
			}
			catch
			{
				return;
			}
			if (!((Object)(object)neighbor == (Object)null) && activated && Vector3.Distance(((Component)neighbor).transform.position, ((Component)this).transform.position) <= range)
			{
				neighbor.Distract(this);
			}
		}

		private void OnDrawGizmosSelected()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			Gizmos.DrawWireSphere(((Component)this).transform.position, range);
		}
	}
	[RegisterTypeInIl2Cpp]
	public class Neighbor : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <Catch>d__35 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public Neighbor <>4__this;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <Catch>d__35(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0074: Unknown result type (might be due to invalid IL or missing references)
				//IL_007e: Expected O, but got Unknown
				//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b4: Expected O, but got Unknown
				//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>4__this.alertState = NeighborState.Catching;
					<>4__this.movementState = MovementState.Catching;
					((Behaviour)<>4__this.agent).enabled = false;
					((Collider)Player.PhysicsRig._football).attachedRigidbody.isKinematic = true;
					<>2__current = (object)new WaitForSeconds(1f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					((Collider)Player.PhysicsRig._football).attachedRigidbody.isKinematic = false;
					<>2__current = (object)new WaitForSeconds(0.5f);
					<>1__state = 2;
					return true;
				case 2:
					<>1__state = -1;
					Player.RigManager.Teleport(((Component)<>4__this.playerMarker).transform.position, true);
					Player.PhysicsRig.TurnOnRig();
					<>4__this.alertState = NeighborState.Chill;
					<>4__this.movementState = MovementState.Walking;
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		public static Neighbor singleton;

		public NeighborState alertState;

		public MovementState movementState;

		public float baseSpeed = 1.5f;

		public float runSpeed = 4f;

		public Task currentTask;

		private Task lastTask;

		public bool performingTask;

		private Distraction currentDistraction;

		private List<Distraction> distractions = new List<Distraction>();

		private TaskManager taskManager;

		private float remainingTaskTime;

		private NavMeshAgent agent;

		private NeighborAnimator neighborAnimator;

		private Vector3 lastKnownPlayerPosition;

		private Vector3 lastKnownPlayerVel;

		private NeighborLineOfSight neighborLineOfSight;

		private PlayerMarker playerMarker;

		private List<KeyPoint> pointsSearched = new List<KeyPoint>();

		private KeyPoint nearestLikelyPoint;

		private KeyPoint currentSearch;

		private float searchCountdown;

		private float searchTime = 2f;

		public bool searching;

		public bool canChase = true;

		private float knockedTime = 4.5f;

		private float knockedCountdown;

		public Neighbor(IntPtr intPtr)
			: base(intPtr)
		{
		}

		private void Start()
		{
			agent = ((Component)this).GetComponent<NavMeshAgent>();
			singleton = this;
			taskManager = TaskManager.instance;
			neighborAnimator = ((Component)this).GetComponent<NeighborAnimator>();
			neighborLineOfSight = ((Component)this).GetComponent<NeighborLineOfSight>();
			playerMarker = Object.FindObjectOfType<PlayerMarker>();
		}

		public void CanChase(bool value)
		{
			canChase = value;
		}

		private void Update()
		{
			if (neighborLineOfSight.canSeePlayer)
			{
				MelonLogger.Msg("Can see");
			}
			if (neighborLineOfSight.canSeePlayer && alertState != NeighborState.Catching)
			{
				alertState = NeighborState.Chase;
			}
			if (!canChase && alertState == NeighborState.Chase)
			{
				alertState = NeighborState.Chill;
			}
			if (knockedCountdown > 0f)
			{
				knockedCountdown -= Time.deltaTime;
			}
			else if (movementState == MovementState.KnockedOver)
			{
				movementState = MovementState.Running;
			}
			switch (movementState)
			{
			case MovementState.Walking:
				((Behaviour)agent).enabled = true;
				agent.speed = baseSpeed;
				DoorCheck();
				break;
			case MovementState.Running:
				((Behaviour)agent).enabled = true;
				agent.speed = runSpeed;
				DoorCheck();
				break;
			case MovementState.Idle:
				((Behaviour)agent).enabled = false;
				break;
			case MovementState.Task:
				((Behaviour)agent).enabled = false;
				break;
			case MovementState.KnockedOver:
				((Behaviour)agent).enabled = false;
				break;
			}
			switch (alertState)
			{
			case NeighborState.Chill:
				Chillin();
				break;
			case NeighborState.Alert:
				if ((Object)(object)currentDistraction != (Object)null)
				{
					Distracted();
				}
				else
				{
					Hunt();
				}
				break;
			case NeighborState.Chase:
				Chase();
				break;
			}
		}

		private void DoorCheck()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0089: 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)
			Vector3 position = ((Component)this).transform.position;
			position.y += 1f;
			RaycastHit val = default(RaycastHit);
			if (Physics.Raycast(position, ((Component)this).transform.forward, ref val, 1f, 951377) && !((Object)(object)((RaycastHit)(ref val)).rigidbody == (Object)null))
			{
				Door componentInParent = ((Component)((RaycastHit)(ref val)).rigidbody).GetComponentInParent<Door>();
				if (!((Object)(object)componentInParent == (Object)null))
				{
					MelonCoroutines.Start(componentInParent.NeighborOpen());
					((RaycastHit)(ref val)).rigidbody.AddForce(((Component)this).transform.forward * 25f);
				}
			}
		}

		private void Chillin()
		{
			//IL_0050: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)currentTask == (Object)null)
			{
				if (performingTask)
				{
					EndTask();
				}
				FindTask();
			}
			else if (performingTask)
			{
				PerformTask();
			}
			else
			{
				SetDestination(((Component)currentTask).transform.position);
				if ((double)Vector3.Distance(((Component)currentTask).transform.position, ((Component)this).transform.position) <= 0.1)
				{
					StartTask();
				}
			}
		}

		private void Chase()
		{
			//IL_000e: 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_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			movementState = MovementState.Running;
			if (Vector3.Distance(((Component)this).transform.position, neighborLineOfSight.playerRef.transform.position) <= 2f)
			{
				MelonCoroutines.Start(Catch());
			}
			if (performingTask)
			{
				EndTask();
			}
			if (neighborLineOfSight.canSeePlayer)
			{
				lastKnownPlayerPosition = neighborLineOfSight.playerRef.transform.position;
				lastKnownPlayerVel = ((Collider)Player.PhysicsRig._football).attachedRigidbody.velocity;
				SetDestination(lastKnownPlayerPosition);
			}
			else
			{
				SetDestination(lastKnownPlayerPosition + lastKnownPlayerVel);
				if (Vector3.Distance(((Component)this).transform.position, lastKnownPlayerPosition + lastKnownPlayerVel) <= 0.5f && alertState != NeighborState.Catching)
				{
					alertState = NeighborState.Alert;
				}
			}
			if (Vector3.Distance(((Component)this).transform.position, lastKnownPlayerPosition + lastKnownPlayerVel) <= 0.5f && alertState != NeighborState.Catching)
			{
				alertState = NeighborState.Alert;
			}
		}

		private void Hunt()
		{
			//IL_0303: 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_0324: 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_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)PointManager.instance == (Object)null)
			{
				MelonLogger.Error("PointManager doesnt exist!");
				return;
			}
			if (PointManager.instance.keyPoints.Count() == 0)
			{
				MelonLogger.Error("No keypoints!");
				return;
			}
			if ((Object)(object)currentSearch == (Object)null)
			{
				if (PointManager.instance.mostLikely.Count == 0)
				{
					KeyPoint[] keyPoints = PointManager.instance.keyPoints;
					foreach (KeyPoint keyPoint in keyPoints)
					{
						if (pointsSearched.Count == 0 || !pointsSearched.Contains(keyPoint))
						{
							MelonLogger.Msg("No likely: Point not searched");
							if ((Object)(object)nearestLikelyPoint == (Object)null)
							{
								nearestLikelyPoint = keyPoint;
							}
							if (Vector3.Distance(((Component)this).transform.position, ((Component)keyPoint).transform.position) < Vector3.Distance(((Component)this).transform.position, ((Component)nearestLikelyPoint).transform.position))
							{
								nearestLikelyPoint = keyPoint;
							}
						}
					}
					MelonLogger.Msg("No likely: Got past foreach");
					if ((Object)(object)nearestLikelyPoint == (Object)null && alertState != NeighborState.Catching)
					{
						alertState = NeighborState.Chill;
						currentSearch = null;
						pointsSearched.Clear();
					}
					currentSearch = nearestLikelyPoint;
					pointsSearched.Add(currentSearch);
				}
				else
				{
					foreach (KeyPoint item in PointManager.instance.mostLikely)
					{
						if (!pointsSearched.Contains(item))
						{
							if ((Object)(object)nearestLikelyPoint == (Object)null)
							{
								nearestLikelyPoint = item;
							}
							if (Vector3.Distance(((Component)this).transform.position, ((Component)item).transform.position) < Vector3.Distance(((Component)this).transform.position, ((Component)nearestLikelyPoint).transform.position))
							{
								nearestLikelyPoint = item;
							}
						}
					}
					if ((Object)(object)nearestLikelyPoint == (Object)null && alertState != NeighborState.Catching)
					{
						alertState = NeighborState.Chill;
						currentSearch = null;
						pointsSearched.Clear();
					}
					currentSearch = nearestLikelyPoint;
					pointsSearched.Add(currentSearch);
				}
			}
			if ((Object)(object)currentSearch == (Object)null)
			{
				return;
			}
			MelonLogger.Msg(((Object)currentSearch).name);
			SetDestination(((Component)currentSearch).transform.position);
			if (Vector3.Distance(((Component)this).transform.position, ((Component)currentSearch).transform.position) <= 5f)
			{
				if (!searching)
				{
					searching = true;
					movementState = MovementState.Idle;
					searchCountdown = searchTime;
				}
				else if (searchCountdown <= 0f)
				{
					searching = false;
					currentSearch = null;
					movementState = MovementState.Running;
					nearestLikelyPoint = null;
				}
				searchCountdown -= Time.deltaTime;
			}
		}

		[IteratorStateMachine(typeof(<Catch>d__35))]
		private IEnumerator Catch()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <Catch>d__35(0)
			{
				<>4__this = this
			};
		}

		private void StartTask()
		{
			//IL_008b: 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)
			remainingTaskTime = Random.Range(currentTask.timeRange.x, currentTask.timeRange.y);
			movementState = MovementState.Task;
			if (!currentTask.canSeeDuring)
			{
				neighborLineOfSight.blind = true;
			}
			neighborAnimator.TaskAnim(currentTask.animation);
			if (currentTask.setTransform)
			{
				((Component)this).transform.position = ((Component)currentTask).transform.position;
				((Component)this).transform.rotation = ((Component)currentTask).transform.rotation;
			}
			performingTask = true;
		}

		private void PerformTask()
		{
			if (remainingTaskTime <= 0f)
			{
				EndTask();
				return;
			}
			movementState = MovementState.Task;
			remainingTaskTime -= Time.deltaTime;
		}

		private void EndTask()
		{
			movementState = MovementState.Walking;
			neighborLineOfSight.blind = false;
			lastTask = currentTask;
			currentTask = null;
			performingTask = false;
			remainingTaskTime = 0f;
		}

		private void FindTask()
		{
			currentTask = taskManager.tasks[Random.Range(0, taskManager.tasks.Length)];
			if ((Object)(object)currentTask == (Object)(object)lastTask)
			{
				currentTask = null;
			}
		}

		private void Distracted()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			alertState = NeighborState.Alert;
			movementState = MovementState.Running;
			if (Vector3.Distance(((Component)this).transform.position, ((Component)currentDistraction).transform.position) <= 2f)
			{
				currentDistraction.activated = false;
				currentDistraction = null;
			}
			SetDestination(((Component)currentDistraction).transform.position);
		}

		private void SetDestination(Vector3 position)
		{
			//IL_0001: 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_0017: 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)
			NavMeshHit val = default(NavMeshHit);
			if (!NavMesh.SamplePosition(position, ref val, 5f, -1))
			{
				NavMeshHit val2 = default(NavMeshHit);
				NavMesh.FindClosestEdge(position, ref val2, -1);
				agent.destination = ((NavMeshHit)(ref val2)).position;
			}
			else
			{
				agent.destination = position;
			}
		}

		public void Distract(Distraction distraction)
		{
			if (!isDistractedBy(distraction))
			{
				alertState = NeighborState.Alert;
				if ((Object)(object)currentDistraction == (Object)null)
				{
					currentDistraction = distraction;
				}
				else
				{
					distractions.Add(distraction);
				}
			}
		}

		public bool isDistractedBy(Distraction distraction)
		{
			return distractions.Contains(distraction) || (Object)(object)currentDistraction == (Object)(object)distraction;
		}

		private void KnockOver()
		{
			MelonLogger.Msg("Knock Over");
			movementState = MovementState.KnockedOver;
			knockedCountdown = knockedTime;
		}

		private void OnCollisionEnter(Collision collision)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			Vector3 relativeVelocity = collision.relativeVelocity;
			if (((Vector3)(ref relativeVelocity)).magnitude >= 50f)
			{
				KnockOver();
			}
		}
	}
	public enum NeighborState
	{
		Chill,
		Alert,
		Chase,
		Catching
	}
	public enum MovementState
	{
		Walking,
		Running,
		Idle,
		Task,
		Catching,
		KnockedOver
	}
	[RegisterTypeInIl2Cpp]
	public class NeighborAnimator : MonoBehaviour
	{
		private Animator animator;

		private Neighbor neighbor;

		private NeighborLineOfSight neighborLineOfSight;

		public NeighborAnimator(IntPtr intPtr)
			: base(intPtr)
		{
		}

		private void Start()
		{
			animator = ((Component)this).GetComponentInChildren<Animator>();
			neighbor = ((Component)this).GetComponent<Neighbor>();
			neighborLineOfSight = ((Component)this).GetComponent<NeighborLineOfSight>();
		}

		private void Update()
		{
			animator.SetInteger("MoveState", (int)neighbor.movementState);
			animator.SetBool("CanSeePlayer", neighborLineOfSight.canSeePlayer);
			animator.SetBool("Search", neighbor.searching);
		}

		public void TaskAnim(AnimationClip clip)
		{
			animator.Play(((Object)clip).name);
		}
	}
	[RegisterTypeInIl2Cpp]
	public class NeighborLineOfSight : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <FOVRoutine>d__14 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public NeighborLineOfSight <>4__this;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <FOVRoutine>d__14(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0083: Unknown result type (might be due to invalid IL or missing references)
				//IL_008d: Expected O, but got Unknown
				//IL_004f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0059: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					break;
				case 1:
					<>1__state = -1;
					<>4__this.angle = 90f;
					goto IL_00ae;
				case 2:
					{
						<>1__state = -1;
						<>4__this.angle = 170f;
						goto IL_00ae;
					}
					IL_00ae:
					if (!<>4__this.blind)
					{
						<>4__this.FieldOfViewCheck();
					}
					break;
				}
				if (<>4__this.neighbor.alertState == NeighborState.Chill)
				{
					<>2__current = (object)new WaitForSeconds(1f);
					<>1__state = 1;
					return true;
				}
				<>2__current = (object)new WaitForSeconds(0.2f);
				<>1__state = 2;
				return true;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		public float radius = 30f;

		public float angle = 170f;

		public GameObject playerRef;

		public LayerMask targetMask = LayerMask.op_Implicit(16777472);

		public LayerMask obstructionMask = LayerMask.op_Implicit(951377);

		public Transform localPlayerHead;

		public bool blind = true;

		public bool canSeePlayer;

		private Transform playerHead;

		private Transform eyePos;

		private Neighbor neighbor;

		public NeighborLineOfSight(IntPtr intPtr)
			: base(intPtr)
		{
		}//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)


		public void SetUp(Transform EyePos)
		{
			eyePos = EyePos;
		}

		private void Start()
		{
			neighbor = ((Component)this).GetComponent<Neighbor>();
			MelonCoroutines.Start(FOVRoutine());
		}

		[IteratorStateMachine(typeof(<FOVRoutine>d__14))]
		private IEnumerator FOVRoutine()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <FOVRoutine>d__14(0)
			{
				<>4__this = this
			};
		}

		private void FieldOfViewCheck()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: 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_00b1: 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_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)playerHead == (Object)null)
			{
				playerHead = Player.Head;
				return;
			}
			Collider[] array = Il2CppArrayBase<Collider>.op_Implicit((Il2CppArrayBase<Collider>)(object)Physics.OverlapSphere(eyePos.position, radius, LayerMask.op_Implicit(targetMask)));
			if (array.Length != 0)
			{
				Transform val = playerHead;
				Vector3 val2 = val.position - eyePos.position;
				Vector3 normalized = ((Vector3)(ref val2)).normalized;
				if (Vector3.Angle(eyePos.forward, normalized) <= angle / 2f)
				{
					float num = Vector3.Distance(eyePos.position, val.position);
					RaycastHit val3 = default(RaycastHit);
					if (!Physics.Raycast(eyePos.position, normalized, ref val3, num, LayerMask.op_Implicit(obstructionMask)))
					{
						canSeePlayer = true;
						playerRef = ((Component)val).gameObject;
					}
					else if (((Component)((RaycastHit)(ref val3)).collider).gameObject.layer == 8)
					{
						canSeePlayer = true;
						playerRef = ((Component)val).gameObject;
					}
					else
					{
						canSeePlayer = false;
					}
				}
				else
				{
					canSeePlayer = false;
				}
			}
			else if (canSeePlayer)
			{
				canSeePlayer = false;
			}
		}
	}
	[RegisterTypeInIl2Cpp]
	public class Task : MonoBehaviour
	{
		public AnimationClip animation;

		public Vector2 timeRange;

		public bool setTransform;

		public bool canSeeDuring = true;

		public Task(IntPtr intPtr)
			: base(intPtr)
		{
		}

		public void SetUp(AnimationClip Animation, Vector2 TimeRange, bool SetTransform)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			animation = Animation;
			timeRange = TimeRange;
			setTransform = SetTransform;
		}

		private void Start()
		{
		}

		private void Update()
		{
		}

		public void CanSeeDuring(bool value)
		{
			canSeeDuring = value;
		}
	}
	[RegisterTypeInIl2Cpp]
	public class TaskManager : MonoBehaviour
	{
		public static TaskManager instance;

		public Task[] tasks;

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

		private void Awake()
		{
			instance = this;
		}

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