Decompiled source of EeveeFrenzy v0.0.3

plugins/EeveeFrenzy/EeveeFrenzy.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
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 BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using EeveeFrenzy.NetcodePatcher;
using EeveeFrenzy.src.Content.Enemies;
using EeveeFrenzy.src.Content.Items;
using EeveeFrenzy.src.MiscScripts;
using EeveeFrenzy.src.Patches;
using EeveeFrenzy.src.Util;
using EeveeFrenzy.src.Util.AssetLoading;
using EeveeFrenzy.src.Util.Extensions;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using On;
using On.GameNetcodeStuff;
using Unity.Mathematics;
using Unity.Netcode;
using Unity.Netcode.Components;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Events;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("EeveeFrenzy")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("I need to fill this in!")]
[assembly: AssemblyFileVersion("0.0.3.0")]
[assembly: AssemblyInformationalVersion("0.0.3+554623f1d5efdfde46290717da5ef594ac58b9bf")]
[assembly: AssemblyProduct("EeveeFrenzy")]
[assembly: AssemblyTitle("EeveeFrenzy")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.3.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 EeveeFrenzy
{
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "EeveeFrenzy";

		public const string PLUGIN_NAME = "EeveeFrenzy";

		public const string PLUGIN_VERSION = "0.0.3";
	}
}
namespace EeveeFrenzy.Util.Extensions
{
	internal static class ObjectExtensions
	{
		public static string ToStringWithDefault(this object it, string defaultString = "null")
		{
			return it.ToString().OrIfEmpty(defaultString);
		}
	}
	internal static class StringExtensions
	{
		public static string OrIfEmpty(this string? self, string defaultValue)
		{
			if (string.IsNullOrEmpty(self))
			{
				return defaultValue;
			}
			return self;
		}
	}
}
namespace EeveeFrenzy.src
{
	public class EeveeFrenzyConfig
	{
		public ConfigEntry<bool> ConfigEnableExtendedLogging { get; private set; }

		public ConfigEntry<string> ConfigUmbreonSpawnWeight { get; private set; }

		public ConfigEntry<string> ConfigEspeonSpawnWeight { get; private set; }

		public ConfigEntry<string> ConfigJolteonSpawnWeight { get; private set; }

		public ConfigEntry<string> ConfigLeafeonSpawnWeight { get; private set; }

		public ConfigEntry<string> ConfigMechaSylveonSpawnWeight { get; private set; }

		public ConfigEntry<string> ConfigGlaceonSpawnWeight { get; private set; }

		public ConfigEntry<string> ConfigVaporeonSpawnWeight { get; private set; }

		public ConfigEntry<string> ConfigFlareonSpawnWeight { get; private set; }

		public EeveeFrenzyConfig(ConfigFile configFile)
		{
			configFile.SaveOnConfigSet = false;
			ConfigEnableExtendedLogging = configFile.Bind<bool>("Debug Options", "Debug Mode | Enable Extended Logging", false, "Whether extended logging is enabled.");
			ConfigUmbreonSpawnWeight = configFile.Bind<string>("Eevee Frenzy", "Umbreon Spawn Weight", "Vanilla:10,Custom:10", "Spawn weight of Umbreon.");
			ConfigEspeonSpawnWeight = configFile.Bind<string>("Eevee Frenzy", "Espeon Spawn Weight", "Vanilla:10,Custom:10", "Spawn weight of Espeon.");
			ConfigJolteonSpawnWeight = configFile.Bind<string>("Eevee Frenzy", "Jolteon Spawn Weight", "Vanilla:10,Custom:10", "Spawn weight of Jolteon.");
			ConfigLeafeonSpawnWeight = configFile.Bind<string>("Eevee Frenzy", "Leafeon Spawn Weight", "Vanilla:10,Custom:10", "Spawn weight of Leafeon.");
			ConfigMechaSylveonSpawnWeight = configFile.Bind<string>("Eevee Frenzy", "Sylveon Spawn Weight", "Vanilla:10,Custom:10", "Spawn weight of Sylveon.");
			ConfigGlaceonSpawnWeight = configFile.Bind<string>("Eevee Frenzy", "Glaceon Spawn Weight", "Vanilla:10,Custom:10", "Spawn weight of Glaceon.");
			ConfigVaporeonSpawnWeight = configFile.Bind<string>("Eevee Frenzy", "Vaporeon Spawn Weight", "Vanilla:10,Custom:10", "Spawn weight of Vaporeon.");
			ConfigFlareonSpawnWeight = configFile.Bind<string>("Eevee Frenzy", "Flareon Spawn Weight", "Vanilla:10,Custom:10", "Spawn weight of Flareon.");
			configFile.SaveOnConfigSet = true;
			ClearUnusedEntries(configFile);
		}

		private void ClearUnusedEntries(ConfigFile configFile)
		{
			PropertyInfo property = ((object)configFile).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic);
			Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)property.GetValue(configFile, null);
			dictionary.Clear();
			configFile.Save();
		}
	}
	[BepInPlugin("EeveeFrenzy", "EeveeFrenzy", "0.0.3")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		internal class MainAssets : AssetBundleLoader<MainAssets>
		{
			[LoadFromBundle("EeveeFrenzyUtils.prefab")]
			public GameObject UtilsPrefab { get; private set; }

			public MainAssets(string bundleName)
				: base(bundleName, registerNetworkPrefabs: true, fixMixerGroups: true)
			{
			}
		}

		internal static ManualLogSource Logger = null;

		internal static readonly Harmony _harmony = new Harmony("EeveeFrenzy");

		internal static readonly Dictionary<string, AssetBundle> LoadedBundles = new Dictionary<string, AssetBundle>();

		internal static readonly Dictionary<string, Item> samplePrefabs = new Dictionary<string, Item>();

		public static EeveeFrenzyConfig ModConfig { get; private set; } = null;


		internal static MainAssets Assets { get; private set; } = null;


		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			ModConfig = new EeveeFrenzyConfig(((BaseUnityPlugin)this).Config);
			PlayerControllerBPatch.Init();
			DoorLockPatch.Init();
			MineshaftElevatorControllerPatch.Init();
			_harmony.PatchAll(typeof(StartOfRoundPatch));
			Assets = new MainAssets("eeveefrenzyassets");
			InitializeNetworkBehaviours();
			Logger.LogInfo((object)"Registering content.");
			RegisterContentHandlers(Assembly.GetExecutingAssembly());
			Logger.LogInfo((object)"Plugin EeveeFrenzy is loaded!");
		}

		public static void RegisterContentHandlers(Assembly assembly)
		{
			List<Type> list = (from x in assembly.GetLoadableTypes()
				where x.BaseType != null && x.BaseType.IsGenericType && x.BaseType.GetGenericTypeDefinition() == typeof(ContentHandler<>)
				select x).ToList();
			foreach (Type item in list)
			{
				item.GetConstructor(Array.Empty<Type>()).Invoke(Array.Empty<object>());
			}
		}

		private void OnDisable()
		{
			foreach (AssetBundle value in LoadedBundles.Values)
			{
				value.Unload(false);
			}
			Logger.LogDebug((object)"Unloaded assetbundles.");
			LoadedBundles.Clear();
		}

		internal static void ExtendedLogging(object text)
		{
			if (ModConfig.ConfigEnableExtendedLogging.Value)
			{
				Logger.LogInfo(text);
			}
		}

		private void InitializeNetworkBehaviours()
		{
			IEnumerable<Type> loadableTypes = Assembly.GetExecutingAssembly().GetLoadableTypes();
			foreach (Type item in loadableTypes)
			{
				if (item.IsNested || !typeof(NetworkBehaviour).IsAssignableFrom(item))
				{
					continue;
				}
				MethodInfo[] methods = item.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array = methods;
				foreach (MethodInfo methodInfo in array)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}
	}
}
namespace EeveeFrenzy.src.Util
{
	public class ContentHandler<T> where T : ContentHandler<T>
	{
		internal static T Instance { get; private set; }

		internal ContentHandler()
		{
			Instance = (T)this;
		}

		protected void RegisterEnemyWithConfig(string configMoonRarity, EnemyType enemy, TerminalNode? terminalNode, TerminalKeyword? terminalKeyword, float powerLevel, int spawnCount)
		{
			enemy.MaxCount = spawnCount;
			enemy.PowerLevel = powerLevel;
			var (dictionary, dictionary2) = ConfigParsing(configMoonRarity);
			Enemies.RegisterEnemy(enemy, dictionary, dictionary2, terminalNode, terminalKeyword);
		}

		protected void RegisterScrapWithConfig(string configMoonRarity, Item scrap, int itemWorthMin, int itemWorthMax)
		{
			if (itemWorthMax != -1 && itemWorthMin != -1)
			{
				if (itemWorthMax < itemWorthMin)
				{
					itemWorthMax = itemWorthMin;
				}
				scrap.minValue = (int)((float)itemWorthMin / 0.4f);
				scrap.maxValue = (int)((float)itemWorthMax / 0.4f);
			}
			var (dictionary, dictionary2) = ConfigParsing(configMoonRarity);
			Items.RegisterScrap(scrap, dictionary, dictionary2);
		}

