Decompiled source of Enemy Overhaul v1.0.12

EnemyOverhaul.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Events;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("EnemyOverhaul")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.11.0")]
[assembly: AssemblyInformationalVersion("1.0.11+a0453f343c0322aa6c1b71ab6f30bbb330f4c32b")]
[assembly: AssemblyProduct("EnemyOverhaul")]
[assembly: AssemblyTitle("EnemyOverhaul")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.11.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;
		}
	}
}
namespace Ardot.REPO.EnemyOverhaul
{
	public static class Debug
	{
		public static void PrintTree(Transform root, bool printComponents = true, int maxDepth = -1, IEnumerable<MonoBehaviour> forceInclude = null)
		{
			List<char> message = new List<char>();
			Utils.ForObjectsInTree(root, delegate(Transform branch, int depth)
			{
				message.Add('\n');
				for (int i = 0; i < depth; i++)
				{
					message.AddRange("   |");
				}
				message.AddRange("- " + ((Object)((Component)branch).gameObject).name);
				if (printComponents)
				{
					message.AddRange(" -");
					int componentCount = ((Component)branch).gameObject.GetComponentCount();
					for (int j = 0; j < componentCount; j++)
					{
						message.AddRange($" {((object)((Component)branch).gameObject.GetComponentAtIndex(j)).GetType()},");
					}
					message.RemoveAt(message.Count - 1);
				}
			}, maxDepth, forceInclude);
			Plugin.Logger.LogInfo((object)new string(new ReadOnlySpan<char>(message.ToArray())));
		}
	}
	public class PlayerAggro
	{
		public PlayerAvatar Player;

		public float Aggro;
	}
	public class AggroHandler
	{
		public List<PlayerAggro> AggroList = new List<PlayerAggro>();

		public PlayerAggro GetHighestAggro()
		{
			PlayerAggro playerAggro = null;
			for (int i = 0; i < AggroList.Count; i++)
			{
				PlayerAggro playerAggro2 = AggroList[i];
				if (playerAggro == null || playerAggro2.Aggro > playerAggro.Aggro)
				{
					playerAggro = playerAggro2;
				}
			}
			return playerAggro;
		}

		public void LoseAggro(float amount)
		{
			for (int i = 0; i < AggroList.Count; i++)
			{
				AggroList[i].Aggro = Mathf.Max(AggroList[i].Aggro - amount, 0f);
			}
		}

		public PlayerAggro GetAggro(PlayerAvatar playerAvatar)
		{
			int num = -1;
			for (int i = 0; i < AggroList.Count; i++)
			{
				if ((Object)(object)AggroList[i].Player == (Object)(object)playerAvatar)
				{
					num = i;
					break;
				}
			}
			if (num == -1)
			{
				num = AggroList.Count;
				AggroList.Add(new PlayerAggro
				{
					Player = playerAvatar,
					Aggro = 0f
				});
			}
			return AggroList[num];
		}
	}
	public class OverhaulDirector : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <GameOverCoroutine>d__12 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public OverhaulDirector <>4__this;

			private int <x>5__1;

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

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

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

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

			private bool MoveNext()
			{
				//IL_002f: 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_005f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0069: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					SemiFunc.UIBigMessage("ESSENTIAL ASSETS DAMAGED", "{!}", 30f, Color.red, Color.red);
					BigMessageUI.instance.Set<BigMessageUI>("bigMessageTimer", 3f);
					<>2__current = (object)new WaitForSeconds(6f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<x>5__1 = 0;
					while (<x>5__1 < GameDirector.instance.PlayerList.Count)
					{
						GameDirector.instance.PlayerList[<x>5__1].PlayerDeath(-1);
						<x>5__1++;
					}
					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 OverhaulDirector Instance;

		public bool ExtractionCompletedImpulse = false;

		public bool ExtractionUnlockedImpulse = false;

		public bool AllExtractionPointsCompleted = false;

		public int ExtractionOverflow = 0;

		public ExtractionPoint CurrentExtraction = null;

		public static void Init()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			Plugin.Harmony.Patch((MethodBase)AccessTools.Method(typeof(GameDirector), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(OverhaulDirector), "AwakePostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}

		public static void AwakePostfix(GameDirector __instance)
		{
			((Component)__instance).gameObject.AddComponent<OverhaulDirector>();
		}

		public void Awake()
		{
			Instance = this;
		}

		public void Update()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Invalid comparison between Unknown and I4
			ExtractionUnlockedImpulse = false;
			ExtractionCompletedImpulse = false;
			ExtractionPoint val = (ExtractionPoint)RoundDirector.instance.Get<RoundDirector>("extractionPointCurrent");
			if ((Object)(object)val != (Object)(object)CurrentExtraction && (!((Object)(object)val != (Object)null) || ((int)(State)val.Get<ExtractionPoint>("currentState") == 2 && !(bool)val.Get<ExtractionPoint>("stateStart"))))
			{
				if ((Object)(object)CurrentExtraction == (Object)null)
				{
					ExtractionUnlockedImpulse = true;
				}
				else
				{
					ExtractionCompletedImpulse = true;
				}
				CurrentExtraction = val;
				AllExtractionPointsCompleted = (bool)RoundDirector.instance.Get<RoundDirector>("allExtractionPointsCompleted");
			}
			if (ExtractionUnlockedImpulse)
			{
				AccessTools.Method(typeof(ExtractionPoint), "HaulGoalSet", (Type[])null, (Type[])null).Invoke(CurrentExtraction, new object[1] { (int)RoundDirector.instance.Get<RoundDirector>("haulGoal") / (int)RoundDirector.instance.Get<RoundDirector>("extractionPoints") + ExtractionOverflow * 12 / 10 });
				AccessTools.Method(typeof(ExtractionPoint), "SetHaulText", (Type[])null, (Type[])null).Invoke(CurrentExtraction, null);
				ExtractionOverflow = 0;
			}
		}

		public void DestroyExtractionPoint(ExtractionPoint extraction)
		{
			//IL_00d9: 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)
			((Behaviour)extraction).enabled = false;
			ExtractionOverflow += extraction.haulGoal;
			RoundDirector.instance.Set<RoundDirector>("extractionPointActive", false);
			RoundDirector.instance.ExtractionPointsUnlock();
			RoundDirector.instance.ExtractionCompleted();
			SemiFunc.StatSetRunCurrency(SemiFunc.StatGetRunCurrency() - 5);
			((SemiUI)CurrencyUI.instance).Show();
			CurrencyUI.instance.Set<CurrencyUI>("showTimer", 2f);
			int num = (int)RoundDirector.instance.Get<RoundDirector>("extractionPoints");
			int num2 = (int)RoundDirector.instance.Get<RoundDirector>("extractionPointsCompleted");
			if (num - num2 <= 0)
			{
				GameOver();
				return;
			}
			SemiFunc.UIBigMessage($"EXTRACTION DESTROYED\n${5000} FINED", "{!}", 25f, Color.red, Color.red);
			BigMessageUI.instance.Set<BigMessageUI>("bigMessageTimer", 3f);
		}

		public void GameOver()
		{
			((MonoBehaviour)this).StartCoroutine(GameOverCoroutine());
		}

		[IteratorStateMachine(typeof(<GameOverCoroutine>d__12))]
		public IEnumerator GameOverCoroutine()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <GameOverCoroutine>d__12(0)
			{
				<>4__this = this
			};
		}
	}
	public static class GnomeOverhaul
	{
		public static ConfigEntry<bool> OverhaulItemDamage;

		public static void Init()
		{
			OverhaulItemDamage = Plugin.BindConfig("Gnome", "OverhaulItemDamage", defaultValue: true, "If true, significantly reduces the damage that Gnomes do to items", delegate
			{
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: Expected O, but got Unknown
				Plugin.SetPatch(OverhaulItemDamage.Value, AccessTools.Method(typeof(EnemyGnome), "Start", (Type[])null, (Type[])null), null, new HarmonyMethod(typeof(GnomeOverhaul), "StartPostfix", (Type[])null));
			});
		}

		public static void StartPostfix(EnemyGnome __instance)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			List<HurtCollider> hurtColliders = Utils.GetHurtColliders(((Component)((Component)__instance.enemy).GetComponentInParent<EnemyParent>()).transform);
			for (int i = 0; i < hurtColliders.Count; i++)
			{
				HurtCollider val = hurtColliders[i];
				val.physImpact = (BreakImpact)1;
			}
		}
	}
	public static class HeadmanOverhaul
	{
		private enum HeadmanState
		{
			Roaming,
			Interested,
			Annoyed,
			VeryAnnoyed,
			Pissed
		}

		private const int VisionTimerMeta = 0;

		private const int LastVisionTime = 1;

		private const int State = 2;

		private const int Started = 3;

		private const int HurtColliders = 4;

		public static ConfigEntry<bool> OverhaulAI;

		public static void Init()
		{
			OverhaulAI = Plugin.BindConfig("Headman", "OverhaulAI", defaultValue: true, "If true, Headman AI is overhauled", delegate
			{
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				//IL_003c: Expected O, but got Unknown
				//IL_006e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0078: Expected O, but got Unknown
				Plugin.SetPatch(OverhaulAI.Value, AccessTools.Method(typeof(EnemyHeadController), "VisionTriggered", (Type[])null, (Type[])null), new HarmonyMethod(typeof(HeadmanOverhaul), "VisionTriggeredPrefix", (Type[])null));
				Plugin.SetPatch(OverhaulAI.Value, AccessTools.Method(typeof(EnemyHeadController), "Update", (Type[])null, (Type[])null), null, new HarmonyMethod(typeof(HeadmanOverhaul), "UpdatePostfix", (Type[])null));
			});
		}

		public static void Start(EnemyHeadController instance, Enemy enemy)
		{
			((MonoBehaviour)(object)instance).SetMetadata(4, Utils.GetHurtColliders(((Component)enemy.Get<EnemyParent, Enemy>("EnemyParent")).transform));
		}

