Decompiled source of Synergy v0.3.0

Synergy.dll

Decompiled 3 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Photon.Pun;
using REPO.Patches;
using Strobotnik.Klattersynth;
using TMPro;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("REPO")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("REPO")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("8910fcaa-d6e1-4fe2-9564-52ad4326a4af")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("synergy.repo", "Synergy", "0.3.0")]
public class Synergy : BaseUnityPlugin
{
	internal static ManualLogSource Logger;

	private void Awake()
	{
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		Logger = ((BaseUnityPlugin)this).Logger;
		new Harmony("synergy.repo").PatchAll();
	}
}
namespace TalkingCart.Patches
{
	[HarmonyPatch(typeof(PhysGrabObject))]
	internal class PhysGrabObjectPatch
	{
		[CompilerGenerated]
		private sealed class <DisableRoastValidity>d__1 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public int itemInd;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <DisableRoastValidity>d__1(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(2f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					ValuableObjectPatch.isValidForRoast[itemInd] = false;
					ValuableObjectPatch.roastValidityCoroutines[itemInd] = null;
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void UpdatePatch(PhysGrabObject __instance, ref bool ___grabbed, ref bool ___isValuable)
		{
			if (!___isValuable)
			{
				return;
			}
			ValuableObject component = ((Component)__instance).GetComponent<ValuableObject>();
			int num = ValuableObjectPatch.levelValuables.IndexOf(component);
			if (___grabbed)
			{
				if (ValuableObjectPatch.roastValidityCoroutines[num] != null)
				{
					((MonoBehaviour)__instance).StopCoroutine(ValuableObjectPatch.roastValidityCoroutines[num]);
				}
				ValuableObjectPatch.isValidForRoast[num] = true;
			}
			else if (ValuableObjectPatch.isValidForRoast[num] && ValuableObjectPatch.roastValidityCoroutines[num] == null)
			{
				ValuableObjectPatch.roastValidityCoroutines[num] = ((MonoBehaviour)__instance).StartCoroutine(DisableRoastValidity(num));
			}
		}

		[IteratorStateMachine(typeof(<DisableRoastValidity>d__1))]
		private static IEnumerator DisableRoastValidity(int itemInd)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <DisableRoastValidity>d__1(0)
			{
				itemInd = itemInd
			};
		}
	}
}
namespace REPO.Patches
{
	[HarmonyPatch(typeof(Arena))]
	internal class ArenaPatch
	{
		[HarmonyPatch("StateGameOver")]
		[HarmonyPostfix]
		private static void StateGameOverPatch(Arena __instance, int ___numberOfPlayers, PlayerAvatar ___winnerPlayer)
		{
			if (Object.op_Implicit((Object)(object)___winnerPlayer))
			{
				ArenaMessageWinUI.instance.ArenaText("KOEN GOT WHIPPED!", true);
				if (Object.op_Implicit((Object)(object)__instance.crownMesh))
				{
					((Renderer)__instance.crownMesh).enabled = false;
				}
			}
			else if (___numberOfPlayers > 1 && SemiFunc.IsMultiplayer())
			{
				ArenaMessageWinUI.instance.ArenaText("THE WORMS WON!", false);
			}
		}
	}
	[HarmonyPatch(typeof(PhysGrabCart))]
	internal class CartVocalPatch
	{
		public static List<CartTalkingManager> carts = new List<CartTalkingManager>();

		private static List<PhysGrabObject> cartsPhysGrabObjects = new List<PhysGrabObject>();

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void StartPatch(PhysGrabCart __instance, ref PhysGrabObject ___physGrabObject)
		{
			if (!__instance.isSmallCart)
			{
				CartTalkingManager cartTalkingManager = ((Component)__instance).gameObject.AddComponent<CartTalkingManager>();
				(cartTalkingManager.cartRoastSync = ((Component)__instance).gameObject.AddComponent<CartRoastSync>()).cart = cartTalkingManager;
				carts.Add(cartTalkingManager);
				cartsPhysGrabObjects.Add(___physGrabObject);
			}
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void UpdatePatch(PhysGrabCart __instance, ref bool ___cartBeingPulled)
		{
			if (!__instance.isSmallCart)
			{
				((Component)__instance).GetComponent<CartTalkingManager>().isCartBeingPulled = ___cartBeingPulled;
			}
		}
	}
	internal class CartRoastSync : MonoBehaviourPun
	{
		public CartTalkingManager cart;

		public float cartChanceToReactToDamagingItems = 0.5f;

		private static readonly string[] roasts = new string[24]
		{
			"Who needs money anyways", "Were you born like this?", "Who needs enemies when we have you", "The dumbass strikes again", "Wisdom chases you, but you are faster", "You're the type of guy who would eat all the supplies in a zombie movie and then die first", "I would rather burn my eyes looking at the sun than watch you play one more level", "Seriously can we kick this guy?", "Have you considered uninstalling the game?", "I bet your family doesn't invite you over for christmas",
			"I wish I had legs so I could kick your ass", "Single digit IQ", "This has to be some form of disability", "Can't wait until they add the kick button", "Is your spirit animal a rock?", "You're so ugly even a TSA agent wouldn't touch you", "I'm considering retirement", "I should've taken the walmart job", "We should've left bro in the ship", "Great now go find the robe and give him a hug",
			"I would drop kick you if I had legs", "This is why you're always picked last", "It takes a special person to screw up this badly", "The worms can have you"
		};

		public void AttemptRoast()
		{
			if (cart.cartVoiceQueue.Count <= 0)
			{
				int item = Random.Range(0, roasts.Length);
				List<int> list = new List<int>();
				List<float> list2 = new List<float>();
				list.Add(item);
				list2.Add(0f);
				if (SemiFunc.IsMultiplayer())
				{
					((MonoBehaviourPun)this).photonView.RPC("AttemptRoastRPC", (RpcTarget)0, new object[2]
					{
						list.ToArray(),
						list2.ToArray()
					});
				}
				else
				{
					AttemptRoastRPC(list.ToArray(), list2.ToArray());
				}
			}
		}

		[PunRPC]
		private void AttemptRoastRPC(int[] indices, float[] delays)
		{
			for (int i = 0; i < indices.Length; i++)
			{
				int num = indices[i];
				string text = roasts[num];
				foreach (AudioClip item in cart.TTSGenerateAudioClip(text))
				{
					cart.EnqueueValues(item, delays[i], text);
				}
			}
		}
	}
	internal class CartSelfMovementManager : MonoBehaviour
	{
		private Rigidbody rb;

		public CartTargetSync cartTargetSync;

		private Transform inCart;

		private float totalCartMass;

		private float calculateObjectsEvery = 1f;

		private int cornerInd;

		private NavMeshPath cartNavMeshPath;

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

		private bool isCartFollowingPath;

