Decompiled source of Be A Bot v1.1.0

EmpressBotPlayers.dll

Decompiled 17 hours 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.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using UnityEngine;
using UnityEngine.AI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("Omniscye")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("EmpressBotPlayers")]
[assembly: AssemblyTitle("EmpressBotPlayers")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Empress.PlayerBot
{
	[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_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Invalid comparison between Unknown and I4
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Invalid comparison between Unknown and I4
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Invalid comparison between Unknown and I4
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Invalid comparison between Unknown and I4
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: 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_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Invalid comparison between Unknown and I4
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Invalid comparison between Unknown and I4
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Invalid comparison between Unknown and I4
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Invalid comparison between Unknown and I4
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: 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
		}

		private PlayerController _player;

		private State _currentState = State.Initializing;

		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 float _extractorActivationTimer;

		private string _debugStatus = "Initializing...";

		private bool _reachedTruck;

		private float _retargetTimer;

		private float _waitingForActivationTimer;

		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; }

		private void Start()
		{
			PlayerIsBotComplete.Log.LogInfo((object)"BotBrain: Start() called.");
			_player = ((Component)this).GetComponent<PlayerController>();
			Camera val = ((Component)this).GetComponentInChildren<Camera>();
			if (!Object.op_Implicit((Object)(object)val))
			{
				val = Camera.main;
			}
			if (Object.op_Implicit((Object)(object)val))
			{
				CamTr = ((Component)val).transform;
			}
			else
			{
				CamTr = ((Component)this).transform;
			}
			Navigation = new PlayerBotNavigation(this);
			LootScanner = new PlayerBotLootScanner(this);
			CarryController = new PlayerBotCarryController(this);
			ExtractionController = new PlayerBotExtractionController(this);
			CombatController = new PlayerBotCombatController(this);
			((MonoBehaviour)this).StartCoroutine(InitLevelData());
		}

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

		private void OnGUI()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			GUI.color = Color.cyan;
			GUI.skin.label.fontStyle = (FontStyle)1;
			GUI.skin.box.fontStyle = (FontStyle)1;
			GUI.Box(new Rect(10f, 10f, 300f, 200f), "BOT BRAIN v5.1 (EMP-7.1 Logic)");
			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}");
			string text = ((Object.op_Implicit((Object)(object)CarryController.Grabber) && Object.op_Implicit((Object)(object)CarryController.Grabber.grabbedObject)) ? ((Object)CarryController.Grabber.grabbedObject).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)
		{
			_debugStatus = status;
		}

		private IEnumerator InitLevelData()
		{
			_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;
					_debugStatus = "Ready";
					PlayerIsBotComplete.IsActive = true;
					PlayerIsBotComplete.Log.LogInfo((object)"BotBrain: Agent placed. ACTIVATING.");
				}
				else
				{
					_debugStatus = "Retrying NavMesh...";
					yield return (object)new WaitForSeconds(2f);
				}
			}
			Navigation.BuildGlobalTargets();
			Navigation.PickWanderDest();
		}

		private void Update()
		{
			//IL_002c: 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)
			if ((Object)(object)Navigation.Agent == (Object)null)
			{
				return;
			}
			Navigation.Agent.nextPosition = ((Component)this).transform.position;
			if (!Navigation.Agent.isOnNavMesh)
			{
				Navigation.TryPlaceOnNavMesh(((Component)this).transform.position);
				return;
			}
			LootScanner.UpdateTimers();
			ExtractionController.Update();
			CombatController.UpdateCombat();
			UpdateDecisions();
			Navigation.UpdateMovement();
			UpdateAiming();
			if (Object.op_Implicit((Object)(object)CarryController.CarriedItem))
			{
				CarryController.KeepItemAttached();
			}
		}

		private void UpdateDecisions()
		{
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0487: Unknown result type (might be due to invalid IL or missing references)
			//IL_048c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0494: 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_07b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_07bc: 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_0640: Unknown result type (might be due to invalid IL or missing references)
			//IL_0708: Unknown result type (might be due to invalid IL or missing references)
			//IL_0560: Unknown result type (might be due to invalid IL or missing references)
			//IL_056b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0575: Unknown result type (might be due to invalid IL or missing references)
			//IL_057a: Unknown result type (might be due to invalid IL or missing references)
			PlayerIsBotComplete.InputSprint = false;
			if (Object.op_Implicit((Object)(object)_player) && _player.EnergyStart > 0f)
			{
				float num = _player.EnergyCurrent / _player.EnergyStart;
				if (num >= 0.5f)
				{
					bool flag = Navigation.Agent.hasPath && !Navigation.Agent.pathPending;
					float remainingDistance = Navigation.Agent.remainingDistance;
					if (flag && remainingDistance > 5f)
					{
						Vector3 val = Navigation.Agent.steeringTarget - ((Component)this).transform.position;
						Vector3 normalized = ((Vector3)(ref val)).normalized;
						if (Vector3.Angle(((Component)this).transform.forward, normalized) < 20f)
						{
							PlayerIsBotComplete.InputSprint = true;
						}
					}
				}
			}
			if (_currentState == State.WaitingForActivation)
			{
				_waitingForActivationTimer += Time.deltaTime;
				if (!Object.op_Implicit((Object)(object)_targetExtractor))
				{
					_currentState = State.Wandering;
					_waitingForActivationTimer = 0f;
				}
				else if (Object.op_Implicit((Object)(object)RoundDirector.instance) && RoundDirector.instance.extractionPointActive && (Object)(object)RoundDirector.instance.extractionPointCurrent == (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();
				ExtractionPoint targetEP = null;
				Vector3 goal;
				bool flag2 = TryResolveDeliveryTarget(out goal, out targetEP);
				if (!flag2)
				{
					ExtractionPoint val2 = SemiFunc.ExtractionPointGetNearest(((Component)this).transform.position);
					if (Object.op_Implicit((Object)(object)val2))
					{
						targetEP = val2;
						goal = ((Component)val2).transform.position;
						flag2 = true;
					}
				}
				if (flag2)
				{
					Navigation.SetDestination(goal);
					Navigation.Agent.stoppingDistance = 0.5f;
				}
				float num2 = Vector3.Distance(((Component)this).transform.position, goal);
				if (num2 <= 3f && !CarryController.IsDropping)
				{
					if (Object.op_Implicit((Object)(object)targetEP) && !IsDeliveryDropAllowed(targetEP))
					{
						_debugStatus = "Dropping item to activate extractor...";
						CarryController.ReleaseItem(immediate: false);
						TryActivateExtraction(targetEP);
						_targetExtractor = targetEP;
						_currentState = State.WaitingForActivation;
						_waitingForActivationTimer = 0f;
						ExtractionController.StartActivation(targetEP);
						return;
					}
					if (IsDeliveryDropAllowed(targetEP) || Time.time < ExtractionController.ActivationGraceUntil || CarryController.CarryTimer > 12f)
					{
						_debugStatus = "Dropping item into chute...";
						CarryController.StartDrop(targetEP);
					}
				}
				PlayerIsBotComplete.InputInteract = false;
				return;
			}
			PlayerIsBotComplete.InputThrow = false;
			PlayerIsBotComplete.InputInteract = false;
			bool flag3 = false;
			if (Object.op_Implicit((Object)(object)RoundDirector.instance) && RoundDirector.instance.allExtractionPointsCompleted)
			{
				flag3 = true;
			}
			bool flag4 = false;
			if (!PhotonNetwork.InRoom || PhotonNetwork.CurrentRoom.PlayerCount <= 1)
			{
				flag4 = true;
			}
			if (flag4)
			{
				if (SemiFunc.RunIsShop())
				{
					flag3 = true;
				}
				if (!SemiFunc.RunIsLevel())
				{
					flag3 = true;
				}
			}
			if (flag3)
			{
				_currentState = State.GoingToTruck;
				_targetLoot = null;
				_chaseTimer = 0f;
				Vector3 truckDestination = Navigation.GetTruckDestination();
				Navigation.SetDestination(truckDestination);
				Navigation.Agent.stoppingDistance = 1.5f;
				float num3 = Vector3.Distance(((Component)this).transform.position, truckDestination);
				if (num3 <= 3f && !_reachedTruck)
				{
					_reachedTruck = true;
					_truckInteractTimer = 0f;
					_debugStatus = "At truck, looking for screen...";
				}
				if (_reachedTruck && Object.op_Implicit((Object)(object)TruckScreenText.instance))
				{
					_currentState = State.StartingEngine;
					_debugStatus = "Interacting with truck screen...";
					if (_truckInteractTimer > 8f)
					{
						_reachedTruck = false;
						_truckInteractTimer = 0f;
						Navigation.TryPlaceOnNavMesh(((Component)this).transform.position - ((Component)this).transform.forward * 2f);
						_debugStatus = "Retrying Screen Approach...";
					}
				}
			}
			else if ((Object)(object)_targetLoot != (Object)null)
			{
				if ((Object)(object)_targetLoot != (Object)(object)_lastTargetLoot)
				{
					_lastTargetLoot = _targetLoot;
					_chaseTimer = 0f;
				}
				if (!((Component)_targetLoot).gameObject.activeInHierarchy || (Object)(object)_targetLoot.rb == (Object)null || SemiFunc.PhysGrabObjectIsGrabbed(_targetLoot))
				{
					_targetLoot = null;
					_currentState = State.Wandering;
					return;
				}
				float num4 = Vector3.Distance(((Component)this).transform.position, ((Component)_targetLoot).transform.position);
				if (num4 < 2.5f)
				{
					_currentState = State.Grabbing;
					_chaseTimer = 0f;
					Navigation.Agent.ResetPath();
					_grabAttemptTimer += Time.deltaTime;
					if (_grabAttemptTimer > 3f)
					{
						LootScanner.IgnorePermanent(((Object)_targetLoot).GetInstanceID());
						_targetLoot = null;
						_grabAttemptTimer = 0f;
						Navigation.PickWanderDest();
					}
					return;
				}
				_currentState = State.ChasingLoot;
				_grabAttemptTimer = 0f;
				Navigation.SetDestination(((Component)_targetLoot).transform.position);
				_chaseTimer += Time.deltaTime;
				if (_chaseTimer > 15f)
				{
					PlayerIsBotComplete.Log.LogWarning((object)("BotBrain: Chase timeout! Abandoning '" + ((Object)_targetLoot).name + "'."));
					LootScanner.IgnorePermanent(((Object)_targetLoot).GetInstanceID());
					_targetLoot = null;
					_lastTargetLoot = null;
					_chaseTimer = 0f;
					Navigation.PickWanderDest();
				}
			}
			else
			{
				PhysGrabObject val3 = LootScanner.ScanForLoot(((Component)this).transform.position, Navigation.SpawnTruckPos);
				if ((Object)(object)val3 != (Object)null)
				{
					_targetLoot = val3;
				}
				_currentState = State.Wandering;
				_chaseTimer = 0f;
				_retargetTimer -= Time.deltaTime;
				bool flag5 = !Navigation.Agent.pathPending && Navigation.Agent.remainingDistance <= Navigation.Agent.stoppingDistance + 1f;
				if (_retargetTimer <= 0f || flag5)
				{
					Navigation.PickWanderDest();
					_retargetTimer = Random.Range(3f, 8f);
				}
			}
		}

		private bool TryResolveDeliveryTarget(out Vector3 goal, out ExtractionPoint targetEP)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: 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_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			goal = ((Component)this).transform.position;
			targetEP = null;
			try
			{
				if (Object.op_Implicit((Object)(object)RoundDirector.instance))
				{
					if (RoundDirector.instance.allExtractionPointsCompleted)
					{
						goal = Navigation.GetTruckDestination();
						return true;
					}
					if (RoundDirector.instance.extractionPointActive && Object.op_Implicit((Object)(object)RoundDirector.instance.extractionPointCurrent))
					{
						targetEP = RoundDirector.instance.extractionPointCurrent;
						goal = ((Component)targetEP).transform.position;
						return true;
					}
					ExtractionPoint val = SemiFunc.ExtractionPointGetNearestNotActivated(((Component)this).transform.position);
					if (Object.op_Implicit((Object)(object)val))
					{
						targetEP = val;
						goal = ((Component)val).transform.position;
						return true;
					}
				}
			}
			catch
			{
			}
			return false;
		}

		private bool IsDeliveryDropAllowed(ExtractionPoint targetEP)
		{
			try
			{
				if ((Object)(object)targetEP != (Object)null && (Object)(object)targetEP.spotlight1 != (Object)null && ((Behaviour)targetEP.spotlight1).enabled)
				{
					return true;
				}
				if (Object.op_Implicit((Object)(object)RoundDirector.instance))
				{
					if (RoundDirector.instance.allExtractionPointsCompleted)
					{
						return true;
					}
					if ((Object)(object)targetEP == (Object)null)
					{
						return false;
					}
					return RoundDirector.instance.extractionPointActive && (Object)(object)RoundDirector.instance.extractionPointCurrent == (Object)(object)targetEP;
				}
			}
			catch
			{
			}
			return true;
		}

		private void TryActivateExtraction(ExtractionPoint ep)
		{
			if (!Object.op_Implicit((Object)(object)ep))
			{
				return;
			}
			int instanceID = ((Object)ep).GetInstanceID();
			if (_lastActivateId == instanceID && Time.time - _lastActivateTime < 0.75f)
			{
				return;
			}
			_lastActivateId = instanceID;
			_lastActivateTime = Time.time;
			try
			{
				ep.OnClick();
			}
			catch
			{
			}
		}

		private void UpdateAiming()
		{
			//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_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_008e: 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_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: 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_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: 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_0101: 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_011f: 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_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: 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)
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02af: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02de: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_030b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0272: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_043d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0448: Unknown result type (might be due to invalid IL or missing references)
			//IL_044d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0452: Unknown result type (might be due to invalid IL or missing references)
			//IL_0456: Unknown result type (might be due to invalid IL or missing references)
			//IL_045b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0469: Unknown result type (might be due to invalid IL or missing references)
			//IL_046b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0392: Unknown result type (might be due to invalid IL or missing references)
			//IL_0394: Unknown result type (might be due to invalid IL or missing references)
			//IL_0482: Unknown result type (might be due to invalid IL or missing references)
			//IL_0487: Unknown result type (might be due to invalid IL or missing references)
			//IL_0489: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c0: Unknown result type (might be due to invalid IL or missing references)
			PlayerIsBotComplete.LookInput = Vector2.zero;
			PlayerIsBotComplete.InputInteract = false;
			PlayerIsBotComplete.InputGrab = false;
			Vector3 val2;
			if (_currentState == State.WaitingForActivation)
			{
				_debugStatus = "Waiting for extractor activation...";
			}
			else 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 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;
				}
				_debugStatus = $"Aiming: Y={num:F1}° P={num2:F1}°";
				float num3 = Vector3.Angle(forward, normalized);
				if (num3 < 15f && CarryController.CanReachTarget(_targetLoot))
				{
					CarryController.PickUpItem(_targetLoot);
					_targetLoot = null;
					_grabAttemptTimer = 0f;
				}
			}
			else if (_currentState == State.StartingEngine && Object.op_Implicit((Object)(object)TruckScreenText.instance))
			{
				Vector3 position = ((Component)TruckScreenText.instance).transform.position;
				if (Object.op_Implicit((Object)(object)TruckScreenText.instance.staticGrabCollider))
				{
					position = TruckScreenText.instance.staticGrabCollider.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 < 30f)
				{
					PlayerIsBotComplete.InputGrab = true;
					if (_truckInteractTimer > 2f)
					{
						_debugStatus = "Held grab, starting...";
					}
				}
			}
			else if (Navigation.Agent.hasPath && !Navigation.Agent.pathPending)
			{
				val2 = Navigation.Agent.steeringTarget - ((Component)this).transform.position;
				Vector3 normalized7 = ((Vector3)(ref val2)).normalized;
				normalized7.y = 0f;
				if (normalized7 != Vector3.zero)
				{
					float num7 = Vector3.SignedAngle(((Component)this).transform.forward, normalized7, Vector3.up);
					float num8 = Mathf.Clamp(num7 / 45f, -1f, 1f) * 1.5f;
					PlayerIsBotComplete.LookInput = new Vector2(num8, 0f);
				}
			}
		}
	}
	public class PlayerBotCarryController
	{
		private PlayerBotBrain _brain;

		private Transform _holdPoint;

		private Rigidbody _carriedRB;

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

		private Collider[] _myCols;

		public PhysGrabber Grabber { get; private set; }

		public PhysGrabObject CarriedItem { get; private set; }

		public float CarryTimer { get; private set; }

		public bool IsDropping { get; private set; }

		public PlayerBotCarryController(PlayerBotBrain brain)
		{
			//IL_002d: 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_0075: 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_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_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = _holdPoint.position;
			float num = Vector3.Distance(position, ((Component)target).transform.position);
			return num < 2f;
		}

		public void PickUpItem(PhysGrabObject item)
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)item) || (Object)(object)CarriedItem != (Object)null)
			{
				return;
			}
			CarriedItem = 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_0045: 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)
			if (Object.op_Implicit((Object)(object)CarriedItem))
			{
				Transform transform = ((Component)CarriedItem).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_00a4: 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_00be: 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_00c8: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//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)
			if (!Object.op_Implicit((Object)(object)CarriedItem))
			{
				return;
			}
			PhysGrabObject carriedItem = CarriedItem;
			int instanceID = ((Object)carriedItem).GetInstanceID();
			_brain.LootScanner.IgnoreTemp(instanceID, 5f);
			try
			{
				((Component)carriedItem).transform.SetParent((Transform)null, true);
				if (Object.op_Implicit((Object)(object)_carriedRB))
				{
					_carriedRB.isKinematic = false;
					_carriedRB.velocity = Vector3.zero;
					_carriedRB.angularVelocity = Vector3.zero;
				}
			}
			catch
			{
			}
			SetCarryCollisionIgnore(ignore: false);
			Vector3 position = ((Component)carriedItem).transform.position + ((Component)_brain).transform.forward * 0.8f;
			((Component)carriedItem).transform.position = position;
			if (addForce && Object.op_Implicit((Object)(object)_carriedRB))
			{
				_carriedRB.AddForce(((Component)_brain).transform.forward * 4f, (ForceMode)1);
			}
			CarriedItem = null;
			_carriedRB = null;
			CarryTimer = 0f;
			_brain.ExtractionController.ResetGrace();
			_brain.SetDebugStatus("Dropped item");
		}

		public void StartDrop(ExtractionPoint activeEP)
		{
			IsDropping = true;
			((MonoBehaviour)_brain).StartCoroutine(DropGently(activeEP));
		}

		private IEnumerator DropGently(ExtractionPoint activeEP)
		{
			if (!Object.op_Implicit((Object)(object)CarriedItem))
			{
				IsDropping = false;
				yield break;
			}
			PhysGrabObject released = CarriedItem;
			Transform tform = ((Component)released).transform;
			try
			{
				tform.SetParent((Transform)null, true);
			}
			catch
			{
			}
			Vector3 start = tform.position;
			Vector3 val;
			Vector3 val2;
			if (!Object.op_Implicit((Object)(object)activeEP))
			{
				val = ((Component)_brain).transform.forward;
			}
			else
			{
				val2 = (((Component)activeEP).transform.position - ((Component)_brain).transform.position).WithY(0f);
				val = ((Vector3)(ref val2)).normalized;
			}
			Vector3 fwd = val;
			if (((Vector3)(ref fwd)).sqrMagnitude < 0.0001f)
			{
				fwd = ((Component)_brain).transform.forward;
			}
			Vector3 end = start + fwd * 0.6f + Vector3.down * 0.3f;
			float t = 0f;
			float dur = 0.25f;
			while (t < dur && Object.op_Implicit((Object)(object)CarriedItem))
			{
				t += Time.deltaTime;
				float a = Mathf.Clamp01(t / dur);
				tform.position = Vector3.Lerp(start, end, a);
				tform.rotation = Quaternion.Slerp(tform.rotation, Quaternion.identity, a * 0.5f);
				yield return null;
			}
			try
			{
				if (Object.op_Implicit((Object)(object)_carriedRB))
				{
					_carriedRB.isKinematic = false;
					_carriedRB.detectCollisions = true;
					if ((int)_carriedRB.collisionDetectionMode == 0)
					{
						_carriedRB.collisionDetectionMode = (CollisionDetectionMode)2;
					}
					_carriedRB.velocity = Vector3.zero;
					_carriedRB.angularVelocity = Vector3.zero;
				}
			}
			catch
			{
			}
			SetCarryCollisionIgnore(ignore: false);
			if (Object.op_Implicit((Object)(object)_brain.Navigation.Agent) && _brain.Navigation.Agent.isOnNavMesh)
			{
				Vector3 position = ((Component)_brain).transform.position;
				val2 = Random.insideUnitSphere.WithY(0f);
				Vector3 aside = position + ((Vector3)(ref val2)).normalized * 1.2f;
				NavMeshHit hit = default(NavMeshHit);
				if (NavMesh.SamplePosition(aside, ref hit, 2f, -1))
				{
					_brain.Navigation.SetDestination(((NavMeshHit)(ref hit)).position);
				}
				hit = default(NavMeshHit);
			}
			yield return (object)new WaitForFixedUpdate();
			HardReleaseAndSeparate(((Component)_brain).transform.position);
			int id = ((Object)released).GetInstanceID();
			_brain.LootScanner.IgnoreTemp(id, 5f);
			CarriedItem = null;
			_carriedRB = null;
			CarryTimer = 0f;
			_brain.ExtractionController.ResetGrace();
			IsDropping = false;
			_brain.SetDebugStatus("Item delivered!");
		}

		private void HardReleaseAndSeparate(Vector3 awayFrom, float minSeparation = 0.9f)
		{
			//IL_003e: 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_0044: 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)
			//IL_007b: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)CarriedItem == (Object)null)
			{
				return;
			}
			try
			{
				((Component)CarriedItem).transform.SetParent((Transform)null, true);
			}
			catch
			{
			}
			Vector3 val = (((Component)CarriedItem).transform.position - awayFrom).WithY(0f);
			if (((Vector3)(ref val)).sqrMagnitude < 0.0001f)
			{
				val = ((Component)_brain).transform.forward;
			}
			val = ((Vector3)(ref val)).normalized;
			Vector3 position = ((Component)CarriedItem).transform.position + val * minSeparation;
			RaycastHit val2 = default(RaycastHit);
			if (Physics.Raycast(((Component)CarriedItem).transform.position + Vector3.up * 0.1f, val, ref val2, minSeparation, -1, (QueryTriggerInteraction)1))
			{
				position = ((RaycastHit)(ref val2)).point - val * 0.05f;
			}
			((Component)CarriedItem).transform.position = position;
			Physics.SyncTransforms();
			try
			{
				if (Object.op_Implicit((Object)(object)_carriedRB))
				{
					_carriedRB.AddForce(val * 1.25f, (ForceMode)1);
				}
			}
			catch
			{
			}
		}

		private void SetCarryCollisionIgnore(bool ignore)
		{
			if ((Object)(object)CarriedItem == (Object)null)
			{
				return;
			}
			_carriedCols.Clear();
			((Component)CarriedItem).GetComponentsInChildren<Collider>(true, _carriedCols);
			for (int i = 0; i < _myCols.Length; i++)
			{
				Collider val = _myCols[i];
				if (!Object.op_Implicit((Object)(object)val))
				{
					continue;
				}
				for (int j = 0; j < _carriedCols.Count; j++)
				{
					Collider val2 = _carriedCols[j];
					if (Object.op_Implicit((Object)(object)val2))
					{
						try
						{
							Physics.IgnoreCollision(val, val2, ignore);
						}
						catch
						{
						}
					}
				}
			}
		}
	}
	public class PlayerBotCombatController
	{
		private PlayerBotBrain _brain;

		private float _scanTimer;

		private const float KILL_RANGE_MIN = 3f;

		private const float KILL_RANGE_MAX = 15f;

		public PlayerBotCombatController(PlayerBotBrain brain)
		{
			_brain = brain;
		}

		public void UpdateCombat()
		{
			//IL_00cc: 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_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			_scanTimer += Time.deltaTime;
			if (_scanTimer < 0.25f)
			{
				return;
			}
			_scanTimer = 0f;
			if ((Object)(object)EnemyDirector.instance == (Object)null)
			{
				return;
			}
			List<EnemyParent> enemiesSpawned = EnemyDirector.instance.enemiesSpawned;
			for (int i = 0; i < enemiesSpawned.Count; i++)
			{
				EnemyParent val = enemiesSpawned[i];
				if (!((Object)(object)val == (Object)null) && val.Spawned && !((Object)(object)val.Enemy == (Object)null) && !((Object)(object)val.Enemy.Health == (Object)null))
				{
					float num = Vector3.Distance(((Component)_brain).transform.position, ((Component)val.Enemy).transform.position);
					if (num > 3f && num < 15f)
					{
						Vector3 val2 = ((Component)val.Enemy).transform.position - ((Component)_brain).transform.position;
						Vector3 normalized = ((Vector3)(ref val2)).normalized;
						val.Enemy.Health.Hurt(999, normalized);
					}
				}
			}
		}
	}
	public class PlayerBotExtractionController
	{
		private PlayerBotBrain _brain;

		private int _lastActivateId;

		private float _lastActivateTime;

		private float _activationTimer;

		public float ActivationGraceUntil { get; private set; }

		public bool IsActivating { get; private set; }

		public PlayerBotExtractionController(PlayerBotBrain brain)
		{
			_brain = brain;
		}

		public void ResetGrace()
		{
			ActivationGraceUntil = 0f;
		}

		public void Update()
		{
			if (IsActivating)
			{
				_activationTimer += Time.deltaTime;
				if (_activationTimer > 3f)
				{
					IsActivating = false;
					_activationTimer = 0f;
				}
			}
		}

		public bool IsDeliveryDropAllowed(ExtractionPoint targetEP)
		{
			try
			{
				if (Object.op_Implicit((Object)(object)RoundDirector.instance))
				{
					if (RoundDirector.instance.allExtractionPointsCompleted)
					{
						return true;
					}
					if ((Object)(object)targetEP == (Object)null)
					{
						return false;
					}
					return RoundDirector.instance.extractionPointActive && (Object)(object)RoundDirector.instance.extractionPointCurrent == (Object)(object)targetEP;
				}
			}
			catch
			{
			}
			return true;
		}

		public void StartActivation(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;
					ActivationGraceUntil = Time.time + 2f;
					IsActivating = true;
					_activationTimer = 0f;
				}
			}
		}

		public void CancelActivation()
		{
			IsActivating = false;
			_activationTimer = 0f;
		}
	}
	public class PlayerBotLootScanner
	{
		private PlayerBotBrain _brain;

		private HashSet<int> _permanentIgnoreIds = new HashSet<int>();

		private Dictionary<int, float> _tempIgnoreIds = new Dictionary<int, float>();

		private float _scanTimer;

		public PlayerBotLootScanner(PlayerBotBrain brain)
		{
			_brain = brain;
		}

		public void IgnorePermanent(int id)
		{
			_permanentIgnoreIds.Add(id);
		}

		public void IgnoreTemp(int id, float duration)
		{
			_tempIgnoreIds[id] = Time.time + duration;
		}

		public void UpdateTimers()
		{
			List<int> list = new List<int>();
			foreach (KeyValuePair<int, float> tempIgnoreId in _tempIgnoreIds)
			{
				if (Time.time > tempIgnoreId.Value)
				{
					list.Add(tempIgnoreId.Key);
				}
			}
			foreach (int item in list)
			{
				_tempIgnoreIds.Remove(item);
			}
		}

		public PhysGrabObject ScanForLoot(Vector3 scanOrigin, Vector3 defaultDropZone)
		{
			//IL_0034: 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)
			_scanTimer -= Time.deltaTime;
			if (_scanTimer > 0f)
			{
				return null;
			}
			_scanTimer = 0.5f;
			return FindLoot(scanOrigin, defaultDropZone);
		}

		private PhysGrabObject FindLoot(Vector3 origin, Vector3 defaultDropZone)
		{
			//IL_0001: 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_0016: 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_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: 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_0111: Unknown result type (might be due to invalid IL or missing references)
			Collider[] array = Physics.OverlapSphere(origin, 20f);
			float num = 999f;
			PhysGrabObject result = null;
			Vector3 val = defaultDropZone;
			if (Object.op_Implicit((Object)(object)RoundDirector.instance) && RoundDirector.instance.extractionPointActive && Object.op_Implicit((Object)(object)RoundDirector.instance.extractionPointCurrent))
			{
				val = ((Component)RoundDirector.instance.extractionPointCurrent).transform.position;
			}
			Collider[] array2 = array;
			foreach (Collider val2 in array2)
			{
				ValuableObject componentInParent = ((Component)val2).GetComponentInParent<ValuableObject>();
				if (!Object.op_Implicit((Object)(object)componentInParent))
				{
					continue;
				}
				PhysGrabObject component = ((Component)componentInParent).GetComponent<PhysGrabObject>();
				if (!Object.op_Implicit((Object)(object)component))
				{
					continue;
				}
				int instanceID = ((Object)component).GetInstanceID();
				if (!SemiFunc.PhysGrabObjectIsGrabbed(component) && !_permanentIgnoreIds.Contains(instanceID) && !_tempIgnoreIds.ContainsKey(instanceID) && !(Vector3.Distance(((Component)component).transform.position, val) < 4f))
				{
					float num2 = Vector3.Distance(origin, ((Component)component).transform.position);
					if (num2 < num)
					{
						num = num2;
						result = component;
					}
				}
			}
			return result;
		}
	}
	public class PlayerBotNavigation
	{
		private PlayerBotBrain _brain;

		private List<Vector3> _globalPoints = new List<Vector3>();

		private bool _haveGlobal;

		private float _stuckTimer;

		private Vector3 _lastPos;

		private float _strafeDir = 1f;

		public NavMeshAgent Agent { get; private set; }

		public Vector3 SpawnTruckPos { get; private set; }

		public float StuckTimer => _stuckTimer;

		public PlayerBotNavigation(PlayerBotBrain brain)
		{
			_brain = brain;
			Agent = ((Component)brain).gameObject.AddComponent<NavMeshAgent>();
			Agent.updatePosition = false;
			Agent.updateRotation = false;
			Agent.updateUpAxis = false;
			Agent.radius = 0.5f;
			Agent.height = 1.8f;
			Agent.speed = 0f;
			Agent.acceleration = 9999f;
			Agent.autoBraking = true;
		}

		public bool TryPlaceOnNavMesh(Vector3 desired)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			NavMeshHit val = default(NavMeshHit);
			if (NavMesh.SamplePosition(desired, ref val, 10f, -1))
			{
				return Agent.Warp(((NavMeshHit)(ref val)).position);
			}
			return false;
		}

		public void BuildGlobalTargets()
		{
			//IL_0019: 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_00fd: 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_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			_globalPoints.Clear();
			SpawnTruckPos = ((Component)_brain).transform.position;
			try
			{
				if (Object.op_Implicit((Object)(object)LevelGenerator.Instance) && LevelGenerator.Instance.LevelPathPoints != null)
				{
					foreach (LevelPoint levelPathPoint in LevelGenerator.Instance.LevelPathPoints)
					{
						if (Object.op_Implicit((Object)(object)levelPathPoint))
						{
							_globalPoints.Add(((Component)levelPathPoint).transform.position);
							if (Object.op_Implicit((Object)(object)levelPathPoint.Room) && levelPathPoint.Room.Truck)
							{
								SpawnTruckPos = ((Component)levelPathPoint).transform.position;
							}
						}
					}
				}
			}
			catch
			{
			}
			if (_globalPoints.Count == 0)
			{
				try
				{
					NavMeshTriangulation val = NavMesh.CalculateTriangulation();
					Vector3[] vertices = val.vertices;
					int num = Mathf.Max(1, vertices.Length / 64);
					NavMeshHit val2 = default(NavMeshHit);
					for (int i = 0; i < vertices.Length; i += num)
					{
						if (NavMesh.SamplePosition(vertices[i], ref val2, 3f, -1))
						{
							_globalPoints.Add(((NavMeshHit)(ref val2)).position);
						}
					}
				}
				catch
				{
				}
			}
			_haveGlobal = _globalPoints.Count > 0;
		}

		public void PickWanderDest()
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = ((!_haveGlobal) ? (((Component)_brain).transform.position + Random.insideUnitSphere * 15f) : _globalPoints[Random.Range(0, _globalPoints.Count)]);
			NavMeshHit val2 = default(NavMeshHit);
			if (NavMesh.SamplePosition(val, ref val2, 5f, -1))
			{
				Agent.SetDestination(((NavMeshHit)(ref val2)).position);
			}
			else
			{
				Agent.SetDestination(val);
			}
		}

		public Vector3 GetTruckDestination()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: 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_00b0: 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_0084: Unknown result type (might be due to invalid IL or missing references)
			Vector3 result = SpawnTruckPos;
			try
			{
				if (Object.op_Implicit((Object)(object)LevelGenerator.Instance) && LevelGenerator.Instance.LevelPathPoints != null)
				{
					foreach (LevelPoint levelPathPoint in LevelGenerator.Instance.LevelPathPoints)
					{
						if (!Object.op_Implicit((Object)(object)levelPathPoint) || !Object.op_Implicit((Object)(object)levelPathPoint.Room) || !levelPathPoint.Room.Truck)
						{
							continue;
						}
						result = ((Component)levelPathPoint).transform.position;
						break;
					}
				}
			}
			catch
			{
			}
			return result;
		}

		public void SetDestination(Vector3 target)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			Agent.SetDestination(target);
		}

		public void UpdateMovement()
		{
			//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_001c: 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_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: 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_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			PlayerIsBotComplete.MoveInput = Vector2.zero;
			PlayerIsBotComplete.InputJump = false;
			bool flag = Physics.Raycast(((Component)_brain).transform.position + Vector3.up, ((Component)_brain).transform.forward, 1.2f);
			bool flag2 = Agent.hasPath && !Agent.pathPending && Agent.remainingDistance > 0.4f;
			float num = Vector3.Distance(((Component)_brain).transform.position, _lastPos);
			_lastPos = ((Component)_brain).transform.position;
			if (num < 0.02f && flag2)
			{
				_stuckTimer += Time.deltaTime;
				if (_stuckTimer > 0.5f && _stuckTimer <= 1.5f)
				{
					if (Time.frameCount % 20 == 0)
					{
						_strafeDir *= -1f;
					}
					PlayerIsBotComplete.MoveInput = new Vector2(_strafeDir, 1f);
				}
				else if (_stuckTimer > 1.5f && _stuckTimer <= 2.5f)
				{
					PlayerIsBotComplete.MoveInput = new Vector2(0f, 1f);
					PlayerIsBotComplete.InputJump = true;
				}
				else if (_stuckTimer > 2.5f)
				{
					Agent.ResetPath();
					PickWanderDest();
					_stuckTimer = 0f;
				}
			}
			else
			{
				_stuckTimer = 0f;
			}
			if (!flag2 || !(_stuckTimer <= 0.5f))
			{
				return;
			}
			Vector3 val = Agent.steeringTarget - ((Component)_brain).transform.position;
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			normalized.y = 0f;
			if (normalized != Vector3.zero)
			{
				float num2 = Vector3.SignedAngle(((Component)_brain).transform.forward, normalized, Vector3.up);
				float num3 = ((Mathf.Abs(num2) < 60f) ? 1f : 0f);
				if (Mathf.Abs(num2) > 45f)
				{
					num3 = 0.5f;
				}
				PlayerIsBotComplete.MoveInput = new Vector2(0f, num3);
			}
		}
	}
	[BepInPlugin("Empress.PlayerBotComplete", "Player Is The Bot (Complete)", "4.4.0")]
	public class PlayerIsBotComplete : BaseUnityPlugin
	{
		public static PlayerIsBotComplete Instance;

		public static ManualLogSource Log;

		private Harmony _harmony;

		public static bool IsActive;

		public static Vector2 MoveInput;

		public static Vector2 LookInput;

		public static bool InputJump;

		public static bool InputInteract;

		public static bool InputThrow;

		public static bool InputGrab;

		public static bool InputSprint;

		private void Awake()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			Instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			_harmony = new Harmony("Empress.PlayerBotComplete");
			_harmony.PatchAll();
			Log.LogInfo((object)"=== Player Bot (Complete) v4.4 Loaded. Waiting for player... ===");
			((MonoBehaviour)this).StartCoroutine(WaitForPlayer());
		}

		private void OnDestroy()
		{
			_harmony.UnpatchSelf();
		}

		private IEnumerator WaitForPlayer()
		{
			while (true)
			{
				if ((Object)(object)PlayerController.instance != (Object)null)
				{
					bool isClient = false;
					try
					{
						if (PhotonNetwork.InRoom && !PhotonNetwork.IsMasterClient)
						{
							isClient = true;
						}
					}
					catch
					{
					}
					if (isClient)
					{
						break;
					}
					PlayerBotBrain brain = ((Component)PlayerController.instance).gameObject.GetComponent<PlayerBotBrain>();
					if ((Object)(object)brain == (Object)null)
					{
						Log.LogInfo((object)">>> Injecting Bot Brain into Player GameObject <<<");
						((Component)PlayerController.instance).gameObject.AddComponent<PlayerBotBrain>();
					}
				}
				yield return (object)new WaitForSeconds(1f);
			}
			Log.LogWarning((object)"PlayerBot: You are a Client (Not Host). Bot disabled.");
		}
	}
	public static class VectorExtensions
	{
		public static Vector3 WithY(this Vector3 v, float y)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			v.y = y;
			return v;
		}
	}
}