		protected void RegisterShopItemWithConfig(bool enabledScrap, Item item, TerminalNode terminalNode, int itemCost, string configMoonRarity, int minWorth, int maxWorth)
		{
			Items.RegisterShopItem(item, (TerminalNode)null, (TerminalNode)null, terminalNode, itemCost);
			if (enabledScrap)
			{
				RegisterScrapWithConfig(configMoonRarity, item, minWorth, maxWorth);
			}
		}

		protected LevelTypes LevelToLevelType(string levelName)
		{
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: 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_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			Plugin.ExtendedLogging("Cutup Level type: " + levelName);
			return (LevelTypes)(levelName switch
			{
				"experimentation" => 4, 
				"assurance" => 8, 
				"offense" => 32, 
				"march" => 64, 
				"vow" => 16, 
				"dine" => 256, 
				"rend" => 128, 
				"titan" => 512, 
				"artifice" => 4096, 
				"adamance" => 2048, 
				"embrion" => 8192, 
				"vanilla" => 15356, 
				"modded" => 1024, 
				_ => 1, 
			});
		}

		protected string[] MapObjectConfigParsing(string configString)
		{
			List<string> list = new List<string>();
			foreach (string item in from s in configString.Split(',')
				select s.Trim())
			{
				string text = item;
				if (Enum.TryParse<LevelTypes>(text, ignoreCase: true, out LevelTypes result))
				{
					list.Add(text);
					continue;
				}
				string text2 = text + "Level";
				if (Enum.TryParse<LevelTypes>(text2, ignoreCase: true, out result))
				{
					list.Add(text2);
				}
				else
				{
					list.Add(text);
				}
			}
			return list.ToArray();
		}

		protected (Dictionary<LevelTypes, int> spawnRateByLevelType, Dictionary<string, int> spawnRateByCustomLevelType) ConfigParsing(string configMoonRarity)
		{
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<LevelTypes, int> dictionary = new Dictionary<LevelTypes, int>();
			Dictionary<string, int> dictionary2 = new Dictionary<string, int>();
			foreach (string item in from s in configMoonRarity.Split(',')
				select s.Trim())
			{
				string[] array = (from s in item.Split(':')
					select s.Trim()).ToArray();
				if (array.Length != 2)
				{
					continue;
				}
				string text = array[0].ToLowerInvariant();
				if (!int.TryParse(array[1], out var result))
				{
					continue;
				}
				if (text == "custom")
				{
					text = "modded";
				}
				if (Enum.TryParse<LevelTypes>(text, ignoreCase: true, out LevelTypes result2))
				{
					dictionary[result2] = result;
					continue;
				}
				string value = text + "Level";
				if (Enum.TryParse<LevelTypes>(value, ignoreCase: true, out result2))
				{
					dictionary[result2] = result;
				}
				else
				{
					dictionary2[text] = result;
				}
			}
			return (dictionary, dictionary2);
		}

		protected (Dictionary<LevelTypes, string> spawnRateByLevelType, Dictionary<string, string> spawnRateByCustomLevelType) ConfigParsingWithCurve(string configMoonRarity)
		{
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<LevelTypes, string> dictionary = new Dictionary<LevelTypes, string>();
			Dictionary<string, string> dictionary2 = new Dictionary<string, string>();
			foreach (string item in from s in configMoonRarity.Split('|')
				select s.Trim())
			{
				string[] array = (from s in item.Split('-')
					select s.Trim()).ToArray();
				if (array.Length != 2)
				{
					continue;
				}
				string text = array[0].ToLowerInvariant();
				if (text == "custom")
				{
					text = "modded";
				}
				if (Enum.TryParse<LevelTypes>(text, ignoreCase: true, out LevelTypes result))
				{
					dictionary[result] = array[1];
					continue;
				}
				string value = text + "level";
				if (Enum.TryParse<LevelTypes>(value, ignoreCase: true, out result))
				{
					dictionary[result] = array[1];
				}
				else
				{
					dictionary2[text] = array[1];
				}
			}
			return (dictionary, dictionary2);
		}

		protected int[] ChangeItemValues(string config)
		{
			string[] array = (from s in config.Split(',')
				select s.Trim()).ToArray();
			string[] array2 = array;
			foreach (string text in array2)
			{
				text.Trim();
			}
			int num = -1;
			int num2 = -1;
			if (array.Length == 2)
			{
				Plugin.ExtendedLogging("[Scrap Worth] Changing item worth between " + array[0] + " and " + array[1]);
				num = int.Parse(array[0]);
				num2 = int.Parse(array[1]);
			}
			return new int[2] { num, num2 };
		}

		public AnimationCurve CreateCurveFromString(string keyValuePairs, string nameOfThing, string MoonName)
		{
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Expected O, but got Unknown
			//IL_008a: 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_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Expected O, but got Unknown
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Expected O, but got Unknown
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			Plugin.ExtendedLogging("Creating curve for " + nameOfThing + " on moon " + MoonName + " with key-value pairs: " + keyValuePairs);
			string[] array = (from s in keyValuePairs.Split(';')
				select s.Trim()).ToArray();
			if (array.Length == 0)
			{
				if (!int.TryParse(keyValuePairs, out var result))
				{
					Plugin.Logger.LogError((object)("Invalid key-value pairs format: " + keyValuePairs));
					return new AnimationCurve((Keyframe[])(object)new Keyframe[2]
					{
						new Keyframe(0f, 0f),
						new Keyframe(1f, 0f)
					});
				}
				return new AnimationCurve((Keyframe[])(object)new Keyframe[2]
				{
					new Keyframe(0f, 0f),
					new Keyframe(1f, (float)result)
				});
			}
			List<Keyframe> list = new List<Keyframe>();
			string[] array2 = array;
			foreach (string text in array2)
			{
				string[] array3 = (from s in text.Split(',')
					select s.Trim()).ToArray();
				if (array3.Length == 2 && float.TryParse(array3[0], NumberStyles.Float, CultureInfo.InvariantCulture, out var result2) && float.TryParse(array3[1], NumberStyles.Float, CultureInfo.InvariantCulture, out var result3))
				{
					Plugin.ExtendedLogging($"Adding keyframe for {nameOfThing} at time {result2} with value {result3}");
					list.Add(new Keyframe(result2, result3));
					continue;
				}
				Plugin.Logger.LogError((object)("Failed config for hazard: " + nameOfThing));
				Plugin.Logger.LogError((object)$"Split pair length: {array3.Length}");
				Plugin.Logger.LogError((object)$"Could parse first value: {float.TryParse(array3[0], NumberStyles.Float, CultureInfo.InvariantCulture, out var result4)}, instead got: {result4}, with splitPair0 being: {array3[0]}");
				Plugin.Logger.LogError((object)$"Could parse second value: {float.TryParse(array3[1], NumberStyles.Float, CultureInfo.InvariantCulture, out var result5)}, instead got: {result5}, with splitPair1 being: {array3[1]}");
				Plugin.Logger.LogError((object)("Invalid key,value pair format: " + text));
			}
			return new AnimationCurve(list.ToArray());
		}
	}
	internal class EeveeFrenzyUtils : NetworkBehaviour
	{
		private static Random random;

		internal static EeveeFrenzyUtils Instance { get; private set; }

		private void Awake()
		{
			Instance = this;
		}

