Decompiled source of Moai Enemy v2.6.1

MoaiEnemy.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
using LethalLib.Modules;
using LethalNetworkAPI;
using Microsoft.CodeAnalysis;
using MoaiEnemy.NetcodePatcher;
using MoaiEnemy.src.MoaiGold;
using MoaiEnemy.src.MoaiGreen;
using MoaiEnemy.src.MoaiNormal;
using MoaiEnemy.src.Utilities;
using On;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Rendering;

[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("bcs4313")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Moai Enemy for Lethal Company.")]
[assembly: AssemblyFileVersion("1.6.6")]
[assembly: AssemblyInformationalVersion("2.2.5+de30a7b4fd06f505c14721da353043ab3517b186")]
[assembly: AssemblyProduct("MoaiEnemy")]
[assembly: AssemblyTitle("MoaiEnemy")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.6.6.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
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 MoaiEnemy
{
	internal class ConfigModel
	{
		public static ConfigEntry<float> moaiGlobalSize;

		public static ConfigEntry<float> moaiGlobalMusicVol;

		public static ConfigEntry<float> moaiGlobalRarity;

		public static ConfigEntry<float> moaiGlobalSpeed;

		public static void setupConfig()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_0028: Expected O, but got Unknown
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_0050: Expected O, but got Unknown
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Expected O, but got Unknown
			//IL_0078: Expected O, but got Unknown
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Expected O, but got Unknown
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Expected O, but got Unknown
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Expected O, but got Unknown
			//IL_00a0: Expected O, but got Unknown
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			ConfigEntry<float> obj = moaiGlobalSize;
			FloatSliderOptions val = new FloatSliderOptions();
			((BaseRangeOptions<float>)val).Min = 0.05f;
			((BaseRangeOptions<float>)val).Max = 5f;
			FloatSliderConfigItem val2 = new FloatSliderConfigItem(obj, val);
			ConfigEntry<float> obj2 = moaiGlobalMusicVol;
			FloatSliderOptions val3 = new FloatSliderOptions();
			((BaseRangeOptions<float>)val3).Min = 0f;
			((BaseRangeOptions<float>)val3).Max = 2f;
			FloatSliderConfigItem val4 = new FloatSliderConfigItem(obj2, val3);
			ConfigEntry<float> obj3 = moaiGlobalRarity;
			FloatSliderOptions val5 = new FloatSliderOptions();
			((BaseRangeOptions<float>)val5).Min = 0f;
			((BaseRangeOptions<float>)val5).Max = 10f;
			FloatSliderConfigItem val6 = new FloatSliderConfigItem(obj3, val5);
			ConfigEntry<float> obj4 = moaiGlobalSpeed;
			FloatSliderOptions val7 = new FloatSliderOptions();
			((BaseRangeOptions<float>)val7).Min = 0f;
			((BaseRangeOptions<float>)val7).Max = 5f;
			FloatSliderConfigItem val8 = new FloatSliderConfigItem(obj4, val7);
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("MoaiEnemy", "MoaiEnemy", "2.2.5")]
	public class Plugin : BaseUnityPlugin
	{
		public static class Assets
		{
			public static AssetBundle MainAssetBundle;

			public static void PopulateAssets()
			{
				string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
				MainAssetBundle = AssetBundle.LoadFromFile(Path.Combine(directoryName, "moaibundle"));
				if ((Object)(object)MainAssetBundle == (Object)null)
				{
					Logger.LogError((object)"Failed to load custom assets.");
				}
			}
		}

		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_LoadNewLevel <>9__34_0;

			internal void <Awake>b__34_0(orig_LoadNewLevel orig, RoundManager self, int randomSeed, SelectableLevel newLevel)
			{
				if (newLevel.PlanetName.Contains("Easter"))
				{
					rawSpawnMultiplier = RawspawnHandler.getSpawnMultiplier(pickMax: true);
				}
				else
				{
					rawSpawnMultiplier = RawspawnHandler.getSpawnMultiplier();
				}
				RawspawnHandler.enemyRarityPkg enemyRarityPkg = default(RawspawnHandler.enemyRarityPkg);
				enemyRarityPkg.name = ((Object)MoaiEnemy).name;
				enemyRarityPkg.rarity = (int)(50f * baseRarity.Value * rawSpawnMultiplier);
				RawspawnHandler.enemyRarityPkg enemyRarityPkg2 = default(RawspawnHandler.enemyRarityPkg);
				enemyRarityPkg2.name = ((Object)MoaiGreen).name;
				enemyRarityPkg2.rarity = (int)(30f * greenRarity.Value * rawSpawnMultiplier);
				RawspawnHandler.enemyRarityPkg enemyRarityPkg3 = default(RawspawnHandler.enemyRarityPkg);
				enemyRarityPkg3.name = ((Object)MoaiPurple).name;
				enemyRarityPkg3.rarity = (int)(35f * purpleRarity.Value * rawSpawnMultiplier);
				RawspawnHandler.enemyRarityPkg enemyRarityPkg4 = default(RawspawnHandler.enemyRarityPkg);
				enemyRarityPkg4.name = ((Object)MoaiBlue).name;
				enemyRarityPkg4.rarity = (int)(20f * blueRarity.Value * rawSpawnMultiplier);
				RawspawnHandler.enemyRarityPkg enemyRarityPkg5 = default(RawspawnHandler.enemyRarityPkg);
				enemyRarityPkg5.name = ((Object)MoaiRed).name;
				enemyRarityPkg5.rarity = (int)(40f * redRarity.Value * rawSpawnMultiplier);
				RawspawnHandler.enemyRarityPkg enemyRarityPkg6 = default(RawspawnHandler.enemyRarityPkg);
				enemyRarityPkg6.name = ((Object)MoaiOrange).name;
				enemyRarityPkg6.rarity = (int)(30f * orangeRarity.Value * rawSpawnMultiplier);
				RawspawnHandler.enemyRarityPkg enemyRarityPkg7 = default(RawspawnHandler.enemyRarityPkg);
				enemyRarityPkg7.name = ((Object)MoaiGold).name;
				enemyRarityPkg7.rarity = (int)(4f * goldRarity.Value * rawSpawnMultiplier);
				RawspawnHandler.setLevelSpawnWeights(new RawspawnHandler.enemyRarityPkg[7] { enemyRarityPkg, enemyRarityPkg7, enemyRarityPkg4, enemyRarityPkg5, enemyRarityPkg2, enemyRarityPkg3, enemyRarityPkg6 }, Array.Empty<RawspawnHandler.enemyRarityPkg>());
				orig.Invoke(self, randomSeed, newLevel);
				try
				{
					GreenEnemyAI.getMapObjects();
					GreenEnemyAI.findTraps();
					EntityWarp.mapEntrances = Object.FindObjectsOfType<EntranceTeleport>(false);
				}
				catch (Exception ex)
				{
					Debug.LogWarning((object)("Moai Enemy: Error during map initialization process. " + ex.ToString()));
				}
			}
		}

		public static Harmony _harmony;

		public static EnemyType ExampleEnemy;

		public static ManualLogSource Logger;

		public static MoaiNormalNet networkHandler = new MoaiNormalNet();

		public static EnemyType MoaiEnemy;

		public static TerminalNode tlTerminalNode;

		public static TerminalKeyword tlTerminalKeyword;

		public static EnemyType MoaiBlue;

		public static TerminalNode MoaiBlueTerminalNode;

		public static TerminalKeyword MoaiBlueTerminalKeyword;

		public static EnemyType MoaiRed;

		public static TerminalNode MoaiRedTerminalNode;

		public static TerminalKeyword MoaiRedTerminalKeyword;

		public static EnemyType MoaiGreen;

		public static TerminalNode MoaiGreenTerminalNode;

		public static TerminalKeyword MoaiGreenTerminalKeyword;

		public static GameObject plasmaProjectile;

		public static GameObject consumptionCircle;

		public static EnemyType MoaiGold;

		public static TerminalNode MoaiGoldTerminalNode;

		public static TerminalKeyword MoaiGoldTerminalKeyword;

		public static EnemyType MoaiPurple;

		public static TerminalNode MoaiPurpleTerminalNode;

		public static TerminalKeyword MoaiPurpleTerminalKeyword;

		public static GameObject PlasmaPad;

		public static EnemyType MoaiOrange;

		public static TerminalNode MoaiOrangeTerminalNode;

		public static TerminalKeyword MoaiOrangeTerminalKeyword;

		public static EnemyType SoulDevourer;

		public static TerminalNode SoulDevourerTerminalNode;

		public static TerminalKeyword SoulDevourerTerminalKeyword;

		public static float rawSpawnMultiplier = 0f;

		public static ConfigEntry<float> moaiGlobalSize;

		public static ConfigEntry<float> moaiGlobalSizeVar;

		public static ConfigEntry<float> moaiAngelChance;

		public static ConfigEntry<float> moaiSizeCap;

		public static ConfigEntry<float> moaiGlobalMusicVol;

		public static ConfigEntry<float> moaiGlobalSpeed;

		public static ConfigEntry<bool> moaiConsumeScrap;

		public static ConfigEntry<string> moaiSpawnDistribution;

		public static ConfigEntry<float> baseRarity;

		public static ConfigEntry<float> blueRarity;

		public static ConfigEntry<float> redRarity;

		public static ConfigEntry<float> greenRarity;

		public static ConfigEntry<float> purpleRarity;

		public static ConfigEntry<float> goldRarity;

		public static ConfigEntry<float> orangeRarity;

		public static ConfigEntry<float> soulRarity;

		public static void LogDebug(string text)
		{
			Logger.LogInfo((object)text);
		}

		public static void LogProduction(string text)
		{
			Logger.LogInfo((object)text);
		}

		private void Awake()
		{
			//IL_04d6: 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_04e1: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			Assets.PopulateAssets();
			bindVars();
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
			MoaiEnemy = Assets.MainAssetBundle.LoadAsset<EnemyType>("MoaiEnemy");
			tlTerminalNode = Assets.MainAssetBundle.LoadAsset<TerminalNode>("MoaiEnemyTN");
			tlTerminalKeyword = Assets.MainAssetBundle.LoadAsset<TerminalKeyword>("MoaiEnemyTK");
			MoaiBlue = Assets.MainAssetBundle.LoadAsset<EnemyType>("MoaiBlue");
			MoaiBlueTerminalNode = Assets.MainAssetBundle.LoadAsset<TerminalNode>("MoaiBlueTN");
			MoaiBlueTerminalKeyword = Assets.MainAssetBundle.LoadAsset<TerminalKeyword>("MoaiBlueTK");
			MoaiRed = Assets.MainAssetBundle.LoadAsset<EnemyType>("MoaiRed");
			MoaiRedTerminalNode = Assets.MainAssetBundle.LoadAsset<TerminalNode>("MoaiRedTN");
			MoaiRedTerminalKeyword = Assets.MainAssetBundle.LoadAsset<TerminalKeyword>("MoaiRedTK");
			MoaiGreen = Assets.MainAssetBundle.LoadAsset<EnemyType>("MoaiGreen");
			MoaiGreenTerminalNode = Assets.MainAssetBundle.LoadAsset<TerminalNode>("MoaiGreenTN");
			MoaiGreenTerminalKeyword = Assets.MainAssetBundle.LoadAsset<TerminalKeyword>("MoaiGreenTK");
			MoaiPurple = Assets.MainAssetBundle.LoadAsset<EnemyType>("MoaiPurple");
			MoaiPurpleTerminalNode = Assets.MainAssetBundle.LoadAsset<TerminalNode>("MoaiGoldTN");
			MoaiPurpleTerminalKeyword = Assets.MainAssetBundle.LoadAsset<TerminalKeyword>("MoaiGoldTK");
			PlasmaPad = Assets.MainAssetBundle.LoadAsset<GameObject>("PlasmaPadPrefab");
			MoaiGold = Assets.MainAssetBundle.LoadAsset<EnemyType>("MoaiGold");
			MoaiGoldTerminalNode = Assets.MainAssetBundle.LoadAsset<TerminalNode>("MoaiGoldTN");
			MoaiGoldTerminalKeyword = Assets.MainAssetBundle.LoadAsset<TerminalKeyword>("MoaiGoldTK");
			MoaiOrange = Assets.MainAssetBundle.LoadAsset<EnemyType>("MoaiOrange");
			MoaiOrangeTerminalNode = Assets.MainAssetBundle.LoadAsset<TerminalNode>("MoaiOrangeTN");
			MoaiOrangeTerminalKeyword = Assets.MainAssetBundle.LoadAsset<TerminalKeyword>("MoaiOrangeTK");
			SoulDevourer = Assets.MainAssetBundle.LoadAsset<EnemyType>("SoulDev");
			SoulDevourerTerminalNode = Assets.MainAssetBundle.LoadAsset<TerminalNode>("SoulDevTN");
			SoulDevourerTerminalKeyword = Assets.MainAssetBundle.LoadAsset<TerminalKeyword>("SoulDevTK");
			plasmaProjectile = Assets.MainAssetBundle.LoadAsset<GameObject>("PlasmaBall01");
			consumptionCircle = Assets.MainAssetBundle.LoadAsset<GameObject>("ConsumptionCircle");
			Debug.Log((object)("MOAI ENEMY BUNDLE: " + ((object)Assets.MainAssetBundle).ToString()));
			Debug.Log((object)("Orange E: " + (object)MoaiOrange));
			Debug.Log((object)("SD TN: " + (object)MoaiOrangeTerminalNode));
			Debug.Log((object)("SD TK: " + (object)MoaiOrangeTerminalKeyword));
			Random.InitState((int)DateTime.Now.Ticks);
			NetworkPrefabs.RegisterNetworkPrefab(MoaiEnemy.enemyPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(MoaiBlue.enemyPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(MoaiRed.enemyPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(MoaiGreen.enemyPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(MoaiGold.enemyPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(MoaiPurple.enemyPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(MoaiOrange.enemyPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(SoulDevourer.enemyPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(plasmaProjectile);
			NetworkPrefabs.RegisterNetworkPrefab(consumptionCircle);
			NetworkPrefabs.RegisterNetworkPrefab(PlasmaPad);
			rawSpawnMultiplier = RawspawnHandler.getSpawnMultiplier();
			Enemies.RegisterEnemy(MoaiEnemy, 0, (LevelTypes)(-1), (SpawnType)1, tlTerminalNode, tlTerminalKeyword);
			Enemies.RegisterEnemy(MoaiBlue, 0, (LevelTypes)(-1), (SpawnType)1, MoaiBlueTerminalNode, MoaiBlueTerminalKeyword);
			Enemies.RegisterEnemy(MoaiRed, 0, (LevelTypes)(-1), (SpawnType)1, MoaiRedTerminalNode, MoaiRedTerminalKeyword);
			Enemies.RegisterEnemy(MoaiGreen, 0, (LevelTypes)(-1), (SpawnType)1, MoaiGreenTerminalNode, MoaiGreenTerminalKeyword);
			Enemies.RegisterEnemy(MoaiGold, 0, (LevelTypes)(-1), (SpawnType)1, MoaiGreenTerminalNode, MoaiGreenTerminalKeyword);
			Enemies.RegisterEnemy(MoaiPurple, 0, (LevelTypes)(-1), (SpawnType)1, MoaiGreenTerminalNode, MoaiGreenTerminalKeyword);
			Enemies.RegisterEnemy(MoaiOrange, 0, (LevelTypes)(-1), (SpawnType)1, MoaiOrangeTerminalNode, MoaiOrangeTerminalKeyword);
			Enemies.RegisterEnemy(SoulDevourer, 0, (LevelTypes)(-1), (SpawnType)2, MoaiGreenTerminalNode, MoaiGreenTerminalKeyword);
			Debug.Log((object)"MOAI: Registering Moai Net Messages");
			networkHandler.setup();
			object obj = <>c.<>9__34_0;
			if (obj == null)
			{
				hook_LoadNewLevel val = delegate(orig_LoadNewLevel orig, RoundManager self, int randomSeed, SelectableLevel newLevel)
				{
					if (newLevel.PlanetName.Contains("Easter"))
					{
						rawSpawnMultiplier = RawspawnHandler.getSpawnMultiplier(pickMax: true);
					}
					else
					{
						rawSpawnMultiplier = RawspawnHandler.getSpawnMultiplier();
					}
					RawspawnHandler.enemyRarityPkg enemyRarityPkg = default(RawspawnHandler.enemyRarityPkg);
					enemyRarityPkg.name = ((Object)MoaiEnemy).name;
					enemyRarityPkg.rarity = (int)(50f * baseRarity.Value * rawSpawnMultiplier);
					RawspawnHandler.enemyRarityPkg enemyRarityPkg2 = default(RawspawnHandler.enemyRarityPkg);
					enemyRarityPkg2.name = ((Object)MoaiGreen).name;
					enemyRarityPkg2.rarity = (int)(30f * greenRarity.Value * rawSpawnMultiplier);
					RawspawnHandler.enemyRarityPkg enemyRarityPkg3 = default(RawspawnHandler.enemyRarityPkg);
					enemyRarityPkg3.name = ((Object)MoaiPurple).name;
					enemyRarityPkg3.rarity = (int)(35f * purpleRarity.Value * rawSpawnMultiplier);
					RawspawnHandler.enemyRarityPkg enemyRarityPkg4 = default(RawspawnHandler.enemyRarityPkg);
					enemyRarityPkg4.name = ((Object)MoaiBlue).name;
					enemyRarityPkg4.rarity = (int)(20f * blueRarity.Value * rawSpawnMultiplier);
					RawspawnHandler.enemyRarityPkg enemyRarityPkg5 = default(RawspawnHandler.enemyRarityPkg);
					enemyRarityPkg5.name = ((Object)MoaiRed).name;
					enemyRarityPkg5.rarity = (int)(40f * redRarity.Value * rawSpawnMultiplier);
					RawspawnHandler.enemyRarityPkg enemyRarityPkg6 = default(RawspawnHandler.enemyRarityPkg);
					enemyRarityPkg6.name = ((Object)MoaiOrange).name;
					enemyRarityPkg6.rarity = (int)(30f * orangeRarity.Value * rawSpawnMultiplier);
					RawspawnHandler.enemyRarityPkg enemyRarityPkg7 = default(RawspawnHandler.enemyRarityPkg);
					enemyRarityPkg7.name = ((Object)MoaiGold).name;
					enemyRarityPkg7.rarity = (int)(4f * goldRarity.Value * rawSpawnMultiplier);
					RawspawnHandler.setLevelSpawnWeights(new RawspawnHandler.enemyRarityPkg[7] { enemyRarityPkg, enemyRarityPkg7, enemyRarityPkg4, enemyRarityPkg5, enemyRarityPkg2, enemyRarityPkg3, enemyRarityPkg6 }, Array.Empty<RawspawnHandler.enemyRarityPkg>());
					orig.Invoke(self, randomSeed, newLevel);
					try
					{
						GreenEnemyAI.getMapObjects();
						GreenEnemyAI.findTraps();
						EntityWarp.mapEntrances = Object.FindObjectsOfType<EntranceTeleport>(false);
					}
					catch (Exception ex)
					{
						Debug.LogWarning((object)("Moai Enemy: Error during map initialization process. " + ex.ToString()));
					}
				};
				<>c.<>9__34_0 = val;
				obj = (object)val;
			}
			RoundManager.LoadNewLevel += (hook_LoadNewLevel)obj;
			Logger.LogInfo((object)"Plugin MoaiEnemy is loaded!");
		}

		public void bindVars()
		{
			//IL_0242: 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)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Expected O, but got Unknown
			//IL_025b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Expected O, but got Unknown
			//IL_026c: Expected O, but got Unknown
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: Expected O, but got Unknown
			//IL_0272: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Expected O, but got Unknown
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0296: Expected O, but got Unknown
			//IL_029c: Expected O, but got Unknown
			//IL_0297: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Expected O, but got Unknown
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02af: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ba: Expected O, but got Unknown
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Expected O, but got Unknown
			//IL_02cc: Expected O, but got Unknown
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cd: Expected O, but got Unknown
			//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ea: Expected O, but got Unknown
			//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Expected O, but got Unknown
			//IL_02fc: Expected O, but got Unknown
			//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: Expected O, but got Unknown
			//IL_0302: Unknown result type (might be due to invalid IL or missing references)
			//IL_0307: Unknown result type (might be due to invalid IL or missing references)
			//IL_030f: Unknown result type (might be due to invalid IL or missing references)
			//IL_031a: Expected O, but got Unknown
			//IL_031b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0326: Expected O, but got Unknown
			//IL_032c: Expected O, but got Unknown
			//IL_0327: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: Expected O, but got Unknown
			//IL_0333: Unknown result type (might be due to invalid IL or missing references)
			//IL_0338: Unknown result type (might be due to invalid IL or missing references)
			//IL_0340: Unknown result type (might be due to invalid IL or missing references)
			//IL_034b: Expected O, but got Unknown
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0357: Expected O, but got Unknown
			//IL_035d: Expected O, but got Unknown
			//IL_0358: Unknown result type (might be due to invalid IL or missing references)
			//IL_035f: Expected O, but got Unknown
			//IL_0364: Unknown result type (might be due to invalid IL or missing references)
			//IL_0369: Unknown result type (might be due to invalid IL or missing references)
			//IL_0376: Expected O, but got Unknown
			//IL_0371: Unknown result type (might be due to invalid IL or missing references)
			//IL_0378: Expected O, but got Unknown
			//IL_037d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0382: Unknown result type (might be due to invalid IL or missing references)
			//IL_038f: Expected O, but got Unknown
			//IL_038a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0391: Expected O, but got Unknown
			//IL_0396: Unknown result type (might be due to invalid IL or missing references)
			//IL_039b: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ae: Expected O, but got Unknown
			//IL_03af: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ba: Expected O, but got Unknown
			//IL_03c0: Expected O, but got Unknown
			//IL_03bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c2: Expected O, but got Unknown
			//IL_03c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03df: Expected O, but got Unknown
			//IL_03e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03eb: Expected O, but got Unknown
			//IL_03f1: Expected O, but got Unknown
			//IL_03ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f3: Expected O, but got Unknown
			//IL_03f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0405: Unknown result type (might be due to invalid IL or missing references)
			//IL_0410: Expected O, but got Unknown
			//IL_0411: Unknown result type (might be due to invalid IL or missing references)
			//IL_041c: Expected O, but got Unknown
			//IL_0422: Expected O, but got Unknown
			//IL_041d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0424: Expected O, but got Unknown
			//IL_0429: Unknown result type (might be due to invalid IL or missing references)
			//IL_042e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0436: Unknown result type (might be due to invalid IL or missing references)
			//IL_0441: Expected O, but got Unknown
			//IL_0442: Unknown result type (might be due to invalid IL or missing references)
			//IL_044d: Expected O, but got Unknown
			//IL_0453: Expected O, but got Unknown
			//IL_044e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0455: Expected O, but got Unknown
			//IL_045a: Unknown result type (might be due to invalid IL or missing references)
			//IL_045f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0467: Unknown result type (might be due to invalid IL or missing references)
			//IL_0472: Expected O, but got Unknown
			//IL_0473: Unknown result type (might be due to invalid IL or missing references)
			//IL_047e: Expected O, but got Unknown
			//IL_0484: Expected O, but got Unknown
			//IL_047f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0486: Expected O, but got Unknown
			//IL_048b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0490: Unknown result type (might be due to invalid IL or missing references)
			//IL_0498: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a3: Expected O, but got Unknown
			//IL_04a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04af: Expected O, but got Unknown
			//IL_04b5: Expected O, but got Unknown
			//IL_04b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b7: Expected O, but got Unknown
			//IL_04bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d4: Expected O, but got Unknown
			//IL_04d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e0: Expected O, but got Unknown
			//IL_04e6: Expected O, but got Unknown
			//IL_04e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e8: Expected O, but got Unknown
			//IL_04ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0505: Expected O, but got Unknown
			//IL_0506: Unknown result type (might be due to invalid IL or missing references)
			//IL_0511: Expected O, but got Unknown
			//IL_0517: Expected O, but got Unknown
			//IL_0512: Unknown result type (might be due to invalid IL or missing references)
			//IL_0519: Expected O, but got Unknown
			moaiGlobalMusicVol = ((BaseUnityPlugin)this).Config.Bind<float>("Global", "Enemy Sound Volume", 0.6f, "Changes the volume of all moai sounds. May make moai more sneaky as well.");
			moaiGlobalSizeVar = ((BaseUnityPlugin)this).Config.Bind<float>("Global", "Size Variant Chance", 0.2f, "The chance of a moai to spawn in a randomly scaled size. Affects their pitch too.");
			moaiAngelChance = ((BaseUnityPlugin)this).Config.Bind<float>("Global", "Angel Spawn Chance", 0.1f, "Chance for the moai to spawn as an angel (good guy). They guard players and kill enemies, but they certainly aren't friendly forever.");
			moaiGlobalSize = ((BaseUnityPlugin)this).Config.Bind<float>("Global", "Size Multiplier", 1f, "Changes the size of all moai models. Scales pretty violently. Affects SFX pitch.");
			moaiSizeCap = ((BaseUnityPlugin)this).Config.Bind<float>("Advanced", "Size Variant Cap", 100f, "Caps the max size of a moai with the size variant. Normal size is 1. 1.5 is slightly taller than the ship. 2 is very large. 3.5+ is giant tier (with 5 being the largest usually)");
			moaiGlobalSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Global", "Enemy Speed Multiplier", 1f, "Changes the speed of all moai. 4x would mean they are 4 times faster, 0.5x would be 2 times slower.");
			moaiConsumeScrap = ((BaseUnityPlugin)this).Config.Bind<bool>("Global", "Allow Scrap Eating Behavior", true, "If enabled, moai can seek out scrap and consume it. Moai that consume scrap become angel variants for a time. Does not apply to dead bodies.");
			moaiSpawnDistribution = ((BaseUnityPlugin)this).Config.Bind<string>("Advanced", "Enemy Spawn Distribution", "4%100%, 6%50%, 10%25%", "For fine tuning spawn multipliers day to day. Value is a comma separated list. Each value follows the format C%M%, with C being the chance for the spawnrate multiplier to activate on a day (0-100%) and M being the multiplier (0-inf%). If a multiplier isn't activated, the spawnrate will be 0%.");
			baseRarity = ((BaseUnityPlugin)this).Config.Bind<float>("Variants", "Basic Moai Spawnrate", 1f, "Changes the spawnrate of the variant.");
			blueRarity = ((BaseUnityPlugin)this).Config.Bind<float>("Variants", "Blue Moai Spawnrate", 1f, "Changes the spawnrate of the variant.");
			redRarity = ((BaseUnityPlugin)this).Config.Bind<float>("Variants", "Red Moai Spawnrate", 1f, "Changes the spawnrate of the variant.");
			greenRarity = ((BaseUnityPlugin)this).Config.Bind<float>("Variants", "Green Moai Spawnrate", 1f, "Changes the spawnrate of the variant.");
			purpleRarity = ((BaseUnityPlugin)this).Config.Bind<float>("Variants", "Purple Moai Spawnrate", 1f, "Changes the spawnrate of the variant.");
			goldRarity = ((BaseUnityPlugin)this).Config.Bind<float>("Variants", "Gold Moai Spawnrate", 1f, "Changes the spawnrate of the variant.");
			orangeRarity = ((BaseUnityPlugin)this).Config.Bind<float>("Variants", "Orange Moai Spawnrate", 1f, "Changes the spawnrate of the variant.");
			soulRarity = ((BaseUnityPlugin)this).Config.Bind<float>("Variants", "Devourer Spawnrate", 0.4f, "Changes the spawnrate of this... thing. Note that devourers don't spawn naturally, they have a chance to spawn when any moai consumes a corpse.");
			ConfigEntry<float> obj = moaiAngelChance;
			FloatSliderOptions val = new FloatSliderOptions
			{
				RequiresRestart = false
			};
			((BaseRangeOptions<float>)val).Min = 0f;
			((BaseRangeOptions<float>)val).Max = 1f;
			FloatSliderConfigItem val2 = new FloatSliderConfigItem(obj, val);
			ConfigEntry<float> obj2 = moaiGlobalSize;
			FloatSliderOptions val3 = new FloatSliderOptions
			{
				RequiresRestart = false
			};
			((BaseRangeOptions<float>)val3).Min = 0.05f;
			((BaseRangeOptions<float>)val3).Max = 5f;
			FloatSliderConfigItem val4 = new FloatSliderConfigItem(obj2, val3);
			ConfigEntry<float> obj3 = moaiGlobalSizeVar;
			FloatSliderOptions val5 = new FloatSliderOptions
			{
				RequiresRestart = false
			};
			((BaseRangeOptions<float>)val5).Min = 0f;
			((BaseRangeOptions<float>)val5).Max = 1f;
			FloatSliderConfigItem val6 = new FloatSliderConfigItem(obj3, val5);
			ConfigEntry<float> obj4 = moaiSizeCap;
			FloatInputFieldOptions val7 = new FloatInputFieldOptions
			{
				RequiresRestart = false
			};
			((BaseRangeOptions<float>)val7).Min = 0.01f;
			((BaseRangeOptions<float>)val7).Max = 100f;
			FloatInputFieldConfigItem val8 = new FloatInputFieldConfigItem(obj4, val7);
			ConfigEntry<float> obj5 = moaiGlobalMusicVol;
			FloatSliderOptions val9 = new FloatSliderOptions
			{
				RequiresRestart = false
			};
			((BaseRangeOptions<float>)val9).Min = 0f;
			((BaseRangeOptions<float>)val9).Max = 1f;
			FloatSliderConfigItem val10 = new FloatSliderConfigItem(obj5, val9);
			ConfigEntry<float> obj6 = moaiGlobalSpeed;
			FloatSliderOptions val11 = new FloatSliderOptions
			{
				RequiresRestart = false
			};
			((BaseRangeOptions<float>)val11).Min = 0f;
			((BaseRangeOptions<float>)val11).Max = 5f;
			FloatSliderConfigItem val12 = new FloatSliderConfigItem(obj6, val11);
			BoolCheckBoxConfigItem val13 = new BoolCheckBoxConfigItem(moaiConsumeScrap, new BoolCheckBoxOptions
			{
				RequiresRestart = false
			});
			TextInputFieldConfigItem val14 = new TextInputFieldConfigItem(moaiSpawnDistribution, new TextInputFieldOptions
			{
				RequiresRestart = false
			});
			ConfigEntry<float> obj7 = baseRarity;
			FloatInputFieldOptions val15 = new FloatInputFieldOptions
			{
				RequiresRestart = false
			};
			((BaseRangeOptions<float>)val15).Min = 0f;
			((BaseRangeOptions<float>)val15).Max = 10000f;
			FloatInputFieldConfigItem val16 = new FloatInputFieldConfigItem(obj7, val15);
			ConfigEntry<float> obj8 = greenRarity;
			FloatInputFieldOptions val17 = new FloatInputFieldOptions
			{
				RequiresRestart = false
			};
			((BaseRangeOptions<float>)val17).Min = 0f;
			((BaseRangeOptions<float>)val17).Max = 10000f;
			FloatInputFieldConfigItem val18 = new FloatInputFieldConfigItem(obj8, val17);
			ConfigEntry<float> obj9 = purpleRarity;
			FloatInputFieldOptions val19 = new FloatInputFieldOptions
			{
				RequiresRestart = false
			};
			((BaseRangeOptions<float>)val19).Min = 0f;
			((BaseRangeOptions<float>)val19).Max = 10000f;
			FloatInputFieldConfigItem val20 = new FloatInputFieldConfigItem(obj9, val19);
			ConfigEntry<float> obj10 = redRarity;
			FloatInputFieldOptions val21 = new FloatInputFieldOptions
			{
				RequiresRestart = false
			};
			((BaseRangeOptions<float>)val21).Min = 0f;
			((BaseRangeOptions<float>)val21).Max = 10000f;
			FloatInputFieldConfigItem val22 = new FloatInputFieldConfigItem(obj10, val21);
			ConfigEntry<float> obj11 = blueRarity;
			FloatInputFieldOptions val23 = new FloatInputFieldOptions
			{
				RequiresRestart = false
			};
			((BaseRangeOptions<float>)val23).Min = 0f;
			((BaseRangeOptions<float>)val23).Max = 10000f;
			FloatInputFieldConfigItem val24 = new FloatInputFieldConfigItem(obj11, val23);
			ConfigEntry<float> obj12 = goldRarity;
			FloatInputFieldOptions val25 = new FloatInputFieldOptions
			{
				RequiresRestart = false
			};
			((BaseRangeOptions<float>)val25).Min = 0f;
			((BaseRangeOptions<float>)val25).Max = 10000f;
			FloatInputFieldConfigItem val26 = new FloatInputFieldConfigItem(obj12, val25);
			ConfigEntry<float> obj13 = orangeRarity;
			FloatInputFieldOptions val27 = new FloatInputFieldOptions
			{
				RequiresRestart = false
			};
			((BaseRangeOptions<float>)val27).Min = 0f;
			((BaseRangeOptions<float>)val27).Max = 10000f;
			FloatInputFieldConfigItem val28 = new FloatInputFieldConfigItem(obj13, val27);
			ConfigEntry<float> obj14 = goldRarity;
			FloatInputFieldOptions val29 = new FloatInputFieldOptions
			{
				RequiresRestart = false
			};
			((BaseRangeOptions<float>)val29).Min = 0f;
			((BaseRangeOptions<float>)val29).Max = 10000f;
			FloatInputFieldConfigItem val30 = new FloatInputFieldConfigItem(obj14, val29);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val10);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val4);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val2);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val6);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val12);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val13);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val16);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val24);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val22);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val14);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val18);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val20);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val26);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val28);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val30);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val8);
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "MoaiEnemy";

		public const string PLUGIN_NAME = "MoaiEnemy";

		public const string PLUGIN_VERSION = "2.2.5";
	}
}
namespace MoaiEnemy.src.Utilities
{
	internal class EntityWarp
	{
		public struct entrancePack
		{
			public EntranceTeleport tele;

