Decompiled source of PjonkGoose v1.5.0

plugins/PjonkGoose/PjonkGoose.dll

Decompiled 3 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using PjonkGoose.Configs;
using PjonkGoose.NetcodePatcher;
using PjonkGooseEnemy.EnemyStuff;
using PjonkGooseEnemy.Misc;
using PjonkGooseEnemy.ScrapStuff;
using PjonkGooseEnemy.Util.Extensions;
using PjonkGooseEnemy.Util.Spawning;
using PjonkGooseEnemy.src.EnemyStuff;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
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("PjonkGoose")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("PjonkGoose for Lethal Company.")]
[assembly: AssemblyFileVersion("1.5.0.0")]
[assembly: AssemblyInformationalVersion("1.5.0+b931d32d5bc376965dd4a2161358546ac93b584f")]
[assembly: AssemblyProduct("PjonkGoose")]
[assembly: AssemblyTitle("PjonkGoose")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.5.0.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 PjonkGoose
{
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "PjonkGoose";

		public const string PLUGIN_NAME = "PjonkGoose";

		public const string PLUGIN_VERSION = "1.5.0";
	}
}
namespace PjonkGoose.Configs
{
	public class PjonkGooseConfig
	{
		public ConfigEntry<string> ConfigPjonkGooseSpawnWeights { get; private set; }

		public ConfigEntry<int> ConfigPjonkGooseMaxCount { get; private set; }

		public ConfigEntry<int> ConfigPjonkGoosePowerLevel { get; private set; }

		public ConfigEntry<int> ConfigPjonkGooseOffSpringMaxCount { get; private set; }

		public ConfigEntry<bool> ConfigPjonkGooseExtendedLogs { get; private set; }

		public PjonkGooseConfig(ConfigFile configFile)
		{
			ConfigPjonkGooseExtendedLogs = configFile.Bind<bool>("PjonkGoose Options", "Pjonk Goose | Extended Logs", false, "Extended Logs for the Pjonk Goose.");
			ConfigPjonkGoosePowerLevel = configFile.Bind<int>("PjonkGoose Options", "Pjonk Goose | Power Level", 3, "Power Level of the Pjonk Goose in the moon.");
			ConfigPjonkGooseSpawnWeights = configFile.Bind<string>("PjonkGoose Options", "Pjonk Goose | Spawn Weights", "All:66,Modded:66,Vanilla:66", "Spawn Weight of the Pjonk Goose in moons.");
			ConfigPjonkGooseMaxCount = configFile.Bind<int>("PjonkGoose Options", "Pjonk Goose | Max Count", 1, "Max Count of the PjonkGoose that spawn naturally in the moon.");
			ConfigPjonkGooseOffSpringMaxCount = configFile.Bind<int>("PjonkGoose Options", "Pjonk Goose | Off-Spring Max Count", 3, "Max Count of the PjonkGoose that spawn when they are spawned through as off-spring in the moon.");
			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();
		}
	}
}
namespace PjonkGooseEnemy
{
	public class KnockPlayersAway : MonoBehaviour
	{
		public PjonkGooseAI mainscript;

		private List<PlayerControllerB> playersBeingSmashed = new List<PlayerControllerB>();

		private void OnTriggerEnter(Collider other)
		{
			if (mainscript.pushingAway && ((Component)other).CompareTag("Player") && !playersBeingSmashed.Contains(((Component)other).GetComponent<PlayerControllerB>()))
			{
				PlayerControllerB component = ((Component)other).GetComponent<PlayerControllerB>();
				playersBeingSmashed.Add(component);
				((MonoBehaviour)this).StartCoroutine(SmashPlayer(component));
			}
		}

		private void OnTriggerStay(Collider other)
		{
			if (mainscript.pushingAway && ((Component)other).CompareTag("Player") && !playersBeingSmashed.Contains(((Component)other).GetComponent<PlayerControllerB>()))
			{
				PlayerControllerB component = ((Component)other).GetComponent<PlayerControllerB>();
				playersBeingSmashed.Add(component);
				((MonoBehaviour)this).StartCoroutine(SmashPlayer(component));
			}
		}