		private float cornerMinDistance = 1f;

		private float cartSpeed = 15f;

		private float cartRotationSpeed = 2f;

		private float cartDriveRotationSpeed = 7f;

		private int extractionPointInd = -1;

		private bool isExtracting;

		public bool isCartBeingPulled;

		private Vector3 lastCartPosition = Vector3.zero;

		public bool remoteControlForward;

		public bool remoteControlBack;

		public bool remoteControlRight;

		public bool remoteControlLeft;

		private float pathRecalculationTimer = 5f;

		private float checkDistanceFromPathTimer = 0.5f;

		private Vector3 finalDestination;

		private List<GameObject> cornerSpheres;

		private GameObject cartHeightGuide;

		private bool cartGuideForward = true;

		private bool toVisualize;

		private List<PhysGrabHinge> collidedUnbrokenDoors = new List<PhysGrabHinge>();

		private List<float> doorsCollisionTime = new List<float>();

		private float destroyDoorAfter = 2f;

		private void Start()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Expected O, but got Unknown
			//IL_008e: 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_00bc: Unknown result type (might be due to invalid IL or missing references)
			rb = ((Component)this).GetComponent<Rigidbody>();
			cartTargetSync = ((Component)this).gameObject.AddComponent<CartTargetSync>();
			inCart = ((Component)this).transform.Find("In Cart");
			cartNavMeshPath = new NavMeshPath();
			isCartFollowingPath = false;
			isCartBeingPulled = false;
			remoteControlForward = false;
			remoteControlBack = false;
			remoteControlRight = false;
			remoteControlLeft = false;
			cornerSpheres = new List<GameObject>();
			cartHeightGuide = new GameObject("CartHeightGuide");
			cartHeightGuide.transform.localScale = Vector3.one / 4f;
			cartGuideForward = true;
			if (toVisualize)
			{
				MiscHelper.AddSphereToGameObject(cartHeightGuide, 0.1f, Color.yellow);
			}
		}

		private void FixedUpdate()
		{
			GetNextCartStepHeight();
			HandleCollidedDoors();
			calculateObjectsEvery -= Time.fixedDeltaTime;
			if (calculateObjectsEvery < 0f)
			{
				CalculateCartObjectsMass();
				calculateObjectsEvery = 0.5f;
			}
			if ((remoteControlForward || remoteControlBack || remoteControlRight || remoteControlLeft) && !isCartBeingPulled)
			{
				StopPathfinding();
				ApplyUpwardsForceToCart();
				if (remoteControlForward || remoteControlBack)
				{
					HandleCartSpeed();
				}
				if (remoteControlForward)
				{
					MoveCartForward();
				}
				if (remoteControlBack)
				{
					MoveCartBackward();
				}
				if (remoteControlRight)
				{
					TurnCartRight();
				}
				if (remoteControlLeft)
				{
					TurnCartLeft();
				}
			}
			if (isCartBeingPulled && isCartFollowingPath)
			{
				StopPathfinding();
			}
			if (isCartFollowingPath)
			{
				ApplyUpwardsForceToCart();
				HandleCartSpeed();
				FollowPath();
				HandlePathRecalculation();
			}
		}

		private void HandlePathRecalculation()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			checkDistanceFromPathTimer -= Time.fixedDeltaTime;
			pathRecalculationTimer -= Time.fixedDeltaTime;
			if (checkDistanceFromPathTimer < 0f)
			{
				Vector3 closestPointOnPath = GetClosestPointOnPath();
				if (Vector3.Distance(((Component)this).transform.position, closestPointOnPath) > 0.5f)
				{
					CalculatePath(finalDestination);
					checkDistanceFromPathTimer = 0.5f;
					pathRecalculationTimer = 5f;
				}
			}
			if (pathRecalculationTimer < 0f)
			{
				CalculatePath(finalDestination);
				checkDistanceFromPathTimer = 0.5f;
				pathRecalculationTimer = 5f;
			}
		}