		public static void UpdatePostfix(EnemyHeadController __instance, Enemy ___Enemy)
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Invalid comparison between Unknown and I4
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Invalid comparison between Unknown and I4
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			if (!((MonoBehaviour)(object)__instance).GetMetadata(3, defaultValue: false))
			{
				((MonoBehaviour)(object)__instance).SetMetadata(3, true);
				Start(__instance, ___Enemy);
			}
			HeadmanState headmanState = ((MonoBehaviour)(object)__instance).GetMetadata(2, HeadmanState.Roaming);
			float metadata = ((MonoBehaviour)(object)__instance).GetMetadata(0, 0f);
			EnemyVision obj = (EnemyVision)___Enemy.Get<Enemy>("Vision");
			PlayerAvatar val = obj.Get<PlayerAvatar, EnemyVision>("onVisionTriggeredPlayer");
			EnemyStateInvestigate component = ((Component)__instance).GetComponent<EnemyStateInvestigate>();
			if ((int)___Enemy.CurrentState == 4 || (int)___Enemy.CurrentState == 5)
			{
				List<HurtCollider> metadata2 = ((MonoBehaviour)(object)__instance).GetMetadata<List<HurtCollider>>(4);
				for (int i = 0; i < metadata2.Count; i++)
				{
					metadata2[i].playerDamage = 80;
				}
				SetMovement(__instance, ___Enemy, 12f, 20f);
			}
			else
			{
				SetMovement(__instance, ___Enemy, 6f, 10f);
			}
			switch (headmanState)
			{
			case HeadmanState.Roaming:
				if (metadata > 0.1f)
				{
					component.Set(Vector3.Lerp(((Component)__instance).transform.position, val.playerTransform.position, 0.2f));
					headmanState = HeadmanState.Interested;
				}
				break;
			case HeadmanState.Interested:
				if (metadata > 0.2f)
				{
					component.Set(Vector3.Lerp(((Component)__instance).transform.position, val.playerTransform.position, 0.2f));
					AccessTools.Method(typeof(EnemyHeadAnimationSystem), "IdleTeeth", (Type[])null, (Type[])null).Invoke(__instance.AnimationSystem, Array.Empty<object>());
					headmanState = HeadmanState.Annoyed;
				}
				if (metadata < 0.1f)
				{
					headmanState = HeadmanState.Roaming;
				}
				break;
			case HeadmanState.Annoyed:
				if (metadata > 0.4f)
				{
					component.Set(Vector3.Lerp(((Component)__instance).transform.position, val.playerTransform.position, 0.2f));
					AccessTools.Method(typeof(EnemyHeadAnimationSystem), "IdleTeeth", (Type[])null, (Type[])null).Invoke(__instance.AnimationSystem, Array.Empty<object>());
					headmanState = HeadmanState.VeryAnnoyed;
				}
				if (metadata < 0.2f)
				{
					headmanState = HeadmanState.Interested;
				}
				break;
			case HeadmanState.VeryAnnoyed:
				if (metadata > 0.7f)
				{
					headmanState = HeadmanState.Pissed;
				}
				if (metadata < 0.4f)
				{
					headmanState = HeadmanState.Annoyed;
				}
				break;
			case HeadmanState.Pissed:
				if (metadata < 0.5f)
				{
					headmanState = HeadmanState.Roaming;
				}
				break;
			}
			((MonoBehaviour)(object)__instance).SetMetadata(2, headmanState);
			float metadata3 = ((MonoBehaviour)(object)__instance).GetMetadata(1, 0f);
			if (!(Time.time - metadata3 < 0.5f))
			{
				metadata = Mathf.Max(metadata - 0.2f * Time.deltaTime, 0f);
				((MonoBehaviour)(object)__instance).SetMetadata(0, metadata);
			}
		}