		private IEnumerator SmashPlayer(PlayerControllerB player)
		{
			float duration = 0.2f;
			Vector3 position = ((Component)player).transform.position;
			Bounds bounds = ((Component)this).gameObject.GetComponent<Collider>().bounds;
			Vector3 val = position - ((Bounds)(ref bounds)).center;
			Vector3 direction = ((Vector3)(ref val)).normalized;
			while (duration > 0f)
			{
				duration -= Time.fixedDeltaTime;
				player.externalForces = direction * 10f;
				yield return (object)new WaitForFixedUpdate();
			}
			playersBeingSmashed.Remove(player);
		}
	}
	[BepInPlugin("PjonkGoose", "PjonkGoose", "1.5.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		public static EnemyType PjonkGooseEnemyType;

		public static Item GoldenEggItem;

		public static GameObject UtilsPrefab;

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

		private readonly Harmony _harmony = new Harmony("PjonkGoose");

		public static PjonkGooseConfig BoundConfig { get; private set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			BoundConfig = new PjonkGooseConfig(((BaseUnityPlugin)this).Config);
			Assets.PopulateAssets();
			_harmony.PatchAll(Assembly.GetExecutingAssembly());
			UtilsPrefab = Assets.MainAssetBundle.LoadAsset<GameObject>("PjonkGooseEnemyUtils");
			GoldenEggItem = Assets.MainAssetBundle.LoadAsset<Item>("PjonkEggObj");
			Utilities.FixMixerGroups(GoldenEggItem.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(GoldenEggItem.spawnPrefab);
			Items.RegisterScrap(GoldenEggItem, 0, (LevelTypes)1);
			samplePrefabs.Add("GoldenEgg", GoldenEggItem);
			PjonkGooseEnemyType = Assets.MainAssetBundle.LoadAsset<EnemyType>("PjonkGooseObj");
			TerminalNode terminalNode = Assets.MainAssetBundle.LoadAsset<TerminalNode>("PjonkGooseTN");
			TerminalKeyword terminalKeyword = Assets.MainAssetBundle.LoadAsset<TerminalKeyword>("PjonkGooseTK");
			NetworkPrefabs.RegisterNetworkPrefab(PjonkGooseEnemyType.enemyPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(PjonkGooseEnemyType.enemyPrefab.GetComponent<PjonkGooseAI>().nest);
			RegisterEnemyWithConfig(BoundConfig.ConfigPjonkGooseSpawnWeights.Value, PjonkGooseEnemyType, terminalNode, terminalKeyword, BoundConfig.ConfigPjonkGoosePowerLevel.Value, BoundConfig.ConfigPjonkGooseMaxCount.Value);
			InitializeNetworkBehaviours();
			Logger.LogInfo((object)"Plugin PjonkGoose is loaded!");
		}

		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 (Dictionary<LevelTypes, int> spawnRateByLevelType, Dictionary<string, int> spawnRateByCustomLevelType) ConfigParsing(string configMoonRarity)
		{
			//IL_007a: 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)
			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 = item.Split(':');
				if (array.Length != 2)
				{
					continue;
				}
				string text = array[0];
				if (!int.TryParse(array[1], out var result))
				{
					continue;
				}
				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);
		}

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

		private void InitializeNetworkBehaviours()
		{
			IEnumerable<Type> enumerable;
			try
			{
				enumerable = Assembly.GetExecutingAssembly().GetTypes();
			}
			catch (ReflectionTypeLoadException ex)
			{
				enumerable = ex.Types.Where((Type t) => t != null);
			}
			foreach (Type item in enumerable)
			{
				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);
					}
				}
			}
		}
	}
	public static class Assets
	{
		public static AssetBundle MainAssetBundle;

		public static void PopulateAssets()
		{
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			MainAssetBundle = AssetBundle.LoadFromFile(Path.Combine(directoryName, "pjonkgooseassets"));
			if ((Object)(object)MainAssetBundle == (Object)null)
			{
				Plugin.Logger.LogError((object)"Failed to load custom assets.");
			}
		}
	}
}
namespace PjonkGooseEnemy.src.EnemyStuff
{
	public abstract class PjonkGooseEnemyEnemyAI : EnemyAI
	{
		public EnemyAI targetEnemy;

		public bool usingElevator;

		public Vector3 positionOfPlayerBeforeTeleport = Vector3.zero;

		public EntranceTeleport lastUsedEntranceTeleport;

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

		public MineshaftElevatorController? elevatorScript;

		public override void Start()
		{
			((EnemyAI)this).Start();
		}

		[Conditional("DEBUG")]
		public void LogIfDebugBuild(object text)
		{
			Plugin.Logger.LogInfo(text);
		}