		private void CalculateCartObjectsMass()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: 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)
			List<PhysGrabObject> list = new List<PhysGrabObject>();
			float num = 0f;
			Collider[] array = Physics.OverlapBox(inCart.position, inCart.localScale / 2f, inCart.rotation);
			foreach (Collider val in array)
			{
				bool flag = ((Component)val).gameObject.layer == LayerMask.NameToLayer("PhysGrabObject");
				bool flag2 = ((Component)val).gameObject.layer == LayerMask.NameToLayer("Player");
				if (!flag && !flag2)
				{
					continue;
				}
				Rigidbody componentInParent = ((Component)val).gameObject.GetComponentInParent<Rigidbody>();
				if ((Object)(object)componentInParent == (Object)null)
				{
					continue;
				}
				if (flag)
				{
					PhysGrabObject componentInParent2 = ((Component)val).GetComponentInParent<PhysGrabObject>();
					if (!list.Contains(componentInParent2))
					{
						list.Add(componentInParent2);
						num += componentInParent.mass;
					}
				}
				else
				{
					num += componentInParent.mass;
				}
			}
			totalCartMass = num;
		}

		private void MoveCartForward()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: 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_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			if (!cartGuideForward)
			{
				cartGuideForward = true;
			}
			Vector3 val = new Vector3(((Component)this).transform.forward.x, 0f, ((Component)this).transform.forward.z);
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			float y = rb.velocity.y;
			Vector3 val2 = normalized * cartSpeed;
			val2.y = y;
			rb.velocity = Vector3.Lerp(rb.velocity, val2, Time.fixedDeltaTime * 2f);
		}

		private void MoveCartBackward()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: 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_003c: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: 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_008e: Unknown result type (might be due to invalid IL or missing references)
			if (cartGuideForward)
			{
				cartGuideForward = false;
			}
			Vector3 val = new Vector3(((Component)this).transform.forward.x, 0f, ((Component)this).transform.forward.z);
			Vector3 val2 = -((Vector3)(ref val)).normalized;
			float y = rb.velocity.y;
			Vector3 val3 = val2 * (cartSpeed * 0.7f);
			val3.y = y;
			rb.velocity = Vector3.Lerp(rb.velocity, val3, Time.fixedDeltaTime * 2f);
		}

		private void TurnCartLeft()
		{
			//IL_0006: 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)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: 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_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = new Vector3(rb.velocity.x, 0f, rb.velocity.z);
			float magnitude = ((Vector3)(ref val)).magnitude;
			float num = Mathf.Clamp01(1f - magnitude / (cartSpeed * 1.2f));
			float num2 = cartDriveRotationSpeed * Mathf.Lerp(0.5f, 1f, num);
			float num3 = -90f * Time.fixedDeltaTime * num2;
			float num4 = Mathf.Clamp(Mathf.Abs(num3) / 180f, 0.2f, 1f) * 15f;
			num4 = Mathf.Clamp(num4, 0f, 4f);
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor(0f, Mathf.Sign(num3) * num4, 0f);
			rb.angularVelocity = Vector3.MoveTowards(rb.angularVelocity, val2, num4);
			rb.angularVelocity = Vector3.ClampMagnitude(rb.angularVelocity, 4f);
			Vector3 val3 = Vector3.Project(rb.velocity, ((Component)this).transform.right);
			Rigidbody obj = rb;
			obj.velocity -= val3 * 0.1f * Time.fixedDeltaTime;
		}

		private void TurnCartRight()
		{
			//IL_0006: 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)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: 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_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = new Vector3(rb.velocity.x, 0f, rb.velocity.z);
			float magnitude = ((Vector3)(ref val)).magnitude;
			float num = Mathf.Clamp01(1f - magnitude / (cartSpeed * 1.2f));
			float num2 = cartDriveRotationSpeed * Mathf.Lerp(0.5f, 1f, num);
			float num3 = 90f * Time.fixedDeltaTime * num2;
			float num4 = Mathf.Clamp(Mathf.Abs(num3) / 180f, 0.2f, 1f) * 15f;
			num4 = Mathf.Clamp(num4, 0f, 4f);
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor(0f, Mathf.Sign(num3) * num4, 0f);
			rb.angularVelocity = Vector3.MoveTowards(rb.angularVelocity, val2, num4);
			rb.angularVelocity = Vector3.ClampMagnitude(rb.angularVelocity, 4f);
			Vector3 val3 = Vector3.Project(rb.velocity, ((Component)this).transform.right);
			Rigidbody obj = rb;
			obj.velocity -= val3 * 0.1f * Time.fixedDeltaTime;
		}

		private void ApplyUpwardsForceToCart()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = Vector3.up * (totalCartMass + GetNextCartStepHeight());
			Vector3 gravity = Physics.gravity;
			Vector3 val2 = val * ((Vector3)(ref gravity)).magnitude;
			rb.AddForce(val2);
		}

		private float GetNextCartStepHeight()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: 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_0036: 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_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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_0080: 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_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: 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_007d: Unknown result type (might be due to invalid IL or missing references)
			float num = 1.5f;
			Vector3 origin = ((Component)this).transform.position + ((Component)this).transform.forward * num;
			if (!cartGuideForward)
			{
				origin = ((Component)this).transform.position + ((Component)this).transform.forward * (0f - num);
			}
			if (isCartFollowingPath)
			{
				origin = MiscHelper.GetPointTowardTarget(((Component)this).transform.position, pathCorners[cornerInd], num);
			}
			origin = GetNearestNavMeshPosition(origin);
			cartHeightGuide.transform.position = origin;
			float num2 = origin.y - ((Component)this).transform.position.y;
			num2 += 0.5f;
			if (num2 > 0.3f)
			{
				return 2.1f;
			}
			if (num2 < -0.3f)
			{
				return -2f;
			}
			return 0f;
		}

		private void HandleCartSpeed()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			float distanceWithoutY = GetDistanceWithoutY(((Component)this).transform.position, lastCartPosition);
			if (distanceWithoutY < 0.075f && cartSpeed < 30f)
			{
				cartSpeed *= 1.003f;
			}
			else if (distanceWithoutY > 0.08f)
			{
				cartSpeed /= 1.01f;
			}
			lastCartPosition = ((Component)this).transform.position;
		}

		private void FollowPath()
		{
			//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_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_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: 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_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//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)
			//IL_0036: 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_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)
			//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_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: 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_0088: 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_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: 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_00bd: 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_00c9: 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_00d2: 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_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0435: Unknown result type (might be due to invalid IL or missing references)
			//IL_043b: Invalid comparison between Unknown and I4
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_0296: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: 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_0494: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a8: 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_04ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0470: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0304: Unknown result type (might be due to invalid IL or missing references)
			//IL_0309: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ce: 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_050e: Unknown result type (might be due to invalid IL or missing references)
			//IL_051e: Unknown result type (might be due to invalid IL or missing references)
			//IL_039a: Unknown result type (might be due to invalid IL or missing references)
			//IL_039f: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ad: 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_03c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fe: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = pathCorners[cornerInd];
			Vector3 nearestNavMeshPosition = GetNearestNavMeshPosition(((Component)this).transform.position);
			Vector3 val2 = val - nearestNavMeshPosition;
			Vector3 normalized = ((Vector3)(ref val2)).normalized;
			float distanceWithoutY = GetDistanceWithoutY(nearestNavMeshPosition, val);
			val2 = new Vector3(normalized.x, 0f, normalized.z);
			Vector3 normalized2 = ((Vector3)(ref val2)).normalized;
			val2 = new Vector3(((Component)this).transform.forward.x, 0f, ((Component)this).transform.forward.z);
			float num = Vector3.Angle(((Vector3)(ref val2)).normalized, normalized2);
			Vector3 val3 = ((Component)this).transform.forward * -1f;
			val2 = new Vector3(val3.x, 0f, val3.z);
			float num2 = Vector3.Angle(((Vector3)(ref val2)).normalized, normalized2);
			float num3;
			if (num <= num2)
			{
				num3 = num;
				cartGuideForward = true;
			}
			else
			{
				num3 = num2;
				cartGuideForward = false;
			}
			bool flag = false;
			float num4 = 3f;
			float num5 = 45f;
			if (cornerInd < pathCorners.Count - 1 && distanceWithoutY < num4)
			{
				val2 = pathCorners[cornerInd + 1] - val;
				Vector3 normalized3 = ((Vector3)(ref val2)).normalized;
				float num6 = Vector3.Angle(normalized, normalized3);
				if (num6 > num5)
				{
					flag = true;
					_ = distanceWithoutY / num4;
					Mathf.Clamp01(num6 / 90f);
				}
			}
			if (distanceWithoutY > cornerMinDistance)
			{
				float num7 = Mathf.Lerp(0.3f, 1f, Mathf.Clamp01(1f - num3 / 90f));
				float num8 = 1f;
				if (flag)
				{
					float num9 = 1f - distanceWithoutY / num4;
					val2 = pathCorners[cornerInd + 1] - val;
					float num10 = Mathf.Clamp01(Vector3.Angle(normalized, ((Vector3)(ref val2)).normalized) / 90f);
					num8 = Mathf.Lerp(0.8f, 0.4f, num9 * num10);
				}
				float num11 = num7 * num8;
				Vector3 val4 = normalized * cartSpeed * num11;
				val4.y = rb.velocity.y;
				rb.velocity = Vector3.Lerp(rb.velocity, val4, Time.fixedDeltaTime * 2f);
				Vector3 val5 = default(Vector3);
				((Vector3)(ref val5))..ctor(rb.velocity.x, 0f, rb.velocity.z);
				if (((Vector3)(ref val5)).magnitude > 0.1f)
				{
					Quaternion val6 = Quaternion.LookRotation(val5, Vector3.up);
					Quaternion val7 = ((Component)this).transform.rotation;
					float num12 = ((Quaternion)(ref val7)).eulerAngles.y;
					if (!cartGuideForward)
					{
						val7 = ((Component)this).transform.rotation;
						num12 = (((Quaternion)(ref val7)).eulerAngles.y + 180f) % 360f;
					}
					Quaternion val8 = Quaternion.Euler(0f, num12, 0f);
					val7 = val6 * Quaternion.Inverse(val8);
					float num13 = default(float);
					Vector3 val9 = default(Vector3);
					((Quaternion)(ref val7)).ToAngleAxis(ref num13, ref val9);
					if (num13 > 180f)
					{
						num13 -= 360f;
					}
					float num14 = 12f * cartRotationSpeed;
					float num15 = Mathf.Clamp(Mathf.Abs(num13) / 180f, 0.2f, 1f) * num14;
					num15 = Mathf.Clamp(num15, 2f, 3f * cartRotationSpeed);
					num15 *= 1f - Mathf.Clamp01(num3 / 180f) * 0.7f;
					Vector3 val10 = (float)Math.PI / 180f * num13 * ((Vector3)(ref val9)).normalized * num15;
					val10 = Vector3.ClampMagnitude(val10, 4f * cartRotationSpeed);
					rb.angularVelocity = Vector3.MoveTowards(rb.angularVelocity, val10, num15);
					rb.angularVelocity = Vector3.ClampMagnitude(rb.angularVelocity, 4f * cartRotationSpeed);
				}
			}
			else if (cornerInd == pathCorners.Count - 1)
			{
				if (extractionPointInd != -1 && (int)ExtractionPointPatch.extractionStates[extractionPointInd] == 1)
				{
					((Component)ExtractionPointPatch.extractionPoints[extractionPointInd]).GetComponent<ExtractionPoint>().OnClick();
				}
				if (isExtracting)
				{
					SetPathfindingTarget(ExtractionPointPatch.extractionPoints[extractionPointInd].position, -1, _isExtracting: false);
					cornerMinDistance = 0.4f;
					return;
				}
				rb.velocity = Vector3.Lerp(rb.velocity, new Vector3(0f, 0f, 0f), Time.fixedDeltaTime * 3f);
				rb.angularVelocity = Vector3.Lerp(rb.angularVelocity, Vector3.zero, Time.fixedDeltaTime * 5f);
				val2 = rb.velocity;
				if (((Vector3)(ref val2)).magnitude < 0.1f)
				{
					rb.velocity = Vector3.zero;
					rb.angularVelocity = Vector3.zero;
					StopPathfinding();
				}
			}
			else
			{
				ChangeCornerInd(cornerInd + 1);
			}
		}

		private void StopPathfinding()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			isCartFollowingPath = false;
			cartNavMeshPath = new NavMeshPath();
			pathCorners.Clear();
			cartSpeed = 15f;
			cornerMinDistance = 1f;
			extractionPointInd = -1;
			isExtracting = false;
		}

		public void SetPathfindingTarget(Vector3 target, int _extractionPointInd, bool _isExtracting)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			StopPathfinding();
			finalDestination = target;
			extractionPointInd = _extractionPointInd;
			isExtracting = _isExtracting;
			CalculatePath(target);
			cartSpeed = 15f;
			isCartFollowingPath = true;
			checkDistanceFromPathTimer = 0.5f;
			pathRecalculationTimer = 5f;
		}

		private void CalculatePath(Vector3 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_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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_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_0052: Unknown result type (might be due to invalid IL or missing references)
			Vector3 nearestNavMeshPosition = GetNearestNavMeshPosition(((Component)this).transform.position);
			Vector3 nearestNavMeshPosition2 = GetNearestNavMeshPosition(target);
			if (NavMesh.CalculatePath(nearestNavMeshPosition, nearestNavMeshPosition2, 1, cartNavMeshPath))
			{
				pathCorners.Clear();
				Vector3[] corners = cartNavMeshPath.corners;
				foreach (Vector3 item in corners)
				{
					pathCorners.Add(item);
				}
				ChangeCornerInd(0);
				VisualizeCorners();
			}
		}

		private void VisualizeCorners()
		{
			//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_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Expected O, but got Unknown
			//IL_0065: 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_007b: 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)
			foreach (GameObject cornerSphere in cornerSpheres)
			{
				Object.Destroy((Object)(object)cornerSphere);
			}
			cornerSpheres = new List<GameObject>();
			foreach (Vector3 pathCorner in pathCorners)
			{
				GameObject val = new GameObject("CornerSphere");
				val.transform.position = pathCorner;
				val.transform.localScale = Vector3.one / 4f;
				if (toVisualize)
				{
					MiscHelper.AddSphereToGameObject(val, 0.1f, Color.red);
				}
				cornerSpheres.Add(val);
			}
		}

		public Vector3 GetNearestNavMeshPosition(Vector3 origin)
		{
			//IL_000e: 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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: 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)
			float num = 0.5f;
			float num2 = 32f;
			NavMeshHit val = default(NavMeshHit);
			while (num < num2 && !NavMesh.SamplePosition(origin, ref val, num, 1))
			{
				num *= 2f;
			}
			if (num >= num2)
			{
				return default(Vector3);
			}
			return ((NavMeshHit)(ref val)).position;
		}

		private static float GetDistanceWithoutY(Vector3 pos1, Vector3 pos2)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = new Vector3(pos1.x, 0f, pos1.z);
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor(pos2.x, 0f, pos2.z);
			return Vector3.Distance(val, val2);
		}

		public float GetDistanceFrom(Vector3 position)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			return GetDistanceWithoutY(((Component)this).transform.position, position);
		}

		private Vector3 GetClosestPointOnPath()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//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)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0085: 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_0092: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			Vector3 result = ((Component)this).transform.position;
			float num = float.MaxValue;
			for (int i = 0; i < pathCorners.Count - 1; i++)
			{
				Vector3 val = pathCorners[i];
				Vector3 val2 = pathCorners[i + 1] - val;
				float magnitude = ((Vector3)(ref val2)).magnitude;
				((Vector3)(ref val2)).Normalize();
				float num2 = Vector3.Dot(((Component)this).transform.position - val, val2);
				num2 = Mathf.Clamp(num2, 0f, magnitude);
				Vector3 val3 = val + val2 * num2;
				float num3 = Vector3.Distance(((Component)this).transform.position, val3);
				if (num3 < num)
				{
					num = num3;
					result = val3;
				}
			}
			return result;
		}

		private void ChangeCornerInd(int newVal)
		{
			cornerInd = newVal;
		}

		private void HandleCollidedDoors()
		{
			if (!isCartFollowingPath && !remoteControlForward && !remoteControlBack && !remoteControlRight && !remoteControlLeft)
			{
				if (collidedUnbrokenDoors.Count > 0)
				{
					collidedUnbrokenDoors.Clear();
					doorsCollisionTime.Clear();
				}
				return;
			}
			for (int i = 0; i < collidedUnbrokenDoors.Count; i++)
			{
				doorsCollisionTime[i] += Time.deltaTime;
				if (doorsCollisionTime[i] > destroyDoorAfter)
				{
					if ((Object)(object)collidedUnbrokenDoors[i] != (Object)null)
					{
						collidedUnbrokenDoors[i].DestroyHinge();
					}
					collidedUnbrokenDoors.RemoveAt(i);
					doorsCollisionTime.RemoveAt(i);
				}
			}
		}
	}
	internal class CartTalkingManager : MonoBehaviour
	{
		private PhysGrabCart physGrabCart;

		public bool isCartBeingPulled;

		public CartRoastSync cartRoastSync;

		private Sound cartSound = new Sound();

		private Speech cartSpeech;

		public Queue<AudioClip> cartVoiceQueue = new Queue<AudioClip>();

		private Queue<float> cartVoiceDelayQueue = new Queue<float>();

		private Queue<string> cartTextQueue = new Queue<string>();

		private float cartVoiceTimer;

		private GameObject cartTalkText;

		private RectTransform cartTalkTextTransform;

		private TextMeshProUGUI cartTalkTextTMP;

		private float textAlpha = 1f;

		private float textAlphaTarget = 1f;

		private float alphaCheckTimer;

		private Color textColor = Color.white;

		private void InitializeVariables()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			physGrabCart = ((Component)this).GetComponent<PhysGrabCart>();
			isCartBeingPulled = false;
			cartSound = new Sound();
			cartVoiceQueue = new Queue<AudioClip>();
			cartVoiceDelayQueue = new Queue<float>();
			cartTextQueue = new Queue<string>();
			cartVoiceTimer = 0f;
		}

		private void SetupTTS()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			((Component)this).gameObject.AddComponent<AudioSource>();
			GameObject val = new GameObject("CartSpeech");
			val.transform.parent = ((Component)this).transform;
			cartSpeech = val.AddComponent<Speech>();
			cartSpeech.useStreamingMode = true;
			cartSpeech.maxAutoCachedClips = 10;
			cartSpeech.voiceBaseFrequency = 220;
			cartSpeech.voicingSource = (VoicingSource)0;
			cartSpeech.msPerSpeechFrame = 10;
			cartSpeech.flutter = 10;
			cartSpeech.flutterSpeed = 1f;
		}

		private void Start()
		{
			InitializeVariables();
			cartSound.Volume = 1f;
			cartSound.Pitch = 1f;
			cartSound.PitchRandom = 0f;
			SetupTTS();
			InitializeCartText();
		}

		private void Update()
		{
			CartVoiceQueueRoller();
			HandleCartText();
		}

		private void InitializeCartText()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			cartTalkText = Object.Instantiate<GameObject>(WorldSpaceUIParent.instance.TTSPrefab, ((Component)WorldSpaceUIParent.instance).transform.position, ((Component)WorldSpaceUIParent.instance).transform.rotation, ((Component)WorldSpaceUIParent.instance).transform);
			WorldSpaceUITTS component = cartTalkText.GetComponent<WorldSpaceUITTS>();
			if ((Object)(object)component != (Object)null)
			{
				Object.Destroy((Object)(object)component);
			}
			cartTalkTextTransform = cartTalkText.GetComponent<RectTransform>();
			cartTalkTextTMP = cartTalkText.GetComponent<TextMeshProUGUI>();
			((Graphic)cartTalkTextTMP).color = textColor;
			((TMP_Text)cartTalkTextTMP).text = "";
		}

		private void HandleCartText()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = SemiFunc.UIWorldToCanvasPosition(((Component)this).transform.position);
			cartTalkTextTransform.anchoredPosition = Vector2.op_Implicit(val);
			alphaCheckTimer -= Time.deltaTime;
			if (alphaCheckTimer <= 0f)
			{
				alphaCheckTimer = 0.1f;
				textAlphaTarget = 1f;
				float num = 5f;
				float num2 = 25f;
				float num3 = Vector3.Distance(((Component)this).transform.position, PlayerControllerPatch.playerPosition);
				if (num3 > num)
				{
					num3 = Mathf.Clamp(num3, num, num2);
					textAlphaTarget = 1f - (num3 - num) / (num2 - num);
				}
			}
			textAlpha = Mathf.Lerp(textAlpha, textAlphaTarget, 30f * Time.deltaTime);
			((Graphic)cartTalkTextTMP).color = new Color(textColor.r, textColor.g, textColor.b, textAlpha);
		}

		public List<AudioClip> TTSGenerateAudioClip(string text)
		{
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Expected O, but got Unknown
			List<AudioClip> list = new List<AudioClip>();
			foreach (string item in new List<string>(text.Split(new char[1] { ' ' })))
			{
				StringBuilder stringBuilder = new StringBuilder(text.Length * 3 / 2);
				stringBuilder.Length = 0;
				stringBuilder.Append(item);
				SpeechClip val = (SpeechClip)ReflectionHelper.InvokePrivateMethod(cartSpeech, "findFromCache", stringBuilder, 220, (object)(VoicingSource)0, false);
				if (val == null)
				{
					cartSpeech.pregenerate(ref val, 220, (VoicingSource)0, stringBuilder, false, true);
				}
				if (val != null)
				{
					list.Add(val.pregenAudio);
				}
			}
			return list;
		}

		public void EnqueueValues(AudioClip audioClip, float delay, string text)
		{
			cartVoiceQueue.Enqueue(audioClip);
			cartVoiceDelayQueue.Enqueue(delay);
			cartTextQueue.Enqueue(text);
		}

		private void CartVoiceQueueRoller()
		{
			cartVoiceTimer -= Time.deltaTime;
			if (cartVoiceQueue.Count == 0 && cartVoiceTimer <= 0f && ((TMP_Text)cartTalkTextTMP).text != "")
			{
				((TMP_Text)cartTalkTextTMP).text = "";
			}
			if (cartVoiceQueue.Count != 0 && !(cartVoiceTimer > 0f))
			{
				AudioClip val = cartVoiceQueue.Dequeue();
				float num = cartVoiceDelayQueue.Dequeue();
				cartSound.Sounds = (AudioClip[])(object)new AudioClip[1] { val };
				cartVoiceTimer = val.length + num;
				string text = cartTextQueue.Dequeue();
				((TMP_Text)cartTalkTextTMP).text = text;
			}
		}
	}
	internal class CartTargetSync : MonoBehaviourPun
	{
		private CartSelfMovementManager cart;

		private void Start()
		{
			cart = ((Component)this).GetComponent<CartSelfMovementManager>();
		}

		public void GoToTarget(int type, Vector3 playerPosition)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				GoToTargetRPC(type, playerPosition);
				return;
			}
			((MonoBehaviourPun)this).photonView.RPC("GoToTargetRPC", (RpcTarget)2, new object[2] { type, playerPosition });
		}

		[PunRPC]
		private void GoToTargetRPC(int type, Vector3 playerPosition)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: 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_005f: Invalid comparison between Unknown and I4
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Invalid comparison between Unknown and I4
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: 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)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: 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_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			switch (type)
			{
			case 0:
				cart.SetPathfindingTarget(playerPosition, -1, _isExtracting: false);
				return;
			case 1:
				cart.SetPathfindingTarget(TruckHealerPatch.truckPosition, -1, _isExtracting: false);
				return;
			}
			Vector3 val = default(Vector3);
			int num = 0;
			float num2 = float.PositiveInfinity;
			bool flag = false;
			for (int i = 0; i < ExtractionPointPatch.extractionPoints.Count; i++)
			{
				Transform val2 = ExtractionPointPatch.extractionPoints[i];
				State val3 = ExtractionPointPatch.extractionStates[i];
				if ((int)val3 == 2)
				{
					val = GetExtractionFrontPosition(val2.position, val2.rotation);
					cart.SetPathfindingTarget(val, i, type == 3);
					return;
				}
				if ((int)val3 != 7)
				{
					float num3 = Vector3.Distance(val2.position, playerPosition);
					if (num3 < num2)
					{
						num = i;
						num2 = num3;
						flag = true;
					}
				}
			}
			if (flag)
			{
				Transform val4 = ExtractionPointPatch.extractionPoints[num];
				val = GetExtractionFrontPosition(val4.position, val4.rotation);
				cart.SetPathfindingTarget(val, num, type == 3);
			}
		}

		private Vector3 GetExtractionFrontPosition(Vector3 position, Quaternion rotation)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: 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_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: 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_012e: 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_010e: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = new Vector3(position.x, position.y, position.z);
			Vector3 zero = Vector3.zero;
			float num = 0.1f;
			float num2 = 4f;
			if (Mathf.Abs(rotation.y - 0.7071f) < num)
			{
				if (Mathf.Abs(rotation.w - 0.7071f) < num)
				{
					((Vector3)(ref zero))..ctor(num2, 0f, 0f);
				}
				else
				{
					((Vector3)(ref zero))..ctor(0f - num2, 0f, 0f);
				}
			}
			else if (Mathf.Abs(rotation.y + 0.7071f) < num)
			{
				if (Mathf.Abs(rotation.w - 0.7071f) < num)
				{
					((Vector3)(ref zero))..ctor(0f - num2, 0f, 0f);
				}
				else
				{
					((Vector3)(ref zero))..ctor(num2, 0f, 0f);
				}
			}
			else if (Mathf.Abs(rotation.y - 1f) < num || Mathf.Abs(rotation.y + 1f) < num)
			{
				((Vector3)(ref zero))..ctor(0f, 0f, 0f - num2);
			}
			else if (Mathf.Abs(rotation.y) < num)
			{
				((Vector3)(ref zero))..ctor(0f, 0f, num2);
			}
			return val + zero;
		}

		public void MoveCart(bool moveForward, bool moveBack, bool turnRight, bool turnLeft)
		{
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				MoveCartRPC(moveForward, moveBack, turnRight, turnLeft);
				return;
			}
			((MonoBehaviourPun)this).photonView.RPC("MoveCartRPC", (RpcTarget)2, new object[4] { moveForward, moveBack, turnRight, turnLeft });
		}

		[PunRPC]
		private void MoveCartRPC(bool moveForward, bool moveBack, bool turnRight, bool turnLeft)
		{
			cart.remoteControlForward = moveForward;
			cart.remoteControlBack = moveBack;
			cart.remoteControlRight = turnRight;
			cart.remoteControlLeft = turnLeft;
		}
	}
	[HarmonyPatch(typeof(ChatManager))]
	internal class ChatManagerPatch
	{
		public static ChatState chatState;

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void UpdatePatch(ref ChatState ___chatState)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			chatState = ___chatState;
		}
	}
	[HarmonyPatch(typeof(ExtractionPoint))]
	internal class ExtractionPointPatch
	{
		public static List<Transform> extractionPoints = new List<Transform>();

		public static List<State> extractionStates = new List<State>();

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void ExtractionPointStartPatch(ExtractionPoint __instance, ref State ___currentState)
		{
			extractionPoints.Add(((Component)__instance).transform);
			extractionStates.Add(___currentState);
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void ExtractionPointUpdatePatch(ExtractionPoint __instance, ref State ___currentState)
		{
			int index = extractionPoints.IndexOf(((Component)__instance).transform);
			extractionStates[index] = ___currentState;
		}
	}
	public static class MiscHelper
	{
		private static Dictionary<PrimitiveType, Mesh> primitiveMeshes = new Dictionary<PrimitiveType, Mesh>();

		public static void AddSphereToGameObject(GameObject gameObject, float radius, Color color)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected O, but got Unknown
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			SphereCollider obj = gameObject.AddComponent<SphereCollider>();
			obj.radius = radius;
			((Collider)obj).isTrigger = true;
			gameObject.AddComponent<MeshFilter>().mesh = GetPrimitiveMesh((PrimitiveType)0);
			MeshRenderer obj2 = gameObject.AddComponent<MeshRenderer>();
			((Renderer)obj2).material = new Material(Shader.Find("Standard"));
			((Renderer)obj2).material.color = color;
		}

		public static Mesh GetPrimitiveMesh(PrimitiveType type)
		{
			//IL_0005: 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_000d: 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)
			if (!primitiveMeshes.ContainsKey(type))
			{
				GameObject obj = GameObject.CreatePrimitive(type);
				Mesh sharedMesh = obj.GetComponent<MeshFilter>().sharedMesh;
				Object.Destroy((Object)(object)obj);
				primitiveMeshes[type] = sharedMesh;
			}
			return primitiveMeshes[type];
		}

		public static Vector3 GetPointTowardTarget(Vector3 originPosition, Vector3 targetPosition, float distance)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//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_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = targetPosition - originPosition;
			float magnitude = ((Vector3)(ref val)).magnitude;
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			if (magnitude <= distance)
			{
				return targetPosition;
			}
			return originPosition + normalized * distance;
		}
	}
	[HarmonyPatch(typeof(PhysGrabCart))]
	internal class PhysGrabCartPatch
	{
		[CompilerGenerated]
		private sealed class <SetDisplayTextCoroutine>d__3 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public float delay;

			public Action action;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <SetDisplayTextCoroutine>d__3(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(delay);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					action();
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		public static int controlledCart = -1;

		public static List<CartSelfMovementManager> carts = new List<CartSelfMovementManager>();

		private static readonly Dictionary<PhysGrabCart, Coroutine> _setDisplayTextCoroutines = new Dictionary<PhysGrabCart, Coroutine>();

		[IteratorStateMachine(typeof(<SetDisplayTextCoroutine>d__3))]
		private static IEnumerator SetDisplayTextCoroutine(float delay, Action action)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <SetDisplayTextCoroutine>d__3(0)
			{
				delay = delay,
				action = action
			};
		}

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void CartStartPatch(PhysGrabCart __instance)
		{
			if (!__instance.isSmallCart)
			{
				CartSelfMovementManager item = ((Component)__instance).gameObject.AddComponent<CartSelfMovementManager>();
				carts.Add(item);
			}
		}

		[HarmonyPatch("FixedUpdate")]
		[HarmonyPostfix]
		private static void CartFixedUpdatePatch(PhysGrabCart __instance, ref bool ___cartBeingPulled)
		{
			if (!__instance.isSmallCart)
			{
				CartSelfMovementManager component = ((Component)__instance).gameObject.GetComponent<CartSelfMovementManager>();
				if ((Object)(object)component == (Object)null)
				{
					carts.Remove(component);
				}
				else
				{
					component.isCartBeingPulled = ___cartBeingPulled;
				}
			}
		}

		public static CartSelfMovementManager GetCartToOrder(Vector3 position)
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			if (controlledCart > -1)
			{
				return carts[controlledCart];
			}
			CartSelfMovementManager result = null;
			float num = float.PositiveInfinity;
			foreach (CartSelfMovementManager cart in carts)
			{
				if (!((Object)(object)cart == (Object)null) && !cart.isCartBeingPulled)
				{
					float distanceFrom = cart.GetDistanceFrom(position);
					if (distanceFrom < num)
					{
						result = cart;
						num = distanceFrom;
					}
				}
			}
			return result;
		}

		public static void OrderCart(int orderType, Vector3 playerPosition)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			CartSelfMovementManager cartToOrder = GetCartToOrder(playerPosition);
			if (!((Object)(object)cartToOrder == (Object)null))
			{
				cartToOrder.cartTargetSync.GoToTarget(orderType, playerPosition);
			}
		}

		public static void SwitchCarts()
		{
			if (controlledCart + 1 < carts.Count)
			{
				controlledCart++;
			}
			else
			{
				controlledCart = -1;
			}
		}
	}
	[HarmonyPatch(typeof(PhysGrabHinge))]
	internal class PhysGrabHingePatch
	{
		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		private static void AwakePatch(PhysGrabHinge __instance)
		{
			((Component)__instance).gameObject.AddComponent<DoorTracker>();
		}

		[HarmonyPatch("HingeBreakImpulse")]
		[HarmonyPostfix]
		private static void HingeBreakImpulsePatch(PhysGrabHinge __instance)
		{
			((Component)__instance).GetComponent<DoorTracker>().isBroken = true;
		}

		[HarmonyPatch("DestroyHinge")]
		[HarmonyPostfix]
		private static void DestroyHingePatch(PhysGrabHinge __instance)
		{
			((Component)__instance).GetComponent<DoorTracker>().isDestroyed = true;
		}
	}
	internal class DoorTracker : MonoBehaviour
	{
		public bool isBroken;

		public bool isDestroyed;

		private void Start()
		{
			isBroken = false;
			isDestroyed = false;
		}
	}
	[HarmonyPatch(typeof(PlayerAvatar))]
	internal class PlayerAvatarPatch
	{
		[CompilerGenerated]
		private sealed class <Delay>d__13 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public float delay;

			public Action action;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <Delay>d__13(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(delay);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					action();
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		internal static PlayerAvatar instance;

		internal static string playerName;

		internal const float RandomTimeMin = 120f;

		internal const float RandomTimeMax = 180f;

		internal static string targetedPlayer = "SnakeXeye";

		private static bool isBedTime = false;

		private static readonly string[] messages = new string[17]
		{
			"I need to clean the dishes", "Not my house, but my problem", "I won that hand with three pair", "Second second chance", "Excuse me, have you seen my spine?", "I am looking for... my own will", "Can you take me out for a walk?", "Be right back, must throw away the glass", "Worms... worms everywhere", "I would check on a raise",
			"Why is it so tight around my neck?", "Hello, my name is property", "Tickling is allowed", "My anus is itchy", "I swim with my kids in a jacuzzi", "Whip me harder!", "I wonder how gaming on a PC is"
		};

		private static float timeForNextMessage = 0f;

		private static readonly HashSet<int> usedMessageIndices = new HashSet<int>();

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void StartPatch(PlayerAvatar __instance, bool ___isLocal, string ___playerName)
		{
			if (___isLocal)
			{
				instance = __instance;
				playerName = ___playerName;
			}
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void UpdatePatch()
		{
			if (((Behaviour)instance).isActiveAndEnabled)
			{
				ActionKoen();
			}
		}

		private static void ActionKoen()
		{
			if (!(playerName == targetedPlayer))
			{
				return;
			}
			if (!isBedTime && DateTime.Now.Hour == 23)
			{
				isBedTime = true;
				timeForNextMessage = RandomTime();
				instance.ChatMessageSend("Sorry boys, it is 23:00 so it is my girls uhhh I mean my own bedtime. Stopping now, goodnight!");
				((MonoBehaviour)instance).StartCoroutine(Delay(11f, delegate
				{
					instance.playerHealth.Hurt(666, false, -1, false);
				}));
			}
			if (timeForNextMessage == 0f)
			{
				timeForNextMessage = RandomTime();
			}
			else if (Time.time > timeForNextMessage)
			{
				timeForNextMessage = RandomTime();
				instance.ChatMessageSend(GetUnusedMessage());
			}
		}

		private static string GetUnusedMessage()
		{
			if (usedMessageIndices.Count == messages.Length)
			{
				usedMessageIndices.Clear();
			}
			int num;
			do
			{
				num = Random.Range(0, messages.Length);
			}
			while (usedMessageIndices.Contains(num));
			usedMessageIndices.Add(num);
			return messages[num];
		}

		[IteratorStateMachine(typeof(<Delay>d__13))]
		private static IEnumerator Delay(float delay, Action action)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <Delay>d__13(0)
			{
				delay = delay,
				action = action
			};
		}

		private static float RandomTime(float min = 120f, float max = 180f)
		{
			return Time.time + Random.Range(min, max);
		}
	}
	[HarmonyPatch(typeof(PlayerController))]
	internal class PlayerControllerPatch
	{
		private static CartSelfMovementManager closestCart = null;

		private static bool lastFrameHadMovement = false;

		public static Vector3 playerPosition = default(Vector3);

		private static List<string> mouseBtns = new List<string> { "leftButton", "rightButton", "middleButton", "forwardButton", "backButton" };

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void UpdatePatch(PlayerController __instance)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Invalid comparison between Unknown and I4
			//IL_00fa: 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_0070: 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_00aa: Unknown result type (might be due to invalid IL or missing references)
			if (!(PlayerAvatarPatch.playerName == "SyntaxTC"))
			{
				return;
			}
			playerPosition = ((Component)__instance).transform.position;
			if ((int)ChatManagerPatch.chatState != 1)
			{
				if (WasButtonPressedThisFrame("l"))
				{
					PhysGrabCartPatch.SwitchCarts();
				}
				if (WasButtonPressedThisFrame("i"))
				{
					PhysGrabCartPatch.OrderCart(0, ((Component)__instance).transform.position);
				}
				if (WasButtonPressedThisFrame("o"))
				{
					PhysGrabCartPatch.OrderCart(1, ((Component)__instance).transform.position);
				}
				if (WasButtonPressedThisFrame("u"))
				{
					PhysGrabCartPatch.OrderCart(2, ((Component)__instance).transform.position);
				}
				if (WasButtonPressedThisFrame("y"))
				{
					PhysGrabCartPatch.OrderCart(3, ((Component)__instance).transform.position);
				}
			}
			bool flag = IsButtonPressed("upArrow");
			bool flag2 = IsButtonPressed("downArrow");
			bool flag3 = IsButtonPressed("leftArrow");
			bool flag4 = IsButtonPressed("rightArrow");
			bool flag5 = flag || flag2 || flag4 || flag3;
			if (flag5 || lastFrameHadMovement)
			{
				CartSelfMovementManager cartToOrder = PhysGrabCartPatch.GetCartToOrder(((Component)__instance).transform.position);
				if ((Object)(object)cartToOrder != (Object)null)
				{
					if ((Object)(object)cartToOrder != (Object)(object)closestCart && (Object)(object)closestCart != (Object)null)
					{
						closestCart.cartTargetSync.MoveCart(moveForward: false, moveBack: false, turnRight: false, turnLeft: false);
					}
					closestCart = cartToOrder;
					closestCart.cartTargetSync.MoveCart(flag, flag2, flag4, flag3);
					if (!flag5)
					{
						lastFrameHadMovement = false;
					}
					else
					{
						lastFrameHadMovement = true;
					}
				}
				else
				{
					closestCart = null;
				}
			}
			else
			{
				closestCart = null;
			}
		}

		private static bool WasButtonPressedThisFrame(string btn)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			InputControl val = ((!mouseBtns.Contains(btn)) ? ((InputControl)Keyboard.current)[btn] : ((InputControl)Mouse.current)[btn]);
			return ((ButtonControl)val).wasPressedThisFrame;
		}

		private static bool IsButtonPressed(string btn)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			InputControl val = ((!mouseBtns.Contains(btn)) ? ((InputControl)Keyboard.current)[btn] : ((InputControl)Mouse.current)[btn]);
			return ((ButtonControl)val).isPressed;
		}
	}
	[HarmonyPatch(typeof(RoundDirector))]
	internal class RoundDirectorPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void StartPatch()
		{
			PhysGrabCartPatch.carts.Clear();
			ExtractionPointPatch.extractionPoints.Clear();
			ExtractionPointPatch.extractionStates.Clear();
			ValuableObjectPatch.ResetLists();
			CartVocalPatch.carts.Clear();
		}
	}
	[HarmonyPatch(typeof(TruckHealer))]
	internal class TruckHealerPatch
	{
		public static Vector3 truckPosition;

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void StartPatch(TruckHealer __instance)
		{
			//IL_0006: 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)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			truckPosition = new Vector3(((Component)__instance).transform.position.x, 0f, ((Component)__instance).transform.position.z);
		}
	}
	public static class ReflectionHelper
	{
		public static object InvokePrivateMethod(object instance, string methodName, params object[] parameters)
		{
			if (instance == null)
			{
				throw new ArgumentNullException("instance");
			}
			Type type = instance.GetType();
			MethodInfo methodInfo = AccessTools.Method(type, methodName, (Type[])null, (Type[])null);
			if (methodInfo == null)
			{
				throw new MissingMethodException("Method '" + methodName + "' not found on type '" + type.FullName + "'");
			}
			return methodInfo.Invoke(instance, parameters);
		}

		public static T GetPrivateField<T>(object instance, string fieldName)
		{
			if (instance == null)
			{
				throw new ArgumentNullException("instance");
			}
			Type type = instance.GetType();
			FieldInfo fieldInfo = AccessTools.Field(type, fieldName);
			if (fieldInfo == null)
			{
				throw new MissingFieldException("Field '" + fieldName + "' not found on type '" + type.FullName + "'");
			}
			return (T)fieldInfo.GetValue(instance);
		}
	}
	[HarmonyPatch(typeof(ValuableObject))]
	internal class ValuableObjectPatch
	{
		public static List<ValuableObject> levelValuables = new List<ValuableObject>();

		public static List<float> valuableLastValue = new List<float>();

		public static List<bool> isValidForRoast = new List<bool>();

		public static List<Coroutine> roastValidityCoroutines = new List<Coroutine>();

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void ValuableStartPatch(ValuableObject __instance)
		{
			levelValuables.Add(__instance);
			isValidForRoast.Add(item: false);
			roastValidityCoroutines.Add(null);
			valuableLastValue.Add(100f);
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void UpdatePatch(ValuableObject __instance)
		{
			//IL_0059: 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)
			int index = levelValuables.IndexOf(__instance);
			float privateField = ReflectionHelper.GetPrivateField<float>(__instance, "dollarValueCurrent");
			if (privateField < valuableLastValue[index])
			{
				CartTalkingManager cartTalkingManager = CartVocalPatch.carts[0];
				float num = float.PositiveInfinity;
				foreach (CartTalkingManager cart in CartVocalPatch.carts)
				{
					float num2 = Vector3.Distance(((Component)cart).transform.position, ((Component)__instance).transform.position);
					if (num2 < num)
					{
						cartTalkingManager = cart;
						num = num2;
					}
				}
				if (num <= 12f && isValidForRoast[index])
				{
					cartTalkingManager.cartRoastSync.AttemptRoast();
				}
			}
			if (privateField != valuableLastValue[index])
			{
				valuableLastValue[index] = privateField;
			}
		}

		public static void ResetLists()
		{
			levelValuables.Clear();
			isValidForRoast.Clear();
			roastValidityCoroutines.Clear();
			valuableLastValue.Clear();
		}
	}
}