Decompiled source of BetterBots v0.1.0

BetterBots.dll

Decompiled 2 months ago
using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using AIGraph;
using Agents;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using BepInEx.Unity.IL2CPP.Utils.Collections;
using BetterBots.Attributes;
using BetterBots.Components;
using BetterBots.Data;
using BetterBots.Managers;
using BetterBots.PlayerBotActionDebugs;
using BetterBots.Utils;
using ChainedPuzzles;
using Enemies;
using GTFO.API;
using GameData;
using Gear;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.Attributes;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Il2CppSystem.Reflection;
using LevelGeneration;
using Microsoft.CodeAnalysis;
using Player;
using SNetwork;
using UnityEngine;
using UnityEngine.AI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("BetterBots")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BetterBots")]
[assembly: AssemblyTitle("BetterBots")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
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;
		}
	}
}
namespace BetterBots
{
	[BepInPlugin("com.east.bb", "BetterBots", "0.1.0")]
	public class BetterBots : BasePlugin
	{
		public static class Settings
		{
			public const float ADDITIONAL_BULLET_DAMAGE = 0.01f;

			public const float DAMAGE_RESISTANCE_MULTIPLIER = 0.01f;
		}

		public static Harmony HarmonyMain;

		private const string GUID = "com.east.bb";

		private const string Name = "BetterBots";

		private const string Version = "0.1.0";

		public override void Load()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			BBLog.Message("<<<<---------Launcing Better Bots------------>>>");
			new Harmony("com.east.bb").PatchAll();
			EventAPI.OnExpeditionStarted += MonoBehaviorFixed.Initialize;
		}

		public static void OnStartGame()
		{
			BBLog.Message("<<<<---------OnStartGame Better Bots------------>>>");
			LaunchComponents();
			OnStarted();
		}

		private static void OnStarted()
		{
			ConfigurationPluginManager.Initialized();
		}

		private static void LaunchComponents()
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected O, but got Unknown
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			foreach (Type type in types)
			{
				if (!(type.BaseType != null))
				{
					continue;
				}
				Type typeFromHandle = typeof(MonoBehaviorFixed);
				if (!(type.BaseType == typeFromHandle) && !typeFromHandle.IsSubclassOf(typeFromHandle))
				{
					continue;
				}
				ClassInjector.RegisterTypeInIl2Cpp(type);
				IL2CPP_ComponentDescriptorAttribute customAttribute = type.GetCustomAttribute<IL2CPP_ComponentDescriptorAttribute>();
				if (customAttribute != null && customAttribute.m_launchOnStartLoad)
				{
					GameObject val = new GameObject();
					val.AddComponent(Il2CppType.From(type));
					BBLog.Message("Adding Component " + type);
					if (customAttribute.m_dontDestroyOnLoad)
					{
						Object.DontDestroyOnLoad((Object)(object)val);
					}
				}
			}
		}
	}
	[GeneratedCode("VersionInfoGenerator", "2.0.0+git50a4b1a-master")]
	[CompilerGenerated]
	internal static class VersionInfo
	{
		public const string RootNamespace = "BetterBots";

		public const string Version = "1.0.0";

		public const string VersionPrerelease = null;

		public const string VersionMetadata = null;

		public const string SemVer = "1.0.0";

		public const string GitRevShort = null;

		public const string GitRevLong = null;

		public const string GitBranch = null;

		public const string GitTag = null;

		public const bool GitIsDirty = false;
	}
}
namespace BetterBots.Utils
{
	public static class BBLog
	{
		private static readonly ManualLogSource logger;

		private static bool m_enableDebugs;

		static BBLog()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Expected O, but got Unknown
			logger = new ManualLogSource("BETTER-BETTER-IMPROVED");
			m_enableDebugs = true;
			Logger.Sources.Add((ILogSource)(object)logger);
		}

		public static void Verbose(object msg)
		{
			logger.LogInfo(msg);
		}

		public static void Debug(object msg)
		{
			if (m_enableDebugs)
			{
				logger.LogDebug(msg);
			}
		}

		public static void Message(object msg)
		{
			if (m_enableDebugs)
			{
				logger.LogMessage(msg);
			}
		}

		public static void Error(object msg)
		{
			if (m_enableDebugs)
			{
				logger.LogError(msg);
			}
		}