		[ServerRpc(RequireOwnership = false)]
		public void SpawnScrapServerRpc(string itemName, Vector3 position, bool defaultRotation = true, int valueIncrease = 0)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: 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_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: 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)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(861815319u, val, (RpcDelivery)0);
				bool flag = itemName != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(itemName, false);
				}
				((FastBufferWriter)(ref val2)).WriteValueSafe(ref position);
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref defaultRotation, default(ForPrimitives));
				BytePacker.WriteValueBitPacked(val2, valueIncrease);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 861815319u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost) && !(itemName == string.Empty))
			{
				Plugin.samplePrefabs.TryGetValue(itemName, out Item value);
				if ((Object)(object)value == (Object)null)
				{
					Plugin.Logger.LogError((object)("'" + itemName + "' either isn't a EeveeFrenzy scrap or not registered! This method only handles EeveeFrenzy scrap!"));
				}
				else
				{
					SpawnScrap(value, position, defaultRotation, valueIncrease);
				}
			}
		}

		public NetworkObjectReference SpawnScrap(Item item, Vector3 position, bool defaultRotation, int valueIncrease)
		{
			//IL_000f: 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_0052: 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_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)StartOfRound.Instance == (Object)null)
			{
				return default(NetworkObjectReference);
			}
			if (random == null)
			{
				random = new Random(StartOfRound.Instance.randomMapSeed + 85);
			}
			Transform val = null;
			if ((Object)(object)val == (Object)null)
			{
				val = StartOfRound.Instance.propsContainer;
			}
			GameObject val2 = Object.Instantiate<GameObject>(item.spawnPrefab, position + Vector3.up * 0.2f, defaultRotation ? Quaternion.Euler(item.restingRotation) : Quaternion.identity, val);
			val2.GetComponent<NetworkObject>().Spawn(false);
			int num = (int)((float)random.NextInt(item.minValue, item.maxValue) * RoundManager.Instance.scrapValueMultiplier) + valueIncrease;
			ScanNodeProperties componentInChildren = val2.GetComponentInChildren<ScanNodeProperties>();
			componentInChildren.scrapValue = num;
			componentInChildren.subText = $"Value: ${num}";
			val2.GetComponent<GrabbableObject>().scrapValue = num;
			UpdateScanNodeClientRpc(new NetworkObjectReference(val2), num);
			return new NetworkObjectReference(val2);
		}

		[ClientRpc]
		public void UpdateScanNodeClientRpc(NetworkObjectReference go, int value)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3566988089u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref go, default(ForNetworkSerializable));
				BytePacker.WriteValueBitPacked(val2, value);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3566988089u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				NetworkObject val3 = default(NetworkObject);
				((NetworkObjectReference)(ref go)).TryGet(ref val3, (NetworkManager)null);
				GrabbableObject val4 = default(GrabbableObject);
				if ((Object)(object)val3 != (Object)null && ((Component)val3).gameObject.TryGetComponent<GrabbableObject>(ref val4))
				{
					val4.SetScrapValue(value);
					Plugin.ExtendedLogging($"Scrap Value: {value}");
				}
			}
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_EeveeFrenzyUtils()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(861815319u, new RpcReceiveHandler(__rpc_handler_861815319));
			NetworkManager.__rpc_func_table.Add(3566988089u, new RpcReceiveHandler(__rpc_handler_3566988089));
		}

		private static void __rpc_handler_861815319(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string itemName = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref itemName, false);
				}
				Vector3 position = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref position);
				bool defaultRotation = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref defaultRotation, default(ForPrimitives));
				int valueIncrease = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref valueIncrease);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((EeveeFrenzyUtils)(object)target).SpawnScrapServerRpc(itemName, position, defaultRotation, valueIncrease);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3566988089(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkObjectReference go = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref go, default(ForNetworkSerializable));
				int value = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref value);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((EeveeFrenzyUtils)(object)target).UpdateScanNodeClientRpc(go, value);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "EeveeFrenzyUtils";
		}
	}
}
namespace EeveeFrenzy.src.Util.Extensions
{
	public static class AssemblyExtensions
	{
		internal static IEnumerable<Type> GetLoadableTypes(this Assembly assembly)
		{
			if (assembly == null)
			{
				throw new ArgumentNullException("assembly");
			}
			try
			{
				return assembly.GetTypes();
			}
			catch (ReflectionTypeLoadException ex)
			{
				return ex.Types.Where((Type t) => t != null);
			}
		}
	}
	public static class ManualLogSourceExtensions
	{
		[Conditional("DEBUG")]
		public static void LogVerbose(this ManualLogSource logger, object data)
		{
			logger.LogInfo(data);
		}
	}
	public static class NetworkObjectExtensions
	{
		public static IEnumerator WaitUntilSpawned(this NetworkObject networkObject)
		{
			NetworkObject networkObject2 = networkObject;
			yield return (object)new WaitUntil((Func<bool>)(() => networkObject2.IsSpawned));
		}

		private static IEnumerator RunActionAfterSpawned(NetworkObject networkObject, Action action)
		{
			yield return networkObject.WaitUntilSpawned();
			action();
		}

		public static void OnSpawn(this NetworkObject networkObject, Action action)
		{
			((MonoBehaviour)networkObject).StartCoroutine(RunActionAfterSpawned(networkObject, action));
		}
	}
	public static class RandomExtensions
	{
		public static T NextEnum<T>(this Random random) where T : struct, Enum
		{
			Array values = Enum.GetValues(typeof(T));
			return (T)values.GetValue(random.Next(values.Length));
		}

		public static T NextItem<T>(this Random random, List<T> collection)
		{
			int index = random.Next(collection.Count);
			return collection[index];
		}

		public static T NextItem<T>(this Random random, T[] collection)
		{
			int num = random.Next(collection.Length);
			return collection[num];
		}

		public static double NextDouble(this Random random, double min, double max)
		{
			return random.NextDouble() * (max - min) + min;
		}

		public static float NextFloat(this Random random, float min, float max)
		{
			return (float)random.NextDouble(min, max);
		}

		public static int NextInt(this Random random, int min, int max)
		{
			return random.Next(min, max + 1);
		}

		public static bool NextBool(this Random random)
		{
			return random.Next(0, 2) == 0;
		}

		public static int NextSign(this Random random)
		{
			if (!random.NextBool())
			{
				return -1;
			}
			return 1;
		}

		public static Quaternion NextQuaternion(this Random random)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			return quaternion.op_Implicit(quaternion.Euler(random.NextFloat(0f, 360f), random.NextFloat(0f, 360f), random.NextFloat(0f, 360f), (RotationOrder)4));
		}
	}
	public static class ShovelExtensions
	{
		public static int CriticalHit(int force, Random random, float critChance)
		{
			if (random.NextDouble(0.0, 100.0) < (double)Math.Clamp(critChance, 0f, 100f))
			{
				Plugin.ExtendedLogging("Critical Hit!");
				return force * 2;
			}
			return force;
		}
	}
}
namespace EeveeFrenzy.src.Util.AssetLoading
{
	public class AssetBundleLoader<T> where T : AssetBundleLoader<T>
	{
		protected AssetBundle bundle;

		protected AssetBundleLoader(string filePath, bool registerNetworkPrefabs = true, bool fixMixerGroups = true)
		{
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Assets", filePath);
			bool flag = Plugin.LoadedBundles.TryGetValue(text, out bundle);
			if (!flag)
			{
				bundle = AssetBundle.LoadFromFile(text);
				Plugin.LoadedBundles.Add(text, bundle);
				Plugin.Logger.LogDebug((object)("[AssetBundle Loading] " + filePath + " contains these objects: " + string.Join(",", bundle.GetAllAssetNames())));
			}
			else
			{
				flag = true;
				Plugin.Logger.LogDebug((object)("[AssetBundle Loading] Used cached " + filePath));
			}
			Type typeFromHandle = typeof(T);
			PropertyInfo[] properties = typeFromHandle.GetProperties();
			foreach (PropertyInfo propertyInfo in properties)
			{
				LoadFromBundleAttribute loadFromBundleAttribute = (LoadFromBundleAttribute)propertyInfo.GetCustomAttribute(typeof(LoadFromBundleAttribute));
				if (loadFromBundleAttribute != null)
				{
					propertyInfo.SetValue(this, LoadAsset(bundle, loadFromBundleAttribute.BundleFile));
				}
			}
			if (flag)
			{
				Plugin.Logger.LogDebug((object)"Skipping registering stuff as this bundle has already been loaded");
				return;
			}
			GameObject[] array = bundle.LoadAllAssets<GameObject>();
			foreach (GameObject val in array)
			{
				if (fixMixerGroups)
				{
					Utilities.FixMixerGroups(val);
					Plugin.ExtendedLogging("[AssetBundle Loading] Fixed Mixer Groups: " + ((Object)val).name);
				}
				if (registerNetworkPrefabs && !((Object)(object)val.GetComponent<NetworkObject>() == (Object)null))
				{
					NetworkPrefabs.RegisterNetworkPrefab(val);
					Plugin.ExtendedLogging("[AssetBundle Loading] Registered Network Prefab: " + ((Object)val).name);
				}
			}
			Item[] array2 = bundle.LoadAllAssets<Item>();
			foreach (Item val2 in array2)
			{
				if (registerNetworkPrefabs && !((Object)(object)val2.spawnPrefab == (Object)null) && !((Object)(object)val2.spawnPrefab.GetComponent<NetworkObject>() == (Object)null))
				{
					NetworkPrefabs.RegisterNetworkPrefab(val2.spawnPrefab);
					Plugin.ExtendedLogging("[AssetBundle Loading] Registered Network Prefab: " + ((Object)val2).name);
				}
			}
		}

		private Object LoadAsset(AssetBundle bundle, string path)
		{
			Object val = bundle.LoadAsset<Object>(path);
			if (val == (Object)null)
			{
				throw new ArgumentException(path + " is not valid in the assetbundle!");
			}
			return val;
		}
	}
	[AttributeUsage(AttributeTargets.Property)]
	public class LoadFromBundleAttribute : Attribute
	{
		public string BundleFile { get; private set; }

