Decompiled source of LethalIntelligenceExperimental v0.3.1

BepInEx\plugins\VirusTLNR-LethalIntelligence\LethalIntelligence.dll

Decompiled 5 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Imperium.API;
using LethalIntelligence.Patches;
using LethalNetworkAPI;
using LobbyCompatibility.Enums;
using LobbyCompatibility.Features;
using Microsoft.CodeAnalysis;
using Mirage.Unity;
using SkinwalkerMod;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using Wendigos;

[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("VirusTLNR")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.3.1.0")]
[assembly: AssemblyInformationalVersion("0.3.1")]
[assembly: AssemblyProduct("LethalIntelligence")]
[assembly: AssemblyTitle("LethalIntelligence")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.3.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace LethalIntelligence
{
	[BepInPlugin("VirusTLNR.LethalIntelligence", "LethalIntelligence", "0.3.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public static bool DebugMode = false;

		public static string LastDebugModeMsg;

		public static string logPluginName = "Lethal Intelligence";

		public static AssetBundle Bundle;

		public static bool enableMaskedFeatures;

		public static bool enableSkinWalkers;

		public static bool enableWendigos;

		public static bool enableMirage;

		public static bool enableMaskedAggressive;

		public static bool enableMaskedStealthy;

		public static bool enableMaskedCunning;

		public static bool enableMaskedDeceiving;

		public static bool enableMaskedInsane;

		public static bool useTerminal;

		public static bool useTerminalCredit;

		public static bool maskedShipDeparture;

		public static GameObject MapDotPrefab;

		public static RuntimeAnimatorController MaskedAnimController;

		public static RuntimeAnimatorController MapDotRework;

		public static string PluginDirectory;

		public static bool skinWalkersIntegrated;

		public static bool wendigosIntegrated;

		public static bool mirageIntegrated;

		public static bool alwaysHearActiveWalkiesIntegrated;

		public static bool debugModeSetting;

		public static int debugStatusDelay;

		internal static bool isTerminalBeingUsed = false;

		internal static bool isBreakerBoxBeingUsed = false;

		internal static bool imperiumFound;

		public static Plugin Instance { get; private set; } = null;


		internal static ManualLogSource mls { get; private set; } = null;


		internal static Harmony? harmony { get; set; }

		private void Awake()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			if ((Object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = ((BaseUnityPlugin)this).Logger;
			if (LobbyCompatibilityChecker.Enabled)
			{
				mls.LogInfo((object)"BMX.LobbyCompatibility has been found, Initiating Soft Dependency!");
				LobbyCompatibilityChecker.Init();
			}
			imperiumFound = Chainloader.PluginInfos.ContainsKey("giosuel.Imperium");
			PluginDirectory = ((BaseUnityPlugin)this).Info.Location;
			LoadAssets();
			mls.LogInfo((object)"Plugin VirusTLNR.LethalIntelligence v0.3.1 has loaded!");
			enableMaskedFeatures = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Masked AI Features", true, "Turn on masked AI features. If this feature is disabled, it will only change Masked's radar movement. If all masked Personalities are disabled, this will be disabled by default. *This option must be enabled to change Masked's AI.*").Value;
			enableSkinWalkers = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "SkinWalkers mod Compatibility", true, "Enables compatibility with the SkinWalkers mod. (Requires SkinWalkers mod installed, automatically disables on launch if not installed)").Value;
			enableWendigos = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Wendigos mod Compatibility", true, "Enables compatibility with the Wendigos_Voice_Cloning mod. (Requires Wendigos_Voice_Cloning mod installed, automatically disables on launch if not installed)").Value;
			enableMirage = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Mirage mod Compatibility", true, "Enables compatibility with the Mirage mod. (Requires Mirage mod installed, automatically disables on launch if not installed)").Value;
			enableMaskedAggressive = ((BaseUnityPlugin)this).Config.Bind<bool>("MaskedPersonalities", "MaskedAggressive", true, "Enables the 'Aggressive' personality for the Masked (at least 1 of these must be TRUE)").Value;
			enableMaskedStealthy = ((BaseUnityPlugin)this).Config.Bind<bool>("MaskedPersonalities", "MaskedStealthy", true, "Enables the 'Stealthy' personality for the Masked (at least 1 of these must be TRUE)").Value;
			enableMaskedCunning = ((BaseUnityPlugin)this).Config.Bind<bool>("MaskedPersonalities", "MaskedCunning", true, "Enables the Cunning personality for the Masked (at least 1 of these must be TRUE)").Value;
			enableMaskedDeceiving = ((BaseUnityPlugin)this).Config.Bind<bool>("MaskedPersonalities", "MaskedDeceiving", true, "Enables the 'Deceiving' personality for the Masked (at least 1 of these must be TRUE)").Value;
			enableMaskedInsane = ((BaseUnityPlugin)this).Config.Bind<bool>("MaskedPersonalities", "MaskedInsane", true, "Enables the 'Insane' personality for the Masked (at least 1 of these must be TRUE)").Value;
			if (!enableMaskedAggressive && !enableMaskedStealthy && !enableMaskedCunning && !enableMaskedDeceiving && !enableMaskedInsane)
			{
				enableMaskedFeatures = false;
				mls.LogWarning((object)"Bad Config!, all Masked personalities are disabled, disabling entire MaskedAI Module.");
			}
			useTerminal = ((BaseUnityPlugin)this).Config.Bind<bool>("MaskedAI", "Masked terminal access", true, "Allows Masked to use the terminal.").Value;
			useTerminalCredit = ((BaseUnityPlugin)this).Config.Bind<bool>("MaskedAI", "Masked uses credits", false, "(Not working rn) Allows Masked to use the terminal to spend credits.").Value;
			maskedShipDeparture = ((BaseUnityPlugin)this).Config.Bind<bool>("MaskedAI", "Masked pulls the brake lever", true, "Allows Masked to pull the brake lever.").Value;
			debugModeSetting = ((BaseUnityPlugin)this).Config.Bind<bool>("DebugMode", "Debug Mode", true, "Enables more spammy logs for debugging, will be enabled automatically if imperium is installed. (all other DebugMode settings are ignored if Debug Mode is disabled)").Value;
			debugStatusDelay = ((BaseUnityPlugin)this).Config.Bind<int>("DebugMode", "Status Report Delay", 0, "How often should status reports (only updates when information changes) be logged (higher number = less log spam but also less accurate as not all information is gathered").Value;
			if (imperiumFound || debugModeSetting)
			{
				if (imperiumFound)
				{
					mls.LogWarning((object)"Imperium has been found, All Hail The Emperor!, Auto Initiating Debug Mode (More Logs!)");
				}
				else
				{
					mls.LogWarning((object)"Debug Mode enabled in config (More Logs!)");
				}
				DebugMode = true;
			}
			RemoveOrphanedConfigs();
			Patch();
			Start();
		}

		internal void RemoveOrphanedConfigs()
		{
			PropertyInfo property = ((object)((BaseUnityPlugin)this).Config).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic);
			Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)property.GetValue(((BaseUnityPlugin)this).Config, null);
			if (dictionary.Count != 0)
			{
				mls.LogInfo((object)"Found Orphaned Config Entries - Removing them all as they are not needed anymore");
			}
			dictionary.Clear();
			((BaseUnityPlugin)this).Config.Save();
		}

		internal static void Patch()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			if (harmony == null)
			{
				harmony = new Harmony("LethalNetworkAPI");
			}
			mls.LogDebug((object)"Patching...");
			harmony.PatchAll(typeof(Plugin));
			harmony.PatchAll(typeof(MaskedPlayerEnemyPatch));
			harmony.PatchAll(typeof(ShotgunItemPatch));
			harmony.PatchAll(typeof(GrabbableObjectPatch));
			harmony.PatchAll(typeof(StartOfRoundPatch));
			mls.LogDebug((object)"Finished patching!");
		}

		private void Start()
		{
			if (enableMaskedFeatures)
			{
				mls.LogInfo((object)"MaskedPersonalities feature has been enabled! Masked AI's behavior is now modified.");
			}
			else
			{
				mls.LogInfo((object)"MaskedPersonalities feature has been disabled! Masked AI's behaviour will not be modified.");
			}
			if (Chainloader.PluginInfos.Keys.Any((string k) => k == "RugbugRedfern.SkinwalkerMod") && enableSkinWalkers && enableMaskedFeatures)
			{
				mls.LogInfo((object)(logPluginName + " <-> SkinWalkers Integrated!"));
				skinWalkersIntegrated = true;
			}
			if (Chainloader.PluginInfos.Keys.Any((string w) => w == "Tim_Shaw.Wendigos_Voice_Cloning") && enableWendigos && enableMaskedFeatures)
			{
				mls.LogInfo((object)(logPluginName + " <-> Wendigos_Voice_Cloning Integrated!"));
				wendigosIntegrated = true;
			}
			if (Chainloader.PluginInfos.Keys.Any((string m) => m == "qwbarch.Mirage") && enableMirage && enableMaskedFeatures)
			{
				mls.LogInfo((object)(logPluginName + " <-> Mirage Integrated!"));
				mirageIntegrated = true;
			}
			if (Chainloader.PluginInfos.Keys.Any((string s) => s == "suskitech.LCAlwaysHearActiveWalkie") && enableMaskedFeatures)
			{
				mls.LogInfo((object)(logPluginName + " <-> AlwaysHearActiveWalkies Support Enabled!"));
				alwaysHearActiveWalkiesIntegrated = true;
			}
			mls.LogInfo((object)"Plugin VirusTLNR.LethalIntelligence v0.3.1 finished checking for available dependencies!");
		}

		private void LoadAssets()
		{
			try
			{
				Bundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(PluginDirectory), "mapdotanimpack"));
			}
			catch (Exception ex)
			{
				mls.LogError((object)("Couldn't load asset bundle: " + ex.Message));
				return;
			}
			try
			{
				MapDotRework = Bundle.LoadAsset<RuntimeAnimatorController>("MapDotRework.controller");
				MapDotPrefab = Bundle.LoadAsset<GameObject>("MaskedMapDot.prefab");
				MaskedAnimController = Bundle.LoadAsset<RuntimeAnimatorController>("MaskedMetarig.controller");
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Successfully loaded assets!");
			}
			catch (Exception ex2)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Couldn't load assets: " + ex2.Message));
			}
		}
	}
	internal static class PluginInfo
	{
		public const string PLUGIN_GUID = "VirusTLNR.LethalIntelligence";

		public const string PLUGIN_NAME = "LethalIntelligence";

		public const string PLUGIN_VERSION = "0.3.1";
	}
}
namespace LethalIntelligence.Patches
{
	internal class ImperiumPatches
	{
		public static void maskedVisualization(MaskedAIRevamp.Personality p, MaskedAIRevamp.Activity a, MaskedAIRevamp.Focus f)
		{
			try
			{
				Visualization.InsightsFor<MaskedPlayerEnemy>().RegisterInsight("Personality", (Func<MaskedPlayerEnemy, string>)((MaskedPlayerEnemy entity) => $"{p}")).RegisterInsight("Focus", (Func<MaskedPlayerEnemy, string>)((MaskedPlayerEnemy entity) => $"{f}"))
					.RegisterInsight("Activity", (Func<MaskedPlayerEnemy, string>)((MaskedPlayerEnemy entity) => $"{a}"));
			}
			catch (NullReferenceException)
			{
			}
		}
	}
	public static class LobbyCompatibilityChecker
	{
		public static bool Enabled => Chainloader.PluginInfos.ContainsKey("BMX.LobbyCompatibility");

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void Init()
		{
			PluginHelper.RegisterPlugin("VirusTLNR.LethalIntelligence", Version.Parse("0.3.1"), (CompatibilityLevel)2, (VersionStrictness)3);
		}
	}
	public class BushSystem : MonoBehaviour
	{
		public bool bushWithItem;
	}
	public class GlobalItemList : MonoBehaviour
	{
		public List<GrabbableObject> allitems = new List<GrabbableObject>();