		public static void Warn(object msg)
		{
			if (m_enableDebugs)
			{
				logger.LogWarning(msg);
			}
		}
	}
	public static class CppUtils
	{
		public static List<T> ToList<T>(this List<T> cppList)
		{
			List<T> list = new List<T>();
			for (int i = 0; i < cppList.Count; i++)
			{
				list.Add(cppList[i]);
			}
			return list;
		}
	}
	public static class PlayerAgentExtraExtensions
	{
		public static bool CanSeePosition(this PlayerAgent player, Vector3 eyePos, Vector3 targetPos, int layerMask, out RaycastHit hitInfo)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			Ray val = default(Ray);
			((Ray)(ref val)).origin = eyePos;
			Ray val2 = val;
			Vector3 val3 = targetPos - eyePos;
			float magnitude = ((Vector3)(ref val3)).magnitude;
			val3 = (((Ray)(ref val2)).direction = val3 / magnitude);
			return !Physics.Raycast(val2, ref hitInfo, magnitude, layerMask);
		}

		public static bool CanSeeObject(this PlayerAgent player, Vector3 eyePos, GameObject targetObj)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = targetObj.transform.position;
			if (!player.CanSeePosition(eyePos, position, LayerManager.MASK_WORLD, out var hitInfo) && (Object)(object)((Component)((RaycastHit)(ref hitInfo)).transform).gameObject != (Object)(object)targetObj)
			{
				return ((RaycastHit)(ref hitInfo)).transform.IsChildOf(targetObj.transform);
			}
			return true;
		}
	}
	public static class TypeExtensions
	{
		public static bool IsTypeMonoBehaviorFixed(Type type)
		{
			if (type == typeof(MonoBehaviorFixed))
			{
				return true;
			}
			if (type.BaseType == typeof(MonoBehaviorFixed) || type.IsSubclassOf(typeof(MonoBehaviorFixed)))
			{
				return true;
			}
			return false;
		}
	}
}
namespace BetterBots.PlayerBotActionDebugs
{
	public class PBAD_Attack : PlayerBotActionDebug<PlayerBotActionAttack>
	{
		protected override void PostAdditionalFields(PlayerBotActionAttack action)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			StanceEnum stance = action.m_desc.Stance;
			AppendInformation("Posture", ((object)(StanceEnum)(ref stance)).ToString());
			PostureEnum posture = action.m_desc.Posture;
			AppendInformation("Stance", ((object)(PostureEnum)(ref posture)).ToString());
			AppendInformation("Haste", "<color=orange>" + action.m_desc.Haste + "</color>");
			AttackMeansEnum means = action.m_desc.Means;
			AppendInformation("Means", "<color=#FFA8A8>" + ((object)(AttackMeansEnum)(ref means)).ToString() + "</color>");
		}
	}
	public class PBAD_CarryExpeditionItem : PlayerBotActionDebug<PlayerBotActionCarryExpeditionItem>
	{
		protected override void PostAdditionalFields(PlayerBotActionCarryExpeditionItem action)
		{
			//IL_0011: 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_001c: Unknown result type (might be due to invalid IL or missing references)
			if (action.m_desc != null)
			{
				Color yellow = Color.yellow;
				State state = action.m_state;
				AppendColorInformation("State", yellow, ((object)(State)(ref state)).ToString());
				if ((Object)(object)action.m_desc.TargetItem != (Object)null)
				{
					AppendInformation("TargetItem", "<color=yellow>" + ((Item)action.m_desc.TargetItem).PublicName + "</color>");
				}
				else
				{
					AppendInformation("TargetItem", "<color=red>NONE</color>");
				}
				AppendInformation("AllowIdleDrop", action.m_desc.AllowIdleDrop.ToString());
				AppendInformation("MaxLeaderDistance", action.m_desc.MaxLeaderDistance.ToString());
				AppendInformation("HoldPrio", action.m_desc.HoldPrio.ToString());
			}
		}
	}
	public class PBAD_CollectItem : PlayerBotActionDebug<PlayerBotActionCollectItem>
	{
		protected override void PostAdditionalFields(PlayerBotActionCollectItem action)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			State state = action.m_state;
			AppendInformation("State", ((object)(State)(ref state)).ToString());
			if ((Object)(object)action.m_desc.TargetItem != (Object)null)
			{
				AppendInformation("TargetItem", "<color=yellow>" + action.m_desc.TargetItem.PublicName + "</color>");
			}
			else
			{
				AppendInformation("TargetItem", "<color=red>NONE</color>");
			}
			if ((Object)(object)action.m_desc.TargetContainer != (Object)null)
			{
				eResourceContainerStatus status = action.m_desc.TargetContainer.m_core.Status;
				AppendInformation("TargetContainer Status", ((object)(eResourceContainerStatus)(ref status)).ToString());
				AppendInformation("TargetContainer Name", ((Object)action.m_desc.TargetContainer).name.ToString());
			}
		}
	}
	public class PBAD_Follow : PlayerBotActionDebug<PlayerBotActionFollow>
	{
		protected override void PostAdditionalFields(PlayerBotActionFollow action)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			State state = action.m_state;
			AppendInformation("State", ((object)(State)(ref state)).ToString());
			AppendInformation("Client", ((Object)action.m_desc.Client.Owner).ToString());
			AppendInformation("MaxDistance", action.m_desc.MaxDistance.ToString());
			AppendInformation("FormationPrio", action.m_desc.FormationPrio.ToString());
		}
	}
	public class PBAD_Melee : PlayerBotActionDebug<PlayerBotActionMelee>
	{
		protected override void PostAdditionalFields(PlayerBotActionMelee action)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			StateEnum state = action.m_desc.State;
			AppendInformation("State", ((object)(StateEnum)(ref state)).ToString());
			AppendInformation("Strike", action.m_desc.Strike.ToString());
			AppendInformation("IsCharged", action.m_desc.IsCharged.ToString());
			AppendInformation("ChargeDuraction", Mathf.Max(Time.time - action.m_chargeStartTime, 0f).ToString());
		}
	}
	public class PBAD_UseBioScan : PlayerBotActionDebug<PlayerBotActionUseBioscan>
	{
		protected override void PostAdditionalFields(PlayerBotActionUseBioscan action)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			State state = action.m_state;
			AppendInformation("State", ((object)(State)(ref state)).ToString());
		}
	}
	public class PBAD_UseFireArm : PlayerBotActionDebug<PlayerBotActionUseFirearm>
	{
		protected override void PostAdditionalFields(PlayerBotActionUseFirearm action)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: 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_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			bool flag = action.TestFriendlyFire();
			AppendColorInformation("TestFriendlyFire", flag ? Color.green : Color.red, flag);
			AppendColorInformation("OpenFire", action.m_desc.OpenFire ? Color.green : Color.red, action.m_desc.OpenFire);
			AppendColorInformation("m_lookAction", (action.m_lookAction != null) ? Color.green : Color.red, (action.m_lookAction != null) ? "Active" : "Not Active");
			AppendColorInformation("m_aimIsBlending", ((PlayerBotActionBase)action).m_agent.SyncIK.m_aimIsBlending ? Color.green : Color.red, ((PlayerBotActionBase)action).m_agent.SyncIK.m_aimIsBlending);
			AppendColorInformation("requireVisibility", action.m_desc.requireVisibility ? Color.green : Color.red, "action.m_desc.requireVisibility");
		}
	}
	public class PlayerBotActionDebug<PA> : PlayerBotActionDebugBase where PA : PlayerBotActionBase
	{
		public override Type ActionType => Il2CppType.Of<PA>();

		public override string ActionName => ((MemberInfo)Il2CppType.Of<PA>()).Name;

		public sealed override void PrintFields(PlayerBotActionBase m_actionBase)
		{
			base.PrintFields(m_actionBase);
			PostAdditionalFields(((Il2CppObjectBase)m_actionBase).TryCast<PA>());
		}

		protected virtual void PostAdditionalFields(PA action)
		{
		}
	}
	public abstract class PlayerBotActionDebugBase
	{
		private string m_currentMessage;

		public virtual Type ActionType => null;

		public virtual string ActionName => "UNKNOWN";

		public string Message => m_currentMessage;

		public virtual void PrintFields(PlayerBotActionBase m_actionBase)
		{
			ResetMessage();
			SetTitle(ActionName);
			PrintBaseFields(m_actionBase);
		}

		protected void PrintBaseFields(PlayerBotActionBase m_actionBase)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			if (m_actionBase.m_descBase != null)
			{
				StatusType status = m_actionBase.m_descBase.Status;
				AppendInformation("Status", ((object)(StatusType)(ref status)).ToString());
				AppendInformation("Priority", "<color=orange>" + m_actionBase.m_descBase.Prio + "</color>");
			}
			else
			{
				ApendErrorInformation("Action Descriptor is null!!");
			}
		}

		private void SetTitle(string title)
		{
			m_currentMessage = m_currentMessage + "\n\t" + title;
		}

		private void ResetMessage()
		{
			m_currentMessage = string.Empty;
		}

		protected void AppendInformation(string fieldName, string information)
		{
			m_currentMessage = m_currentMessage + "\n\t\t" + fieldName + " : " + information;
		}

		protected void AppendInformation(string fieldName, object informationObject)
		{
			AppendInformation(fieldName, informationObject.ToString());
		}

		protected void AppendColorInformation(string fieldName, Color color, string information)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			m_currentMessage = m_currentMessage + "\n\t\t" + fieldName + " : <color=#" + ColorUtility.ToHtmlStringRGBA(color) + ">" + information + "</color>";
		}

		protected void AppendColorInformation(string fieldName, Color color, object informationObj)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			AppendColorInformation(fieldName, color, informationObj.ToString());
		}

		protected void ApendErrorInformation(string information)
		{
			m_currentMessage = m_currentMessage + "\n\t\t<color=red>" + information + "</color>";
		}
	}
	public enum PlayerBotActionType
	{
		Idle,
		Follow,
		Attack,
		Revive,
		ShareResource,
		UseBioScan,
		CollectItem,
		CarryExpedtionItem,
		Melee,
		UseFireArm
	}
}
namespace BetterBots.Patches.ManualPatches
{
	[HarmonyPatch(typeof(AgentModifierManager))]
	internal class Patch_AgentModifierManager
	{
		[HarmonyPrefix]
		[HarmonyPatch("ApplyModifier")]
		private static void Pre_ApplyModifier(Agent agent, AgentModifier modifier, ref float value)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Invalid comparison between Unknown and I4
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Invalid comparison between Unknown and I4
			if ((Object)(object)agent != (Object)null)
			{
				PlayerAgent val = ((Il2CppObjectBase)agent).TryCast<PlayerAgent>();
				if ((Object)(object)val != (Object)null && (Object)(object)val.Owner != (Object)null && val.Owner.IsBot && ((int)modifier == 6 || (int)modifier == 7))
				{
					value = PlayerBotManagerExtended.SubtractBonusMulitplier(value, 0.01f);
				}
			}
		}
	}
	[HarmonyPatch(typeof(BulletWeapon))]
	internal class Patch_BulletWeapon
	{
		[HarmonyPrefix]
		[HarmonyPatch("BulletHit")]
		private static bool Pre_BulletHit(ref WeaponHitData weaponRayData, bool doDamage)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			RaycastHit rayHit = weaponRayData.rayHit;
			if ((Object)(object)((RaycastHit)(ref rayHit)).collider != (Object)null)
			{
				rayHit = weaponRayData.rayHit;
				if ((Object)(object)((Component)((RaycastHit)(ref rayHit)).collider).gameObject != (Object)null && weaponRayData.owner.Owner.IsBot)
				{
					rayHit = weaponRayData.rayHit;
					if (CustomExtensions.IsInLayerMask(((Component)((RaycastHit)(ref rayHit)).collider).gameObject, LayerMask.op_Implicit(LayerMask.GetMask(new string[1] { "PlayerSynced" }))))
					{
						return false;
					}
				}
			}
			if (SNet.IsMaster && (Object)(object)weaponRayData.owner != (Object)null && weaponRayData.owner.Owner.IsBot)
			{
				weaponRayData.damage = PlayerBotManagerExtended.AddBonusMultiplier(weaponRayData.damage, 0.01f);
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(BulletWeaponSynced))]
	internal class Patch_BullletWeaponSynced
	{
		[HarmonyPrefix]
		[HarmonyPatch("Fire")]
		private static void Pre_Fire(BulletWeaponSynced __instance)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			if (SNet.IsMaster && ConfigurationPluginManager.BetterBotsAimBot && PlayerBotManagerExtended.TryToHitEnemy(((Item)__instance).Owner, out var hitDir, out var _))
			{
				((Agent)((Item)__instance).Owner).TargetLookDir = hitDir;
				((ItemEquippable)__instance).MuzzleAlign.forward = ((Vector3)(ref hitDir)).normalized;
			}
		}
	}
	[HarmonyPatch(typeof(Dam_SyncedDamageBase))]
	public class Patch_Dam_SyncedDamageBase
	{
		[HarmonyPrefix]
		[HarmonyPatch("BulletDamage")]
		private static bool Pre_BulletDamage(Dam_SyncedDamageBase __instance, float dam, Agent sourceAgent)
		{
			if ((Object)(object)sourceAgent != (Object)null)
			{
				PlayerAgent val = ((Il2CppObjectBase)sourceAgent).TryCast<PlayerAgent>();
				if ((Object)(object)val != (Object)null && val.Owner.IsBot)
				{
					Agent baseAgent = __instance.GetBaseAgent();
					if ((Object)(object)baseAgent != (Object)null && (Object)(object)((Il2CppObjectBase)baseAgent).TryCast<PlayerAgent>() != (Object)null)
					{
						return false;
					}
				}
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(DramaManager))]
	internal class Patch_DramaManager
	{
		[HarmonyPostfix]
		[HarmonyPatch("CheckLoudTransition")]
		private static void PostCheckLoudTransition(DRAMA_State newState)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			bool hasLoudStateEnter = false;
			if (newState - 5 <= 3)
			{
				hasLoudStateEnter = true;
			}
			PlayerBotManagerExtended.HasLoudStateEnter = hasLoudStateEnter;
		}
	}
	[HarmonyPatch(typeof(PlayerAgent))]
	internal class Patch_PlayerAgent
	{
		private const bool m_recordBot = true;

		[HarmonyPostfix]
		[HarmonyPatch("Setup")]
		private static void PostSetup(PlayerAgent __instance)
		{
			if (__instance.Owner.IsBot && (Object)(object)((Component)__instance).gameObject.GetComponent<BotRecorder>() == (Object)null)
			{
				((Component)__instance).gameObject.AddComponent<BotRecorder>();
				BBLog.Message("BotRecoder Setup for " + __instance.Owner.NickName);
			}
		}
	}
	[HarmonyPatch(typeof(PlayerAIBot))]
	internal class Patch_PlayerAIBot
	{
		[HarmonyPostfix]
		[HarmonyPatch("WantsCrouch")]
		private static void Post_WantsToCrouch(PlayerAIBot __instance, ref bool __result)
		{
			BotRecorder component = ((Component)__instance.Agent).gameObject.GetComponent<BotRecorder>();
			if ((Object)(object)component != (Object)null && component.SneakingRestricted)
			{
				__result = false;
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("HasTwitcherNearby")]
		private static void Post_HasTwitcherNearby(PlayerAIBot __instance, ref bool __result)
		{
			BotRecorder component = ((Component)__instance.Agent).gameObject.GetComponent<BotRecorder>();
			if ((Object)(object)component != (Object)null && component.SneakingRestricted)
			{
				__result = false;
			}
		}
	}
	[HarmonyPatch(typeof(PlayerBotActionAttack))]
	internal class Patch_PlayerBotActionAttack
	{
		[HarmonyPostfix]
		[HarmonyPatch("ChooseAttackOption")]
		private static void Post_ChooseAttackOption(PlayerBotActionAttack __instance, ref bool __result)
		{
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			if (!__result)
			{
				return;
			}
			BotRecorder component = ((Component)((PlayerBotActionBase)__instance).m_agent).gameObject.GetComponent<BotRecorder>();
			if (!((Object)(object)component != (Object)null))
			{
				return;
			}
			ItemEquippable bestItemToUse;
			if (PlayerBotManagerExtended.LoudStateIsEarlyToMelee)
			{
				if (PlayerBotManagerExtended.TryGetBestMeleeWeapon(PlayerBackpackManager.GetBackpack(((PlayerBotActionBase)__instance).m_agent.Owner), out MeleeWeaponThirdPerson weapon))
				{
					__instance.m_currentAttackOption.Means = (AttackMeansEnum)1;
					__instance.m_currentAttackOption.Prio = 100000f;
					__instance.m_currentAttackOption.ItemToUse = (ItemEquippable)(object)weapon;
					__instance.m_currentAttackOption.Stance = (StanceEnum)2;
				}
			}
			else if (component.Brain.HasAmmo() && component.Brain.ForceBulletsOnly && PlayerBotManagerExtended.TryToGetBestWeapon(((PlayerBotActionBase)__instance).m_agent, out bestItemToUse) && (int)__instance.m_currentAttackOption.Means != 4)
			{
				__instance.m_currentAttackOption.Means = (AttackMeansEnum)4;
				__instance.m_currentAttackOption.Prio = 100000f;
				__instance.m_currentAttackOption.ItemToUse = bestItemToUse;
				__instance.m_currentAttackOption.Stance = (StanceEnum)1;
			}
		}
	}
	[HarmonyPatch(typeof(PlayerBotActionBioscanProximity))]
	internal class Patch_PlayerBotActionBioscanProximity
	{
		[HarmonyPostfix]
		[HarmonyPatch("VerifyScanner")]
		private static void Post_VerifyScanner(PlayerBotActionBioscanProximity __instance, ref bool __result)
		{
			if ((Object)(object)__instance.m_desc.Bioscan != (Object)null && __instance.m_desc.Bioscan.IsExitPuzzle)
			{
				__result = true;
			}
		}
	}
	[HarmonyPatch(typeof(PlayerBotActionCarryExpeditionItem))]
	internal class Patch_PlayerBotActionCarryExpeditionItem
	{
		[HarmonyPostfix]
		[HarmonyPatch("UpdateStateIdle")]
		private static void Post_UpdateStateIdle(PlayerBotActionCarryExpeditionItem __instance)
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			BotRecorder component = ((Component)((PlayerBotActionBase)__instance).m_agent).gameObject.GetComponent<BotRecorder>();
			if ((Object)(object)component != (Object)null && !component.IsDangerousToCollectExpeditionItem() && (!component.m_firstExpeditionItemTimer || component.m_abortExpeditionItemTimer + 3f < Time.time) && !__instance.m_isCarrying && !PlayerBotManagerExtended.IsBotCurrentlyBusyWithAction(((PlayerBotActionBase)__instance).m_bot))
			{
				__instance.m_collectAction.TargetPosition = ((Component)__instance.m_desc.TargetItem).transform.position;
				if (((PlayerBotActionBase)__instance).m_bot.RequestAction((Descriptor)(object)__instance.m_collectAction))
				{
					__instance.SetState((State)1);
				}
			}
		}
	}
	[HarmonyPatch(typeof(PlayerBotActionUseBioscan))]
	internal class Patch_PlayerBotActionUseBioscan
	{
		[HarmonyPostfix]
		[HarmonyPatch("VerifyScanner")]
		private static void Post_VerifyScanner(PlayerBotActionUseBioscan __instance, ref bool __result)
		{
			if ((Object)(object)__instance.m_desc.Bioscan != (Object)null && __instance.m_desc.Bioscan.IsExitPuzzle)
			{
				__result = true;
			}
		}
	}
	[HarmonyPatch(typeof(PlayerBotActionUseFirearm))]
	internal class Patch_PlayerBotActionUseFireArm
	{
		[HarmonyPrefix]
		[HarmonyPatch("TestFriendlyFire")]
		private static bool Pre_TestFriendlyFire(PlayerBotActionUseFirearm __instance, ref bool __result)
		{
			__result = PlayerBotManagerExtended.TryToHitEnemy(((PlayerBotActionBase)__instance).m_agent, out var _, out var _);
			return false;
		}
	}
	[HarmonyPatch(typeof(RootPlayerBotAction))]
	internal class Patch_RootPlayerBotAction
	{
		[HarmonyPrefix]
		[HarmonyPatch("UpdateActionReviveTeammate")]
		private static bool Pre_UpdateActionReviveTeammate(RootPlayerBotAction __instance)
		{
			BotRecorder component = ((Component)((PlayerBotActionBase)__instance).m_agent).gameObject.GetComponent<BotRecorder>();
			if ((Object)(object)component != (Object)null)
			{
				return !component.Brain.ReviveRestricted;
			}
			return true;
		}

		[HarmonyPrefix]
		[HarmonyPatch("UpdateActionShareResoursePack")]
		private static bool Pre_UpdateActionShareResoursePack(RootPlayerBotAction __instance)
		{
			BotRecorder component = ((Component)((PlayerBotActionBase)__instance).m_agent).gameObject.GetComponent<BotRecorder>();
			if ((Object)(object)component != (Object)null)
			{
				return !component.IsInDangerousSituation();
			}
			return true;
		}

		[HarmonyPrefix]
		[HarmonyPatch("UpdateActionCollectItem")]
		private static bool Pre_UpdateActionCollectItem(RootPlayerBotAction __instance, ref Descriptor bestAction)
		{
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: 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_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Invalid comparison between Unknown and I4
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			int characterID = ((PlayerBotActionBase)__instance).m_agent.CharacterID;
			if (((Descriptor)__instance.m_collectItemAction).IsTerminated())
			{
				((Descriptor)__instance.m_collectItemAction).Prio = RootPlayerBotAction.m_prioSettings.CollectItem;
				if (RootPlayerBotAction.CompareActionPrios((Descriptor)(object)__instance.m_collectItemAction, bestAction) && !PlayerBackpackManager.GetBackpack(((PlayerBotActionBase)__instance).m_agent.Owner).HasBackpackItem((InventorySlot)8) && !((PlayerBotActionBase)__instance).m_bot.IsActionForbidden((Descriptor)(object)__instance.m_collectItemAction))
				{
					ItemPriorityData itemPriorityData = new ItemPriorityData(((PlayerBotActionBase)__instance).m_agent);
					AIG_CourseNode courseNode = ((Agent)((PlayerBotActionBase)__instance).m_agent).CourseNode;
					for (int i = 0; i < courseNode.MetaData.StorageContainers.Count; i++)
					{
						LG_ResourceContainer_Storage val = courseNode.MetaData.StorageContainers[i];
						LG_WeakResourceContainer component = ((Component)val).gameObject.GetComponent<LG_WeakResourceContainer>();
						if (!((Object)(object)component != (Object)null) || !component.ISOpen)
						{
							continue;
						}
						((AIReservation)RootPlayerBotAction.s_tempObjReservation).CharacterID = characterID;
						RootPlayerBotAction.s_tempObjReservation.Object = ((Component)val).gameObject;
						if (PlayerManager.Current.IsObjectReserved(RootPlayerBotAction.s_tempObjReservation) || ((PlayerBotActionBase)__instance).IsAnyHumanPlayerNear(((Component)val).transform.position, 7f))
						{
							continue;
						}
						Transform transform = ((Component)val).transform;
						Vector3 val2 = transform.position - transform.up * RootPlayerBotAction.s_collectItemStandDistance;
						if (!((PlayerBotActionBase)__instance).SnapPositionToNav(val2, ref val2))
						{
							continue;
						}
						((AIReservation)RootPlayerBotAction.s_tempPosReservation).CharacterID = characterID;
						RootPlayerBotAction.s_tempPosReservation.Position = val2;
						if (PlayerManager.Current.IsPositionReserved(RootPlayerBotAction.s_tempPosReservation))
						{
							continue;
						}
						float originalValue = ((Descriptor)__instance.m_collectItemAction).Prio;
						if ((int)DramaManager.CurrentStateEnum == 7)
						{
							originalValue = PlayerBotManagerExtended.AddBonusMultiplier(originalValue, 5f);
						}
						if (((PlayerBotActionBase)__instance).m_bot.ApplyRestrictionsToRootPosition(ref val2, ref originalValue) || !PlayerBotManagerExtended.GetItemsFromStorageContainer(val, out List<Item> storageItems))
						{
							continue;
						}
						for (int j = 0; j < storageItems.Count; j++)
						{
							Item val3 = storageItems[j];
							if (val3.ItemDataBlock != null && !ItemPriorityData.BlockedItems.Contains(((GameDataBlockBase<ItemDataBlock>)(object)val3.ItemDataBlock).persistentID))
							{
								itemPriorityData.UpcomingItemGrabStatus = new ItemPriorityData.ItemGrabStats
								{
									Item = val3,
									Position = val2,
									Container = val
								};
								itemPriorityData.DeterminePriority();
							}
						}
					}
					if (itemPriorityData.CurrentItemGrabStatus != null)
					{
						__instance.m_collectItemAction.TargetItem = itemPriorityData.CurrentItemGrabStatus.Item;
						__instance.m_collectItemAction.TargetContainer = itemPriorityData.CurrentItemGrabStatus.Container;
						__instance.m_collectItemAction.TargetPosition = itemPriorityData.CurrentItemGrabStatus.Position;
						__instance.m_collectItemAction.Haste = ((DramaManager.GoToCombat || DramaManager.GoToEncounter) ? 2f : 0.5f);
						bestAction = (Descriptor)(object)__instance.m_collectItemAction;
					}
				}
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(ShotgunSynced))]
	internal class Patch_ShotgunSynced
	{
		[HarmonyPrefix]
		[HarmonyPatch("Fire")]
		private static void Pre_Fire(ShotgunSynced __instance)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			if (SNet.IsMaster && ConfigurationPluginManager.BetterBotsAimBot && PlayerBotManagerExtended.TryToHitEnemy(((Item)__instance).Owner, out var hitDir, out var _))
			{
				((Agent)((Item)__instance).Owner).TargetLookDir = hitDir;
				((ItemEquippable)__instance).MuzzleAlign.forward = ((Vector3)(ref hitDir)).normalized;
			}
		}
	}
	[HarmonyPatch(typeof(StartMainGame))]
	internal class Patch_StartMainGame
	{
		[HarmonyPostfix]
		[HarmonyPatch("Start")]
		private static void PostStart()
		{
			BetterBots.OnStartGame();
		}
	}
	[HarmonyPatch(typeof(Weapon))]
	internal class Patch_Weapon
	{
		[HarmonyPrefix]
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		private static void Pre_CastWeaponRay(Transform alignTransform, ref WeaponHitData weaponRayData, ref Vector3 originPos, ref int altRayCastMask)
		{
			if (!SNet.IsMaster || weaponRayData == null)
			{
				return;
			}
			bool flag = false;
			if ((Object)(object)alignTransform != (Object)null && (Object)(object)((Component)alignTransform).gameObject != (Object)null)
			{
				PlayerAgent componentInParent = ((Component)alignTransform).gameObject.GetComponentInParent<PlayerAgent>();
				if ((Object)(object)componentInParent != (Object)null && (Object)(object)componentInParent.Owner != (Object)null)
				{
					flag = componentInParent.Owner.IsBot;
				}
			}
			if ((flag || PlayerBotManagerExtended.USE_MASK_BULLETS_RAY_BOTS || ((Object)(object)weaponRayData.owner != (Object)null && (Object)(object)weaponRayData.owner.Owner != (Object)null && weaponRayData.owner.Owner.IsBot)) && altRayCastMask == -1)
			{
				altRayCastMask = PlayerBotManagerExtended.MASK_BULLET_RAY_BOTS;
			}
		}
	}
}
namespace BetterBots.Managers
{
	public static class BotRecorderManager
	{
		private static List<BotRecorder> s_recorders = new List<BotRecorder>();