			public Vector3 navPosition;
		}

		public static EntranceTeleport[] mapEntrances;

		public static entrancePack findNearestEntrance(EnemyAI __instance)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: 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_0057: 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)
			float num = 100000000f;
			EntranceTeleport val = null;
			EntranceTeleport[] array = mapEntrances;
			for (int i = 0; i < array.Length; i++)
			{
				if (__instance.isOutside == array[i].isEntranceToBuilding && Vector3.Distance(((Component)__instance).transform.position, ((Component)array[i]).transform.position) < num)
				{
					num = Vector3.Distance(((Component)__instance).transform.position, ((Component)array[i]).transform.position);
					val = array[i];
				}
			}
			entrancePack result = default(entrancePack);
			NavMeshHit val2 = default(NavMeshHit);
			if ((Object)(object)val != (Object)null && NavMesh.SamplePosition(((Component)val).transform.position, ref val2, 10f, -1))
			{
				result.navPosition = ((NavMeshHit)(ref val2)).position;
			}
			result.tele = val;
			return result;
		}

		public static void SendEnemyInside(EnemyAI __instance)
		{
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			__instance.isOutside = false;
			__instance.allAINodes = GameObject.FindGameObjectsWithTag("AINode");
			EntranceTeleport tele = findNearestEntrance(__instance).tele;
			if (!Object.op_Implicit((Object)(object)tele))
			{
				Debug.LogError((object)"MOAI EntranceTeleport: Failed to find entrance teleport.");
			}
			Transform entrancePoint = tele.entrancePoint;
			if (!Object.op_Implicit((Object)(object)entrancePoint))
			{
				Debug.LogError((object)"MOAI EntranceTeleport: Failed to find best exit position.");
			}
			NavMeshHit val = default(NavMeshHit);
			if (NavMesh.SamplePosition(((Component)entrancePoint).transform.position, ref val, 10f, -1))
			{
				__instance.serverPosition = ((NavMeshHit)(ref val)).position;
				((Component)__instance).transform.position = ((NavMeshHit)(ref val)).position;
				__instance.agent.Warp(__instance.serverPosition);
				__instance.SyncPositionToClients();
			}
			else
			{
				Debug.LogError((object)"MOAI EntranceTeleport: Failed to find exit NavmeshHit position");
			}
		}

		public static Transform findExitPoint(EntranceTeleport referenceDoor)
		{
			return referenceDoor.exitPoint;
		}

		public static void SendEnemyOutside(EnemyAI __instance, bool SpawnOnDoor = true)
		{
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			__instance.isOutside = true;
			__instance.allAINodes = GameObject.FindGameObjectsWithTag("OutsideAINode");
			EntranceTeleport tele = findNearestEntrance(__instance).tele;
			if (!Object.op_Implicit((Object)(object)tele))
			{
				Debug.LogError((object)"MOAI EntranceTeleport: Failed to find entrance teleport.");
			}
			Transform entrancePoint = tele.entrancePoint;
			if (!Object.op_Implicit((Object)(object)entrancePoint))
			{
				Debug.LogError((object)"MOAI EntranceTeleport: Failed to find best exit position.");
			}
			NavMeshHit val = default(NavMeshHit);
			if (NavMesh.SamplePosition(((Component)entrancePoint).transform.position, ref val, 10f, -1))
			{
				__instance.serverPosition = ((NavMeshHit)(ref val)).position;
				((Component)__instance).transform.position = ((NavMeshHit)(ref val)).position;
				__instance.agent.Warp(__instance.serverPosition);
				__instance.SyncPositionToClients();
			}
			else
			{
				Debug.LogError((object)"MOAI EntranceTeleport: Failed to find exit NavmeshHit position");
			}
		}
	}
	public class RawspawnHandler
	{
		public struct enemyRarityPkg
		{
			public string name;

			public int rarity;
		}

		public static void setLevelSpawnWeights(enemyRarityPkg[] dayReferences, enemyRarityPkg[] nightReferences)
		{
			RoundManager instance = RoundManager.Instance;
			SelectableLevel currentLevel = instance.currentLevel;
			for (int i = 0; i < currentLevel.DaytimeEnemies.Count; i++)
			{
				SpawnableEnemyWithRarity val = currentLevel.DaytimeEnemies[i];
				for (int j = 0; j < dayReferences.Length; j++)
				{
					enemyRarityPkg enemyRarityPkg = dayReferences[j];
					if (((Object)val.enemyType).name.Equals(enemyRarityPkg.name))
					{
						currentLevel.DaytimeEnemies[i].rarity = enemyRarityPkg.rarity;
					}
				}
			}
			for (int k = 0; k < currentLevel.OutsideEnemies.Count; k++)
			{
				SpawnableEnemyWithRarity val2 = currentLevel.OutsideEnemies[k];
				for (int l = 0; l < nightReferences.Length; l++)
				{
					enemyRarityPkg enemyRarityPkg2 = nightReferences[l];
					if (((Object)val2.enemyType).name.Equals(enemyRarityPkg2.name))
					{
						currentLevel.OutsideEnemies[k].rarity = enemyRarityPkg2.rarity;
					}
				}
			}
		}

		public static float getSpawnMultiplier(bool pickMax = false)
		{
			float num = 0f;
			float num2 = Random.Range(0f, 1f);
			List<float> list = new List<float>();
			List<float> list2 = new List<float>();
			string value = Plugin.moaiSpawnDistribution.Value;
			string[] array = value.Split(",");
			try
			{
				string[] array2 = array;
				foreach (string text in array2)
				{
					string[] array3 = text.Split("%");
					list.Add(float.Parse(array3[0]) / 100f);
					list2.Add(float.Parse(array3[1]) / 100f);
				}
				if (pickMax)
				{
					float num3 = 0f;
					for (int j = 0; j < list2.Count; j++)
					{
						float num4 = list2[j];
						if (num4 > num3)
						{
							num3 = num4;
							num = num4;
						}
					}
				}
				else
				{
					float num5 = 0f;
					for (int k = 0; k < list.Count; k++)
					{
						float num6 = list[k];
						float num7 = list2[k];
						if (num2 > num5 && num2 < num6 + num5)
						{
							num = num7;
							break;
						}
						num5 += num6;
					}
				}
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("Moai Enemy: Exception when parsing spawn distribution chances! Error is: " + ex.ToString()));
			}
			Debug.Log((object)"Moai Enemy: Spawn Distribution Parsed is -->");
			if (pickMax)
			{
				Debug.Log((object)"Moai Enemy: Picked largest spawn multiplier due to being in easter island.");
				Debug.Log((object)"Moai Enemy: Multipliers:");
				Debug.Log((object)string.Join(",", list2));
				Debug.Log((object)("Moai Enemy: Selected multiplier for the day is " + num * 100f + "%"));
			}
			else
			{
				Debug.Log((object)"Moai Enemy: Chances:");
				Debug.Log((object)string.Join(",", list));
				Debug.Log((object)"Moai Enemy: Multipliers:");
				Debug.Log((object)string.Join(",", list2));
				Debug.Log((object)"Moai Enemy: Random chance roll:");
				Debug.Log((object)num2);
				Debug.Log((object)("Moai Enemy: Selected multiplier for the day is " + num * 100f + "%"));
			}
			return num;
		}
	}
}
namespace MoaiEnemy.src.MoaiOrange
{
	internal class OrangeEnemyAI : MOAIAICORE
	{
		private new enum State
		{
			SearchingForPlayer,
			Guard,
			StickingInFrontOfEnemy,
			StickingInFrontOfPlayer,
			HeadSwingAttackInProgress,
			HeadingToEntrance,
			Kidnapping,
			GroundHopping
		}