		[ClientRpc]
		public void SetFloatAnimationClientRpc(string name, float value)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: 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_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3904357172u, val, (RpcDelivery)0);
				bool flag = name != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(name, false);
				}
				((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref value, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3904357172u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				SetFloatAnimationOnLocalClient(name, value);
			}
		}

		public void SetFloatAnimationOnLocalClient(string name, float value)
		{
			base.creatureAnimator.SetFloat(name, value);
		}

		[ClientRpc]
		public void SetBoolAnimationClientRpc(string name, bool active)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: 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_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2481451427u, val, (RpcDelivery)0);
				bool flag = name != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(name, false);
				}
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref active, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2481451427u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				SetBoolAnimationOnLocalClient(name, active);
			}
		}

		public void SetBoolAnimationOnLocalClient(string name, bool active)
		{
			base.creatureAnimator.SetBool(name, active);
		}

		[ServerRpc(RequireOwnership = false)]
		public void TriggerAnimationServerRpc(string triggerName)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2028302706u, val, (RpcDelivery)0);
				bool flag = triggerName != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(triggerName, false);
				}
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2028302706u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				TriggerAnimationClientRpc(triggerName);
			}
		}

		[ClientRpc]
		public void TriggerAnimationClientRpc(string triggerName)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2654770785u, val, (RpcDelivery)0);
				bool flag = triggerName != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(triggerName, false);
				}
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2654770785u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				TriggerAnimationOnLocalClient(triggerName);
			}
		}

		public void TriggerAnimationOnLocalClient(string triggerName)
		{
			base.creatureAnimator.SetTrigger(triggerName);
		}

		public void ToggleEnemySounds(bool toggle)
		{
			((Behaviour)base.creatureSFX).enabled = toggle;
			((Behaviour)base.creatureVoice).enabled = toggle;
		}

		[ClientRpc]
		public void ChangeSpeedClientRpc(float speed)
		{
			//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)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1468592744u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref speed, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1468592744u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					ChangeSpeedOnLocalClient(speed);
				}
			}
		}

		public void ChangeSpeedOnLocalClient(float speed)
		{
			base.agent.speed = speed;
		}

		public bool FindClosestPlayerInRange(float range)
		{
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB val = null;
			float num = float.MaxValue;
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val2 in allPlayerScripts)
			{
				if (((NetworkBehaviour)val2).IsSpawned && val2.isPlayerControlled && !val2.isPlayerDead && !val2.isInHangarShipRoom && EnemyHasLineOfSightToPosition(((Component)val2).transform.position, 60f, range))
				{
					float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)val2).transform.position);
					if (num2 < num)
					{
						num = num2;
						val = val2;
					}
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			base.targetPlayer = val;
			return true;
		}

		public bool EnemyHasLineOfSightToPosition(Vector3 pos, float width = 60f, float range = 20f, float proximityAwareness = 5f)
		{
			//IL_0024: 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_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_0051: 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_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_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)base.eye == (Object)null)
			{
				_ = ((Component)this).transform;
			}
			else
			{
				_ = base.eye;
			}
			if (Vector3.Distance(base.eye.position, pos) >= range || Physics.Linecast(base.eye.position, pos, StartOfRound.Instance.collidersAndRoomMaskAndDefault))
			{
				return false;
			}
			Vector3 val = pos - base.eye.position;
			if (!(Vector3.Angle(base.eye.forward, val) < width))
			{
				return Vector3.Distance(((Component)this).transform.position, pos) < proximityAwareness;
			}
			return true;
		}

		public bool IsPlayerReachable(PlayerControllerB PlayerToCheck)
		{
			//IL_000b: 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_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Invalid comparison between Unknown and I4
			Vector3 navMeshPosition = RoundManager.Instance.GetNavMeshPosition(((Component)PlayerToCheck).transform.position, RoundManager.Instance.navHit, 2.7f, -1);
			if (!RoundManager.Instance.GotNavMeshPositionResult)
			{
				return false;
			}
			base.agent.CalculatePath(navMeshPosition, base.agent.path);
			return (int)base.agent.path.status == 0;
		}

		public float PlayerDistanceFromShip(PlayerControllerB PlayerToCheck)
		{
			//IL_0015: 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)
			if ((Object)(object)PlayerToCheck == (Object)null)
			{
				return -1f;
			}
			return Vector3.Distance(((Component)PlayerToCheck).transform.position, ((Component)StartOfRound.Instance.shipBounds).transform.position);
		}

		private float DistanceFromPlayer(PlayerControllerB player, bool IncludeYAxis)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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 ((Object)(object)player == (Object)null)
			{
				return -1f;
			}
			if (IncludeYAxis)
			{
				return Vector3.Distance(((Component)player).transform.position, ((Component)this).transform.position);
			}
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(((Component)player).transform.position.x, ((Component)player).transform.position.z);
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor(((Component)this).transform.position.x, ((Component)this).transform.position.z);
			return Vector2.Distance(val, val2);
		}

		public bool AnimationIsFinished(string AnimName)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			AnimatorStateInfo currentAnimatorStateInfo = base.creatureAnimator.GetCurrentAnimatorStateInfo(0);
			if (!((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName(AnimName))
			{
				return true;
			}
			currentAnimatorStateInfo = base.creatureAnimator.GetCurrentAnimatorStateInfo(0);
			return ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).normalizedTime >= 1f;
		}

		[ServerRpc(RequireOwnership = false)]
		public void SetTargetServerRpc(int PlayerID)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			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(2676652769u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, PlayerID);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2676652769u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					SetTargetClientRpc(PlayerID);
				}
			}
		}

		[ClientRpc]
		public void SetTargetClientRpc(int PlayerID)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2379409763u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, PlayerID);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2379409763u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (PlayerID == -1)
				{
					base.targetPlayer = null;
				}
				else if (!((Object)(object)StartOfRound.Instance.allPlayerScripts[PlayerID] == (Object)null))
				{
					base.targetPlayer = StartOfRound.Instance.allPlayerScripts[PlayerID];
				}
			}
		}

		[ServerRpc]
		public void SetEnemyTargetServerRpc(int enemyID)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Invalid comparison between Unknown and I4
			//IL_00a5: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: 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_0084: Invalid comparison between Unknown and I4
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1173269175u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, enemyID);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1173269175u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				SetEnemyTargetClientRpc(enemyID);
			}
		}

		[ClientRpc]
		public void SetEnemyTargetClientRpc(int enemyID)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1630424606u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, enemyID);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1630424606u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (enemyID == -1)
				{
					targetEnemy = null;
				}
				else if (!((Object)(object)RoundManager.Instance.SpawnedEnemies[enemyID] == (Object)null))
				{
					targetEnemy = RoundManager.Instance.SpawnedEnemies[enemyID];
				}
			}
		}

		public void GoThroughEntrance(bool followingPlayer)
		{
			//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_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: 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_011a: 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_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: 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_0049: 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)
			//IL_005f: 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_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: 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)
			{
				EntranceTeleport val3 = null;
				foreach (EntranceTeleport key in exitPoints.Keys)
				{
					if ((Object)(object)val3 == (Object)null || Vector3.Distance(positionOfPlayerBeforeTeleport, ((Component)key).transform.position) < Vector3.Distance(positionOfPlayerBeforeTeleport, ((Component)val3).transform.position))
					{
						val3 = key;
					}
				}
				if ((Object)(object)val3 != (Object)null)
				{
					entranceTeleportToUse = val3;
					val = ((Component)val3.entrancePoint).transform.position;
					val2 = ((Component)val3.exitPoint).transform.position;
				}
			}
			else
			{
				entranceTeleportToUse = lastUsedEntranceTeleport;
				val = ((Component)lastUsedEntranceTeleport.exitPoint).transform.position;
				val2 = ((Component)lastUsedEntranceTeleport.entrancePoint).transform.position;
			}
			if ((Object)(object)elevatorScript != (Object)null && NeedsElevator(val, entranceTeleportToUse, elevatorScript))
			{
				UseTheElevator(elevatorScript);
			}
			else if (Vector3.Distance(((Component)this).transform.position, val) <= 3f)
			{
				lastUsedEntranceTeleport = entranceTeleportToUse;
				base.agent.Warp(val2);
				SetEnemyOutsideServerRpc(!base.isOutside);
			}
			else
			{
				base.agent.SetDestination(val);
			}
		}

		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 (!base.isOutside)
			{
				if (!flag || flag2)
				{
					return !flag && flag2;
				}
				return true;
			}
			return false;
		}

		public 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)
					{
						base.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)
			{
				base.agent.SetDestination(needToGoUp ? elevatorScript.elevatorBottomPoint.position : elevatorScript.elevatorTopPoint.position);
			}
			else
			{
				base.agent.SetDestination(elevatorScript.elevatorInsidePoint.position);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void SetEnemyOutsideServerRpc(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)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(4276311489u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref setOutside, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 4276311489u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					SetEnemyOutsideClientRpc(setOutside);
				}
			}
		}

		[ClientRpc]
		public void SetEnemyOutsideClientRpc(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)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2536352066u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref setOutside, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2536352066u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					Plugin.ExtendedLogging("Setting enemy outside: " + setOutside);
					((EnemyAI)this).SetEnemyOutside(setOutside);
				}
			}
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_PjonkGooseEnemyEnemyAI()
		{
			//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
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Expected O, but got Unknown
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Expected O, but got Unknown
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Expected O, but got Unknown
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(3904357172u, new RpcReceiveHandler(__rpc_handler_3904357172));
			NetworkManager.__rpc_func_table.Add(2481451427u, new RpcReceiveHandler(__rpc_handler_2481451427));
			NetworkManager.__rpc_func_table.Add(2028302706u, new RpcReceiveHandler(__rpc_handler_2028302706));
			NetworkManager.__rpc_func_table.Add(2654770785u, new RpcReceiveHandler(__rpc_handler_2654770785));
			NetworkManager.__rpc_func_table.Add(1468592744u, new RpcReceiveHandler(__rpc_handler_1468592744));
			NetworkManager.__rpc_func_table.Add(2676652769u, new RpcReceiveHandler(__rpc_handler_2676652769));
			NetworkManager.__rpc_func_table.Add(2379409763u, new RpcReceiveHandler(__rpc_handler_2379409763));
			NetworkManager.__rpc_func_table.Add(1173269175u, new RpcReceiveHandler(__rpc_handler_1173269175));
			NetworkManager.__rpc_func_table.Add(1630424606u, new RpcReceiveHandler(__rpc_handler_1630424606));
			NetworkManager.__rpc_func_table.Add(4276311489u, new RpcReceiveHandler(__rpc_handler_4276311489));
			NetworkManager.__rpc_func_table.Add(2536352066u, new RpcReceiveHandler(__rpc_handler_2536352066));
		}

		private static void __rpc_handler_3904357172(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_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: 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 name = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref name, false);
				}
				float value = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref value, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((PjonkGooseEnemyEnemyAI)(object)target).SetFloatAnimationClientRpc(name, value);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2481451427(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_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: 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 name = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref name, false);
				}
				bool active = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref active, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((PjonkGooseEnemyEnemyAI)(object)target).SetBoolAnimationClientRpc(name, active);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2028302706(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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: 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 triggerName = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref triggerName, false);
				}
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((PjonkGooseEnemyEnemyAI)(object)target).TriggerAnimationServerRpc(triggerName);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2654770785(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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: 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 triggerName = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref triggerName, false);
				}
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((PjonkGooseEnemyEnemyAI)(object)target).TriggerAnimationClientRpc(triggerName);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1468592744(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)
			{
				float speed = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref speed, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((PjonkGooseEnemyEnemyAI)(object)target).ChangeSpeedClientRpc(speed);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2676652769(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int targetServerRpc = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref targetServerRpc);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((PjonkGooseEnemyEnemyAI)(object)target).SetTargetServerRpc(targetServerRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2379409763(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int targetClientRpc = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref targetClientRpc);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((PjonkGooseEnemyEnemyAI)(object)target).SetTargetClientRpc(targetClientRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1173269175(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: 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_0083: 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_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Invalid comparison between Unknown and I4
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
			}
			else
			{
				int enemyTargetServerRpc = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref enemyTargetServerRpc);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((PjonkGooseEnemyEnemyAI)(object)target).SetEnemyTargetServerRpc(enemyTargetServerRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1630424606(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int enemyTargetClientRpc = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref enemyTargetClientRpc);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((PjonkGooseEnemyEnemyAI)(object)target).SetEnemyTargetClientRpc(enemyTargetClientRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_4276311489(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 enemyOutsideServerRpc = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref enemyOutsideServerRpc, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((PjonkGooseEnemyEnemyAI)(object)target).SetEnemyOutsideServerRpc(enemyOutsideServerRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2536352066(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 enemyOutsideClientRpc = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref enemyOutsideClientRpc, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((PjonkGooseEnemyEnemyAI)(object)target).SetEnemyOutsideClientRpc(enemyOutsideClientRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "PjonkGooseEnemyEnemyAI";
		}
	}
}
namespace PjonkGooseEnemy.EnemyStuff
{
	public class PjonkGooseAI : PjonkGooseEnemyEnemyAI
	{
		public enum State
		{
			Spawning,
			Wandering,
			Guarding,
			ChasingPlayer,
			Death,
			Stunned,
			Idle,
			DragPlayerBodyToNest
		}

		private PlayerControllerB? playerWhoLastHit;

		private const float WALKING_SPEED = 5f;

		private const float SPRINTING_SPEED = 20f;

		private bool isAggro;

		private int playerHits;

		private bool carryingPlayerBody;

		private DeadBodyInfo? bodyBeingCarried;

		public AudioClip GuardHyperVentilateClip;

		public AudioClip[] HonkSounds;

		public AudioClip StartStunSound;

		public AudioClip EndStunSound;

		public AudioClip SpawnSound;

		public AudioClip HissSound;

		public AudioClip EnrageSound;

		public AudioClip[] FootstepSounds;

		public AudioClip[] ViolentFootstepSounds;

		public AudioClip[] featherSounds;

		public AudioClip[] hitSounds;

		public AudioClip[] deathSounds;

		public Transform TopOfBody;

		public GameObject nest;

		public ParticleSystem featherHitParticles;

		public AnimationClip stunAnimation;

		private bool inAggroAnimation;

		private bool canKillPjonk;

		private int hitPjonkCount;

		private GoldenEgg goldenEgg;

		private static int pjonkGooseCount;

		private float timeSinceHittingLocalPlayer;

		private float timeSinceAction;

		private bool holdingEgg;

		private bool recentlyDamaged;

		private bool nestCreated;

		private bool isNestInside = true;

		private Coroutine? recentlyDamagedCoroutine;

		private float collisionThresholdVelocity = 16f;

		private Random enemyRandom;

		private DoorLock[]? doors;

		private bool goldenEggCreated;

		private Vector3 lastPosition;

		private float velocity;

		private float deltaTime = 0.05f;

		[NonSerialized]
		public bool pushingAway;

		private Vector3 pointToGo = Vector3.zero;

		public override void OnDestroy()
		{
			((EnemyAI)this).OnDestroy();
			pjonkGooseCount--;
		}

		public void BaseOutsideOrInsideStart()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//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_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: 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_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			Vector3[] array = (Vector3[])(object)new Vector3[RoundManager.Instance.outsideAINodes.Length];
			for (int i = 0; i < RoundManager.Instance.outsideAINodes.Length; i++)
			{
				array[i] = RoundManager.Instance.outsideAINodes[i].transform.position;
			}
			Vector3[] array2 = (Vector3[])(object)new Vector3[RoundManager.Instance.insideAINodes.Length];
			for (int j = 0; j < RoundManager.Instance.insideAINodes.Length; j++)
			{
				array2[j] = RoundManager.Instance.insideAINodes[j].transform.position;
			}
			Vector3 position = ((Component)this).transform.position;
			Vector3 val = Vector3.positiveInfinity;
			Vector3 val2 = Vector3.positiveInfinity;
			Vector3 val3;
			for (int k = 0; k < array.Length; k++)
			{
				val3 = array[k] - position;
				float sqrMagnitude = ((Vector3)(ref val3)).sqrMagnitude;
				val3 = val - position;
				if (sqrMagnitude < ((Vector3)(ref val3)).sqrMagnitude)
				{
					val = array[k];
				}
			}
			for (int l = 0; l < array2.Length; l++)
			{
				val3 = array2[l] - position;
				float sqrMagnitude2 = ((Vector3)(ref val3)).sqrMagnitude;
				val3 = val2 - position;
				if (sqrMagnitude2 < ((Vector3)(ref val3)).sqrMagnitude)
				{
					val2 = array2[l];
				}
			}
			if (!((EnemyAI)this).isOutside)
			{
				val3 = val - position;
				float sqrMagnitude3 = ((Vector3)(ref val3)).sqrMagnitude;
				val3 = val2 - position;
				if (sqrMagnitude3 < ((Vector3)(ref val3)).sqrMagnitude)
				{
					SetEnemyOutsideClientRpc(setOutside: true);
					((EnemyAI)this).favoriteSpot = nest.transform;
					return;
				}
			}
			if (((EnemyAI)this).isOutside)
			{
				val3 = val - position;
				float sqrMagnitude4 = ((Vector3)(ref val3)).sqrMagnitude;
				val3 = val2 - position;
				if (sqrMagnitude4 > ((Vector3)(ref val3)).sqrMagnitude)
				{
					SetEnemyOutsideClientRpc(setOutside: false);
					((EnemyAI)this).favoriteSpot = nest.transform;
				}
			}
		}

		public override void Start()
		{
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			base.Start();
			((EnemyAI)this).agent.areaMask = -1;
			NavMeshAgent agent = ((EnemyAI)this).agent;
			agent.radius /= 2f;
			((EnemyAI)this).agent.acceleration = 20f;
			((EnemyAI)this).creatureVoice.pitch = 1.4f;
			doors = Object.FindObjectsOfType<DoorLock>();
			enemyRandom = new Random(StartOfRound.Instance.randomMapSeed + 323);
			timeSinceHittingLocalPlayer = 0f;
			timeSinceAction = 0f;
			((EnemyAI)this).creatureVoice.PlayOneShot(SpawnSound);
			pjonkGooseCount++;
			((EnemyAI)this).openDoorSpeedMultiplier = 0.5f;
			if (!((NetworkBehaviour)this).IsHost)
			{
				return;
			}
			lastPosition = ((Component)this).transform.position;
			((MonoBehaviour)this).StartCoroutine(CalculateVelocity());
			((MonoBehaviour)this).StartCoroutine(PushTimer());
			ControlStateSpeedAnimationServerRpc(0f, 0, startSearch: false, running: false, guarding: false, -1, delaySpeed: true, _isAggro: false);
			((MonoBehaviour)this).StartCoroutine(SpawnTimer());
			exitPoints = new Dictionary<EntranceTeleport, Transform[]>();
			EntranceTeleport[] array = Object.FindObjectsByType<EntranceTeleport>((FindObjectsInactive)0, (FindObjectsSortMode)1);
			foreach (EntranceTeleport val in array)
			{
				exitPoints.Add(val, (Transform[])(object)new Transform[2] { val.entrancePoint, val.exitPoint });
				if (val.isEntranceToBuilding)
				{
					lastUsedEntranceTeleport = val;
				}
				if (!val.FindExitPoint())
				{
					Plugin.Logger.LogError((object)"Something went wrong in the generation of the fire exits");
				}
			}
			elevatorScript = Object.FindObjectOfType<MineshaftElevatorController>();
		}

		private IEnumerator PushTimer()
		{
			while (true)
			{
				pushingAway = true;
				yield return (object)new WaitForSeconds(0.5f);
				pushingAway = false;
				yield return (object)new WaitForSeconds(3f);
			}
		}

		private IEnumerator CalculateVelocity()
		{
			while (true)
			{
				Vector3 position = ((Component)this).transform.position;
				velocity = Vector3.Distance(position, lastPosition) / deltaTime;
				lastPosition = position;
				yield return (object)new WaitForSeconds(deltaTime);
			}
		}

		public IEnumerator SpawnTimer()
		{
			yield return (object)new WaitForSeconds(1f);
			if (!nestCreated)
			{
				SpawnNestServerRpc();
			}
			if (!goldenEggCreated)
			{
				SpawnEggInNestServerRpc();
			}
			yield return (object)new WaitForSeconds(2f);
			if (((EnemyAI)this).currentBehaviourStateIndex != 5 && ((EnemyAI)this).currentBehaviourStateIndex != 3 && ((EnemyAI)this).currentBehaviourStateIndex != 4)
			{
				ControlStateSpeedAnimationServerRpc(5f, 1, startSearch: true, running: false, guarding: false, -1, delaySpeed: true, _isAggro: false);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void SpawnNestServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			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(1312854404u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1312854404u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					nest = Object.Instantiate<GameObject>(nest, ((Component)this).transform.position + Vector3.down * 0.013f, Quaternion.identity, RoundManager.Instance.mapPropsContainer.transform);
					nest.GetComponent<NetworkObject>().Spawn(true);
					BaseOutsideOrInsideStart();
					SpawnNestClientRpc();
				}
			}
		}

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

		[ServerRpc(RequireOwnership = false)]
		private void SpawnEggInNestServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: 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_00df: 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(3240551806u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3240551806u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					NetworkObjectReference go = PjonkGooseEnemyUtils.Instance.SpawnScrap(Plugin.GoldenEggItem, nest.transform.position, isQuest: false, defaultRotation: true, 0);
					SpawnEggInNestClientRpc(go);
				}
			}
		}

		[ClientRpc]
		public void SpawnEggInNestClientRpc(NetworkObjectReference go)
		{
			//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)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1305380007u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref go, default(ForNetworkSerializable));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1305380007u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					goldenEggCreated = true;
					GoldenEgg component = NetworkObjectReference.op_Implicit(go).GetComponent<GoldenEgg>();
					Transform transform = ((Component)component).transform;
					transform.localScale *= ((Component)this).transform.localScale.x;
					((GrabbableObject)component).originalScale = ((Component)component).transform.localScale;
					component.spawnedOne = pjonkGooseCount >= 3;
					component.mommyAlive = !((EnemyAI)this).isEnemyDead;
					((MonoBehaviour)this).StartCoroutine(DelayFindingGoldenEgg(component));
				}
			}
		}

		public IEnumerator DelayFindingGoldenEgg(GoldenEgg? _goldenEgg)
		{
			yield return (object)new WaitForSeconds(0.5f);
			if ((Object)(object)_goldenEgg == (Object)null)
			{
				Plugin.Logger.LogError((object)"GoldenEgg spawned null");
				yield break;
			}
			goldenEgg = _goldenEgg;
			if (((NetworkBehaviour)this).IsServer)
			{
				((Component)goldenEgg).transform.SetParent(StartOfRound.Instance.propsContainer, true);
			}
			Plugin.ExtendedLogging("Found egg in nest: " + ((GrabbableObject)goldenEgg).itemProperties.itemName);
		}

		[ServerRpc(RequireOwnership = false)]
		private void ControlStateSpeedAnimationServerRpc(float speed, int state, bool startSearch, bool running, bool guarding, int playerWhoStunnedIndex, bool delaySpeed, bool _isAggro)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: 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_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: 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)
			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(343310906u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref speed, default(ForPrimitives));
					BytePacker.WriteValueBitPacked(val2, state);
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref startSearch, default(ForPrimitives));
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref running, default(ForPrimitives));
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref guarding, default(ForPrimitives));
					BytePacker.WriteValueBitPacked(val2, playerWhoStunnedIndex);
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref delaySpeed, default(ForPrimitives));
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref _isAggro, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 343310906u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ControlStateSpeedAnimationClientRpc(speed, state, startSearch, running, guarding, playerWhoStunnedIndex, delaySpeed, _isAggro);
				}
			}
		}

		[ClientRpc]
		public void ControlStateSpeedAnimationClientRpc(float speed, int state, bool startSearch, bool running, bool guarding, int playerWhoStunnedIndex, bool delaySpeed, bool _isAggro)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: 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_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: 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_01a0: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3246608238u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref speed, default(ForPrimitives));
				BytePacker.WriteValueBitPacked(val2, state);
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref startSearch, default(ForPrimitives));
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref running, default(ForPrimitives));
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref guarding, default(ForPrimitives));
				BytePacker.WriteValueBitPacked(val2, playerWhoStunnedIndex);
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref delaySpeed, default(ForPrimitives));
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref _isAggro, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3246608238u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			isAggro = _isAggro;
			if (state == 3 && delaySpeed)
			{
				inAggroAnimation = true;
				ChangeSpeedOnLocalClient(0f);
				((EnemyAI)this).agent.velocity = Vector3.zero;
			}
			else
			{
				ChangeSpeedOnLocalClient(speed);
				inAggroAnimation = false;
			}
			if (state == 5)
			{
				((EnemyAI)this).SetEnemyStunned(true, stunAnimation.length, StartOfRound.Instance.allPlayerScripts[playerWhoStunnedIndex]);
				TriggerAnimationOnLocalClient("Stunned");
			}
			if (state == 4)
			{
				TriggerAnimationOnLocalClient("Death");
			}
			SetBoolAnimationOnLocalClient("Running", running);
			SetBoolAnimationOnLocalClient("Guarding", guarding);
			SetBoolAnimationOnLocalClient("Aggro", _isAggro);
			SetFloatAnimationOnLocalClient("MoveZ", speed);
			((EnemyAI)this).SwitchToBehaviourStateOnLocalClient(state);
			if (((NetworkBehaviour)this).IsHost)
			{
				if (startSearch)
				{
					((EnemyAI)this).StartSearch(nest.transform.position, (AISearchRoutine)null);
				}
				else
				{
					((EnemyAI)this).StopSearch(((EnemyAI)this).currentSearch, true);
				}
			}
		}

		public override void Update()
		{
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: 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_0159: 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)
			((EnemyAI)this).Update();
			if (((EnemyAI)this).isEnemyDead)
			{
				return;
			}
			if (((EnemyAI)this).stunNormalizedTimer > 0f && ((EnemyAI)this).currentBehaviourStateIndex != 5 && ((NetworkBehaviour)this).IsHost)
			{
				if ((Object)(object)((EnemyAI)this).targetPlayer == (Object)null)
				{
					if ((Object)(object)playerWhoLastHit == (Object)null)
					{
						PlayerControllerB playerWhoStunned = StartOfRound.Instance.allPlayerScripts.OrderBy((PlayerControllerB player) => Vector3.Distance(((Component)player).transform.position, ((Component)this).transform.position)).First();
						StunGoose(playerWhoStunned, delaySpeed: false);
					}
					else
					{
						StunGoose(playerWhoLastHit, delaySpeed: false);
					}
				}
				else
				{
					StunGoose(((EnemyAI)this).targetPlayer, delaySpeed: false);
				}
			}
			timeSinceAction += Time.deltaTime;
			if (timeSinceHittingLocalPlayer > 0f)
			{
				timeSinceHittingLocalPlayer -= Time.deltaTime;
			}
			if (((EnemyAI)this).creatureAnimator.GetBool("Guarding") || ((EnemyAI)this).currentBehaviourStateIndex == 2)
			{
				PlayerControllerB val = StartOfRound.Instance.allPlayerScripts.OrderBy((PlayerControllerB player) => Vector3.Distance(((Component)player).transform.position, ((Component)this).transform.position)).First();
				Vector3 position = ((Component)val).transform.position;
				Vector3 val2 = position - ((Component)this).transform.position;
				Vector3 normalized = ((Vector3)(ref val2)).normalized;
				normalized.y = 0f;
				if (normalized != Vector3.zero)
				{
					Quaternion val3 = Quaternion.LookRotation(normalized);
					((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, val3, Time.deltaTime * 5f);
				}
			}
			if (((NetworkBehaviour)this).IsHost)
			{
				CheckWallCollision();
				CheckForCollidingWithDoor();
			}
		}

		private void CheckForCollidingWithDoor()
		{
			//IL_0064: 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)
			if ((Object)(object)((EnemyAI)this).targetPlayer == (Object)null || ((EnemyAI)this).currentBehaviourStateIndex != 3 || doors == null || doors.Length == 0)
			{
				return;
			}
			DoorLock[] array = doors;
			foreach (DoorLock val in array)
			{
				if (!((Object)(object)val == (Object)null) && !(velocity <= collisionThresholdVelocity - 1f) && Vector3.Distance(((Component)val).transform.position, ((Component)this).transform.position) <= 2.5f)
				{
					Plugin.Logger.LogInfo((object)("Exploding door: " + ((Object)((Component)((Component)val).transform.parent).gameObject).name));
					ExplodeDoorClientRpc(Array.IndexOf(doors, val));
					StunGoose(((EnemyAI)this).targetPlayer, delaySpeed: false);
					if (recentlyDamagedCoroutine != null)
					{
						((MonoBehaviour)this).StopCoroutine(recentlyDamagedCoroutine);
					}
					recentlyDamagedCoroutine = ((MonoBehaviour)this).StartCoroutine(RecentlyDamagedCooldown(((EnemyAI)this).targetPlayer));
				}
			}
		}

		private void CheckWallCollision()
		{
			//IL_0056: 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_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)((EnemyAI)this).targetPlayer == (Object)null || ((EnemyAI)this).currentBehaviourStateIndex != 3 || !(velocity >= 17f))
			{
				return;
			}
			Plugin.ExtendedLogging("Velocity too high: " + velocity);
			int collidersAndRoomMask = StartOfRound.Instance.collidersAndRoomMask;
			RaycastHit val = default(RaycastHit);
			if (!Physics.Raycast(((Component)this).transform.position, ((Component)this).transform.forward, ref val, 1f, collidersAndRoomMask))
			{
				return;
			}
			float num = Vector3.Angle(((RaycastHit)(ref val)).normal, Vector3.up);
			if (num >= 75f)
			{
				Plugin.ExtendedLogging("Wall collision detected with slope >= 70 degrees");
				StunGoose(((EnemyAI)this).targetPlayer, delaySpeed: false);
				if (recentlyDamagedCoroutine != null)
				{
					((MonoBehaviour)this).StopCoroutine(recentlyDamagedCoroutine);
				}
				recentlyDamagedCoroutine = ((MonoBehaviour)this).StartCoroutine(RecentlyDamagedCooldown(((EnemyAI)this).targetPlayer));
			}
		}

		private void StunGoose(PlayerControllerB playerWhoStunned, bool delaySpeed = true)
		{
			ControlStateSpeedAnimationServerRpc(0f, 5, startSearch: false, running: false, guarding: false, Array.IndexOf(StartOfRound.Instance.allPlayerScripts, playerWhoStunned), delaySpeed, _isAggro: true);
			if (holdingEgg)
			{
				DropEggServerRpc();
			}
			if (carryingPlayerBody)
			{
				DropPlayerBodyServerRpc();
			}
			((MonoBehaviour)this).StartCoroutine(StunCooldown(playerWhoStunned, delaySpeed: false));
		}

		private IEnumerator StunCooldown(PlayerControllerB playerWhoStunned, bool delaySpeed = true)
		{
			yield return (object)new WaitUntil((Func<bool>)(() => ((EnemyAI)this).stunNormalizedTimer <= 0f));
			if (!((EnemyAI)this).isEnemyDead)
			{
				SetTargetServerRpc(Array.IndexOf(StartOfRound.Instance.allPlayerScripts, playerWhoStunned));
				ControlStateSpeedAnimationServerRpc(20f, 3, startSearch: false, running: true, guarding: false, Array.IndexOf(StartOfRound.Instance.allPlayerScripts, playerWhoStunned), delaySpeed, _isAggro: true);
			}
		}

		public override void DoAIInterval()
		{
			((EnemyAI)this).DoAIInterval();
			if (!((EnemyAI)this).isEnemyDead && !StartOfRound.Instance.allPlayersDead && ((NetworkBehaviour)this).IsHost)
			{
				switch (((EnemyAI)this).currentBehaviourStateIndex)
				{
				case 1:
					DoWandering();
					break;
				case 2:
					DoGuarding();
					break;
				case 3:
					DoChasingPlayer();
					break;
				case 7:
					DoDragPlayerBodyToNest();
					break;
				case 4:
				case 5:
				case 6:
					break;
				}
			}
		}

		public void DoWandering()
		{
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			if (isAggro)
			{
				return;
			}
			if (timeSinceAction >= (float)enemyRandom.Next(10, 20))
			{
				timeSinceAction = 0f;
				ControlStateSpeedAnimationServerRpc(0f, 6, startSearch: false, running: false, guarding: false, -1, delaySpeed: true, _isAggro: false);
				TriggerAnimationClientRpc("PerformIdleAction");
				((MonoBehaviour)this).StartCoroutine(SpawnTimer());
				return;
			}
			if ((float)Random.Range(1, 101) <= 5f)
			{
				HonkAnimationClientRpc();
			}
			if (HandleEnemyOrPlayerGrabbingEgg() || !(Vector3.Distance(((Component)goldenEgg).transform.position, nest.transform.position) > 5f))
			{
				return;
			}
			Plugin.ExtendedLogging("Egg is not near the nest, get egg back.");
			if ((Object)(object)((GrabbableObject)goldenEgg).playerHeldBy == (Object)null)
			{
				Plugin.ExtendedLogging("Egg is not held by any player");
				if ((Object)(object)((EnemyAI)this).targetPlayer != (Object)null)
				{
					SetTargetServerRpc(-1);
				}
				if (Vector3.Distance(((Component)this).transform.position, ((Component)goldenEgg).transform.position) <= 3f && !holdingEgg)
				{
					GrabEggServerRpc();
					PlayMiscSoundsServerRpc(0);
					ControlStateSpeedAnimationServerRpc(15f, 2, startSearch: false, running: false, guarding: true, -1, delaySpeed: true, _isAggro: false);
				}
				else
				{
					DoPathingToDestination(((Component)goldenEgg).transform.position, ((GrabbableObject)goldenEgg).isInFactory, followingPlayer: true);
				}
			}
		}

		public void DoGuarding()
		{
			//IL_0019: 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_006c: Unknown result type (might be due to invalid IL or missing references)
			if (HandleEnemyOrPlayerGrabbingEgg())
			{
				Plugin.ExtendedLogging("Egg was stolen somehow");
				return;
			}
			if (Vector3.Distance(((Component)this).transform.position, nest.transform.position) < 0.75f)
			{
				DropEggServerRpc();
				ControlStateSpeedAnimationServerRpc(0f, 6, startSearch: false, running: false, guarding: true, -1, delaySpeed: true, _isAggro: false);
				((MonoBehaviour)this).StartCoroutine(SpawnTimer());
				return;
			}
			DoPathingToDestination(nest.transform.position, isNestInside, followingPlayer: false);
			if (((GrabbableObject)goldenEgg).isHeldByEnemy)
			{
				((GrabbableObject)goldenEgg).EnablePhysics(true);
			}
		}

		public void DoChasingPlayer()
		{
			//IL_0131: 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_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			if ((float)Random.Range(1, 101) <= 7f && ((EnemyAI)this).agent.speed >= 1f)
			{
				HonkAnimationClientRpc();
			}
			if ((Object)(object)goldenEgg == (Object)null)
			{
				Plugin.ExtendedLogging("Golden egg is null");
				ControlStateSpeedAnimationServerRpc(5f, 1, startSearch: true, running: false, guarding: false, -1, delaySpeed: true, _isAggro: false);
				SetTargetServerRpc(-1);
				return;
			}
			if ((Object)(object)((EnemyAI)this).targetPlayer == (Object)null && recentlyDamaged)
			{
				Plugin.ExtendedLogging("Target player is null");
				SetTargetServerRpc(Array.IndexOf(StartOfRound.Instance.allPlayerScripts, playerWhoLastHit));
			}
			if (recentlyDamaged && (Object)(object)((EnemyAI)this).targetPlayer != (Object)null)
			{
				Plugin.ExtendedLogging("Chasing player because recently damaged");
				if (holdingEgg)
				{
					DropEggServerRpc();
				}
				if (carryingPlayerBody)
				{
					DropPlayerBodyServerRpc();
				}
				DoPathingToDestination(((Component)((EnemyAI)this).targetPlayer).transform.position, ((EnemyAI)this).targetPlayer.isInsideFactory, followingPlayer: true);
			}
			else if ((Object)(object)((EnemyAI)this).targetPlayer != (Object)null && (Object)(object)((GrabbableObject)goldenEgg).playerHeldBy == (Object)(object)((EnemyAI)this).targetPlayer)
			{
				Plugin.ExtendedLogging("Chasing player holding the egg");
				DoPathingToDestination(((Component)((EnemyAI)this).targetPlayer).transform.position, ((EnemyAI)this).targetPlayer.isInsideFactory, followingPlayer: true);
			}
			else if ((Object)(object)((GrabbableObject)goldenEgg).playerHeldBy != (Object)null && (Object)(object)((EnemyAI)this).targetPlayer != (Object)(object)((GrabbableObject)goldenEgg).playerHeldBy)
			{
				Plugin.ExtendedLogging("Changing target to player holding the egg");
				SetTargetServerRpc(Array.IndexOf(StartOfRound.Instance.allPlayerScripts, ((GrabbableObject)goldenEgg).playerHeldBy));
			}
			else if ((Object)(object)((GrabbableObject)goldenEgg).playerHeldBy == (Object)null)
			{
				Plugin.ExtendedLogging("Egg is not held by any player");
				if ((Object)(object)((EnemyAI)this).targetPlayer != (Object)null)
				{
					SetTargetServerRpc(-1);
				}
				if (Vector3.Distance(((Component)this).transform.position, ((Component)goldenEgg).transform.position) < 3f && !holdingEgg)
				{
					GrabEggServerRpc();
					PlayMiscSoundsServerRpc(0);
					ControlStateSpeedAnimationServerRpc(5f, 2, startSearch: false, running: false, guarding: true, -1, delaySpeed: true, _isAggro: false);
				}
				else
				{
					DoPathingToDestination(((Component)goldenEgg).transform.position, ((GrabbableObject)goldenEgg).isInFactory, followingPlayer: true);
				}
			}
			else if (!recentlyDamaged && (Object)(object)((GrabbableObject)goldenEgg).playerHeldBy != (Object)null && (Object)(object)((EnemyAI)this).t