		private static int s_lastGuiSlotIndex = -1;

		private const float m_recty = 300f;

		public const float m_height = 2000f;

		private static Rect[] s_guiSlots = (Rect[])(object)new Rect[4]
		{
			new Rect(400f, 300f, 500f, 2000f),
			new Rect(700f, 300f, 500f, 2000f),
			new Rect(1000f, 300f, 500f, 2000f),
			new Rect(1200f, 300f, 500f, 2000f)
		};

		public const bool m_guiManagerEnabled = false;

		public static void RegisterBotRecorder(BotRecorder recorder)
		{
		}

		private static void AssignSlotIndex(BotRecorder recorder)
		{
			//IL_0022: 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)
			s_lastGuiSlotIndex++;
			recorder.m_guiSlotIndex = s_lastGuiSlotIndex;
			recorder.m_guiSlot = s_guiSlots[s_lastGuiSlotIndex];
			recorder.m_hasGuiSlot = true;
		}

		public static void DeRegisterRecorder(BotRecorder recorderDestroyed)
		{
		}
	}
	public static class ConfigurationPluginManager
	{
		private static bool Inited;

		private static ConfigFile ConfigurationFile;

		public static bool BetterBotsAimBot;

		public static void Initialized()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			if (!Inited)
			{
				Inited = true;
				ConfigurationFile = new ConfigFile(Path.Combine(Paths.ConfigPath, "BetterBots.cfg"), true);
				ConfigDefinition val = new ConfigDefinition("Improved Aim", "Enabled");
				ConfigDescription val2 = new ConfigDescription("Improves the bots' accuracy by 100%", (AcceptableValueBase)null, (object[])null);
				ConfigurationFile.Bind<bool>(val, false, val2);
				ConfigEntry<bool> val3 = default(ConfigEntry<bool>);
				if (ConfigurationFile.TryGetEntry<bool>(val, ref val3))
				{
					BetterBotsAimBot = val3.Value;
				}
				ConfigurationFile.Save();
			}
		}
	}
	public static class PlayerBotManagerExtended
	{
		public class AimSpot
		{
			public Dam_EnemyDamageLimb DamLimb;

			public float Prio;

			public static readonly float HEAD_LIMB_PRIO = 2f;

			public static readonly float WEAK_LIMB_PRIO = 3f;

			public static readonly float DEFAULT_LIMB_PRIO = 1f;
		}

		public class AttackEnemy
		{
			public bool Awake;

			public EnemyAgent Enemy;

			public float Prio;

			public AttackEnemy(EnemyAgent enemyAgent)
			{
				Enemy = enemyAgent;
			}

			private bool IsAwake()
			{
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				//IL_0026: Invalid comparison between Unknown and I4
				bool flag = default(bool);
				bool flag2 = default(bool);
				Enemy.AI.IsHibernating(ref flag, ref flag2);
				if ((int)((AgentAI)Enemy.AI).Mode == 1 || flag2)
				{
					return true;
				}
				return false;
			}

			public bool IsAttackable()
			{
				//IL_0052: Unknown result type (might be due to invalid IL or missing references)
				//IL_0058: Unknown result type (might be due to invalid IL or missing references)
				if (IsAwake())
				{
					return true;
				}
				if (((Agent)Enemy).CourseNode == null)
				{
					return false;
				}
				List<EnemyAgent> reachableEnemiesInNodes = AIG_CourseGraph.GetReachableEnemiesInNodes(((Agent)Enemy).CourseNode, 2);
				if (reachableEnemiesInNodes != null)
				{
					Enumerator<EnemyAgent> enumerator = reachableEnemiesInNodes.GetEnumerator();
					while (enumerator.MoveNext())
					{
						EnemyAgent current = enumerator.Current;
						if ((Object)(object)current != (Object)(object)Enemy)
						{
							float num = Vector3.Distance(Enemy.ListenerPosition, current.ListenerPosition);
							float num2 = current.EnemyDetectionData.movementDetectionDistance * 0.1f;
							if (current.EnemyDetectionData.movementDetectionDistance + num2 > num)
							{
								return false;
							}
						}
					}
				}
				return true;
			}
		}

		private static float m_loudStateEnter;

		private static bool m_hasLoudStateEnter;

		public static int MASK_BULLET_RAY_BOTS;

		public static bool SkipWarpSound;

		public static bool USE_MASK_BULLETS_RAY_BOTS;

		private static List<BotRecorder> m_botRecorders;

		public static bool HasLoudStateEnter
		{
			get
			{
				return m_hasLoudStateEnter;
			}
			set
			{
				if (m_hasLoudStateEnter != value)
				{
					m_hasLoudStateEnter = value;
					if (m_hasLoudStateEnter)
					{
						m_loudStateEnter = Time.time;
					}
				}
			}
		}

		public static bool LoudStateIsEarlyToMelee
		{
			get
			{
				if (m_hasLoudStateEnter)
				{
					return m_loudStateEnter + 3f > Time.time;
				}
				return false;
			}
		}

		public static void Awake()
		{
			m_botRecorders = new List<BotRecorder>();
			MASK_BULLET_RAY_BOTS = LayerManager.Current.GetMask(new string[6] { "Default", "Default_NoGraph", "Default_BlockGraph", "EnemyDamagable", "ProjectileBlocker", "Dynamic" });
			BBLog.Message("PlayerBotManagerExtended, Awake");
		}

		public static bool IsBotCurrentlyBusyWithAction(PlayerAIBot bot)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Invalid comparison between Unknown and I4
			if ((int)bot.Agent.Sync.m_locomotionData.State == 8)
			{
				return true;
			}
			Descriptor targetDesc;
			bool num = bot.TryGetActionDescriptor<Descriptor>(queued: true, active: true, out targetDesc);
			Descriptor targetDesc2;
			bool flag = bot.TryGetActionDescriptor<Descriptor>(queued: true, active: true, out targetDesc2);
			Descriptor targetDesc3;
			bool flag2 = bot.TryGetActionDescriptor<Descriptor>(queued: true, active: true, out targetDesc3);
			Descriptor targetDesc4;
			bool flag3 = bot.TryGetActionDescriptor<Descriptor>(queued: true, active: true, out targetDesc4);
			Descriptor targetDesc5;
			bool flag4 = bot.TryGetActionDescriptor<Descriptor>(queued: true, active: true, out targetDesc5);
			Descriptor targetDesc6;
			bool flag5 = bot.TryGetActionDescriptor<Descriptor>(queued: true, active: true, out targetDesc6);
			Descriptor targetDesc7;
			bool flag6 = bot.TryGetActionDescriptor<Descriptor>(queued: true, active: true, out targetDesc7);
			Descriptor targetDesc8;
			bool flag7 = bot.TryGetActionDescriptor<Descriptor>(queued: true, active: true, out targetDesc8);
			Descriptor targetDesc9;
			Descriptor targetDesc10;
			bool flag8 = bot.TryGetActionDescriptor<Descriptor>(queued: true, active: true, out targetDesc9) || bot.TryGetActionDescriptor<Descriptor>(queued: true, active: true, out targetDesc10);
			return num || flag8 || flag || flag2 || flag3 || flag4 || flag5 || flag7 || flag6;
		}

		public static void Start()
		{
		}

		public static void Update()
		{
		}

		public static float AddBonusMultiplier(float originalValue, float multiplier)
		{
			float num = originalValue * multiplier;
			return originalValue += num;
		}

		public static float SubtractBonusMulitplier(float originalValue, float multiplier)
		{
			float num = originalValue * multiplier;
			return originalValue -= num;
		}

		private static void UpdateForcedUnlockObjective()
		{
			//IL_003e: 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_00b5: 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)
			SyncedNavMarkerWrapper[] array = Il2CppArrayBase<SyncedNavMarkerWrapper>.op_Implicit((Il2CppArrayBase<SyncedNavMarkerWrapper>)(object)GuiManager.Current.m_playerPings);
			for (int i = 0; i < array.Length; i++)
			{
				if (!array[i].NavMarkerIsVisible() || IsPlayerSlotIndexBot(array[i].m_playerIndex))
				{
					continue;
				}
				Collider[] array2 = Il2CppArrayBase<Collider>.op_Implicit((Il2CppArrayBase<Collider>)(object)Physics.OverlapSphere(((Component)array[i]).transform.position, 10f, LayerManager.MASK_PING_TARGET));
				if (array2.Length == 0)
				{
					continue;
				}
				for (int j = 0; j < array2.Length; j++)
				{
					LG_WeakResourceContainer componentInParent = ((Component)array2[i]).gameObject.GetComponentInParent<LG_WeakResourceContainer>();
					if ((Object)(object)componentInParent != (Object)null && (Object)(object)componentInParent.m_weakLock != (Object)null && (int)componentInParent.m_weakLock.m_lockType != 0 && !IsObjectReservedForUnlockAction(((Component)componentInParent).gameObject) && TryToGetClosestPlayerBotToStorage(((Component)componentInParent).gameObject, componentInParent.m_weakLock.m_lockType, out BotRecorder bestBotRecorder))
					{
						bestBotRecorder.ForceUnlockAction(componentInParent, componentInParent.m_weakLock.m_lockType);
					}
				}
			}
		}

		public static bool IsObjectReservedForUnlockAction(GameObject gameObject)
		{
			for (int i = 0; i < m_botRecorders.Count; i++)
			{
				BotRecorder botRecorder = m_botRecorders[i];
				if (botRecorder.HasRootAction && !((Descriptor)botRecorder.RootAction.m_unlockAction).IsTerminated() && (Object)(object)botRecorder.RootAction.m_unlockAction.TargetGO == (Object)(object)gameObject)
				{
					return true;
				}
			}
			return false;
		}

		private static bool TryToGetClosestPlayerBotToStorage(GameObject storage, eWeakLockType lockType, out BotRecorder bestBotRecorder)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Invalid comparison between Unknown and I4
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			bestBotRecorder = null;
			float num = 0f;
			for (int i = 0; i < m_botRecorders.Count; i++)
			{
				BotRecorder botRecorder = m_botRecorders[i];
				if (botRecorder.HasRootAction && ((Agent)botRecorder.Agent).Alive && ((Descriptor)botRecorder.RootAction.m_unlockAction).IsTerminated() && ((int)lockType == 1 || botRecorder.HasLockMelters()))
				{
					float num2 = Vector3.Distance(((Agent)botRecorder.Agent).Position, storage.transform.position);
					if ((Object)(object)bestBotRecorder == (Object)null || num > num2)
					{
						bestBotRecorder = botRecorder;
						num = num2;
					}
				}
			}
			return (Object)(object)bestBotRecorder != (Object)null;
		}

		public static void FixedUpdate()
		{
		}

		public static void LateUpdate()
		{
		}

		public static bool IsPlayerSlotIndexBot(int playerSlotIndex)
		{
			for (int i = 0; i < PlayerManager.PlayerAgentsInLevel.Count; i++)
			{
				PlayerAgent val = PlayerManager.PlayerAgentsInLevel[i];
				if ((Object)(object)val != (Object)null && val.PlayerSlotIndex == playerSlotIndex)
				{
					return val.Owner.IsBot;
				}
			}
			return false;
		}

		public static void RegisterBotRecoder(BotRecorder botRecorder)
		{
			if (!m_botRecorders.Contains(botRecorder))
			{
				m_botRecorders.Add(botRecorder);
			}
		}

		public static void DeRegisterBotRecorder(BotRecorder botRecorder)
		{
			if (m_botRecorders.Contains(botRecorder))
			{
				m_botRecorders.Remove(botRecorder);
			}
		}

		public static float GetAmmoRel(PlayerBackpack backPack, AmmoType ammoType)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Invalid comparison between Unknown and I4
			float ammoInPack = backPack.AmmoStorage.GetAmmoInPack(ammoType);
			if ((int)ammoType != 0)
			{
				if ((int)ammoType == 1)
				{
					return backPack.AmmoStorage.GetClipAmmoFromSlot((InventorySlot)2) + ammoInPack;
				}
				return 0f;
			}
			return backPack.AmmoStorage.GetClipAmmoFromSlot((InventorySlot)1) + ammoInPack;
		}

		public static bool TryGetBulletWeapon(PlayerBackpack playerBackpack, InventorySlot slot, out BulletWeaponSynced weapon)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			weapon = null;
			BackpackItem val = default(BackpackItem);
			if (playerBackpack.TryGetBackpackItem(slot, ref val) && (Object)(object)val.Instance != (Object)null)
			{
				ItemEquippable val2 = ((Il2CppObjectBase)val.Instance).TryCast<ItemEquippable>();
				if ((Object)(object)val2 != (Object)null && val2.IsWeapon && (Object)(object)val2.WeaponComp != (Object)null)
				{
					weapon = ((Il2CppObjectBase)val2.WeaponComp).TryCast<BulletWeaponSynced>();
					return (Object)(object)weapon != (Object)null;
				}
			}
			return false;
		}

		public static bool TryGetBestMeleeWeapon(PlayerBackpack playerBackpack, out MeleeWeaponThirdPerson weapon)
		{
			weapon = null;
			BackpackItem val = default(BackpackItem);
			if (playerBackpack.TryGetBackpackItem((InventorySlot)10, ref val) && (Object)(object)val.Instance != (Object)null)
			{
				ItemEquippable val2 = ((Il2CppObjectBase)val.Instance).TryCast<ItemEquippable>();
				if ((Object)(object)val2 != (Object)null)
				{
					weapon = ((Il2CppObjectBase)val2).TryCast<MeleeWeaponThirdPerson>();
					return (Object)(object)weapon != (Object)null;
				}
			}
			return false;
		}

		public static bool TryToGetBestWeapon(PlayerAgent playerAgent, out ItemEquippable bestItemToUse)
		{
			bestItemToUse = null;
			PlayerBackpack playerBackpack = default(PlayerBackpack);
			PlayerBackpackManager.TryGetBackpack(playerAgent.Owner, ref playerBackpack);
			if (playerBackpack == null)
			{
				return false;
			}
			float highestClipsRel = 0f;
			float highestBulletInPackRel = 0f;
			BulletWeaponSynced weapon;
			bool flag = TryGetBulletWeapon(playerBackpack, (InventorySlot)1, out weapon);
			BulletWeaponSynced weapon2;
			bool flag2 = TryGetBulletWeapon(playerBackpack, (InventorySlot)2, out weapon2);
			if (flag2)
			{
				DetermineBestWeapon(weapon2, ignoreClip: false, ref bestItemToUse);
			}
			if (flag)
			{
				DetermineBestWeapon(weapon, ignoreClip: false, ref bestItemToUse);
			}
			if ((Object)(object)bestItemToUse == (Object)null)
			{
				if (flag2)
				{
					DetermineBestWeapon(weapon2, ignoreClip: true, ref bestItemToUse);
				}
				if (flag)
				{
					DetermineBestWeapon(weapon, ignoreClip: true, ref bestItemToUse);
				}
			}
			return (Object)(object)bestItemToUse != (Object)null;
			void DetermineBestWeapon(BulletWeaponSynced bulletWeapon, bool ignoreClip, ref ItemEquippable bestitemEquippable)
			{
				//IL_0013: Unknown result type (might be due to invalid IL or missing references)
				float currentClipRel = ((ItemEquippable)bulletWeapon).GetCurrentClipRel();
				float bulletsRelInPack = playerBackpack.AmmoStorage.GetBulletsRelInPack(((ItemEquippable)bulletWeapon).AmmoType);
				if (ignoreClip)
				{
					if (bulletsRelInPack > 0f && bulletsRelInPack > highestBulletInPackRel)
					{
						bestitemEquippable = (ItemEquippable)(object)bulletWeapon;
						highestBulletInPackRel = bulletsRelInPack;
					}
				}
				else if (currentClipRel > 0f && currentClipRel > highestClipsRel)
				{
					bestitemEquippable = (ItemEquippable)(object)bulletWeapon;
					highestClipsRel = currentClipRel;
				}
			}
		}

		public static bool TryToGetLimb(EnemyAgent enemy, bool includeHeadLimb, out AimSpot bestTargetAimSpot)
		{
			//IL_003a: 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_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Invalid comparison between Unknown and I4
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: 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_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Invalid comparison between Unknown and I4
			bestTargetAimSpot = null;
			if ((Object)(object)enemy.ModelRef == (Object)null)
			{
				return false;
			}
			if (enemy.Damage.DamageLimbs != null && ((Il2CppArrayBase<Dam_EnemyDamageLimb>)(object)enemy.Damage.DamageLimbs).Count > 0)
			{
				Vector3 eyePosition = ((Agent)enemy).EyePosition;
				float num = 0f;
				for (int i = 0; i < ((Il2CppArrayBase<Dam_EnemyDamageLimb>)(object)enemy.Damage.DamageLimbs).Count; i++)
				{
					Dam_EnemyDamageLimb val = ((Il2CppArrayBase<Dam_EnemyDamageLimb>)(object)enemy.Damage.DamageLimbs)[i];
					if ((Object)(object)val != (Object)null && (int)val.m_type != 2 && !val.IsDestroyed)
					{
						Vector3 position = ((Component)val).transform.position;
						Vector3 val2 = eyePosition - position;
						float magnitude = ((Vector3)(ref val2)).magnitude;
						AimSpot aimSpot = new AimSpot
						{
							DamLimb = val,
							Prio = (((int)val.m_type == 1) ? AimSpot.WEAK_LIMB_PRIO : AimSpot.DEFAULT_LIMB_PRIO)
						};
						if (bestTargetAimSpot == null || (num > magnitude && aimSpot.Prio > bestTargetAimSpot.Prio))
						{
							num = magnitude;
							bestTargetAimSpot = aimSpot;
						}
					}
				}
			}
			if (includeHeadLimb && (Object)(object)enemy.m_headLimb != (Object)null && !enemy.m_headLimb.IsDestroyed)
			{
				AimSpot aimSpot2 = new AimSpot
				{
					DamLimb = enemy.m_headLimb,
					Prio = AimSpot.HEAD_LIMB_PRIO
				};
				if (bestTargetAimSpot == null || aimSpot2.Prio > bestTargetAimSpot.Prio)
				{
					bestTargetAimSpot = aimSpot2;
				}
			}
			return bestTargetAimSpot != null;
		}

		public static bool TryToHitEnemy(PlayerAgent playerAgent, out Vector3 hitDir, out RaycastHit raycastHit)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: 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_00cf: Unknown result type (might be due to invalid IL or missing references)
			hitDir = Vector3.zero;
			raycastHit = default(RaycastHit);
			if (playerAgent.TryGetActionDescriptor<Descriptor>(queued: true, active: true, out Descriptor targetDesc) && (Object)(object)targetDesc.TargetAgent != (Object)null)
			{
				EnemyAgent val = ((Il2CppObjectBase)targetDesc.TargetAgent).TryCast<EnemyAgent>();
				if ((Object)(object)val != (Object)null && TryToGetLimb(val, includeHeadLimb: true, out AimSpot bestTargetAimSpot) && (Object)(object)playerAgent.Inventory != (Object)null && (Object)(object)playerAgent.Inventory.WieldedItem != (Object)null)
				{
					Collider component = ((Component)bestTargetAimSpot.DamLimb).GetComponent<Collider>();
					if ((Object)(object)component != (Object)null)
					{
						Transform muzzleAlign = playerAgent.Inventory.WieldedItem.MuzzleAlign;
						Bounds bounds = component.bounds;
						hitDir = ((Bounds)(ref bounds)).center - muzzleAlign.position;
						if (Physics.Raycast(muzzleAlign.position, hitDir, ref raycastHit, 100000f, LayerManager.MASK_BULLETWEAPON_RAY, (QueryTriggerInteraction)1))
						{
							GameObject gameObject = ((Component)((RaycastHit)(ref raycastHit)).collider).gameObject;
							if ((Object)(object)gameObject.GetComponentInParent<EnemyAgent>() != (Object)null)
							{
								return (Object)(object)gameObject.GetComponentInParent<PlayerAgent>() == (Object)null;
							}
						}
					}
				}
			}
			return false;
		}

		public static bool TryGetActionDescriptor<PAD>(this PlayerAgent playerAgent, bool queued, bool active, out PAD targetDesc) where PAD : Descriptor
		{
			targetDesc = default(PAD);
			PlayerAIBot component = ((Component)playerAgent).gameObject.GetComponent<PlayerAIBot>();
			if ((Object)(object)component != (Object)null)
			{
				return component.TryGetActionDescriptor<PAD>(queued, active, out targetDesc);
			}
			return false;
		}

		public static bool TryGetActionDescriptor<PAD>(this PlayerAIBot bot, bool queued, bool active, out PAD targetDesc) where PAD : Descriptor
		{
			targetDesc = default(PAD);
			if ((Object)(object)bot != (Object)null)
			{
				if (queued)
				{
					for (int i = 0; i < bot.m_queuedActions.Count; i++)
					{
						Descriptor val = bot.m_queuedActions[i];
						if (val != null)
						{
							PAD val2 = ((Il2CppObjectBase)val).TryCast<PAD>();
							if (val2 != null)
							{
								targetDesc = val2;
								return true;
							}
						}
					}
				}
				if (active)
				{
					for (int j = 0; j < bot.m_actions.Count; j++)
					{
						PlayerBotActionBase val3 = bot.m_actions[j];
						if (val3 != null && val3.DescBase != null)
						{
							PAD val4 = ((Il2CppObjectBase)val3.DescBase).TryCast<PAD>();
							if (val4 != null)
							{
								targetDesc = val4;
								return true;
							}
						}
					}
				}
			}
			return false;
		}

		public static bool GetItemsFromStorageContainer(LG_ResourceContainer_Storage storage, out List<Item> storageItems)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			storageItems = new List<Item>();
			Il2CppArrayBase<BoxCollider> componentsInChildren = ((Component)storage).GetComponentsInChildren<BoxCollider>();
			if (componentsInChildren != null && componentsInChildren.Count > 0)
			{
				Collider[] array = Il2CppArrayBase<Collider>.op_Implicit((Il2CppArrayBase<Collider>)(object)Physics.OverlapSphere(((Component)storage).transform.position, 2f, LayerManager.MASK_APPLY_CARRY_ITEM, (QueryTriggerInteraction)1));
				if (array.Length != 0)
				{
					for (int i = 0; i < array.Length; i++)
					{
						Item componentInParent = ((Component)array[i]).GetComponentInParent<Item>();
						if (!((Object)(object)componentInParent != (Object)null))
						{
							continue;
						}
						for (int j = 0; j < componentsInChildren.Count; j++)
						{
							Bounds bounds = ((Collider)componentsInChildren[j]).bounds;
							if (((Bounds)(ref bounds)).Contains(((Component)componentInParent).transform.position))
							{
								storageItems.Add(componentInParent);
								break;
							}
						}
					}
				}
			}
			return storageItems.Count > 0;
		}

		public static int PriorityBasedOnItem(uint itemID)
		{
			return itemID switch
			{
				101u => 10, 
				127u => 9, 
				102u => 8, 
				132u => 7, 
				_ => 0, 
			};
		}

		public static float GetTotalAmmoRel()
		{
			int num = 0;
			float num2 = 0f;
			BackpackItem val = default(BackpackItem);
			BackpackItem val2 = default(BackpackItem);
			for (int i = 0; i < PlayerManager.PlayerAgentsInLevel.Count; i++)
			{
				PlayerBackpack backpack = PlayerBackpackManager.GetBackpack(PlayerManager.PlayerAgentsInLevel[i].Owner);
				if (backpack.TryGetBackpackItem((InventorySlot)1, ref val))
				{
					num++;
					num2 += backpack.AmmoStorage.StandardAmmo.RelInPack;
				}
				if (backpack.TryGetBackpackItem((InventorySlot)2, ref val2))
				{
					num++;
					num2 += backpack.AmmoStorage.SpecialAmmo.RelInPack;
				}
			}
			return num2 / (float)num;
		}

		public static float GetOverallHealth()
		{
			float num = 0f;
			float num2 = 0f;
			List<PlayerAgent> playerAgentsInLevel = PlayerManager.PlayerAgentsInLevel;
			if (playerAgentsInLevel.Count > 0)
			{
				for (int i = 0; i < playerAgentsInLevel.Count; i++)
				{
					PlayerAgent val = playerAgentsInLevel[i];
					if ((Object)(object)val != (Object)null)
					{
						num2 += ((Dam_SyncedDamageBase)val.Damage).GetHealthRel();
						num += 1f;
					}
				}
			}
			return num2 / num;
		}

		public static bool TryToGetClosestPlayerAgentToPlayer(PlayerAgent sourcePlayer, out PlayerAgent otherPlayer)
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			otherPlayer = null;
			List<PlayerAgent> playerAgentsInLevel = PlayerManager.PlayerAgentsInLevel;
			bool flag = false;
			float num = 0f;
			for (int i = 0; i < playerAgentsInLevel.Count; i++)
			{
				PlayerAgent val = playerAgentsInLevel[i];
				if (((Object)val).GetInstanceID() != ((Object)sourcePlayer).GetInstanceID() && !val.Owner.IsBot && ((Agent)val).Alive)
				{
					float num2 = Vector3.Distance(((Agent)val).Position, ((Agent)sourcePlayer).Position);
					if (!flag || num2 < num)
					{
						otherPlayer = val;
						num = num2;
						flag = true;
					}
				}
			}
			return flag;
		}

		public static bool HasEndlessWave()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			if (Mastermind.Current.m_events == null)
			{
				return false;
			}
			Enumerator<MastermindEvent> enumerator = Mastermind.Current.m_events.GetEnumerator();
			while (enumerator.MoveNext())
			{
				MastermindEvent current = enumerator.Current;
				if ((int)current.EventType == 1)
				{
					SurvivalWave val = ((Il2CppObjectBase)current).TryCast<SurvivalWave>();
					if ((Object)(object)val != (Object)null && val.m_settings.m_populationPointsTotal < 0f)
					{
						return true;
					}
				}
			}
			return false;
		}
	}
}
namespace BetterBots.Data
{
	public class ItemPriorityData
	{
		public class ItemGrabStats
		{
			public LG_ResourceContainer_Storage Container;