		private float surfaceTime = 13.8f;

		private float undergroundTime = 16.8f;

		private float cycleTimer = 0f;

		private bool isUnderground = false;

		private int diggingState = 0;

		private float digStateTimer = 0f;

		public AudioSource customMoaiDrillSound;

		public AudioSource customMoaiDigSound;

		private bool hasPlayedDigAnim = false;

		private bool hasPlayedUndergroundAnim = false;

		private float leapAnimationLength = 1f;

		private float leapPeakHeight = 3f;

		private float timeBetweenLeaps = 1.1f;

		public AudioSource leapPrepareSound;

		public AudioSource[] leapHitSounds;

		private bool isInLeapSequence = false;

		private bool doneWithLeaps = false;

		private float hopMinRange = 12f;

		private float hopMaxRange = 18f;

		public AudioSource explosionImpactSound;

		private float beeSpawnChance = 0.25f;

		private float impactRange = 5.7f;

		private int impactDamage = 35;

		private float impactForce = 4f;

		public ParticleSystem undergroundParticleSystem;

		public ParticleSystem emergeParticleSystem;

		public ParticleSystem explosionParticles;

		private List<RedLocustBees> spawnedBees;

		private PlayerControllerB yoinkedPlayer;

		public Transform playerGrabPoint;

		private bool sneakingUpOnPlayer = false;

