Decompiled source of HuntedCompanyUpdated v1.0.1

HuntedCompany-1.2.4b0.dll

Decompiled 4 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using HuntedCompany.NetcodePatcher;
using HuntedCompany.ai;
using HuntedCompany.audio;
using HuntedCompany.predator;
using HuntedCompany.util;
using JetBrains.Annotations;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.UIElements.Collections;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("HuntedCompany")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A vore mod for Lethal Company")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: AssemblyInformationalVersion("1.2.0+ca7cff335cbeeff61cf30b6c5ded0974b0e79ecf")]
[assembly: AssemblyProduct("HuntedCompany")]
[assembly: AssemblyTitle("HuntedCompany")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace HuntedCompany
{
	[BepInPlugin("HuntedCompany", "HuntedCompany", "1.2.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		private readonly Harmony _harmony = new Harmony("HuntedCompany");

		public static ManualLogSource LoggerInst;

		public static AssetBundle ModAssetBundle;

		public static GameObject ScavPrefab;

		public static GameObject TestPrefab;

		public static List<(string, EnemyType, GameObject, TerminalNode, TerminalKeyword, Dictionary<string, int>)> Predators = new List<(string, EnemyType, GameObject, TerminalNode, TerminalKeyword, Dictionary<string, int>)>();

		public static Dictionary<string, int> PredOffset = new Dictionary<string, int>();

		public static ConfigEntry<int> PredCount;

		public static ConfigEntry<int> SpawnChance;

		public static ConfigEntry<bool> DuplicatePred;

		public static ConfigEntry<bool> DisableVanilla;

		public static ConfigEntry<bool> PredsIgnorePower;

		public static ConfigEntry<bool> Digestion;

		public static ConfigEntry<bool> StruggleTip;

		public static ConfigEntry<bool> LeaveImmediately;

		public static ConfigEntry<bool> StruggleEffect;

		public static ConfigFile ConfigFile;

		private static readonly List<string> Moons = new List<string>(12)
		{
			"41 Experimentation", "220 Assurance", "56 Vow", "21 Offense", "61 March", "20 Adamance", "85 Rend", "7 Dine", "8 Titan", "68 Artifice",
			"5 Embrion", "44 Liquidation"
		};

		private void Awake()
		{
			LoggerInst = ((BaseUnityPlugin)this).Logger;
			LoggerInst.LogInfo((object)"Loading Hunted Company! Version 1.2.0");
			ModAssetBundle = AssetBundle.LoadFromMemory(Global.GetValue("devout"));
			TestPrefab = ModAssetBundle.LoadAsset<GameObject>("Assets/Modded/Items/Testing.prefab");
			ScavPrefab = ModAssetBundle.LoadAsset<GameObject>("Assets/Modded/Scavenger/Scavenger.prefab");
			AddPredator<DevAI>("DeVout", MakeSpawnList(new <>z__ReadOnlyArray<int>(new int[12]
			{
				7, 6, 6, 5, 5, 5, 4, 4, 3, 3,
				5, 5
			})));
			AddPredator<ArchieAI>("Archie", MakeSpawnList(new <>z__ReadOnlyArray<int>(new int[12]
			{
				3, 4, 4, 5, 5, 5, 6, 6, 7, 7,
				5, 5
			})));
			PredCount = ((BaseUnityPlugin)this).Config.Bind<int>("Spawning", "Predator Count", 1, "The maximum amount of predators spawned");
			SpawnChance = ((BaseUnityPlugin)this).Config.Bind<int>("Spawning", "Spawn Chance", 40, "The chance of a predator replacing a vanilla spawn (0 to 100)");
			DuplicatePred = ((BaseUnityPlugin)this).Config.Bind<bool>("Spawning", "Enable Duplicate Predators", false, "Allow duplicates of the same predator to spawn.");
			DisableVanilla = ((BaseUnityPlugin)this).Config.Bind<bool>("Spawning", "Disable Vanilla Enemies", false, "Disables vanilla enemy spawns. Does not disable outdoor spawns or traps. If true, you should probably set Spawn Chance to 100.");
			PredsIgnorePower = ((BaseUnityPlugin)this).Config.Bind<bool>("Spawning", "Predators Ignore Power Level", false, "Causes Predators that spawn to spawn with 0 power. Useful in conjunction with DisableVanilla to finetune how many preds should spawn.");
			Digestion = ((BaseUnityPlugin)this).Config.Bind<bool>("Gameplay", "Enable Digestion", true, "Enable the predator digesting their prey. This is per-client, other players will still be digested if they set this to true");
			StruggleTip = ((BaseUnityPlugin)this).Config.Bind<bool>("Gameplay", "Show Struggle Tip", true, "Shows the struggle tip again. This is mostly here cause there isn't a better way to save this lol");
			LeaveImmediately = ((BaseUnityPlugin)this).Config.Bind<bool>("Gameplay", "Leave Immediately", true, "Causes the ship to leave immediately after every non-digestion player is eaten");
			StruggleEffect = ((BaseUnityPlugin)this).Config.Bind<bool>("Gameplay", "Struggle Damage", true, "Causes damage when you struggle. Set to false if you'd like to enjoy the animations without taking damage. Has no effect if Digestion is false.");
			ConfigFile = ((BaseUnityPlugin)this).Config;
			((BaseUnityPlugin)this).Config.Save();
			AudioManager.Setup(ModAssetBundle);
			_harmony.PatchAll();
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}

		private Dictionary<string, int> MakeSpawnList(IReadOnlyList<int> spawns)
		{
			Dictionary<string, int> dictionary = new Dictionary<string, int>();
			for (int i = 0; i < spawns.Count; i++)
			{
				dictionary.Add(Moons[i], spawns[i]);
			}
			return dictionary;
		}

		private void AddPredator<T>(string name, Dictionary<string, int> spawnChances) where T : EnemyAI
		{
			if (((BaseUnityPlugin)this).Config.Bind<bool>("Predators", name, true, "Toggles whether " + name + " will appear in game. Only the host's choices affect this, so make sure to tell them if there's a predator you absolutely do not want to see.").Value)
			{
				EnemyType item = ModAssetBundle.LoadAsset<EnemyType>("Assets/Modded/Preds/" + name + "/Type.asset");
				TerminalNode item2 = ModAssetBundle.LoadAsset<TerminalNode>("Assets/Modded/Preds/" + name + "/Log.asset");
				TerminalKeyword item3 = ModAssetBundle.LoadAsset<TerminalKeyword>("Assets/Modded/Preds/" + name + "/Keyword.asset");
				GameObject val = ModAssetBundle.LoadAsset<GameObject>("Assets/Modded/Preds/" + name + "/Predator.prefab");
				val.AddComponent<T>();
				Predators.Add((name, item, val, item2, item3, spawnChances));
				EnemyAICollisionDetect[] componentsInChildren = val.GetComponentsInChildren<EnemyAICollisionDetect>();
				foreach (EnemyAICollisionDetect val2 in componentsInChildren)
				{
					val2.mainScript = (EnemyAI)(object)val.GetComponent<T>();
				}
			}
		}
	}
	[HarmonyPatch(typeof(NetworkManager))]
	internal class NetworkManagerPatch
	{
		[HarmonyPatch("OnEnable")]
		[HarmonyPostfix]
		private static void Enable(ref NetworkManager __instance)
		{
			foreach (var predator in Plugin.Predators)
			{
				GameObject item = predator.Item3;
				__instance.AddNetworkPrefab(item);
			}
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartGamePatch
	{
		public static bool isSetup;

		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		private static void StartGame(ref StartOfRound __instance)
		{
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Expected O, but got Unknown
			Debug.Log((object)("Checking setup: " + isSetup));
			if (isSetup)
			{
				return;
			}
			isSetup = true;
			SelectableLevel[] levels = __instance.levels;
			foreach (SelectableLevel val in levels)
			{
				Debug.Log((object)("Added predators to planet " + val.PlanetName));
				Plugin.PredOffset.Add(val.PlanetName, val.Enemies.Count);
			}
			foreach (var predator in Plugin.Predators)
			{
				EnemyType types = predator.Item2;
				Debug.Log((object)("Setup spawns for " + types.enemyName));
				SpawnableEnemyWithRarity item = new SpawnableEnemyWithRarity(types, 0);
				SelectableLevel[] levels2 = __instance.levels;
				foreach (SelectableLevel val2 in levels2)
				{
					if (val2.Enemies.All((SpawnableEnemyWithRarity found) => (Object)(object)found.enemyType != (Object)(object)types))
					{
						val2.Enemies.Add(item);
					}
				}
			}
		}
	}
	[HarmonyPatch(typeof(RoundManager))]
	internal class RoundManagerPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPrefix]
		private static void Update(ref RoundManager __instance)
		{
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: 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_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			if (((ButtonControl)Keyboard.current.numpad0Key).wasPressedThisFrame && Keyboard.current.shiftKey.isPressed && Keyboard.current.ctrlKey.isPressed)
			{
				int num = 0;
				foreach (SpawnableEnemyWithRarity enemy in __instance.currentLevel.Enemies)
				{
					EnemyType enemyType = enemy.enemyType;
					if ((Object)(object)enemyType != (Object)null && enemyType.enemyName != null && enemyType.enemyName == "Dev")
					{
						break;
					}
					num++;
				}
				__instance.SpawnEnemyOnServer(((Component)__instance.playersManager.allPlayerScripts[0]).transform.position + ((Component)__instance.playersManager.allPlayerScripts[0].gameplayCamera).transform.forward * 5f, 0f, num);
			}
			else if (((ButtonControl)Keyboard.current.numpad1Key).wasPressedThisFrame && Keyboard.current.shiftKey.isPressed && Keyboard.current.ctrlKey.isPressed)
			{
				int num2 = 0;
				foreach (SpawnableEnemyWithRarity enemy2 in __instance.currentLevel.Enemies)
				{
					EnemyType enemyType2 = enemy2.enemyType;
					if ((Object)(object)enemyType2 != (Object)null && enemyType2.enemyName != null && enemyType2.enemyName == "Archie")
					{
						break;
					}
					num2++;
				}
				__instance.SpawnEnemyOnServer(((Component)__instance.playersManager.allPlayerScripts[0]).transform.position + ((Component)__instance.playersManager.allPlayerScripts[0].gameplayCamera).transform.forward * 5f, 0f, num2);
			}
			else if (((ButtonControl)Keyboard.current.minusKey).wasPressedThisFrame)
			{
				Transform transform = ((Component)__instance.playersManager.allPlayerScripts[0]).transform;
				transform.position += ((Component)__instance.playersManager.allPlayerScripts[0].gameplayCamera).transform.forward * 10f;
			}
		}
	}
	[HarmonyPatch(typeof(Terminal))]
	internal class TerminalPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		private static void Start(ref Terminal __instance)
		{
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Expected O, but got Unknown
			Terminal val = __instance;
			int num = val.enemyFiles.Count;
			foreach (var predator in Plugin.Predators)
			{
				GameObject item = predator.Item3;
				TerminalNode item2 = predator.Item4;
				TerminalKeyword item3 = predator.Item5;
				item.GetComponentInChildren<ScanNodeProperties>().creatureScanID = num;
				item2.creatureFileID = num;
				TerminalKeyword val2 = (item3.defaultVerb = val.terminalNodes.allKeywords.First((TerminalKeyword keyword) => keyword.word == "info"));
				val.enemyFiles.Add(item2);
				List<TerminalKeyword> list = val.terminalNodes.allKeywords.ToList();
				list.Add(item3);
				val.terminalNodes.allKeywords = list.ToArray();
				List<CompatibleNoun> list2 = val2.compatibleNouns.ToList();
				list2.Add(new CompatibleNoun(item3, item2));
				val2.compatibleNouns = list2.ToArray();
				num++;
			}
		}
	}
	public static class Global
	{
		public static byte[] GetValue(string name)
		{
			Stream manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("HuntedCompany.resources.huntedcompany");
			byte[] array = new byte[manifestResourceStream.Length];
			if (manifestResourceStream.Read(array, 0, (int)manifestResourceStream.Length) != manifestResourceStream.Length)
			{
				Plugin.LoggerInst.LogError((object)$"Bytes: {manifestResourceStream.Length}");
			}
			return array;
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "HuntedCompany";

		public const string PLUGIN_NAME = "HuntedCompany";

		public const string PLUGIN_VERSION = "1.2.0";
	}
}
namespace HuntedCompany.util
{
	public static class Animations
	{
		public static IEnumerator PlayDefaultEatAnimation<T>(PredAI<T> predator, Food food, int doneState)
		{
			((Renderer)predator.scavenger.GetComponentInChildren<SkinnedMeshRenderer>()).enabled = false;
			yield return (object)new WaitForSeconds(1.3f);
			((EnemyAI)predator).creatureSFX.PlayOneShot(AudioManager.Gulps[Random.Range(0, 10)]);
			yield return (object)new WaitForSeconds(1.2f);
			((EnemyAI)predator).creatureSFX.PlayOneShot(AudioManager.Gulps[Random.Range(0, 10)]);
			yield return (object)new WaitForSeconds(1.2f);
			Debug.Log((object)"Switching to third person");
			predator.eating.disableLookInput = false;
			predator.thirdPerson = true;
			((Renderer)predator.scavenger.GetComponentInChildren<SkinnedMeshRenderer>()).enabled = true;
			((EnemyAI)predator).creatureSFX.PlayOneShot(AudioManager.Gulps[Random.Range(0, 10)]);
			yield return (object)new WaitForSeconds(1.3f);
			((EnemyAI)predator).creatureSFX.PlayOneShot(AudioManager.Gulps[Random.Range(0, 10)]);
			yield return (object)new WaitForSeconds(1.3f);
			((EnemyAI)predator).creatureSFX.PlayOneShot(AudioManager.Gulps[Random.Range(0, 10)]);
			yield return (object)new WaitForSeconds(1f);
			predator.thirdPerson = false;
			if (RoundManager.Instance.playersManager.allPlayerScripts.All((PlayerControllerB player) => !((EnemyAI)predator).PlayerIsTargetable(player, false, false, true)))
			{
				PredAI<T>[] array = Object.FindObjectsOfType<PredAI<T>>();
				foreach (PredAI<T> pred in array)
				{
					pred.allEaten = true;
				}
			}
			else
			{
				Debug.Log((object)("Switching state post eat: " + doneState));
			}
			((EnemyAI)predator).SwitchToBehaviourState((!predator.allEaten) ? doneState : 0);
			predator.FinishEat(food);
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class TeleportPatch
	{
		[HarmonyPatch("TeleportPlayer")]
		[HarmonyPrefix]
		private static bool TeleportPlayer(ref PlayerControllerB __instance, Vector3 pos, bool withRotation, float rot, bool allowInteractTrigger, bool enableController)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			if (rot != 160f || allowInteractTrigger || !enableController || !withRotation || !IsTeleporterPosition(pos))
			{
				return true;
			}
			Debug.LogWarning((object)("Teleporting triggered for " + (object)__instance));
			BasePred[] array = Object.FindObjectsOfType<BasePred>();
			foreach (BasePred basePred in array)
			{
				Debug.LogWarning((object)("Checking from " + GeneralExtensions.Join<string>(basePred.Bellied.Select((Food food) => food.Player.playerUsername), (Func<string, string>)null, ", ")));
				ulong id = __instance.playerClientId;
				Food food2 = basePred.Bellied.Find((Food food) => food.Player.playerClientId == id);
				if (food2 != null)
				{
					Debug.LogWarning((object)("Teleporting " + food2.Player.playerUsername));
					basePred.UnbellySync(food2.Player);
				}
			}
			return true;
		}

		[HarmonyPatch("TeleportPlayer")]
		[HarmonyPostfix]
		private static void FixPostTeleport(ref PlayerControllerB __instance, Vector3 pos, bool withRotation, float rot, bool allowInteractTrigger, bool enableController)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			if (!(rot != 160f || allowInteractTrigger) && enableController && withRotation && IsTeleporterPosition(pos))
			{
				Debug.LogWarning((object)"Teleporter Postfix Entered.");
			}
		}

		private static bool IsTeleporterPosition(Vector3 pos)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			return StartOfRound.Instance.SpawnedShipUnlockables.Values.Select((GameObject unlockable) => unlockable.GetComponent<ShipTeleporter>()).Any((ShipTeleporter teleporter) => (Object)(object)teleporter != (Object)null && !teleporter.isInverseTeleporter && pos == teleporter.teleporterPosition.position);
		}
	}
	[HarmonyPatch(typeof(ShipTeleporter))]
	internal class TeleporterFix
	{
		[HarmonyPatch("PressTeleportButtonClientRpc")]
		[HarmonyPostfix]
		private static void DoBeamUpPlayer(ref ShipTeleporter __instance)
		{
			Debug.LogWarning((object)("Button press triggered for " + ((Object)__instance).name));
			if (__instance.isInverseTeleporter)
			{
				return;
			}
			PlayerControllerB targetedPlayer = StartOfRound.Instance.mapScreen.targetedPlayer;
			BasePred[] array = Object.FindObjectsOfType<BasePred>();
			foreach (BasePred basePred in array)
			{
				Debug.LogWarning((object)("Checking from " + GeneralExtensions.Join<string>(basePred.Bellied.Select((Food food) => food.Player.playerUsername), (Func<string, string>)null, ", ")));
				ulong id = targetedPlayer.playerClientId;
				Food food2 = basePred.Bellied.Find((Food food) => food.Player.playerClientId == id);
				if (food2 != null && !food2.Savable)
				{
					Debug.LogWarning((object)("Cancelling teleporting " + food2.Player.playerUsername));
					((MonoBehaviour)__instance).StopAllCoroutines();
				}
			}
		}
	}
	[HarmonyPatch(typeof(GameNetworkManager))]
	internal class RoundEndFix
	{
		[HarmonyPatch("StartDisconnect")]
		[HarmonyPrefix]
		private static void Disconnect(ref GameNetworkManager __instance)
		{
			PlayerControllerB localPlayerController = __instance.localPlayerController;
			Debug.LogWarning((object)("Disconnecting player id " + localPlayerController.actualClientId + " (" + __instance.localPlayerController.playerUsername + ")"));
			BasePred[] array = Object.FindObjectsOfType<BasePred>();
			foreach (BasePred basePred in array)
			{
				ulong id = localPlayerController.actualClientId;
				if (((NetworkBehaviour)basePred).OwnerClientId == id && localPlayerController.actualClientId != 0)
				{
					((EnemyAI)basePred).ChangeOwnershipOfEnemy(0uL);
				}
				Food food2 = basePred.Bellied.Find((Food food) => food.Player.actualClientId == id);
				if (food2 != null)
				{
					Debug.Log((object)("Food was not null on disconnect: " + food2.Player.playerUsername));
					basePred.UnbellyAndCleanupSync(food2, (int)id);
				}
			}
		}
	}
	[HarmonyPatch(typeof(RoundManager))]
	internal class EndOfRoundCleanUpPatch
	{
		[HarmonyPatch("UnloadSceneObjectsEarly")]
		[HarmonyPrefix]
		private static void UnbellyBeforeUnloadScene(ref RoundManager __instance)
		{
			if (!((NetworkBehaviour)GameNetworkManager.Instance.localPlayerController).IsHost || !((NetworkBehaviour)GameNetworkManager.Instance.localPlayerController).IsServer)
			{
				return;
			}
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB player in allPlayerScripts)
			{
				BasePred[] array = Object.FindObjectsOfType<BasePred>();
				foreach (BasePred basePred in array)
				{
					if (!basePred.Bellied.All((Food food) => (Object)(object)food.Player != (Object)(object)player))
					{
						Debug.Log((object)(player.playerUsername + " is eaten post round. ==Unload Scene=="));
						Food food2 = basePred.Bellied.Find((Food food) => (Object)(object)food.Player == (Object)(object)player);
						basePred.UnbellyAndCleanupSync(food2, (int)food2.Player.playerClientId);
						break;
					}
				}
			}
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class DisableKillPatch
	{
		[HarmonyPatch("KillPlayer")]
		[HarmonyPrefix]
		private static bool TakeOffHelper(ref PlayerControllerB __instance, Vector3 bodyVelocity, bool spawnBody)
		{
			PlayerControllerB player = __instance;
			Debug.LogWarning((object)("TakeOffHelper entered, KillPlayer call on " + ((Object)player).name + " and shipIsLeaving: " + StartOfRound.Instance.shipIsLeaving));
			Debug.LogWarning((object)("TakeOffHelper: Player is dead?: " + player.isPlayerDead));
			if (player.isPlayerDead)
			{
				return false;
			}
			if (StartOfRound.Instance.shipIsLeaving)
			{
				BasePred[] array = Object.FindObjectsOfType<BasePred>();
				foreach (BasePred basePred in array)
				{
					if (!basePred.Bellied.All((Food food) => (Object)(object)food.Player != (Object)(object)player))
					{
						Debug.Log((object)(player.playerUsername + " is eaten post round. ==TakeOffHelper=="));
						Food food2 = basePred.Bellied.Find((Food food) => (Object)(object)food.Player == (Object)(object)player);
						basePred.UnbellyAndCleanupSync(food2, (int)food2.Player.playerClientId);
					}
				}
				return true;
			}
			if (!spawnBody || (Object)(object)__instance == (Object)null || (Object)(object)__instance.inAnimationWithEnemy == (Object)null || !__instance.inSpecialInteractAnimation)
			{
				return true;
			}
			bool flag = false;
			BasePred[] array2 = Object.FindObjectsOfType<BasePred>();
			foreach (BasePred basePred2 in array2)
			{
				if (!basePred2.Bellied.All((Food food) => (Object)(object)food.Player != (Object)(object)player))
				{
					flag = true;
					break;
				}
			}
			if (flag)
			{
				Debug.Log((object)"Stopping kill!");
			}
			return !flag;
		}

		[HarmonyPatch("KillPlayer")]
		[HarmonyPostfix]
		private static void TakeOffAfterDeath(ref PlayerControllerB __instance, Vector3 bodyVelocity, bool spawnBody)
		{
			Debug.LogWarning((object)("Player died postfix: " + __instance.playerUsername + ", is dead: " + __instance.isPlayerDead));
			if (__instance.isPlayerDead)
			{
				CheckTakeoffServerRPC(__instance);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public static void CheckTakeoffServerRPC(PlayerControllerB __instance)
		{
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: 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_0195: Expected O, but got Unknown
			if (!Plugin.LeaveImmediately.Value || StartOfRound.Instance.livingPlayers == 0)
			{
				return;
			}
			Debug.Log((object)"Endo player check for early takeoff.");
			bool flag = true;
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if ((Object)(object)val == (Object)(object)__instance || val.isPlayerDead || !val.isPlayerControlled)
				{
					continue;
				}
				bool flag2 = false;
				BasePred[] array = Object.FindObjectsOfType<BasePred>();
				foreach (BasePred basePred in array)
				{
					ulong id = val.playerClientId;
					Food food2 = basePred.Bellied.Find((Food food) => food.Player.playerClientId == id);
					if (food2 != null)
					{
						if (!food2.DigestionValue)
						{
							Debug.Log((object)(val.playerUsername + " is eaten with endo enabled."));
							flag2 = true;
						}
						else
						{
							Debug.Log((object)(val.playerUsername + " is eaten with digestion enabled."));
						}
						break;
					}
				}
				if (!flag2)
				{
					flag = false;
					break;
				}
			}
			if (flag && !StartOfRound.Instance.shipIsLeaving)
			{
				StartOfRound.Instance.ShipLeaveAutomatically(false);
				HUDManager.Instance.ReadDialogue((DialogueSegment[])(object)new DialogueSegment[1]
				{
					new DialogueSegment
					{
						speakerText = "SHIP LEAVING",
						bodyText = "Ship leaving early due to incapacitation of all workers"
					}
				});
			}
		}
	}
	[HarmonyPatch]
	internal static class HuntedProtogenExtensionsVisibility
	{
		private static MethodBase _target;

		[UsedImplicitly]
		private static bool Prepare()
		{
			if (!Chainloader.PluginInfos.Select((KeyValuePair<string, PluginInfo> plugin) => plugin.Value.Metadata).Any((BepInPlugin metadata) => metadata.GUID.Equals("CompanyIssuedProtogen")))
			{
				return false;
			}
			Debug.LogWarning((object)"CompanyIssuedProtogen detected, patching for HuntedCompany");
			Type type = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault((Assembly a) => a.GetName().Name == "CompanyIssuedProtogen")?.GetType("CompanyIssuedProtogen.Protogen.ProtogenHandler");
			if (type == null)
			{
				return true;
			}
			Debug.LogWarning((object)type);
			_target = type.GetTypeInfo().GetDeclaredMethod("IsVisible");
			return true;
		}

		[UsedImplicitly]
		private static MethodBase TargetMethod()
		{
			return _target;
		}

		[UsedImplicitly]
		private static void Prefix(ref Object __instance, ref bool visible)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			PlayerControllerB player = (PlayerControllerB)((object)__instance).GetType().GetTypeInfo().GetField("player")
				.GetValue(__instance);
			if (Object.FindObjectsOfType<BasePred>().Any((BasePred pred) => pred.Bellied.Any((Food food) => food.Player.playerClientId == player.playerClientId)))
			{
				visible = false;
			}
		}
	}
	public static class MapManager
	{
		public static List<MapNode> Nodes;

		private static readonly Color[] Colors = (Color[])(object)new Color[6]
		{
			Color.red,
			Color.green,
			Color.blue,
			Color.cyan,
			Color.magenta,
			Color.red
		};

		private const float Scale = 0.2f;

		private static readonly Vector3[] Checking = (Vector3[])(object)new Vector3[6]
		{
			new Vector3(0f, 0.2f, 0f),
			new Vector3(0.2f, 0f, 0f),
			new Vector3(-0.2f, 0f, 0f),
			new Vector3(0f, -0.2f, 0f),
			new Vector3(0f, 0f, 0.2f),
			new Vector3(0f, 0f, -0.2f)
		};

		public static void CreateMap(bool debug = false)
		{
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: 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_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_040d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0412: Unknown result type (might be due to invalid IL or missing references)
			//IL_0425: Unknown result type (might be due to invalid IL or missing references)
			//IL_0435: Expected O, but got Unknown
			//IL_0442: Unknown result type (might be due to invalid IL or missing references)
			//IL_0447: Unknown result type (might be due to invalid IL or missing references)
			//IL_045a: Unknown result type (might be due to invalid IL or missing references)
			//IL_046a: Expected O, but got Unknown
			//IL_049f: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b6: Unknown result type (might be due to invalid IL or missing references)
			List<MapNode> found = new List<MapNode>();
			GameObject[] array = GameObject.FindGameObjectsWithTag("AINode");
			foreach (GameObject val in array)
			{
				if (debug)
				{
					GameObject val2 = Object.Instantiate<GameObject>(Plugin.TestPrefab);
					val2.transform.position = val.transform.position;
					found.Add(new MapNode(val2, val2.transform.position));
				}
				else
				{
					found.Add(new MapNode(null, val.transform.position));
				}
			}
			DoorLock[] array2 = Object.FindObjectsByType<DoorLock>((FindObjectsSortMode)0);
			foreach (DoorLock val3 in array2)
			{
				if (((Behaviour)val3).isActiveAndEnabled)
				{
					if (debug)
					{
						GameObject val4 = Object.Instantiate<GameObject>(Plugin.TestPrefab);
						val4.transform.position = ((Component)val3).transform.position;
						found.Add(new MapNode(val4, val4.transform.position));
					}
					else
					{
						found.Add(new MapNode(null, ((Component)val3).transform.position));
					}
				}
			}
			for (int i = 0; i < found.Count; i++)
			{
				int j;
				for (j = i + 1; j < found.Count; j++)
				{
					if (!(Vector3.Distance(found[i].Position, found[j].Position) > 25f) && !Checking.All((Vector3 adding) => Physics.Linecast(found[i].Position + adding, found[j].Position + adding, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1)))
					{
						found[i].Connected.Add(found[j]);
						found[j].Connected.Add(found[i]);
					}
				}
			}
			foreach (MapNode node in found)
			{
				List<MapNode> list = node.Connected.ToList();
				foreach (MapNode item in node.Connected.SelectMany((MapNode connected) => connected.Connected.Where((MapNode mutual) => node.Connected.Contains(mutual) && Vector3.Distance(node.Position, mutual.Position) > Vector3.Distance(connected.Position, mutual.Position) && Vector3.Distance(node.Position, connected.Position) < Vector3.Distance(node.Position, mutual.Position))))
				{
					list.Remove(item);
				}
				if (!debug)
				{
					continue;
				}
				LineRenderer val5 = node.Testing.AddComponent<LineRenderer>();
				((Renderer)val5).sortingOrder = 1;
				((Renderer)node.Testing.GetComponent<MeshRenderer>()).material = new Material(Shader.Find("Sprites/Default"))
				{
					color = Colors[Math.Min(list.Count, 5)]
				};
				((Renderer)val5).material = new Material(Shader.Find("Sprites/Default"))
				{
					color = Colors[Math.Min(list.Count, 5)]
				};
				Vector3[] array3 = (Vector3[])(object)new Vector3[list.Count * 2];
				int num = 0;
				foreach (MapNode item2 in list)
				{
					array3[num] = node.Position;
					array3[num + 1] = item2.Position;
					num += 2;
				}
				val5.positionCount = num;
				val5.SetPositions(array3.ToArray());
			}
			Nodes = found;
		}
	}
	[HarmonyPatch(typeof(RoundManager))]
	internal class SmartMapper
	{
		[HarmonyPatch("GenerateNewFloor")]
		[HarmonyPostfix]
		private static void Update(ref RoundManager __instance)
		{
			MapManager.CreateMap();
		}
	}
	[HarmonyPatch(typeof(EnemyAI))]
	internal class DisableLineOfSightEnemyAI
	{
		[HarmonyPatch("CheckLineOfSightForPlayer")]
		[HarmonyPostfix]
		private static void DisableLOSGeneralPlayer(ref PlayerControllerB __result)
		{
			if (!((Object)(object)__result != (Object)null))
			{
				return;
			}
			bool flag = false;
			BasePred[] array = Object.FindObjectsOfType<BasePred>();
			foreach (BasePred basePred in array)
			{
				ulong id = __result.playerClientId;
				Food food2 = basePred.Bellied.Find((Food food) => food.Player.playerClientId == id);
				if (food2 != null)
				{
					flag = true;
					break;
				}
			}
			if (flag)
			{
				__result = null;
			}
		}

		[HarmonyPatch("CheckLineOfSightForClosestPlayer")]
		[HarmonyPostfix]
		private static void DisableLOSClosestPlayer(ref PlayerControllerB __result)
		{
			if (!((Object)(object)__result != (Object)null))
			{
				return;
			}
			bool flag = false;
			BasePred[] array = Object.FindObjectsOfType<BasePred>();
			foreach (BasePred basePred in array)
			{
				ulong id = __result.playerClientId;
				Food food2 = basePred.Bellied.Find((Food food) => food.Player.playerClientId == id);
				if (food2 != null)
				{
					flag = true;
					break;
				}
			}
			if (flag)
			{
				__result = null;
			}
		}

		[HarmonyPatch("CheckLineOfSightForPosition")]
		[HarmonyPostfix]
		private static void DisableLOSForPosition(ref bool __result, ref Vector3 objectPosition)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			BasePred[] array = Object.FindObjectsOfType<BasePred>();
			foreach (BasePred basePred in array)
			{
				foreach (Food item in basePred.Bellied)
				{
					if (((Component)item.Player.gameplayCamera).transform.position == objectPosition)
					{
						__result = false;
					}
				}
			}
		}
	}
	[HarmonyPatch(typeof(NutcrackerEnemyAI))]
	internal class DisableNutcrackerLineOfSight
	{
		[HarmonyPatch("CheckLineOfSightForLocalPlayer")]
		[HarmonyPostfix]
		private static void DisableLOS(ref bool __result)
		{
			if (__result && (from ai in Object.FindObjectsOfType<BasePred>()
				let id = GameNetworkManager.Instance.localPlayerController.playerClientId
				select ai.Bellied.Find((Food food) => food.Player.playerClientId == id)).Any((Food food) => food != null))
			{
				__result = false;
			}
		}
	}
	[HarmonyPatch(typeof(Turret))]
	internal class DisableTurretLineOfSight
	{
		[HarmonyPatch("CheckForPlayersInLineOfSight")]
		[HarmonyPostfix]
		private static void DisableLOS(ref PlayerControllerB __result)
		{
			if (!((Object)(object)__result != (Object)null))
			{
				return;
			}
			bool flag = false;
			BasePred[] array = Object.FindObjectsOfType<BasePred>();
			foreach (BasePred basePred in array)
			{
				ulong id = __result.playerClientId;
				Food food2 = basePred.Bellied.Find((Food food) => food.Player.playerClientId == id);
				if (food2 != null)
				{
					flag = true;
					break;
				}
			}
			if (flag)
			{
				__result = null;
			}
		}
	}
	[HarmonyPatch(typeof(CentipedeAI))]
	internal class UnclingIfPlayerEaten
	{
		[HarmonyPatch("DamagePlayerOnIntervals")]
		[HarmonyPrefix]
		private static void UnclingFromPlayer(ref CentipedeAI __instance)
		{
			BasePred[] array = Object.FindObjectsOfType<BasePred>();
			foreach (BasePred basePred in array)
			{
				ulong id = __instance.clingingToPlayer.playerClientId;
				Food food2 = basePred.Bellied.Find((Food food) => food.Player.playerClientId == id);
				if (food2 != null)
				{
					((EnemyAI)__instance).SetEnemyStunned(true, 1f, (PlayerControllerB)null);
					break;
				}
			}
		}
	}
	[HarmonyPatch(typeof(RoundManager))]
	public class SpawnUtil
	{
		private static readonly FieldInfo FirstSpawn = typeof(RoundManager).GetField("firstTimeSpawningEnemies", BindingFlags.Instance | BindingFlags.NonPublic);

		[HarmonyPatch("AssignRandomEnemyToVent")]
		[HarmonyPrefix]
		private static bool AssignRandomEnemyToVent(ref RoundManager __instance, ref bool __result, EnemyVent vent, float spawnTime)
		{
			Debug.Log((object)"Attempting to spawn a creature.");
			if (__instance.EnemySpawnRandom.NextDouble() * 100.0 > (double)Plugin.SpawnChance.Value)
			{
				return true;
			}
			if (FirstSpawn.GetValue(__instance).Equals(true))
			{
				Debug.Log((object)"Resetting enemy spawns");
				foreach (SpawnableEnemyWithRarity enemy in __instance.currentLevel.Enemies)
				{
					enemy.enemyType.numberSpawned = 0;
				}
				FirstSpawn.SetValue(__instance, false);
			}
			string planetName = __instance.currentLevel.PlanetName;
			List<int> list = new List<int>();
			int num = 0;
			int num2 = Plugin.PredOffset[__instance.currentLevel.PlanetName];
			foreach (var predator in Plugin.Predators)
			{
				EnemyType item = predator.Item2;
				Dictionary<string, int> item2 = predator.Item6;
				int numberSpawned = __instance.currentLevel.Enemies[num2++].enemyType.numberSpawned;
				num += numberSpawned;
				if (numberSpawned > 0)
				{
					list.Add(0);
				}
				else
				{
					list.Add(item2.TryGetValue(planetName, out var value) ? value : item2["8 Titan"]);
				}
			}
			Debug.Log((object)("Pred count is: " + num));
			if (num >= Plugin.PredCount.Value || (list.Sum() == 0 && !Plugin.DuplicatePred.Value))
			{
				if (Plugin.DisableVanilla.Value)
				{
					Debug.Log((object)"Predator count exceeded!");
				}
				else
				{
					Debug.Log((object)"Predator count exceeded, spawning a vanilla enemy!");
				}
				return !Plugin.DisableVanilla.Value;
			}
			Debug.Log((object)("Spawning a predator with the weights " + GeneralExtensions.Join<string>(list.Select((int weight) => weight.ToString() ?? ""), (Func<string, string>)null, ", ")));
			int num3 = __instance.GetRandomWeightedIndex(list.ToArray(), __instance.EnemySpawnRandom) + Plugin.PredOffset[__instance.currentLevel.PlanetName];
			if (!Plugin.PredsIgnorePower.Value)
			{
				RoundManager obj = __instance;
				obj.currentEnemyPower += __instance.currentLevel.Enemies[num3].enemyType.PowerLevel;
			}
			vent.enemyType = __instance.currentLevel.Enemies[num3].enemyType;
			vent.enemyTypeIndex = num3;
			vent.occupied = true;
			vent.spawnTime = spawnTime;
			vent.SyncVentSpawnTimeClientRpc((int)spawnTime, num3);
			Debug.Log((object)("Chose predator " + vent.enemyType.enemyName + " in " + spawnTime));
			EnemyType enemyType = __instance.currentLevel.Enemies[num3].enemyType;
			enemyType.numberSpawned++;
			__result = true;
			return false;
		}
	}
}
namespace HuntedCompany.predator
{
	public class ArchieAI : PredAI<ArchieStates>, INoiseListener
	{
		public override void Start()
		{
			PredData = new PredData();
			forcedCameraTransform = ((Component)this).gameObject.transform.Find("Archie/Armature/Camera");
			int connectedPlayersAmount = StartOfRound.Instance.connectedPlayersAmount;
			if (1 == 0)
			{
			}
			TotalTries totalTries = connectedPlayersAmount switch
			{
				1 => new TotalTries(4, 6), 
				2 => new TotalTries(3, 5), 
				_ => new TotalTries(2, 4), 
			};
			if (1 == 0)
			{
			}
			TotalTries totalTries2 = totalTries;
			AIBehavior<ArchieStates> aIBehavior = AI.CreateLayer(ArchieStates.Wandering);
			aIBehavior.AddBehavior(new PlaySound<ArchieStates, bool>(AudioManager.Hungry), new RandomChance(100 * StartOfRound.Instance.livingPlayers));
			aIBehavior.AddBehavior(new SwitchStates<ArchieStates, bool>(ArchieStates.Chasing), new PlayerLookedAt());
			aIBehavior.AddBehavior(new MoveNearPlayer<ArchieStates>(), new TargetClosePlayer());
			aIBehavior.AddBehavior(new Patrol<ArchieStates, bool>());
			AIBehavior<ArchieStates> aIBehavior2 = AI.CreateLayer(ArchieStates.Staring);
			aIBehavior2.AddBehavior(new SwitchStates<ArchieStates, bool>(ArchieStates.Chasing), new JointConstraint(new LookedAt(), new Timer(2f)));
			aIBehavior2.AddBehavior(new SwitchStates<ArchieStates, bool>(ArchieStates.Running), new Timer(2f));
			aIBehavior2.AddBehavior(new MoveTowardsPlayer<ArchieStates>(), new HasTargetPlayer());
			AIBehavior<ArchieStates> aIBehavior3 = AI.CreateLayer(ArchieStates.Chasing);
			aIBehavior3.AddBehavior(new SwitchStates<ArchieStates, bool>(ArchieStates.Wandering), new JointConstraint(new PlayerLookedAt(invert: true), new Timer(2f)));
			aIBehavior3.AddBehavior(new MoveTowardsPlayer<ArchieStates>(), new HasTargetPlayer());
			aIBehavior3.AddBehavior(new SwitchStates<ArchieStates, bool>(ArchieStates.Wandering));
			AIBehavior<ArchieStates> aIBehavior4 = AI.CreateLayer(ArchieStates.Running);
			aIBehavior4.AddBehavior(new SwitchStates<ArchieStates, bool>(ArchieStates.Wandering), new Timer(20f));
			aIBehavior4.AddBehavior(new MoveTowardsPositionVec<ArchieStates>(), new FindFurthestNode());
			foreach (var predator in Plugin.Predators)
			{
				if (predator.Item1.ToLower().Equals("archie"))
				{
					((EnemyAI)this).enemyType = predator.Item2;
				}
			}
			base.Start();
		}

		public override void DoAIInterval()
		{
			if ((Object)(object)eating != (Object)null)
			{
				((EnemyAI)this).agent.speed = 0f;
				return;
			}
			AI.DoAIInterval((EnemyAI)(object)this);
			if (((EnemyAI)this).currentBehaviourStateIndex == 1)
			{
				((EnemyAI)this).agent.speed = 0f;
			}
			else if (!allEaten)
			{
				((EnemyAI)this).agent.speed = (1f - (float)Bellied.Count / (float)StartOfRound.Instance.livingPlayers + 0.1f) * 2f + 4f;
			}
			else
			{
				((EnemyAI)this).agent.speed = ((1f - (float)Bellied.Count / (float)StartOfRound.Instance.livingPlayers + 0.1f) * 2f + 4f) / 2f;
			}
			((EnemyAI)this).DoAIInterval();
		}

		protected override IEnumerator EatAnimation(Food food)
		{
			food.Savable = false;
			return HuntedCompany.util.Animations.PlayDefaultEatAnimation(this, food, 3);
		}

		public void DetectNoise(Vector3 noisePosition, float noiseLoudness, int timesPlayedInOneSpot, int noiseID)
		{
			Debug.Log((object)"Heard a noise");
		}

		protected override void __initializeVariables()
		{
			base.__initializeVariables();
		}

		protected override void __initializeRpcs()
		{
			base.__initializeRpcs();
		}

		protected internal override string __getTypeName()
		{
			return "ArchieAI";
		}
	}
	public enum ArchieStates
	{
		Wandering,
		Staring,
		Chasing,
		Running
	}
	public class DevAI : PredAI<DevStates>
	{
		public override void Start()
		{
			PredData.FlipCamera = true;
			forcedCameraTransform = ((Component)this).gameObject.transform.Find("DeVout/DeVoutRetop-Rig.GameRig/Camera");
			int connectedPlayersAmount = StartOfRound.Instance.connectedPlayersAmount;
			if (1 == 0)
			{
			}
			TotalTries totalTries = connectedPlayersAmount switch
			{
				1 => new TotalTries(4, 6), 
				2 => new TotalTries(3, 5), 
				_ => new TotalTries(2, 4), 
			};
			if (1 == 0)
			{
			}
			TotalTries totalTries2 = totalTries;
			AIBehavior<DevStates> aIBehavior = AI.CreateLayer(DevStates.Wandering);
			aIBehavior.AddBehavior(new PlaySound<DevStates, bool>(AudioManager.Hungry), new RandomChance(100 * StartOfRound.Instance.livingPlayers));
			aIBehavior.AddBehavior(new SwitchStates<DevStates, bool>(DevStates.Staring), new LookedAt());
			aIBehavior.AddBehavior(new MoveTowardsPlayer<DevStates>(), new HasTargetPlayer());
			aIBehavior.AddBehavior(new Patrol<DevStates, bool>());
			AIBehavior<DevStates> aIBehavior2 = AI.CreateLayer(DevStates.Staring);
			aIBehavior2.AddBehavior(new SwitchStates<DevStates, bool>(DevStates.Chasing), new JointConstraint(totalTries2, new Timer(2f)));
			aIBehavior2.AddBehavior(new SwitchStates<DevStates, bool>(DevStates.Running), new Timer(2f));
			aIBehavior2.AddBehavior(new MoveTowardsPlayer<DevStates>(), new HasTargetPlayer());
			AIBehavior<DevStates> aIBehavior3 = AI.CreateLayer(DevStates.Chasing);
			aIBehavior3.AddBehavior(new SwitchStates<DevStates, bool>(DevStates.Running), new Timer());
			if (StartOfRound.Instance.livingPlayers > 1)
			{
				aIBehavior3.AddBehavior(new SwitchStates<DevStates, bool>(DevStates.Staring), new LookedAt((int)Math.Ceiling((float)StartOfRound.Instance.livingPlayers * 2f / 3f)));
			}
			aIBehavior3.AddBehavior(new MoveTowardsPlayer<DevStates>(), new HasTargetPlayer());
			aIBehavior3.AddBehavior(new SwitchStates<DevStates, bool>(DevStates.Wandering));
			AIBehavior<DevStates> aIBehavior4 = AI.CreateLayer(DevStates.Running);
			aIBehavior4.AddBehavior(new SwitchStates<DevStates, bool>(DevStates.Chasing), new LookedAt());
			aIBehavior4.AddBehavior(new SwitchStates<DevStates, bool>(DevStates.Wandering), new Timer(10f));
			aIBehavior4.AddBehavior(new RunAway<DevStates, bool>());
			foreach (var predator in Plugin.Predators)
			{
				if (predator.Item1.ToLower().Equals("devout"))
				{
					((EnemyAI)this).enemyType = predator.Item2;
				}
			}
			base.Start();
		}

		public override void DoAIInterval()
		{
			if ((Object)(object)eating != (Object)null)
			{
				((EnemyAI)this).agent.speed = 0f;
				return;
			}
			AI.DoAIInterval((EnemyAI)(object)this);
			if (((EnemyAI)this).currentBehaviourStateIndex == 1)
			{
				((EnemyAI)this).agent.speed = 0f;
			}
			else if (!allEaten)
			{
				((EnemyAI)this).agent.speed = (1f - (float)Bellied.Count / (float)StartOfRound.Instance.livingPlayers + 0.1f) * 2f + 4f;
			}
			else
			{
				((EnemyAI)this).agent.speed = ((1f - (float)Bellied.Count / (float)StartOfRound.Instance.livingPlayers + 0.1f) * 2f + 4f) / 2f;
			}
			((EnemyAI)this).DoAIInterval();
		}

		protected override IEnumerator EatAnimation(Food food)
		{
			return HuntedCompany.util.Animations.PlayDefaultEatAnimation(this, food, 0);
		}

		protected override void __initializeVariables()
		{
			base.__initializeVariables();
		}

		protected override void __initializeRpcs()
		{
			base.__initializeRpcs();
		}

		protected internal override string __getTypeName()
		{
			return "DevAI";
		}
	}
	public enum DevStates
	{
		Wandering,
		Staring,
		Chasing,
		Running
	}
	internal static class Animations
	{
		public static readonly int Eat = Animator.StringToHash("Eat");

		public static readonly int Walking = Animator.StringToHash("Walking");

		public static readonly int Stalking = Animator.StringToHash("Stalking");
	}
	public abstract class PredAI<T> : BasePred
	{
		protected readonly AIUtility<T> AI = new AIUtility<T>();

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

		protected override void __initializeVariables()
		{
			base.__initializeVariables();
		}

		protected override void __initializeRpcs()
		{
			base.__initializeRpcs();
		}

		protected internal override string __getTypeName()
		{
			return "PredAI`1";
		}
	}
	public abstract class BasePred : EnemyAI
	{
		public bool allEaten;

		public PlayerControllerB eating;

		public bool thirdPerson;

		public GameObject scavenger;

		public Transform forcedCameraTransform;

		public readonly List<Food> Bellied = new List<Food>();

		protected PredData PredData = new PredData();

		private float _eatTime;

		private Coroutine _eatAnimationCoroutine;

		private Vector3 _lastPosition;

		private Quaternion _lastRotation;

		private float _lastTick;

		private float _lastBellySize;

		private readonly List<float> _targetWeights = new List<float>(3) { 0f, 0f, 0f };

		private readonly List<float> _struggleWeights = new List<float>(3) { 0f, 0f, 0f };

		public override void Start()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			_lastPosition = ((Component)this).transform.position;
			_lastRotation = ((Component)this).transform.rotation;
			base.creatureSFX = ((Component)this).GetComponent<AudioSource>();
			base.eye = ((Component)this).transform.Find("Scavenger/CrewMate-GameRig/DEF-spine.006");
			((EnemyAI)this).Start();
		}

		public override void Update()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			if (((Component)this).transform.position != _lastPosition)
			{
				if ((Object)(object)base.targetPlayer != (Object)null && base.creatureAnimator.GetLayerWeight(1) == 0f)
				{
					base.creatureAnimator.SetBool(Animations.Walking, false);
					base.creatureAnimator.SetBool(Animations.Stalking, true);
				}
				else
				{
					base.creatureAnimator.SetBool(Animations.Stalking, false);
					base.creatureAnimator.SetBool(Animations.Walking, true);
				}
				_lastPosition = ((Component)this).transform.position;
			}
			else
			{
				base.creatureAnimator.SetBool(Animations.Stalking, false);
				base.creatureAnimator.SetBool(Animations.Walking, false);
			}
			float num = 0f;
			if (Bellied.Any())
			{
				num = 0.25f + Bellied.Sum((Food food) => (float)food.Player.health / 300f);
			}
			if ((Object)(object)eating != (Object)null)
			{
				float num2 = 0f - Mathf.Pow((Time.time - _eatTime) / 4f - 1.9f, 2f) + 1f;
				num += Mathf.Min(0f, num2) * (float)eating.health / 300f;
			}
			_lastBellySize += (Mathf.Max(0f, Mathf.Min(1f, num)) - _lastBellySize) * Time.deltaTime;
			base.creatureAnimator.SetLayerWeight(1, _lastBellySize);
			base.creatureAnimator.SetLayerWeight(2, Mathf.Sin(Time.time) * 0.5f * _lastBellySize);
			base.creatureAnimator.SetLayerWeight(3, Mathf.Sin(Time.time / 2f) * 0.5f * _lastBellySize);
			base.creatureAnimator.SetLayerWeight(4, Mathf.Sin(Time.time / 3f) * 0.5f * _lastBellySize);
			base.creatureAnimator.SetLayerWeight(5, Mathf.Sin(Time.time / 5f) * 0.5f * _lastBellySize);
			List<(Food, int)> list = new List<(Food, int)>();
			foreach (Food item in Bellied)
			{
				item.Player.DisablePlayerModel(((Component)item.Player).gameObject, false, false);
				item.Player.inAnimationWithEnemy = (EnemyAI)(object)this;
				item.Player.inSpecialInteractAnimation = true;
				if (!((Object)(object)item.Player != (Object)(object)GameNetworkManager.Instance.localPlayerController))
				{
					if (((ButtonControl)Keyboard.current.aKey).wasPressedThisFrame)
					{
						list.Add((item, 0));
					}
					else if (((ButtonControl)Keyboard.current.wKey).wasPressedThisFrame || ((ButtonControl)Keyboard.current.sKey).wasPressedThisFrame)
					{
						list.Add((item, 1));
					}
					else if (((ButtonControl)Keyboard.current.dKey).wasPressedThisFrame)
					{
						list.Add((item, 2));
					}
				}
			}
			foreach (var (food2, id) in list)
			{
				StruggleSync(food2, id);
			}
			for (int i = 0; i < 3; i++)
			{
				_targetWeights[i] = Mathf.Min(1f, Mathf.Max(0f, _targetWeights[i] - Time.deltaTime));
				_struggleWeights[i] += (_targetWeights[i] - _struggleWeights[i]) * Time.deltaTime;
				for (int j = 6 + i * 4; j < 8 + i * 4; j++)
				{
					base.creatureAnimator.SetLayerWeight(j, Mathf.Min(1f, Mathf.Max(0f, (_struggleWeights[i] + Mathf.Sin(Time.time / (float)j) * 0.1f) * (num * 2f))));
				}
			}
			((EnemyAI)this).Update();
		}

		private void LateUpdate()
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			foreach (Food item in Bellied)
			{
				if (!item.Player.teleportedLastFrame)
				{
					((Component)item.Player).transform.position = ((Component)this).transform.position + ((Component)this).transform.forward * 1f;
				}
			}
			SpectateCameraRay();
		}

		public override void OnCollideWithPlayer(Collider other)
		{
			((EnemyAI)this).OnCollideWithPlayer(other);
			PlayerControllerB playerControllerB = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, false, false);
			if (!((Object)(object)playerControllerB == (Object)null) && (!Bellied.Any() || !PredData.SingleGut) && !((Object)(object)eating != (Object)null) && !Bellied.Any((Food item) => item.Player.playerClientId == playerControllerB.playerClientId))
			{
				Debug.Log((object)("Collided with " + playerControllerB.playerUsername));
				Bellied.Add(new Food(playerControllerB, PredData.DigestTicks, Plugin.Digestion.Value, Plugin.StruggleEffect.Value));
				Debug.Log((object)("Bellied add " + playerControllerB.playerUsername));
				StartEat(playerControllerB);
			}
		}

		public void FinishEat(Food food)
		{
			if (Plugin.StruggleTip.Value && (Object)(object)food.Player == (Object)(object)GameNetworkManager.Instance.localPlayerController)
			{
				HUDManager.Instance.DisplayTip("Struggling", Plugin.Digestion.Value ? "You can use the movement keys to struggle. This will cause you to digest faster!" : "You can use the movement keys to struggle.", false, false, "LC_Tip1");
				Plugin.StruggleTip.Value = false;
				Plugin.ConfigFile.Save();
			}
			if ((Object)(object)food.Player == (Object)(object)GameNetworkManager.Instance.localPlayerController)
			{
				Debug.Log((object)("Digest coroutine started on " + ((Object)food.Player).name));
				food.DigestCoroutine = ((MonoBehaviour)this).StartCoroutine(Digest(food));
			}
			base.creatureAnimator.SetBool(Animations.Eat, false);
			DisableKillPatch.CheckTakeoffServerRPC(null);
			eating = null;
			Object.Destroy((Object)(object)scavenger);
			scavenger = null;
			base.inSpecialAnimation = false;
			_eatAnimationCoroutine = null;
		}

		private void StartEat(PlayerControllerB food)
		{
			Debug.LogWarning((object)("Starting eat " + food.playerUsername));
			if (((NetworkBehaviour)food).IsHost || ((NetworkBehaviour)food).IsServer)
			{
				Debug.LogWarning((object)(food.playerUsername + " is Host"));
				StartEatClientRpc((int)food.playerClientId, Plugin.Digestion.Value, Plugin.StruggleEffect.Value);
			}
			else
			{
				StartEatServerRpc((int)food.playerClientId, Plugin.Digestion.Value, Plugin.StruggleEffect.Value);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void StartEatServerRpc(int id, bool digest, bool struggle)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: 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(2416770251u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, id);
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref digest, default(ForPrimitives));
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref struggle, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2416770251u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					Debug.LogWarning((object)("Server eat " + RoundManager.Instance.playersManager.allPlayerScripts[id].playerUsername + " with Digestion: " + digest));
					StartEatClientRpc(id, digest, struggle);
				}
			}
		}

		private void SpectateCameraRay()
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: 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_018b: 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_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: 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_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			if (Bellied.All((Food food) => (Object)(object)food.Player != (Object)(object)GameNetworkManager.Instance.localPlayerController))
			{
				return;
			}
			Transform transform = ((Component)this).transform;
			if ((Object)(object)scavenger != (Object)null)
			{
				scavenger.transform.position = transform.position;
				scavenger.transform.rotation = transform.rotation;
			}
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			Transform transform2 = ((Component)localPlayerController.gameplayCamera).transform;
			if ((Object)(object)eating == (Object)(object)localPlayerController && !thirdPerson)
			{
				Transform val = forcedCameraTransform;
				((Component)localPlayerController.gameplayCamera).transform.position = val.position;
				Quaternion rotation = transform2.rotation;
				Quaternion rotation2 = val.rotation;
				Vector3 eulerAngles = ((Quaternion)(ref rotation2)).eulerAngles;
				if (PredData.FlipCamera)
				{
					eulerAngles.x += 180f;
					eulerAngles.z += 180f;
				}
				((Quaternion)(ref rotation)).eulerAngles = eulerAngles;
				((Component)transform2).transform.rotation = rotation;
			}
			else
			{
				Vector3 val2 = ((Component)this).transform.position + Vector3.up * 2f + -((Component)localPlayerController.gameplayCamera).transform.forward * 0.5f;
				Ray val3 = default(Ray);
				((Ray)(ref val3))..ctor(val2, -transform2.forward);
				RaycastHit val4 = default(RaycastHit);
				Vector3 position = ((!Physics.Raycast(val3, ref val4, 4.5f, 268437761, (QueryTriggerInteraction)2)) ? ((Ray)(ref val3)).GetPoint(4.5f) : (((Ray)(ref val3)).GetPoint(((RaycastHit)(ref val4)).distance - 0.25f) + ((Component)localPlayerController.gameplayCamera).transform.forward * 0.1f));
				Quaternion val5 = ((Component)this).transform.rotation * Quaternion.Inverse(_lastRotation);
				_lastRotation = ((Component)this).transform.rotation;
				((Component)localPlayerController.gameplayCamera).transform.position = position;
				((Component)localPlayerController.gameplayCamera).transform.LookAt(val2);
			}
		}

		[ClientRpc]
		private void StartEatClientRpc(int id, bool digest, bool struggle)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: 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.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(708662875u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, id);
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref digest, default(ForPrimitives));
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref struggle, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 708662875u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					PlayerControllerB val3 = RoundManager.Instance.playersManager.allPlayerScripts[id];
					Debug.LogWarning((object)("Client eat " + val3.playerUsername + " with Digestion: " + digest));
					StartEatLocal(val3, digest, struggle);
				}
			}
		}

		private void StartEatLocal(PlayerControllerB food, bool digest, bool struggle)
		{
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			_eatTime = Time.time;
			((Behaviour)food.usernameCanvas).enabled = false;
			((Renderer)food.playerBetaBadgeMesh).enabled = false;
			food.inAnimationWithEnemy = (EnemyAI)(object)this;
			((Renderer)food.thisPlayerModelArms).enabled = false;
			food.inSpecialInteractAnimation = true;
			food.disableLookInput = true;
			((Component)food).GetComponent<Collider>().enabled = false;
			if ((Object)(object)food == (Object)(object)GameNetworkManager.Instance.localPlayerController)
			{
				((Component)food.localVisor).gameObject.SetActive(false);
			}
			food.DropAllHeldItemsAndSyncNonexact();
			BasePred[] array = Object.FindObjectsOfType<BasePred>();
			foreach (BasePred basePred in array)
			{
				if ((Object)(object)((EnemyAI)basePred).targetPlayer != (Object)null && (Object)(object)((EnemyAI)basePred).targetPlayer == (Object)(object)food)
				{
					((EnemyAI)basePred).targetPlayer = null;
					((EnemyAI)basePred).movingTowardsTargetPlayer = false;
				}
			}
			base.inSpecialAnimation = true;
			Debug.Log((object)"Spawned scavenger");
			scavenger = Object.Instantiate<GameObject>(Plugin.ScavPrefab);
			scavenger.transform.position = forcedCameraTransform.parent.position;
			scavenger.transform.rotation = ((Component)this).gameObject.transform.rotation;
			((Component)scavenger.transform.Find("Scavenger")).GetComponent<Animator>().SetBool(Animations.Eat, true);
			SkinnedMeshRenderer component = ((Component)scavenger.transform.Find("Scavenger/CrewMateBody")).GetComponent<SkinnedMeshRenderer>();
			((Renderer)component).material = ((Renderer)food.thisPlayerModel).material;
			if ((Object)(object)food.currentVoiceChatAudioSource != (Object)null)
			{
				((Component)food.currentVoiceChatAudioSource).transform.parent = ((Component)this).transform;
				((Component)food.currentVoiceChatAudioSource).GetComponent<AudioLowPassFilter>().lowpassResonanceQ = 5f;
				OccludeAudio component2 = ((Component)food.currentVoiceChatAudioSource).GetComponent<OccludeAudio>();
				component2.overridingLowPass = true;
				component2.lowPassOverride = 500f;
				food.voiceMuffledByEnemy = true;
			}
			base.creatureAnimator.SetBool(Animations.Eat, true);
			eating = food;
			Food food2 = Bellied.Find((Food foodObj) => (Object)(object)foodObj.Player == (Object)(object)food);
			if (food2 == null)
			{
				food2 = new Food(food, PredData.DigestTicks, digest, struggle);
				Debug.Log((object)("Bellied add LATE " + food2.Player.playerUsername));
				Bellied.Add(food2);
			}
			Renderer[] componentsInChildren = ((Component)food).GetComponentsInChildren<Renderer>();
			foreach (Renderer val in componentsInChildren)
			{
				if (val.enabled)
				{
					food2.Renderers.Add(val);
					val.enabled = false;
				}
			}
			_eatAnimationCoroutine = ((MonoBehaviour)this).StartCoroutine(EatAnimation(food2));
		}

		private IEnumerator Digest(Food food)
		{
			yield return (object)new WaitForSeconds(PredData.UnsavableTime);
			UnsavableSync(food);
			float digestTime = Random.Range(PredData.MinDigestTime, PredData.MaxDigestTime);
			float time = digestTime / (float)PredData.DigestTicks;
			while (Bellied.Contains(food))
			{
				Debug.Log((object)"Struggle from Digest Coroutine");
				Struggle(food, -1);
				yield return (object)new WaitForSeconds(time);
			}
		}

		private void UnsavableSync(Food food)
		{
			if (((NetworkBehaviour)food.Player).IsHost || ((NetworkBehaviour)food.Player).IsServer)
			{
				UnsavableClientRpc((int)food.Player.playerClientId);
			}
			else
			{
				UnsavableServerRpc((int)food.Player.playerClientId);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void UnsavableServerRpc(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)
			//IL_00ce: 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(1327337140u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerId);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1327337140u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					UnsavableClientRpc(playerId);
				}
			}
		}

		[ClientRpc]
		private void UnsavableClientRpc(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)
			//IL_00ce: 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.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1894191636u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, playerId);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1894191636u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				int playerId2 = playerId;
				Food food = Bellied.Find((Food player) => (int)player.Player.playerClientId == playerId2);
				if (food != null)
				{
					food.Savable = false;
				}
				else
				{
					Debug.Log((object)("Failed to set Food " + playerId2 + " to unsavable."));
				}
			}
		}

		private void StruggleSync(Food food, int id)
		{
			if (((NetworkBehaviour)food.Player).IsHost || ((NetworkBehaviour)food.Player).IsServer)
			{
				StruggleClientRpc((int)food.Player.playerClientId, id);
			}
			else
			{
				StruggleServerRpc((int)food.Player.playerClientId, id);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void StruggleServerRpc(int playerId, int id)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: 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(4124803454u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerId);
					BytePacker.WriteValueBitPacked(val2, id);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 4124803454u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					StruggleClientRpc(playerId, id);
				}
			}
		}

		[ClientRpc]
		private void StruggleClientRpc(int playerId, int id)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: 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.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2495335419u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, playerId);
				BytePacker.WriteValueBitPacked(val2, id);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2495335419u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			int playerId2 = playerId;
			Food food = Bellied.Find((Food player) => (int)player.Player.playerClientId == playerId2);
			if (food != null)
			{
				Struggle(food, id);
				return;
			}
			Debug.LogWarning((object)("Failed to find food " + playerId2 + " in belly " + GeneralExtensions.Join<string>(Bellied.Select((Food inner) => inner.Player.playerUsername), (Func<string, string>)null, ", ")));
			Debug.LogWarning((object)"Searching for belly occupants in ClientRPC");
			foreach (Food item in Bellied)
			{
				Debug.Log((object)("In belly:" + ((Object)item.Player).name + " (" + item.Player.playerClientId + ")"));
			}
		}

		public void Struggle(Food food, int struggle)
		{
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			if (!Bellied.Contains(food))
			{
				return;
			}
			if (struggle >= 0)
			{
				_targetWeights[struggle] = Mathf.Min(_targetWeights[struggle] + 0.25f, 1f);
				if (_targetWeights[struggle] < 0.5f)
				{
					return;
				}
				if (PredData.DoesDamage && food.DigestionValue && food.StruggleValue)
				{
					if (food.Player.health <= 20 && Time.time > _lastTick)
					{
						Debug.LogWarning((object)("Killing " + food.Player.playerUsername));
						UnbellyAndCleanup(food, (int)food.Player.actualClientId);
					}
					else if (Time.time > _lastTick)
					{
						Debug.Log((object)("Struggle damaging " + food.Player.playerUsername + " to " + (food.Player.health - 10)));
						food.Player.DamagePlayer(10, false, true, (CauseOfDeath)0, 0, false, default(Vector3));
						_lastTick = Time.time + 1f;
					}
				}
			}
			else if (PredData.DoesDamage && food.DigestionValue)
			{
				if (food.Player.health <= 20 + food.Damage || food.TicksLeft == 1)
				{
					Debug.LogWarning((object)("Killing " + food.Player.playerUsername));
					UnbellyAndCleanupSync(food, (int)food.Player.actualClientId);
				}
				else
				{
					Debug.Log((object)("Struggle damaging " + food.Player.playerUsername + " to " + (food.Player.health - food.Damage)));
					food.Player.DamagePlayer(food.Damage, false, true, (CauseOfDeath)0, 0, false, default(Vector3));
					food.TicksLeft--;
				}
			}
			if (!((Component)this).GetComponent<AudioSource>().isPlaying)
			{
				((Component)this).GetComponent<AudioSource>().PlayOneShot(AudioManager.Gurgles[Random.Range(0, AudioManager.Gurgles.Count)]);
			}
		}

		public void UnbellyAndCleanupSync(Food food, int id)
		{
			if (((NetworkBehaviour)food.Player).IsHost || ((NetworkBehaviour)food.Player).IsServer)
			{
				UnbellyAndCleanupClientRpc((int)food.Player.playerClientId, id);
			}
			else
			{
				UnbellyAndCleanupServerRpc((int)food.Player.playerClientId, id);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void UnbellyAndCleanupServerRpc(int playerId, int id)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: 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(3519570287u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerId);
					BytePacker.WriteValueBitPacked(val2, id);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3519570287u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					UnbellyAndCleanupClientRpc(playerId, id);
				}
			}
		}

		[ClientRpc]
		private void UnbellyAndCleanupClientRpc(int playerId, int id)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: 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.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1762748099u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, playerId);
				BytePacker.WriteValueBitPacked(val2, id);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1762748099u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				int playerId2 = playerId;
				Food food = Bellied.Find((Food player) => (int)player.Player.playerClientId == playerId2);
				UnbellyAndCleanup(food, id);
			}
		}

		public void UnbellyAndCleanup(Food food, int id)
		{
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: 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_0063: 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)
			Debug.LogWarning((object)("Unbellying and cleaning up, killing " + food.Player.playerUsername));
			UnbellyLocal(food.Player);
			if ((Object)(object)food.Player == (Object)(object)GameNetworkManager.Instance.localPlayerController)
			{
				if (StartOfRound.Instance.shipIsLeaving)
				{
					food.Player.KillPlayer(Vector3.zero, false, (CauseOfDeath)10, 0, default(Vector3), false);
				}
				else
				{
					food.Player.KillPlayer(Vector3.zero, false, (CauseOfDeath)0, 0, default(Vector3), false);
				}
			}
		}

		public void UnbellySync(PlayerControllerB instance)
		{
			if (((NetworkBehaviour)instance).IsHost || ((NetworkBehaviour)instance).IsServer)
			{
				UnbellyClientRpc((int)instance.playerClientId);
			}
			else
			{
				UnbellyServerRpc((int)instance.playerClientId);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void UnbellyServerRpc(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)
			//IL_00ce: 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(2764341592u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerId);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2764341592u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					UnbellyClientRpc(playerId);
				}
			}
		}

		[ClientRpc]
		public void UnbellyClientRpc(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)
			//IL_00ce: 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.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(367100545u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, playerId);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 367100545u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				PlayerControllerB val3 = StartOfRound.Instance.allPlayerScripts[playerId];
				if ((Object)(object)val3 == (Object)null)
				{
					Debug.LogWarning((object)"UnbellyClientRpc: instance was null");
				}
				else
				{
					UnbellyLocal(val3);
				}
			}
		}

		public void UnbellyLocal(PlayerControllerB instance)
		{
			//IL_0337: Unknown result type (might be due to invalid IL or missing references)
			//IL_034e: Unknown result type (might be due to invalid IL or missing references)
			Debug.LogWarning((object)("Unbellying " + instance.playerUsername + " for " + GeneralExtensions.Join<string>(from enemy in Object.FindObjectsOfType<BasePred>()
				select ((Object)enemy).name, (Func<string, string>)null, ", ")));
			int num = Bellied.FindIndex((Food food) => (Object)(object)food.Player == (Object)(object)instance);
			if (num == -1)
			{
				Debug.LogWarning((object)("Failed to unbelly " + instance.playerUsername + ", not in a belly"));
				return;
			}
			foreach (Renderer item in Bellied[num].Renderers.Where((Renderer componentsInChild) => (Object)(object)componentsInChild != (Object)null))
			{
				item.enabled = true;
			}
			if (Bellied[num].DigestCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(Bellied[num].DigestCoroutine);
				Bellied[num].DigestCoroutine = null;
			}
			Debug.Log((object)("Removing player from bellied: " + GeneralExtensions.Join<string>(Bellied.Select((Food player) => player.Player.playerUsername), (Func<string, string>)null, ", ")));
			Bellied.RemoveAt(num);
			Debug.Log((object)("After bellied: " + GeneralExtensions.Join<string>(Bellied.Select((Food player) => player.Player.playerUsername), (Func<string, string>)null, ", ")));
			if ((Object)(object)eating == (Object)(object)instance)
			{
				eating = null;
				if (_eatAnimationCoroutine != null)
				{
					((MonoBehaviour)this).StopCoroutine(_eatAnimationCoroutine);
					_eatAnimationCoroutine = null;
				}
				Object.DestroyImmediate((Object)(object)scavenger);
				scavenger = null;
				base.creatureAnimator.SetBool(Animations.Eat, false);
			}
			((Component)instance).GetComponent<Collider>().enabled = true;
			if ((Object)(object)((Component)instance).gameObject.transform.parent != (Object)null && (Object)(object)((Component)((Component)instance).gameObject.transform.parent).gameObject.GetComponent<BasePred>() != (Object)null)
			{
				((Component)instance).gameObject.transform.parent = null;
			}
			((Behaviour)instance.usernameCanvas).enabled = true;
			((Renderer)instance.playerBetaBadgeMesh).enabled = true;
			instance.inSpecialInteractAnimation = false;
			instance.inAnimationWithEnemy = null;
			instance.disableLookInput = false;
			Transform transform = ((Component)instance.gameplayCamera).transform;
			transform.rotation = instance.cameraContainerTransform.rotation;
			transform.position = instance.cameraContainerTransform.position;
			if ((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)(object)instance)
			{
				((Renderer)instance.thisPlayerModelArms).enabled = true;
				((Component)instance.localVisor).gameObject.SetActive(true);
			}
			else
			{
				instance.DisablePlayerModel(((Component)instance).gameObject, true, true);
			}
			if (!((Object)(object)instance.currentVoiceChatAudioSource == (Object)null))
			{
				if ((Object)(object)((Component)instance.currentVoiceChatAudioSource).transform != (Object)null)
				{
					((Component)instance.currentVoiceChatAudioSource).transform.parent = null;
				}
				if ((Object)(object)((Component)instance.currentVoiceChatAudioSource).GetComponent<AudioLowPassFilter>() != (Object)null)
				{
					((Component)instance.currentVoiceChatAudioSource).GetComponent<AudioLowPassFilter>().lowpassResonanceQ = 1f;
				}
				OccludeAudio component = ((Component)instance.currentVoiceChatAudioSource).GetComponent<OccludeAudio>();
				if ((Object)(object)component != (Object)null)
				{
					component.overridingLowPass = false;
					component.lowPassOverride = 20000f;
				}
				instance.voiceMuffledByEnemy = false;
			}
		}

		protected abstract IEnumerator EatAnimation(Food food);

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

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Expected O, but got Unknown
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Expected O, but got Unknown
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Expected O, but got Unknown
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Expected O, but got Unknown
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(2416770251u, new RpcReceiveHandler(__rpc_handler_2416770251), "StartEatServerRpc");
			((NetworkBehaviour)this).__registerRpc(708662875u, new RpcReceiveHandler(__rpc_handler_708662875), "StartEatClientRpc");
			((NetworkBehaviour)this).__registerRpc(1327337140u, new RpcReceiveHandler(__rpc_handler_1327337140), "UnsavableServerRpc");
			((NetworkBehaviour)this).__registerRpc(1894191636u, new RpcReceiveHandler(__rpc_handler_1894191636), "UnsavableClientRpc");
			((NetworkBehaviour)this).__registerRpc(4124803454u, new RpcReceiveHandler(__rpc_handler_4124803454), "StruggleServerRpc");
			((NetworkBehaviour)this).__registerRpc(2495335419u, new RpcReceiveHandler(__rpc_handler_2495335419), "StruggleClientRpc");
			((NetworkBehaviour)this).__registerRpc(3519570287u, new RpcReceiveHandler(__rpc_handler_3519570287), "UnbellyAndCleanupServerRpc");
			((NetworkBehaviour)this).__registerRpc(1762748099u, new RpcReceiveHandler(__rpc_handler_1762748099), "UnbellyAndCleanupClientRpc");
			((NetworkBehaviour)this).__registerRpc(2764341592u, new RpcReceiveHandler(__rpc_handler_2764341592), "UnbellyServerRpc");
			((NetworkBehaviour)this).__registerRpc(367100545u, new RpcReceiveHandler(__rpc_handler_367100545), "UnbellyClientRpc");
			((EnemyAI)this).__initializeRpcs();
		}

		private static void __rpc_handler_2416770251(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: 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_0057: 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_006c: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int id = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref id);
				bool digest = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref digest, default(ForPrimitives));
				bool struggle = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref struggle, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((BasePred)(object)target).StartEatServerRpc(id, digest, struggle);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_708662875(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: 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_0057: 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_006c: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int id = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref id);
				bool digest = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref digest, default(ForPrimitives));
				bool struggle = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref struggle, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((BasePred)(object)target).StartEatClientRpc(id, digest, struggle);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1327337140(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 playerId = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerId);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((BasePred)(object)target).UnsavableServerRpc(playerId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1894191636(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 playerId = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerId);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((BasePred)(object)target).UnsavableClientRpc(playerId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

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

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

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

		private static void __rpc_handler_1762748099(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: 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 referen