			public Item Item;

			public Vector3 Position;
		}

		public PlayerAgent Player;

		public static List<uint> BlockedItems = new List<uint>
		{
			Item.CONSUMABLE_GlowStick,
			Item.CONSUMABLE_GlowStick_Christmas,
			Item.CONSUMABLE_GlowStick_Halloween,
			Item.CONSUMABLE_GlowStick_Yellow,
			Item.CONSUMABLE_Syringe_Health,
			Item.CONSUMABLE_Syringe_MeleeBuff,
			Item.CONSUMABLE_FlashlightMedium
		};

		public ItemGrabStats UpcomingItemGrabStatus;

		public ItemGrabStats CurrentItemGrabStatus;

		public float BestPriority;

		public ItemPriorityData(PlayerAgent player)
		{
			Player = player;
		}

		private bool IsBackPackItemPrefferable()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			return PlayerBackpackManager.GetBackpack(Player.Owner).HasBackpackItem(UpcomingItemGrabStatus.Item.ItemDataBlock.inventorySlot);
		}

		public void DeterminePriority()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			if (UpcomingItemGrabStatus != null && CanGrabItem() && !IsBackPackItemPrefferable())
			{
				float num = Vector3.Distance(((Agent)Player).Position, UpcomingItemGrabStatus.Position);
				switch (((GameDataBlockBase<ItemDataBlock>)(object)UpcomingItemGrabStatus.Item.ItemDataBlock).persistentID)
				{
				case 101u:
					num /= Mathf.Lerp(10f, 4f, PlayerBotManagerExtended.GetTotalAmmoRel());
					break;
				case 102u:
					num /= Mathf.Lerp(5f, 2f, PlayerBotManagerExtended.GetOverallHealth());
					break;
				}
				if (CurrentItemGrabStatus == null || BestPriority > num)
				{
					BestPriority = num;
					CurrentItemGrabStatus = UpcomingItemGrabStatus;
				}
			}
		}

		private bool CanGrabItem()
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Invalid comparison between Unknown and I4
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Invalid comparison between Unknown and I4
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: 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)
			if ((Object)(object)UpcomingItemGrabStatus.Item.PickupInteraction == (Object)null)
			{
				return false;
			}
			Interact_Base pickupInteraction = UpcomingItemGrabStatus.Item.PickupInteraction;
			if (!pickupInteraction.IsActive || pickupInteraction.ManualTriggeringOnly || !pickupInteraction.PlayerCanInteract(Player))
			{
				return false;
			}
			InventorySlot inventorySlot = UpcomingItemGrabStatus.Item.ItemDataBlock.inventorySlot;
			if ((int)inventorySlot != 5 && (int)inventorySlot != 4)
			{
				return false;
			}
			float num = RootPlayerBotAction.s_collectItemSearchDistance;
			if (PlayerBotManagerExtended.HasEndlessWave() || ((GameDataBlockBase<ItemDataBlock>)(object)UpcomingItemGrabStatus.Item.ItemDataBlock).persistentID == Item.AmmoPackWeapon)
			{
				num *= 10f;
			}
			Vector3 val = ((Component)UpcomingItemGrabStatus.Item).transform.position - ((Agent)Player).Position;
			return ((Vector3)(ref val)).magnitude < num;
		}
	}
	public class PB_Base
	{
		protected PlayerBotBrain m_brain;

		public PB_Base(PlayerBotBrain brain)
		{
			m_brain = brain;
		}

		public virtual void UpdateBrain()
		{
		}
	}
	public class PB_Damage : PB_Base
	{
		private bool m_firstCheck;

		private float m_lastHealthRatio;

		private float m_damageTakenTime;

		private bool m_firstDamageTaken;

		public bool IsTakingDamage => HasTakenDamageFromTimePassed(3f);

		public PB_Damage(PlayerBotBrain brain)
			: base(brain)
		{
		}

		public override void UpdateBrain()
		{
			float healthRel = ((Dam_SyncedDamageBase)m_brain.Agent.Damage).GetHealthRel();
			if (!m_firstCheck)
			{
				m_firstCheck = true;
				m_lastHealthRatio = healthRel;
			}
			else if (healthRel != m_lastHealthRatio)
			{
				if (healthRel < m_lastHealthRatio)
				{
					m_damageTakenTime = Time.time;
					m_firstDamageTaken = true;
				}
				m_lastHealthRatio = healthRel;
			}
		}

		public bool HasTakenDamageFromTimePassed(float timePassed)
		{
			if (m_firstDamageTaken)
			{
				return m_damageTakenTime + timePassed > Time.time;
			}
			return false;
		}
	}
	public class PB_Enemy : PB_Base
	{
		public struct EnemyDetectionData
		{
			public int m_amountOfSeenEnemies;

			public int m_amountOfSeenEnemiesClose;

			public int m_amountOfSeenOneShotEnemiesClose;

			public int m_amountOfSeenOneShotEnemies;

			public float m_closestEnemyInBounds;

			public EnemyAgent m_closestEnemy;

			public bool m_AggressiveEnemyFound;
		}

		private EnemyDetectionData m_detectData;

		public EnemyDetectionData EnemyDetection => m_detectData;

		public PB_Enemy(PlayerBotBrain brain)
			: base(brain)
		{
		}

		public override void UpdateBrain()
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Invalid comparison between Unknown and I4
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			if (((Agent)m_brain.Agent).CourseNode == null)
			{
				m_detectData = default(EnemyDetectionData);
				return;
			}
			List<EnemyAgent> reachableEnemiesInNodes = AIG_CourseGraph.GetReachableEnemiesInNodes(((Agent)m_brain.Agent).CourseNode, 3);
			EnemyDetectionData detectData = default(EnemyDetectionData);
			detectData.m_AggressiveEnemyFound = false;
			for (int i = 0; i < reachableEnemiesInNodes.Count; i++)
			{
				EnemyAgent val = reachableEnemiesInNodes[i];
				if (!((Agent)val).Alive || (int)((AgentAI)val.AI).Mode != 1)
				{
					continue;
				}
				bool num = m_brain.Agent.CanSeeObject(((Agent)m_brain.Agent).EyePosition, ((Component)val).gameObject);
				float num2 = Vector3.Distance(((Agent)m_brain.Agent).Position, val.Position);
				bool flag = (double)m_brain.Agent.PlayerData.health * 0.15 < (double)val.EnemyBalancingData.MeleeAttackDamage;
				if (!detectData.m_AggressiveEnemyFound || detectData.m_closestEnemyInBounds > num2)
				{
					detectData.m_closestEnemyInBounds = num2;
					detectData.m_AggressiveEnemyFound = true;
					detectData.m_closestEnemy = val;
				}
				if (!num)
				{
					continue;
				}
				detectData.m_amountOfSeenEnemies++;
				if (flag)
				{
					detectData.m_amountOfSeenOneShotEnemies++;
				}
				if (num2 < 8f)
				{
					detectData.m_amountOfSeenEnemiesClose++;
					if (flag)
					{
						detectData.m_amountOfSeenOneShotEnemiesClose++;
					}
				}
			}
			m_detectData = detectData;
		}
	}
	public class PB_Friendlies : PB_Base
	{
		public struct FriendlyStatus
		{
			public int m_tm_CanSee;

			public int m_tm_CanSee_Close;

			public float m_rev_confidence;
		}

		private static class Settings
		{
			public static readonly float Rev_Con_MaxDistance = 15f;

			public static readonly float Rev_Con_MixDistance = 5f;

			public static readonly float Rev_Close_Distance_Friendly = 5f;
		}

		private FriendlyStatus m_friendlyStatus;

		public FriendlyStatus CurrentFriendlyStatus => m_friendlyStatus;

		public PB_Friendlies(PlayerBotBrain brain)
			: base(brain)
		{
		}

		public override void UpdateBrain()
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			if (((Agent)m_brain.Agent).CourseNode == null)
			{
				m_friendlyStatus = default(FriendlyStatus);
				return;
			}
			FriendlyStatus friendlyStatus = default(FriendlyStatus);
			List<PlayerAgent> playerAgentsInLevel = PlayerManager.PlayerAgentsInLevel;
			for (int i = 0; i < playerAgentsInLevel.Count; i++)
			{
				PlayerAgent val = playerAgentsInLevel[i];
				if (val.CharacterID == m_brain.Agent.CharacterID || !((Agent)val).Alive)
				{
					continue;
				}
				bool num = m_brain.Agent.CanSeeObject(m_brain.EyePosition, ((Component)val).gameObject);
				float num2 = Vector3.Distance(((Agent)m_brain.Agent).Position, ((Agent)val).Position);
				if (num)
				{
					friendlyStatus.m_tm_CanSee++;
					if (num2 < Settings.Rev_Close_Distance_Friendly)
					{
						friendlyStatus.m_tm_CanSee_Close++;
					}
				}
			}
			m_friendlyStatus = friendlyStatus;
		}
	}
	public class PB_Revive : PB_Base
	{
		public static class Settings
		{
			public static int s_attackers_Visible_Restrict_Revive = 5;

			public static int s_attackers_Close_And_Visible_Restrict_Revive = 2;

			public static int s_attackers_OneShot_Close_And_Visible_Restrict_Revive = 1;

			public static float s_reviveConfidenceProgressUninterrupted = 0.7f;

			public static float s_takingDamageDecay = 3f;
		}

		public bool ReviveIsDangerous
		{
			get
			{
				if (m_brain.m_friendliesBrain.CurrentFriendlyStatus.m_tm_CanSee_Close > 2)
				{
					return false;
				}
				if (m_brain.m_enemyBrain.EnemyDetection.m_amountOfSeenEnemiesClose >= Settings.s_attackers_Close_And_Visible_Restrict_Revive)
				{
					return true;
				}
				if (m_brain.m_enemyBrain.EnemyDetection.m_amountOfSeenOneShotEnemiesClose >= Settings.s_attackers_OneShot_Close_And_Visible_Restrict_Revive)
				{
					return true;
				}
				return false;
			}
		}

		public PB_Revive(PlayerBotBrain brain)
			: base(brain)
		{
		}
	}
	public class PB_UnlockResourceContainer : PB_Base
	{
		private LG_ResourceContainer_Storage m_targetContainer;

		public bool HasTargetContainer => (Object)(object)m_targetContainer != (Object)null;

		public PB_UnlockResourceContainer(PlayerBotBrain brain)
			: base(brain)
		{
		}

		public void SetTargetResourceContainer(LG_ResourceContainer_Storage targetContainer)
		{
			m_targetContainer = targetContainer;
		}

		public void OpenTargetContainer()
		{
			if (!((Object)(object)m_targetContainer == (Object)null))
			{
				LG_WeakResourceContainer component = ((Component)m_targetContainer).gameObject.GetComponent<LG_WeakResourceContainer>();
				if (!component.ISOpen && !component.IsLocked())
				{
					component.OnWeakLockUnlocked(true);
				}
				m_targetContainer = null;
			}
		}
	}
	public class PlayerBotActionCollection
	{
		public PlayerBotActionHighlight HighLight;

		public PlayerBotActionIdle Idle;

		public PlayerBotActionFollow Follow;

		public PlayerBotActionUseBioscan UseBioScan;

		public PlayerBotActionAttack Attack;

		public PlayerBotActionRevive Revive;

		public PlayerBotActionUseEnemyScanner UseEnemyScanner;

		public PlayerBotActionUseEnemyScanner TagEnemies;

		public PlayerBotActionCollectItem CollectItem;

		public PlayerBotActionShareResourcePack ShareResourcePack;

		public void OnSetupRootAction(RootPlayerBotAction rootAction)
		{
			HighLight = ((Il2CppObjectBase)((Descriptor)rootAction.m_highlightAction).ActionBase).TryCast<PlayerBotActionHighlight>();
			Idle = ((Il2CppObjectBase)((Descriptor)rootAction.m_highlightAction).ActionBase).TryCast<PlayerBotActionIdle>();
			Follow = ((Il2CppObjectBase)((Descriptor)rootAction.m_highlightAction).ActionBase).TryCast<PlayerBotActionFollow>();
			UseBioScan = ((Il2CppObjectBase)((Descriptor)rootAction.m_highlightAction).ActionBase).TryCast<PlayerBotActionUseBioscan>();
			Attack = ((Il2CppObjectBase)((Descriptor)rootAction.m_highlightAction).ActionBase).TryCast<PlayerBotActionAttack>();
			Revive = ((Il2CppObjectBase)((Descriptor)rootAction.m_highlightAction).ActionBase).TryCast<PlayerBotActionRevive>();
			UseEnemyScanner = ((Il2CppObjectBase)((Descriptor)rootAction.m_highlightAction).ActionBase).TryCast<PlayerBotActionUseEnemyScanner>();
			TagEnemies = ((Il2CppObjectBase)((Descriptor)rootAction.m_highlightAction).ActionBase).TryCast<PlayerBotActionUseEnemyScanner>();
			CollectItem = ((Il2CppObjectBase)((Descriptor)rootAction.m_highlightAction).ActionBase).TryCast<PlayerBotActionCollectItem>();
			ShareResourcePack = ((Il2CppObjectBase)((Descriptor)rootAction.m_highlightAction).ActionBase).TryCast<PlayerBotActionShareResourcePack>();
		}
	}
	public class PlayerBotBrain
	{
		public PB_Revive m_reviveBrain;

		public PB_Damage m_damageBrain;

		public PB_Enemy m_enemyBrain;

		public PB_Friendlies m_friendliesBrain;

		public PB_UnlockResourceContainer m_unlockResourceContainerBrain;

		private PlayerAgent m_agent;

		public PlayerAgent Agent => m_agent;

		public Vector3 EyePosition => ((Agent)m_agent).EyePosition;

		public bool IsTakingDamage => m_damageBrain.IsTakingDamage;

		public bool ForceBulletsOnly
		{
			get
			{
				if (HasAmmo())
				{
					if (IsTakingDamage)
					{
						return true;
					}
					if (m_enemyBrain.EnemyDetection.m_amountOfSeenOneShotEnemies > 0)
					{
						return true;
					}
					if (m_enemyBrain.EnemyDetection.m_amountOfSeenEnemies > 2)
					{
						return true;
					}
				}
				return false;
			}
		}

		public bool ForceAvoidStance
		{
			get
			{
				if (IsTakingDamage)
				{
					return true;
				}
				if (m_enemyBrain.EnemyDetection.m_amountOfSeenOneShotEnemies > 0)
				{
					return true;
				}
				if (m_enemyBrain.EnemyDetection.m_amountOfSeenEnemies > 3)
				{
					return true;
				}
				return false;
			}
		}

		public bool RestrictHighlightingItems => m_enemyBrain.EnemyDetection.m_amountOfSeenEnemiesClose > 0;

		public bool ReviveRestricted => m_reviveBrain.ReviveIsDangerous;

		public void Setup(PlayerAgent agent)
		{
			m_agent = agent;
			m_reviveBrain = new PB_Revive(this);
			m_damageBrain = new PB_Damage(this);
			m_enemyBrain = new PB_Enemy(this);
			m_friendliesBrain = new PB_Friendlies(this);
			m_unlockResourceContainerBrain = new PB_UnlockResourceContainer(this);
		}

		public void Update()
		{
			m_enemyBrain.UpdateBrain();
			m_reviveBrain.UpdateBrain();
			m_damageBrain.UpdateBrain();
			m_friendliesBrain.UpdateBrain();
			m_unlockResourceContainerBrain.UpdateBrain();
		}

		public bool TryToGetBioScanOnPlayerAgent(PlayerAgent playerAgent, out CP_Bioscan_Core selectedCore)
		{
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Invalid comparison between Unknown and I4
			selectedCore = null;
			List<ChainedPuzzleInstance> instances = ChainedPuzzleManager.Current.m_instances;
			if (instances == null)
			{
				return false;
			}
			for (int i = 0; i < instances.Count; i++)
			{
				ChainedPuzzleInstance val = instances[i];
				if (!((Object)(object)val != (Object)null))
				{
					continue;
				}
				Il2CppReferenceArray<iChainedPuzzleCore> chainedPuzzleCores = val.m_chainedPuzzleCores;
				if (chainedPuzzleCores == null || ((Il2CppArrayBase<iChainedPuzzleCore>)(object)chainedPuzzleCores).Count <= 0)
				{
					continue;
				}
				for (int j = 0; j < ((Il2CppArrayBase<iChainedPuzzleCore>)(object)chainedPuzzleCores).Count; j++)
				{
					if (((Il2CppArrayBase<iChainedPuzzleCore>)(object)chainedPuzzleCores)[j] == null)
					{
						continue;
					}
					CP_Bioscan_Core val2 = ((Il2CppObjectBase)((Il2CppArrayBase<iChainedPuzzleCore>)(object)chainedPuzzleCores)[j]).TryCast<CP_Bioscan_Core>();
					if ((Object)(object)val2 != (Object)null)
					{
						CP_PlayerScanner val3 = ((Il2CppObjectBase)val2.PlayerScanner).TryCast<CP_PlayerScanner>();
						if ((Object)(object)val3 != (Object)null && (int)val3.ScanPlayersRequired == 1 && val2.PlayersOnScan.ToList<PlayerAgent>().Contains(playerAgent))
						{
							selectedCore = val2;
						}
					}
				}
			}
			return (Object)(object)selectedCore != (Object)null;
		}

		public float GetAmmoRel(PlayerBackpack backPack, AmmoType ammoType)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Invalid comparison between Unknown and I4
			float ammoInPack = backPack.AmmoStorage.GetAmmoInPack(ammoType);
			if ((int)ammoType != 0)
			{
				if ((int)ammoType == 1)
				{
					return backPack.AmmoStorage.GetClipAmmoFromSlot((InventorySlot)2) + ammoInPack;
				}
				return 0f;
			}
			return backPack.AmmoStorage.GetClipAmmoFromSlot((InventorySlot)1) + ammoInPack;
		}

		public bool HasAmmo()
		{
			PlayerBackpack backpack = PlayerBackpackManager.GetBackpack(m_agent.Owner);
			BackpackItem val = default(BackpackItem);
			if (backpack.TryGetBackpackItem((InventorySlot)1, ref val) && GetAmmoRel(backpack, (AmmoType)0) > 0f)
			{
				return true;
			}
			if (backpack.TryGetBackpackItem((InventorySlot)2, ref val) && GetAmmoRel(backpack, (AmmoType)1) > 0f)
			{
				return true;
			}
			return false;
		}
	}
	public class PlayerBotForcedUnlockAction
	{
		public PlayerAIBot Bot;

		public PlayerBotForcedUnlockAction(PlayerAIBot bot)
		{
			Bot = bot;
		}

		public void ForceUnlockAction(LG_WeakResourceContainer storage, eWeakLockType lockType, Descriptor descriptor)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Invalid comparison between Unknown and I4
			descriptor.TargetGO = ((Component)storage).gameObject;
			descriptor.TargetPosition = ((Component)storage).gameObject.transform.position;
			descriptor.TargetType = (TargetTypeEnum)1;
			((Descriptor)descriptor).Prio = 500f;
			descriptor.Method = (MethodEnum)(((int)lockType != 2) ? 1 : 4);
			descriptor.Lock = storage.m_weakLock;
			Bot.StartAction((Descriptor)(object)descriptor);
		}
	}
}
namespace BetterBots.Components
{
	[IL2CPP_ComponentDescriptor(m_dontDestroyOnLoad = true, m_launchOnStartLoad = false)]
	public class BotRecorder : MonoBehaviorFixed
	{
		public Rect m_guiSlot;