		public LoadFromBundleAttribute(string bundleFile)
		{
			BundleFile = bundleFile;
			base..ctor();
		}
	}
}
namespace EeveeFrenzy.src.Patches
{
	public static class DoorLockPatch
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_OnTriggerStay <0>__DoorLock_OnTriggerStay;
		}

		public static void Init()
		{
			//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_001b: Expected O, but got Unknown
			object obj = <>O.<0>__DoorLock_OnTriggerStay;
			if (obj == null)
			{
				hook_OnTriggerStay val = DoorLock_OnTriggerStay;
				<>O.<0>__DoorLock_OnTriggerStay = val;
				obj = (object)val;
			}
			DoorLock.OnTriggerStay += (hook_OnTriggerStay)obj;
		}

		private static void DoorLock_OnTriggerStay(orig_OnTriggerStay orig, DoorLock self, Collider other)
		{
			if (!((Object)(object)NetworkManager.Singleton == (Object)null) && ((NetworkBehaviour)self).IsServer && !self.isLocked && !self.isDoorOpened && ((Component)other).gameObject.layer == 19 && ((Object)((Component)other).gameObject).name == "DoorCollider")
			{
				self.enemyDoorMeter += Time.deltaTime * 0.5f;
				if (self.enemyDoorMeter > 1f)
				{
					self.enemyDoorMeter = 0f;
					((Component)self).gameObject.GetComponent<AnimatedObjectTrigger>().TriggerAnimationNonPlayer(false, true, false);
					self.OpenDoorAsEnemyServerRpc();
				}
			}
			orig.Invoke(self, other);
		}
	}
	public static class MineshaftElevatorControllerPatch
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_Update <0>__MineshaftElevatorController_Update;
		}

		public static void Init()
		{
			//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_001b: Expected O, but got Unknown
			object obj = <>O.<0>__MineshaftElevatorController_Update;
			if (obj == null)
			{
				hook_Update val = MineshaftElevatorController_Update;
				<>O.<0>__MineshaftElevatorController_Update = val;
				obj = (object)val;
			}
			MineshaftElevatorController.Update += (hook_Update)obj;
		}

		private static void MineshaftElevatorController_Update(orig_Update orig, MineshaftElevatorController self)
		{
			orig.Invoke(self);
			if (self.elevatorFinishedMoving)
			{
				if (self.movingDownLastFrame)
				{
					self.elevatorIsAtBottom = true;
				}
				else
				{
					self.elevatorIsAtBottom = false;
				}
			}
		}
	}
	internal static class PlayerControllerBPatch
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_TeleportPlayer <0>__PlayerControllerB_TeleportPlayer;

			public static hook_DamagePlayer <1>__PlayerControllerB_DamagePlayer;
		}

		public static List<SmartAgentNavigator> smartAgentNavigators = new List<SmartAgentNavigator>();

		public static void Init()
		{
			//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_001b: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			object obj = <>O.<0>__PlayerControllerB_TeleportPlayer;
			if (obj == null)
			{
				hook_TeleportPlayer val = PlayerControllerB_TeleportPlayer;
				<>O.<0>__PlayerControllerB_TeleportPlayer = val;
				obj = (object)val;
			}
			PlayerControllerB.TeleportPlayer += (hook_TeleportPlayer)obj;
			object obj2 = <>O.<1>__PlayerControllerB_DamagePlayer;
			if (obj2 == null)
			{
				hook_DamagePlayer val2 = PlayerControllerB_DamagePlayer;
				<>O.<1>__PlayerControllerB_DamagePlayer = val2;
				obj2 = (object)val2;
			}
			PlayerControllerB.DamagePlayer += (hook_DamagePlayer)obj2;
		}

		private static void PlayerControllerB_DamagePlayer(orig_DamagePlayer orig, PlayerControllerB self, int damageNumber, bool hasDamageSFX, bool callRPC, CauseOfDeath causeOfDeath, int deathAnimation, bool fallDamage, Vector3 force)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self, damageNumber, hasDamageSFX, callRPC, causeOfDeath, deathAnimation, fallDamage, force);
			Plugin.ExtendedLogging("PlayerControllerB_DamagePlayer called on client: " + self.playerUsername + " with caller: " + self.playerUsername);
			if (self.currentlyHeldObjectServer is ChildEnemyAI childEnemyAI && (Object)(object)self == (Object)(object)GameNetworkManager.Instance.localPlayerController)
			{
				((MonoBehaviour)self).StartCoroutine(self.waitToEndOfFrameToDiscard());
				if (childEnemyAI.mommyAlive && (Object)(object)childEnemyAI.parentEevee != (Object)null)
				{
					childEnemyAI.parentEevee.HandleStateAnimationSpeedChangesServerRpc(2);
					childEnemyAI.parentEevee.SetTargetServerRpc(-1);
				}
			}
		}

		private static void PlayerControllerB_TeleportPlayer(orig_TeleportPlayer orig, PlayerControllerB self, Vector3 pos, bool withRotation, float rot, bool allowInteractTrigger, bool enableController)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			foreach (SmartAgentNavigator smartAgentNavigator in smartAgentNavigators)
			{
				Plugin.ExtendedLogging($"Setting SmartAgentNavigator.positionsOfPlayersBeforeTeleport[self] to {((Component)self).transform.position}");
				smartAgentNavigator.positionsOfPlayersBeforeTeleport[self] = ((Component)self).transform.position;
			}
			orig.Invoke(self, pos, withRotation, rot, allowInteractTrigger, enableController);
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal static class StartOfRoundPatch
	{
		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		public static void StartOfRound_Awake(ref StartOfRound __instance)
		{
			Plugin.ExtendedLogging("StartOfRound.Awake");
			((NetworkBehaviour)__instance).NetworkObject.OnSpawn(CreateNetworkManager);
		}

		private static void CreateNetworkManager()
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			if (((NetworkBehaviour)StartOfRound.Instance).IsServer || ((NetworkBehaviour)StartOfRound.Instance).IsHost)
			{
				if ((Object)(object)EeveeFrenzyUtils.Instance == (Object)null)
				{
					GameObject val = Object.Instantiate<GameObject>(Plugin.Assets.UtilsPrefab);
					SceneManager.MoveGameObjectToScene(val, ((Component)StartOfRound.Instance).gameObject.scene);
					val.GetComponent<NetworkObject>().Spawn(false);
					Scene scene = val.scene;
					Plugin.ExtendedLogging("Created EeveeFrenzyUtils. Scene is: '" + ((Scene)(ref scene)).name + "'");
				}
				else
				{
					Plugin.Logger.LogWarning((object)"EeveeFrenzyUtils already exists?");
				}
			}
		}
	}
}
namespace EeveeFrenzy.src.MiscScripts
{
	public class ChildHittableCollisionDetect : MonoBehaviour, IHittable
	{
		[SerializeField]
		private ChildEnemyAI _mainScript;