		private List<GrabbableObject> previtems = new List<GrabbableObject>();

		public List<WalkieTalkie> allWalkieTalkies = new List<WalkieTalkie>();

		public bool isShotgun;

		public bool isShovel;

		public bool isWalkie;

		public static GlobalItemList Instance { get; private set; }

		private void Awake()
		{
			Instance = this;
		}

		private void Update()
		{
			if (allitems != previtems)
			{
				CheckItem(1);
				CheckItem(2);
				CheckItem(3);
				previtems = allitems;
			}
		}

		private void CheckItem(int id)
		{
			foreach (GrabbableObject allitem in allitems)
			{
				if (id == 1)
				{
					if (allitem is ShotgunItem)
					{
						isShotgun = true;
						break;
					}
					isShotgun = false;
				}
				if (id == 2)
				{
					if (allitem is Shovel)
					{
						isShovel = true;
						break;
					}
					isShovel = false;
				}
				if (id == 3)
				{
					if (allitem is WalkieTalkie)
					{
						isWalkie = true;
						break;
					}
					isWalkie = false;
				}
			}
		}
	}
	public class SyncConfiguration : NetworkBehaviour
	{
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("Awake")]
		private static void Awake_Postfix()
		{
			if (Plugin.enableMaskedFeatures)
			{
				((Component)StartOfRound.Instance).gameObject.AddComponent<SyncConfiguration>();
				((Component)StartOfRound.Instance).gameObject.AddComponent<GlobalItemList>();
			}
		}
	}
	public class CheckItemCollision : MonoBehaviour
	{
		public bool hidedByMasked;
	}
	[HarmonyPatch(typeof(GrabbableObject))]
	internal class GrabbableObjectPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("Start")]
		private static void Start_Postfix(GrabbableObject __instance)
		{
			if (Plugin.enableMaskedFeatures)
			{
				((Component)__instance).gameObject.AddComponent<CheckItemCollision>();
				GlobalItemList.Instance.allitems.Add(__instance);
				if (__instance is WalkieTalkie)
				{
					GlobalItemList.Instance.allWalkieTalkies.Add(((Component)__instance).GetComponent<WalkieTalkie>());
				}
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("DestroyObjectInHand")]
		private static void DestroyObjectInHand_Postfix(GrabbableObject __instance)
		{
			if (Plugin.enableMaskedFeatures)
			{
				GlobalItemList.Instance.allitems.Remove(__instance);
				if (__instance is WalkieTalkie)
				{
					GlobalItemList.Instance.allWalkieTalkies.Remove(((Component)__instance).GetComponent<WalkieTalkie>());
				}
			}
		}
	}
	public class MaskedAIRevamp : NetworkBehaviour
	{
		public enum Personality
		{
			None,
			Aggressive,
			Stealthy,
			Cunning,
			Deceiving,
			Insane
		}

		public enum Focus
		{
			None,
			Player,
			Items,
			Terminal,
			BreakerBox,
			Hiding,
			Mimicking,
			Apparatus,
			Escape
		}

		public enum Activity
		{
			None,
			MainEntrance,
			FireExit,
			ItemLocker,
			BreakerBox,
			Apparatus,
			RandomItem,
			RandomPlayer,
			WalkieTalkie
		}

		public Personality maskedPersonality;

		public Personality lastMaskedPersonality;

		public Focus maskedFocus;

		public LethalNetworkVariable<int> maskedFocusInt = new LethalNetworkVariable<int>("maskedFocusInt");

		public Focus lastMaskedFocus;

		public Activity maskedActivity;

		public LethalNetworkVariable<int> maskedActivityInt = new LethalNetworkVariable<int>("maskedActivityInt");

		public bool mustChangeFocus;

		public bool mustChangeActivity;

		public bool ignoringPersonality;

		public bool focusingPersonality;

		public AISearchRoutine searchForItems;

		public float stopAndTbagTimer = 1.1f;

		public float stopAndTbagCooldown;

		public int randomPose;

		public bool isHoldingObject;

		public bool heldTwoHanded;

		public bool moveSpecial;

		public EnemyAI __instance;

		public MaskedPlayerEnemy maskedEnemy;

		public Animator creatureAnimator;

		public NavMeshAgent agent;

		public bool checkDestination;

		public GrabbableObject closestGrabbable;

		public GrabbableObject nearestGrabbable;

		public GrabbableObject heldGrabbable;

		private bool targetPlayerReachable;

		private bool closestGrabbableReachable;

		private bool nearestGrabbableReachable;

		private bool justPickedUpItem = false;

		public CheckItemCollision itemSystem;

		public float enterTermianlCodeTimer;

		public float transmitMessageTimer;

		public float transmitPauseTimer;

		public int enterTermianlSpecialCodeTime;

		public LethalNetworkVariable<int> enterTermianlSpecialCodeInt = new LethalNetworkVariable<int>("enterTermianlSpecialCodeInt");

		public LethalNetworkVariable<bool> isCrouched = new LethalNetworkVariable<bool>("isCrouched");

		public LethalNetworkVariable<bool> dropItem = new LethalNetworkVariable<bool>("dropItem");

		public LethalNetworkVariable<bool> isDancing = new LethalNetworkVariable<bool>("isDancing");

		public LethalNetworkVariable<bool> isRunning = new LethalNetworkVariable<bool>("isRunning");

		public LethalNetworkVariable<bool> useWalkie = new LethalNetworkVariable<bool>("useWalkie");

		public LethalNetworkVariable<bool> isJumped = new LethalNetworkVariable<bool>("isJumped");

		public LethalNetworkVariable<int> SelectPersonalityInt = new LethalNetworkVariable<int>("SelectPersonalityInt");

		public LethalNetworkVariable<int> maxDanceCount = new LethalNetworkVariable<int>("maxDanceCount");

		public LethalNetworkVariable<float> terminalTimeFloat = new LethalNetworkVariable<float>("terminalTimeFloat");

		public LethalNetworkVariable<float> delayMaxTime = new LethalNetworkVariable<float>("delayMaxTime");

		public float jumpTime = 1f;

		private float dropTimerB;

		private Vector3 prevPos;

		private float velX;

		private float velZ;

		public float closetTimer;

		private bool enableDance;

		public float shovelTimer;

		public float hornTimer;

		public bool stunThrowed;

		public float angle1;

		public float angle2;

		public float dropTimer;

		public float shootTimer;

		public float rotationTimer;

		public float rotationCooldown;

		public bool itemDroped;

		public bool droppingItem;

		public Terminal terminal;

		public bool isUsingTerminal;

		public bool isUsingApparatus;

		public bool completedApparatusFocus;

		public bool noMoreItems = false;

		public bool noMoreTerminal = false;

		public float dropShipTimer;

		public bool isDeliverEmptyDropship;

		public GameObject itemHolder;

		public float upperBodyAnimationsWeight;

		public float grabbableTime;

		public float distanceToPlayer = 1000f;

		private float terminalDistance = 1000f;

		private bool terminalReachable;

		private float breakerBoxDistance = 1000f;

		private float apparatusDistance = 1000f;

		private float closestGrabbableDistance = 1000f;

		private float nearestGrabbableDistance = 1000f;

		private bool apparatusReachable;

		private bool breakerBoxReachable;

		private float bushDistance = 1000f;

		public bool isStaminaDowned;

		public Vector3 originDestination;

		public bool walkieUsed;

		public bool walkieVoiceTransmitted;

		public float walkieTimer;

		public float walkieCooldown;

		public float originTimer;

		private BreakerBox breakerBox;

		private LungProp apparatus;

		private GrabbableObject grabbableApparatus;

		public bool isUsingBreakerBox;

		public bool noMoreBreakerBox = false;

		public bool noMoreApparatus = false;

		private AnimatedObjectTrigger powerBox;

		private GameObject[] bushes;

		private ItemDropship dropship;

		private TerminalAccessibleObject[] terminalAccessibleObject;

		private float lookTimer;

		private bool lookedPlayer;

		public bool notGrabClosestItem;

		public bool notGrabItems;

		public bool isReeledWithShovel;

		public bool isHittedWithShovel;

		public bool shovelHitConfirm;

		public PlayerControllerB nearestPlayer;

		public bool canGoThroughItem;

		public bool isDroppedShotgunAvailable;

		public string maskedId = null;

		private string lastDebugModeStatus;

		public string maskedGoal = "";

		private bool stopStatusReporting = false;

		private float breakerClosestPoint;

		private float terminalClosestPoint;

		private float grabbableClosestPoint;

		private float apparatusClosestPoint;

		private Vector3 destination;

		private float distanceToDestination;

		private int delayNumber = 0;

		private int delayMax = Plugin.debugStatusDelay;

		private string currentMoon = null;

		private string currentInterior = null;

		private List<Personality> useablePersonalities;

		private float updateFrequency = 0.02f;

		private Vector3 terminalPosition;

		private Vector3 breakerPosition;

		private Vector3 lockerPosition;

		private Vector3 apparatusPosition;

		private Vector3 fireExitPosition;

		private Vector3 mainEntrancePosition;

		private float lockerDistance;

		private float lockerClosestPoint;

		private bool lockerReachable;

		private int itemsToHide = 5;

		private int calculationDelay = 0;

		private bool lateGameChoices = false;

		private GrabbableObject walkieToGrab = null;

		private int countOfNullWalkieError = 0;

		private int timeToPlay = 20;

		private int currentTime = 0;

		private int seenCheckNum = 200;

		private bool isTerminalEscaping;

		private bool isLeverEscaping;

		private float kad = 1f;

		private bool purchasedStuff = false;

		private float MaxTimeBeforeTeleporting = 1f;

		private EntranceTeleport[] entrancesTeleportArray = null;

		private EntranceTeleport? selectedEntrance = null;

		private int mirageAudioClipsPlayedInARow;

		private int randomMirageAllowedAudioClipsInARow;

		private DateTime endMirageClipTime;

		private bool mirageClipAllowed;

		private float followTime = 0f;

		private float TimeSinceTeleporting { get; set; }

		private void TestConfig()
		{
			maskedPersonality = Personality.Stealthy;
			SelectPersonalityInt.Value = 0;
			lastMaskedPersonality = Personality.Stealthy;
			maskedFocusInt.Value = 5;
			maskedActivityInt.Value = 0;
			mustChangeFocus = false;
		}

		private void CheckForEntrancesNearby()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			TimeSinceTeleporting += updateFrequency;
			if (!(Vector3.Distance(((Component)maskedEnemy).transform.position, agent.pathEndPosition) < 5f))
			{
				return;
			}
			EntranceTeleport[] array = entrancesTeleportArray;
			Vector3 pos = default(Vector3);
			foreach (EntranceTeleport val in array)
			{
				if (Vector3.Distance(((Component)maskedEnemy).transform.position, val.entrancePoint.position) < 4f)
				{
					((Vector3)(ref pos))..ctor(((Component)val).transform.position.x, ((Component)this).transform.position.y, ((Component)val).transform.position.z);
					LookAtPos(pos);
				}
				if (objectInLOSCheck((EnemyAI)(object)maskedEnemy, ((Component)val).gameObject) == 2 || Vector3.Distance(((Component)maskedEnemy).transform.position, val.entrancePoint.position) < 1f)
				{
					Vector3 position;
					if (TimeSinceTeleporting < 3f)
					{
						string[] obj = new string[5]
						{
							"waiting to use entrance (",
							val.entranceId.ToString(),
							"/",
							null,
							null
						};
						position = val.entrancePoint.position;
						obj[3] = ((object)(Vector3)(ref position)).ToString();
						obj[4] = ") (less than 3 seconds)";
						maskedGoal = string.Concat(obj);
					}
					else
					{
						Vector3? teleportDestination = getTeleportDestination(val);
						string[] obj2 = new string[5]
						{
							"using entrance (",
							val.entranceId.ToString(),
							"/",
							null,
							null
						};
						position = val.entrancePoint.position;
						obj2[3] = ((object)(Vector3)(ref position)).ToString();
						obj2[4] = ")";
						maskedGoal = string.Concat(obj2);
						TimeSinceTeleporting = 0f;
						TeleportMaskedEnemyAndSync(teleportDestination.Value, !((EnemyAI)maskedEnemy).isOutside);
						mustChangeFocus = true;
						mustChangeActivity = true;
					}
					break;
				}
			}
		}

		private bool delayUpdate()
		{
			delayNumber++;
			if (delayNumber >= delayMax)
			{
				delayNumber = 0;
				return true;
			}
			return false;
		}

		public void MaskedStatusReport()
		{
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			if (!Plugin.DebugMode || stopStatusReporting || !delayUpdate())
			{
				return;
			}
			try
			{
				string text = "null";
				string text2 = "null";
				string text3 = "null";
				string text4 = "null";
				string text5 = "null";
				string text6 = "null";
				string text7 = "null";
				string text8 = "null";
				string text9 = "null";
				string text10 = "null";
				if ((Object)(object)nearestGrabbable != (Object)null)
				{
					text = ((Object)nearestGrabbable).name.ToString();
					text3 = nearestGrabbableDistance.ToString();
				}
				if ((Object)(object)heldGrabbable != (Object)null)
				{
					text2 = ((Object)heldGrabbable).name.ToString();
				}
				if ((Object)(object)closestGrabbable != (Object)null)
				{
					text4 = ((Object)closestGrabbable).name.ToString();
				}
				if ((Object)(object)breakerBox != (Object)null)
				{
					text5 = breakerBoxReachable.ToString();
					text6 = breakerBox.isPowerOn.ToString();
				}
				if ((Object)(object)apparatus != (Object)null)
				{
					text7 = apparatusReachable.ToString();
					text8 = completedApparatusFocus.ToString();
				}
				if (currentMoon != null)
				{
					text9 = currentMoon.ToString();
				}
				if (currentInterior != null)
				{
					text10 = currentInterior.ToString();
				}
				string text11 = breakerClosestPoint.ToString();
				string text12 = terminalClosestPoint.ToString();
				string text13 = breakerBoxDistance.ToString();
				string text14 = terminalDistance.ToString();
				destination = ((EnemyAI)maskedEnemy).destination;
				distanceToDestination = Vector3.Distance(((Component)maskedEnemy).transform.position, destination);
				string text15 = "\n------------ Focus Details ------------";
				string text16 = "";
				if (maskedFocus == Focus.Items || (maskedFocus == Focus.None && maskedActivity == Activity.RandomItem))
				{
					text16 = text15 + "\nnearestGrabbableReachable = " + nearestGrabbableReachable + "\nnearestGrabbable = " + text + "\nclosestGrabbable = " + text4;
				}
				else if (maskedFocus == Focus.BreakerBox || (maskedFocus == Focus.None && maskedActivity == Activity.BreakerBox))
				{
					text16 = text15 + "\nBreakerBoxReachable = " + text5 + "\nbreakerBox.isPowerOn = " + text6;
				}
				else if (maskedFocus == Focus.Terminal)
				{
					text16 = text15 + "\nTerminalReachable = " + terminalReachable;
				}
				else if (maskedActivity == Activity.Apparatus || maskedFocus == Focus.Apparatus)
				{
					text16 = text15 + "\nApparatusReachable = " + text7 + "\nThisMaskedSabotagedApparatus? = " + text8;
				}
				else if (maskedFocus == Focus.Escape)
				{
					text16 = text15 + "\nisTerminalEscaping = " + isTerminalEscaping + "\ntermianlSpecialCodeTime = " + enterTermianlSpecialCodeTime + "\nisLeverEscaping = " + isLeverEscaping;
				}
				string text17 = "\n===== MaskedStatusReport() Start =====\nMaskedID = " + maskedId + "\nMaskedPersonality = " + maskedPersonality.ToString() + "\nMaskedFocus = " + maskedFocus.ToString() + "\nMustChangeFocus = " + mustChangeFocus + "\nMaskedActivity (Focus=None) = " + maskedActivity.ToString() + "\nMustChangeActivity = " + mustChangeActivity + "\nLateGameChoices = " + lateGameChoices + "\nMoon = " + text9 + "\nInterior = " + text10 + "\nisDead = " + ((EnemyAI)maskedEnemy).isEnemyDead + "\n\nisOutside = " + ((EnemyAI)maskedEnemy).isOutside + "\nisInsidePlayerShip = " + ((EnemyAI)maskedEnemy).isInsidePlayerShip + "\nheldGrabbable = " + text2 + "\nMaskedGoal = " + maskedGoal + "\n\nnoMoreBreakerBox = " + noMoreBreakerBox + "\nnoMoreTerminal = " + noMoreTerminal + "\nnoMoreApparatus = " + noMoreApparatus + "\nnoMoreItems = " + noMoreItems + "\nnotGrabClosestItem = " + notGrabClosestItem + text16 + "\n===== MaskedStatusReport() End =======";
				if (text17 != lastDebugModeStatus)
				{
					lastDebugModeStatus = text17;
					Plugin.mls.LogInfo((object)text17);
				}
				if (((EnemyAI)maskedEnemy).isEnemyDead)
				{
					Plugin.mls.LogInfo((object)("Masked " + maskedPersonality.ToString() + "(" + maskedId + ") is now dead, status reporting will cease for this masked"));
					stopStatusReporting = true;
				}
			}
			catch (Exception ex)
			{
				Plugin.mls.LogWarning((object)("MaskedStatusReport has failed to write...\n\t" + ex.ToString()));
			}
		}

		private void selectAvailablePersonalities()
		{
			useablePersonalities = new List<Personality>();
			if (!Plugin.enableMaskedAggressive && !Plugin.enableMaskedCunning && !Plugin.enableMaskedDeceiving && !Plugin.enableMaskedInsane && !Plugin.enableMaskedStealthy)
			{
				Plugin.mls.LogWarning((object)"Bad Config!! - All masked personalities are turned off so turning off whole Masked AI Module.");
				return;
			}
			if (Plugin.enableMaskedAggressive)
			{
				useablePersonalities.Add(Personality.Aggressive);
			}
			if (Plugin.enableMaskedStealthy)
			{
				useablePersonalities.Add(Personality.Stealthy);
			}
			if (Plugin.enableMaskedCunning)
			{
				useablePersonalities.Add(Personality.Cunning);
			}
			if (Plugin.enableMaskedDeceiving)
			{
				useablePersonalities.Add(Personality.Deceiving);
			}
			if (Plugin.enableMaskedInsane)
			{
				useablePersonalities.Add(Personality.Insane);
			}
		}

		public void Start()
		{
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Expected O, but got Unknown
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Expected O, but got Unknown
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Expected O, but got Unknown
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0303: Unknown result type (might be due to invalid IL or missing references)
			//IL_030d: Expected O, but got Unknown
			//IL_030d: Expected O, but got Unknown
			//IL_0347: Unknown result type (might be due to invalid IL or missing references)
			//IL_0351: Unknown result type (might be due to invalid IL or missing references)
			//IL_035b: Expected O, but got Unknown
			//IL_035b: Expected O, but got Unknown
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Expected O, but got Unknown
			selectAvailablePersonalities();
			if ((Object)(object)RoundManager.Instance.currentLevel == (Object)null)
			{
				return;
			}
			if (((Object)RoundManager.Instance.currentLevel).name.ToString() == "CompanyBuildingLevel")
			{
				currentMoon = ((Object)RoundManager.Instance.currentLevel).name;
				currentInterior = "null";
			}
			else
			{
				Plugin.mls.LogDebug((object)("NormalMoonWithInteriorFound:- " + ((Object)RoundManager.Instance.currentLevel).name.ToString()));
				currentMoon = ((Object)RoundManager.Instance.currentLevel).name;
				currentInterior = ((Object)RoundManager.Instance.dungeonGenerator.Generator.DungeonFlow).name.ToString();
			}
			if (GameNetworkManager.Instance.isHostingGame)
			{
				maskedId = ((Object)this).GetInstanceID().ToString();
				enterTermianlSpecialCodeInt.Value = Random.Range(0, Enum.GetNames(typeof(Personality)).Length);
			}
			if ((Object)GameObject.FindGameObjectWithTag("Bush") != (Object)null)
			{
				if (bushes != GameObject.FindGameObjectsWithTag("Bush"))
				{
					bushes = GameObject.FindGameObjectsWithTag("Bush");
				}
				GameObject[] array = bushes;
				GameObject[] array2 = array;
				foreach (GameObject val in array2)
				{
					if ((Object)val.GetComponent<BushSystem>() == (Object)null)
					{
						val.AddComponent<BushSystem>();
					}
				}
			}
			terminal = Object.FindObjectOfType<Terminal>();
			breakerBox = Object.FindObjectOfType<BreakerBox>();
			apparatus = Object.FindObjectOfType<LungProp>();
			__instance = (EnemyAI)((Component)this).GetComponent<MaskedPlayerEnemy>();
			maskedEnemy = ((Component)this).GetComponent<MaskedPlayerEnemy>();
			creatureAnimator = ((Component)((Component)this).transform.GetChild(0).GetChild(3)).GetComponent<Animator>();
			itemHolder = new GameObject("ItemHolder");
			itemHolder.transform.parent = ((Component)__instance).transform.GetChild(0).GetChild(3).GetChild(0)
				.GetChild(0)
				.GetChild(0)
				.GetChild(0)
				.GetChild(1)
				.GetChild(0)
				.GetChild(0)
				.GetChild(0);
			itemHolder.transform.localPosition = new Vector3(-0.002f, 0.036f, -0.042f);
			itemHolder.transform.localRotation = Quaternion.Euler(-3.616f, -2.302f, 0.145f);
			if (GameNetworkManager.Instance.isHostingGame)
			{
				maxDanceCount.Value = Random.Range(2, 4);
				if (Plugin.mirageIntegrated)
				{
					enableMirageAudio();
				}
			}
			if ((Object)creatureAnimator.runtimeAnimatorController != (Object)Plugin.MaskedAnimController)
			{
				creatureAnimator.runtimeAnimatorController = Plugin.MaskedAnimController;
			}
			if ((Object)((Component)((Component)__instance).transform.GetChild(3).GetChild(0)).GetComponent<Animator>().runtimeAnimatorController != (Object)Plugin.MapDotRework)
			{
				((Component)((Component)__instance).transform.GetChild(3).GetChild(0)).GetComponent<Animator>().runtimeAnimatorController = Plugin.MapDotRework;
			}
			dropship = Object.FindObjectOfType<ItemDropship>();
			terminalAccessibleObject = Object.FindObjectsOfType<TerminalAccessibleObject>();
			entrancesTeleportArray = Object.FindObjectsOfType<EntranceTeleport>(false);
		}

		private void Jump(bool enable)
		{
			if (jumpTime > 0f && !isJumped.Value)
			{
				jumpTime -= updateFrequency;
			}
			if (!isCrouched.Value && !isJumped.Value && jumpTime < 1f && jumpTime > 0.9f)
			{
				isJumped.Value = true;
				creatureAnimator.SetTrigger("FakeJump");
			}
		}

		private void Dance(bool enabled)
		{
			if (enabled)
			{
				isDancing.Value = true;
				__instance.movingTowardsTargetPlayer = false;
				agent.speed = 0f;
			}
			else
			{
				isDancing.Value = false;
			}
		}

		private void InvokeAllClientsSynced()
		{
			Plugin.mls.LogWarning((object)"InvokeAllClientsSynced");
		}

		private void InvokeOtherClientsSynced()
		{
			Plugin.mls.LogWarning((object)"InvokeOtherClientsSynced");
		}

		private void SelectPersonality(int num)
		{
			switch (num)
			{
			case 0:
				maskedPersonality = Personality.Aggressive;
				break;
			case 1:
				maskedPersonality = Personality.Cunning;
				break;
			case 2:
				maskedPersonality = Personality.Deceiving;
				break;
			case 3:
				maskedPersonality = Personality.Stealthy;
				break;
			case 4:
				maskedPersonality = Personality.Insane;
				break;
			}
		}

		private void SyncTermianlInt(int num)
		{
			enterTermianlSpecialCodeTime = num;
		}

		private void CalculatingVariables()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_043c: Unknown result type (might be due to invalid IL or missing references)
			//IL_05bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_030d: Unknown result type (might be due to invalid IL or missing references)
			//IL_031d: Unknown result type (might be due to invalid IL or missing references)
			//IL_032f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0334: Unknown result type (might be due to invalid IL or missing references)
			//IL_045e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0475: Unknown result type (might be due to invalid IL or missing references)
			//IL_0485: Unknown result type (might be due to invalid IL or missing references)
			//IL_0497: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04be: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: 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_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: 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_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			NavMeshPath val = new NavMeshPath();
			NavMeshPath val2 = new NavMeshPath();
			NavMeshPath val3 = new NavMeshPath();
			NavMeshPath val4 = new NavMeshPath();
			if (calculationDelay > 0)
			{
				calculationDelay--;
				return;
			}
			calculationDelay = 250;
			if (TimeOfDay.Instance.hour >= 8)
			{
				lateGameChoices = true;
			}
			if (mustChangeFocus || maskedFocus == Focus.Items)
			{
				setNearestGrabbable();
			}
			if (mustChangeFocus || maskedFocus == Focus.Apparatus || maskedActivity == Activity.Apparatus)
			{
				if ((Object)(object)apparatus == (Object)null)
				{
					Plugin.mls.LogDebug((object)"Apparatus is Null");
					apparatusReachable = false;
					apparatusDistance = 1000f;
					noMoreApparatus = true;
				}
				else
				{
					try
					{
						NavMeshHit val5 = default(NavMeshHit);
						if (NavMesh.SamplePosition(((Component)apparatus).transform.position + -((Component)apparatus).transform.forward, ref val5, 10f, -1))
						{
							apparatusReachable = agent.CalculatePath(((NavMeshHit)(ref val5)).position, val4);
							apparatusDistance = Vector3.Distance(((Component)maskedEnemy).transform.position, ((NavMeshHit)(ref val5)).position);
							apparatusClosestPoint = Vector3.Distance(((NavMeshHit)(ref val5)).position, ((Component)apparatus).transform.position);
							apparatusPosition = ((NavMeshHit)(ref val5)).position;
						}
						else
						{
							apparatusReachable = false;
						}
						if (!apparatusReachable)
						{
							apparatusDistance = 1000f;
						}
					}
					catch (NullReferenceException ex)
					{
						Plugin.mls.LogDebug((object)("Apparatus NullReferenceException() Caught!\n" + ex.Message));
						apparatusReachable = false;
						noMoreApparatus = true;
					}
					catch (Exception ex2)
					{
						Plugin.mls.LogDebug((object)("Apparatus Exception() Caught!\n" + ex2.Message));
						apparatusReachable = false;
						noMoreApparatus = true;
					}
				}
			}
			if (mustChangeFocus || maskedFocus == Focus.BreakerBox || maskedActivity == Activity.BreakerBox)
			{
				if ((Object)(object)breakerBox == (Object)null)
				{
					Plugin.mls.LogDebug((object)"BreakerBox is Null");
					breakerBoxReachable = false;
					breakerBoxDistance = 1000f;
					noMoreBreakerBox = true;
				}
				else
				{
					try
					{
						NavMeshHit val6 = default(NavMeshHit);
						if (NavMesh.SamplePosition(((Component)breakerBox).transform.position + -((Component)breakerBox).transform.up, ref val6, 10f, -1))
						{
							breakerBoxReachable = agent.CalculatePath(((NavMeshHit)(ref val6)).position, val);
							breakerBoxDistance = Vector3.Distance(((Component)this).transform.position, ((NavMeshHit)(ref val6)).position);
							breakerClosestPoint = Vector3.Distance(((NavMeshHit)(ref val6)).position, ((Component)breakerBox).transform.position);
							breakerPosition = ((NavMeshHit)(ref val6)).position;
						}
						else
						{
							breakerBoxReachable = false;
						}
						if (!breakerBoxReachable)
						{
							breakerBoxDistance = 1000f;
						}
					}
					catch (NullReferenceException ex3)
					{
						Plugin.mls.LogDebug((object)("BreakerBox NullReferenceException() Caught!\n" + ex3.Message));
						breakerBoxReachable = false;
						noMoreBreakerBox = true;
					}
					catch (Exception ex4)
					{
						Plugin.mls.LogDebug((object)("BreakerBox Exception() Caught!\n" + ex4.Message));
						breakerBoxReachable = false;
						noMoreBreakerBox = true;
					}
				}
			}
			if (mustChangeFocus || maskedFocus == Focus.Terminal || maskedFocus == Focus.Escape)
			{
				if ((Object)(object)terminal == (Object)null)
				{
					Plugin.mls.LogDebug((object)"Terminal is Null");
					terminalReachable = false;
					terminalDistance = 1000f;
					noMoreTerminal = true;
				}
				else
				{
					try
					{
						NavMeshHit val7 = default(NavMeshHit);
						if (NavMesh.SamplePosition(((Component)terminal).transform.position, ref val7, 10f, -1))
						{
							terminalReachable = agent.CalculatePath(((NavMeshHit)(ref val7)).position, val2);
							terminalDistance = Vector3.Distance(((Component)this).transform.position, ((Component)terminal).transform.position);
							terminalClosestPoint = Vector3.Distance(((NavMeshHit)(ref val7)).position, ((Component)terminal).transform.position);
							terminalPosition = ((NavMeshHit)(ref val7)).position;
						}
						else
						{
							terminalReachable = false;
						}
						if (!terminalReachable)
						{
							terminalDistance = 1000f;
						}
					}
					catch (NullReferenceException ex5)
					{
						Plugin.mls.LogDebug((object)("Terminal NullReferenceException() Caught!\n" + ex5.Message));
						terminalReachable = false;
						noMoreTerminal = true;
					}
					catch (Exception ex6)
					{
						Plugin.mls.LogDebug((object)("Terminal Exception() Caught!\n" + ex6.Message));
						terminalReachable = false;
						noMoreTerminal = true;
					}
				}
			}
			if (!mustChangeFocus && maskedActivity != Activity.ItemLocker)
			{
				return;
			}
			if ((Object)(object)GameObject.Find("LockerAudio") == (Object)null)
			{
				Plugin.mls.LogDebug((object)"LockerAudio is Null");
				lockerReachable = false;
				lockerDistance = 1000f;
				return;
			}
			try
			{
				lockerPosition = GameObject.Find("LockerAudio").transform.position;
			}
			catch (NullReferenceException ex7)
			{
				Plugin.mls.LogDebug((object)("Locker NullReferenceException() Caught!\n" + ex7.Message));
				lockerReachable = false;
			}
			catch (Exception ex8)
			{
				Plugin.mls.LogDebug((object)("Locker Exception() Caught!\n" + ex8.Message));
				lockerReachable = false;
			}
		}

		private void SetFocus()
		{
			if (!GameNetworkManager.Instance.isHostingGame || !mustChangeFocus)
			{
				return;
			}
			lastMaskedFocus = maskedFocus;
			if (maskedPersonality == Personality.Cunning && breakerBoxDistance < 40f && lastMaskedFocus != Focus.BreakerBox && breakerBoxReachable && !noMoreBreakerBox)
			{
				maskedFocusInt.Value = 4;
				maskedActivityInt.Value = 0;
				mustChangeActivity = true;
			}
			else if ((maskedPersonality == Personality.Cunning || maskedPersonality == Personality.Deceiving || maskedPersonality == Personality.Insane) && terminalDistance < 40f && lastMaskedFocus != Focus.Terminal && terminalReachable && !noMoreTerminal)
			{
				maskedFocusInt.Value = 3;
				maskedActivityInt.Value = 0;
				mustChangeActivity = true;
			}
			else if ((maskedPersonality == Personality.Cunning || maskedPersonality == Personality.Deceiving || maskedPersonality == Personality.Aggressive) && nearestGrabbableDistance < 40f && lastMaskedFocus != Focus.Items && nearestGrabbableReachable && !noMoreItems)
			{
				maskedFocusInt.Value = 2;
				maskedActivityInt.Value = 0;
				mustChangeActivity = true;
			}
			else if (maskedPersonality == Personality.Stealthy && (Object)(object)__instance.targetPlayer != (Object)null && lastMaskedFocus != Focus.Hiding)
			{
				maskedFocusInt.Value = 5;
				maskedActivityInt.Value = 0;
				mustChangeActivity = true;
			}
			else if (maskedPersonality == Personality.Stealthy && (Object)(object)__instance.targetPlayer != (Object)null && lastMaskedFocus != Focus.Mimicking)
			{
				maskedFocusInt.Value = 6;
				maskedActivityInt.Value = 0;
				mustChangeActivity = true;
			}
			else if ((maskedPersonality == Personality.Aggressive || maskedPersonality == Personality.Deceiving) && (Object)(object)__instance.targetPlayer != (Object)null && lastMaskedFocus != Focus.Player)
			{
				maskedFocusInt.Value = 1;
				maskedActivityInt.Value = 0;
				mustChangeActivity = true;
			}
			else if (maskedPersonality == Personality.Insane && lastMaskedFocus != Focus.Apparatus && lateGameChoices && !((EnemyAI)maskedEnemy).isOutside)
			{
				maskedFocusInt.Value = 7;
				maskedActivityInt.Value = 0;
				mustChangeActivity = true;
			}
			else if (maskedPersonality == Personality.Insane && lastMaskedFocus != Focus.Escape && lateGameChoices && completedApparatusFocus && ((EnemyAI)maskedEnemy).isOutside)
			{
				maskedFocusInt.Value = 8;
				maskedActivityInt.Value = 0;
				mustChangeActivity = true;
			}
			else
			{
				maskedFocusInt.Value = 0;
				if (mustChangeActivity)
				{
					SetActivity();
					mustChangeActivity = false;
				}
			}
			mustChangeFocus = false;
		}

		private void SetActivity()
		{
			if (maskedActivity != Activity.MainEntrance && maskedActivity != Activity.FireExit)
			{
				switch (Random.RandomRangeInt(0, 2))
				{
				case 0:
					maskedActivityInt.Value = 1;
					break;
				case 1:
					maskedActivityInt.Value = 2;
					break;
				}
			}
			else if (((EnemyAI)maskedEnemy).isOutside)
			{
				if (maskedActivity != Activity.ItemLocker)
				{
					maskedActivityInt.Value = 3;
				}
				else if (maskedActivity != Activity.RandomItem)
				{
					maskedActivityInt.Value = 6;
				}
			}
			else if (!((EnemyAI)maskedEnemy).isOutside)
			{
				if (maskedActivity != Activity.BreakerBox)
				{
					maskedActivityInt.Value = 4;
				}
				else if (maskedActivity != Activity.Apparatus)
				{
					maskedActivityInt.Value = 5;
				}
				else if (maskedActivity != Activity.RandomItem)
				{
					maskedActivityInt.Value = 6;
				}
			}
			maskedActivity = (Activity)maskedActivityInt.Value;
		}

		public void FixedUpdate()
		{
			//IL_0363: Unknown result type (might be due to invalid IL or missing references)
			//IL_036e: Expected O, but got Unknown
			//IL_0390: Unknown result type (might be due to invalid IL or missing references)
			//IL_039b: Expected O, but got Unknown
			//IL_03bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c8: Expected O, but got Unknown
			if (Plugin.imperiumFound)
			{
				try
				{
					ImperiumPatches.maskedVisualization(maskedPersonality, maskedActivity, maskedFocus);
				}
				catch (MissingMethodException ex)
				{
					Plugin.mls.LogWarning((object)("Imperium Visualisers Integeration has an (MME)xception...\n\r" + ex.Message));
				}
				catch (Exception ex2)
				{
					Plugin.mls.LogWarning((object)("Imperium Visualisers Integeration has an (E)xception...\n\r" + ex2.Message));
				}
			}
			if ((currentMoon == null || currentInterior == null) && (currentMoon != null || currentInterior != null))
			{
				return;
			}
			MaskedStatusReport();
			if (((EnemyAI)maskedEnemy).isEnemyDead && isHoldingObject)
			{
				maskedGoal = "died, dropping objects!";
				closestGrabbable.parentObject = null;
				closestGrabbable.isHeld = false;
				closestGrabbable.isHeldByEnemy = false;
				isHoldingObject = false;
			}
			if (__instance.isEnemyDead)
			{
				maskedGoal = "none, he died!";
				((Behaviour)agent).enabled = false;
				if (isUsingTerminal)
				{
					isUsingTerminal = false;
					Plugin.isTerminalBeingUsed = false;
					terminal.SetTerminalNoLongerInUse();
					terminalAccess(enabled: true);
				}
				return;
			}
			if (useWalkie.Value)
			{
				if ((maskedFocus == Focus.Escape || maskedFocus == Focus.Apparatus) && maskedPersonality == Personality.Insane)
				{
					maskedGoal = "insane is ignoring walkie due to its current focus being urgent";
				}
				else
				{
					maskedGoal = "use walkie";
					GrabWalkie();
					HoldWalkie();
					useWalkie.Value = false;
				}
			}
			if (GameNetworkManager.Instance.isHostingGame && maskedPersonality == Personality.None)
			{
				SelectPersonalityInt.Value = Random.Range(0, useablePersonalities.Count);
			}
			maskedPersonality = useablePersonalities[SelectPersonalityInt.Value];
			if (lastMaskedPersonality != maskedPersonality)
			{
				maskedGoal = "selecting new personality";
				lastMaskedPersonality = maskedPersonality;
				if (maskedPersonality == Personality.Deceiving)
				{
					SyncTermianlInt(15);
				}
				else if (maskedPersonality == Personality.Insane)
				{
					SyncTermianlInt(10);
				}
				Plugin.mls.LogInfo((object)("Masked '" + maskedId + "' personality changed to '" + maskedPersonality.ToString() + "'"));
				mustChangeFocus = true;
				mustChangeActivity = true;
			}
			if (!((Component)this).TryGetComponent<NavMeshAgent>(ref agent))
			{
				agent = ((Component)this).GetComponent<NavMeshAgent>();
			}
			if ((Plugin.wendigosIntegrated || Plugin.skinWalkersIntegrated || Plugin.mirageIntegrated) && ((NetworkBehaviour)this).IsHost && (maskedPersonality == Personality.Deceiving || maskedPersonality == Personality.Insane || maskedPersonality == Personality.Stealthy))
			{
				useWalkie.Value = true;
			}
			if ((Object)creatureAnimator == (Object)null)
			{
				Plugin.mls.LogError((object)"VariableDeclarationClass.Update():  creatureAnimator is null!");
				return;
			}
			if ((Object)agent == (Object)null)
			{
				Plugin.mls.LogError((object)"VariableDeclarationClass.Update():  __agent is null!");
				return;
			}
			if ((Object)__instance == (Object)null)
			{
				Plugin.mls.LogError((object)"VariableDeclarationClass.Update():  __instance is null!");
				return;
			}
			MovementAnimationSelector(creatureAnimator, maskedEnemy);
			ItemAnimationSelector(creatureAnimator, __instance);
			CalculatingVariables();
			DetectAndSelectRandomPlayer();
			TargetAndKillPlayer();
			CheckForEntrancesNearby();
			SetFocus();
			maskedFocus = (Focus)maskedFocusInt.Value;
			maskedActivity = (Activity)maskedActivityInt.Value;
			if (maskedFocus != 0)
			{
				if (maskedPersonality == Personality.Cunning)
				{
					maskedGoal = "trying to be cunning...";
					MaskedCunning();
					return;
				}
				if (maskedPersonality == Personality.Deceiving)
				{
					maskedGoal = "trying to be deceiving...";
					MaskedDeceiving();
					return;
				}
				if (maskedPersonality == Personality.Aggressive)
				{
					maskedGoal = "trying to be aggressive...";
					MaskedAggressive();
					return;
				}
				if (maskedPersonality == Personality.Stealthy)
				{
					maskedGoal = "trying to be stealthy...";
					MaskedStealthy();
					return;
				}
				if (maskedPersonality == Personality.Insane)
				{
					maskedGoal = "trying to be insane...";
					MaskedInsane();
					return;
				}
				Plugin.mls.LogError((object)"Personality = None???");
				Plugin.mls.LogWarning((object)("maskedPersonality = " + maskedPersonality));
				Plugin.mls.LogWarning((object)("SelectPersonalityInt.Value" + SelectPersonalityInt.Value));
				Plugin.mls.LogWarning((object)"No Personality Found => changing personality!");
				foreach (Personality useablePersonality in useablePersonalities)
				{
					Plugin.mls.LogWarning((object)(useablePersonality.ToString() + " is available"));
				}
				SelectPersonalityInt.Value = Random.Range(0, useablePersonalities.Count);
			}
			else if (maskedFocus == Focus.None && maskedActivity != 0)
			{
				if (maskedActivity == Activity.ItemLocker)
				{
					maskedGoal = "pathing to ship locker";
					findLockerAudio();
				}
				else if (maskedActivity == Activity.MainEntrance)
				{
					maskedGoal = "pathing to main entrance";
					findMainEntrance();
				}
				else if (maskedActivity == Activity.FireExit)
				{
					maskedGoal = "pathing to closest fire exit";
					maskedActivity = Activity.FireExit;
					findFireExit();
				}
				else if (maskedActivity == Activity.BreakerBox)
				{
					maskedGoal = "pathing to breaker box";
					findBreakerBox();
				}
				else if (maskedActivity == Activity.RandomPlayer)
				{
					maskedGoal = "finding random player";
					findRandomPlayer();
				}
				else if (maskedActivity == Activity.Apparatus)
				{
					maskedGoal = "finding Apparatus";
					findApparatus();
				}
				else if (maskedActivity == Activity.RandomItem)
				{
					maskedGoal = "finding RandomItem";
					findRandomItem();
				}
			}
		}

		public void LookAtPos(Vector3 pos, float lookAtTime = 1f, bool needsToSeePosition = true)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			maskedGoal = "Looking at Position for " + lookAtTime;
			if (__instance.CheckLineOfSightForPosition(pos, 80f, 60, -1f, (Transform)null))
			{
				maskedEnemy.focusOnPosition = pos;
				maskedEnemy.lookAtPositionTimer = lookAtTime;
				float num = Vector3.Angle(((Component)this).transform.forward, pos - ((Component)this).transform.position);
				if (pos.y - maskedEnemy.headTiltTarget.position.y < 0f)
				{
					num *= -1f;
				}
				maskedEnemy.verticalLookAngle = num;
			}
		}

		private void setNearestGrabbable()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: 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_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0287: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			NavMeshPath val = new NavMeshPath();
			float num = float.PositiveInfinity;
			List<GrabbableObject> allitems = GlobalItemList.Instance.allitems;
			if (allitems.Count == 0)
			{
				Plugin.mls.LogDebug((object)"allItemsList is empty so setting no more items=true");
				noMoreItems = true;
				mustChangeFocus = true;
			}
			NavMeshHit val2 = default(NavMeshHit);
			foreach (GrabbableObject item in allitems)
			{
				if ((Object)(object)this == (Object)null)
				{
					break;
				}
				_ = ((Component)this).transform.position;
				if (false)
				{
					break;
				}
				if ((Object)(object)item == (Object)null)
				{
					continue;
				}
				_ = ((Component)item).transform.position;
				if (false || ((Object)item).name == "ClipboardManual" || ((Object)item).name == "StickyNoteItem" || ((Object)item).name == "RedLocustHive" || (maskedPersonality == Personality.Cunning && Vector3.Distance(((Component)item).transform.position, ((Component)terminal).transform.position) >= 15f) || (maskedPersonality == Personality.Deceiving && Vector3.Distance(((Component)item).transform.position, ((Component)terminal).transform.position) <= 30f))
				{
					continue;
				}
				float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)item).transform.position);
				if ((Object)(object)((Component)item).GetComponent<CheckItemCollision>() != (Object)null)
				{
					itemSystem = ((Component)item).GetComponent<CheckItemCollision>();
				}
				if (!itemSystem.hidedByMasked && agent.CalculatePath(((Component)item).transform.position, val) && num2 < num && num2 <= 30f && !item.isHeld && !item.isHeldByEnemy && !notGrabClosestItem)
				{
					num = num2;
					nearestGrabbable = item;
					if (NavMesh.SamplePosition(((Component)nearestGrabbable).transform.position, ref val2, 10f, -1))
					{
						nearestGrabbableReachable = agent.CalculatePath(((Component)nearestGrabbable).transform.position, val);
						nearestGrabbableDistance = Vector3.Distance(((Component)this).transform.position, ((Component)nearestGrabbable).transform.position);
					}
					else
					{
						nearestGrabbableReachable = false;
						nearestGrabbableDistance = 1000f;
					}
				}
			}
		}

		private void DetectAndSelectRandomPlayer()
		{
			PlayerControllerB[] allPlayersInLineOfSight = ((EnemyAI)maskedEnemy).GetAllPlayersInLineOfSight(80f, 60, (Transform)null, -1f, -1);
			if (allPlayersInLineOfSight != null && maskedFocus != Focus.Player && (maskedFocus != 0 || maskedActivity != Activity.RandomPlayer) && !((EnemyAI)maskedEnemy).inSpecialAnimation && allPlayersInLineOfSight.Length != 0)
			{
				maskedGoal = "Detecting Players";
				int num = 0;
				if (maskedPersonality == Personality.Cunning)
				{
					num = allPlayersInLineOfSight.Length;
				}
				else if (maskedPersonality == Personality.Deceiving)
				{
					num = allPlayersInLineOfSight.Length * 2;
				}
				else if (maskedPersonality == Personality.Stealthy)
				{
					num = allPlayersInLineOfSight.Length * 4;
				}
				else if (maskedPersonality == Personality.Insane)
				{
					num = 2;
				}
				else if (maskedPersonality == Personality.Aggressive)
				{
					num = 1;
				}
				int num2 = Random.RandomRangeInt(0, allPlayersInLineOfSight.Length + num);
				if (num2 < allPlayersInLineOfSight.Length)
				{
					mustChangeActivity = false;
					mustChangeFocus = false;
					maskedFocus = Focus.None;
					maskedActivity = Activity.RandomPlayer;
					mustChangeActivity = false;
					mustChangeFocus = false;
					__instance.targetPlayer = allPlayersInLineOfSight[num2];
				}
			}
		}

		public void DetectEnemy()
		{
			//IL_0031: 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_0085: Unknown result type (might be due to invalid IL or missing references)
			maskedGoal = "detectEnemy";
			foreach (GrabbableObject allitem in GlobalItemList.Instance.allitems)
			{
				float num = Vector3.Distance(((Component)this).transform.position, ((Component)allitem).transform.position);
				if (num < float.PositiveInfinity && num <= 10f && ((NetworkBehaviour)this).IsHost)
				{
					if (num > 0.5f)
					{
						__instance.SetDestinationToPosition(((Component)closestGrabbable).transform.position, true);
						__instance.moveTowardsDestination = true;
						__instance.movingTowardsTargetPlayer = false;
					}
					else
					{
						maskedFocusInt.Value = 0;
						maskedActivityInt.Value = 1;
						__instance.moveTowardsDestination = false;
					}
				}
			}
		}

		public void ManuelGrabItem(GrabbableObject item)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: 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_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			maskedGoal = "manuelGrabItem";
			if (isHoldingObject)
			{
				return;
			}
			float num = Vector3.Distance(((Component)this).transform.position, ((Component)item).transform.position);
			if (num < 0.9f)
			{
				float num2 = Vector3.Angle(((Component)__instance).transform.forward, ((Component)closestGrabbable).transform.position - ((Component)__instance).transform.position);
				if (((Component)closestGrabbable).transform.position.y - maskedEnemy.headTiltTarget.position.y < 0f)
				{
					num2 *= -1f;
				}
				maskedEnemy.verticalLookAngle = num2;
				item.parentObject = itemHolder.transform;
				item.hasHitGround = false;
				item.isHeld = true;
				item.isHeldByEnemy = true;
				item.grabbable = false;
				isHoldingObject = true;
				itemDroped = false;
				item.GrabItemFromEnemy(__instance);
			}
			if (num < 4f && !isHoldingObject && maskedPersonality != Personality.Aggressive && ((NetworkBehaviour)this).IsHost)
			{
				isCrouched.Value = true;
			}
		}

		public void ForceGrabCustomItem(GrabbableObject item)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: 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_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			maskedGoal = "forcegrabcustomitem";
			float num = Vector3.Angle(((Component)__instance).transform.forward, ((Component)closestGrabbable).transform.position - ((Component)__instance).transform.position);
			if (((Component)closestGrabbable).transform.position.y - maskedEnemy.headTiltTarget.position.y < 0f)
			{
				num *= -1f;
			}
			maskedEnemy.verticalLookAngle = num;
			item.parentObject = itemHolder.transform;
			item.hasHitGround = false;
			item.isHeld = true;
			item.isHeldByEnemy = true;
			item.grabbable = false;
			isHoldingObject = true;
			itemDroped = false;
			item.GrabItemFromEnemy(__instance);
		}

		public void MovementAnimationSelector(Animator creatureAnimator, MaskedPlayerEnemy maskedEnemy)
		{
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			if (isCrouched.Value)
			{
				isDancing.Value = false;
				creatureAnimator.ResetTrigger("Dancing");
				isRunning.Value = false;
				creatureAnimator.ResetTrigger("Running");
				creatureAnimator.SetTrigger("Crouching");
				agent.speed = 1.9f;
			}
			else if (isRunning.Value)
			{
				isCrouched.Value = false;
				creatureAnimator.ResetTrigger("Crouching");
				isDancing.Value = false;
				creatureAnimator.ResetTrigger("Dancing");
				creatureAnimator.SetTrigger("Running");
				maskedEnemy.staminaTimer -= updateFrequency * 0.05f;
				agent.speed = 7f;
			}
			else if (isDancing.Value)
			{
				isCrouched.Value = false;
				creatureAnimator.ResetTrigger("Crouching");
				isRunning.Value = false;
				creatureAnimator.ResetTrigger("Running");
				creatureAnimator.SetTrigger("Dancing");
				__instance.SetDestinationToPosition(((Component)__instance).transform.position, false);
				agent.speed = 0f;
				Plugin.mls.LogInfo((object)"Dancing");
			}
			else
			{
				isCrouched.Value = false;
				creatureAnimator.ResetTrigger("Crouching");
				isDancing.Value = false;
				creatureAnimator.ResetTrigger("Dancing");
				isRunning.Value = false;
				creatureAnimator.ResetTrigger("Running");
				agent.speed = 3.8f;
			}
			if (maskedEnemy.staminaTimer >= 5f && !isStaminaDowned)
			{
				if (!isJumped.Value)
				{
					isJumped.Value = true;
				}
				else
				{
					creatureAnimator.ResetTrigger("FakeJump");
				}
				isRunning.Value = true;
			}
			if (maskedEnemy.staminaTimer < 0f)
			{
				isStaminaDowned = true;
				isRunning.Value = false;
				((EnemyAI)maskedEnemy).creatureAnimator.SetTrigger("Tired");
			}
			if (isStaminaDowned)
			{
				maskedEnemy.staminaTimer += updateFrequency * 0.2f;
				if (maskedEnemy.staminaTimer < 3f)
				{
					isStaminaDowned = false;
					((EnemyAI)maskedEnemy).creatureAnimator.ResetTrigger("Tired");
				}
			}
			if ((Object)(object)__instance.targetPlayer != (Object)null)
			{
				LookAtPos(((Component)((EnemyAI)maskedEnemy).targetPlayer).transform.position, 0.5f);
			}
		}

		public void ItemAnimationSelector(Animator creatureAnimator, EnemyAI __instance)
		{
			if (isHoldingObject)
			{
				upperBodyAnimationsWeight = Mathf.Lerp(upperBodyAnimationsWeight, 0.9f, 25f * updateFrequency);
				creatureAnimator.SetLayerWeight(creatureAnimator.GetLayerIndex("Item"), upperBodyAnimationsWeight);
			}
			else
			{
				upperBodyAnimationsWeight = Mathf.Lerp(upperBodyAnimationsWeight, 0f, 25f * updateFrequency);
				creatureAnimator.SetLayerWeight(creatureAnimator.GetLayerIndex("Item"), upperBodyAnimationsWeight);
			}
			if (isHoldingObject && heldGrabbable.itemProperties.twoHandedAnimation && !(heldGrabbable is ShotgunItem))
			{
				creatureAnimator.SetTrigger("HoldLung");
				creatureAnimator.ResetTrigger("HoldFlash");
				creatureAnimator.ResetTrigger("HoldShotgun");
				creatureAnimator.ResetTrigger("HoldOneItem");
			}
			else if (isHoldingObject && !heldGrabbable.itemProperties.twoHandedAnimation && heldGrabbable is FlashlightItem)
			{
				creatureAnimator.SetTrigger("HoldFlash");
				creatureAnimator.ResetTrigger("HoldLung");
				creatureAnimator.ResetTrigger("HoldShotgun");
				creatureAnimator.ResetTrigger("HoldOneItem");
			}
			else if (isHoldingObject && !heldGrabbable.itemProperties.twoHandedAnimation && !(heldGrabbable is ShotgunItem) && !(heldGrabbable is FlashlightItem) && !(heldGrabbable is Shovel))
			{
				creatureAnimator.SetTrigger("HoldOneItem");
				creatureAnimator.ResetTrigger("HoldFlash");
				creatureAnimator.ResetTrigger("HoldLung");
				creatureAnimator.ResetTrigger("HoldShotgun");
			}
			else if (isHoldingObject && !heldGrabbable.itemProperties.twoHandedAnimation && heldGrabbable is Shovel)
			{
				creatureAnimator.SetTrigger("HoldLung");
				creatureAnimator.ResetTrigger("HoldOneItem");
				creatureAnimator.ResetTrigger("HoldFlash");
				creatureAnimator.ResetTrigger("HoldShotgun");
			}
			else if (isHoldingObject && heldGrabbable is ShotgunItem)
			{
				creatureAnimator.SetTrigger("HoldShotgun");
				creatureAnimator.ResetTrigger("HoldFlash");
				creatureAnimator.ResetTrigger("HoldLung");
				creatureAnimator.ResetTrigger("HoldOneItem");
			}
			else if (!isHoldingObject)
			{
				creatureAnimator.ResetTrigger("HoldFlash");
				creatureAnimator.ResetTrigger("HoldLung");
				creatureAnimator.ResetTrigger("HoldShotgun");
				creatureAnimator.ResetTrigger("HoldOneItem");
			}
		}

		public void CheckPathRotating(NavMeshAgent agent, EnemyAI __instance)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: 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_00be: 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_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			maskedGoal = "checkpathrotating";
			if (!((NetworkBehaviour)this).IsHost)
			{
				return;
			}
			NavMeshPath val = new NavMeshPath();
			int num = 1;
			if (agent.pathPending)
			{
				return;
			}
			Vector3 val2;
			if (agent.remainingDistance < agent.stoppingDistance)
			{
				if (!agent.hasPath)
				{
					return;
				}
				Vector3 velocity = agent.velocity;
				val2 = velocity;
				if (((Vector3)(ref val2)).sqrMagnitude == 0f)
				{
					return;
				}
			}
			if (num >= agent.path.corners.Length || !((NetworkBehaviour)this).IsHost)
			{
				return;
			}
			Vector3 val3 = agent.path.corners[num] - ((Component)agent).transform.position;
			if (num + 1 < agent.path.corners.Length)
			{
				Vector3 val4 = agent.path.corners[num + 1] - agent.path.corners[num];
				float num2 = Vector3.Angle(val3, val4);
				if (num2 > 30f)
				{
					rotationTimer += updateFrequency;
					if (rotationTimer > 0f && rotationTimer < 0.5f)
					{
						if (angle1 == 0f)
						{
							angle1 = ((Component)__instance).transform.localEulerAngles.y + 10f;
						}
						Plugin.mls.LogInfo((object)("angle1: " + angle1));
						((Component)__instance).transform.localEulerAngles = new Vector3(((Component)__instance).transform.localEulerAngles.x, angle1, ((Component)__instance).transform.localEulerAngles.z);
					}
					else if ((double)rotationTimer > 0.5 && rotationTimer < 1.1f)
					{
						if (angle2 == 0f)
						{
							angle1 = ((Component)__instance).transform.localEulerAngles.y - 5f;
						}
						Plugin.mls.LogInfo((object)("angle2: " + angle2));
						((Component)__instance).transform.localEulerAngles = new Vector3(((Component)__instance).transform.localEulerAngles.x, angle1, ((Component)__instance).transform.localEulerAngles.z);
					}
					Plugin.mls.LogWarning((object)"Soon to rotate more than 30 degrees");
				}
				else
				{
					rotationTimer = 0f;
					angle1 = 0f;
					angle2 = 0f;
				}
			}
			val2 = val3;
			if (((Vector3)(ref val2)).magnitude <= agent.stoppingDistance)
			{
				Plugin.mls.LogWarning((object)"Almost reached corner, increase index to check next corner");
				num++;
			}
		}

		private void GrabWalkie()
		{
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_031f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0324: Unknown result type (might be due to invalid IL or missing references)
			//IL_0369: Unknown result type (might be due to invalid IL or missing references)
			//IL_0379: Unknown result type (might be due to invalid IL or missing references)
			//IL_0389: Unknown result type (might be due to invalid IL or missing references)
			//IL_038e: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ba: Unknown result type (might be due to invalid IL or missing references)
			if (!((NetworkBehaviour)this).IsHost || isHoldingObject || maskedFocus != 0 || (StartOfRound.Instance.allPlayerScripts.Count() < 2 && Plugin.skinWalkersIntegrated))
			{
				return;
			}
			List<WalkieTalkie> allWalkieTalkies = GlobalItemList.Instance.allWalkieTalkies;
			if (allWalkieTalkies.Count < 2)
			{
				return;
			}
			if ((Object)(object)walkieToGrab == (Object)null)
			{
				foreach (WalkieTalkie item in allWalkieTalkies)
				{
					if ((Object)(object)item == (Object)null)
					{
						if (countOfNullWalkieError < 1)
						{
							countOfNullWalkieError++;
							Plugin.mls.LogWarning((object)"walkie is Null (GrabWalkie) - dont worry about this, its usually happening because the walkie is not on the navmesh");
						}
						continue;
					}
					if ((Object)(object)((Component)item).transform == (Object)null)
					{
						Plugin.mls.LogError((object)"walkie.transform is Null (GrabWalkie)");
						continue;
					}
					_ = ((Component)item).transform.position;
					if (false)
					{
						Plugin.mls.LogError((object)"walkie.transform.position is Null (GrabWalkie)");
					}
					else if (__instance.CheckLineOfSightForPosition(((Component)item).transform.position, 60f, 60, -1f, (Transform)null) && !((GrabbableObject)item).isHeld && !((GrabbableObject)item).isHeldByEnemy)
					{
						maskedGoal = "spotted walkie talkie, going to go pick it up";
						walkieToGrab = (GrabbableObject)(object)item;
						maskedFocusInt.Value = 0;
						maskedActivityInt.Value = 8;
						break;
					}
				}
			}
			if ((Object)(object)walkieToGrab == (Object)null)
			{
				return;
			}
			if (walkieToGrab.isHeld || walkieToGrab.isHeldByEnemy)
			{
				walkieToGrab = null;
				isCrouched.Value = false;
				mustChangeFocus = true;
				mustChangeActivity = true;
				return;
			}
			float num = Vector3.Distance(((Component)__instance).transform.position, ((Component)walkieToGrab).transform.position);
			if (num < 1f && !isHoldingObject)
			{
				isCrouched.Value = true;
			}
			if (num > 0.5f)
			{
				Vector3 position = ((Component)walkieToGrab).transform.position;
				maskedGoal = "walkiing to selected walkie @ " + ((object)(Vector3)(ref position)).ToString();
				__instance.SetDestinationToPosition(((Component)walkieToGrab).transform.position, true);
				__instance.moveTowardsDestination = true;
				__instance.movingTowardsTargetPlayer = false;
			}
			if (num > 0.5f && num < 3f)
			{
				maskedEnemy.focusOnPosition = ((Component)walkieToGrab).transform.position;
				maskedEnemy.lookAtPositionTimer = 1.5f;
			}
			if (num < 0.9f && !isHoldingObject)
			{
				float num2 = Vector3.Angle(((Component)__instance).transform.forward, ((Component)walkieToGrab).transform.position - ((Component)__instance).transform.position);
				if (((Component)walkieToGrab).transform.position.y - maskedEnemy.headTiltTarget.position.y < 0f)
				{
					num2 *= -1f;
				}
				maskedEnemy.verticalLookAngle = num2;
				heldGrabbable = walkieToGrab;
				walkieToGrab.parentObject = itemHolder.transform;
				walkieToGrab.hasHitGround = false;
				walkieToGrab.isHeld = true;
				walkieToGrab.isHeldByEnemy = true;
				walkieToGrab.grabbable = false;
				isHoldingObject = true;
				itemDroped = false;
				walkieToGrab.GrabItemFromEnemy(__instance);
				if (isHoldingObject)
				{
					walkieToGrab = null;
					isCrouched.Value = false;
					mustChangeFocus = true;
					mustChangeActivity = true;
				}
			}
		}

		private void HoldWalkie()
		{
			maskedGoal = "holdwalkie";
			if ((Plugin.wendigosIntegrated || Plugin.skinWalkersIntegrated) && isHoldingObject && heldGrabbable is WalkieTalkie)
			{
				WalkieTalkie component = ((Component)heldGrabbable).GetComponent<WalkieTalkie>();
				walkieCooldown += updateFrequency;
				if (walkieCooldown < 1f)
				{
					creatureAnimator.ResetTrigger("UseWalkie");
					walkieUsed = false;
					walkieVoiceTransmitted = false;
					walkieTimer = 0f;
				}
				else if (walkieCooldown < 4f && walkieCooldown > 3f && !((GrabbableObject)component).isBeingUsed)
				{
					((GrabbableObject)component).isBeingUsed = true;
				}
				if (walkieCooldown > 10f)
				{
					UseWalkie();
				}
			}
		}

		private AudioClip wendigosClip()
		{
			List<AudioClip> list = Plugin.audioClips[maskedEnemy.mimickingPlayer.playerClientId];
			int count = list.Count;
			int index = Random.RandomRangeInt(0, count);
			return list[index];
		}

		private bool wendigosTimer()
		{
			if (currentTime >= timeToPlay)
			{
				currentTime = 0;
				return true;
			}
			currentTime++;
			return false;
		}

		public void UseWalkie()
		{
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Expected O, but got Unknown
			//IL_017e: Expected O, but got Unknown
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Expected O, but got Unknown
			//IL_0294: Expected O, but got Unknown
			maskedGoal = "usewalkie";
			if ((!Plugin.wendigosIntegrated && !Plugin.skinWalkersIntegrated) || !isHoldingObject || !(heldGrabbable is WalkieTalkie))
			{
				return;
			}
			walkieTimer += updateFrequency;
			WalkieTalkie component = ((Component)heldGrabbable).GetComponent<WalkieTalkie>();
			if (walkieTimer > 1f && !walkieUsed)
			{
				if (!((GrabbableObject)component).isBeingUsed)
				{
					((GrabbableObject)component).isBeingUsed = true;
					component.EnableWalkieTalkieListening(true);
					((Renderer)((GrabbableObject)component).mainObjectRenderer).sharedMaterial = component.onMaterial;
					((Behaviour)component.walkieTalkieLight).enabled = true;
					component.thisAudio.PlayOneShot(component.switchWalkieTalkiePowerOn);
				}
				walkieUsed = true;
			}
			if (walkieTimer > 1.5f && !walkieVoiceTransmitted)
			{
				Plugin.mls.LogInfo((object)"Walkie Voice Transmitted!");
				foreach (WalkieTalkie allWalkieTalky in GlobalItemList.Instance.allWalkieTalkies)
				{
					if (((GrabbableObject)allWalkieTalky).isBeingUsed)
					{
						allWalkieTalky.thisAudio.PlayOneShot(allWalkieTalky.startTransmissionSFX[Random.Range(0, allWalkieTalky.startTransmissionSFX.Length + 1)]);
					}
					if ((Object)((Component)heldGrabbable).gameObject != (Object)((Component)allWalkieTalky).gameObject && ((GrabbableObject)allWalkieTalky).isBeingUsed)
					{
						if (Plugin.skinWalkersIntegrated)
						{
							playSkinwalkersAudio(allWalkieTalky);
						}
						else if (Plugin.wendigosIntegrated)
						{
							allWalkieTalky.target.PlayOneShot(wendigosClip());
						}
					}
				}
				creatureAnimator.SetTrigger("UseWalkie");
				walkieVoiceTransmitted = true;
			}
			if (!(walkieTimer > 5f))
			{
				return;
			}
			foreach (WalkieTalkie allWalkieTalky2 in GlobalItemList.Instance.allWalkieTalkies)
			{
				if (((GrabbableObject)allWalkieTalky2).isBeingUsed)
				{
					allWalkieTalky2.thisAudio.PlayOneShot(allWalkieTalky2.stopTransmissionSFX[Random.Range(0, allWalkieTalky2.stopTransmissionSFX.Length + 1)]);
				}
				if ((Object)((Component)heldGrabbable).gameObject == (Object)((Component)allWalkieTalky2).gameObject && ((GrabbableObject)allWalkieTalky2).isBeingUsed)
				{
					((GrabbableObject)component).isBeingUsed = false;
					component.EnableWalkieTalkieListening(false);
					((Renderer)((GrabbableObject)component).mainObjectRenderer).sharedMaterial = component.offMaterial;
					((Behaviour)component.walkieTalkieLight).enabled = false;
					component.thisAudio.PlayOneShot(component.switchWalkieTalkiePowerOff);
				}
			}
			creatureAnimator.ResetTrigger("UseWalkie");
			walkieCooldown = 0f;
			walkieTimer = 0f;
		}

		private void playSkinwalkersAudio(WalkieTalkie walkie)
		{
			walkie.target.PlayOneShot(SkinwalkerModPersistent.Instance.GetSample());
		}

		public void AwayFromPlayer()
		{
			//IL_0031: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Expected O, but got Unknown
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: 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_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			maskedGoal = "awayfromplayer() method";
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			PlayerControllerB[] array = allPlayerScripts;
			foreach (PlayerControllerB val in array)
			{
				float num = Vector3.Distance(((Component)__instance).transform.position, ((Component)val).transform.position);
				if (!(num < float.PositiveInfinity))
				{
					continue;
				}
				nearestPlayer = val;
				float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position);
				if (num2 < 4f && (Object)__instance.targetPlayer != (Object)null)
				{
					Vector3 val2 = ((Component)this).transform.position - ((Component)val).transform.position;
					Vector3 position = ((Component)this).transform.position;
					Vector3 val3 = val2;
					Vector3 val4 = position + ((Vector3)(ref val3)).normalized * 5f;
					if (originDestination != agent.destination)
					{
						originDestination = agent.destination;
					}
					if (Vector3.Distance(originDestination, agent.destination) < 1.5f)
					{
						originTimer += updateFrequency;
					}
					if (originTimer > 3.5f)
					{
						if (__instance.isOutside)
						{
							__instance.SetDestinationToPosition(maskedEnemy.shipHidingSpot, true);
						}
						else
						{
							maskedFocusInt.Value = 0;
							maskedActivityInt.Value = 1;
						}
						originTimer = 0f;
					}
					__instance.SetDestinationToPosition(val4, true);
				}
				else
				{
					__instance.SetDestinationToPosition(originDestination, true);
				}
			}
		}

		public void PlayerLikeAction()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: 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_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			float num = Vector3.Distance(((Component)this).transform.position, ((Component)nearestPlayer).transform.position);
			if (num < 4f && (Object)__instance.targetPlayer != (Object)null)
			{
				Vector3 val = ((Component)this).transform.position - ((Component)nearestPlayer).transform.position;
				Vector3 position = ((Component)this).transform.position;
				Vector3 val2 = val;
				Vector3 val3 = position + ((Vector3)(ref val2)).normalized * 5f;
				if (originDestination != agent.destination)
				{
					originDestination = agent.destination;
				}
				if (Vector3.Distance(originDestination, agent.destination) < 1.5f)
				{
					originTimer += updateFrequency;
				}
				if (originTimer > 3.5f)
				{
					if (__instance.isOutside)
					{
						__instance.SetDestinationToPosition(maskedEnemy.shipHidingSpot, true);
					}
					else
					{
						maskedFocusInt.Value = 0;
						maskedActivityInt.Value = 1;
					}
					originTimer = 0f;
				}
				__instance.SetDestinationToPosition(val3, true);
			}
			else
			{
				__instance.SetDestinationToPosition(originDestination, true);
			}
		}

		public void MaskedCunning()
		{
			//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_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_046a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0476: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_051e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0556: Unknown result type (might be due to invalid IL or missing references)
			//IL_055b: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)breakerBox != (Object)null && breakerBox.isPowerOn)
			{
				noMoreBreakerBox = false;
			}
			Vector3 position;
			if (maskedFocus == Focus.Terminal)
			{
				if (!noMoreTerminal && Plugin.useTerminal)
				{
					UsingTerminal();
				}
				else
				{
					mustChangeFocus = true;
				}
			}
			else if (maskedFocus == Focus.BreakerBox)
			{
				if (seenCheckNum <= 0)
				{
					Plugin.mls.LogWarning((object)"BreakerBox was seen, but could not be reached! Not Critical, but please report this!");
					mustChangeFocus = true;
					mustChangeActivity = true;
					noMoreBreakerBox = true;
				}
				if (breakerBoxDistance < 15f && breakerBoxDistance > 3.5f && Plugin.isBreakerBoxBeingUsed)
				{
					Plugin.mls.LogDebug((object)"BreakerBox is being used by another entity");
					noMoreBreakerBox = true;
					mustChangeFocus = true;
					mustChangeActivity = true;
				}
				else if (!noMoreBreakerBox)
				{
					if (!(breakerBoxDistance < 40f) && !noMoreTerminal)
					{
						return;
					}
					position = ((Component)breakerBox).transform.position;
					maskedGoal = "walking to breaker box (" + ((object)(Vector3)(ref position)).ToString() + ")";
					((EnemyAI)maskedEnemy).SetDestinationToPosition(breakerPosition, false);
					((EnemyAI)maskedEnemy).moveTowardsDestination = true;
					breakerBoxDistance = Vector3.Distance(((Component)__instance).transform.position, breakerPosition);
					if (breakerBoxDistance < 0.5f && !isUsingBreakerBox)
					{
						Plugin.isBreakerBoxBeingUsed = true;
						maskedGoal = "using breaker box";
						maskedEnemy.LookAtFocusedPosition();
						isUsingBreakerBox = true;
						creatureAnimator.ResetTrigger("Crouching");
						isCrouched.Value = false;
						agent.speed = 0f;
						creatureAnimator.ResetTrigger("IsMoving");
						if (breakerBox.isPowerOn)
						{
							breakerBoxSwitchLogic(breakerBoxDistance, on: false);
						}
						else
						{
							breakerBoxSwitchLogic(breakerBoxDistance, on: true);
							((EnemyAI)maskedEnemy).SetDestinationToPosition(((Component)terminal).transform.position, false);
						}
						Plugin.isBreakerBoxBeingUsed = false;
					}
				}
				else
				{
					mustChangeFocus = true;
				}
			}
			else
			{
				if (maskedFocus != Focus.Items)
				{
					return;
				}
				if (!noMoreItems)
				{
					if (itemsToHide == 0)
					{
						maskedGoal = "changing focus as we have stolen enough items";
						noMoreItems = true;
						mustChangeFocus = true;
						return;
					}
					if (!isHoldingObject)
					{
						if ((Object)(object)nearestGrabbable == (Object)null)
						{
							maskedGoal = "cant find any grabbable items, switching focus";
							noMoreItems = true;
							mustChangeFocus = true;
						}
						else
						{
							maskedGoal = "grabbing item from inside ship";
							GrabItem();
						}
						return;
					}
					isCrouched.Value = false;
					if (!isHoldingObject || !((EnemyAI)maskedEnemy).isOutside || !((NetworkBehaviour)this).IsHost || bushes == null)
					{
						if (isHoldingObject && ((EnemyAI)maskedEnemy).isOutside && bushes == null)
						{
							Plugin.mls.LogDebug((object)"Masked Cunning cannot find any bushes on this moon!");
							noMoreItems = true;
							mustChangeFocus = true;
						}
						return;
					}
					GameObject[] array = bushes;
					array.ToList().RemoveAll((GameObject bush) => bush.GetComponent<BushSystem>().bushWithItem);
					if (array.Length == 0)
					{
						Plugin.mls.LogDebug((object)"all bushes have an item, dropping item and changing focus");
						dropItem.Value = true;
						DropItem();
						noMoreItems = true;
						mustChangeFocus = true;
					}
					GameObject[] array2 = array;
					foreach (GameObject val in array2)
					{
						bushDistance = Vector3.Distance(((Component)__instance).transform.position, val.transform.position);
						if (bushDistance < float.PositiveInfinity && !val.GetComponent<BushSystem>().bushWithItem)
						{
							if (bushDistance > 2f && bushDistance < float.PositiveInfinity && !val.GetComponent<BushSystem>().bushWithItem)
							{
								position = val.transform.position;
								maskedGoal = "walking to bush (" + ((object)(Vector3)(ref position)).ToString() + ")";
								((EnemyAI)maskedEnemy).SetDestinationToPosition(val.transform.position, true);
								moveSpecial = true;
							}
							if (bushDistance < 2f)
							{
								position = val.transform.position;
								maskedGoal = "hiding item in bush (" + ((object)(Vector3)(ref position)).ToString() + ")";
								Plugin.mls.LogDebug((object)"Cunning Is Hiding an Item");
								itemSystem.hidedByMasked = true;
								dropItem.Value = true;
								DropItem();
								itemsToHide--;
								mustChangeFocus = true;
								val.GetComponent<BushSystem>().bushWithItem = true;
							}
						}
					}
				}
				else
				{
					mustChangeFocus = true;
				}
			}
		}

		public void MaskedDeceiving()
		{
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: 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)
			if (maskedFocus == Focus.Terminal)
			{
				if (!noMoreTerminal && Plugin.useTerminal)
				{
					UsingTerminal();
				}
				else
				{
					mustChangeFocus = true;
				}
			}
			else if (maskedFocus == Focus.Items)
			{
				if (!noMoreItems)
				{
					if (!isHoldingObject)
					{
						if ((Object)(object)closestGrabbable == (Object)null)
						{
							maskedGoal = "locating new grabbable item";
							noMoreItems = true;
							mustChangeFocus = true;
						}
						else
						{
							maskedGoal = "grabbing nearest item";
							GrabItem();
						}
						return;
					}
					isCrouched.Value = false;
					if (((EnemyAI)maskedEnemy).isInsidePlayerShip)
					{
						float num = Vector3.Distance(((Component)this).transform.position, ((Component)terminal).transform.position);
						if (num > 6f)
						{
							maskedGoal = "heading to player ship to drop an item";
							((EnemyAI)maskedEnemy).SetDestinationToPosition(((Component)terminal).transform.position, false);
						}
						else if (num < 6f)
						{
							maskedGoal = "dropping item in player ship";
							dropItem.Value = true;
							DropItem();
						}
					}
					else
					{
						findLockerAudio();
					}
				}
				else
				{
					mustChangeFocus = true;
				}
			}
			else
			{
				if (maskedFocus != Focus.Player)
				{
					return;
				}
				if (distanceToPlayer >= 17f)
				{
					PlayerControllerB closestPlayer = __instance.GetClosestPlayer(false, false, false);
					__instance.SetMovingTowardsTargetPlayer(closestPlayer);
					return;
				}
				if (enableDance)
				{
					isDancing.Value = true;
					maskedEnemy.stopAndStareTimer = 0.9f;
					agent.speed = 0f;
				}
				if (distanceToPlayer < 17f && __instance.targetPlayer.performingEmote && maxDanceCount.Value > 0)
				{
					maskedGoal = "emoting with nearby player";
					if (GameNetworkManager.Instance.isHostingGame && !enableDance)
					{
						LethalNetworkVariable<int> val = maxDanceCount;
						val.Value -= 1;
						randomPose = 1;
						enableDance = true;
					}
					stopAndTbagTimer = 0.9f;
					__instance.agent.speed = 0f;
				}
				else if (isDancing.Value && GameNetworkManager.Instance.isHostingGame)
				{
					isDancing.Value = false;
					stopAndTbagTimer = 0.4f;
					randomPose = 1;
					enableDance = false;
				}
				mustChangeFocus = true;
			}
		}

		public void MaskedStealthy()
		{
			if (maskedFocus == Focus.Hiding)
			{
				if (((NetworkBehaviour)this).IsHost)
				{
					maskedGoal = "going AwayFromPlayer()";
					AwayFromPlayer();
				}
			}
			else if (maskedFocus == Focus.Mimicking && ((NetworkBehaviour)this).IsHost)
			{
				maskedGoal = "doing PlayerLikeAction()";
				PlayerLikeAction();
			}
		}

		public void MaskedAggressive()
		{
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			if (maskedFocus == Focus.Items)
			{
				if (noMoreItems)
				{
					return;
				}
				if (GlobalItemList.Instance.isShotgun)
				{
					maskedGoal = "grabbing a shotgun";
					FindAndGrabShotgun();
					if (isHoldingObject && closestGrabbable is ShotgunItem)
					{
						maskedGoal = "using a shotgun";
						UseItem(((EnemyAI)maskedEnemy).targetPlayer, distanceToPlayer);
					}
				}
				else
				{
					noMoreItems = true;
					mustChangeFocus = true;
					mustChangeActivity = true;
				}
			}
			else