		public int m_guiSlotIndex;

		private PlayerAIBot m_bot;

		private RootPlayerBotAction m_rootAction;

		private PlayerBotBrain m_brain;

		private bool m_hasRootAction;

		private string m_botName;

		private PlayerBotActionCollection m_actionCollection;

		private PlayerBotForcedUnlockAction m_forcedUnlockAction;

		public float m_abortExpeditionItemTimer;

		public bool m_firstExpeditionItemTimer;

		private PlayerBotActionDebugBase[] m_actiondebugs;

		private GUIStyle m_recorderStyle;

		public bool m_hasGuiSlot;

		[HideFromIl2Cpp]
		public PlayerBotBrain Brain => m_brain;

		[HideFromIl2Cpp]
		public PlayerAgent Agent => m_agent;

		[HideFromIl2Cpp]
		public RootPlayerBotAction RootAction => m_rootAction;

		[HideFromIl2Cpp]
		public bool HasRootAction => m_hasRootAction;

		[HideFromIl2Cpp]
		public PlayerBotForcedUnlockAction ForcedUnlockAction => m_forcedUnlockAction;

		[HideFromIl2Cpp]
		public bool SneakingRestricted
		{
			get
			{
				if (!Brain.m_enemyBrain.EnemyDetection.m_AggressiveEnemyFound)
				{
					return false;
				}
				if (Brain.m_enemyBrain.EnemyDetection.m_amountOfSeenEnemiesClose > 0)
				{
					return true;
				}
				if (Brain.m_enemyBrain.EnemyDetection.m_closestEnemyInBounds < 10f)
				{
					return true;
				}
				return false;
			}
		}