		public bool Hit(int force, Vector3 hitDirection, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return _mainScript.Hit(force, hitDirection, playerWhoHit, playHitSFX, hitID);
		}
	}
	public abstract class EFHittable : NetworkBehaviour
	{
		public abstract bool Hit(int force, Vector3 hitDirection, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1);

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

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "EFHittable";
		}
	}
	public class HittableCollisionDetect : MonoBehaviour, IHittable
	{
		[SerializeField]
		private EFHittable _mainScript;

		public bool Hit(int force, Vector3 hitDirection, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return _mainScript.Hit(force, hitDirection, playerWhoHit, playHitSFX, hitID);
		}
	}
	public class SmartAgentNavigator : NetworkBehaviour
	{
		[NonSerialized]
		public bool cantMove;

		[NonSerialized]
		public UnityEvent<bool> OnUseEntranceTeleport = new UnityEvent<bool>();

		[NonSerialized]
		public UnityEvent<bool> OnEnableOrDisableAgent = new UnityEvent<bool>();

		[NonSerialized]
		public UnityEvent<bool> OnEnterOrExitElevator = new UnityEvent<bool>();

		private float nonAgentMovementSpeed = 10f;

		[NonSerialized]
		public NavMeshAgent agent;

		private Vector3 pointToGo = Vector3.zero;

		[NonSerialized]
		public bool isOutside = true;

		private bool usingElevator;

		private bool wasInElevatorLastFrame;

		private Coroutine? searchRoutine;

		private Coroutine? searchCoroutine;

		private bool isSearching;

		private bool reachedDestination;

		private MineshaftElevatorController? elevatorScript;

		private EntranceTeleport? lastUsedEntranceTeleport;

		[NonSerialized]
		public Dictionary<PlayerControllerB, Vector3> positionsOfPlayersBeforeTeleport = new Dictionary<PlayerControllerB, Vector3>();

		private Dictionary<EntranceTeleport, Transform[]> exitPoints = new Dictionary<EntranceTeleport, Transform[]>();

		private bool InElevator
		{
			get
			{
				//IL_0014: 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)
				if ((Object)(object)elevatorScript != (Object)null)
				{
					return Vector3.Distance(((Component)this).transform.position, elevatorScript.elevatorInsidePoint.position) < 7f;
				}
				return false;
			}
		}

		public void Start()
		{
			agent = ((Component)this).gameObject.GetComponent<NavMeshAgent>();
			PlayerControllerBPatch.smartAgentNavigators.Add(this);
		}

		public override void OnNetworkDespawn()
		{
			((NetworkBehaviour)this).OnNetworkDespawn();
			PlayerControllerBPatch.smartAgentNavigators.Remove(this);
		}

		public void SetAllValues(bool isOutside)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			this.isOutside = isOutside;
			positionsOfPlayersBeforeTeleport.Clear();
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				positionsOfPlayersBeforeTeleport.Add(val, ((Component)val).transform.position);
			}
			exitPoints.Clear();
			EntranceTeleport[] array = Object.FindObjectsByType<EntranceTeleport>((FindObjectsInactive)0, (FindObjectsSortMode)1);
			foreach (EntranceTeleport val2 in array)
			{
				exitPoints.Add(val2, (Transform[])(object)new Transform[2] { val2.entrancePoint, val2.exitPoint });
				if (val2.isEntranceToBuilding)
				{
					lastUsedEntranceTeleport = val2;
				}
				if (!val2.FindExitPoint())
				{
					Plugin.Logger.LogError((object)"Something went wrong in the generation of the fire exits");
				}
			}
			elevatorScript = Object.FindObjectOfType<MineshaftElevatorController>();
		}

		public void ResetAllValues()
		{
			exitPoints.Clear();
			positionsOfPlayersBeforeTeleport.Clear();
			lastUsedEntranceTeleport = null;
			elevatorScript = null;
		}

		public void Update()
		{
			if (InElevator)
			{
				if (!wasInElevatorLastFrame)
				{
					OnEnterOrExitElevator.Invoke(true);
				}
				wasInElevatorLastFrame = true;
			}
			else if (wasInElevatorLastFrame)
			{
				OnEnterOrExitElevator.Invoke(false);
				wasInElevatorLastFrame = false;
			}
		}

		public bool DoPathingToDestination(Vector3 destination, bool destinationIsInside, bool followingPlayer, PlayerControllerB? playerBeingFollowed)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: 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_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: 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)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			if (!((Behaviour)agent).enabled)
			{
				if (cantMove)
				{
					return true;
				}
				Vector3 val = pointToGo;
				float num = 10f;
				float num2 = Vector3.Distance(((Component)this).transform.position, val);
				float num3 = Mathf.Clamp01(Vector3.Distance(((Component)this).transform.position, val) / num2);
				Vector3 position = Vector3.MoveTowards(((Component)this).transform.position, val, Time.deltaTime * nonAgentMovementSpeed);
				position.y += Mathf.Sin(num3 * MathF.PI) * num;
				((Component)this).transform.position = position;
				((Component)this).transform.rotation = Quaternion.LookRotation(val - ((Component)this).transform.position);
				if (Vector3.Distance(((Component)this).transform.position, val) <= 1f)
				{
					OnEnableOrDisableAgent.Invoke(true);
					((Behaviour)agent).enabled = true;
				}
				return true;
			}
			if ((isOutside && destinationIsInside) || (!isOutside && !destinationIsInside))
			{
				GoThroughEntrance(followingPlayer, playerBeingFollowed);
				return true;
			}
			if (!isOutside && (Object)(object)elevatorScript != (Object)null && !usingElevator)
			{
				bool flag = Vector3.Distance(((Component)this).transform.position, elevatorScript.elevatorTopPoint.position) < Vector3.Distance(((Component)this).transform.position, elevatorScript.elevatorBottomPoint.position);
				bool flag2 = Vector3.Distance(destination, elevatorScript.elevatorTopPoint.position) < Vector3.Distance(destination, elevatorScript.elevatorBottomPoint.position);
				if (flag != flag2)
				{
					UseTheElevator(elevatorScript);
					return true;
				}
			}
			bool flag3 = (Object)(object)elevatorScript != (Object)null && !elevatorScript.elevatorFinishedMoving && Vector3.Distance(destination, elevatorScript.elevatorInsidePoint.position) < 7f;
			if (!usingElevator && !flag3 && DetermineIfNeedToDisableAgent(destination))
			{
				return true;
			}
			if (!usingElevator)
			{
				agent.SetDestination(destination);
			}
			if (usingElevator && (Object)(object)elevatorScript != (Object)null)
			{
				agent.Warp(elevatorScript.elevatorInsidePoint.position);
			}
			return false;
		}

		private bool DetermineIfNeedToDisableAgent(Vector3 destination)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Invalid comparison between Unknown and I4
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: 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_0060: 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_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			NavMeshPath val = new NavMeshPath();
			if ((!agent.CalculatePath(destination, val) || (int)val.status == 1) && Vector3.Distance(((Component)this).transform.position, destination) > 7f)
			{
				Vector3 val2 = FindClosestValidPoint();
				agent.SetDestination(val2);
				if (Vector3.Distance(((Component)agent).transform.position, val2) <= agent.stoppingDistance)
				{
					agent.SetDestination(destination);
					NavMeshHit val3 = default(NavMeshHit);
					if ((!agent.CalculatePath(destination, val) || (int)val.status != 0) && NavMesh.SamplePosition(destination, ref val3, 5f, -1))
					{
						Vector3 val4 = (pointToGo = ((NavMeshHit)(ref val3)).position);
						OnEnableOrDisableAgent.Invoke(false);
						((Behaviour)agent).enabled = false;
						Plugin.ExtendedLogging($"Pathing to {destination} failed, going to {val4} instead.");
					}
				}
				return true;
			}
			return false;
		}

		private void GoThroughEntrance(bool followingPlayer, PlayerControllerB? playerBeingFollowed)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: 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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0287: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = Vector3.zero;
			Vector3 val2 = Vector3.zero;
			EntranceTeleport entranceTeleportToUse = null;
			if (followingPlayer && (Object)(object)playerBeingFollowed != (Object)null)
			{
				Vector3 val3 = positionsOfPlayersBeforeTeleport[playerBeingFollowed];
				EntranceTeleport val4 = null;
				foreach (EntranceTeleport key in exitPoints.Keys)
				{
					if ((Object)(object)val4 == (Object)null || Vector3.Distance(val3, ((Component)key).transform.position) < Vector3.Distance(val3, ((Component)val4).transform.position))
					{
						val4 = key;
					}
				}
				if ((Object)(object)val4 != (Object)null)
				{
					entranceTeleportToUse = val4;
					val = ((Component)val4.entrancePoint).transform.position;
					val2 = ((Component)val4.exitPoint).transform.position;
				}
			}
			else if ((Object)(object)lastUsedEntranceTeleport != (Object)null)
			{
				entranceTeleportToUse = lastUsedEntranceTeleport;
				val = ((!isOutside) ? ((Component)lastUsedEntranceTeleport.exitPoint).transform.position : ((Component)lastUsedEntranceTeleport.entrancePoint).transform.position);
				val2 = ((!isOutside) ? ((Component)lastUsedEntranceTeleport.entrancePoint).transform.position : ((Component)lastUsedEntranceTeleport.exitPoint).transform.position);
			}
			else
			{
				EntranceTeleport val5 = null;
				foreach (EntranceTeleport key2 in exitPoints.Keys)
				{
					if ((Object)(object)val5 == (Object)null || Vector3.Distance(((Component)this).transform.position, ((Component)key2).transform.position) < Vector3.Distance(((Component)this).transform.position, ((Component)val5).transform.position))
					{
						val5 = key2;
					}
				}
				if ((Object)(object)val5 != (Object)null)
				{
					entranceTeleportToUse = val5;
					val = ((Component)val5.entrancePoint).transform.position;
					val2 = ((Component)val5.exitPoint).transform.position;
				}
			}
			if ((Object)(object)elevatorScript != (Object)null && NeedsElevator(val, entranceTeleportToUse, elevatorScript))
			{
				UseTheElevator(elevatorScript);
				return;
			}
			float num = Vector3.Distance(((Component)this).transform.position, val);
			if (!(num <= agent.stoppingDistance))
			{
				Vector3 velocity = agent.velocity;
				if (!(((Vector3)(ref velocity)).sqrMagnitude <= 0.01f) || !(num <= 10f))
				{
					agent.SetDestination(val);
					return;
				}
			}
			lastUsedEntranceTeleport = entranceTeleportToUse;
			agent.Warp(val2);
			SetThingOutsideServerRpc(!isOutside);
		}

		private bool NeedsElevator(Vector3 destination, EntranceTeleport entranceTeleportToUse, MineshaftElevatorController elevatorScript)
		{
			//IL_0000: 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_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			bool flag = Vector3.Distance(destination, RoundManager.FindMainEntrancePosition(true, false)) < Vector3.Distance(destination, ((Component)entranceTeleportToUse).transform.position);
			bool flag2 = Vector3.Distance(((Component)this).transform.position, elevatorScript.elevatorTopPoint.position) < Vector3.Distance(((Component)this).transform.position, elevatorScript.elevatorBottomPoint.position);
			if (!isOutside)
			{
				if (!flag || flag2)
				{
					return !flag && flag2;
				}
				return true;
			}
			return false;
		}

		private void UseTheElevator(MineshaftElevatorController elevatorScript)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			bool flag = Vector3.Distance(((Component)this).transform.position, elevatorScript.elevatorBottomPoint.position) < Vector3.Distance(((Component)this).transform.position, elevatorScript.elevatorTopPoint.position);
			if (elevatorScript.elevatorFinishedMoving)
			{
				if (elevatorScript.elevatorDoorOpen)
				{
					if (NeedToCallElevator(elevatorScript, flag))
					{
						elevatorScript.CallElevatorOnServer(flag);
						MoveToWaitingPoint(elevatorScript, flag);
					}
					else if (Vector3.Distance(((Component)this).transform.position, elevatorScript.elevatorInsidePoint.position) > 1f)
					{
						agent.SetDestination(elevatorScript.elevatorInsidePoint.position);
					}
					else if (!usingElevator)
					{
						elevatorScript.PressElevatorButtonOnServer(true);
						((MonoBehaviour)this).StartCoroutine(StopUsingElevator(elevatorScript));
					}
				}
			}
			else
			{
				MoveToWaitingPoint(elevatorScript, flag);
			}
		}

		private IEnumerator StopUsingElevator(MineshaftElevatorController elevatorScript)
		{
			MineshaftElevatorController elevatorScript2 = elevatorScript;
			usingElevator = true;
			yield return (object)new WaitForSeconds(2f);
			yield return (object)new WaitUntil((Func<bool>)(() => elevatorScript2.elevatorDoorOpen && elevatorScript2.elevatorFinishedMoving));
			Plugin.ExtendedLogging("Stopped using elevator");
			usingElevator = false;
		}

		private bool NeedToCallElevator(MineshaftElevatorController elevatorScript, bool needToGoUp)
		{
			if (!elevatorScript.elevatorCalled)
			{
				if (!(!elevatorScript.elevatorIsAtBottom && needToGoUp))
				{
					if (elevatorScript.elevatorIsAtBottom)
					{
						return !needToGoUp;
					}
					return false;
				}
				return true;
			}
			return false;
		}

		private void MoveToWaitingPoint(MineshaftElevatorController elevatorScript, bool needToGoUp)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			if (Vector3.Distance(((Component)this).transform.position, elevatorScript.elevatorInsidePoint.position) > 1f)
			{
				agent.SetDestination(needToGoUp ? elevatorScript.elevatorBottomPoint.position : elevatorScript.elevatorTopPoint.position);
			}
			else
			{
				agent.SetDestination(elevatorScript.elevatorInsidePoint.position);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void SetThingOutsideServerRpc(bool setOutside)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3500600747u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref setOutside, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3500600747u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					SetThingOutsideClientRpc(setOutside);
				}
			}
		}

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

		private Vector3 FindClosestValidPoint()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return agent.pathEndPosition;
		}

		private Vector3 WarpForwardUntilOnNavMesh(Vector3 originalDestination)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			Vector3 forward = ((Component)agent).transform.forward;
			float num = 0.2f;
			float num2 = 50f;
			float num3 = 1f;
			NavMeshHit val2 = default(NavMeshHit);
			for (int i = 0; (float)i < num2; i++)
			{
				Vector3 val = originalDestination + forward * num * (float)(i + 1);
				if (NavMesh.SamplePosition(val, ref val2, num3, -1))
				{
					return ((NavMeshHit)(ref val2)).position;
				}
			}
			Plugin.Logger.LogWarning((object)"Unable to find valid point on NavMesh by warping forward.");
			return Vector3.zero;
		}

		public void SetDestinationWithSpeedAdjustment(Vector3 destination)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			agent.SetDestination(destination);
			AdjustSpeedBasedOnDistance(agent.remainingDistance);
		}

		public void AdjustSpeedBasedOnDistance(float multiplierBoost)
		{
			float num = 0f;
			float num2 = 40f;
			float num3 = 0f;
			float num4 = 10f;
			float num5 = Mathf.Clamp(agent.remainingDistance, num, num2);
			float num6 = (num5 - num) / (num2 - num);
			agent.speed = Mathf.Lerp(num3, num4, num6) * multiplierBoost;
		}

		public void StopNavigation()
		{
			if ((Object)(object)agent != (Object)null)
			{
				agent.isStopped = true;
				agent.ResetPath();
			}
		}

		public void WarpToLocation(Vector3 location)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			agent.Warp(location);
		}

		public bool CurrentPathIsValid()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Invalid comparison between Unknown and I4
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Invalid comparison between Unknown and I4
			if ((int)agent.path.status == 1 || (int)agent.path.status == 2)
			{
				return false;
			}
			return true;
		}

		public void StartSearchRoutine(Vector3 position, float radius)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			if (searchRoutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(searchRoutine);
			}
			isSearching = true;
			searchRoutine = ((MonoBehaviour)this).StartCoroutine(SearchAlgorithm(position, radius));
		}

		public void StopSearchRoutine()
		{
			isSearching = false;
			if (searchCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(searchRoutine);
			}
			searchRoutine = null;
		}

		private IEnumerator SearchAlgorithm(Vector3 position, float radius)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			while (isSearching)
			{
				Vector3 positionToTravel = RoundManager.Instance.GetRandomNavMeshPositionInRadius(position, radius, default(NavMeshHit));
				Plugin.ExtendedLogging($"Search: {positionToTravel}");
				reachedDestination = false;
				while (!reachedDestination && isSearching)
				{
					agent.SetDestination(positionToTravel);
					yield return (object)new WaitForSeconds(3f);
					if (!(Vector3.Distance(((Component)this).transform.position, positionToTravel) <= 10f))
					{
						Vector3 velocity = agent.velocity;
						if (!(((Vector3)(ref velocity)).magnitude <= 1f))
						{
							continue;
						}
					}
					reachedDestination = true;
				}
			}
			searchRoutine = null;
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_SmartAgentNavigator()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(3500600747u, new RpcReceiveHandler(__rpc_handler_3500600747));
			NetworkManager.__rpc_func_table.Add(3520670532u, new RpcReceiveHandler(__rpc_handler_3520670532));
		}

		private static void __rpc_handler_3500600747(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool thingOutsideServerRpc = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref thingOutsideServerRpc, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((SmartAgentNavigator)(object)target).SetThingOutsideServerRpc(thingOutsideServerRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3520670532(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool thingOutsideClientRpc = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref thingOutsideClientRpc, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((SmartAgentNavigator)(object)target).SetThingOutsideClientRpc(thingOutsideClientRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "SmartAgentNavigator";
		}
	}
}
namespace EeveeFrenzy.src.Content.Items
{
	[RequireComponent(typeof(SmartAgentNavigator))]
	public class ChildEnemyAI : GrabbableObject
	{
		public enum FriendState
		{
			Neutral,
			Friendly,
			Tamed
		}

		public enum State
		{
			Spawning,
			Wandering,
			FollowingPlayer,
			Scared,
			Dancing,
			Grabbed
		}

		public NavMeshAgent agent;

		public Animator animator;

		public NetworkAnimator networkAnimator;

		public SmartAgentNavigator smartAgentNavigator;

		public float rangeOfDetection = 20f;

		[Header("Sound and Audio")]
		public AudioSource eeveeSource;

		public AudioClip spawnSound;

		public AudioClip[] hitSounds = Array.Empty<AudioClip>();

		public AudioClip[] idleSounds = Array.Empty<AudioClip>();

		public AudioClip[] idleHappySounds = Array.Empty<AudioClip>();

		public AudioClip[] scaredSounds = Array.Empty<AudioClip>();

		public AudioClip[] footstepSounds = Array.Empty<AudioClip>();

		[HideInInspector]
		public ParentEnemyAI? parentEevee;

		[HideInInspector]
		public int health = 4;

		[HideInInspector]
		public bool mommyAlive = true;

		[HideInInspector]
		public float[] friendShipMeterGoals = new float[3] { 0f, 20f, 50f };

		private float idleTimer;

		private float idleHappyTimer;

		private Dictionary<PlayerControllerB, float> friendShipMeterPlayers = new Dictionary<PlayerControllerB, float>();

		private List<Vector3> scaryPositionsList = new List<Vector3>();

		private float scaredTimer = 10f;

		private bool isScared;

		private bool isRunning;

		private bool isSitting;

		private float sittingTimer = 20f;

		private float observationCheckTimer = 2f;

		private PlayerControllerB? nearbyPlayer;

		private static readonly int isChildDeadAnimation = Animator.StringToHash("isChildDead");

		private static readonly int childGrabbedAnimation = Animator.StringToHash("childGrabbed");

		private static readonly int isWalkingAnimation = Animator.StringToHash("isWalking");

		private static readonly int isGoofyAnimation = Animator.StringToHash("isGoofy");

		private static readonly int isRunningAnimation = Animator.StringToHash("isRunning");

		private static readonly int isScaredAnimation = Animator.StringToHash("isScared");

		private static readonly int isSittingAnimation = Animator.StringToHash("isSitting");

		private static readonly int isDancingAnimation = Animator.StringToHash("isDancing");

		private static readonly int doIdleGestureAnimation = Animator.StringToHash("doIdleGesture");

		private static readonly int doSitGesture1Animation = Animator.StringToHash("doSitGesture1");

		private static readonly int doSitGesture2Animation = Animator.StringToHash("doSitGesture2");

		private static readonly int RunSpeedFloat = Animator.StringToHash("RunSpeed");

		private Coroutine? grabbingRoutine;

		private State eeveeState;

		private FriendState friendEeveeState;

		public override void OnNetworkSpawn()
		{
			((NetworkBehaviour)this).OnNetworkSpawn();
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if (!friendShipMeterPlayers.ContainsKey(val))
				{
					Plugin.ExtendedLogging("Adding player " + ((Object)val).name + " to friendShipMeterPlayers");
					friendShipMeterPlayers.TryAdd(val, 0f);
				}
			}
		}

		public override void Start()
		{
			((GrabbableObject)this).Start();
			eeveeSource.PlayOneShot(spawnSound);
			base.fallTime = 0f;
			smartAgentNavigator.OnEnterOrExitElevator.AddListener((UnityAction<bool>)OnEnterOrExitElevator);
			smartAgentNavigator.OnUseEntranceTeleport.AddListener((UnityAction<bool>)OnUseEntranceTeleport);
			if ((Object)(object)parentEevee != (Object)null)
			{
				smartAgentNavigator.SetAllValues(((EnemyAI)parentEevee).isOutside);
				base.isInFactory = !((EnemyAI)parentEevee).isOutside;
			}
			else
			{
				smartAgentNavigator.SetAllValues(isOutside: true);
				base.isInFactory = false;
				friendEeveeState = FriendState.Tamed;
				((Behaviour)agent).enabled = false;
				((Behaviour)smartAgentNavigator).enabled = false;
			}
			if (((NetworkBehaviour)this).IsServer)
			{
				HandleStateAnimationSpeedChanges(State.Spawning);
			}
		}

		public override void EquipItem()
		{
			((GrabbableObject)this).EquipItem();
			HandleStateAnimationSpeedChangesServerRpc(5);
		}

		public override void DiscardItem()
		{
			((GrabbableObject)this).DiscardItem();
			if ((Object)(object)parentEevee == (Object)null)
			{
				return;
			}
			parentEevee.canGrabChild = false;
			if (grabbingRoutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(grabbingRoutine);
				grabbingRoutine = null;
			}
			grabbingRoutine = ((MonoBehaviour)this).StartCoroutine(ChildGrabbableCooldown(parentEevee));
			if (!parentEevee.holdingChild)
			{
				if (isScared)
				{
					HandleStateAnimationSpeedChangesServerRpc(3);
				}
				else
				{
					HandleStateAnimationSpeedChangesServerRpc(1);
				}
			}
		}

		private IEnumerator ChildGrabbableCooldown(ParentEnemyAI _parentEevee)
		{
			yield return (object)new WaitForSeconds(2f);
			_parentEevee.canGrabChild = true;
		}

		private void BaseUpdate()
		{
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			if (base.currentUseCooldown >= 0f)
			{
				base.currentUseCooldown -= Time.deltaTime;
			}
			if (((NetworkBehaviour)this).IsOwner)
			{
				if (base.isBeingUsed && base.itemProperties.requiresBattery)
				{
					if (base.insertedBattery.charge > 0f)
					{
						if (!base.itemProperties.itemIsTrigger)
						{
							Battery insertedBattery = base.insertedBattery;
							insertedBattery.charge -= Time.deltaTime / base.itemProperties.batteryUsage;
						}
					}
					else if (!base.insertedBattery.empty)
					{
						base.insertedBattery.empty = true;
						if (base.isBeingUsed)
						{
							Plugin.ExtendedLogging("Use up batteries local");
							base.isBeingUsed = false;
							((GrabbableObject)this).UseUpBatteries();
							base.isSendingItemRPC++;
							((GrabbableObject)this).UseUpItemBatteriesServerRpc();
						}
					}
				}
				if (!base.wasOwnerLastFrame)
				{
					base.wasOwnerLastFrame = true;
				}
			}
			else if (base.wasOwnerLastFrame)
			{
				base.wasOwnerLastFrame = false;
			}
			if (!base.isHeld && (Object)(object)base.parentObject == (Object)null)
			{
				if (base.fallTime >= 1f)
				{
					if (!base.reachedFloorTarget)
					{
						if (!base.hasHitGround)
						{
							((GrabbableObject)this).PlayDropSFX();
							((GrabbableObject)this).OnHitGround();
						}
						base.reachedFloorTarget = true;
						if (base.floorYRot == -1)
						{
							((Component)this).transform.rotation = Quaternion.Euler(base.itemProperties.restingRotation.x, ((Component)this).transform.eulerAngles.y, base.itemProperties.restingRotation.z);
						}
						else
						{
							((Component)this).transform.rotation = Quaternion.Euler(base.itemProperties.restingRotation.x, (float)(base.floorYRot + base.itemProperties.floorYOffset) + 90f, base.itemProperties.restingRotation.z);
						}
					}
					((Component)this).transform.localPosition = base.targetFloorPosition;
				}
				else
				{
					base.reachedFloorTarget = false;
					if (((Component)this).transform.localPosition.y - base.targetFloorPosition.y < 0.05f && !base.hasHitGround)
					{
						((GrabbableObject)this).PlayDropSFX();
						((GrabbableObject)this).OnHitGround();
					}
				}
			}
			else if (base.isHeld || base.isHeldByEnemy)
			{
				base.reachedFloorTarget = false;
			}
		}

		public override void Update()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)parentEevee == (Object)null || ((EnemyAI)parentEevee).isEnemyDead)
			{
				Bounds bounds = StartOfRound.Instance.shipBounds.bounds;
				if (((Bounds)(ref bounds)).Contains(((Component)this).transform.position))
				{
					((Behaviour)agent).enabled = false;
					smartAgentNavigator.StopSearchRoutine();
					((Behaviour)smartAgentNavigator).enabled = false;
				}
			}
			if (!((Behaviour)agent).enabled && !((Behaviour)smartAgentNavigator).enabled)
			{
				((GrabbableObject)this).Update();
				return;
			}
			BaseUpdate();
			if ((Object)(object)nearbyPlayer != (Object)null && (nearbyPlayer.isPlayerDead || !nearbyPlayer.isPlayerControlled || (nearbyPlayer.isInHangarShipRoom && (Object)(object)base.playerHeldBy != (Object)(object)nearbyPlayer)))
			{
				nearbyPlayer = null;
			}
			if ((Object)(object)base.playerHeldBy != (Object)null && base.isHeld)
			{
				friendShipMeterPlayers[base.playerHeldBy] += Time.deltaTime * 2f;
			}
			else
			{
				PlayerControllerB[] array = friendShipMeterPlayers.Keys.ToArray();
				foreach (PlayerControllerB val in array)
				{
					if (!((Object)(object)val == (Object)null) && !val.isPlayerDead && val.isPlayerControlled)
					{
						if (Vector3.Distance(((Component)val).transform.position, ((Component)this).transform.position) <= 10f)
						{
							friendShipMeterPlayers[val] += Time.deltaTime * 0.25f;
						}
						else if (!(friendShipMeterPlayers[val] <= 0f))
						{
							friendShipMeterPlayers[val] -= Time.deltaTime * 0.25f;
						}
					}
				}
			}
			if (((NetworkBehaviour)this).IsServer)
			{
				DoHostSideUpdate();
			}
		}

		private float GetCurrentMultiplierBoost()
		{
			if (isSitting)
			{
				return 0f;
			}
			if (isScared)
			{
				return 2f;
			}
			if (isRunning)
			{
				return 2f;
			}
			return 1f;
		}

		private void DoHostSideUpdate()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			if (((Behaviour)agent).enabled)
			{
				Animator obj = animator;
				int runSpeedFloat = RunSpeedFloat;
				Vector3 velocity = agent.velocity;
				obj.SetFloat(runSpeedFloat, ((Vector3)(ref velocity)).magnitude / 2f);
				agent.speed = 4f * GetCurrentMultiplierBoost();
			}
			switch (eeveeState)
			{
			case State.Spawning:
				DoSpawning();
				break;
			case State.Wandering:
				DoWandering();
				break;
			case State.FollowingPlayer:
				DoFollowingPlayer();
				break;
			case State.Scared:
				DoScared();
				break;
			case State.Dancing:
				DoDancing();
				break;
			}
			HandleFriendShipMeter();
			if (!base.isHeldByEnemy && !base.isHeld && !isSitting && sittingTimer <= 0f)
			{
				animator.SetBool(isSittingAnimation, true);
				isSitting = true;
				sittingTimer = Random.Range(20, 30);
				if (Random.Range(0, 2) == 0)
				{
					networkAnimator.SetTrigger(doSitGesture1Animation, true);
				}
				else
				{
					networkAnimator.SetTrigger(doSitGesture2Animation, true);
				}
				((MonoBehaviour)this).StartCoroutine(StopSittingTimer());
			}
		}

		private IEnumerator StopSittingTimer()
		{
			yield return (object)new WaitForSeconds(1.5f);
			animator.SetBool(isSittingAnimation, false);
			isSitting = false;
		}

		private void DoSpawning()
		{
		}

		private void DoWandering()
		{
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			if (!isSitting)
			{
				sittingTimer -= Time.deltaTime;
			}
			observationCheckTimer -= Time.deltaTime;
			idleTimer -= Time.deltaTime;
			if (idleTimer <= 0f)
			{
				idleTimer = 4f;
				eeveeSource.PlayOneShot(idleSounds[Random.Range(0, idleSounds.Length)]);
			}
			if (observationCheckTimer > 0f)
			{
				return;
			}
			observationCheckTimer = 2f;
			PlayerControllerB val = DetectNearbyPlayer();
			if ((Object)(object)val != (Object)null)
			{
				SetTargetPlayerServerRpc(Array.IndexOf(StartOfRound.Instance.allPlayerScripts, val));
				HandleStateAnimationSpeedChanges(State.FollowingPlayer);
			}
			foreach (EnemyAI spawnedEnemy in RoundManager.Instance.SpawnedEnemies)
			{
				if (!(spawnedEnemy is ParentEnemyAI) && LineOfSightAvailable(((Component)spawnedEnemy).transform))
				{
					BecomeScared(new List<Vector3> { ((Component)spawnedEnemy).transform.position });
					HandleStateAnimationSpeedChanges(State.Scared);
				}
			}
		}

		private void DoFollowingPlayer()
		{
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)nearbyPlayer == (Object)null)
			{
				SetTargetPlayerServerRpc(-1);
				HandleStateAnimationSpeedChanges(State.Wandering);
				return;
			}
			idleHappyTimer -= Time.deltaTime;
			if (idleHappyTimer <= 0f)
			{
				idleHappyTimer = 4f;
				eeveeSource.PlayOneShot(idleHappySounds[Random.Range(0, idleHappySounds.Length)]);
			}
			if ((Object)(object)parentEevee == (Object)null || friendEeveeState != 0)
			{
				smartAgentNavigator.DoPathingToDestination(((Component)nearbyPlayer).transform.position, nearbyPlayer.isInsideFactory, followingPlayer: true, nearbyPlayer);
			}
			else if (Vector3.Distance(((Component)this).transform.position, parentEevee.spawnPosition) <= 25f)
			{
				smartAgentNavigator.DoPathingToDestination(((Component)nearbyPlayer).transform.position, nearbyPlayer.isInsideFactory, followingPlayer: true, nearbyPlayer);
			}
			else
			{
				nearbyPlayer = null;
			}
		}

		public void BecomeScared(List<Vector3> scaryPositions)
		{
			scaryPositionsList.Clear();
			scaryPositionsList.AddRange(scaryPositions);
			HandleStateAnimationSpeedChanges(State.Scared);
		}

		private void DoScared()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			List<Vector3> list = new List<Vector3>(scaryPositionsList);
			Vector3 val = Vector3.zero;
			if (list.Count > 0)
			{
				Vector3 val2 = Vector3.zero;
				foreach (Vector3 item in list)
				{
					Vector3 val3 = val2;
					Vector3 val4 = ((Component)this).transform.position - item;
					val2 = val3 + ((Vector3)(ref val4)).normalized;
				}
				val = ((Component)this).transform.position + val2 * 10f;
				NavMeshHit val5 = default(NavMeshHit);
				if (NavMesh.SamplePosition(val, ref val5, 10f, -1))
				{
					val = ((NavMeshHit)(ref val5)).position;
				}
			}
			scaredTimer -= Time.deltaTime;
			if (scaredTimer <= 0f)
			{
				scaredTimer = 10f;
				HandleStateAnimationSpeedChanges(State.Wandering);
			}
			agent.SetDestination(val);
		}

		private void DoDancing()
		{
		}

		private void HandleFriendShipMeter()
		{
			switch (friendEeveeState)
			{
			case FriendState.Neutral:
				DoNeutralFriendShip();
				break;
			case FriendState.Friendly:
				DoFriendlyFriendShip();
				break;
			case FriendState.Tamed:
				DoTamedFriendShip();
				break;
			}
		}

		private void DoNeutralFriendShip()
		{
			if (!((Object)(object)nearbyPlayer == (Object)null) && friendShipMeterPlayers[nearbyPlayer] >= friendShipMeterGoals[1])
			{
				SwitchFriendShipStateServerRpc(1);
				((MonoBehaviour)this).StartCoroutine(WaitUntilLeavingMoon());
			}
		}

		private void DoFriendlyFriendShip()
		{
		}

		private void DoTamedFriendShip()
		{
		}

		private IEnumerator WaitUntilLeavingMoon()
		{
			yield return (object)new WaitUntil((Func<bool>)(() => StartOfRound.Instance.shipIsLeaving || StartOfRound.Instance.inShipPhase));
			if (friendEeveeState == FriendState.Friendly)
			{
				SwitchFriendShipStateServerRpc(2);
			}
		}

		private PlayerControllerB? DetectNearbyPlayer()
		{
			if (base.isHeld && (Object)(object)base.playerHeldBy != (Object)null)
			{
				nearbyPlayer = base.playerHeldBy;
				return nearbyPlayer;
			}
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if (LineOfSightAvailable(((Component)val).transform))
				{
					nearbyPlayer = val;
					return nearbyPlayer;
				}
			}
			return null;
		}

		private bool LineOfSightAvailable(Transform PlayerOrEnemy)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			float num = Vector3.Distance(PlayerOrEnemy.position, ((Component)this).transform.position);
			if (num >= rangeOfDetection)
			{
				return false;
			}
			Vector3 position = PlayerOrEnemy.position;
			Vector3 val = PlayerOrEnemy.position - ((Component)this).transform.position;
			if (Physics.Raycast(position, ((Vector3)(ref val)).normalized, num, StartOfRound.Instance.collidersAndRoomMaskAndDefault | LayerMask.GetMask(new string[2] { "Terrain", "InteractableObject" }), (QueryTriggerInteraction)1))
			{
				return false;
			}
			return true;
		}

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

		public void DisableOrEnableAllCollidersAndAgent(bool enable)
		{
			((Behaviour)agent).enabled = enable;
		}

		public void HandleStateAnimationSpeedChanges(State state)
		{
			Plugin.ExtendedLogging($"HandleStateAnimationSpeedChanges for CHILD {state}");
			SwitchStateClientRpc((int)state);
			switch (state)
			{
			case State.Spawning:
				SetAnimatorBools(isWalking: false, isRunning: false, isScared: false, isDancing: false, isGrabbed: false);
				break;
			case State.Wandering:
				SetAnimatorBools(isWalking: true, isRunning: false, isScared: false, isDancing: false, isGrabbed: false);
				break;
			case State.FollowingPlayer:
				SetAnimatorBools(isWalking: true, isRunning: true, isScared: false, isDancing: false, isGrabbed: false);
				break;
			case State.Scared:
				SetAnimatorBools(animator.GetBool(isWalkingAnimation), isRunning, isScared: true, isDancing: false, base.isHeld);
				break;
			case State.Dancing:
				SetAnimatorBools(isWalking: false, isRunning: false, isScared: false, isDancing: true, isGrabbed: false);
				break;
			case State.Grabbed:
				SetAnimatorBools(isWalking: false, isRunning: false, isScared, isDancing: false, isGrabbed: true);
				break;
			}
		}

		private void SetAnimatorBools(bool isWalking, bool isRunning, bool isScared, bool isDancing, bool isGrabbed)
		{
			Plugin.ExtendedLogging($"Setting animator bools for child: isWalking: {isWalking}, isRunning: {isRunning}, isScared: {isScared}, isDancing: {isDancing}, isGrabbed: {isGrabbed}");
			animator.SetBool(isWalkingAnimation, isWalking);
			animator.SetBool(isRunningAnimation, isRunning);
			this.isRunning = isRunning;
			animator.SetBool(isScaredAnimation, isScared);
			this.isScared = isScared;
			animator.SetBool(isDancingAnimation, isDancing);
			animator.SetBool(childGrabbedAnimation, isGrabbed);
			animator.SetBool(isSittingAnimation, false);
			isSitting = false;
		}

		[ServerRpc(RequireOwnership = false)]
		private void SwitchFriendShipStateServerRpc(int state)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2168788941u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, state);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2168788941u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					SwitchFriendShipStateClientRpc(state);
				}
			}
		}

		[ClientRpc]
		private void SwitchFriendShipStateClientRpc(int state)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_