		public static bool VisionTriggeredPrefix(EnemyHeadController __instance, Enemy ___Enemy)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Invalid comparison between Unknown and I4
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Invalid comparison between Unknown and I4
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Invalid comparison between Unknown and I4
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Invalid comparison between Unknown and I4
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Invalid comparison between Unknown and I4
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Invalid comparison between Unknown and I4
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Invalid comparison between Unknown and I4
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Invalid comparison between Unknown and I4
			//IL_0297: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			EnemyVision obj = (EnemyVision)___Enemy.Get<Enemy>("Vision");
			PlayerAvatar val = obj.Get<PlayerAvatar, EnemyVision>("onVisionTriggeredPlayer");
			___Enemy.Set<Enemy>("TargetPlayerViewID", val.photonView.ViewID);
			___Enemy.Set<Enemy>("TargetPlayerAvatar", val);
			PhysGrabber physGrabber = val.physGrabber;
			Rigidbody val2 = physGrabber.Get<Rigidbody, PhysGrabber>("grabbedObject");
			if ((Object)(object)val2 == (Object)null || (float)___Enemy.Get<Enemy>("DisableChaseTimer") > 0f)
			{
				return false;
			}
			HeadmanState metadata = ((MonoBehaviour)(object)__instance).GetMetadata(2, HeadmanState.Roaming);
			float metadata2 = ((MonoBehaviour)(object)__instance).GetMetadata(0, 0f);
			float num = (float)obj.Get<EnemyVision>("VisionCheckTime");
			float num2 = 0f;
			ValuableObject component = ((Component)val2).GetComponent<ValuableObject>();
			if (component != null)
			{
				num2 = component.dollarValueCurrent / 1500f;
			}
			else
			{
				ItemAttributes component2 = ((Component)val2).GetComponent<ItemAttributes>();
				if (component2 != null && ((int)component2.item.itemType == 6 || (int)component2.item.itemType == 7 || (int)component2.item.itemType == 9 || (int)component2.item.itemType == 11))
				{
					num2 = 4f;
				}
			}
			metadata2 = Mathf.Min(metadata2 + num * num2 / Vector3.Distance(val.playerTransform.position, ((Component)__instance).transform.position), 1f);
			((MonoBehaviour)(object)__instance).SetMetadata(1, Time.time);
			((MonoBehaviour)(object)__instance).SetMetadata(0, metadata2);
			if (metadata != HeadmanState.Pissed)
			{
				return false;
			}
			if ((int)___Enemy.CurrentState != 4 && (int)___Enemy.CurrentState != 10)
			{
				if ((int)___Enemy.CurrentState == 5)
				{
					___Enemy.CurrentState = (EnemyState)4;
				}
				else if ((bool)obj.Get<EnemyVision>("onVisionTriggeredCulled") && !(bool)obj.Get<EnemyVision>("onVisionTriggeredNear"))
				{
					if ((int)___Enemy.CurrentState != 8)
					{
						if (Random.Range(0f, 100f) <= 30f)
						{
							___Enemy.CurrentState = (EnemyState)3;
						}
						else
						{
							___Enemy.CurrentState = (EnemyState)8;
						}
					}
				}
				else if ((float)obj.Get<EnemyVision>("onVisionTriggeredDistance") >= 7f)
				{
					___Enemy.CurrentState = (EnemyState)4;
					___Enemy.Get<EnemyStateChase, Enemy>("StateChase").ChaseCanReach = true;
				}
				else
				{
					___Enemy.CurrentState = (EnemyState)3;
				}
			}
			return false;
		}

		public static void SetMovement(EnemyHeadController instance, Enemy enemy, float speed, float acceleration)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			EnemyRigidbody val = (EnemyRigidbody)enemy.Get<Enemy>("Rigidbody");
			EnemyStateChase component = ((Component)instance).GetComponent<EnemyStateChase>();
			val.OverrideFollowPosition(1f, speed, -1f);
			component.Speed = speed;
			component.Acceleration = acceleration;
			instance.Visual.PositionFollowChasing = speed;
		}
	}
	public static class HuntsmanOverhaul
	{
		public static ConfigEntry<bool> OverhaulAI;

		public static ConfigEntry<bool> OverhaulDamageFalloff;

		public static ConfigEntry<bool> OverhaulTargetPlayerItems;

		public static void Init()
		{
			OverhaulAI = Plugin.BindConfig("Huntsman", "OverhaulAI", defaultValue: true, "If true, Huntsman AI is overhauled", delegate
			{
				//IL_0032: Unknown result type (might be due to invalid IL or missing references)
				//IL_003c: Expected O, but got Unknown
				//IL_006d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0078: Expected O, but got Unknown
				//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b4: Expected O, but got Unknown
				//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f0: Expected O, but got Unknown
				//IL_0121: Unknown result type (might be due to invalid IL or missing references)
				//IL_012c: Expected O, but got Unknown
				Plugin.SetPatch(OverhaulAI.Value, AccessTools.Method(typeof(EnemyHunter), "Awake", (Type[])null, (Type[])null), null, new HarmonyMethod(typeof(HuntsmanOverhaul), "AwakePostfix", (Type[])null));
				Plugin.SetPatch(OverhaulAI.Value, AccessTools.Method(typeof(EnemyHunter), "OnInvestigate", (Type[])null, (Type[])null), new HarmonyMethod(typeof(HuntsmanOverhaul), "OnInvestigatePrefix", (Type[])null));
				Plugin.SetPatch(OverhaulAI.Value, AccessTools.Method(typeof(EnemyHunter), "StateAim", (Type[])null, (Type[])null), new HarmonyMethod(typeof(HuntsmanOverhaul), "StateAimPrefix", (Type[])null));
				Plugin.SetPatch(OverhaulAI.Value, AccessTools.Method(typeof(EnemyHunter), "Update", (Type[])null, (Type[])null), null, new HarmonyMethod(typeof(HuntsmanOverhaul), "UpdatePostfix", (Type[])null));
				Plugin.SetPatch(OverhaulAI.Value, AccessTools.Method(typeof(EnemyHunter), "UpdateState", (Type[])null, (Type[])null), new HarmonyMethod(typeof(HuntsmanOverhaul), "UpdateStatePrefix", (Type[])null));
			});
			OverhaulDamageFalloff = Plugin.BindConfig("Huntsman", "OverhaulDamageFalloff", defaultValue: true, "If true, Huntsman damage reduces over long distances and increases at short range", delegate
			{
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: Expected O, but got Unknown
				Plugin.SetPatch(OverhaulDamageFalloff.Value, AccessTools.Method(typeof(EnemyHunter), "ShootRPC", (Type[])null, (Type[])null), null, new HarmonyMethod(typeof(HuntsmanOverhaul), "HunterShootRPCPostFix", (Type[])null));
			});
			OverhaulTargetPlayerItems = Plugin.BindConfig("Huntsman", "OverhaulTargetPlayerItems", defaultValue: true, "If true, Huntsman shoot directly at valuables that touch it, not the players holding those valuables.", delegate
			{
				//IL_0032: Unknown result type (might be due to invalid IL or missing references)
				//IL_003c: Expected O, but got Unknown
				//IL_006e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0078: Expected O, but got Unknown
				Plugin.SetPatch(OverhaulTargetPlayerItems.Value, AccessTools.Method(typeof(EnemyHunter), "OnTouchPlayerGrabbedObject", (Type[])null, (Type[])null), null, new HarmonyMethod(typeof(HuntsmanOverhaul), "HunterOnTouchPlayerGrabbedObjectPostfix", (Type[])null));
				Plugin.SetPatch(OverhaulTargetPlayerItems.Value, AccessTools.Method(typeof(EnemyRigidbody), "OnCollisionStay", (Type[])null, (Type[])null), null, new HarmonyMethod(typeof(HuntsmanOverhaul), "EnemyOnCollisionStayPostfix", (Type[])null));
			});
		}

		public static void AwakePostfix(EnemyHunter __instance)
		{
			HuntsmanOverhaulState huntsmanOverhaulState = ((Component)__instance).gameObject.AddComponent<HuntsmanOverhaulState>();
			huntsmanOverhaulState.Hunter = __instance;
		}

		public static void UpdateStatePrefix(EnemyHunter __instance, State _state)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Invalid comparison between Unknown and I4
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Invalid comparison between Unknown and I4
			HuntsmanOverhaulState component = ((Component)__instance).GetComponent<HuntsmanOverhaulState>();
			if ((int)_state != 3 && (int)__instance.currentState != 3)
			{
				component.InvestigateFrames = 0;
			}
		}

		public static void UpdatePostfix(EnemyHunter __instance)
		{
			HuntsmanOverhaulState component = ((Component)__instance).GetComponent<HuntsmanOverhaulState>();
			component.InvestigateFrames--;
		}

		public static void OnInvestigatePrefix(EnemyHunter __instance)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Invalid comparison between Unknown and I4
			//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_0084: 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_009d: 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)
			HuntsmanOverhaulState component = ((Component)__instance).GetComponent<HuntsmanOverhaulState>();
			if (!SemiFunc.IsMasterClientOrSingleplayer() || !((float)component.EnemyRigidbody.Get<EnemyRigidbody>("timeSinceStun") > 1.5f))
			{
				return;
			}
			component.InvestigateFrames = 2;
			if ((int)__instance.currentState == 5 && component.InvestigateCooldown <= 0f)
			{
				component.InvestigateTriggeredImpulse = true;
				Vector3 val = (Vector3)component.StateInvestigate.Get<EnemyStateInvestigate>("onInvestigateTriggeredPosition");
				__instance.Set<EnemyHunter>("investigatePoint", val);
				__instance.Set<EnemyHunter>("shootFast", Vector3.Distance(val, ((Component)component).transform.position) < 4f);
				component.InvestigateTransformGet();
				if (SemiFunc.IsMultiplayer())
				{
					component.PhotonView.RPC("UpdateInvestigationPoint", (RpcTarget)1, new object[1] { val });
				}
			}
		}

		public static bool StateAimPrefix(EnemyHunter __instance)
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			HuntsmanOverhaulState component = ((Component)__instance).GetComponent<HuntsmanOverhaulState>();
			if (component.InvestigateFrames <= 0)
			{
				return true;
			}
			float num = (float)__instance.Get<EnemyHunter>("stateTimer");
			component.InvestigateFrames = 2;
			if ((bool)__instance.Get<EnemyHunter>("stateImpulse"))
			{
				component.EnemyNavAgent.Warp(((Component)component.EnemyRigidbody).transform.position);
				component.EnemyNavAgent.ResetPath();
				__instance.Set<EnemyHunter>("stateImpulse", false);
				num = 5f;
				component.InvestigateCooldown = 1f;
				__instance.Set<EnemyHunter>("investigatePointTransform", null);
				__instance.Set<EnemyHunter>("investigatePointHasTransform", false);
			}
			if (component.InvestigateTriggeredImpulse && !component.Aiming)
			{
				component.InvestigateTriggeredImpulse = false;
				component.Aiming = true;
				component.InvestigateCooldown = 0.5f;
				num = 0.5f;
				__instance.Set<EnemyHunter>("investigatePointSpread", Vector3.zero);
				__instance.Set<EnemyHunter>("investigatePointSpreadTarget", Vector3.zero);
				__instance.Set<EnemyHunter>("investigatePointSpreadTimer", 0f);
			}
			num -= Time.deltaTime;
			if (num <= 0f)
			{
				if (component.Aiming)
				{
					component.Aiming = false;
					component.UpdateState((State)6);
				}
				else
				{
					component.Animator.CrossFade("Leave Start", 1f);
					component.UpdateState((State)8);
				}
			}
			__instance.Set<EnemyHunter>("stateTimer", num);
			return false;
		}

		public static void HunterOnTouchPlayerGrabbedObjectPostfix(EnemyHunter __instance)
		{
			AccessTools.Field(typeof(EnemyHunter), "investigatePointHasTransform").SetValue(__instance, false);
		}

		public static void HunterShootRPCPostFix(EnemyHunter __instance, Vector3 _hitPosition)
		{
			//IL_0006: 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)
			float num = Mathf.Min(2f / Mathf.Pow(Vector3.Distance(_hitPosition, __instance.gunTipTransform.position), 1.5f), 0.5f);
			__instance.hurtCollider.playerDamage = (int)(300f * num);
			__instance.hurtCollider.playerTumbleForce = 30f * num;
			__instance.hurtCollider.playerTumbleTorque = 30f * num;
			__instance.hurtCollider.playerHitForce = 30f * num;
			__instance.hurtCollider.playerTumbleTime = 6f * num;
			__instance.hurtCollider.enemyDamage = (int)(300f * num);
			__instance.hurtCollider.enemyHitForce = 30f * num;
			__instance.hurtCollider.enemyHitTorque = 60f * num;
		}

		public static void EnemyOnCollisionStayPostfix(EnemyRigidbody __instance, Collision other)
		{
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			if (other.gameObject.CompareTag("Phys Grab Object"))
			{
				PhysGrabObject val = other.gameObject.GetComponent<PhysGrabObject>();
				if (!Object.op_Implicit((Object)(object)val))
				{
					val = other.gameObject.GetComponentInParent<PhysGrabObject>();
				}
				if (Object.op_Implicit((Object)(object)val) && !__instance.enemy.CheckChase() && val.playerGrabbing.Count > 0)
				{
					__instance.Set<EnemyRigidbody>("onTouchPlayerGrabbedObjectPosition", other.transform.position);
				}
			}
		}
	}
	public class HuntsmanOverhaulState : MonoBehaviour
	{
		public EnemyHunter Hunter;

		public EnemyHunterAnim EnemyAnim;

		public Animator Animator;

		public Enemy Enemy;

		public EnemyNavMeshAgent EnemyNavAgent;

		public EnemyRigidbody EnemyRigidbody;

		public EnemyStateInvestigate StateInvestigate;

		public PhotonView PhotonView;

		public Action<State> UpdateState;

		public Action InvestigateTransformGet;

		public bool InvestigateTriggeredImpulse;

		public float InvestigateCooldown;

		public bool Aiming;

		public int InvestigateFrames;

		public void Awake()
		{
			EnemyNavAgent = ((Component)this).GetComponent<EnemyNavMeshAgent>();
			PhotonView = ((Component)this).GetComponent<PhotonView>();
			StateInvestigate = ((Component)this).GetComponent<EnemyStateInvestigate>();
			Enemy = ((Component)this).GetComponent<Enemy>();
		}

		public void Start()
		{
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: 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
			UpdateState = (Action<State>)AccessTools.Method(typeof(EnemyHunter), "UpdateState", (Type[])null, (Type[])null).CreateDelegate(typeof(Action<State>), Hunter);
			InvestigateTransformGet = (Action)AccessTools.Method(typeof(EnemyHunter), "InvestigateTransformGet", (Type[])null, (Type[])null).CreateDelegate(typeof(Action), Hunter);
			EnemyAnim = Hunter.enemyHunterAnim;
			Animator = (Animator)EnemyAnim.Get<EnemyHunterAnim>("animator");
			EnemyRigidbody = (EnemyRigidbody)Enemy.Get<Enemy>("Rigidbody");
		}

		public void Update()
		{
			InvestigateCooldown -= Time.deltaTime;
		}
	}
	public static class PitOverhaul
	{
		public const int MapHurtColliderMeta = 0;

		public static ConfigEntry<bool> OverhaulPlayers;

		public static ConfigEntry<bool> OverhaulEnemies;

		public static ConfigEntry<bool> OverhaulItems;

		public static void Init()
		{
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Expected O, but got Unknown
			OverhaulPlayers = Plugin.BindConfig("Pits", "OverhaulPlayers", defaultValue: true, "If true, pit overhauled mechanics are applied to players", delegate
			{
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: Expected O, but got Unknown
				Plugin.SetPatch(OverhaulPlayers.Value, AccessTools.Method(typeof(HurtCollider), "PlayerHurt", (Type[])null, (Type[])null), new HarmonyMethod(typeof(PitOverhaul), "PlayerHurtPrefix", (Type[])null));
			});
			OverhaulEnemies = Plugin.BindConfig("Pits", "OverhaulEnemies", defaultValue: true, "If true, pit overhauled mechanics are applied to enemies", delegate
			{
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: Expected O, but got Unknown
				Plugin.SetPatch(OverhaulEnemies.Value, AccessTools.Method(typeof(HurtCollider), "EnemyHurt", (Type[])null, (Type[])null), new HarmonyMethod(typeof(PitOverhaul), "EnemyHurtPrefix", (Type[])null));
			});
			OverhaulItems = Plugin.BindConfig("Pits", "OverhaulItems", defaultValue: true, "If true, pit overhauled mechanics are applied to items", delegate
			{
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: Expected O, but got Unknown
				Plugin.SetPatch(OverhaulItems.Value, AccessTools.Method(typeof(HurtCollider), "PhysObjectHurt", (Type[])null, (Type[])null), new HarmonyMethod(typeof(PitOverhaul), "PhysObjectHurtPrefix", (Type[])null));
			});
			Plugin.Harmony.Patch((MethodBase)AccessTools.Method(typeof(LevelGenerator), "GenerateDone", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(PitOverhaul), "GenerateDonePostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}

		public static void GenerateDonePostfix(LevelGenerator __instance)
		{
			if ((Object)(object)RunManager.instance.levelCurrent == (Object)(object)RunManager.instance.levelArena)
			{
				return;
			}
			List<HurtCollider> hurtColliders = Utils.GetHurtColliders(__instance.LevelParent.transform);
			for (int i = 0; i < hurtColliders.Count; i++)
			{
				HurtCollider val = hurtColliders[i];
				if (((Object)val).name.Contains("Kill Box"))
				{
					((MonoBehaviour)(object)val).SetMetadata(0, true);
				}
			}
		}

		public static bool PlayerHurtPrefix(HurtCollider __instance, PlayerAvatar _player)
		{
			//IL_0036: 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_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: 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_0078: 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_0099: Expected O, but got Unknown
			//IL_009a: 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)
			if (!((MonoBehaviour)(object)__instance).GetMetadata(0, defaultValue: false))
			{
				return true;
			}
			__instance.onImpactAny.Invoke();
			__instance.onImpactPlayer.Invoke();
			LevelPoint val = Utils.ChooseLevelPoint(((Component)_player).transform.position, 40f, 1f);
			Vector3 val2 = ((Component)val).transform.position + new Vector3(0f, 1f, 0f);
			_player.Spawn(val2, ((Component)_player).transform.rotation);
			Rigidbody val3 = (Rigidbody)_player.tumble.Get<PlayerTumble>("rb");
			val3.position = val2;
			((Component)val3).transform.position = val2;
			PlayerController.instance.CollisionController.Set<PlayerCollisionController>("fallDistance", 0);
			_player.tumble.TumbleRequest(true, false);
			_player.tumble.TumbleOverrideTime(3f);
			_player.tumble.ImpactHurtSet(float.PositiveInfinity, Random.Range(35, 45));
			return false;
		}

		public static bool EnemyHurtPrefix(HurtCollider __instance, Enemy _enemy)
		{
			//IL_0038: 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_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: 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_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Expected O, but got Unknown
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Expected O, but got Unknown
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			if (!((MonoBehaviour)(object)__instance).GetMetadata(0, defaultValue: false))
			{
				return true;
			}
			__instance.onImpactAny.Invoke();
			__instance.onImpactEnemy.Invoke();
			LevelPoint val = Utils.ChooseLevelPoint(((Component)_enemy).transform.position, 30f, 1f);
			Vector3 val2 = ((Component)val).transform.position + new Vector3(0f, 1f, 0f);
			_enemy.EnemyTeleported(val2);
			EnemyHealth val3 = (EnemyHealth)_enemy.Get<Enemy>("Health");
			if ((Object)(object)val3 != (Object)null)
			{
				val3.Hurt(Random.Range(100, 145), ((Component)__instance).transform.forward);
			}
			else if ((bool)_enemy.Get<Enemy>("HasStateDespawn"))
			{
				_enemy.Get<EnemyParent, Enemy>("EnemyParent").SpawnedTimerSet(0f);
				_enemy.CurrentState = (EnemyState)11;
			}
			EnemyStateStunned val4 = (EnemyStateStunned)_enemy.Get<Enemy>("StateStunned");
			if ((Object)(object)val4 != (Object)null)
			{
				val4.Set(5f);
			}
			return false;
		}

		public static bool PhysObjectHurtPrefix(ref bool __result, HurtCollider __instance, PhysGrabObject physGrabObject)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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)
			if (!((MonoBehaviour)(object)__instance).GetMetadata(0, defaultValue: false))
			{
				return true;
			}
			LevelPoint val = Utils.ChooseLevelPoint(((Component)physGrabObject).transform.position, 20f, 1f);
			Vector3 val2 = ((Component)val).transform.position + new Vector3(0f, 1f, 0f);
			physGrabObject.Teleport(val2, ((Component)physGrabObject).transform.rotation);
			__result = true;
			return false;
		}
	}
	public static class ReaperOverhaul
	{
		public static ConfigEntry<bool> OverhaulAI;

		public static void Init()
		{
			OverhaulAI = Plugin.BindConfig("Reaper", "OverhaulAI", defaultValue: true, "If true, overhauls the AI of the Reaper", delegate
			{
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				//IL_003c: Expected O, but got Unknown
				//IL_006e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0078: 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_00e6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f0: Expected O, but got Unknown
				Plugin.SetPatch(OverhaulAI.Value, AccessTools.Method(typeof(EnemyRunner), "StateAttackPlayer", (Type[])null, (Type[])null), new HarmonyMethod(typeof(ReaperOverhaul), "StateAttackPlayerPrefix", (Type[])null));
				Plugin.SetPatch(OverhaulAI.Value, AccessTools.Method(typeof(EnemyRunner), "Awake", (Type[])null, (Type[])null), null, new HarmonyMethod(typeof(ReaperOverhaul), "AwakePostfix", (Type[])null));
				Plugin.SetPatch(OverhaulAI.Value, AccessTools.Method(typeof(EnemyRunner), "OnHurt", (Type[])null, (Type[])null), null, new HarmonyMethod(typeof(ReaperOverhaul), "OnHurtPostfix", (Type[])null));
				Plugin.SetPatch(OverhaulAI.Value, AccessTools.Method(typeof(EnemyRunner), "StateLeave", (Type[])null, (Type[])null), null, new HarmonyMethod(typeof(ReaperOverhaul), "StateLeavePostfix", (Type[])null));
			});
		}

		public static void StateLeavePostfix(EnemyRunner __instance)
		{
			ReaperOverhaulState component = ((Component)__instance).GetComponent<ReaperOverhaulState>();
			if (component.RunningTimer > 0f)
			{
				component.OverrideMovement(3f, 5f, 6f, 0.2f);
			}
		}

		public static void AwakePostfix(EnemyRunner __instance)
		{
			ReaperOverhaulState reaperOverhaulState = ((Component)__instance).gameObject.AddComponent<ReaperOverhaulState>();
			reaperOverhaulState.Reaper = __instance;
			reaperOverhaulState.Enemy = ((Component)__instance).GetComponent<Enemy>();
			reaperOverhaulState.UpdateState = (Action<State>)AccessTools.Method(typeof(EnemyRunner), "UpdateState", (Type[])null, (Type[])null).CreateDelegate(typeof(Action<State>), __instance);
			reaperOverhaulState.VisionBlocked = (Func<bool>)AccessTools.Method(typeof(EnemyRunner), "VisionBlocked", (Type[])null, (Type[])null).CreateDelegate(typeof(Func<bool>), __instance);
		}

		public static void OnHurtPostfix(EnemyRunner __instance)
		{
			//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)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//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)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Invalid comparison between Unknown and I4
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			State currentState = __instance.currentState;
			State val = currentState;
			if (val - 7 <= 2)
			{
				ReaperOverhaulState component = ((Component)__instance).GetComponent<ReaperOverhaulState>();
				int num = component.PrevHealth - (int)component.EnemyHealth.Get<EnemyHealth>("healthCurrent");
				component.Aggro -= num;
				if (component.Aggro <= 0f)
				{
					component.UpdateState((State)16);
					component.HurtAggroCooldown = 3f;
					component.RunningTimer = 5f;
					component.EnemyAnim.sfxJump.Play(((Component)__instance).transform.position, 1.5f, 1f, 1f, 1f);
				}
			}
		}

		public static bool StateAttackPlayerPrefix(EnemyRunner __instance)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_030d: Unknown result type (might be due to invalid IL or missing references)
			ReaperOverhaulState component = ((Component)__instance).GetComponent<ReaperOverhaulState>();
			if (component.HurtAggroCooldown > 0f)
			{
				component.UpdateState((State)16);
				return false;
			}
			PlayerAvatar val = (PlayerAvatar)__instance.Get<EnemyRunner>("targetPlayer");
			bool flag = (bool)__instance.Get<EnemyRunner>("stateImpulse");
			float num = (float)__instance.Get<EnemyRunner>("stateTimer");
			if (flag)
			{
				__instance.Set<EnemyRunner>("stateImpulse", false);
				__instance.Set<EnemyRunner>("stateTimer", 2f);
				num = 2f;
				component.RetargetTimer = 0f;
				component.ChaseTime = 0f;
			}
			component.Aggro += Time.deltaTime;
			component.ChaseTime += Time.deltaTime;
			component.RetargetTimer -= Time.deltaTime;
			if (component.RetargetTimer <= 0f)
			{
				component.RetargetTimer = 0.2f;
				if ((bool)val.tumble.Get<PlayerTumble>("isTumbling"))
				{
					component.SetPlayerDamage((int)component.ChaseTime);
				}
				else
				{
					component.SetPlayerDamage((int)component.ChaseTime + 10);
				}
				float num2 = 1f + component.ChaseTime / 5f;
				component.OverrideMovement(num2, num2 * 3f, num2 * 3f, 0.25f);
				component.EnemyNavAgent.SetDestination(((Component)val).transform.position);
			}
			if (!component.EnemyNavAgent.CanReach(((Component)val).transform.position, 0.25f) && Vector3.Distance(((Component)component.EnemyRigidbody).transform.position, component.EnemyNavAgent.GetPoint()) < 2f && ((Component)val).transform.position.y > ((Component)component.EnemyRigidbody).transform.position.y - 0.8f)
			{
				component.EnemyJump.StuckTrigger(((Component)val).transform.position - component.EnemyVision.VisionTransform.position);
			}
			if (!(bool)component.EnemyJump.Get<EnemyJump>("jumping") && (float)component.EnemyRigidbody.Get<EnemyRigidbody>("notMovingTimer") > 2f)
			{
				component.EnemyJump.StuckTrigger(((Component)val).transform.position - component.FeetTransform.position);
			}
			if (num > 1.5f && (bool)val.Get<PlayerAvatar>("isCrawling") && !(bool)val.Get<PlayerAvatar>("isTumbling") && (double)Vector3.Distance(component.EnemyNavAgent.GetPoint(), ((Component)val).transform.position) > 0.5 && Vector3.Distance(((Component)val).transform.position, (Vector3)val.Get<PlayerAvatar>("LastNavmeshPosition")) < 2f)
			{
				component.SetPlayerDamage(20);
				component.UpdateState((State)12);
				return false;
			}
			if (num <= 0f)
			{
				component.UpdateState((State)1);
			}
			return false;
		}
	}
	public class ReaperOverhaulState : MonoBehaviour
	{
		public Action<State> UpdateState;

		public Func<bool> VisionBlocked;

		public EnemyRunner Reaper;

		public EnemyRunnerAnim EnemyAnim;

		public Enemy Enemy;

		public Transform FeetTransform;

		public PhotonView PhotonView;

		public EnemyHealth EnemyHealth;

		public EnemyVision EnemyVision;

		public EnemyJump EnemyJump;

		public EnemyNavMeshAgent EnemyNavAgent;

		public EnemyRigidbody EnemyRigidbody;

		public float RetargetTimer = 0f;

		public float ChaseTime = 0f;

		public float HurtAggroCooldown = 0f;

		public float Aggro = 0f;

		public float RunningTimer = 0f;

		public int PrevHealth = 0;

		public int PlayerDamage = 0;

		public void Awake()
		{
			PhotonView = ((Component)this).GetComponent<PhotonView>();
		}

		public void Start()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: 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
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected O, but got Unknown
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Expected O, but got Unknown
			FeetTransform = Reaper.feetTransform;
			EnemyAnim = Reaper.animator;
			EnemyVision = (EnemyVision)Enemy.Get<Enemy>("Vision");
			EnemyJump = (EnemyJump)Enemy.Get<Enemy>("Jump");
			EnemyNavAgent = (EnemyNavMeshAgent)Enemy.Get<Enemy>("NavMeshAgent");
			EnemyRigidbody = (EnemyRigidbody)Enemy.Get<Enemy>("Rigidbody");
			EnemyHealth = (EnemyHealth)Enemy.Get<Enemy>("Health");
			Reaper.hurtCollider.physHitForce = 3f;
			Reaper.hurtCollider.physHitTorque = 10f;
			Reaper.hurtCollider.playerTumbleForce = 2f;
		}

		public void Update()
		{
			PrevHealth = (int)EnemyHealth.Get<EnemyHealth>("healthCurrent");
			HurtAggroCooldown -= Time.deltaTime;
			RunningTimer -= Time.deltaTime;
			Reaper.hurtCollider.playerDamage = PlayerDamage;
		}

		public void OverrideMovement(float speed, float acceleration, float rigidbodyAcceleration, float time)
		{
			EnemyNavAgent.OverrideAgent(speed, acceleration, time);
			EnemyRigidbody.OverrideFollowPosition(time, rigidbodyAcceleration, -1f);
		}

		[PunRPC]
		public void SetPlayerDamage(int damage)
		{
			if (SemiFunc.IsMasterClient())
			{
				PhotonView.RPC("SetPlayerDamage", (RpcTarget)1, new object[1] { damage });
			}
			PlayerDamage = damage;
		}
	}
	public static class RobeOverhaul
	{
		public static ConfigEntry<bool> OverhaulAI;

		public static void Init()
		{
			OverhaulAI = Plugin.BindConfig("Robe", "OverhaulAI", defaultValue: true, "If true, Robe AI is overhauled", delegate
			{
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: Expected O, but got Unknown
				Plugin.SetPatch(OverhaulAI.Value, AccessTools.Method(typeof(EnemyRobe), "Awake", (Type[])null, (Type[])null), new HarmonyMethod(typeof(RobeOverhaul), "AwakePrefix", (Type[])null));
			});
		}

		public static bool AwakePrefix(EnemyRobe __instance)
		{
			RobeOverride robeOverride = ((Component)__instance).gameObject.AddComponent<RobeOverride>();
			robeOverride.RotationSpring = __instance.rotationSpring;
			robeOverride.Animator = ((Component)__instance.robeAnim).GetComponent<Animator>();
			robeOverride.deathParticles = __instance.robeAnim.deathParticles;
			robeOverride.spawnParticles = __instance.robeAnim.spawnParticles;
			robeOverride.sfxTargetPlayerLoop = __instance.robeAnim.sfxTargetPlayerLoop;
			robeOverride.sfxIdleBreak = __instance.robeAnim.sfxIdleBreak;
			robeOverride.sfxAttack = __instance.robeAnim.sfxAttack;
			robeOverride.sfxAttackGlobal = __instance.robeAnim.sfxAttackGlobal;
			robeOverride.sfxHurt = __instance.robeAnim.sfxHurt;
			robeOverride.sfxHandIdle = __instance.robeAnim.sfxHandIdle;
			robeOverride.sfxHandAggressive = __instance.robeAnim.sfxHandAggressive;
			robeOverride.sfxStunStart = __instance.robeAnim.sfxStunStart;
			robeOverride.sfxStunLoop = __instance.robeAnim.sfxStunLoop;
			robeOverride.sfxAttackUnder = __instance.robeAnim.sfxAttackUnder;
			robeOverride.sfxAttackUnderGlobal = __instance.robeAnim.sfxAttackUnderGlobal;
			Object.Destroy((Object)(object)__instance.robeAnim);
			Object.Destroy((Object)(object)__instance);
			return false;
		}
	}
	public class RobeOverride : MonoBehaviour
	{
		public enum RobeState
		{
			Spawn,
			Idle,
			Investigate,
			Shifty,
			Roam,
			FollowPlayer,
			HelpPlayer,
			ChaseBegin,
			Chase,
			Attack,
			AttackUnderBegin,
			AttackUnder,
			GiveSpace
		}

		public enum RobeAggroMode
		{
			None,
			All
		}

		public enum RobeFocusMode
		{
			None,
			Player
		}

		public record struct TrackedValuable(ValuableObject Valuable, UnityAction BreakListener);

		public StateMachine<RobeState> State;

		public float LastFocusedPlayerVisionTimer = float.PositiveInfinity;

		public float ItemBreakLogicTimer = 0f;

		public RobeAggroMode AggroMode = RobeAggroMode.All;

		public RobeFocusMode FocusMode = RobeFocusMode.Player;

		public Enemy Enemy;

		public EnemyParent EnemyParent;

		public PhotonView PhotonView;

		public EnemyVision Vision;

		public EnemyRigidbody Rigidbody;

		public Animator Animator;

		public HurtCollider HurtCollider;

		public EnemyNavMeshAgent EnemyAgent;

		public PlayerAvatar FocusedPlayer;

		public AggroHandler Aggro = new AggroHandler();

		public SpringQuaternion RotationSpring;

		private EnemyStateInvestigate StateInvestigate;

		public ValuableObject TargetValuable;

		public List<TrackedValuable> TrackedValuables = new List<TrackedValuable>();

		public Quaternion RotationTarget;

		public ParticleSystem[] deathParticles;

		public ParticleSystem spawnParticles;

		public Sound sfxTargetPlayerLoop;

		public Sound sfxIdleBreak;

		public Sound sfxAttack;

		public Sound sfxAttackGlobal;

		public Sound sfxHurt;

		public Sound sfxHandIdle;

		public Sound sfxHandAggressive;

		public Sound sfxStunStart;

		public Sound sfxStunLoop;

		public Sound sfxAttackUnder;

		public Sound sfxAttackUnderGlobal;

		[PunRPC]
		public void SetState(RobeState state, float stateTimer)
		{
			if (State.SetState(state, stateTimer) && SemiFunc.IsMasterClient() && SemiFunc.IsMultiplayer())
			{
				PhotonView.RPC("SetState", (RpcTarget)1, new object[2] { state, stateTimer });
			}
		}

		public void SyncFields()
		{
			if (GameManager.Multiplayer())
			{
				PhotonView.RPC("SyncFieldsRPC", (RpcTarget)1, new object[2]
				{
					Object.op_Implicit((Object)(object)FocusedPlayer) ? FocusedPlayer.photonView.ViewID : (-1),
					Object.op_Implicit((Object)(object)TargetValuable) ? ((Component)TargetValuable).GetComponent<PhotonView>().ViewID : (-1)
				});
			}
		}

		[PunRPC]
		private void SyncFieldsRPC(int focusedPlayerID, int targetValuableID)
		{
			FocusedPlayer = ((focusedPlayerID == -1) ? null : ((Component)PhotonView.Find(focusedPlayerID)).GetComponent<PlayerAvatar>());
			TargetValuable = ((targetValuableID == -1) ? null : ((Component)PhotonView.Find(targetValuableID)).GetComponent<ValuableObject>());
		}

		public void Awake()
		{
			Enemy = ((Component)this).GetComponent<Enemy>();
			PhotonView = ((Component)this).GetComponent<PhotonView>();
			State = new StateMachine<RobeState>(StateMachine);
			State.State = RobeState.Spawn;
		}

		public void Start()
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Expected O, but got Unknown
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Expected O, but got Unknown
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Expected O, but got Unknown
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Expected O, but got Unknown
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Expected O, but got Unknown
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Expected O, but got Unknown
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Expected O, but got Unknown
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Expected O, but got Unknown
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Expected O, but got Unknown
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Expected O, but got Unknown
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Expected O, but got Unknown
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Expected O, but got Unknown
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Expected O, but got Unknown
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Expected O, but got Unknown
			HurtCollider = Utils.GetHurtColliders(((Component)this).transform.parent)[0];
			Rigidbody = (EnemyRigidbody)Enemy.Get<Enemy>("Rigidbody");
			EnemyAgent = (EnemyNavMeshAgent)Enemy.Get<Enemy>("NavMeshAgent");
			Vision = (EnemyVision)Enemy.Get<Enemy>("Vision");
			EnemyParent = (EnemyParent)Enemy.Get<Enemy>("EnemyParent");
			((Behaviour)((Component)EnemyParent).GetComponentInChildren<EnemyRobePersistent>()).enabled = false;
			if (!SemiFunc.IsMasterClientOrSingleplayer())
			{
				return;
			}
			EnemyHealth health = ((Component)this).GetComponent<EnemyHealth>();
			EnemyStateSpawn component = ((Component)this).GetComponent<EnemyStateSpawn>();
			EnemyStateDespawn component2 = ((Component)this).GetComponent<EnemyStateDespawn>();
			EnemyStateStunned component3 = ((Component)this).GetComponent<EnemyStateStunned>();
			StateInvestigate = ((Component)this).GetComponent<EnemyStateInvestigate>();
			Vision.onVisionTriggered.AddListener((UnityAction)delegate
			{
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				//IL_002f: Expected O, but got Unknown
				//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d0: Expected O, but got Unknown
				//IL_010f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0115: Invalid comparison between Unknown and I4
				//IL_011e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0124: Invalid comparison between Unknown and I4
				//IL_012d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0134: Invalid comparison between Unknown and I4
				//IL_013d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0144: Invalid comparison between Unknown and I4
				if (FocusMode == RobeFocusMode.Player)
				{
					PlayerAvatar val = (PlayerAvatar)Vision.Get<EnemyVision>("onVisionTriggeredPlayer");
					if ((Object)(object)FocusedPlayer == (Object)null)
					{
						FocusedPlayer = val;
						LastFocusedPlayerVisionTimer = 0f;
					}
					else if ((Object)(object)FocusedPlayer == (Object)(object)val)
					{
						LastFocusedPlayerVisionTimer = 0f;
					}
				}
				else
				{
					LastFocusedPlayerVisionTimer = float.PositiveInfinity;
				}
				if (AggroMode == RobeAggroMode.All)
				{
					PlayerAvatar val2 = (PlayerAvatar)Vision.Get<EnemyVision>("onVisionTriggeredPlayer");
					if (val2.physGrabber.grabbed)
					{
						ItemAttributes component4 = ((Component)val2.physGrabber.Get<PhysGrabObject, PhysGrabber>("grabbedPhysGrabObject")).GetComponent<ItemAttributes>();
						if (component4 != null && ((int)component4.item.itemType == 6 || (int)component4.item.itemType == 7 || (int)component4.item.itemType == 9 || (int)component4.item.itemType == 11))
						{
							Aggro.GetAggro(val2).Aggro += (float)Vision.Get<EnemyVision>("VisionCheckTime") * 6f;
						}
					}
				}
			});
			Rigidbody.onGrabbed.AddListener((UnityAction)delegate
			{
				//IL_0038: Unknown result type (might be due to invalid IL or missing references)
				//IL_0042: Expected O, but got Unknown
				if (AggroMode == RobeAggroMode.All)
				{
					Aggro.GetAggro((PlayerAvatar)Rigidbody.Get<EnemyRigidbody>("onGrabbedPlayerAvatar")).Aggro += Time.deltaTime * 5f;
				}
			});
			Rigidbody.onTouchPlayer.AddListener((UnityAction)delegate
			{
				//IL_0038: Unknown result type (might be due to invalid IL or missing references)
				//IL_0042: Expected O, but got Unknown
				if (AggroMode == RobeAggroMode.All)
				{
					Aggro.GetAggro((PlayerAvatar)Rigidbody.Get<EnemyRigidbody>("onTouchPlayerAvatar")).Aggro += Time.deltaTime * 5f;
				}
			});
			Rigidbody.onTouchPlayerGrabbedObject.AddListener((UnityAction)delegate
			{
				//IL_0038: Unknown result type (might be due to invalid IL or missing references)
				//IL_0042: Expected O, but got Unknown
				if (AggroMode == RobeAggroMode.All)
				{
					Aggro.GetAggro((PlayerAvatar)Rigidbody.Get<EnemyRigidbody>("onTouchPlayerGrabbedObjectAvatar")).Aggro += Time.deltaTime * 5f;
				}
			});
			health.onHurt.AddListener((UnityAction)delegate
			{
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				sfxHurt.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
				if (AggroMode == RobeAggroMode.All)
				{
					for (int j = 0; j < Aggro.AggroList.Count; j++)
					{
						Aggro.AggroList[j].Aggro += 15f;
					}
				}
			});
			health.onObjectHurt.AddListener((UnityAction)delegate
			{
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_003d: Expected O, but got Unknown
				if (AggroMode == RobeAggroMode.All)
				{
					Aggro.GetAggro((PlayerAvatar)health.Get<EnemyHealth>("onObjectHurtPlayer")).Aggro += 15f;
				}
			});
			health.onDeath.AddListener((UnityAction)delegate
			{
				Animator.SetTrigger("Death");
				ParticleSystem[] array = deathParticles;
				for (int i = 0; i < array.Length; i++)
				{
					array[i].Play();
				}
				if (Utils.IsHost())
				{
					EnemyParent.Despawn();
				}
			});
			component.OnSpawn.AddListener((UnityAction)delegate
			{
				Aggro.LoseAggro(float.PositiveInfinity);
				if (SemiFunc.IsMasterClientOrSingleplayer())
				{
					SetState(RobeState.Spawn, 0.5f);
				}
			});
			component2.OnDespawn.AddListener((UnityAction)delegate
			{
				Animator.SetTrigger("despawn");
			});
			component3.onStunnedStart.AddListener((UnityAction)delegate
			{
				Animator.SetTrigger("Stun");
				Animator.SetBool("Stunned", true);
				sfxStunLoop.PlayLoop(true, 2f, 2f, 1f);
			});
			component3.onStunnedEnd.AddListener((UnityAction)delegate
			{
				Animator.SetBool("Stunned", false);
				sfxStunLoop.PlayLoop(false, 2f, 2f, 1f);
			});
			StateInvestigate.onInvestigateTriggered.AddListener((UnityAction)delegate
			{
				RobeState state = State.State;
				RobeState robeState = state;
				if ((uint)robeState <= 1u || robeState == RobeState.Roam)
				{
					SetState(RobeState.Investigate, Random.Range(4f, 6f));
				}
			});
		}

		public void Update()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Invalid comparison between Unknown and I4
			//IL_0088: 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)
			EnemyParent.SpawnedTimerPause(float.PositiveInfinity);
			if ((int)Enemy.CurrentState != 9)
			{
				LastFocusedPlayerVisionTimer += Time.deltaTime;
				if (SemiFunc.IsMasterClientOrSingleplayer())
				{
					ItemBreakTrackingLogic();
					ExtractionAggroLogic();
				}
				AggroLogic();
				State.Update(Time.deltaTime);
				Aggro.LoseAggro(Time.deltaTime);
				((Component)this).transform.rotation = SemiFunc.SpringQuaternionGet(RotationSpring, RotationTarget, -1f);
			}
		}

		public void StateMachine()
		{
			//IL_02af: 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_04ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ea7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ed2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fdd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fe2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ff1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_036f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0374: Unknown result type (might be due to invalid IL or missing references)
			//IL_0379: Unknown result type (might be due to invalid IL or missing references)
			//IL_04db: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0602: Unknown result type (might be due to invalid IL or missing references)
			//IL_0607: Unknown result type (might be due to invalid IL or missing references)
			//IL_0611: Unknown result type (might be due to invalid IL or missing references)
			//IL_0616: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d71: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e31: Unknown result type (might be due to invalid IL or missing references)
			//IL_1013: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0406: Unknown result type (might be due to invalid IL or missing references)
			//IL_069e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0862: Unknown result type (might be due to invalid IL or missing references)
			//IL_087d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0884: Expected O, but got Unknown
			//IL_088a: Unknown result type (might be due to invalid IL or missing references)
			//IL_089a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a76: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f51: Unknown result type (might be due to invalid IL or missing references)
			//IL_039e: Unknown result type (might be due to invalid IL or missing references)
			//IL_050a: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_063b: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c07: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c17: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bbf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_0be4: Unknown result type (might be due to invalid IL or missing references)
			//IL_093d: 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_0958: Unknown result type (might be due to invalid IL or missing references)
			//IL_095d: 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_0966: Unknown result type (might be due to invalid IL or missing references)
			//IL_0970: Unknown result type (might be due to invalid IL or missing references)
			//IL_0975: Unknown result type (might be due to invalid IL or missing references)
			//IL_0992: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val;
			float num5;
			switch (State.State)
			{
			case RobeState.Spawn:
				if (State.ConsumeStateImpulse())
				{
					SemiFunc.EnemySpawn(Enemy);
					AggroMode = RobeAggroMode.All;
					Animator.Play("Robe Spawn", 0, 0f);
					spawnParticles.Play();
				}
				if (!SemiFunc.IsMasterClientOrSingleplayer())
				{
				}
				if (State.StateTimer <= 0f)
				{
					SetState(RobeState.Idle, 1f);
				}
				break;
			case RobeState.Idle:
				if (State.ConsumeStateImpulse())
				{
					AggroMode = RobeAggroMode.All;
					EnemyAgent.ResetPath();
				}
				if ((Object)(object)FocusedPlayer != (Object)null)
				{
					LookAt(((Component)FocusedPlayer).transform.position);
				}
				if (!SemiFunc.IsMasterClientOrSingleplayer() || LosePlayerLogic() || !(State.StateTimer <= 0f))
				{
					break;
				}
				if ((Object)(object)FocusedPlayer != (Object)null)
				{
					float num4 = Utils.WeightedDistance(((Component)this).transform.position, ((Component)FocusedPlayer).transform.position, 1f, 0.2f);
					if (FocusedPlayer.physGrabber.grabbed)
					{
						object obj = FocusedPlayer.physGrabber.Get<PhysGrabber>("grabbedPhysGrabObject");
						PhysGrabObject val4 = (PhysGrabObject)((obj is PhysGrabObject) ? obj : null);
						if (val4 != null && (Object)(object)(TargetValuable = ((Component)val4).GetComponent<ValuableObject>()) != (Object)null)
						{
							SetState(RobeState.HelpPlayer, Random.Range(40f, 70f));
							SyncFields();
							break;
						}
					}
					if (num4 > 5f || num4 < 2.5f)
					{
						SetState(RobeState.FollowPlayer, Random.Range(10f, 12f));
					}
					else
					{
						SetState(RobeState.Shifty, 3f);
					}
				}
				else
				{
					SetState(RobeState.Roam, Random.Range(4f, 9f));
				}
				break;
			case RobeState.Investigate:
				if (State.ConsumeStateImpulse())
				{
					AggroMode = RobeAggroMode.All;
					if (Utils.FindNavPosition((Vector3)StateInvestigate.Get<EnemyStateInvestigate>("onInvestigateTriggeredPosition"), out var navPosition5))
					{
						EnemyAgent.SetDestination(navPosition5);
					}
					else
					{
						State.StateStartImpulse = true;
					}
				}
				NormalRotationLogic();
				if (Utils.IsHost() && State.StateTimer <= 0f)
				{
					SetState(RobeState.Idle, 1f);
				}
				break;
			case RobeState.Shifty:
			{
				if (State.ConsumeStateImpulse())
				{
					AggroMode = RobeAggroMode.All;
					LevelPoint val2 = SemiFunc.LevelPointGet(((Component)this).transform.position, 1f, 4f);
					if (val2 != null && Utils.FindNavPosition(((Component)val2).transform.position + Random.insideUnitSphere, out var navPosition3))
					{
						EnemyAgent.SetDestination(navPosition3);
					}
					OverrideMovement(0.75f, 1f, 1f);
				}
				if (State.StateEndImpulse)
				{
					EndMovementOverride();
				}
				NormalRotationLogic();
				float num = (Object.op_Implicit((Object)(object)FocusedPlayer) ? Utils.WeightedDistance(((Component)this).transform.position, ((Component)FocusedPlayer).transform.position, 1f, 0.2f) : 3f);
				if (SemiFunc.IsMasterClientOrSingleplayer())
				{
					if (LosePlayerLogic())
					{
						SetState(RobeState.Idle, Random.Range(0.25f, 0.5f));
					}
					else if (num < 2f || num > 5f || State.StateTimer <= 0f)
					{
						SetState(RobeState.Idle, 1f);
					}
				}
				break;
			}
			case RobeState.Roam:
				if (State.ConsumeStateImpulse())
				{
					AggroMode = RobeAggroMode.All;
					LevelPoint val5 = SemiFunc.LevelPointGet(((Component)this).transform.position, 3f, 10f);
					if (val5 != null && Utils.FindNavPosition(((Component)val5).transform.position + Random.insideUnitSphere, out var navPosition7))
					{
						EnemyAgent.SetDestination(navPosition7);
					}
				}
				NormalRotationLogic();
				if (SemiFunc.IsMasterClientOrSingleplayer())
				{
					if ((Object)(object)FocusedPlayer != (Object)null)
					{
						SetState(RobeState.FollowPlayer, 3f);
					}
					else if (!EnemyAgent.HasPath() || State.StateTimer <= 0f)
					{
						SetState(RobeState.Idle, Random.Range(1f, 2f));
					}
				}
				break;
			case RobeState.FollowPlayer:
				if (State.ConsumeStateImpulse())
				{
					AggroMode = RobeAggroMode.All;
					if ((Object)(object)FocusedPlayer != (Object)null)
					{
						Vector3 position = ((Component)FocusedPlayer).transform.position;
						val = ((Component)this).transform.position - ((Component)FocusedPlayer).transform.position;
						if (Utils.FindNavPosition(position + ((Vector3)(ref val)).normalized * 3f + Random.insideUnitSphere * 0.5f, out var navPosition2))
						{
							EnemyAgent.SetDestination(navPosition2);
							goto IL_0651;
						}
					}
					State.StateStartImpulse = true;
					goto IL_0651;
				}
				goto IL_0668;
			case RobeState.HelpPlayer:
				if (State.ConsumeStateImpulse())
				{
					AggroMode = RobeAggroMode.All;
					sfxHandIdle.PlayLoop(true, 2f, 2f, 0.4f);
					OverrideMovement(1f, 2f, 3f);
					EnemyAgent.ResetPath();
					State.SetStateTimer(0, 0f);
				}
				if (State.StateEndImpulse)
				{
					sfxHandIdle.PlayLoop(false, 2f, 2f, 0.4f);
					EndMovementOverride();
				}
				if ((Object)(object)TargetValuable != (Object)null)
				{
					LookAt(((Component)TargetValuable).transform.position);
					Rigidbody val3 = (Rigidbody)TargetValuable.Get<ValuableObject>("rb");
					float num3 = Utils.WeightedDistance(((Component)this).transform.position, ((Component)FocusedPlayer).transform.position, 1f, 0.2f);
					if (num3 < 4.5f)
					{
						val3.AddForce(new Vector3(0f, Mathf.Min(val3.mass, 5f), 0f), (ForceMode)0);
					}
					if ((num3 < 1.8f || num3 > 2.6f) && State.GetStateTimer(0) <= 0f)
					{
						State.SetStateTimer(0, 0.1f);
						Vector3 position2 = ((Component)TargetValuable).transform.position;
						val = ((Component)this).transform.position - ((Component)TargetValuable).transform.position;
						Utils.FindNavPosition(position2 + ((Vector3)(ref val)).normalized * 1.5f, out var navPosition6, 3f);
						EnemyAgent.SetDestination(navPosition6);
					}
				}
				if (SemiFunc.IsMasterClientOrSingleplayer() && (State.StateTimer <= 0f || ((Object)(object)FocusedPlayer != (Object)null && !FocusedPlayer.physGrabber.grabbed)))
				{
					SetState(RobeState.Idle, 1f);
				}
				break;
			case RobeState.ChaseBegin:
				if (State.ConsumeStateImpulse())
				{
					AggroMode = RobeAggroMode.None;
					((Behaviour)HurtCollider).enabled = false;
					EnemyAgent.ResetPath();
					AttackAnimation();
				}
				if (State.StateEndImpulse)
				{
					((Behaviour)HurtCollider).enabled = true;
				}
				if ((Object)(object)FocusedPlayer != (Object)null)
				{
					LookAt(((Component)FocusedPlayer).transform.position);
				}
				if (SemiFunc.IsMasterClientOrSingleplayer() && State.StateTimer <= 0f)
				{
					SetState(RobeState.Chase, Random.Range(10f, 14f));
				}
				break;
			case RobeState.Chase:
			{
				if (State.ConsumeStateImpulse())
				{
					AggroMode = RobeAggroMode.None;
					sfxTargetPlayerLoop.PlayLoop(true, 2f, 2f, 2f);
					OverrideMovement(6f, 10f, 20f);
					State.SetStateTimer(0, 0f);
				}
				if (State.StateEndImpulse)
				{
					EndMovementOverride();
					sfxTargetPlayerLoop.PlayLoop(false, 2f, 2f, 2f);
					Aggro.LoseAggro(float.PositiveInfinity);
				}
				NormalRotationLogic();
				if (State.GetStateTimer(0) <= 0f)
				{
					State.SetStateTimer(0, 0.1f);
					if ((Object)(object)FocusedPlayer != (Object)null && Utils.FindNavPosition(((Component)FocusedPlayer).transform.position, out var navPosition4))
					{
						EnemyAgent.SetDestination(navPosition4);
					}
				}
				float num2 = (Object.op_Implicit((Object)(object)FocusedPlayer) ? Utils.WeightedDistance(((Component)this).transform.position, ((Component)FocusedPlayer).transform.position, 1f, 0.2f) : 10f);
				bool flag = Object.op_Implicit((Object)(object)FocusedPlayer) && (bool)FocusedPlayer.Get<PlayerAvatar>("isCrawling");
				if (SemiFunc.IsMasterClientOrSingleplayer())
				{
					if (LastFocusedPlayerVisionTimer > 8f)
					{
						FocusedPlayer = null;
						SyncFields();
						SetState(RobeState.GiveSpace, 2f);
					}
					else if (num2 < 1.5f && !flag)
					{
						SetState(RobeState.Attack, 1f);
					}
					else if (num2 < 2f && flag)
					{
						SetState(RobeState.AttackUnderBegin, 0.5f);
					}
					else if (State.StateTimer <= 0f)
					{
						SetState(RobeState.GiveSpace, 2f);
					}
				}
				break;
			}
			case RobeState.Attack:
				if (State.ConsumeStateImpulse())
				{
					AggroMode = RobeAggroMode.None;
					AttackAnimation();
					EnemyAgent.ResetPath();
				}
				HurtCollider.playerDamage = 120;
				if ((Object)(object)FocusedPlayer != (Object)null)
				{
					LookAt(((Component)FocusedPlayer).transform.position);
				}
				if (SemiFunc.IsMasterClientOrSingleplayer() && State.StateTimer <= 0f)
				{
					SetState(RobeState.GiveSpace, 2f);
				}
				break;
			case RobeState.AttackUnderBegin:
				if (State.ConsumeStateImpulse())
				{
					AggroMode = RobeAggroMode.None;
					EnemyAgent.ResetPath();
					Animator.SetTrigger("LookUnder");
					Animator.SetBool("LookingUnder", true);
				}
				HurtCollider.playerDamage = 80;
				if ((Object)(object)FocusedPlayer != (Object)null)
				{
					LookAt(((Component)FocusedPlayer).transform.position);
				}
				if (!SemiFunc.IsMasterClientOrSingleplayer())
				{
				}
				if (State.StateTimer <= 0f)
				{
					SetState(RobeState.AttackUnder, 0.5f);
				}
				break;
			case RobeState.AttackUnder:
				if (State.ConsumeStateImpulse())
				{
					AggroMode = RobeAggroMode.None;
					AttackShake();
					sfxAttackUnder.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
					sfxAttackUnderGlobal.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
					Animator.SetTrigger("LookUnderAttack");
				}
				if (State.StateEndImpulse)
				{
					Animator.SetBool("LookingUnder", false);
				}
				HurtCollider.playerDamage = 80;
				if ((Object)(object)FocusedPlayer != (Object)null)
				{
					LookAt(((Component)FocusedPlayer).transform.position);
				}
				if (SemiFunc.IsMasterClientOrSingleplayer() && State.StateTimer <= 0f)
				{
					SetState(RobeState.GiveSpace, 2f);
				}
				break;
			case RobeState.GiveSpace:
				{
					if (State.ConsumeStateImpulse())
					{
						AggroMode = RobeAggroMode.All;
						sfxTargetPlayerLoop.PlayLoop(true, 2f, 2f, 2f);
						if (Utils.FindNavPosition(((Component)EnemyAgent).transform.position + Random.onUnitSphere * 4f, out var navPosition))
						{
							EnemyAgent.SetDestination(navPosition);
						}
						else
						{
							State.StateStartImpulse = true;
						}
					}
					if (State.StateEndImpulse)
					{
						sfxTargetPlayerLoop.PlayLoop(false, 2f, 2f, 2f);
					}
					NormalRotationLogic();
					if (SemiFunc.IsMasterClientOrSingleplayer() && State.StateTimer <= 0f)
					{
						SetState(RobeState.Idle, 2f);
					}
					break;
				}
				IL_0651:
				OverrideMovement(2f, 6f, 20f);
				goto IL_0668;
				IL_0668:
				if (State.StateEndImpulse)
				{
					EndMovementOverride();
				}
				if ((Object)(object)FocusedPlayer != (Object)null)
				{
					LookAt(((Component)FocusedPlayer).transform.position);
				}
				num5 = (Object.op_Implicit((Object)(object)FocusedPlayer) ? Utils.WeightedDistance(((Component)this).transform.position, ((Component)FocusedPlayer).transform.position, 1f, 0.2f) : 3f);
				if (SemiFunc.IsMasterClientOrSingleplayer())
				{
					if (LosePlayerLogic())
					{
						SetState(RobeState.Idle, Random.Range(0.25f, 0.5f));
					}
					else if (num5 > 10f)
					{
						SetState(RobeState.ChaseBegin, Random.Range(0.25f, 0.5f));
					}
					else if ((num5 < 3.5f && num5 > 2.5f) || !EnemyAgent.HasPath() || State.StateTimer <= 0f)
					{
						SetState(RobeState.Idle, 0f);
					}
				}
				break;
			}
		}

		public void ItemBreakTrackingLogic()
		{
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Expected O, but got Unknown
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Expected O, but got Unknown
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Expected O, but got Unknown
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Expected O, but got Unknown
			ItemBreakLogicTimer += Time.deltaTime;
			if (ItemBreakLogicTimer < 1f)
			{
				return;
			}
			ItemBreakLogicTimer = 0f;
			for (int i = 0; i < TrackedValuables.Count; i++)
			{
				_ = TrackedValuables[i];
				if (false)
				{
					TrackedValuables.RemoveAt(i);
				}
			}
			for (int j = 0; j < ValuableDirector.instance.valuableList.Count; j++)
			{
				ValuableObject valuable = ValuableDirector.instance.valuableList[j];
				if ((Object)(object)valuable == (Object)null)
				{
					continue;
				}
				float num = Vector3.Distance(((Component)valuable).transform.position, ((Component)this).transform.position);
				int num2 = -1;
				for (int k = 0; k < TrackedValuables.Count; k++)
				{
					if ((Object)(object)TrackedValuables[k].Valuable == (Object)(object)valuable)
					{
						num2 = k;
					}
				}
				if (num > 6f && num2 != -1)
				{
					PhysGrabObjectImpactDetector val = (PhysGrabObjectImpactDetector)valuable.Get<PhysGrabObject, ValuableObject>("physGrabObject").Get<PhysGrabObject>("impactDetector");
					val.onAllBreaks.RemoveListener(TrackedValuables[num2].BreakListener);
					TrackedValuables.RemoveAt(num2);
				}
				else
				{
					if (!(num <= 4f) || num2 != -1)
					{
						continue;
					}
					PhysGrabObject physGrabObject = (PhysGrabObject)valuable.Get<ValuableObject>("physGrabObject");
					PhysGrabObjectImpactDetector impactDetector = (PhysGrabObjectImpactDetector)physGrabObject.Get<PhysGrabObject>("impactDetector");
					UnityAction val2 = (UnityAction)delegate
					{
						//IL_0083: Unknown result type (might be due to invalid IL or missing references)
						//IL_008d: Expected O, but got Unknown
						if (AggroMode == RobeAggroMode.All && !(bool)impactDetector.Get<PhysGrabObjectImpactDetector>("isIndestructible") && !impactDetector.destroyDisable && !((float)physGrabObject.Get<PhysGrabObject>("grabbedTimer") <= 0f))
						{
							PlayerAggro aggro = Aggro.GetAggro((PlayerAvatar)physGrabObject.Get<PhysGrabObject>("lastPlayerGrabbing"));
							aggro.Aggro += (physGrabObject.dead ? (valuable.dollarValueOriginal / 100f) : ((valuable.dollarValueOriginal - valuable.dollarValueCurrent) / 100f));
						}
					};
					TrackedValuables.Add(new TrackedValuable(valuable, val2));
					impactDetector.onAllBreaks.AddListener(val2);
				}
			}
		}

		public void AggroLogic()
		{
			if (AggroMode == RobeAggroMode.None)
			{
				return;
			}
			PlayerAggro playerAggro = null;
			for (int i = 0; i < Aggro.AggroList.Count; i++)
			{
				PlayerAggro playerAggro2 = Aggro.AggroList[i];
				if (playerAggro == null || playerAggro2.Aggro > playerAggro.Aggro)
				{
					playerAggro = playerAggro2;
				}
			}
			if (playerAggro == null)
			{
				sfxTargetPlayerLoop.PlayLoop(false, 1f, 1f, 1f);
				return;
			}
			if (playerAggro.Aggro > 5f)
			{
				sfxTargetPlayerLoop.PlayLoop(true, 1f, 1f, 1f);
			}
			else
			{
				sfxTargetPlayerLoop.PlayLoop(false, 1f, 1f, 1f);
			}
			if (!(playerAggro.Aggro < 10f))
			{
				sfxTargetPlayerLoop.PlayLoop(false, 1f, 1f, 1f);
				if (Utils.IsHost() && State.State != RobeState.ChaseBegin)
				{
					LastFocusedPlayerVisionTimer = 0f;
					FocusedPlayer = playerAggro.Player;
					SyncFields();
					SetState(RobeState.ChaseBegin, 1f);
				}
			}
		}

		public void ExtractionAggroLogic()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Invalid comparison between Unknown and I4
			//IL_003e: 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)
			if ((Object)(object)FocusedPlayer != (Object)null)
			{
				object obj = RoundDirector.instance.Get<RoundDirector>("extractionPointCurrent");
				ExtractionPoint val = (ExtractionPoint)((obj is ExtractionPoint) ? obj : null);
				if (val != null && (int)val.Get<State, ExtractionPoint>("currentState") == 4 && Vector3.Distance(((Component)val).transform.position, ((Component)this).transform.position) < 5f)
				{
					Aggro.GetAggro(FocusedPlayer).Aggro += Time.deltaTime * 10f;
				}
			}
		}

		public bool LosePlayerLogic()
		{
			if ((Object)(object)FocusedPlayer != (Object)null && LastFocusedPlayerVisionTimer > 10f)
			{
				FocusedPlayer = null;
				SyncFields();
				return true;
			}
			return false;
		}

		public void NormalRotationLogic()
		{
			//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_0014: 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_002d: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = EnemyAgent.Get<Vector3, EnemyNavMeshAgent>("AgentVelocity");
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			if (((Vector3)(ref normalized)).magnitude > 0.1f)
			{
				LookInDirection(normalized);
			}
		}

		public void LookAt(Vector3 point)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: 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)
			//IL_0013: 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)
			Vector3 val = point - ((Component)this).transform.position;
			LookInDirection(((Vector3)(ref val)).normalized);
		}

		public void LookInDirection(Vector3 point)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: 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_002d: Unknown result type (might be due to invalid IL or missing references)
			RotationTarget = Quaternion.LookRotation(point);
			((Quaternion)(ref RotationTarget)).eulerAngles = new Vector3(0f, ((Quaternion)(ref RotationTarget)).eulerAngles.y, 0f);
		}

		public void AttackShake()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			GameDirector.instance.CameraShake.ShakeDistance(5f, 3f, 8f, ((Component)this).transform.position, 0.5f);
			GameDirector.instance.CameraImpact.ShakeDistance(5f, 3f, 8f, ((Component)this).transform.position, 0.1f);
		}

		public void AttackSounds()
		{
			//IL_000d: 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)
			sfxAttack.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
			sfxAttackGlobal.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
		}

		public void AttackAnimation()
		{
			AttackSounds();
			AttackShake();
			Animator.SetTrigger("attack");
		}

		public void OverrideMovement(float speed, float acceleration, float rigidbodyAcceleration)
		{
			EnemyAgent.OverrideAgent(speed, acceleration, float.PositiveInfinity);
			Rigidbody.OverrideFollowPosition(float.PositiveInfinity, rigidbodyAcceleration, -1f);
		}

		public void EndMovementOverride()
		{
			EnemyAgent.OverrideAgent(0f, 0f, 0.001f);
			Rigidbody.OverrideFollowPosition(0.001f, 0f, -1f);
		}
	}
	public class StateMachine<TState> where TState : Enum
	{
		public enum StateSetMode
		{
			None,
			SetThisUpdate,
			Set
		}

		public TState State;

		public TState FutureState;

		public float StateTimer;

		public bool StateStartImpulse = false;

		public bool StateEndImpulse = false;

		public StateSetMode SetMode = StateSetMode.None;

		public Action StateMachineAction;

		public List<object> StateData;

		public List<float> StateTimers;

		public StateMachine(Action stateMachineAction)
		{
			StateMachineAction = stateMachineAction;
			StateData = new List<object>();
			StateTimers = new List<float>();
			base..ctor();
		}

		public void Update(float deltaTime)
		{
			StateTimer -= deltaTime;
			for (int i = 0; i < StateTimers.Count; i++)
			{
				StateTimers[i] -= deltaTime;
			}
			if (SetMode == StateSetMode.Set)
			{
				StateEndImpulse = true;
			}
			StateMachineAction();
			if (SetMode == StateSetMode.Set)
			{
				State = FutureState;
				StateStartImpulse = true;
				SetMode = StateSetMode.None;
				StateData.Clear();
				StateTimers.Clear();
			}
			if (SetMode == StateSetMode.SetThisUpdate)
			{
				SetMode = StateSetMode.Set;
			}
			StateEndImpulse = false;
		}

		public bool SetState(TState state, float time)
		{
			if (SetMode != 0)
			{
				return false;
			}
			StateTimer = time;
			FutureState = state;
			SetMode = StateSetMode.SetThisUpdate;
			return true;
		}

		public bool ConsumeStateImpulse()
		{
			if (StateStartImpulse)
			{
				StateStartImpulse = false;
				return true;
			}
			return false;
		}

		public T GetStateData<T>(int index)
		{
			return (T)StateData[index];
		}

		public void SetStateData<T>(int index, T value)
		{
			while (StateData.Count <= index)
			{
				StateData.Add(null);
			}
			StateData[index] = value;
		}

		public float GetStateTimer(int index)
		{
			return StateTimers[index];
		}

		public void SetStateTimer(int index, float time)
		{
			while (StateTimers.Count <= index)
			{
				StateTimers.Add(0f);
			}
			StateTimers[index] = time;
		}
	}
	public static class TrudgeOverhaul
	{
		public static ConfigEntry<bool> OverhaulAI;

		public static void Init()
		{
			OverhaulAI = Plugin.BindConfig("Trudge", "OverhaulAI", defaultValue: true, "If true, Trudge AI is overhauled", delegate
			{
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: Expected O, but got Unknown
				Plugin.SetPatch(OverhaulAI.Value, AccessTools.Method(typeof(EnemySlowWalker), "Start", (Type[])null, (Type[])null), new HarmonyMethod(typeof(TrudgeOverhaul), "StartPrefix", (Type[])null));
			});
		}

		public static bool StartPrefix(EnemySlowWalker __instance)
		{
			TrudgeOverride trudgeOverride = ((Component)__instance).gameObject.AddComponent<TrudgeOverride>();
			EnemySlowWalkerAnim animator = __instance.animator;
			((Behaviour)animator).enabled = false;
			trudgeOverride.ParticleDeathImpact = __instance.particleDeathImpact;
			trudgeOverride.ParticleDeathBitsFar = __instance.particleDeathBitsFar;
			trudgeOverride.ParticleDeathBitsShort = __instance.particleDeathBitsShort;
			trudgeOverride.ParticleDeathSmoke = __instance.particleDeathSmoke;
			trudgeOverride.FeetTransform = __instance.feetTransform;
			trudgeOverride.LookAtTransform = __instance.lookAtTransform;
			trudgeOverride.EnemyAnimator = animator;
			trudgeOverride.RotationSpring = __instance.horizontalRotationSpring;
			Object.Destroy((Object)(object)__instance);
			return false;
		}
	}
	public class TrudgeOverride : MonoBehaviour
	{
		public enum TrudgeState
		{
			Invalid,
			Spawn,
			Idle,
			ApproachTarget,
			Notice,
			ChargeBegin,
			Charge,
			Attack,
			StuckAttack,
			DestroyTarget
		}

		public PhotonView PhotonView;

		public Enemy Enemy;

		public EnemyParent EnemyParent;

		public EnemyVision Vision;

		public EnemyNavMeshAgent EnemyNavAgent;

		public NavMeshAgent NavAgent;

		public EnemyRigidbody EnemyRigidbody;

		public Rigidbody Rigidbody;

		public EnemySlowWalkerAnim EnemyAnimator;

		public EnemyStateInvestigate StateInvestigate;

		public Animator Animator;

		public SpringQuaternion RotationSpring;

		public Transform LookAtTransform;

		public Transform FeetTransform;

		public MonoBehaviour Target;

		public StateMachine<TrudgeState> State;

		public float PrevAggro = 0f;

		public float Aggro = 0f;

		public Quaternion RotationTarget;

		public float DefaultRotationSpeed;

		public float TargetClosestApproach = float.PositiveInfinity;

		public bool HandleAggro = true;

		public int AnimMoving = Animator.StringToHash("moving");

		public int AnimStunned = Animator.StringToHash("stunned");

		public int AnimDespawning = Animator.StringToHash("despawning");

		public int AnimFalling = Animator.StringToHash("falling");

		public int AnimLookingUnder = Animator.StringToHash("lookingUnder");

		public int AnimStun = Animator.StringToHash("Stun");

		public int AnimNotice = Animator.StringToHash("Notice");

		public int AnimAttack = Animator.StringToHash("Attack");

		public int AnimJump = Animator.StringToHash("Jump");

		public int AnimLand = Animator.StringToHash("Land");

		public int AnimLookUnder = Animator.StringToHash("LookUnder");

		public int AnimLookUnderAttack = Animator.StringToHash("LookUnderAttack");

		public int AnimStuckAttack = Animator.StringToHash("StuckAttack");

		public ParticleSystem ParticleDeathImpact;

		public ParticleSystem ParticleDeathBitsFar;

		public ParticleSystem ParticleDeathBitsShort;

		public ParticleSystem ParticleDeathSmoke;

		public void Awake()
		{
			Enemy = ((Component)this).GetComponent<Enemy>();
			PhotonView = ((Component)this).GetComponent<PhotonView>();
			EnemyNavAgent = ((Component)this).GetComponent<EnemyNavMeshAgent>();
			NavAgent = ((Component)this).GetComponent<NavMeshAgent>();
			StateInvestigate = ((Component)this).GetComponent<EnemyStateInvestigate>();
			State = new StateMachine<TrudgeState>(StateMachine);
		}

		public void Start()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Expected O, but got Unknown
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Expected O, but got Unknown
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Expected O, but got Unknown
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Expected O, but got Unknown
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Expected O, but got Unknown
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Expected O, but got Unknown
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Expected O, but got Unknown
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Expected O, but got Unknown
			Vision = (EnemyVision)Enemy.Get<Enemy>("Vision");
			EnemyRigidbody = (EnemyRigidbody)Enemy.Get<Enemy>("Rigidbody");
			Animator = (Animator)EnemyAnimator.Get<EnemySlowWalkerAnim>("animator");
			EnemyParent = (EnemyParent)Enemy.Get<Enemy>("EnemyParent");
			Rigidbody = (Rigidbody)EnemyRigidbody.Get<EnemyRigidbody>("rb");
			EnemyStateSpawn component = ((Component)this).GetComponent<EnemyStateSpawn>();
			EnemyHealth val = (EnemyHealth)Enemy.Get<Enemy>("Health");
			((Behaviour)StateInvestigate).enabled = false;
			DefaultRotationSpeed = RotationSpring.speed;
			NavAgent.areaMask = -1;
			Transform vacuumSphere = EnemyAnimator.slowWalkerAttack.vacuumSphere;
			vacuumSphere.localScale *= 1.7f;
			List<HurtCollider> hurtColliders = Utils.GetHurtColliders(EnemyAnimator.slowWalkerAttack.attackImpactHurtColliders.transform);
			for (int i = 0; i < hurtColliders.Count; i++)
			{
				HurtCollider val2 = hurtColliders[i];
				val2.playerKill = false;
				val2.playerDamage = 30;
			}
			EnemyRigidbody.onGrabbed.AddListener((UnityAction)delegate
			{
				if (HandleAggro)
				{
					Aggro += Time.deltaTime * 5f;
				}
			});
			EnemyRigidbody.onTouchPlayer.AddListener((UnityAction)delegate
			{
				if (HandleAggro)
				{
					Aggro += Time.deltaTime * 5f;
				}
			});
			EnemyRigidbody.onTouchPlayerGrabbedObject.AddListener((UnityAction)delegate
			{
				if (HandleAggro)
				{
					Aggro += Time.deltaTime * 5f;
				}
			});
			StateInvestigate.onInvestigateTriggered.AddListener((UnityAction)delegate
			{
				//IL_001d: 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)
				if (HandleAggro)
				{
					Aggro += 2f / Vector3.Distance(((Component)this).transform.position, (Vector3)StateInvestigate.Get<EnemyStateInvestigate>("onInvestigateTriggeredPosition"));
				}
			});
			component.OnSpawn.AddListener((UnityAction)delegate
			{
				if (Utils.IsHost())
				{
					SetState(TrudgeState.Spawn, 1f);
				}
			});
			val.onDeath.AddListener((UnityAction)delegate
			{
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_0044: Unknown result type (might be due to invalid IL or missing references)
				//IL_0071: 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_00cb: Unknown result type (might be due to invalid IL or missing references)
				//IL_0109: 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)
				((Component)ParticleDeathImpact).transform.position = Enemy.CenterTransform.position;
				ParticleDeathImpact.Play();
				((Component)ParticleDeathBitsFar).transform.position = Enemy.CenterTransform.position;
				ParticleDeathBitsFar.Play();
				((Component)ParticleDeathBitsShort).transform.position = Enemy.CenterTransform.position;
				ParticleDeathBitsShort.Play();
				((Component)ParticleDeathSmoke).transform.position = Enemy.CenterTransform.position;
				ParticleDeathSmoke.Play();
				EnemyAnimator.sfxDeath.Play(((Component)EnemyAnimator).transform.position, 1f, 1f, 1f, 1f);
				GameDirector.instance.CameraShake.ShakeDistance(3f, 3f, 10f, ((Component)this).transform.position, 0.5f);
				GameDirector.instance.CameraImpact.ShakeDistance(3f, 3f, 10f, ((Component)this).transform.position, 0.05f);
				if (Utils.IsHost())
				{
					EnemyParent.Despawn();
					SetState(TrudgeState.Spawn, 1f);
				}
			});
			val.onHurt.AddListener((UnityAction)delegate
			{
				if (HandleAggro)
				{
					Aggro += 15f;
				}
			});
		}

		public void Update()
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Invalid comparison between Unknown and I4
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			if (Utils.IsHost() && State.State != TrudgeState.DestroyTarget && (OverhaulDirector.Instance.ExtractionCompletedImpulse || OverhaulDirector.Instance.ExtractionUnlockedImpulse))
			{
				TargetClosestApproach = float.PositiveInfinity;
				SetState(TrudgeState.Idle, 0f);
			}
			EnemyParent.SpawnedTimerPause(float.PositiveInfinity);
			if ((int