		[HideFromIl2Cpp]
		private PlayerAgent m_agent => m_bot.Agent;

		[HideFromIl2Cpp]
		private string Preffix => "Bot: <color=#" + ColorUtility.ToHtmlStringRGB(m_agent.Owner.PlayerColor) + ">" + m_botName + "</color> ";

		[HideFromIl2Cpp]
		private string GetLogInfo
		{
			get
			{
				List<string> val = new List<string>();
				GetActionDebug(PlayerBotActionType.Idle, val);
				GetActionDebug(PlayerBotActionType.Follow, val);
				GetActionDebug(PlayerBotActionType.UseBioScan, val);
				GetActionDebug(PlayerBotActionType.Attack, val);
				GetActionDebug(PlayerBotActionType.UseFireArm, val);
				GetActionDebug(PlayerBotActionType.Revive, val);
				GetActionDebug(PlayerBotActionType.ShareResource, val);
				GetActionDebug(PlayerBotActionType.CollectItem, val);
				GetActionDebug(PlayerBotActionType.CarryExpedtionItem, val);
				string text = "<b><color=yellow>Active Actions</color></b>\n";
				Enumerator<string> enumerator = val.GetEnumerator();
				while (enumerator.MoveNext())
				{
					string current = enumerator.Current;
					text += current;
				}
				return text;
			}
		}