		private float letGoTimer = 0f;

		private PlayerControllerB targetToYoink;

		private List<Collider> disabledColliders = new List<Collider>();

		private float kidnapImpatienceTimer = 12f;

		private float kidnapImpatienceDuration = 12f;

		private float grabRange = 2f;

		public override void Start()
		{
			baseInit();
			spawnedBees = new List<RedLocustBees>();
			AudioSource obj = leapPrepareSound;
			obj.volume *= Plugin.moaiGlobalMusicVol.Value / 0.6f;
			for (int i = 0; i < leapHitSounds.Length; i++)
			{
				AudioSource obj2 = leapHitSounds[i];
				obj2.volume *= Plugin.moaiGlobalMusicVol.Value / 0.6f;
			}
			AudioSource obj3 = explosionImpactSound;
			obj3.volume *= Plugin.moaiGlobalMusicVol.Value / 0.6f;
			AudioSource obj4 = customMoaiDrillSound;
			obj4.volume *= Plugin.moaiGlobalMusicVol.Value / 0.6f;
			AudioSource obj5 = customMoaiDigSound;
			obj5.volume *= Plugin.moaiGlobalMusicVol.Value / 0.6f;
		}

		public override void setPitches(float pitchAlter)
		{
			AudioSource obj = leapPrepareSound;
			obj.pitch /= pitchAlter;
			for (int i = 0; i < leapHitSounds.Length; i++)
			{
				AudioSource obj2 = leapHitSounds[i];
				obj2.pitch /= pitchAlter;
			}
			AudioSource obj3 = explosionImpactSound;
			obj3.pitch /= pitchAlter;
			AudioSource obj4 = customMoaiDrillSound;
			obj4.pitch /= pitchAlter;
			AudioSource obj5 = customMoaiDigSound;
			obj5.pitch /= pitchAlter;
		}

