Decompiled source of Be A Bot v3.0.3

EmpressBotPlayers.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Empress")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("4.5.0.0")]
[assembly: AssemblyInformationalVersion("4.5.0")]
[assembly: AssemblyProduct("EmpressBotPlayers")]
[assembly: AssemblyTitle("EmpressBotPlayers")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("4.5.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Empress.PlayerBot
{
	internal static class BotAccess
	{
		private delegate void EnemyHurtDelegate(EnemyHealth instance, int damage, Vector3 direction);

		private static readonly FieldInfo TruckScreenInstanceField = AccessTools.Field(typeof(TruckScreenText), "instance");

		private static readonly FieldInfo TruckScreenStaticGrabColliderField = AccessTools.Field(typeof(TruckScreenText), "staticGrabCollider");

		private static readonly FieldInfo PhysGrabberGrabbedPhysObjectField = AccessTools.Field(typeof(PhysGrabber), "grabbedPhysGrabObject");

		private static readonly FieldInfo PhysGrabberGrabbedObjectField = AccessTools.Field(typeof(PhysGrabber), "grabbedObject");

		private static readonly FieldInfo PhysGrabberGrabRangeField = AccessTools.Field(typeof(PhysGrabber), "grabRange");

		private static readonly FieldInfo RoundDirectorInstanceField = AccessTools.Field(typeof(RoundDirector), "instance");

		private static readonly FieldInfo RoundExtractionActiveField = AccessTools.Field(typeof(RoundDirector), "extractionPointActive");

		private static readonly FieldInfo RoundExtractionCurrentField = AccessTools.Field(typeof(RoundDirector), "extractionPointCurrent");

		private static readonly FieldInfo RoundAllExtractionsCompletedField = AccessTools.Field(typeof(RoundDirector), "allExtractionPointsCompleted");

		private static readonly FieldInfo PlayerEnergyStartField = AccessTools.Field(typeof(PlayerController), "EnergyStart");

		private static readonly FieldInfo PlayerEnergyCurrentField = AccessTools.Field(typeof(PlayerController), "EnergyCurrent");

		private static readonly FieldInfo PlayerAvatarField = AccessTools.Field(typeof(PlayerController), "playerAvatarScript");

		private static readonly FieldInfo PlayerSteamIdField = AccessTools.Field(typeof(PlayerAvatar), "steamID");

		private static readonly FieldInfo StatsManagerInstanceField = AccessTools.Field(typeof(StatsManager), "instance");

		private static readonly FieldInfo StatsManagerItemDictionaryField = AccessTools.Field(typeof(StatsManager), "itemDictionary");

		private static readonly FieldInfo StatsManagerItemField = AccessTools.Field(typeof(StatsManager), "item");

		private static readonly FieldInfo StatsManagerSpot1TakenField = AccessTools.Field(typeof(StatsManager), "playerInventorySpot1Taken");

		private static readonly FieldInfo StatsManagerSpot2TakenField = AccessTools.Field(typeof(StatsManager), "playerInventorySpot2Taken");

		private static readonly FieldInfo StatsManagerSpot3TakenField = AccessTools.Field(typeof(StatsManager), "playerInventorySpot3Taken");

		private static readonly FieldInfo InventoryInstanceField = AccessTools.Field(typeof(Inventory), "instance");

		private static readonly FieldInfo PunManagerInstanceField = AccessTools.Field(typeof(PunManager), "instance");

		private static readonly FieldInfo PhysGrabberInstanceField = AccessTools.Field(typeof(PhysGrabber), "instance");

		private static readonly FieldInfo ItemDisabledField = AccessTools.Field(typeof(Item), "disabled");

		private static readonly FieldInfo ItemTypeField = AccessTools.Field(typeof(Item), "itemType");

		private static readonly FieldInfo ItemNameField = AccessTools.Field(typeof(Item), "itemName");

		private static readonly FieldInfo ItemPrefabField = AccessTools.Field(typeof(Item), "prefab");

		private static readonly FieldInfo ItemGunMuzzleField = AccessTools.Field(typeof(ItemGun), "gunMuzzle");

		private static readonly FieldInfo ItemGunBatteryField = AccessTools.Field(typeof(ItemGun), "itemBattery");

		private static readonly FieldInfo ItemGunShootCooldownField = AccessTools.Field(typeof(ItemGun), "shootCooldown");

		private static readonly FieldInfo ItemGunShootTimeField = AccessTools.Field(typeof(ItemGun), "shootTime");

		private static readonly FieldInfo ItemGunBatteryDrainField = AccessTools.Field(typeof(ItemGun), "batteryDrain");

		private static readonly FieldInfo ItemGunBatteryDrainFullBarField = AccessTools.Field(typeof(ItemGun), "batteryDrainFullBar");

		private static readonly FieldInfo ItemBatteryLifeField = AccessTools.Field(typeof(ItemBattery), "batteryLife");

		private static readonly FieldInfo ItemBatteryLifeIntField = AccessTools.Field(typeof(ItemBattery), "batteryLifeInt");

		private static readonly FieldInfo ItemBatteryBarsField = AccessTools.Field(typeof(ItemBattery), "batteryBars");

		private static readonly FieldInfo ItemAttributesInstanceNameField = AccessTools.Field(typeof(ItemAttributes), "instanceName");

		private static readonly FieldInfo EnemyDirectorSpawnedField = AccessTools.Field(typeof(EnemyDirector), "enemiesSpawned");

		private static readonly FieldInfo RunManagerLevelIsShopField = AccessTools.Field(typeof(RunManager), "levelIsShop");

		private static readonly FieldInfo ExtractionSpotlight1Field = AccessTools.Field(typeof(ExtractionPoint), "spotlight1");

		private static readonly FieldInfo EnemyParentSpawnedField = AccessTools.Field(typeof(EnemyParent), "Spawned");

		private static readonly FieldInfo EnemyParentEnemyField = AccessTools.Field(typeof(EnemyParent), "Enemy");

		private static readonly FieldInfo EnemyHealthField = AccessTools.Field(typeof(Enemy), "Health");

		private static readonly FieldInfo EnemyHealthCurrentField = AccessTools.Field(typeof(EnemyHealth), "healthCurrent");

		private static readonly FieldInfo EnemyHealthDeadField = AccessTools.Field(typeof(EnemyHealth), "dead");

		private static readonly FieldInfo EnemyHealthDeadImpulseField = AccessTools.Field(typeof(EnemyHealth), "deadImpulse");

		private static readonly MethodInfo InventoryGetAllSpotsMethod = AccessTools.Method(typeof(Inventory), "GetAllSpots", (Type[])null, (Type[])null);

		private static readonly MethodInfo InventorySpotIsOccupiedMethod = AccessTools.Method(typeof(InventorySpot), "IsOccupied", (Type[])null, (Type[])null);

		private static readonly MethodInfo StatsManagerSetBatteryLevelMethod = AccessTools.Method(typeof(StatsManager), "SetBatteryLevel", new Type[2]
		{
			typeof(string),
			typeof(int)
		}, (Type[])null);

		private static readonly MethodInfo StatsManagerDictionaryUpdateValueMethod = AccessTools.Method(typeof(StatsManager), "DictionaryUpdateValue", new Type[3]
		{
			typeof(string),
			typeof(string),
			typeof(int)
		}, (Type[])null);

		private static readonly MethodInfo PunManagerUpdateStatMethod = AccessTools.Method(typeof(PunManager), "UpdateStat", new Type[3]
		{
			typeof(string),
			typeof(string),
			typeof(int)
		}, (Type[])null);

		private static readonly MethodInfo PunManagerSetItemNameMethod = AccessTools.Method(typeof(PunManager), "SetItemName", new Type[3]
		{
			typeof(string),
			typeof(ItemAttributes),
			typeof(int)
		}, (Type[])null);

		private static readonly MethodInfo PrefabResourcePathGetter = AccessTools.PropertyGetter(typeof(PrefabRef), "ResourcePath");

		private static readonly MethodInfo PrefabObjectGetter = AccessTools.PropertyGetter(typeof(PrefabRef), "Prefab");

		private static readonly MethodInfo ItemEquippableRequestEquipMethod = AccessTools.Method(typeof(ItemEquippable), "RequestEquip", new Type[2]
		{
			typeof(int),
			typeof(int)
		}, (Type[])null);

		private static readonly MethodInfo PhysGrabberOverrideGrabMethod = AccessTools.Method(typeof(PhysGrabber), "OverrideGrab", new Type[3]
		{
			typeof(PhysGrabObject),
			typeof(float),
			typeof(bool)
		}, (Type[])null);

		private static readonly MethodInfo PhysGrabberOverrideAlwaysGrabbableMethod = AccessTools.Method(typeof(PhysGrabber), "OverrideAlwaysGrabbable", new Type[1] { typeof(float) }, (Type[])null);

		private static readonly MethodInfo PhysGrabberOverrideGrabDistanceMethod = AccessTools.Method(typeof(PhysGrabber), "OverrideGrabDistance", new Type[1] { typeof(float) }, (Type[])null);

		private static readonly MethodInfo PhysGrabberOverrideGrabReleaseMethod = AccessTools.Method(typeof(PhysGrabber), "OverrideGrabRelease", new Type[2]
		{
			typeof(int),
			typeof(float)
		}, (Type[])null);

		private static readonly MethodInfo ExtractionPointOnClickMethod = AccessTools.Method(typeof(ExtractionPoint), "OnClick", (Type[])null, (Type[])null);

		private static readonly EnemyHurtDelegate EnemyHurt = CreateEnemyHurtDelegate();

		private static readonly FieldInfo ShopManagerInstanceField = AccessTools.Field(typeof(ShopManager), "instance");

		private static readonly FieldInfo ShopManagerTotalCurrencyField = AccessTools.Field(typeof(ShopManager), "totalCurrency");

		private static readonly FieldInfo ShopManagerTotalCostField = AccessTools.Field(typeof(ShopManager), "totalCost");

		private static readonly FieldInfo ItemAttributesItemField = AccessTools.Field(typeof(ItemAttributes), "item");

		private static readonly FieldInfo ItemAttributesValueField = AccessTools.Field(typeof(ItemAttributes), "value");

		private static readonly MethodInfo ExtractionPointOnShopClickMethod = AccessTools.Method(typeof(ExtractionPoint), "OnShopClick", (Type[])null, (Type[])null);

		private static readonly MethodInfo ExtractionPointButtonPressMethod = AccessTools.Method(typeof(ExtractionPoint), "ButtonPress", (Type[])null, (Type[])null);

		public static TruckScreenText TruckScreen()
		{
			return GetStatic<TruckScreenText>(TruckScreenInstanceField);
		}

		public static GameObject TruckScreenStaticGrabCollider(TruckScreenText screen)
		{
			return Get<GameObject>(TruckScreenStaticGrabColliderField, screen);
		}

		public static PhysGrabObject GrabbedPhysObject(PhysGrabber grabber)
		{
			return Get<PhysGrabObject>(PhysGrabberGrabbedPhysObjectField, grabber);
		}

		public static Rigidbody GrabbedRigidbody(PhysGrabber grabber)
		{
			return Get<Rigidbody>(PhysGrabberGrabbedObjectField, grabber);
		}

		public static float GrabRange(PhysGrabber grabber)
		{
			return GetFloat(PhysGrabberGrabRangeField, grabber, 4f);
		}

		public static RoundDirector RoundDirector()
		{
			return GetStatic<RoundDirector>(RoundDirectorInstanceField);
		}

		public static bool ExtractionPointActive(RoundDirector round)
		{
			return GetBool(RoundExtractionActiveField, round);
		}

		public static ExtractionPoint CurrentExtractionPoint(RoundDirector round)
		{
			return Get<ExtractionPoint>(RoundExtractionCurrentField, round);
		}

		public static bool AllExtractionsCompleted(RoundDirector round)
		{
			return GetBool(RoundAllExtractionsCompletedField, round);
		}

		public static float EnergyStart(PlayerController player)
		{
			return GetFloat(PlayerEnergyStartField, player, 0f);
		}

		public static float EnergyCurrent(PlayerController player)
		{
			return GetFloat(PlayerEnergyCurrentField, player, 0f);
		}

		public static PlayerAvatar PlayerAvatar(PlayerController player)
		{
			return Get<PlayerAvatar>(PlayerAvatarField, player);
		}

		public static string PlayerSteamId(PlayerAvatar avatar)
		{
			return GetString(PlayerSteamIdField, avatar);
		}

		public static StatsManager StatsManagerInstance()
		{
			return GetStatic<StatsManager>(StatsManagerInstanceField);
		}

		public static Inventory InventoryInstance()
		{
			return GetStatic<Inventory>(InventoryInstanceField);
		}

		public static PunManager PunManagerInstance()
		{
			return GetStatic<PunManager>(PunManagerInstanceField);
		}

		public static Dictionary<string, Item> ItemDictionary(StatsManager stats)
		{
			return Get<Dictionary<string, Item>>(StatsManagerItemDictionaryField, stats);
		}

		public static Dictionary<string, int> ItemInstances(StatsManager stats)
		{
			return Get<Dictionary<string, int>>(StatsManagerItemField, stats);
		}

		public static Dictionary<string, int> InventorySpotTaken(StatsManager stats, int spot)
		{
			return spot switch
			{
				1 => Get<Dictionary<string, int>>(StatsManagerSpot2TakenField, stats), 
				0 => Get<Dictionary<string, int>>(StatsManagerSpot1TakenField, stats), 
				_ => Get<Dictionary<string, int>>(StatsManagerSpot3TakenField, stats), 
			};
		}

		public static bool ItemDisabled(Item item)
		{
			return GetBool(ItemDisabledField, item);
		}

		public static itemType ItemType(Item item)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return GetStruct<itemType>(ItemTypeField, (object)item, (itemType)0);
		}

		public static string ItemDisplayName(Item item)
		{
			return GetString(ItemNameField, item);
		}

		public static PrefabRef ItemPrefab(Item item)
		{
			return Get<PrefabRef>(ItemPrefabField, item);
		}

		public static string PrefabResourcePath(PrefabRef prefab)
		{
			if (prefab == null || PrefabResourcePathGetter == null)
			{
				return string.Empty;
			}
			try
			{
				return (PrefabResourcePathGetter.Invoke(prefab, null) as string) ?? string.Empty;
			}
			catch
			{
				return string.Empty;
			}
		}

		public static GameObject PrefabObject(PrefabRef prefab)
		{
			if (prefab == null || PrefabObjectGetter == null)
			{
				return null;
			}
			try
			{
				object? obj = PrefabObjectGetter.Invoke(prefab, null);
				return (GameObject)((obj is GameObject) ? obj : null);
			}
			catch
			{
				return null;
			}
		}

		public static List<InventorySpot> GetAllInventorySpots(Inventory inventory)
		{
			if (!Object.op_Implicit((Object)(object)inventory) || InventoryGetAllSpotsMethod == null)
			{
				return new List<InventorySpot>();
			}
			try
			{
				return (InventoryGetAllSpotsMethod.Invoke(inventory, null) as List<InventorySpot>) ?? new List<InventorySpot>();
			}
			catch
			{
				return new List<InventorySpot>();
			}
		}

		public static bool IsInventorySpotOccupied(InventorySpot spot)
		{
			if (!Object.op_Implicit((Object)(object)spot) || InventorySpotIsOccupiedMethod == null)
			{
				return true;
			}
			try
			{
				object obj = InventorySpotIsOccupiedMethod.Invoke(spot, null);
				bool flag = default(bool);
				int num;
				if (obj is bool)
				{
					flag = (bool)obj;
					num = 1;
				}
				else
				{
					num = 0;
				}
				return (byte)((uint)num & (flag ? 1u : 0u)) != 0;
			}
			catch
			{
				return true;
			}
		}

		public static void SetBatteryLevel(StatsManager stats, string itemName, int value)
		{
			if (!Object.op_Implicit((Object)(object)stats) || string.IsNullOrEmpty(itemName) || StatsManagerSetBatteryLevelMethod == null)
			{
				return;
			}
			try
			{
				StatsManagerSetBatteryLevelMethod.Invoke(stats, new object[2] { itemName, value });
			}
			catch
			{
			}
		}

		public static void DictionaryUpdateValue(StatsManager stats, string dictionaryName, string key, int value)
		{
			if (!Object.op_Implicit((Object)(object)stats) || string.IsNullOrEmpty(dictionaryName) || string.IsNullOrEmpty(key) || StatsManagerDictionaryUpdateValueMethod == null)
			{
				return;
			}
			try
			{
				StatsManagerDictionaryUpdateValueMethod.Invoke(stats, new object[3] { dictionaryName, key, value });
			}
			catch
			{
			}
		}

		public static void UpdateStat(PunManager manager, string dictionaryName, string key, int value)
		{
			if (!Object.op_Implicit((Object)(object)manager) || string.IsNullOrEmpty(dictionaryName) || string.IsNullOrEmpty(key) || PunManagerUpdateStatMethod == null)
			{
				return;
			}
			try
			{
				PunManagerUpdateStatMethod.Invoke(manager, new object[3] { dictionaryName, key, value });
			}
			catch
			{
			}
		}

		public static void SetItemName(PunManager manager, string itemName, ItemAttributes attributes, int photonViewId)
		{
			if (!Object.op_Implicit((Object)(object)manager) || string.IsNullOrEmpty(itemName) || !Object.op_Implicit((Object)(object)attributes) || PunManagerSetItemNameMethod == null)
			{
				return;
			}
			try
			{
				PunManagerSetItemNameMethod.Invoke(manager, new object[3] { itemName, attributes, photonViewId });
			}
			catch
			{
			}
		}

		public static void RequestEquip(ItemEquippable equippable, int spot, int requesterViewId)
		{
			if (!Object.op_Implicit((Object)(object)equippable) || ItemEquippableRequestEquipMethod == null)
			{
				return;
			}
			try
			{
				ItemEquippableRequestEquipMethod.Invoke(equippable, new object[2] { spot, requesterViewId });
			}
			catch
			{
			}
		}

		public static void OverrideGrab(PhysGrabObject target, float grabTime)
		{
			PhysGrabber @static = GetStatic<PhysGrabber>(PhysGrabberInstanceField);
			if (!Object.op_Implicit((Object)(object)@static) || !Object.op_Implicit((Object)(object)target) || PhysGrabberOverrideGrabMethod == null)
			{
				return;
			}
			try
			{
				PhysGrabberOverrideGrabMethod.Invoke(@static, new object[3] { target, grabTime, false });
			}
			catch
			{
			}
		}

		public static void OverrideGrab(PhysGrabber grabber, PhysGrabObject target, float grabTime)
		{
			if (!Object.op_Implicit((Object)(object)grabber) || !Object.op_Implicit((Object)(object)target) || PhysGrabberOverrideGrabMethod == null)
			{
				return;
			}
			try
			{
				PhysGrabberOverrideGrabMethod.Invoke(grabber, new object[3] { target, grabTime, false });
			}
			catch
			{
			}
		}

		public static void OverrideAlwaysGrabbable(PhysGrabber grabber, float time)
		{
			if (!Object.op_Implicit((Object)(object)grabber) || PhysGrabberOverrideAlwaysGrabbableMethod == null)
			{
				return;
			}
			try
			{
				PhysGrabberOverrideAlwaysGrabbableMethod.Invoke(grabber, new object[1] { time });
			}
			catch
			{
			}
		}

		public static void OverrideGrabDistance(PhysGrabber grabber, float distance)
		{
			if (!Object.op_Implicit((Object)(object)grabber) || PhysGrabberOverrideGrabDistanceMethod == null)
			{
				return;
			}
			try
			{
				PhysGrabberOverrideGrabDistanceMethod.Invoke(grabber, new object[1] { distance });
			}
			catch
			{
			}
		}

		public static void ReleaseGrab(PhysGrabber grabber, PhysGrabObject target, float time)
		{
			if (!Object.op_Implicit((Object)(object)grabber) || !Object.op_Implicit((Object)(object)target) || PhysGrabberOverrideGrabReleaseMethod == null)
			{
				return;
			}
			try
			{
				PhysGrabberOverrideGrabReleaseMethod.Invoke(grabber, new object[2]
				{
					PhotonViewId((Component)(object)target),
					time
				});
			}
			catch
			{
			}
		}

		public static int PhotonViewId(Component component)
		{
			if (!Object.op_Implicit((Object)(object)component))
			{
				return -1;
			}
			PhotonView component2 = component.GetComponent<PhotonView>();
			if (!Object.op_Implicit((Object)(object)component2))
			{
				return -1;
			}
			return component2.ViewID;
		}

		public static Transform GunMuzzle(ItemGun gun)
		{
			return Get<Transform>(ItemGunMuzzleField, gun);
		}

		public static ItemBattery GunBattery(ItemGun gun)
		{
			return Get<ItemBattery>(ItemGunBatteryField, gun);
		}

		public static void TuneBotGun(ItemGun gun)
		{
			if (Object.op_Implicit((Object)(object)gun))
			{
				SetField(ItemGunShootCooldownField, gun, 0.08f);
				SetField(ItemGunShootTimeField, gun, 0.03f);
				SetField(ItemGunBatteryDrainField, gun, 0f);
				SetField(ItemGunBatteryDrainFullBarField, gun, value: false);
				gun.gunRandomSpread = 0f;
				gun.gunRange = Mathf.Max(gun.gunRange, 50f);
			}
		}

		public static int BatteryBars(ItemBattery battery)
		{
			return GetStruct(ItemBatteryBarsField, battery, 0);
		}

		public static void SetBattery(ItemBattery battery, float life, int lifeInt)
		{
			if (Object.op_Implicit((Object)(object)battery))
			{
				SetField(ItemBatteryLifeField, battery, life);
				SetField(ItemBatteryLifeIntField, battery, lifeInt);
			}
		}

		public static string ItemInstanceName(ItemAttributes attributes)
		{
			return GetString(ItemAttributesInstanceNameField, attributes);
		}

		public static List<EnemyParent> EnemiesSpawned()
		{
			return Get<List<EnemyParent>>(EnemyDirectorSpawnedField, EnemyDirector.instance) ?? new List<EnemyParent>();
		}

		public static bool RunLevelIsShop(RunManager runManager)
		{
			return GetBool(RunManagerLevelIsShopField, runManager);
		}

		public static bool ExtractionSpotlightEnabled(ExtractionPoint point)
		{
			Light val = Get<Light>(ExtractionSpotlight1Field, point);
			if (Object.op_Implicit((Object)(object)val))
			{
				return ((Behaviour)val).enabled;
			}
			return false;
		}

		public static void ActivateExtractionPoint(ExtractionPoint point)
		{
			if (!Object.op_Implicit((Object)(object)point) || ExtractionPointOnClickMethod == null)
			{
				return;
			}
			try
			{
				ExtractionPointOnClickMethod.Invoke(point, null);
			}
			catch
			{
			}
		}

		public static void ShopCheckout(ExtractionPoint point)
		{
			if (!Object.op_Implicit((Object)(object)point) || ExtractionPointOnShopClickMethod == null)
			{
				return;
			}
			try
			{
				ExtractionPointOnShopClickMethod.Invoke(point, null);
			}
			catch
			{
			}
		}

		public static void ShopButtonPress(ExtractionPoint point)
		{
			if (!Object.op_Implicit((Object)(object)point) || ExtractionPointButtonPressMethod == null)
			{
				return;
			}
			try
			{
				ExtractionPointButtonPressMethod.Invoke(point, null);
			}
			catch
			{
			}
		}

		public static ShopManager ShopManagerInstance()
		{
			return GetStatic<ShopManager>(ShopManagerInstanceField);
		}

		public static int ShopTotalCurrency(ShopManager shop)
		{
			return GetInt(ShopManagerTotalCurrencyField, shop, 0);
		}

		public static int ShopTotalCost(ShopManager shop)
		{
			return GetInt(ShopManagerTotalCostField, shop, 0);
		}

		public static Item ItemFromAttributes(ItemAttributes attributes)
		{
			return Get<Item>(ItemAttributesItemField, attributes);
		}

		public static int ItemAttributesValue(ItemAttributes attributes)
		{
			return GetInt(ItemAttributesValueField, attributes, 0);
		}

		public static int EnemyHealthCurrent(EnemyHealth health)
		{
			return GetInt(EnemyHealthCurrentField, health, 1);
		}

		public static bool EnemyParentSpawned(EnemyParent enemyParent)
		{
			return GetBool(EnemyParentSpawnedField, enemyParent);
		}

		public static Enemy EnemyFromParent(EnemyParent enemyParent)
		{
			return Get<Enemy>(EnemyParentEnemyField, enemyParent);
		}

		public static EnemyHealth EnemyHealth(Enemy enemy)
		{
			return Get<EnemyHealth>(EnemyHealthField, enemy);
		}

		public static bool EnemyHealthDead(EnemyHealth health)
		{
			if (!GetBool(EnemyHealthDeadField, health) && !GetBool(EnemyHealthDeadImpulseField, health))
			{
				return EnemyHealthCurrent(health) <= 0;
			}
			return true;
		}

		public static void HurtEnemy(EnemyHealth health, int damage, Vector3 direction)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)health == (Object)null || EnemyHurt == null)
			{
				return;
			}
			try
			{
				EnemyHurt(health, damage, direction);
			}
			catch
			{
			}
		}

		private static T GetStatic<T>(FieldInfo field) where T : class
		{
			if (field == null)
			{
				return null;
			}
			try
			{
				return field.GetValue(null) as T;
			}
			catch
			{
				return null;
			}
		}

		private static T Get<T>(FieldInfo field, object instance) where T : class
		{
			if (field == null || instance == null)
			{
				return null;
			}
			try
			{
				return field.GetValue(instance) as T;
			}
			catch
			{
				return null;
			}
		}

		private static bool GetBool(FieldInfo field, object instance)
		{
			if (field == null || instance == null)
			{
				return false;
			}
			try
			{
				object value = field.GetValue(instance);
				bool flag = default(bool);
				int num;
				if (value is bool)
				{
					flag = (bool)value;
					num = 1;
				}
				else
				{
					num = 0;
				}
				return (byte)((uint)num & (flag ? 1u : 0u)) != 0;
			}
			catch
			{
				return false;
			}
		}

		private static float GetFloat(FieldInfo field, object instance, float fallback)
		{
			if (field == null || instance == null)
			{
				return fallback;
			}
			try
			{
				return (field.GetValue(instance) is float num) ? num : fallback;
			}
			catch
			{
				return fallback;
			}
		}

		private static int GetInt(FieldInfo field, object instance, int fallback)
		{
			if (field == null || instance == null)
			{
				return fallback;
			}
			try
			{
				return (field.GetValue(instance) is int num) ? num : fallback;
			}
			catch
			{
				return fallback;
			}
		}

		private static string GetString(FieldInfo field, object instance)
		{
			if (field == null || instance == null)
			{
				return string.Empty;
			}
			try
			{
				return (field.GetValue(instance) as string) ?? string.Empty;
			}
			catch
			{
				return string.Empty;
			}
		}

		private static T GetStruct<T>(FieldInfo field, object instance, T fallback) where T : struct
		{
			if (field == null || instance == null)
			{
				return fallback;
			}
			try
			{
				return (field.GetValue(instance) is T val) ? val : fallback;
			}
			catch
			{
				return fallback;
			}
		}

		private static void SetField<T>(FieldInfo field, object instance, T value)
		{
			if (field == null || instance == null)
			{
				return;
			}
			try
			{
				field.SetValue(instance, value);
			}
			catch
			{
			}
		}

		private static EnemyHurtDelegate CreateEnemyHurtDelegate()
		{
			try
			{
				MethodInfo methodInfo = AccessTools.Method(typeof(EnemyHealth), "Hurt", (Type[])null, (Type[])null);
				return (methodInfo == null) ? null : AccessTools.MethodDelegate<EnemyHurtDelegate>(methodInfo, (object)null, true);
			}
			catch
			{
				return null;
			}
		}
	}
	[HarmonyPatch(typeof(InputManager))]
	public static class BotInputPatches
	{
		[HarmonyPatch("GetMovementX")]
		[HarmonyPrefix]
		public static bool MoveX(ref float __result)
		{
			if (!PlayerIsBotComplete.IsActive)
			{
				return true;
			}
			__result = PlayerIsBotComplete.MoveInput.x;
			return false;
		}

		[HarmonyPatch("GetMovementY")]
		[HarmonyPrefix]
		public static bool MoveY(ref float __result)
		{
			if (!PlayerIsBotComplete.IsActive)
			{
				return true;
			}
			__result = PlayerIsBotComplete.MoveInput.y;
			return false;
		}

		[HarmonyPatch("GetMouseX")]
		[HarmonyPrefix]
		public static bool LookX(ref float __result)
		{
			if (!PlayerIsBotComplete.IsActive)
			{
				return true;
			}
			__result = PlayerIsBotComplete.LookInput.x;
			return false;
		}

		[HarmonyPatch("GetMouseY")]
		[HarmonyPrefix]
		public static bool LookY(ref float __result)
		{
			if (!PlayerIsBotComplete.IsActive)
			{
				return true;
			}
			__result = PlayerIsBotComplete.LookInput.y;
			return false;
		}

		[HarmonyPatch("KeyHold")]
		[HarmonyPrefix]
		public static bool KeyHold(InputKey key, ref bool __result)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Invalid comparison between Unknown and I4
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Invalid comparison between Unknown and I4
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Invalid comparison between Unknown and I4
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Invalid comparison between Unknown and I4
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Invalid comparison between Unknown and I4
			if (!PlayerIsBotComplete.IsActive)
			{
				return true;
			}
			if ((int)key == 1)
			{
				__result = PlayerIsBotComplete.InputJump;
				return false;
			}
			if ((int)key == 2)
			{
				__result = PlayerIsBotComplete.InputInteract;
				return false;
			}
			if ((int)key == 4)
			{
				__result = PlayerIsBotComplete.InputThrow;
				return false;
			}
			if ((int)key == 10)
			{
				__result = PlayerIsBotComplete.InputGrab;
				return false;
			}
			if ((int)key == 15)
			{
				__result = PlayerIsBotComplete.InputSprint;
				return false;
			}
			return true;
		}

		[HarmonyPatch("KeyDown")]
		[HarmonyPrefix]
		public static bool KeyDown(InputKey key, ref bool __result)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Invalid comparison between Unknown and I4
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Invalid comparison between Unknown and I4
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Invalid comparison between Unknown and I4
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Invalid comparison between Unknown and I4
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Invalid comparison between Unknown and I4
			if (!PlayerIsBotComplete.IsActive)
			{
				return true;
			}
			if ((int)key == 1)
			{
				__result = PlayerIsBotComplete.InputJump;
				return false;
			}
			if ((int)key == 2)
			{
				__result = PlayerIsBotComplete.InputInteract;
				return false;
			}
			if ((int)key == 4)
			{
				__result = PlayerIsBotComplete.InputThrow;
				return false;
			}
			if ((int)key == 10)
			{
				__result = PlayerIsBotComplete.InputGrab;
				return false;
			}
			if ((int)key == 15)
			{
				__result = PlayerIsBotComplete.InputSprint;
				return false;
			}
			return true;
		}
	}
	public class PlayerBotBrain : MonoBehaviour
	{
		public enum State
		{
			Initializing,
			Wandering,
			ChasingLoot,
			Grabbing,
			CarryingToTruck,
			GoingToTruck,
			StartingEngine,
			WaitingForActivation,
			Combat
		}

		private PlayerController _player;

		private State _currentState;

		private PhysGrabObject _targetLoot;

		private PhysGrabObject _lastTargetLoot;

		private ExtractionPoint _targetExtractor;

		private float _chaseTimer;

		private int _lastActivateId;

		private float _lastActivateTime;

		private float _grabAttemptTimer;

		private float _truckInteractTimer;

		private string _debugStatus = "Initializing...";

		private bool _reachedTruck;

		private bool _returningToTruckBeforeScreenRetry;

		private float _retargetTimer;

		private float _waitingForActivationTimer;

		private float _deliveryNoPathTimer;

		private float _deliveryStillTimer;

		private float _deliveryRecoveryUntil;

		private float _deliveryRepathTimer;

		private float _deliveryEndpointTimer;

		private Vector3 _deliveryRecoveryPoint;

		private Vector3 _deliveryLastGoal;

		private Vector3 _lastDeliveryPosition;

		private ExtractionPoint _deliveryCommittedExtractor;

		private int _deliveryCommittedItemId;

		private float _lootRepathTimer;

		private Vector3 _lastLootGoal;

		private State _lastLoggedState;

		private string _lastLoggedStatus;

		private float _stateTraceTimer;

		private string _sceneKey;

		private Coroutine _initRoutine;

		private bool _levelReady;

		private float _offMeshTimer;

		private Vector3 _globalIdlePosition;

		private float _globalIdleTimer;

		private int _shopCarriedUpgradeId;

		private ExtractionPoint _shopCheckoutExtractor;

		public Transform CamTr { get; private set; }

		public PlayerBotNavigation Navigation { get; private set; }

		public PlayerBotLootScanner LootScanner { get; private set; }

		public PlayerBotCarryController CarryController { get; private set; }

		public PlayerBotExtractionController ExtractionController { get; private set; }

		public PlayerBotCombatController CombatController { get; private set; }

		public PlayerBotShopController ShopController { get; private set; }

		public bool IsWanderingState => _currentState == State.Wandering;

		private void Start()
		{
			_player = ((Component)this).GetComponent<PlayerController>();
			RefreshCameraTransform();
			Navigation = new PlayerBotNavigation(this);
			LootScanner = new PlayerBotLootScanner(this);
			CarryController = new PlayerBotCarryController(this);
			ExtractionController = new PlayerBotExtractionController(this);
			CombatController = new PlayerBotCombatController(this);
			ShopController = new PlayerBotShopController(this);
			_sceneKey = ResolveLevelKey();
			BeginLevelInitialization(releaseCarry: false);
		}

		private void OnDisable()
		{
			PlayerIsBotComplete.IsActive = false;
			if (CarryController != null && Object.op_Implicit((Object)(object)CarryController.CarriedItem))
			{
				CarryController.ReleaseItem(immediate: true);
			}
		}

		private void OnGUI()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)PlayerIsBotComplete.Instance == (Object)null) && PlayerIsBotComplete.Instance.ShowOverlay.Value)
			{
				GUI.color = Color.cyan;
				GUI.skin.label.fontStyle = (FontStyle)1;
				GUI.skin.box.fontStyle = (FontStyle)1;
				GUI.Box(new Rect(10f, 10f, 300f, 200f), "Be A Bot");
				GUI.Label(new Rect(20f, 35f, 280f, 20f), $"State: {_currentState}");
				GUI.Label(new Rect(20f, 50f, 280f, 20f), "Target: " + (Object.op_Implicit((Object)(object)_targetLoot) ? ((Object)_targetLoot).name : "None"));
				GUI.Label(new Rect(20f, 65f, 280f, 20f), "Carrying: " + (Object.op_Implicit((Object)(object)CarryController.CarriedItem) ? ((Object)CarryController.CarriedItem).name : "None"));
				GUI.Label(new Rect(20f, 80f, 280f, 20f), $"Stuck: {Navigation.StuckTimer:F1}");
				GUI.Label(new Rect(20f, 95f, 280f, 20f), "Status: " + _debugStatus);
				GUI.Label(new Rect(20f, 110f, 280f, 20f), $"Carry Time: {CarryController.CarryTimer:F1}s");
				GUI.Label(new Rect(20f, 125f, 280f, 20f), $"Reached Truck: {_reachedTruck}");
				Rigidbody val = (Object.op_Implicit((Object)(object)CarryController.Grabber) ? BotAccess.GrabbedRigidbody(CarryController.Grabber) : null);
				string text = (Object.op_Implicit((Object)(object)val) ? ((Object)val).name : "Nothing");
				GUI.Label(new Rect(20f, 155f, 280f, 20f), "Hand: " + text);
				GUI.Label(new Rect(20f, 170f, 280f, 20f), $"Inputs Locked: {PlayerIsBotComplete.IsActive}");
				GUI.skin.label.fontStyle = (FontStyle)0;
				GUI.skin.box.fontStyle = (FontStyle)0;
			}
		}

		public void SetDebugStatus(string status)
		{
			if (!(_debugStatus == status))
			{
				_debugStatus = status;
				PlayerIsBotComplete.DebugLog("Status=" + status);
			}
		}

		private void RefreshCameraTransform()
		{
			Transform val = ResolveCameraTransform();
			if (Object.op_Implicit((Object)(object)val))
			{
				CamTr = val;
			}
		}

		private Transform ResolveCameraTransform()
		{
			PlayerAvatar val = null;
			if (Object.op_Implicit((Object)(object)_player))
			{
				val = _player.playerAvatarScript;
			}
			if (!Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)PlayerController.instance))
			{
				val = PlayerController.instance.playerAvatarScript;
			}
			if (!Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)PlayerAvatar.instance))
			{
				val = PlayerAvatar.instance;
			}
			if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.PlayerVisionTarget) && Object.op_Implicit((Object)(object)val.PlayerVisionTarget.VisionTransform))
			{
				return val.PlayerVisionTarget.VisionTransform;
			}
			if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.localCamera))
			{
				return ((Component)val.localCamera).transform;
			}
			Camera val2 = ((Component)this).GetComponentInChildren<Camera>();
			if (!Object.op_Implicit((Object)(object)val2))
			{
				val2 = Camera.main;
			}
			if (Object.op_Implicit((Object)(object)val2))
			{
				return ((Component)val2).transform;
			}
			return ((Component)this).transform;
		}

		private IEnumerator InitLevelData()
		{
			_levelReady = false;
			PlayerIsBotComplete.IsActive = false;
			PlayerIsBotComplete.ClearInputs();
			_debugStatus = "Waiting for LevelGen...";
			while ((Object)(object)LevelGenerator.Instance == (Object)null || !LevelGenerator.Instance.Generated)
			{
				yield return (object)new WaitForSeconds(1f);
			}
			_debugStatus = "Waiting for NavMesh...";
			yield return (object)new WaitForSeconds(1f);
			bool placed = false;
			while (!placed)
			{
				if (Navigation.TryPlaceOnNavMesh(((Component)this).transform.position))
				{
					placed = true;
					continue;
				}
				_debugStatus = "Retrying NavMesh...";
				yield return (object)new WaitForSeconds(2f);
			}
			Navigation.BuildGlobalTargets();
			Navigation.PickWanderDest();
			_currentState = State.Wandering;
			_debugStatus = "Ready";
			_levelReady = true;
			PlayerIsBotComplete.IsActive = true;
			_initRoutine = null;
		}

		private void BeginLevelInitialization(bool releaseCarry)
		{
			if (_initRoutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(_initRoutine);
			}
			ResetRuntimeState(releaseCarry);
			_initRoutine = ((MonoBehaviour)this).StartCoroutine(InitLevelData());
		}

		private void ResetRuntimeState(bool releaseCarry)
		{
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			_levelReady = false;
			PlayerIsBotComplete.IsActive = false;
			PlayerIsBotComplete.ClearInputs();
			if (releaseCarry && CarryController != null && Object.op_Implicit((Object)(object)CarryController.CarriedItem))
			{
				CarryController.ReleaseItem(immediate: true);
			}
			_targetLoot = null;
			_lastTargetLoot = null;
			_targetExtractor = null;
			_lastActivateId = 0;
			_lastActivateTime = 0f;
			_currentState = State.Initializing;
			_debugStatus = "Waiting for LevelGen...";
			_chaseTimer = 0f;
			_grabAttemptTimer = 0f;
			_truckInteractTimer = 0f;
			_reachedTruck = false;
			_returningToTruckBeforeScreenRetry = false;
			_retargetTimer = 0f;
			_waitingForActivationTimer = 0f;
			_lootRepathTimer = 0f;
			_lastLootGoal = Vector3.zero;
			_stateTraceTimer = 0f;
			_lastLoggedStatus = null;
			_offMeshTimer = 0f;
			_globalIdlePosition = Vector3.zero;
			_globalIdleTimer = 0f;
			_shopCarriedUpgradeId = 0;
			_shopCheckoutExtractor = null;
			ResetDeliveryState();
			if (Navigation != null)
			{
				Navigation.ResetRuntime();
			}
			if (LootScanner != null)
			{
				LootScanner.Reset();
			}
			if (ShopController != null)
			{
				ShopController.ResetForNewScene(_sceneKey);
			}
		}

		private string ResolveLevelKey()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			Scene activeScene = SceneManager.GetActiveScene();
			string name = ((Scene)(ref activeScene)).name;
			int num = (Object.op_Implicit((Object)(object)LevelGenerator.Instance) ? ((Object)LevelGenerator.Instance).GetInstanceID() : 0);
			bool flag = false;
			bool flag2 = false;
			bool flag3 = false;
			try
			{
				flag = SemiFunc.RunIsShop();
				flag2 = SemiFunc.RunIsLevel();
				flag3 = SemiFunc.MenuLevel();
			}
			catch
			{
			}
			return $"{name}:{num}:{flag}:{flag2}:{flag3}";
		}

		private void Update()
		{
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			if (!PlayerIsBotComplete.CanRunOnThisPeer())
			{
				PlayerIsBotComplete.IsActive = false;
				PlayerIsBotComplete.ClearInputs();
			}
			else
			{
				if ((Object)(object)Navigation.Agent == (Object)null)
				{
					return;
				}
				string text = ResolveLevelKey();
				if (_sceneKey != text)
				{
					_sceneKey = text;
					BeginLevelInitialization(releaseCarry: true);
					return;
				}
				RefreshCameraTransform();
				if (!_levelReady)
				{
					PlayerIsBotComplete.IsActive = false;
					PlayerIsBotComplete.ClearInputs();
					TraceState();
					return;
				}
				PlayerIsBotComplete.IsActive = true;
				Navigation.Agent.nextPosition = ((Component)this).transform.position;
				if (!Navigation.Agent.isOnNavMesh)
				{
					PlayerIsBotComplete.ClearInputs();
					_offMeshTimer += Time.deltaTime;
					if (Navigation.TryPlaceOnNavMesh(((Component)this).transform.position, 6f))
					{
						_offMeshTimer = 0f;
					}
					else if (Navigation.TryPlaceOnNavMesh(((Component)this).transform.position, 20f))
					{
						_offMeshTimer = 0f;
					}
					else if (_offMeshTimer > 5f)
					{
						_offMeshTimer = 0f;
						BeginLevelInitialization(releaseCarry: false);
					}
					return;
				}
				_offMeshTimer = 0f;
				LootScanner.UpdateTimers();
				ExtractionController.Update();
				CombatController.UpdateLoadout();
				if ((Object)(object)PlayerIsBotComplete.Instance != (Object)null && PlayerIsBotComplete.Instance.CombatAssist.Value && CombatController.UpdateCombat())
				{
					_currentState = State.Combat;
				}
				else
				{
					UpdateDecisions();
					Navigation.UpdateMovement();
				}
				UpdateAiming();
				if (Object.op_Implicit((Object)(object)CarryController.CarriedItem))
				{
					CarryController.KeepItemAttached();
				}
				UpdateGlobalIdleWatchdog();
				TraceState();
			}
		}

		private void UpdateGlobalIdleWatchdog()
		{
			//IL_0047: 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)
			//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_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: 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_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			if (_currentState == State.WaitingForActivation || _currentState == State.Grabbing || _currentState == State.StartingEngine || _currentState == State.Combat)
			{
				_globalIdlePosition = ((Component)this).transform.position;
				_globalIdleTimer = 0f;
				return;
			}
			if (_globalIdlePosition == Vector3.zero)
			{
				_globalIdlePosition = ((Component)this).transform.position;
				_globalIdleTimer = 0f;
				return;
			}
			if (Vector3.Distance(((Component)this).transform.position.WithY(0f), _globalIdlePosition.WithY(0f)) > 0.6f)
			{
				_globalIdlePosition = ((Component)this).transform.position;
				_globalIdleTimer = 0f;
				return;
			}
			_globalIdleTimer += Time.deltaTime;
			if (_globalIdleTimer < 8f)
			{
				return;
			}
			PlayerIsBotComplete.DebugLog("Idle watchdog firing in state=" + _currentState);
			_globalIdleTimer = 0f;
			_globalIdlePosition = ((Component)this).transform.position;
			switch (_currentState)
			{
			case State.ChasingLoot:
				if (Object.op_Implicit((Object)(object)_targetLoot))
				{
					LootScanner.IgnorePermanent(((Object)_targetLoot).GetInstanceID());
				}
				_targetLoot = null;
				_lastTargetLoot = null;
				_chaseTimer = 0f;
				_lootRepathTimer = 0f;
				_lastLootGoal = Vector3.zero;
				_currentState = State.Wandering;
				Navigation.Agent.ResetPath();
				Navigation.PickWanderDest();
				break;
			case State.CarryingToTruck:
				if (Object.op_Implicit((Object)(object)CarryController.CarriedItem))
				{
					LootScanner.IgnoreTemp(((Object)CarryController.CarriedItem).GetInstanceID(), 60f);
					CarryController.ReleaseItem(immediate: true);
				}
				ResetDeliveryState();
				_currentState = State.Wandering;
				Navigation.Agent.ResetPath();
				Navigation.PickWanderDest();
				break;
			case State.GoingToTruck:
				_reachedTruck = false;
				_returningToTruckBeforeScreenRetry = false;
				_truckInteractTimer = 0f;
				Navigation.Agent.ResetPath();
				Navigation.PickWanderDest();
				_currentState = State.Wandering;
				break;
			default:
				Navigation.Agent.ResetPath();
				Navigation.PickWanderDest();
				_currentState = State.Wandering;
				break;
			}
			SetDebugStatus("Recovered from idle stall");
		}

		private void UpdateDecisions()
		{
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: 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_10e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_10f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c09: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c0e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c10: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c12: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c2b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b2a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b2f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b37: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b78: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b82: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b87: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b8e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d8d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d92: Unknown result type (might be due to invalid IL or missing references)
			//IL_0de3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0de8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c59: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c63: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c70: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c6c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0dfb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e0b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c77: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ee0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ee5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ee7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0eee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ef4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0efe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ea2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ea7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f3e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f44: Invalid comparison between Unknown and I4
			//IL_041e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0424: Invalid comparison between Unknown and I4
			//IL_0f78: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f82: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f84: Unknown result type (might be due to invalid IL or missing references)
			//IL_0453: Unknown result type (might be due to invalid IL or missing references)
			//IL_045a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0460: Unknown result type (might be due to invalid IL or missing references)
			//IL_046a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fbf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d1a: Unknown result type (might be due to invalid IL or missing references)
			//IL_10c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_10cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fec: Unknown result type (might be due to invalid IL or missing references)
			//IL_09d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a0e: Unknown result type (might be due to invalid IL or missing references)
			//IL_09de: Unknown result type (might be due to invalid IL or missing references)
			//IL_09e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_1033: Unknown result type (might be due to invalid IL or missing references)
			//IL_1035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a26: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a2b: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0536: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0552: Unknown result type (might be due to invalid IL or missing references)
			//IL_0557: Unknown result type (might be due to invalid IL or missing references)
			//IL_0689: Unknown result type (might be due to invalid IL or missing references)
			//IL_0630: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0693: Unknown result type (might be due to invalid IL or missing references)
			//IL_0695: Unknown result type (might be due to invalid IL or missing references)
			//IL_064a: Unknown result type (might be due to invalid IL or missing references)
			//IL_064f: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_072c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0731: Unknown result type (might be due to invalid IL or missing references)
			PlayerIsBotComplete.InputSprint = false;
			float num = (Object.op_Implicit((Object)(object)_player) ? BotAccess.EnergyStart(_player) : 0f);
			if (Object.op_Implicit((Object)(object)_player) && num > 0f && BotAccess.EnergyCurrent(_player) / num >= 0.5f && Navigation.Agent.hasPath && !Navigation.Agent.pathPending && Navigation.TryGetRemainingDistance(out var distance) && distance > 5f && Navigation.TryGetMoveDirection(out var direction) && Vector3.Angle(((Component)this).transform.forward, direction) < 20f)
			{
				PlayerIsBotComplete.InputSprint = true;
			}
			if (_currentState == State.WaitingForActivation)
			{
				_waitingForActivationTimer += Time.deltaTime;
				if (!Object.op_Implicit((Object)(object)_targetExtractor))
				{
					_currentState = State.Wandering;
					_waitingForActivationTimer = 0f;
					return;
				}
				RoundDirector val = BotAccess.RoundDirector();
				if (Object.op_Implicit((Object)(object)val) && BotAccess.ExtractionPointActive(val) && (Object)(object)BotAccess.CurrentExtractionPoint(val) == (Object)(object)_targetExtractor)
				{
					_currentState = State.Wandering;
					_targetExtractor = null;
					_debugStatus = "Extractor Activated! Resuming...";
					_waitingForActivationTimer = 0f;
					Navigation.PickWanderDest();
				}
				else if (_waitingForActivationTimer > 3f)
				{
					_debugStatus = "Activation wait complete, resuming...";
					_currentState = State.Wandering;
					_targetExtractor = null;
					_waitingForActivationTimer = 0f;
					Navigation.PickWanderDest();
				}
				else
				{
					Navigation.Agent.ResetPath();
				}
				return;
			}
			if ((Object)(object)CarryController.CarriedItem != (Object)null)
			{
				_currentState = State.CarryingToTruck;
				_chaseTimer = 0f;
				CarryController.UpdateCarryTimer();
				int instanceID = ((Object)CarryController.CarriedItem).GetInstanceID();
				if (_deliveryCommittedItemId != instanceID)
				{
					ResetDeliveryPathState();
					_deliveryCommittedExtractor = null;
					_deliveryCommittedItemId = instanceID;
				}
				ExtractionPoint targetEP = null;
				Vector3 goal;
				bool flag = TryResolveDeliveryTarget(out goal, out targetEP);
				if (!flag)
				{
					ExtractionPoint val2 = SemiFunc.ExtractionPointGetNearest(((Component)this).transform.position);
					if (Object.op_Implicit((Object)(object)val2))
					{
						targetEP = val2;
						goal = ((Component)val2).transform.position;
						flag = true;
					}
				}
				if (_debugStatus == "Picked up item!" && !CarryController.IsDropping)
				{
					SetDebugStatus(Object.op_Implicit((Object)(object)targetEP) ? "Carrying item to extractor..." : "Carrying item to truck...");
				}
				float num2 = Vector3.Distance(((Component)this).transform.position, goal);
				float num3 = (CarryController.UsingVanillaPhysGrab ? 2.75f : 3f);
				float num4 = (CarryController.UsingVanillaPhysGrab ? 4.5f : 5f);
				if (flag && num2 <= num3 && !CarryController.IsDropping)
				{
					if (Object.op_Implicit((Object)(object)targetEP) && !IsDeliveryDropAllowed(targetEP))
					{
						SetDebugStatus("Activating extractor before delivery...");
						TryActivateExtraction(targetEP);
						_targetExtractor = targetEP;
						_currentState = State.WaitingForActivation;
						_waitingForActivationTimer = 0f;
						ExtractionController.StartActivation(targetEP);
						Navigation.Agent.ResetPath();
						return;
					}
					if (IsDeliveryDropAllowed(targetEP) || CarryController.CarryTimer > 14f)
					{
						SetDebugStatus("Dropping item into chute...");
						CarryController.StartDrop(targetEP);
						PlayerIsBotComplete.InputInteract = false;
						return;
					}
				}
				if (flag)
				{
					UpdateDeliveryProgress();
					Vector3 val3 = ((Time.time < _deliveryRecoveryUntil) ? _deliveryRecoveryPoint : goal);
					float distance2;
					bool flag2 = Navigation.TryGetRemainingDistance(out distance2);
					bool flag3 = Navigation.HasCompletePath() && !flag2 && _deliveryStillTimer > 1.5f;
					bool flag4 = !Navigation.Agent.hasPath || (!Navigation.Agent.pathPending && (int)Navigation.Agent.pathStatus > 0) || flag3;
					bool num5 = Navigation.Agent.pathPending && _deliveryRepathTimer > 0f;
					bool flag5 = Vector3.Distance(val3.WithY(0f), _deliveryLastGoal.WithY(0f)) > 1f;
					_deliveryRepathTimer -= Time.deltaTime;
					bool flag6 = num5 || (Navigation.Agent.hasPath && !flag5 && !flag4);
					if (!flag6 && (flag5 || flag4 || _deliveryRepathTimer <= 0f))
					{
						if (flag3)
						{
							Navigation.Agent.ResetPath();
						}
						flag6 = Navigation.SetDestination(val3);
						if (flag6)
						{
							_deliveryLastGoal = val3;
							_deliveryRecoveryUntil = 0f;
							_deliveryRepathTimer = 1.25f;
						}
					}
					if (!flag6)
					{
						float minRadius = (CarryController.UsingVanillaPhysGrab ? 1.2f : 2f);
						flag6 = Navigation.TrySetDestinationNear(goal, minRadius, 7f, out _deliveryRecoveryPoint);
						if (flag6)
						{
							_deliveryLastGoal = _deliveryRecoveryPoint;
							_deliveryRecoveryUntil = Time.time + 1f;
							_deliveryRepathTimer = 1.25f;
							SetDebugStatus("Recovering delivery path...");
						}
					}
					if (!flag6)
					{
						_deliveryNoPathTimer += Time.deltaTime;
						if (_deliveryNoPathTimer > 1.5f && Navigation.TrySetRecoveryDestination(out _deliveryRecoveryPoint))
						{
							_deliveryLastGoal = _deliveryRecoveryPoint;
							_deliveryRecoveryUntil = Time.time + 1f;
							_deliveryRepathTimer = 1.25f;
							_deliveryNoPathTimer = 0f;
							SetDebugStatus("Repositioning with valuable...");
						}
					}
					else
					{
						_deliveryNoPathTimer = 0f;
					}
					if (_deliveryStillTimer > 5f && num2 > num4 + 1f)
					{
						bool flag7 = false;
						if (!flag2 && Navigation.TrySetCloserDestinationNear(goal, num2, num3, 8f, out _deliveryRecoveryPoint))
						{
							_deliveryLastGoal = _deliveryRecoveryPoint;
							_deliveryRecoveryUntil = Time.time + 1f;
							_deliveryRepathTimer = 1.25f;
							flag7 = true;
							SetDebugStatus("Recovering delivery path...");
						}
						else if (Navigation.SetDestination(goal))
						{
							_deliveryLastGoal = goal;
							_deliveryRecoveryUntil = 0f;
							_deliveryRepathTimer = 1.25f;
							flag7 = true;
							SetDebugStatus("Refreshing delivery route...");
						}
						else if (Navigation.TrySetDestinationNear(goal, num3, 7f, out _deliveryRecoveryPoint))
						{
							_deliveryLastGoal = _deliveryRecoveryPoint;
							_deliveryRecoveryUntil = Time.time + 1f;
							_deliveryRepathTimer = 1.25f;
							flag7 = true;
							SetDebugStatus("Recovering delivery path...");
						}
						else if (Navigation.TrySetRecoveryDestination(out _deliveryRecoveryPoint))
						{
							_deliveryLastGoal = _deliveryRecoveryPoint;
							_deliveryRecoveryUntil = Time.time + 1f;
							_deliveryRepathTimer = 1.25f;
							flag7 = true;
							SetDebugStatus("Repositioning with valuable...");
						}
						if (flag7)
						{
							Navigation.Agent.stoppingDistance = (CarryController.UsingVanillaPhysGrab ? 0.25f : 0.5f);
						}
						_deliveryStillTimer = 0f;
					}
					if (!CarryController.IsDropping && _deliveryStillTimer > 2f && num2 <= num4)
					{
						if (Object.op_Implicit((Object)(object)targetEP) && !IsDeliveryDropAllowed(targetEP))
						{
							SetDebugStatus("Activating extractor from delivery endpoint...");
							TryActivateExtraction(targetEP);
							_targetExtractor = targetEP;
							_currentState = State.WaitingForActivation;
							_waitingForActivationTimer = 0f;
							ExtractionController.StartActivation(targetEP);
							Navigation.Agent.ResetPath();
							return;
						}
						if (IsDeliveryDropAllowed(targetEP) || CarryController.CarryTimer > 14f)
						{
							SetDebugStatus("Dropping item into chute...");
							CarryController.StartDrop(targetEP);
							PlayerIsBotComplete.InputInteract = false;
							return;
						}
					}
					Navigation.Agent.stoppingDistance = (CarryController.UsingVanillaPhysGrab ? 0.25f : 0.5f);
				}
				if (flag && Navigation.HasCompletePath() && Navigation.TryGetRemainingDistance(out var distance3) && distance3 <= Navigation.Agent.stoppingDistance + 0.35f && num2 > num3 + 0.35f && !CarryController.IsDropping)
				{
					_deliveryEndpointTimer += Time.deltaTime;
					if (_deliveryEndpointTimer > 0.65f)
					{
						_deliveryEndpointTimer = 0f;
						if (Object.op_Implicit((Object)(object)targetEP) && !IsDeliveryDropAllowed(targetEP) && num2 <= 5f)
						{
							SetDebugStatus("Activating extractor from delivery endpoint...");
							TryActivateExtraction(targetEP);
							_targetExtractor = targetEP;
							_currentState = State.WaitingForActivation;
							_waitingForActivationTimer = 0f;
							ExtractionController.StartActivation(targetEP);
							Navigation.Agent.ResetPath();
							return;
						}
						if (num2 <= num4 && (IsDeliveryDropAllowed(targetEP) || CarryController.CarryTimer > 14f))
						{
							SetDebugStatus("Dropping item into chute...");
							CarryController.StartDrop(targetEP);
							PlayerIsBotComplete.InputInteract = false;
							return;
						}
						if (num2 > num4)
						{
							if (Navigation.SetDestination(goal))
							{
								_deliveryLastGoal = goal;
								_deliveryRecoveryUntil = 0f;
								_deliveryRepathTimer = 1.25f;
								SetDebugStatus("Refreshing delivery route...");
							}
							else if (Navigation.TrySetDestinationNear(goal, num3, 6f, out _deliveryRecoveryPoint))
							{
								_deliveryLastGoal = _deliveryRecoveryPoint;
								_deliveryRecoveryUntil = Time.time + 1f;
								_deliveryRepathTimer = 1.25f;
								SetDebugStatus("Recovering delivery path...");
							}
						}
					}
				}
				else
				{
					_deliveryEndpointTimer = 0f;
				}
				PlayerIsBotComplete.InputInteract = false;
				return;
			}
			ResetDeliveryState();
			PlayerIsBotComplete.InputThrow = false;
			PlayerIsBotComplete.InputInteract = false;
			if (_shopCarriedUpgradeId != 0 && (Object)(object)CarryController.CarriedItem == (Object)null)
			{
				ShopController.NotifyUpgradeDelivered();
				_shopCarriedUpgradeId = 0;
			}
			if (HandleShopBranch())
			{
				return;
			}
			bool flag8 = false;
			RoundDirector val4 = BotAccess.RoundDirector();
			if (Object.op_Implicit((Object)(object)val4) && BotAccess.AllExtractionsCompleted(val4))
			{
				flag8 = true;
			}
			bool flag9 = false;
			if (!PhotonNetwork.InRoom || PhotonNetwork.CurrentRoom.PlayerCount <= 1)
			{
				flag9 = true;
			}
			if (flag9)
			{
				if (SemiFunc.RunIsShop())
				{
					flag8 = true;
				}
				if (!SemiFunc.RunIsLevel())
				{
					flag8 = true;
				}
			}
			if (flag8)
			{
				_currentState = State.GoingToTruck;
				_targetLoot = null;
				_chaseTimer = 0f;
				if (_returningToTruckBeforeScreenRetry)
				{
					Vector3 truckDestination = Navigation.GetTruckDestination();
					Navigation.SetDestination(truckDestination);
					Navigation.Agent.stoppingDistance = 1.2f;
					_debugStatus = "Returning inside truck before screen retry...";
					bool num6 = !Navigation.Agent.pathPending;
					bool flag10 = Vector3.Distance(((Component)this).transform.position.WithY(0f), truckDestination.WithY(0f)) <= 1.8f;
					float distance4;
					bool flag11 = num6 && Navigation.TryGetRemainingDistance(out distance4) && distance4 <= Navigation.Agent.stoppingDistance + 0.5f;
					if (flag10 || flag11)
					{
						_returningToTruckBeforeScreenRetry = false;
						_reachedTruck = false;
						_truckInteractTimer = 0f;
						_debugStatus = "Retrying truck screen...";
					}
					return;
				}
				Vector3 destination = Navigation.GetTruckDestination();
				Vector3 screenPosition = destination;
				bool flag12 = Navigation.TryGetTruckScreenDestination(out destination, out screenPosition);
				Navigation.SetDestination(destination);
				Navigation.Agent.stoppingDistance = (flag12 ? 0.65f : 1.5f);
				if (Vector3.Distance(((Component)this).transform.position.WithY(0f), (flag12 ? screenPosition : destination).WithY(0f)) <= (flag12 ? 3f : 3f) && !_reachedTruck)
				{
					_reachedTruck = true;
					_truckInteractTimer = 0f;
					_debugStatus = "At truck, looking for screen...";
				}
				if (_reachedTruck && Object.op_Implicit((Object)(object)BotAccess.TruckScreen()))
				{
					_currentState = State.StartingEngine;
					_debugStatus = "Interacting with truck screen...";
					if (_truckInteractTimer > 6f)
					{
						_reachedTruck = false;
						_returningToTruckBeforeScreenRetry = true;
						_truckInteractTimer = 0f;
						_currentState = State.GoingToTruck;
						Navigation.SetDestination(Navigation.GetTruckDestination());
						Navigation.Agent.stoppingDistance = 1.2f;
						_debugStatus = "Truck screen missed, resetting inside truck...";
					}
				}
			}
			else if ((Object)(object)_targetLoot != (Object)null)
			{
				if ((Object)(object)_targetLoot != (Object)(object)_lastTargetLoot)
				{
					_lastTargetLoot = _targetLoot;
					_chaseTimer = 0f;
					_lootRepathTimer = 0f;
					_lastLootGoal = Vector3.zero;
				}
				if (!((Component)_targetLoot).gameObject.activeInHierarchy || (Object)(object)_targetLoot.rb == (Object)null || SemiFunc.PhysGrabObjectIsGrabbed(_targetLoot))
				{
					_targetLoot = null;
					_lastTargetLoot = null;
					_lootRepathTimer = 0f;
					_lastLootGoal = Vector3.zero;
					_currentState = State.Wandering;
					return;
				}
				float num7 = Vector3.Distance(((Component)this).transform.position, ((Component)_targetLoot).transform.position);
				if (num7 < 2.5f)
				{
					_currentState = State.Grabbing;
					_chaseTimer = 0f;
					Navigation.Agent.ResetPath();
					_grabAttemptTimer += Time.deltaTime;
					if (_grabAttemptTimer > 3f)
					{
						LootScanner.IgnorePermanent(((Object)_targetLoot).GetInstanceID());
						_targetLoot = null;
						_lastTargetLoot = null;
						_grabAttemptTimer = 0f;
						_lootRepathTimer = 0f;
						_lastLootGoal = Vector3.zero;
						Navigation.PickWanderDest();
					}
					return;
				}
				_currentState = State.ChasingLoot;
				SetDebugStatus("Chasing loot...");
				_grabAttemptTimer = 0f;
				Vector3 position = ((Component)_targetLoot).transform.position;
				bool num8 = Vector3.Distance(position.WithY(0f), _lastLootGoal.WithY(0f)) > 1f;
				bool flag13 = !Navigation.Agent.hasPath || (!Navigation.Agent.pathPending && (int)Navigation.Agent.pathStatus > 0);
				_lootRepathTimer -= Time.deltaTime;
				if (num8 || flag13 || _lootRepathTimer <= 0f)
				{
					if (Navigation.SetDestination(position))
					{
						_lastLootGoal = position;
						_lootRepathTimer = 1f;
					}
					else
					{
						_lootRepathTimer = 0.25f;
					}
				}
				if (Navigation.StuckTimer > 2.4f)
				{
					bool flag14 = false;
					if (Navigation.TrySetCloserDestinationNear(position, num7, 1.25f, 7f, out var chosen))
					{
						flag14 = true;
						SetDebugStatus("Recovering loot path...");
					}
					else if (Navigation.TrySetAlternateDestinationNear(position, 1.75f, 7f, out chosen))
					{
						flag14 = true;
						SetDebugStatus("Recovering loot path...");
					}
					else if (Navigation.TrySetRecoveryDestination(out chosen))
					{
						flag14 = true;
						SetDebugStatus("Repositioning for loot...");
					}
					if (flag14)
					{
						_lastLootGoal = chosen;
						_lootRepathTimer = 0.75f;
						_chaseTimer = Mathf.Max(0f, _chaseTimer - 2f);
						Navigation.ResetStuckTimer();
					}
				}
				_chaseTimer += Time.deltaTime;
				if (_chaseTimer > 15f)
				{
					LootScanner.IgnorePermanent(((Object)_targetLoot).GetInstanceID());
					_targetLoot = null;
					_lastTargetLoot = null;
					_chaseTimer = 0f;
					_lootRepathTimer = 0f;
					_lastLootGoal = Vector3.zero;
					Navigation.PickWanderDest();
				}
			}
			else
			{
				PhysGrabObject val5 = LootScanner.ScanForLoot(((Component)this).transform.position, Navigation.SpawnTruckPos);
				if ((Object)(object)val5 != (Object)null)
				{
					_targetLoot = val5;
				}
				_currentState = State.Wandering;
				SetDebugStatus("Wandering...");
				_chaseTimer = 0f;
				_retargetTimer -= Time.deltaTime;
				bool num9 = !Navigation.Agent.pathPending;
				float distance5;
				bool flag15 = num9 && Navigation.TryGetRemainingDistance(out distance5) && distance5 <= Navigation.Agent.stoppingDistance + 1f;
				bool flag16 = num9 && !Navigation.Agent.hasPath;
				if (_retargetTimer <= 0f || flag15 || flag16)
				{
					Navigation.PickWanderDest();
					_retargetTimer = Random.Range(3f, 8f);
				}
			}
		}

		private bool HandleShopBranch()
		{
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: 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_0090: 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)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			if (ShopController == null || !ShopController.IsInShop)
			{
				_shopCheckoutExtractor = null;
				return false;
			}
			if (ShopController.ShouldCheckout)
			{
				ExtractionPoint val = _shopCheckoutExtractor;
				if (!Object.op_Implicit((Object)(object)val) || !((Component)val).gameObject.activeInHierarchy)
				{
					try
					{
						val = SemiFunc.ExtractionPointGetNearest(((Component)this).transform.position);
					}
					catch
					{
						val = null;
					}
					_shopCheckoutExtractor = val;
				}
				if (!Object.op_Implicit((Object)(object)val))
				{
					return false;
				}
				Vector3 position = ((Component)val).transform.position;
				if (Vector3.Distance(((Component)this).transform.position.WithY(0f), position.WithY(0f)) > 3.5f)
				{
					Navigation.SetDestination(position);
					Navigation.Agent.stoppingDistance = 1.5f;
					_currentState = State.GoingToTruck;
					SetDebugStatus("Returning to extractor for checkout...");
					return true;
				}
				Navigation.Agent.ResetPath();
				_currentState = State.StartingEngine;
				SetDebugStatus("Pressing shop checkout...");
				ShopController.TryCheckout(val);
				if (!ShopController.ShouldCheckout)
				{
					_shopCheckoutExtractor = null;
				}
				return true;
			}
			if (ShopController.ShouldPursueUpgrade && (Object)(object)CarryController.CarriedItem == (Object)null)
			{
				PhysGrabObject val2 = ShopController.FindAffordableUpgrade();
				if (Object.op_Implicit((Object)(object)val2) && (Object)(object)_targetLoot != (Object)(object)val2)
				{
					_targetLoot = val2;
					_lastTargetLoot = null;
					_chaseTimer = 0f;
					_lootRepathTimer = 0f;
					_lastLootGoal = Vector3.zero;
					SetDebugStatus("Targeting shop upgrade...");
				}
			}
			return false;
		}

		private bool TryResolveDeliveryTarget(out Vector3 goal, out ExtractionPoint targetEP)
		{
			//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_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			goal = ((Component)this).transform.position;
			targetEP = null;
			try
			{
				RoundDirector val = BotAccess.RoundDirector();
				if (Object.op_Implicit((Object)(object)val))
				{
					if (BotAccess.AllExtractionsCompleted(val))
					{
						_deliveryCommittedExtractor = null;
						goal = Navigation.GetTruckDestination();
						return true;
					}
					if (IsCommittedDeliveryExtractorValid())
					{
						targetEP = _deliveryCommittedExtractor;
						goal = ((Component)targetEP).transform.position;
						return true;
					}
					_deliveryCommittedExtractor = null;
					if (BotAccess.ExtractionPointActive(val) && Object.op_Implicit((Object)(object)BotAccess.CurrentExtractionPoint(val)))
					{
						targetEP = BotAccess.CurrentExtractionPoint(val);
						_deliveryCommittedExtractor = targetEP;
						goal = ((Component)targetEP).transform.position;
						return true;
					}
					ExtractionPoint val2 = GetFirstIdleExtraction(val);
					if (!Object.op_Implicit((Object)(object)val2))
					{
						val2 = SemiFunc.ExtractionPointGetNearestNotActivated(((Component)this).transform.position);
					}
					if (Object.op_Implicit((Object)(object)val2))
					{
						targetEP = val2;
						_deliveryCommittedExtractor = targetEP;
						goal = ((Component)val2).transform.position;
						return true;
					}
				}
			}
			catch
			{
			}
			return false;
		}

		private bool IsCommittedDeliveryExtractorValid()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Invalid comparison between Unknown and I4
			if (Object.op_Implicit((Object)(object)_deliveryCommittedExtractor) && ((Component)_deliveryCommittedExtractor).gameObject.activeInHierarchy)
			{
				return (int)_deliveryCommittedExtractor.currentState != 7;
			}
			return false;
		}

		private ExtractionPoint GetFirstIdleExtraction(RoundDirector round)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Invalid comparison between Unknown and I4
			if (!Object.op_Implicit((Object)(object)round) || round.extractionPointList == null)
			{
				return null;
			}
			foreach (GameObject extractionPoint in round.extractionPointList)
			{
				if (Object.op_Implicit((Object)(object)extractionPoint))
				{
					ExtractionPoint component = extractionPoint.GetComponent<ExtractionPoint>();
					if (Object.op_Implicit((Object)(object)component) && (int)component.currentState == 1)
					{
						return component;
					}
				}
			}
			return null;
		}

		private static bool IsFiniteDistance(float distance)
		{
			if (!float.IsNaN(distance))
			{
				return !float.IsInfinity(distance);
			}
			return false;
		}

		private void TraceState()
		{
			_stateTraceTimer -= Time.deltaTime;
			bool flag = _currentState != _lastLoggedState || _debugStatus != _lastLoggedStatus;
			if (flag || !(_stateTraceTimer > 0f))
			{
				_stateTraceTimer = (flag ? 0.25f : 2f);
				_lastLoggedState = _currentState;
				_lastLoggedStatus = _debugStatus;
				bool flag2 = Object.op_Implicit((Object)(object)Navigation.Agent) && Navigation.Agent.hasPath;
				bool flag3 = Object.op_Implicit((Object)(object)Navigation.Agent) && Navigation.Agent.pathPending;
				float num = (Object.op_Implicit((Object)(object)Navigation.Agent) ? Navigation.RemainingDistanceForDebug() : (-1f));
				string text = (Object.op_Implicit((Object)(object)_targetLoot) ? ((Object)_targetLoot).name : "None");
				string text2 = (Object.op_Implicit((Object)(object)CarryController.CarriedItem) ? ((Object)CarryController.CarriedItem).name : "None");
				PlayerIsBotComplete.DebugLog($"State={_currentState} Status={_debugStatus} Target={text} Carrying={text2} HasPath={flag2} Pending={flag3} Remaining={num:F1} Stuck={Navigation.StuckTimer:F1}");
			}
		}

		private void UpdateDeliveryProgress()
		{
			//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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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)
			if (_lastDeliveryPosition == Vector3.zero)
			{
				_lastDeliveryPosition = ((Component)this).transform.position;
			}
			if (Vector3.Distance(((Component)this).transform.position.WithY(0f), _lastDeliveryPosition.WithY(0f)) > 0.08f)
			{
				_lastDeliveryPosition = ((Component)this).transform.position;
				_deliveryStillTimer = 0f;
				return;
			}
			bool num = Navigation.HasCompletePath();
			float distance;
			bool flag = Navigation.TryGetRemainingDistance(out distance);
			if (num && (!flag || distance > Navigation.Agent.stoppingDistance + 0.5f))
			{
				_deliveryStillTimer += Time.deltaTime;
			}
			else
			{
				_deliveryStillTimer = 0f;
			}
		}

		private void ResetDeliveryState()
		{
			ResetDeliveryPathState();
			_deliveryCommittedExtractor = null;
			_deliveryCommittedItemId = 0;
		}

		private void ResetDeliveryPathState()
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: 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_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			_deliveryNoPathTimer = 0f;
			_deliveryStillTimer = 0f;
			_deliveryRecoveryUntil = 0f;
			_deliveryRepathTimer = 0f;
			_deliveryEndpointTimer = 0f;
			_deliveryRecoveryPoint = Vector3.zero;
			_deliveryLastGoal = Vector3.zero;
			_lastDeliveryPosition = Vector3.zero;
		}

		private bool IsDeliveryDropAllowed(ExtractionPoint targetEP)
		{
			try
			{
				if ((Object)(object)targetEP != (Object)null && ExtractionController != null && ExtractionController.IsSettlingActivation(targetEP))
				{
					return false;
				}
				if ((Object)(object)targetEP != (Object)null && BotAccess.ExtractionSpotlightEnabled(targetEP))
				{
					return true;
				}
				RoundDirector val = BotAccess.RoundDirector();
				if (Object.op_Implicit((Object)(object)val))
				{
					if (BotAccess.AllExtractionsCompleted(val))
					{
						return true;
					}
					if ((Object)(object)targetEP == (Object)null)
					{
						return false;
					}
					return BotAccess.ExtractionPointActive(val) && (Object)(object)BotAccess.CurrentExtractionPoint(val) == (Object)(object)targetEP;
				}
			}
			catch
			{
			}
			return true;
		}

		private void TryActivateExtraction(ExtractionPoint ep)
		{
			if (Object.op_Implicit((Object)(object)ep))
			{
				int instanceID = ((Object)ep).GetInstanceID();
				if (_lastActivateId != instanceID || !(Time.time - _lastActivateTime < 0.75f))
				{
					_lastActivateId = instanceID;
					_lastActivateTime = Time.time;
					BotAccess.ActivateExtractionPoint(ep);
				}
			}
		}

		private void UpdateAiming()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0300: Unknown result type (might be due to invalid IL or missing references)
			//IL_0305: Unknown result type (might be due to invalid IL or missing references)
			//IL_0307: Unknown result type (might be due to invalid IL or missing references)
			//IL_0313: Unknown result type (might be due to invalid IL or missing references)
			//IL_031a: Unknown result type (might be due to invalid IL or missing references)
			//IL_031f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0323: Unknown result type (might be due to invalid IL or missing references)
			//IL_0328: Unknown result type (might be due to invalid IL or missing references)
			//IL_0334: Unknown result type (might be due to invalid IL or missing references)
			//IL_033b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0340: Unknown result type (might be due to invalid IL or missing references)
			//IL_0344: Unknown result type (might be due to invalid IL or missing references)
			//IL_0349: Unknown result type (might be due to invalid IL or missing references)
			//IL_034b: Unknown result type (might be due to invalid IL or missing references)
			//IL_034d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0359: Unknown result type (might be due to invalid IL or missing references)
			//IL_036b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_0483: Unknown result type (might be due to invalid IL or missing references)
			//IL_0488: Unknown result type (might be due to invalid IL or missing references)
			//IL_048a: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			PlayerIsBotComplete.LookInput = Vector2.zero;
			PlayerIsBotComplete.InputInteract = false;
			PlayerIsBotComplete.InputGrab = false;
			if (CombatController != null && CombatController.IsEngaged && CombatController.TryGetAimPosition(out var aimPosition))
			{
				float num = AimAt(aimPosition);
				_debugStatus = $"Shooting enemy... Angle: {num:F1}°";
				return;
			}
			if (_currentState == State.WaitingForActivation)
			{
				_debugStatus = "Waiting for extractor activation...";
				return;
			}
			Vector3 val2;
			if (_currentState == State.Grabbing && (Object)(object)_targetLoot != (Object)null)
			{
				Vector3 val = ((Component)_targetLoot).transform.position;
				Collider component = ((Component)_targetLoot).GetComponent<Collider>();
				if (Object.op_Implicit((Object)(object)component))
				{
					Bounds bounds = component.bounds;
					val = ((Bounds)(ref bounds)).center;
				}
				val2 = val - CamTr.position;
				Vector3 normalized = ((Vector3)(ref val2)).normalized;
				Vector3 forward = CamTr.forward;
				val2 = new Vector3(forward.x, 0f, forward.z);
				Vector3 normalized2 = ((Vector3)(ref val2)).normalized;
				val2 = new Vector3(normalized.x, 0f, normalized.z);
				Vector3 normalized3 = ((Vector3)(ref val2)).normalized;
				float num2 = Vector3.SignedAngle(normalized2, normalized3, Vector3.up);
				float num3 = Mathf.Asin(normalized.y) * 57.29578f - Mathf.Asin(forward.y) * 57.29578f;
				float x = Mathf.Clamp(num2 / 15f, -1f, 1f);
				float y = Mathf.Clamp(num3 / 15f, -1f, 1f);
				if (Mathf.Abs(num2) > 1f)
				{
					PlayerIsBotComplete.LookInput.x = x;
				}
				if (Mathf.Abs(num3) > 1f)
				{
					PlayerIsBotComplete.LookInput.y = y;
				}
				_debugStatus = $"Aiming: Y={num2:F1}° P={num3:F1}°";
				if (!(Vector3.Angle(forward, normalized) < 15f) || !CarryController.CanReachTarget(_targetLoot))
				{
					return;
				}
				if (ShopController != null && (Object)(object)ShopController.CurrentUpgradeTarget == (Object)(object)_targetLoot)
				{
					_shopCarriedUpgradeId = ((Object)_targetLoot).GetInstanceID();
					_shopCheckoutExtractor = null;
					try
					{
						_shopCheckoutExtractor = SemiFunc.ExtractionPointGetNearest(((Component)this).transform.position);
					}
					catch
					{
					}
					ShopController.ClearUpgradeTarget();
				}
				CarryController.PickUpItem(_targetLoot);
				_targetLoot = null;
				_grabAttemptTimer = 0f;
				return;
			}
			TruckScreenText val3 = BotAccess.TruckScreen();
			if (_currentState == State.StartingEngine && Object.op_Implicit((Object)(object)val3))
			{
				Vector3 position = ((Component)val3).transform.position;
				GameObject val4 = BotAccess.TruckScreenStaticGrabCollider(val3);
				if (Object.op_Implicit((Object)(object)val4))
				{
					position = val4.transform.position;
				}
				val2 = position - CamTr.position;
				Vector3 normalized4 = ((Vector3)(ref val2)).normalized;
				Vector3 forward2 = CamTr.forward;
				val2 = new Vector3(forward2.x, 0f, forward2.z);
				Vector3 normalized5 = ((Vector3)(ref val2)).normalized;
				val2 = new Vector3(normalized4.x, 0f, normalized4.z);
				Vector3 normalized6 = ((Vector3)(ref val2)).normalized;
				float num4 = Vector3.SignedAngle(normalized5, normalized6, Vector3.up);
				float num5 = Mathf.Asin(normalized4.y) * 57.29578f - Mathf.Asin(forward2.y) * 57.29578f;
				float x2 = Mathf.Clamp(num4 / 15f, -1f, 1f);
				float y2 = Mathf.Clamp(num5 / 15f, -1f, 1f);
				if (Mathf.Abs(num4) > 1f)
				{
					PlayerIsBotComplete.LookInput.x = x2;
				}
				if (Mathf.Abs(num5) > 1f)
				{
					PlayerIsBotComplete.LookInput.y = y2;
				}
				float num6 = Vector3.Angle(forward2, normalized4);
				_debugStatus = $"Starting Engine... Angle: {num6:F1}°";
				_truckInteractTimer += Time.deltaTime;
				if (num6 < 45f || _truckInteractTimer > 1f)
				{
					PlayerIsBotComplete.InputGrab = true;
					if (_truckInteractTimer > 2f)
					{
						_debugStatus = "Held grab, starting...";
					}
				}
			}
			else
			{
				if (Navigation.Agent.hasPath && !Navigation.Agent.pathPending && Navigation.TryGetMoveDirection(out var direction))
				{
					float num7 = Mathf.Clamp(Vector3.SignedAngle(((Component)this).transform.forward, direction, Vector3.up) / 45f, -1f, 1f) * 1.5f;
					PlayerIsBotComplete.LookInput = new Vector2(num7, 0f);
				}
				CenterCameraPitch();
			}
		}

		private float AimAt(Vector3 targetPos)
		{
			//IL_0000: 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_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_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: 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_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = targetPos - CamTr.position;
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			Vector3 forward = CamTr.forward;
			val = new Vector3(forward.x, 0f, forward.z);
			Vector3 normalized2 = ((Vector3)(ref val)).normalized;
			val = new Vector3(normalized.x, 0f, normalized.z);
			Vector3 normalized3 = ((Vector3)(ref val)).normalized;
			float num = Vector3.SignedAngle(normalized2, normalized3, Vector3.up);
			float num2 = Mathf.Asin(normalized.y) * 57.29578f - Mathf.Asin(forward.y) * 57.29578f;
			float x = Mathf.Clamp(num / 15f, -1f, 1f);
			float y = Mathf.Clamp(num2 / 15f, -1f, 1f);
			if (Mathf.Abs(num) > 1f)
			{
				PlayerIsBotComplete.LookInput.x = x;
			}
			if (Mathf.Abs(num2) > 1f)
			{
				PlayerIsBotComplete.LookInput.y = y;
			}
			return Vector3.Angle(forward, normalized);
		}

		private void CenterCameraPitch()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)CamTr))
			{
				float num = Mathf.Asin(Mathf.Clamp(CamTr.forward.y, -1f, 1f)) * 57.29578f;
				if (Mathf.Abs(num) > 1f)
				{
					PlayerIsBotComplete.LookInput.y = Mathf.Clamp((0f - num) / 18f, -0.75f, 0.75f);
				}
			}
		}
	}
	public class PlayerBotCarryController
	{
		private PlayerBotBrain _brain;

		private Transform _holdPoint;

		private PhysGrabObject _fakeCarriedItem;

		private PhysGrabObject _activeGrabItem;

		private PhysGrabObject _pendingGrabItem;

		private float _pendingGrabUntil;

		private Rigidbody _carriedRB;

		private List<Collider> _carriedCols = new List<Collider>();

		private Collider[] _myCols;

		public PhysGrabber Grabber { get; private set; }

		public PhysGrabObject CarriedItem
		{
			get
			{
				if (UseRealGrab)
				{
					PhysGrabObject val = BotAccess.GrabbedPhysObject(Grabber);
					if (Object.op_Implicit((Object)(object)val) && (Object)(object)val == (Object)(object)_activeGrabItem)
					{
						return val;
					}
					if (Object.op_Implicit((Object)(object)val) && (Object)(object)val == (Object)(object)_pendingGrabItem)
					{
						_activeGrabItem = val;
						return val;
					}
					if (Time.time < _pendingGrabUntil && Object.op_Implicit((Object)(object)_pendingGrabItem))
					{
						return _pendingGrabItem;
					}
					if (!Object.op_Implicit((Object)(object)val) && Time.time >= _pendingGrabUntil)
					{
						_activeGrabItem = null;
					}
					return null;
				}
				return _fakeCarriedItem;
			}
		}

		private bool UseRealGrab
		{
			get
			{
				if ((Object)(object)Grabber != (Object)null)
				{
					return PlayerIsBotComplete.ShouldUseVanillaPhysGrab();
				}
				return false;
			}
		}

		public bool UsingVanillaPhysGrab => UseRealGrab;

		public float CarryTimer { get; private set; }

		public bool IsDropping { get; private set; }

		public PlayerBotCarryController(PlayerBotBrain brain)
		{
			//IL_002a: 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_0070: Unknown result type (might be due to invalid IL or missing references)
			_brain = brain;
			Grabber = ((Component)brain).GetComponentInChildren<PhysGrabber>();
			_holdPoint = new GameObject("BotHoldPoint").transform;
			_holdPoint.SetParent(((Component)brain).transform, false);
			_holdPoint.localPosition = new Vector3(0f, 1f, 0.6f);
			_holdPoint.localRotation = Quaternion.identity;
			_myCols = ((Component)brain).GetComponentsInChildren<Collider>(true);
		}

		public void UpdateCarryTimer()
		{
			CarryTimer += Time.deltaTime;
		}

		public bool CanReachTarget(PhysGrabObject target)
		{
			//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_005d: 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_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			if (UseRealGrab)
			{
				float num = Mathf.Max(2f, BotAccess.GrabRange(Grabber) + 0.5f);
				return Vector3.Distance(Object.op_Implicit((Object)(object)_brain.CamTr) ? _brain.CamTr.position : (((Component)_brain).transform.position + Vector3.up), ((Component)target).transform.position) <= num;
			}
			return Vector3.Distance(_holdPoint.position, ((Component)target).transform.position) < 2f;
		}

		public void PickUpItem(PhysGrabObject item)
		{
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)item) || (Object)(object)CarriedItem != (Object)null)
			{
				return;
			}
			if (UseRealGrab)
			{
				_activeGrabItem = item;
				_pendingGrabItem = item;
				_pendingGrabUntil = Time.time + 1.25f;
				PlayerIsBotComplete.InputGrab = true;
				BotAccess.OverrideAlwaysGrabbable(Grabber, 0.25f);
				BotAccess.OverrideGrab(Grabber, item, 0.35f);
				CarryTimer = 0f;
				_brain.ExtractionController.ResetGrace();
				_brain.SetDebugStatus("Grabbing item");
				return;
			}
			_fakeCarriedItem = item;
			_carriedRB = item.rb;
			try
			{
				((Component)item).transform.SetParent((Transform)null, true);
				if (Object.op_Implicit((Object)(object)_carriedRB))
				{
					_carriedRB.velocity = Vector3.zero;
					_carriedRB.angularVelocity = Vector3.zero;
					_carriedRB.isKinematic = true;
				}
				item.OverrideKnockOutOfGrabDisable(2f);
			}
			catch
			{
			}
			SetCarryCollisionIgnore(ignore: true);
			CarryTimer = 0f;
			_brain.ExtractionController.ResetGrace();
			_brain.SetDebugStatus("Picked up item!");
		}

		public void KeepItemAttached()
		{
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)CarriedItem))
			{
				return;
			}
			if (UseRealGrab)
			{
				PlayerIsBotComplete.InputGrab = true;
				PhysGrabObject val = BotAccess.GrabbedPhysObject(Grabber);
				if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)_activeGrabItem) && (Object)(object)val != (Object)(object)_activeGrabItem)
				{
					BotAccess.ReleaseGrab(Grabber, val, 0.15f);
					return;
				}
				if (Object.op_Implicit((Object)(object)_pendingGrabItem) && (!Object.op_Implicit((Object)(object)val) || (Object)(object)val != (Object)(object)_pendingGrabItem) && Time.time < _pendingGrabUntil)
				{
					BotAccess.OverrideAlwaysGrabbable(Grabber, 0.15f);
					BotAccess.OverrideGrab(Grabber, _pendingGrabItem, 0.2f);
				}
				BotAccess.OverrideGrabDistance(Grabber, 2f);
			}
			else
			{
				Transform transform = ((Component)_fakeCarriedItem).transform;
				if ((Object)(object)transform.parent != (Object)(object)_holdPoint)
				{
					transform.SetParent(_holdPoint, false);
				}
				transform.localPosition = Vector3.zero;
				transform.localRotation = Quaternion.identity;
			}
		}

		public void ReleaseItem(bool immediate, bool addForce = false)
		{
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing refer