		private void Awake()
		{
			Setup();
		}

		[HideFromIl2Cpp]
		public bool HasLockMelters()
		{
			BackpackItem val = default(BackpackItem);
			if (!PlayerBackpackManager.GetBackpack(m_bot.Agent.Owner).TryGetBackpackItem((InventorySlot)5, ref val))
			{
				return false;
			}
			if (val.ItemID != Item.CONSUMABLE_LockMelter)
			{
				return false;
			}
			return true;
		}

		[HideFromIl2Cpp]
		public void ForceUnlockAction(LG_WeakResourceContainer storage, eWeakLockType lockType)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			m_forcedUnlockAction.ForceUnlockAction(storage, lockType, m_rootAction.m_unlockAction);
		}

		private void Setup()
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Expected O, but got Unknown
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			m_firstExpeditionItemTimer = false;
			m_actionCollection = new PlayerBotActionCollection();
			m_rootAction = null;
			m_hasRootAction = false;
			m_bot = ((Component)this).GetComponent<PlayerAIBot>();
			m_botName = m_bot.Agent.Owner.NickName;
			m_forcedUnlockAction = new PlayerBotForcedUnlockAction(m_bot);
			SetupActionDebugs();
			m_recorderStyle = new GUIStyle();
			m_recorderStyle.fontSize = 20;
			m_recorderStyle.normal.textColor = Color.white;
			m_brain = new PlayerBotBrain();
			m_brain.Setup(m_bot.Agent);
			BotRecorderManager.RegisterBotRecorder(this);
			PlayerBotManagerExtended.RegisterBotRecoder(this);
			if ((Object)(object)m_bot == (Object)null)
			{
				BBLog.Error("Could not get PlayerAIBot component!!");
			}
		}

		private void SetupActionDebugs()
		{
			m_actiondebugs = new PlayerBotActionDebugBase[typeof(PlayerBotActionType).GetEnumValues().Length];
			m_actiondebugs[1] = new PBAD_Follow();
			m_actiondebugs[9] = new PBAD_UseFireArm();
			m_actiondebugs[5] = new PBAD_UseBioScan();
			m_actiondebugs[2] = new PBAD_Attack();
			m_actiondebugs[6] = new PBAD_CollectItem();
			m_actiondebugs[7] = new PBAD_CarryExpeditionItem();
			m_actiondebugs[8] = new PBAD_Melee();
		}

		private void Update()
		{
			if (SNet.IsMaster)
			{
				CheckRootAction();
				if (m_hasRootAction)
				{
					m_brain.Update();
					UpdateCarryExpeditionItem();
					UpdateReviveAction();
					UpdateShareResourceAction();
					UpdateCollectItemAction();
					UpdateUseBioScanAction();
					UpdateHighlightAction();
					UpdateDeployTripMineAction();
					CheckFollowAction();
				}
			}
		}

		private bool TryToGetBackPackItem(InventorySlot slot, out BackpackItem item)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			return PlayerBackpackManager.GetBackpack(m_agent.Owner).TryGetBackpackItem(slot, ref item);
		}

		private void UpdateCarryExpeditionItem()
		{
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			if (!IsDangerousToContinueHoldingExpeditionItem() || !m_bot.TryGetActionDescriptor<Descriptor>(queued: true, active: true, out Descriptor targetDesc))
			{
				return;
			}
			PlayerBotActionCarryExpeditionItem val = ((Il2CppObjectBase)((Descriptor)targetDesc).ActionBase).TryCast<PlayerBotActionCarryExpeditionItem>();
			if (val != null)
			{
				val.SetState((State)0);
				m_bot.StopAction((Descriptor)(object)val.m_collectAction);
				BackpackItem val2 = default(BackpackItem);
				if (val.m_isCarrying && ((PlayerBotActionBase)val).m_backpack.TryGetBackpackItem((InventorySlot)8, ref val2) && Object.op_Implicit((Object)(object)val2.Instance))
				{
					PlayerBackpackManager.WantToDropItem(m_agent.Owner, val2.Instance.Get_pItemData(), ((Agent)m_agent).Position, ((Agent)m_agent).Rotation, true);
					val.m_isCarrying = false;
				}
				m_abortExpeditionItemTimer = Time.time;
				m_firstExpeditionItemTimer = true;
			}
		}

		private void UpdateDeployTripMineAction()
		{
		}

		[HideFromIl2Cpp]
		public bool IsInDangerousSituation()
		{
			if (!Brain.m_damageBrain.IsTakingDamage)
			{
				return Brain.m_enemyBrain.EnemyDetection.m_amountOfSeenEnemies > 3;
			}
			return true;
		}

		[HideFromIl2Cpp]
		public bool IsDangerousToContinueHoldingExpeditionItem()
		{
			if (!Brain.m_damageBrain.IsTakingDamage && Brain.m_enemyBrain.EnemyDetection.m_amountOfSeenEnemiesClose <= 0)
			{
				return Brain.m_enemyBrain.EnemyDetection.m_amountOfSeenOneShotEnemiesClose > 0;
			}
			return true;
		}

		[HideFromIl2Cpp]
		public bool IsDangerousToCollectExpeditionItem()
		{
			if (!Brain.m_damageBrain.IsTakingDamage && Brain.m_enemyBrain.EnemyDetection.m_amountOfSeenEnemiesClose <= 0)
			{
				return Brain.m_enemyBrain.EnemyDetection.m_amountOfSeenOneShotEnemiesClose > 0;
			}
			return true;
		}

		private void UpdateShareResourceAction()
		{
			if (m_rootAction.m_shareResourceAction != null && !((Descriptor)m_rootAction.m_shareResourceAction).IsTerminated() && IsInDangerousSituation())
			{
				((PlayerBotActionBase)m_rootAction).SafeStopAction((Descriptor)(object)m_rootAction.m_shareResourceAction);
			}
		}

		private void CheckFollowAction()
		{
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Invalid comparison between Unknown and I4
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Invalid comparison between Unknown and I4
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: 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_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Expected I4, but got Unknown
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			if (m_rootAction.m_followLeaderAction == null || (Object)(object)m_rootAction.m_followLeaderAction.Client == (Object)null || !((Agent)m_agent).Alive || ((Agent)m_agent).CourseNode == null)
			{
				return;
			}
			PlayerAgent client = m_rootAction.m_followLeaderAction.Client;
			if (((Agent)client).CourseNode == null || !((Agent)client).Alive || TryToGetBackPackItem((InventorySlot)8, out BackpackItem _) || PlayerBotManagerExtended.IsBotCurrentlyBusyWithAction(m_bot) || (int)GameStateManager.CurrentStateName != 10)
			{
				return;
			}
			float num = 20f;
			if ((Object)(object)((Agent)m_agent).CourseNode.m_area != (Object)(object)((Agent)client).CourseNode.m_area)
			{
				num = 10f;
			}
			if ((int)m_agent.Sync.m_locomotionData.State == 8)
			{
				return;
			}
			Vector3 val = ((Agent)client).EyePosition - ((Agent)m_agent).EyePosition;
			bool flag = false;
			Il2CppStructArray<RaycastHit> val2 = Physics.SphereCastAll(((Agent)m_agent).EyePosition, 0.2f, ((Vector3)(ref val)).normalized, ((Vector3)(ref val)).magnitude, LayerManager.MASK_DEFAULT);
			if (((Il2CppArrayBase<RaycastHit>)(object)val2).Count > 0)
			{
				RaycastHit val3 = ((Il2CppArrayBase<RaycastHit>)(object)val2)[0];
				LG_WeakDoor val4 = ((Component)((RaycastHit)(ref val3)).collider).GetComponent<LG_WeakDoor>();
				if ((Object)(object)val4 == (Object)null)
				{
					val4 = ((Component)((RaycastHit)(ref val3)).collider).GetComponentInParent<LG_WeakDoor>();
				}
				if ((Object)(object)val4 != (Object)null)
				{
					flag = true;
				}
			}
			float num2 = Vector3.Distance(((Agent)client).Position, ((Agent)m_agent).Position);
			if ((flag || num2 > num) && ((Descriptor)m_rootAction.m_followLeaderAction).ActionBase != null && TryToGetRandomNavmeshLocation(((Agent)client).Position, 5f, out var finalPosition))
			{
				uint soundEventOnWarpTo = 0u;
				DimensionData val5 = null;
				Dimension dimension = ((Agent)m_agent).Dimension;
				if (((dimension != null) ? dimension.DimensionData : null) != null)
				{
					val5 = ((Agent)m_agent).Dimension.DimensionData;
					soundEventOnWarpTo = val5.SoundEventOnWarpTo;
					val5.SoundEventOnWarpTo = 0u;
				}
				m_agent.WarpTo(finalPosition, ((Agent)client).Rotation, new pPlayerLocationData
				{
					lookDir = ((Agent)m_agent).TargetLookDir,
					courseNode = new pCourseNode
					{
						courseNodeIDPlusOne = (byte)((Agent)m_agent).CourseNode.NodeID
					},
					plocStateReferenceID = (int)m_agent.Locomotion.m_currentStateEnum,
					goodPosition = finalPosition,
					plocState = m_agent.Locomotion.m_currentStateEnum
				});
				if (val5 != null)
				{
					val5.SoundEventOnWarpTo = soundEventOnWarpTo;
				}
			}
		}

		public bool TryToGetRandomNavmeshLocation(Vector3 fromPos, float radius, out Vector3 finalPosition)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			finalPosition = Vector3.zero;
			NavMeshHit val = default(NavMeshHit);
			if (NavMesh.SamplePosition(Random.insideUnitSphere * radius + fromPos, ref val, radius, -1))
			{
				finalPosition = ((NavMeshHit)(ref val)).position;
				return true;
			}
			return false;
		}

		[HideFromIl2Cpp]
		private void UpdateUseBioScanAction()
		{
			if (m_rootAction.m_useBioscanAction != null && ((Descriptor)m_rootAction.m_useBioscanAction).IsTerminated() && m_rootAction.m_followLeaderAction != null && (Object)(object)m_rootAction.m_followLeaderAction.Client != (Object)null && m_rootAction.m_followLeaderAction.Client.IsInBioscan && m_brain.TryToGetBioScanOnPlayerAgent(m_rootAction.m_followLeaderAction.Client, out CP_Bioscan_Core selectedCore))
			{
				((Descriptor)m_rootAction.m_useBioscanAction).Prio = RootPlayerBotAction.m_prioSettings.UseBioscan;
				m_rootAction.m_useBioscanAction.Bioscan = selectedCore;
				if (m_bot.RequestAction((Descriptor)(object)m_rootAction.m_useBioscanAction))
				{
					BBLog.Warn(m_botName + " forcing to go to following agent since they are going rogue...");
				}
				else
				{
					BBLog.Error(m_botName + " tried to be forced to go to following agent since they are going rogue...");
				}
			}
		}

		[HideFromIl2Cpp]
		private void ForceBulletAttack()
		{
			PlayerBotActionAttack val = ((Il2CppObjectBase)((Descriptor)m_rootAction.m_attackAction).ActionBase).TryCast<PlayerBotActionAttack>();
			if (val != null)
			{
				val.m_desc.Means = (AttackMeansEnum)4;
				val.m_desc.Stance = (StanceEnum)1;
			}
		}

		[HideFromIl2Cpp]
		private void ForceMeleeAttack()
		{
			PlayerBotActionAttack val = ((Il2CppObjectBase)((Descriptor)m_rootAction.m_attackAction).ActionBase).TryCast<PlayerBotActionAttack>();
			if (val != null)
			{
				val.m_desc.Means = (AttackMeansEnum)1;
			}
		}

		[HideFromIl2Cpp]
		private void UpdateCollectItemAction()
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			if (m_rootAction.m_collectItemAction == null || ((Descriptor)m_rootAction.m_collectItemAction).IsTerminated())
			{
				return;
			}
			if ((Object)(object)m_rootAction.m_collectItemAction.TargetContainer != (Object)null)
			{
				LG_ResourceContainer_Storage targetContainer = m_rootAction.m_collectItemAction.TargetContainer;
				if (((PlayerBotActionBase)m_rootAction).IsAnyHumanPlayerNear(((Component)targetContainer).transform.position, 5f))
				{
					((PlayerBotActionBase)m_rootAction).SafeStopAction((Descriptor)(object)m_rootAction.m_collectItemAction);
					return;
				}
			}
			m_rootAction.m_collectItemAction.Haste = ((DramaManager.GoToCombat || DramaManager.GoToEncounter) ? 2f : 0.5f);
		}

		[HideFromIl2Cpp]
		private void UpdateHighlightAction()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Invalid comparison between Unknown and I4
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Invalid comparison between Unknown and I4
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			if (m_rootAction.m_highlightAction == null || ((Descriptor)m_rootAction.m_highlightAction).IsTerminated())
			{
				return;
			}
			Descriptor highlightAction = m_rootAction.m_highlightAction;
			if ((int)((Descriptor)highlightAction).Status == 2)
			{
				if (!Brain.m_unlockResourceContainerBrain.HasTargetContainer)
				{
					LG_ResourceContainer_Storage componentInParent = highlightAction.TargetGO.GetComponentInParent<LG_ResourceContainer_Storage>();
					if ((Object)(object)componentInParent != (Object)null)
					{
						Brain.m_unlockResourceContainerBrain.SetTargetResourceContainer(componentInParent);
					}
				}
				else
				{
					PlayerBotActionHighlight val = ((Il2CppObjectBase)((Descriptor)highlightAction).ActionBase).TryCast<PlayerBotActionHighlight>();
					if (val != null && (int)val.m_state == 2)
					{
						Brain.m_unlockResourceContainerBrain.OpenTargetContainer();
					}
				}
			}
			bool flag = false;
			if (m_brain.RestrictHighlightingItems)
			{
				flag = true;
			}
			else if ((DramaManager.GoToCombat || DramaManager.GoToEncounter) && m_rootAction.m_followLeaderAction != null && (Object)(object)m_rootAction.m_followLeaderAction.Client != (Object)null && Vector3.Distance(((Agent)m_agent).Position, ((Agent)m_rootAction.m_followLeaderAction.Client).Position) > 20f)
			{
				flag = true;
			}
			if (flag)
			{
				m_bot.StopAction((Descriptor)(object)m_rootAction.m_highlightAction);
			}
		}

		[HideFromIl2Cpp]
		private void StopReviveActions(PlayerBotActionRevive action)
		{
			m_bot.StopAction((Descriptor)(object)action.m_desc);
			if (action.m_lookAction != null && !((Descriptor)action.m_lookAction).IsTerminated())
			{
				m_bot.StopAction((Descriptor)(object)action.m_lookAction);
			}
			if (action.m_travelAction != null && !((Descriptor)action.m_travelAction).IsTerminated())
			{
				m_bot.StopAction((Descriptor)(object)action.m_travelAction);
			}
		}

		[HideFromIl2Cpp]
		private void UpdateReviveAction()
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Invalid comparison between Unknown and I4
			if (m_rootAction.m_reviveAction == null || ((Descriptor)m_rootAction.m_reviveAction).IsTerminated())
			{
				return;
			}
			Descriptor reviveAction = m_rootAction.m_reviveAction;
			PlayerBotActionBase actionBase = ((Descriptor)reviveAction).ActionBase;
			PlayerBotActionRevive val = ((actionBase != null) ? ((Il2CppObjectBase)actionBase).TryCast<PlayerBotActionRevive>() : null);
			if (!m_brain.ReviveRestricted || val == null)
			{
				return;
			}
			bool flag = false;
			if ((int)val.m_state == 2)
			{
				if ((Object)(object)reviveAction.Client == (Object)null || (Object)(object)reviveAction.Client.ReviveInteraction == (Object)null || ((Interact_Timed)reviveAction.Client.ReviveInteraction).InteractionTimerRel < 0.5f)
				{
					flag = true;
				}
			}
			else
			{
				flag = true;
			}
			if (flag)
			{
				StopReviveActions(val);
				ForceFollowBestPlayerAgent();
			}
		}

		[HideFromIl2Cpp]
		private void ForceFollowBestPlayerAgent()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Invalid comparison between Unknown and I4
			if (m_rootAction.m_followLeade