		public override void OnDestroy()
		{
			for (int i = 0; i < spawnedBees.Count; i++)
			{
				RedLocustBees val = spawnedBees[i];
				destroyBeesClientRpc(((NetworkBehaviour)val).NetworkObject.NetworkObjectId);
			}
			spawnedBees.Clear();
			if (((NetworkBehaviour)RoundManager.Instance).IsHost && Object.op_Implicit((Object)(object)yoinkedPlayer))
			{
				letGoOfPlayerClientRpc(((NetworkBehaviour)yoinkedPlayer).NetworkObject.NetworkObjectId);
			}
			base.OnDestroy();
		}

		[ClientRpc]
		public void destroyBeesClientRpc(ulong netid)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2210511200u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, netid);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2210511200u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			RedLocustBees[] array = Object.FindObjectsOfType<RedLocustBees>();
			RedLocustBees[] array2 = array;
			foreach (RedLocustBees val3 in array2)
			{
				if (Object.op_Implicit((Object)(object)val3) && ((NetworkBehaviour)val3).NetworkObject.NetworkObjectId == netid)
				{
					if (Object.op_Implicit((Object)(object)val3.hive))
					{
						Object.Destroy((Object)(object)val3.hive);
					}
					Object.Destroy((Object)(object)((Component)val3).gameObject);
				}
			}
		}

		[ClientRpc]
		public void moveHiveClientRpc(ulong netid)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1297456321u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, netid);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1297456321u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			RedLocustBees[] array = Object.FindObjectsOfType<RedLocustBees>();
			RedLocustBees[] array2 = array;
			foreach (RedLocustBees val3 in array2)
			{
				if (Object.op_Implicit((Object)(object)val3) && ((NetworkBehaviour)val3).NetworkObject.NetworkObjectId == netid)
				{
					val3.hive.targetFloorPosition = new Vector3(-333f, -333f, -333f);
					val3.hive.fallTime = 0f;
					((EnemyAI)val3).agent.speed = 4.5f;
				}
			}
		}

		public override void Update()
		{
			//IL_0309: Unknown result type (might be due to invalid IL or missing references)
			//IL_030e: Unknown result type (might be due to invalid IL or missing references)
			//IL_038c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0391: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c9: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Update();
			baseUpdate();
			if (Object.op_Implicit((Object)(object)yoinkedPlayer) && ((NetworkBehaviour)yoinkedPlayer).NetworkObject.NetworkObjectId == ((NetworkBehaviour)RoundManager.Instance.playersManager.localPlayerController).NetworkObject.NetworkObjectId)
			{
				StartOfRound.Instance.drowningTimer = (float)(enemyRandom.NextDouble() + 0.10000000149011612);
			}
			if (!((Behaviour)animator).enabled)
			{
				((Behaviour)animator).enabled = true;
			}
			if (!((NetworkBehaviour)RoundManager.Instance).IsHost)
			{
				return;
			}
			cycleTimer += Time.deltaTime;
			if (((EnemyAI)this).currentBehaviourStateIndex == 0 || ((EnemyAI)this).currentBehaviourStateIndex == 1 || ((EnemyAI)this).currentBehaviourStateIndex == 5)
			{
				if (isUnderground)
				{
					if (cycleTimer > undergroundTime)
					{
						cycleTimer = 0f;
						diggingState = 1;
						hasPlayedDigAnim = false;
						hasPlayedUndergroundAnim = false;
					}
				}
				else if (cycleTimer > surfaceTime)
				{
					cycleTimer = 0f;
					diggingState = 2;
					hasPlayedDigAnim = false;
					hasPlayedUndergroundAnim = false;
				}
			}
			if ((((EnemyAI)this).currentBehaviourStateIndex == 4 || ((EnemyAI)this).currentBehaviourStateIndex == 2) && isUnderground && (double)cycleTimer > 2.5)
			{
				cycleTimer = 0f;
				diggingState = 1;
				hasPlayedDigAnim = false;
				hasPlayedUndergroundAnim = false;
			}
			if (((EnemyAI)this).currentBehaviourStateIndex == 7)
			{
				animator.speed = 1f;
			}
			if (diggingState == 1)
			{
				digStateTimer += Time.deltaTime;
				if (!hasPlayedDigAnim)
				{
					orangeEmergeClientRpc();
					hasPlayedDigAnim = true;
				}
				if (digStateTimer > 1.1f)
				{
					diggingState = 0;
					isUnderground = false;
					hasPlayedDigAnim = false;
					digStateTimer = 0f;
				}
			}
			else if (diggingState == 2)
			{
				digStateTimer += Time.deltaTime;
				if (!hasPlayedDigAnim)
				{
					orangeDigClientRpc();
					hasPlayedDigAnim = true;
				}
				if (digStateTimer > 1.1f)
				{
					diggingState = 0;
					isUnderground = true;
					hasPlayedDigAnim = false;
					digStateTimer = 0f;
				}
			}
			else
			{
				digStateTimer = 0f;
			}
			AnimatorStateInfo currentAnimatorStateInfo;
			if (isUnderground && diggingState == 0)
			{
				currentAnimatorStateInfo = animator.GetCurrentAnimatorStateInfo(0);
				if (!((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("RemainUnderground") && !hasPlayedUndergroundAnim)
				{
					undergroundActivateClientRpc();
					hasPlayedUndergroundAnim = true;
				}
				if (!customMoaiDigSound.isPlaying)
				{
					playUndergroundSoundClientRpc(active: true);
				}
			}
			else
			{
				hasPlayedUndergroundAnim = false;
				if (customMoaiDigSound.isPlaying)
				{
					playUndergroundSoundClientRpc(active: false);
				}
			}
			currentAnimatorStateInfo = animator.GetCurrentAnimatorStateInfo(0);
			if (!((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("RemainUnderground"))
			{
				currentAnimatorStateInfo = animator.GetCurrentAnimatorStateInfo(0);
				if (!((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("DigUp"))
				{
					currentAnimatorStateInfo = animator.GetCurrentAnimatorStateInfo(0);
					if (!((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("DigDown"))
					{
						return;
					}
				}
			}
			if (diggingState == 0 && !isUnderground)
			{
				playWalkClientRpc();
			}
		}

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

		public async void summonBees(Vector3 position)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			RedLocustBees[] beeArr = Resources.FindObjectsOfTypeAll<RedLocustBees>();
			RedLocustBees beeobj = beeArr[0];
			Debug.Log((object)("Orange Moai: spawning bee obj: " + ((Object)beeobj).name + " - " + ((object)beeobj).GetType()?.ToString() + " - " + ((object)beeobj).ToString()));
			GameObject beebase = ((EnemyAI)beeobj).enemyType.enemyPrefab;
			GameObject bees = Object.Instantiate<GameObject>(beebase, position, Quaternion.identity, new GameObject().transform);
			((Renderer)bees.GetComponentInChildren<MeshRenderer>()).enabled = false;
			bees.GetComponentInChildren<NetworkObject>().Spawn(true);
			bees.SetActive(true);
			RedLocustBees comp = bees.GetComponent<RedLocustBees>();
			spawnedBees.Add(comp);
			await Task.Delay((int)(enemyRandom.NextDouble() * 5000.0 + 15000.0));
			destroyBeesClientRpc(((NetworkBehaviour)comp).NetworkObject.NetworkObjectId);
		}

		public static void moaiSpawnExplosion(Vector3 explosionPosition, float killRange = 1f, float damageRange = 1f, int nonLethalDamage = 50, float physicsForce = 0f, GameObject overridePrefab = null, bool goThroughCar = false)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: 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_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0304: Unknown result type (might be due to invalid IL or missing references)
			//IL_0309: Unknown result type (might be due to invalid IL or missing references)
			//IL_0313: Unknown result type (might be due to invalid IL or missing references)
			//IL_0318: Unknown result type (might be due to invalid IL or missing references)
			//IL_0341: Unknown result type (might be due to invalid IL or missing references)
			//IL_0346: Unknown result type (might be due to invalid IL or missing references)
			//IL_0355: Unknown result type (might be due to invalid IL or missing references)
			//IL_035a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0361: Unknown result type (might be due to invalid IL or missing references)
			//IL_0366: Unknown result type (might be due to invalid IL or missing references)
			//IL_036b: Unknown result type (might be due to invalid IL or missing references)
			//IL_036c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0371: Unknown result type (might be due to invalid IL or missing references)
			//IL_037e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0385: Unknown result type (might be due to invalid IL or missing references)
			//IL_038a: Unknown result type (might be due to invalid IL or missing references)
			//IL_049b: Unknown result type (might be due to invalid IL or missing references)
			//IL_045c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0431: Unknown result type (might be due to invalid IL or missing references)
			//IL_0436: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d0: 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_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: 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_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: 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_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: 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)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			float num = Vector3.Distance(((Component)GameNetworkManager.Instance.localPlayerController).transform.position, explosionPosition);
			if (num < 14f)
			{
				HUDManager.Instance.ShakeCamera((ScreenShakeType)1);
			}
			else if (num < 25f)
			{
				HUDManager.Instance.ShakeCamera((ScreenShakeType)0);
			}
			bool flag = false;
			Collider[] array = Physics.OverlapSphere(explosionPosition, damageRange, 2621448, (QueryTriggerInteraction)2);
			RaycastHit val = default(RaycastHit);
			Vector3 val3;
			PlayerControllerB component;
			for (int i = 0; i < array.Length; i++)
			{
				float num2 = Vector3.Distance(explosionPosition, ((Component)array[i]).transform.position);
				if (Physics.Linecast(explosionPosition, ((Component)array[i]).transform.position + Vector3.up * 0.3f, ref val, 1073742080, (QueryTriggerInteraction)1) && ((!goThroughCar && ((Component)((RaycastHit)(ref val)).collider).gameObject.layer == 30) || !(num2 <= 4f)))
				{
					continue;
				}
				if (((Component)array[i]).gameObject.layer == 3 && !flag)
				{
					component = ((Component)array[i]).gameObject.GetComponent<PlayerControllerB>();
					if ((Object)(object)component != (Object)null && ((NetworkBehaviour)component).IsOwner)
					{
						flag = true;
						if (num2 < killRange)
						{
							Vector3 val2 = Vector3.Normalize(((Component)component.gameplayCamera).transform.position - explosionPosition) * 80f / Vector3.Distance(((Component)component.gameplayCamera).transform.position, explosionPosition);
							PlayerControllerB obj = component;
							val3 = default(Vector3);
							obj.KillPlayer(val2, true, (CauseOfDeath)3, 0, val3);
						}
						else if (num2 < damageRange)
						{
							Vector3 val4 = Vector3.Normalize(((Component)component.gameplayCamera).transform.position - explosionPosition) * 80f / Vector3.Distance(((Component)component.gameplayCamera).transform.position, explosionPosition);
							component.DamagePlayer(nonLethalDamage, true, true, (CauseOfDeath)3, 0, false, val4);
						}
					}
				}
				else if (((Component)array[i]).gameObject.layer == 19)
				{
					EnemyAICollisionDetect componentInChildren = ((Component)array[i]).gameObject.GetComponentInChildren<EnemyAICollisionDetect>();
					if ((Object)(object)componentInChildren != (Object)null && ((NetworkBehaviour)componentInChildren.mainScript).IsOwner && num2 < 4.5f && ((Object)((Component)componentInChildren).gameObject).name.ToLower().Contains("moai"))
					{
						EnemyAI mainScript = componentInChildren.mainScript;
						val3 = default(Vector3);
						mainScript.HitEnemyOnLocalClient(6, val3, (PlayerControllerB)null, false, -1);
						componentInChildren.mainScript.HitFromExplosion(num2);
					}
				}
			}
			component = GameNetworkManager.Instance.localPlayerController;
			if (physicsForce > 0f && Vector3.Distance(((Component)component).transform.position, explosionPosition) < 35f && !Physics.Linecast(explosionPosition, ((Component)component).transform.position + Vector3.up * 0.3f, ref val, 256, (QueryTriggerInteraction)1))
			{
				float num3 = Vector3.Distance(((Component)component).transform.position, explosionPosition);
				Vector3 val5 = Vector3.Normalize(((Component)component).transform.position + Vector3.up * num3 - explosionPosition) / (num3 * 0.35f) * physicsForce;
				if (((Vector3)(ref val5)).magnitude > 2f)
				{
					if (((Vector3)(ref val5)).magnitude > 10f)
					{
						component.CancelSpecialTriggerAnimations();
					}
					if (component.inVehicleAnimation)
					{
						val3 = component.externalForceAutoFade + val5;
						if (!(((Vector3)(ref val3)).magnitude > 50f))
						{
							goto IL_0407;
						}
					}
					PlayerControllerB obj2 = component;
					obj2.externalForceAutoFade += val5;
				}
			}
			goto IL_0407;
			IL_0407:
			VehicleController val6 = Object.FindObjectOfType<VehicleController>();
			if ((Object)(object)val6 != (Object)null && !val6.magnetedToShip && physicsForce > 0f && Vector3.Distance(((Component)val6).transform.position, explosionPosition) < 35f)
			{
				val6.mainRigidbody.AddExplosionForce(physicsForce * 50f, explosionPosition, 12f, 3f, (ForceMode)1);
			}
			int num4 = ~LayerMask.GetMask(new string[1] { "Room" });
			num4 = ~LayerMask.GetMask(new string[1] { "Colliders" });
			array = Physics.OverlapSphere(explosionPosition, 10f, num4);
			for (int j = 0; j < array.Length; j++)
			{
				Rigidbody component2 = ((Component)array[j]).GetComponent<Rigidbody>();
				if ((Object)(object)component2 != (Object)null)
				{
					component2.AddExplosionForce(70f, explosionPosition, 10f);
				}
			}
		}

		[ClientRpc]
		public void explosionClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2935351581u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2935351581u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					explosionParticles.Play();
					explosionImpactSound.Play();
					moaiSpawnExplosion(((Component)this).transform.position, 0f, impactRange, impactDamage, impactForce, null, goThroughCar: true);
				}
			}
		}

		[ClientRpc]
		public void playUndergroundSoundClientRpc(bool active)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(889205728u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref active, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 889205728u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (active)
				{
					customMoaiDigSound.Play();
				}
				else
				{
					customMoaiDigSound.Stop();
				}
			}
		}

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

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

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

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

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

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

		private bool ShouldKidnap(PlayerControllerB target)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: 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_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)target == (Object)null || target.isPlayerDead || (Object)(object)yoinkedPlayer != (Object)null)
			{
				return false;
			}
			float num = Vector3.Distance(((Component)this).transform.position, ((Component)target).transform.position);
			if (num > 16.5f)
			{
				return false;
			}
			Vector3 val = ((Component)this).transform.position - ((Component)target.gameplayCamera).transform.position;
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			float num2 = Vector3.Dot(((Component)target.gameplayCamera).transform.forward, normalized);
			float num3 = 0.15f;
			float num4 = Mathf.Clamp01((0f - num2 - 0.1f) / 0.9f);
			float num5 = Mathf.Lerp(num3, 1f, num4);
			float num6 = Random.Range(0f, 1f);
			return num6 < num5;
		}

		public override void DoAIInterval()
		{
			//IL_0486: Unknown result type (might be due to invalid IL or missing references)
			//IL_0496: Unknown result type (might be due to invalid IL or missing references)
			//IL_04dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_043e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0622: Unknown result type (might be due to invalid IL or missing references)
			//IL_0632: Unknown result type (might be due to invalid IL or missing references)
			//IL_0648: Unknown result type (might be due to invalid IL or missing references)
			//IL_053a: Unknown result type (might be due to invalid IL or missing references)
			//IL_054a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0560: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b3: 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)
			if (!((NetworkBehaviour)RoundManager.Instance).IsHost)
			{
				return;
			}
			letGoTimer -= 0.2f;
			if (((EnemyAI)this).isEnemyDead)
			{
				if (customMoaiDigSound.isPlaying)
				{
					customMoaiDigSound.Stop();
				}
				if (((NetworkBehaviour)RoundManager.Instance).IsHost && Object.op_Implicit((Object)(object)yoinkedPlayer))
				{
					letGoOfPlayerClientRpc(((NetworkBehaviour)yoinkedPlayer).NetworkObject.NetworkObjectId);
				}
				return;
			}
			if (isUnderground)
			{
				if (!undergroundParticleSystem.isEmitting)
				{
					ToggleUndergroundParticlesClientRpc(value: true);
				}
			}
			else if (undergroundParticleSystem.isEmitting)
			{
				ToggleUndergroundParticlesClientRpc(value: false);
			}
			if (((EnemyAI)this).currentBehaviourStateIndex == 6 && sneakingUpOnPlayer)
			{
				customMoaiDrillSound.volume = 0.15f * Plugin.moaiGlobalMusicVol.Value;
				customMoaiDigSound.volume = 0.1f * Plugin.moaiGlobalMusicVol.Value;
			}
			else
			{
				customMoaiDrillSound.volume = 0.647f * Plugin.moaiGlobalMusicVol.Value;
				customMoaiDigSound.volume = 0.208f * Plugin.moaiGlobalMusicVol.Value;
			}
			List<RedLocustBees> list = new List<RedLocustBees>();
			for (int i = 0; i < spawnedBees.Count; i++)
			{
				RedLocustBees val = spawnedBees[i];
				if ((Object)(object)val == (Object)null)
				{
					list.Add(val);
				}
				else if (Object.op_Implicit((Object)(object)val.hive))
				{
					moveHiveClientRpc(((NetworkBehaviour)val).NetworkObject.NetworkObjectId);
				}
			}
			for (int j = 0; j < list.Count; j++)
			{
				RedLocustBees item = list[j];
				spawnedBees.Remove(item);
			}
			((EnemyAI)this).DoAIInterval();
			baseAIInterval();
			if (Object.op_Implicit((Object)(object)yoinkedPlayer) && yoinkedPlayer.isPlayerDead)
			{
				yoinkedPlayer = null;
			}
			if (((EnemyAI)this).currentBehaviourStateIndex != 7)
			{
				isInLeapSequence = false;
			}
			if ((letGoTimer < 0f && (Object)(object)yoinkedPlayer != (Object)null) || ((Object)(object)yoinkedPlayer != (Object)null && yoinkedPlayer.isPlayerDead))
			{
				letGoOfPlayerClientRpc(((NetworkBehaviour)yoinkedPlayer).NetworkObject.NetworkObjectId);
			}
			((EnemyAI)this).agent.acceleration = 8f * Plugin.moaiGlobalSpeed.Value;
			switch (((EnemyAI)this).currentBehaviourStateIndex)
			{
			case 0:
				baseSearchingForPlayer();
				break;
			case 5:
				baseHeadingToEntrance();
				break;
			case 1:
				baseGuard();
				break;
			case 2:
				baseStickingInFrontOfEnemy();
				break;
			case 3:
				baseStickingInFrontOfPlayer();
				if (Object.op_Implicit((Object)(object)((EnemyAI)this).targetPlayer))
				{
					if (ShouldKidnap(((EnemyAI)this).targetPlayer))
					{
						sneakingUpOnPlayer = true;
						kidnapImpatienceTimer = kidnapImpatienceDuration;
						targetToYoink = ((EnemyAI)this).targetPlayer;
						((EnemyAI)this).SwitchToBehaviourClientRpc(6);
						((EnemyAI)this).StopSearch(((EnemyAI)this).currentSearch, true);
					}
					else
					{
						((EnemyAI)this).SwitchToBehaviourClientRpc(7);
						doneWithLeaps = false;
					}
				}
				break;
			case 4:
				baseHeadSwingAttackInProgress();
				break;
			case 7:
				((EnemyAI)this).agent.speed = 0f;
				if (!isInLeapSequence && !doneWithLeaps)
				{
					isInLeapSequence = true;
					((MonoBehaviour)this).StartCoroutine(DoGroundHopSequence(Random.Range(2, 5)));
				}
				else if (doneWithLeaps)
				{
					((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
					((EnemyAI)this).targetPlayer = null;
					((EnemyAI)this).SwitchToBehaviourClientRpc(0);
				}
				break;
			case 6:
				stopAllSound();
				if (!Object.op_Implicit((Object)(object)targetToYoink) || targetToYoink.isPlayerDead || Vector3.Distance(((Component)this).transform.position, ((Component)targetToYoink).transform.position) > 35f)
				{
					((EnemyAI)this).SwitchToBehaviourClientRpc(0);
					((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
					break;
				}
				((EnemyAI)this).SetDestinationToPosition(((Component)targetToYoink).transform.position, false);
				if (sneakingUpOnPlayer)
				{
					((EnemyAI)this).agent.speed = 5.3f * Plugin.moaiGlobalSpeed.Value;
					kidnapImpatienceTimer -= 0.2f;
					if (isUnderground)
					{
						if (Vector3.Distance(((Component)this).transform.position, ((Component)targetToYoink).transform.position) < grabRange * ((Component)this).transform.localScale.x)
						{
							sneakingUpOnPlayer = false;
							diggingState = 1;
						}
					}
					else
					{
						diggingState = 2;
					}
					if (kidnapImpatienceTimer <= 0f)
					{
						cycleTimer = 0f;
						diggingState = 1;
						letGoTimer = (float)(enemyRandom.NextDouble() * 25.0 + 2.0);
						((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
						((EnemyAI)this).SwitchToBehaviourClientRpc(0);
					}
				}
				else if (isUnderground)
				{
					diggingState = 1;
				}
				else if (Vector3.Distance(((Component)this).transform.position, ((Component)targetToYoink).transform.position) < grabRange * ((Component)this).transform.localScale.x)
				{
					attachPlayerClientRpc(((NetworkBehaviour)targetToYoink).NetworkObject.NetworkObjectId, healPlayer: true);
					cycleTimer = 0f;
					diggingState = 2;
					letGoTimer = (float)(enemyRandom.NextDouble() * 25.0 + 2.0);
					((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
					((EnemyAI)this).SwitchToBehaviourClientRpc(0);
				}
				else
				{
					letGoTimer = (float)(enemyRandom.NextDouble() * 25.0 + 2.0);
					((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
					((EnemyAI)this).SwitchToBehaviourClientRpc(0);
				}
				break;
			default:
				LogDebug("This Behavior State doesn't exist!");
				break;
			}
		}

		[ClientRpc]
		public void attachPlayerClientRpc(ulong playerId, bool healPlayer = false)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3618973511u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, playerId);
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref healPlayer, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3618973511u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			RoundManager instance = RoundManager.Instance;
			PlayerControllerB[] allPlayerScripts = instance.playersManager.allPlayerScripts;
			foreach (PlayerControllerB val3 in allPlayerScripts)
			{
				if (((NetworkBehaviour)val3).NetworkObject.NetworkObjectId == playerId)
				{
					yoinkedPlayer = val3;
					((Component)val3).transform.position = playerGrabPoint.position;
					((Component)val3).transform.parent = playerGrabPoint;
					val3.playerCollider.enabled = false;
					if (healPlayer)
					{
						val3.DamagePlayer(-30, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
					}
					break;
				}
			}
		}

		[ClientRpc]
		public void letGoOfPlayerClientRpc(ulong playerId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(567840958u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, playerId);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 567840958u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			PlayerControllerB val3 = null;
			RoundManager instance = RoundManager.Instance;
			PlayerControllerB[] allPlayerScripts = instance.playersManager.allPlayerScripts;
			foreach (PlayerControllerB val4 in allPlayerScripts)
			{
				if (((NetworkBehaviour)val4).NetworkObject.NetworkObjectId == playerId)
				{
					val3 = val4;
				}
			}
			((Component)val3).transform.parent = null;
			val3.playerCollider.enabled = true;
			NavMeshHit val5 = default(NavMeshHit);
			if (NavMesh.SamplePosition(((Component)val3).transform.position, ref val5, 15f, -1))
			{
				((Component)val3).transform.position = ((NavMeshHit)(ref val5)).position;
			}
			yoinkedPlayer = null;
		}

		[ClientRpc]
		public void ToggleUndergroundParticlesClientRpc(bool value)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1832729899u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref value, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1832729899u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (value)
				{
					undergroundParticleSystem.Play();
				}
				else
				{
					undergroundParticleSystem.Stop();
				}
			}
		}

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

		public IEnumerator DoGroundHopSequence(int amount)
		{
			((Behaviour)((EnemyAI)this).agent).enabled = false;
			diggingState = 2;
			orangeDigClientRpc();
			yield return (object)new WaitForSeconds(1.1f);
			ToggleUndergroundParticlesClientRpc(value: true);
			playPrepareSoundClientRpc();
			yield return (object)new WaitForSeconds(0.7f);
			undergroundParticleSystem.Stop();
			diggingState = 0;
			for (int i = 0; i < amount; i++)
			{
				Vector3 dir = Random.insideUnitSphere;
				dir.y = 0f;
				((Vector3)(ref dir)).Normalize();
				stamina -= 20f;
				ToggleUndergroundParticlesClientRpc(value: false);
				PlayEmergeParticlesClientRpc();
				playHitSoundClientRpc();
				if ((Object)(object)((EnemyAI)this).targetPlayer == (Object)null)
				{
					break;
				}
				Vector3 target = GetSmartHopTarget(((Component)this).transform.position, ((Component)((EnemyAI)this).targetPlayer).transform.position, hopMinRange, hopMaxRange);
				yield return ((MonoBehaviour)this).StartCoroutine(DoGroundHop(target));
				yield return (object)new WaitForSeconds(Random.Range(0.4f, 0.6f));
				dir = default(Vector3);
			}
			playHitSoundClientRpc();
			yield return (object)new WaitForSeconds(1.1f);
			((Behaviour)((EnemyAI)this).agent).enabled = true;
			isInLeapSequence = false;
			doneWithLeaps = true;
			if (stamina < 0f)
			{
				stamina = 0f;
			}
			recovering = true;
		}

		private Vector3 GetSmartHopTarget(Vector3 origin, Vector3 playerPos, float minRange, float maxRange)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//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_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: 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_0039: 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_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			/