BepInEx/plugins/RepoGeral/RepoGeral.dll

Decompiled 2 hours ago
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using Photon.Voice.Unity;
using Steamworks;
using Steamworks.Data;
using TMPro;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.InputSystem.Utilities;
using UnityEngine.Localization;
using UnityEngine.Localization.Settings;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("R.O.P.E")]
[assembly: AssemblyDescription("Recursos pessoais e administracao de sala para R.E.P.O.")]
[assembly: AssemblyFileVersion("0.6.9.0")]
[assembly: AssemblyVersion("0.6.9.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 RepoGeral
{
	public static class CameraMode
	{
		public enum View
		{
			PrimeiraPessoa,
			TerceiraPessoaAtras,
			TerceiraPessoaFrente
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static CameraCallback <0>__BeginCamera;

			public static CameraCallback <1>__EndCamera;

			public static Action<ScriptableRenderContext, Camera> <2>__BeginScriptableCamera;

			public static Action<ScriptableRenderContext, Camera> <3>__EndScriptableCamera;
		}

		private static ConfigEntry<View> view;

		private static ConfigEntry<Key> key;

		private static ConfigEntry<float> distance;

		private static ManualLogSource log;

		private static Camera changedCamera;

		private static Vector3 originalPosition;

		private static Quaternion originalRotation;

		private static int originalMask;

		private static bool initialized;

		private static bool nearWall;

		private static PlayerAvatarVisuals shownVisuals;

		private static float lastError;

		private static Camera renderedCamera;

		private static Matrix4x4 renderedView;

		private static Matrix4x4 renderedProjection;

		private static Vector3 renderedPosition;

		private static Rect renderedViewport;

		private static int renderedFrame = -2;

		private static int renderedWidth;

		private static int renderedHeight;

		private static int renderedScene;

		private static View renderedMode;

		private static RenderTextureMain outputOwner;

		private static RawImage outputImage;

		private static Canvas outputCanvas;

		private static readonly Vector3[] outputCorners = (Vector3[])(object)new Vector3[4];

		private static Vector2 outputOrigin;

		private static Vector2 outputRight;

		private static Vector2 outputUp;

		private static Rect outputUV;

		private static bool hasOutputQuad;

		public static Func<bool> InputBlocked { get; set; }

		public static View Current
		{
			get
			{
				if (view == null)
				{
					return View.PrimeiraPessoa;
				}
				return view.Value;
			}
		}

		public static string CurrentName
		{
			get
			{
				if (Current != View.TerceiraPessoaAtras)
				{
					if (Current != View.TerceiraPessoaFrente)
					{
						return "Primeira pessoa";
					}
					return "Terceira pessoa — de frente";
				}
				return "Terceira pessoa — atrás";
			}
		}

		public static void Initialize(ConfigFile config, ManualLogSource logger)
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Expected O, but got Unknown
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Expected O, but got Unknown
			//IL_0092: 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_009d: Expected O, but got Unknown
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Expected O, but got Unknown
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Expected O, but got Unknown
			if (!initialized)
			{
				log = logger;
				view = config.Bind<View>("Camera", "Visao", View.PrimeiraPessoa, "Alterna primeira pessoa, terceira pessoa por tras e de frente. So muda a sua camera.");
				key = config.Bind<Key>("Camera", "TeclaAlternar", (Key)98, "Alterna os tres modos de camera.");
				distance = config.Bind<float>("Camera", "Distancia", 3f, new ConfigDescription("Distancia da camera em terceira pessoa; diminui perto de paredes.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 6f), Array.Empty<object>()));
				CameraCallback onPreCull = Camera.onPreCull;
				object obj = <>O.<0>__BeginCamera;
				if (obj == null)
				{
					CameraCallback val = BeginCamera;
					<>O.<0>__BeginCamera = val;
					obj = (object)val;
				}
				Camera.onPreCull = (CameraCallback)Delegate.Combine((Delegate?)(object)onPreCull, (Delegate?)obj);
				CameraCallback onPostRender = Camera.onPostRender;
				object obj2 = <>O.<1>__EndCamera;
				if (obj2 == null)
				{
					CameraCallback val2 = EndCamera;
					<>O.<1>__EndCamera = val2;
					obj2 = (object)val2;
				}
				Camera.onPostRender = (CameraCallback)Delegate.Combine((Delegate?)(object)onPostRender, (Delegate?)obj2);
				RenderPipelineManager.beginCameraRendering += BeginScriptableCamera;
				RenderPipelineManager.endCameraRendering += EndScriptableCamera;
				initialized = true;
			}
		}

		public static void Tick()
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			RestoreCamera();
			if (Application.isFocused && !PlayerState.ChatOpen() && (InputBlocked == null || !InputBlocked()) && (!Object.op_Implicit((Object)(object)InputManager.instance) || (!InputManager.instance.textInputsActivePrevFrame && !InputManager.instance.externalTextInputActivePrevFrame)) && Keyboard.current != null && (int)key.Value != 0 && ((ButtonControl)Keyboard.current[key.Value]).wasPressedThisFrame)
			{
				Cycle();
			}
			PlayerAvatar instance = PlayerAvatar.instance;
			if (CanUse(instance) && Current != View.PrimeiraPessoa && !nearWall && Object.op_Implicit((Object)(object)instance.playerAvatarVisuals))
			{
				shownVisuals = instance.playerAvatarVisuals;
				shownVisuals.ShowSelfOverride(0.15f);
			}
			else if (Object.op_Implicit((Object)(object)shownVisuals))
			{
				shownVisuals.ShowSelfOverride(0f);
				shownVisuals = null;
			}
		}

		public static void DrawPanel()
		{
			//IL_0005: 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)
			HudTheme.Hint(((object)key.Value/*cast due to .constrained prefix*/).ToString() + " alterna · " + CurrentName);
			HudTheme.BeginCard();
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			HudTheme.Button("Primeira pessoa", delegate
			{
				Set(View.PrimeiraPessoa);
			}, enabled: true, Current == View.PrimeiraPessoa);
			HudTheme.Button("Atrás", delegate
			{
				Set(View.TerceiraPessoaAtras);
			}, enabled: true, Current == View.TerceiraPessoaAtras);
			HudTheme.Button("De frente", delegate
			{
				Set(View.TerceiraPessoaFrente);
			}, enabled: true, Current == View.TerceiraPessoaFrente);
			GUILayout.EndHorizontal();
			HudTheme.Hint("A câmera se aproxima das paredes. Estes ajustes aparecem só para você.");
			HudTheme.EndCard();
			if (HudTheme.Foldout("camera.distancia", "Distância em terceira pessoa"))
			{
				HudTheme.Hint(distance.Value.ToString("0.0") + " m · a câmera se aproxima ao encontrar paredes.");
				float num = GUILayout.HorizontalSlider(distance.Value, 1f, 6f, Array.Empty<GUILayoutOption>());
				if (Math.Abs(num - distance.Value) > 0.01f)
				{
					distance.Value = num;
				}
				HudTheme.Hint("A mira continua apontando na direção do personagem.");
			}
		}

		public static void Cycle()
		{
			Set((View)((int)(Current + 1) % 3));
		}

		public static void Set(View next)
		{
			if (!Enum.IsDefined(typeof(View), next))
			{
				next = View.PrimeiraPessoa;
			}
			RestoreCamera();
			view.Value = next;
			nearWall = false;
			renderedFrame = -2;
		}

		private static bool CanUse(PlayerAvatar avatar)
		{
			if (Object.op_Implicit((Object)(object)avatar) && ((Behaviour)avatar).isActiveAndEnabled && !RuntimeSupport.Get<bool>(avatar, "isDisabled") && !RuntimeSupport.Get<bool>(avatar, "deadSet") && !RuntimeSupport.Get<bool>(avatar, "spectating") && Object.op_Implicit((Object)(object)PlayerController.instance))
			{
				return !SemiFunc.MenuLevel();
			}
			return false;
		}

		private static void BeginScriptableCamera(ScriptableRenderContext context, Camera camera)
		{
			BeginCamera(camera);
		}

		private static void EndScriptableCamera(ScriptableRenderContext context, Camera camera)
		{
			EndCamera(camera);
		}

		private static void BeginCamera(Camera camera)
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: 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_00a4: 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_00b3: 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_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: 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_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: 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_01a9: Unknown result type (might be due to invalid IL or missing references)
			Camera val = (Object.op_Implicit((Object)(object)GameDirector.instance) ? GameDirector.instance.MainCamera : Camera.main);
			if (!initialized || !Object.op_Implicit((Object)(object)camera) || (Object)(object)camera != (Object)(object)val || Object.op_Implicit((Object)(object)changedCamera))
			{
				return;
			}
			PlayerAvatar instance = PlayerAvatar.instance;
			if (Current == View.PrimeiraPessoa || !CanUse(instance))
			{
				CaptureProjection(camera);
				return;
			}
			try
			{
				originalPosition = ((Component)camera).transform.position;
				originalRotation = ((Component)camera).transform.rotation;
				originalMask = camera.cullingMask;
				Vector3 val2 = ((Current == View.TerceiraPessoaAtras) ? (-(originalRotation * Vector3.forward)) : (originalRotation * Vector3.forward));
				Vector3 val3 = originalPosition;
				float num = Mathf.Clamp(distance.Value, 1f, 6f);
				float num2 = num;
				RaycastHit[] array = Physics.SphereCastAll(val3, 0.18f, val2, num, -5, (QueryTriggerInteraction)1);
				for (int i = 0; i < array.Length; i++)
				{
					RaycastHit val4 = array[i];
					if (Object.op_Implicit((Object)(object)((RaycastHit)(ref val4)).collider) && !((Object)(object)((Component)((RaycastHit)(ref val4)).collider).GetComponentInParent<PlayerAvatar>() == (Object)(object)instance) && !((Component)((RaycastHit)(ref val4)).collider).transform.IsChildOf(((Component)PlayerController.instance).transform))
					{
						num2 = Mathf.Min(num2, Mathf.Max(0.05f, ((RaycastHit)(ref val4)).distance - 0.05f));
					}
				}
				nearWall = num2 < 0.65f;
				changedCamera = camera;
				((Component)camera).transform.position = val3 + val2 * num2;
				((Component)camera).transform.rotation = ((Current == View.TerceiraPessoaFrente) ? Quaternion.LookRotation(val3 - ((Component)camera).transform.position, Vector3.up) : originalRotation);
				int num3 = LayerMask.NameToLayer("PlayerVisualsLocal");
				if (num3 >= 0)
				{
					camera.cullingMask |= 1 << num3;
				}
				CaptureProjection(camera);
			}
			catch (Exception ex)
			{
				RestoreCamera();
				if (log != null && Time.unscaledTime - lastError > 5f)
				{
					lastError = Time.unscaledTime;
					log.LogWarning((object)("Câmera: " + ex.Message));
				}
			}
		}

		private static void EndCamera(Camera camera)
		{
			if ((Object)(object)camera == (Object)(object)changedCamera)
			{
				RestoreCamera();
			}
		}

		private static void CaptureProjection(Camera camera)
		{
			//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_0017: 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_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			renderedCamera = camera;
			renderedView = camera.worldToCameraMatrix;
			renderedProjection = camera.projectionMatrix;
			renderedPosition = ((Component)camera).transform.position;
			renderedViewport = camera.rect;
			renderedFrame = Time.frameCount;
			renderedWidth = Screen.width;
			renderedHeight = Screen.height;
			Scene scene = ((Component)camera).gameObject.scene;
			renderedScene = SceneHandle.op_Implicit(((Scene)(ref scene)).handle);
			renderedMode = Current;
			CaptureOutput(camera);
		}

		private static void CaptureOutput(Camera camera)
		{
			//IL_00b5: 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_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_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			hasOutputQuad = false;
			RenderTextureMain instance = RenderTextureMain.instance;
			if ((Object)(object)instance != (Object)(object)outputOwner)
			{
				outputOwner = instance;
				outputImage = (Object.op_Implicit((Object)(object)instance) ? ((Component)instance).GetComponent<RawImage>() : null);
				outputCanvas = (Object.op_Implicit((Object)(object)outputImage) ? ((Component)outputImage).GetComponentInParent<Canvas>() : null);
			}
			if (Object.op_Implicit((Object)(object)camera.targetTexture) && Object.op_Implicit((Object)(object)outputImage) && ((Behaviour)outputImage).isActiveAndEnabled && !((Object)(object)outputImage.texture != (Object)(object)camera.targetTexture) && Object.op_Implicit((Object)(object)outputCanvas))
			{
				((Graphic)outputImage).rectTransform.GetWorldCorners(outputCorners);
				Camera obj = (((int)outputCanvas.renderMode == 0) ? null : outputCanvas.worldCamera);
				outputOrigin = RectTransformUtility.WorldToScreenPoint(obj, outputCorners[0]);
				outputRight = RectTransformUtility.WorldToScreenPoint(obj, outputCorners[3]) - outputOrigin;
				outputUp = RectTransformUtility.WorldToScreenPoint(obj, outputCorners[1]) - outputOrigin;
				outputUV = outputImage.uvRect;
				hasOutputQuad = Mathf.Abs(((Rect)(ref outputUV)).width) > 0.0001f && Mathf.Abs(((Rect)(ref outputUV)).height) > 0.0001f;
			}
		}

		private static bool HasProjection(Camera camera)
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: 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)
			int num = Time.frameCount - renderedFrame;
			if (Object.op_Implicit((Object)(object)camera) && (Object)(object)camera == (Object)(object)renderedCamera && num >= 0 && num <= 1 && renderedMode == Current && renderedWidth == Screen.width && renderedHeight == Screen.height)
			{
				SceneHandle val = SceneHandle.op_Implicit(renderedScene);
				Scene scene = ((Component)camera).gameObject.scene;
				return val == ((Scene)(ref scene)).handle;
			}
			return false;
		}

		public static Vector3 RenderedPosition(Camera camera)
		{
			//IL_0022: 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_0010: Unknown result type (might be due to invalid IL or missing references)
			if (!HasProjection(camera))
			{
				if (!Object.op_Implicit((Object)(object)camera))
				{
					return Vector3.zero;
				}
				return ((Component)camera).transform.position;
			}
			return renderedPosition;
		}

		public static bool TryProjectWorld(Camera camera, Vector3 world, out Vector3 screen)
		{
			//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_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_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: 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_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: 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_0099: 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_00b4: 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_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: 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_012e: 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_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_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: 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_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: 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_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: 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_01cc: Unknown result type (might be due to invalid IL or missing references)
			screen = Vector3.zero;
			if (!Object.op_Implicit((Object)(object)camera))
			{
				return false;
			}
			bool flag = HasProjection(camera);
			Vector3 val3 = default(Vector3);
			if (flag)
			{
				Vector4 val = renderedView * new Vector4(world.x, world.y, world.z, 1f);
				Vector4 val2 = renderedProjection * val;
				if (0f - val.z <= 0f || Mathf.Abs(val2.w) < 1E-05f)
				{
					return false;
				}
				((Vector3)(ref val3))..ctor(val2.x / val2.w * 0.5f + 0.5f, val2.y / val2.w * 0.5f + 0.5f, 0f - val.z);
			}
			else
			{
				if (Current != View.PrimeiraPessoa && CanUse(PlayerAvatar.instance))
				{
					return false;
				}
				val3 = camera.WorldToViewportPoint(world);
			}
			if (val3.z <= 0f || float.IsNaN(val3.x) || float.IsNaN(val3.y) || float.IsInfinity(val3.x) || float.IsInfinity(val3.y))
			{
				return false;
			}
			Rect val4 = (flag ? renderedViewport : camera.rect);
			Vector2 val5 = default(Vector2);
			((Vector2)(ref val5))..ctor(((Rect)(ref val4)).x + val3.x * ((Rect)(ref val4)).width, ((Rect)(ref val4)).y + val3.y * ((Rect)(ref val4)).height);
			Vector2 val6 = default(Vector2);
			if (flag && hasOutputQuad)
			{
				val6 = outputOrigin + outputRight * ((val5.x - ((Rect)(ref outputUV)).x) / ((Rect)(ref outputUV)).width) + outputUp * ((val5.y - ((Rect)(ref outputUV)).y) / ((Rect)(ref outputUV)).height);
			}
			else
			{
				((Vector2)(ref val6))..ctor(val5.x * (float)Screen.width, val5.y * (float)Screen.height);
			}
			screen = new Vector3(val6.x, val6.y, val3.z);
			return true;
		}

		private static void RestoreCamera()
		{
			//IL_0016: 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)
			if (Object.op_Implicit((Object)(object)changedCamera))
			{
				((Component)changedCamera).transform.position = originalPosition;
				((Component)changedCamera).transform.rotation = originalRotation;
				changedCamera.cullingMask = originalMask;
			}
			changedCamera = null;
		}

		public static void Shutdown()
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Expected O, but got Unknown
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Expected O, but got Unknown
			RestoreCamera();
			if (Object.op_Implicit((Object)(object)shownVisuals))
			{
				shownVisuals.ShowSelfOverride(0f);
			}
			shownVisuals = null;
			CameraCallback onPreCull = Camera.onPreCull;
			object obj = <>O.<0>__BeginCamera;
			if (obj == null)
			{
				CameraCallback val = BeginCamera;
				<>O.<0>__BeginCamera = val;
				obj = (object)val;
			}
			Camera.onPreCull = (CameraCallback)Delegate.Remove((Delegate?)(object)onPreCull, (Delegate?)obj);
			CameraCallback onPostRender = Camera.onPostRender;
			object obj2 = <>O.<1>__EndCamera;
			if (obj2 == null)
			{
				CameraCallback val2 = EndCamera;
				<>O.<1>__EndCamera = val2;
				obj2 = (object)val2;
			}
			Camera.onPostRender = (CameraCallback)Delegate.Remove((Delegate?)(object)onPostRender, (Delegate?)obj2);
			RenderPipelineManager.beginCameraRendering -= BeginScriptableCamera;
			RenderPipelineManager.endCameraRendering -= EndScriptableCamera;
			initialized = false;
			renderedCamera = null;
			renderedFrame = -2;
			outputOwner = null;
			outputImage = null;
			outputCanvas = null;
		}
	}
	internal static class CartTools
	{
		public enum Destination
		{
			Stopped,
			Host,
			Extraction,
			Truck
		}

		private sealed class Motor
		{
			public PhysGrabCart Cart;

			public PhysGrabObject Object;

			public Rigidbody Body;

			public Destination Goal;

			public ExtractionPoint Extraction;

			public Vector3[] Corners = (Vector3[])(object)new Vector3[0];

			public int Corner;

			public float Repath;

			public float ProgressAt;

			public Vector3 ProgressPosition;

			public bool HasMode;

			public State OldMode;

			public float NextCargoScan;

			public readonly List<PhysGrabObject> Cargo = new List<PhysGrabObject>();
		}

		private static readonly Dictionary<int, Motor> motors = new Dictionary<int, Motor>();

		private static readonly List<Motor> motorBuffer = new List<Motor>();

		private static readonly List<int> removedMotors = new List<int>();

		private static readonly List<PhysGrabObject> queriedCargo = new List<PhysGrabObject>();

		private static readonly HashSet<PhysGrabObject> distinctCargo = new HashSet<PhysGrabObject>();

		private static Collider[] cargoHits = (Collider[])(object)new Collider[64];

		private const int MaximumReusableCargoHits = 1024;

		private static PhysGrabCart[] carts = (PhysGrabCart[])(object)new PhysGrabCart[0];

		private static PhysGrabCart selected;

		private static PhysGrabCart riding;

		private static ConfigEntry<float> speed;

		private static ConfigEntry<bool> shortcuts;

		private static ConfigEntry<bool> protectCargo;

		private static ConfigEntry<Key> hostKey;

		private static ConfigEntry<Key> extractionKey;

		private static ConfigEntry<Key> truckKey;

		private static ConfigEntry<Key> openKey;

		private static ConfigEntry<Key> nextKey;

		private static Harmony harmony;

		private static int scene;

		private static object room;

		private static bool wasHost;

		private static float nextScan;

		private static int loadCartId;

		private static int nextLoadSlot;

		private static float lastLoadAt;

		private static string status = "Selecione um carrinho.";

		public static Func<bool> InputBlocked { get; set; }

		public static string Status => status;

		public static bool ConsumingShortcut
		{
			get
			{
				if (shortcuts != null && shortcuts.Value && Ready && !Blocked && Keyboard.current != null)
				{
					if (!Pressed(hostKey) && !Pressed(extractionKey) && !Pressed(truckKey) && !Pressed(openKey))
					{
						return Pressed(nextKey);
					}
					return true;
				}
				return false;
			}
		}

		private static bool Ready
		{
			get
			{
				//IL_004f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0055: Invalid comparison between Unknown and I4
				if (RuntimeSupport.IsHost && Object.op_Implicit((Object)(object)RuntimeSupport.LocalPlayer) && !PlayerState.IsDead(RuntimeSupport.LocalPlayer) && !SemiFunc.MenuLevel() && Object.op_Implicit((Object)(object)LevelGenerator.Instance) && LevelGenerator.Instance.Generated && Object.op_Implicit((Object)(object)GameDirector.instance))
				{
					return (int)GameDirector.instance.currentState == 2;
				}
				return false;
			}
		}

		private static bool Blocked
		{
			get
			{
				if ((InputBlocked == null || !InputBlocked()) && !PlayerState.ChatOpen() && Object.op_Implicit((Object)(object)InputManager.instance) && !InputManager.instance.textInputsActivePrevFrame)
				{
					return InputManager.instance.externalTextInputActivePrevFrame;
				}
				return true;
			}
		}

		public static void Initialize(ConfigFile config, ManualLogSource logger)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			//IL_00fa: 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_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Expected O, but got Unknown
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Expected O, but got Unknown
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Expected O, but got Unknown
			speed = config.Bind<float>("Carrinhos", "Velocidade", 3.5f, new ConfigDescription("Velocidade do piloto automático em m/s.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 10f), Array.Empty<object>()));
			shortcuts = config.Bind<bool>("Carrinhos", "AtalhosAtivos", false, "J até você, K extração, L caminhão, U abrir extração, I próximo carrinho. Disponíveis enquanto o painel está fechado.");
			protectCargo = config.Bind<bool>("Carrinhos", "ProtegerCarga", true, "Protege a carga enquanto o carrinho automático está se movendo.");
			hostKey = config.Bind<Key>("Carrinhos", "AteVoce", (Key)24, "Trazer carrinho.");
			extractionKey = config.Bind<Key>("Carrinhos", "AteExtracao", (Key)25, "Enviar carrinho à extração.");
			truckKey = config.Bind<Key>("Carrinhos", "AteCaminhao", (Key)26, "Enviar carrinho ao caminhão.");
			openKey = config.Bind<Key>("Carrinhos", "AbrirExtracao", (Key)35, "Abrir a extração mais próxima, sem concluir a meta automaticamente.");
			nextKey = config.Bind<Key>("Carrinhos", "Proximo", (Key)23, "Selecionar próximo carrinho.");
			Scene activeScene = SceneManager.GetActiveScene();
			scene = SceneHandle.op_Implicit(((Scene)(ref activeScene)).handle);
			room = PhotonNetwork.CurrentRoom;
			wasHost = RuntimeSupport.IsHost;
			harmony = new Harmony("br.impga.repogeral.carrinhos");
			harmony.Patch((MethodBase)AccessTools.Method(typeof(PhysGrabCart), "FixedUpdate", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(CartTools), "AfterCartPhysics", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			harmony.Patch((MethodBase)AccessTools.Method(typeof(PhysGrabCart), "StateLogic", (Type[])null, (Type[])null), new HarmonyMethod(typeof(CartTools), "BeforeCartState", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}

		public static void Tick()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0402: Unknown result type (might be due to invalid IL or missing references)
			//IL_0407: Unknown result type (might be due to invalid IL or missing references)
			//IL_040c: Unknown result type (might be due to invalid IL or missing references)
			//IL_042c: Unknown result type (might be due to invalid IL or missing references)
			//IL_043a: 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_044f: 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_047f: Unknown result type (might be due to invalid IL or missing references)
			Scene activeScene = SceneManager.GetActiveScene();
			int num = SceneHandle.op_Implicit(((Scene)(ref activeScene)).handle);
			bool isHost = RuntimeSupport.IsHost;
			bool flag = num != scene || room != PhotonNetwork.CurrentRoom || wasHost != isHost;
			if (flag || !Ready)
			{
				if (motors.Count > 0 || Object.op_Implicit((Object)(object)riding))
				{
					StopAll(!flag);
				}
				motorBuffer.Clear();
				queriedCargo.Clear();
				distinctCargo.Clear();
				selected = null;
				carts = Array.Empty<PhysGrabCart>();
				scene = num;
				room = PhotonNetwork.CurrentRoom;
				wasHost = isHost;
				nextScan = 0f;
				return;
			}
			if (Time.unscaledTime >= nextScan)
			{
				nextScan = Time.unscaledTime + 1f;
				carts = (from c in SceneObjectIndex.Population<PhysGrabCart>().Where(Usable)
					orderby ((Object)c).GetInstanceID()
					select c).ToArray();
				removedMotors.Clear();
				foreach (KeyValuePair<int, Motor> motor in motors)
				{
					if (!Usable(motor.Value.Cart))
					{
						removedMotors.Add(motor.Key);
					}
				}
				foreach (int removedMotor in removedMotors)
				{
					Stop(removedMotor);
				}
				removedMotors.Clear();
				if (!Usable(selected))
				{
					selected = carts.FirstOrDefault();
				}
			}
			motorBuffer.Clear();
			foreach (Motor value2 in motors.Values)
			{
				motorBuffer.Add(value2);
			}
			foreach (Motor item in motorBuffer)
			{
				if (!Usable(item.Cart))
				{
					continue;
				}
				if (item.Object.playerGrabbing.Count > 0)
				{
					Stop(((Object)item.Cart).GetInstanceID());
					status = "Piloto parado: alguém segurou o carrinho.";
					continue;
				}
				if (Time.unscaledTime >= item.Repath)
				{
					Plan(item);
				}
				if (!motors.TryGetValue(((Object)item.Cart).GetInstanceID(), out var value) || value != item)
				{
					continue;
				}
				if (protectCargo.Value)
				{
					if (Time.unscaledTime >= item.NextCargoScan)
					{
						item.NextCargoScan = Time.unscaledTime + 0.1f;
						QueryContents(item.Cart, item.Cargo);
					}
					foreach (PhysGrabObject item2 in item.Cargo)
					{
						if (Object.op_Implicit((Object)(object)item2) && !item2.dead)
						{
							ValuableObject component = ((Component)item2).GetComponent<ValuableObject>();
							if (!Object.op_Implicit((Object)(object)component) || !RuntimeSupport.Get<bool>(component, "committedToExtraction"))
							{
								item2.OverrideIndestructible(0.3f);
							}
						}
					}
				}
				else
				{
					item.Cargo.Clear();
					item.NextCargoScan = 0f;
				}
				item.Object.NetworkTrackerOverride(0.4f);
			}
			motorBuffer.Clear();
			if (Object.op_Implicit((Object)(object)riding))
			{
				PlayerController instance = PlayerController.instance;
				Rigidbody component2 = ((Component)riding).GetComponent<Rigidbody>();
				Vector3 val = ((Component)RuntimeSupport.LocalPlayer).transform.position - ((Component)riding).transform.position;
				if (Object.op_Implicit((Object)(object)instance) && Object.op_Implicit((Object)(object)component2) && !PlayerState.IsDead(RuntimeSupport.LocalPlayer) && !(val.y < -0.5f) && !(val.y > 3.5f))
				{
					Vector2 val2 = new Vector2(val.x, val.z);
					if (!(((Vector2)(ref val2)).magnitude > 1.5f) && !SemiFunc.InputDown((InputKey)1))
					{
						instance.OverridePlatformVelocity(component2.linearVelocity);
						goto IL_0489;
					}
				}
				riding = null;
			}
			goto IL_0489;
			IL_0489:
			if (shortcuts.Value && !Blocked && Keyboard.current != null)
			{
				if (Pressed(nextKey))
				{
					SelectNext();
				}
				if (Pressed(hostKey))
				{
					SendSelected(Destination.Host);
				}
				if (Pressed(extractionKey))
				{
					SendSelected(Destination.Extraction);
				}
				if (Pressed(truckKey))
				{
					SendSelected(Destination.Truck);
				}
				if (Pressed(openKey))
				{
					RuntimeSupport.Safe(OpenExtraction);
				}
			}
		}

		private static bool Pressed(ConfigEntry<Key> key)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			if ((int)key.Value != 0)
			{
				return ((ButtonControl)Keyboard.current[key.Value]).wasPressedThisFrame;
			}
			return false;
		}

		private static bool Usable(PhysGrabCart cart)
		{
			if (!Object.op_Implicit((Object)(object)cart) || !((Component)cart).gameObject.activeInHierarchy)
			{
				return false;
			}
			PhysGrabObject component = ((Component)cart).GetComponent<PhysGrabObject>();
			if (Object.op_Implicit((Object)(object)component) && !component.dead && Object.op_Implicit((Object)(object)component.rb))
			{
				return !component.rb.isKinematic;
			}
			return false;
		}

		public static bool Select(PhysGrabCart cart)
		{
			if (!Ready || !Usable(cart))
			{
				return false;
			}
			InvalidateCargo(selected);
			InvalidateCargo(cart);
			selected = cart;
			status = (cart.isSmallCart ? "Carrinho de bolso selecionado." : "Carrinho selecionado.");
			return true;
		}

		public static void SelectNext()
		{
			if (carts.Length == 0)
			{
				status = "Nenhum carrinho físico disponível.";
				return;
			}
			int num = Array.IndexOf(carts, selected);
			Select(carts[(num + 1) % carts.Length]);
		}

		public static void SendSelected(Destination destination)
		{
			//IL_00a7: 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_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			RuntimeSupport.RequireHost();
			if (!Ready || !Usable(selected))
			{
				status = "Solte um carrinho no chão antes de usar o piloto.";
				return;
			}
			int instanceID = ((Object)selected).GetInstanceID();
			Stop(instanceID);
			if (destination == Destination.Stopped)
			{
				status = "Carrinho parado.";
				return;
			}
			if (((Component)selected).GetComponent<PhysGrabObject>().playerGrabbing.Count > 0)
			{
				status = "Solte o carrinho primeiro.";
				return;
			}
			Motor motor = new Motor
			{
				Cart = selected,
				Object = ((Component)selected).GetComponent<PhysGrabObject>(),
				Body = ((Component)selected).GetComponent<Rigidbody>(),
				Goal = destination,
				OldMode = RuntimeSupport.Get<State>(selected, "currentState"),
				ProgressPosition = ((Component)selected).transform.position,
				ProgressAt = Time.unscaledTime
			};
			if (destination == Destination.Extraction)
			{
				motor.Extraction = NearestExtraction(((Component)selected).transform.position);
			}
			if (!DestinationPosition(motor, out var _))
			{
				status = "Destino indisponível nesta fase.";
				return;
			}
			motors.Add(instanceID, motor);
			try
			{
				RuntimeSupport.Invoke(selected, "StateSwitch", (object)(State)2);
				motor.HasMode = true;
				Plan(motor);
			}
			catch
			{
				Stop(instanceID);
				throw;
			}
		}

		private static ExtractionPoint NearestExtraction(Vector3 position)
		{
			//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)
			return (from p in SceneObjectIndex.Population<ExtractionPoint>()
				where Object.op_Implicit((Object)(object)p) && ((Component)p).gameObject.activeInHierarchy && ((int)RuntimeSupport.Get<State>(p, "currentState") == 1 || (int)RuntimeSupport.Get<State>(p, "currentState") == 2)
				select p).OrderBy(delegate(ExtractionPoint p)
			{
				//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_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)
				Vector3 val = ((Component)p).transform.position - position;
				return ((Vector3)(ref val)).sqrMagnitude;
			}).FirstOrDefault();
		}

		private static bool DestinationPosition(Motor m, out Vector3 point)
		{
			//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_002b: 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_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: 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_0081: Invalid comparison between Unknown and I4
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Invalid comparison between Unknown and I4
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			point = Vector3.zero;
			if (m.Goal == Destination.Host && Object.op_Implicit((Object)(object)RuntimeSupport.LocalPlayer))
			{
				point = ((Component)RuntimeSupport.LocalPlayer).transform.position - ((Component)RuntimeSupport.LocalPlayer).transform.forward * 2.3f;
			}
			else if (m.Goal == Destination.Extraction && Object.op_Implicit((Object)(object)m.Extraction))
			{
				State val = RuntimeSupport.Get<State>(m.Extraction, "currentState");
				if ((int)val != 1 && (int)val != 2)
				{
					return false;
				}
				point = (Object.op_Implicit((Object)(object)m.Extraction.extractionArea) ? m.Extraction.extractionArea.transform.position : ((Component)m.Extraction).transform.position);
			}
			else
			{
				if (m.Goal != Destination.Truck || !Object.op_Implicit((Object)(object)LevelGenerator.Instance) || !Object.op_Implicit((Object)(object)LevelGenerator.Instance.LevelPathTruck))
				{
					return false;
				}
				point = ((Component)LevelGenerator.Instance.LevelPathTruck).transform.position;
			}
			return true;
		}

		private static void Plan(Motor m)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			//IL_0043: 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_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: 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_00df: 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_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: 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_007f: 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_013e: Unknown result type (might be due to invalid IL or missing references)
			m.Repath = Time.unscaledTime + 0.8f;
			if (!DestinationPosition(m, out var point))
			{
				Stop(((Object)m.Cart).GetInstanceID());
				status = "Destino removido; carrinho parado.";
				return;
			}
			NavMeshPath val = new NavMeshPath();
			NavMeshHit val2 = default(NavMeshHit);
			NavMeshHit val3 = default(NavMeshHit);
			if (NavMesh.SamplePosition(m.Body.position, ref val2, 3f, -1) && NavMesh.SamplePosition(point, ref val3, 3f, -1) && NavMesh.CalculatePath(((NavMeshHit)(ref val2)).position, ((NavMeshHit)(ref val3)).position, -1, val) && (int)val.status == 0)
			{
				m.Corners = val.corners;
				m.Corner = ((m.Corners.Length > 1) ? 1 : 0);
				status = "Carrinho seguindo a rota.";
				return;
			}
			Vector3 val4 = point - m.Body.position;
			if (Mathf.Abs(val4.y) < 1.2f && !Physics.RaycastAll(m.Body.position + Vector3.up * 0.6f, ((Vector3)(ref val4)).normalized, ((Vector3)(ref val4)).magnitude, -1, (QueryTriggerInteraction)1).Any((RaycastHit h) => Object.op_Implicit((Object)(object)((RaycastHit)(ref h)).collider) && !Object.op_Implicit((Object)(object)((Component)((RaycastHit)(ref h)).collider).GetComponentInParent<PhysGrabObject>()) && !Object.op_Implicit((Object)(object)((Component)((RaycastHit)(ref h)).collider).GetComponentInParent<PlayerAvatar>())))
			{
				m.Corners = (Vector3[])(object)new Vector3[1] { point };
				m.Corner = 0;
				status = "Carrinho seguindo trecho livre.";
			}
			else
			{
				Stop(((Object)m.Cart).GetInstanceID());
				status = "Sem rota livre até o destino. Aproxime o carrinho e tente novamente.";
			}
		}

		private static bool BeforeCartState(PhysGrabCart __instance)
		{
			if (Ready)
			{
				return !motors.ContainsKey(((Object)__instance).GetInstanceID());
			}
			return true;
		}

		private static void AfterCartPhysics(PhysGrabCart __instance)
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: 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_0072: 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_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: 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_0143: 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_00c1: 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_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: 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_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: 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_0207: Unknown result type (might be due to invalid IL or missing references)
			if (!Ready || !motors.TryGetValue(((Object)__instance).GetInstanceID(), out var value) || !Usable(__instance) || value.Corners.Length == 0 || value.Object.playerGrabbing.Count > 0)
			{
				return;
			}
			Vector3 val = value.Corners[Mathf.Min(value.Corner, value.Corners.Length - 1)] - value.Body.position;
			Vector3 val2 = Vector3.ProjectOnPlane(val, Vector3.up);
			if (((Vector3)(ref val2)).magnitude < 0.65f)
			{
				if (value.Corner < value.Corners.Length - 1)
				{
					value.Corner++;
					return;
				}
				value.Body.linearVelocity = new Vector3(0f, value.Body.linearVelocity.y, 0f);
				value.ProgressAt = Time.unscaledTime;
				value.ProgressPosition = value.Body.position;
				if (value.Goal != Destination.Host)
				{
					Stop(((Object)__instance).GetInstanceID());
					status = "Carrinho chegou ao destino.";
				}
				return;
			}
			Vector3 val3 = value.Body.position - value.ProgressPosition;
			if (((Vector3)(ref val3)).sqrMagnitude > 0.16f)
			{
				value.ProgressPosition = value.Body.position;
				value.ProgressAt = Time.unscaledTime;
			}
			if (Time.unscaledTime - value.ProgressAt > 8f)
			{
				Stop(((Object)__instance).GetInstanceID());
				status = "Carrinho bloqueado. Abra a porta ou retire o obstáculo.";
				return;
			}
			Vector3 val4 = Vector3.ClampMagnitude((((Vector3)(ref val2)).normalized * Mathf.Min(speed.Value, ((Vector3)(ref val2)).magnitude * 2f) - Vector3.ProjectOnPlane(value.Body.linearVelocity, Vector3.up)) * 6f, 30f);
			if (val.y > 0.15f && val.y < 1.2f)
			{
				val4.y = Mathf.Clamp(val.y * 25f - value.Body.linearVelocity.y * 5f, 0f, 18f);
			}
			value.Body.AddForce(val4, (ForceMode)5);
			Quaternion val5 = Quaternion.LookRotation(((Vector3)(ref val2)).normalized, Vector3.up);
			value.Body.MoveRotation(Quaternion.RotateTowards(value.Body.rotation, val5, 120f * Time.fixedDeltaTime));
			value.Object.OverrideIndestructible(0.25f);
			value.Object.OverrideDrag(0.2f, 0.25f);
		}

		private static void Stop(int id, bool restoreNative = true)
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			if (motors.TryGetValue(id, out var value))
			{
				motors.Remove(id);
				value.Cargo.Clear();
				if (restoreNative && Object.op_Implicit((Object)(object)value.Body) && RuntimeSupport.IsHost)
				{
					value.Body.linearVelocity = new Vector3(0f, value.Body.linearVelocity.y, 0f);
				}
				if (restoreNative && value.HasMode && Object.op_Implicit((Object)(object)value.Cart) && RuntimeSupport.IsHost)
				{
					RuntimeSupport.Invoke(value.Cart, "StateSwitch", value.OldMode);
				}
			}
		}

		public static void StopAll()
		{
			StopAll(restoreNative: true);
		}

		private static void StopAll(bool restoreNative)
		{
			int[] array = motors.Keys.ToArray();
			for (int i = 0; i < array.Length; i++)
			{
				Stop(array[i], restoreNative);
			}
			riding = null;
		}

		private static PhysGrabObject[] Contents(PhysGrabCart cart)
		{
			QueryContents(cart, queriedCargo);
			PhysGrabObject[] result = queriedCargo.ToArray();
			queriedCargo.Clear();
			return result;
		}

		private static void InvalidateCargo(PhysGrabCart cart)
		{
			if (Object.op_Implicit((Object)(object)cart) && motors.TryGetValue(((Object)cart).GetInstanceID(), out var value))
			{
				value.Cargo.Clear();
				value.NextCargoScan = 0f;
			}
		}

		private static void QueryContents(PhysGrabCart cart, List<PhysGrabObject> result)
		{
			//IL_0042: 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_004c: 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_0054: 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_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_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: 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_00b3: 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_00b6: Unknown result type (might be due to invalid IL or missing references)
			result.Clear();
			distinctCargo.Clear();
			Transform val = (Object.op_Implicit((Object)(object)cart) ? RuntimeSupport.Get<Transform>(cart, "inCart") : null);
			if (!Object.op_Implicit((Object)(object)val))
			{
				return;
			}
			BoxCollider component = ((Component)val).GetComponent<BoxCollider>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				return;
			}
			Vector3 val2 = val.TransformPoint(component.center);
			Vector3 val3 = Vector3.Scale(component.size, val.lossyScale) * 0.5f;
			int num;
			Collider[] array;
			while (true)
			{
				num = Physics.OverlapBoxNonAlloc(val2, val3, cargoHits, val.rotation, -1, (QueryTriggerInteraction)1);
				if (num < cargoHits.Length)
				{
					array = cargoHits;
					break;
				}
				Array.Clear(cargoHits, 0, cargoHits.Length);
				if (cargoHits.Length >= 1024)
				{
					array = Physics.OverlapBox(val2, val3, val.rotation, -1, (QueryTriggerInteraction)1);
					num = array.Length;
					break;
				}
				cargoHits = (Collider[])(object)new Collider[Math.Min(1024, cargoHits.Length * 2)];
			}
			try
			{
				for (int i = 0; i < num; i++)
				{
					Collider val4 = array[i];
					if (!Object.op_Implicit((Object)(object)val4))
					{
						continue;
					}
					PhysGrabObject componentInParent = ((Component)val4).GetComponentInParent<PhysGrabObject>();
					if (Object.op_Implicit((Object)(object)componentInParent) && !componentInParent.dead && distinctCargo.Add(componentInParent) && !((Object)(object)((Component)componentInParent).gameObject == (Object)(object)((Component)cart).gameObject) && !Object.op_Implicit((Object)(object)((Component)componentInParent).GetComponent<PhysGrabCart>()) && !Object.op_Implicit((Object)(object)((Component)componentInParent).GetComponentInParent<Enemy>()) && !Object.op_Implicit((Object)(object)((Component)componentInParent).GetComponent<PlayerTumble>()))
					{
						ValuableObject component2 = ((Component)componentInParent).GetComponent<ValuableObject>();
						if (!Object.op_Implicit((Object)(object)component2) || !RuntimeSupport.Get<bool>(component2, "committedToExtraction"))
						{
							result.Add(componentInParent);
						}
					}
				}
			}
			finally
			{
				distinctCargo.Clear();
				if (array == cargoHits)
				{
					Array.Clear(cargoHits, 0, num);
				}
			}
		}

		public static void LoadNearby()
		{
			//IL_00fa: 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_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			RuntimeSupport.RequireHost();
			if (!Ready || !Usable(selected))
			{
				return;
			}
			Transform val = RuntimeSupport.Get<Transform>(selected, "inCart");
			if (!Object.op_Implicit((Object)(object)val))
			{
				return;
			}
			HashSet<PhysGrabObject> inside = new HashSet<PhysGrabObject>(Contents(selected));
			PhysGrabObject[] array = (from v in SceneObjectIndex.Population<ValuableObject>()
				where Object.op_Implicit((Object)(object)v) && !RuntimeSupport.Get<bool>(v, "committedToExtraction")
				select ((Component)v).GetComponent<PhysGrabObject>()).Where(delegate(PhysGrabObject o)
			{
				//IL_004b: 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_005f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0064: Unknown result type (might be due to invalid IL or missing references)
				if (Object.op_Implicit((Object)(object)o) && !o.dead && !inside.Contains(o) && Object.op_Implicit((Object)(object)o.rb) && !o.rb.isKinematic && o.playerGrabbing.Count == 0)
				{
					Vector3 val2 = ((Component)o).transform.position - ((Component)selected).transform.position;
					return ((Vector3)(ref val2)).sqrMagnitude < 36f;
				}
				return false;
			}).OrderBy(delegate(PhysGrabObject o)
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				Vector3 val2 = ((Component)o).transform.position - ((Component)selected).transform.position;
				return ((Vector3)(ref val2)).sqrMagnitude;
			}).Take(8)
				.ToArray();
			InvalidateCargo(selected);
			for (int num = 0; num < array.Length; num++)
			{
				array[num].OverrideIndestructible(2f);
				array[num].Teleport(val.position + Vector3.up * (0.3f + (float)num * 0.25f), ((Component)array[num]).transform.rotation);
			}
			status = array.Length + " valores colocados no carrinho; confira o espaço disponível.";
		}

		public static bool LoadObjects(IEnumerable<PhysGrabObject> objects, out string reason)
		{
			//IL_02a5: 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_02b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
			reason = "Entre na sua partida para carregar objetos.";
			if (!Ready || objects == null)
			{
				return false;
			}
			if (!Usable(selected))
			{
				selected = carts.Where(Usable).Where(delegate(PhysGrabCart c)
				{
					//IL_0006: Unknown result type (might be due to invalid IL or missing references)
					//IL_0015: Unknown result type (might be due to invalid IL or missing references)
					//IL_001a: Unknown result type (might be due to invalid IL or missing references)
					//IL_001f: Unknown result type (might be due to invalid IL or missing references)
					Vector3 val3 = ((Component)c).transform.position - ((Component)RuntimeSupport.LocalPlayer).transform.position;
					return ((Vector3)(ref val3)).sqrMagnitude <= 36f;
				}).OrderBy(delegate(PhysGrabCart c)
				{
					//IL_0006: Unknown result type (might be due to invalid IL or missing references)
					//IL_0015: Unknown result type (might be due to invalid IL or missing references)
					//IL_001a: Unknown result type (might be due to invalid IL or missing references)
					//IL_001f: Unknown result type (might be due to invalid IL or missing references)
					Vector3 val3 = ((Component)c).transform.position - ((Component)RuntimeSupport.LocalPlayer).transform.position;
					return ((Vector3)(ref val3)).sqrMagnitude;
				})
					.FirstOrDefault();
			}
			if (!Usable(selected))
			{
				reason = "Selecione um carrinho ou fique a até 6 m de um.";
				return false;
			}
			Transform val = RuntimeSupport.Get<Transform>(selected, "inCart");
			if (!Object.op_Implicit((Object)(object)val))
			{
				reason = "Este carrinho não tem área de carga disponível.";
				return false;
			}
			HashSet<PhysGrabObject> hashSet = new HashSet<PhysGrabObject>(Contents(selected));
			int instanceID = ((Object)selected).GetInstanceID();
			if (loadCartId != instanceID || Time.unscaledTime - lastLoadAt > 2f)
			{
				nextLoadSlot = hashSet.Count;
			}
			nextLoadSlot = Math.Max(nextLoadSlot, hashSet.Count);
			loadCartId = instanceID;
			int num = 0;
			InvalidateCargo(selected);
			Vector3 val2 = default(Vector3);
			foreach (PhysGrabObject item in objects.Where((PhysGrabObject o) => Object.op_Implicit((Object)(object)o)).Distinct().Take(12))
			{
				if (nextLoadSlot >= 12)
				{
					break;
				}
				if (!item.dead && ((Component)item).gameObject.activeInHierarchy && Object.op_Implicit((Object)(object)item.rb) && !item.rb.isKinematic && item.playerGrabbing.Count == 0 && !hashSet.Contains(item) && !Object.op_Implicit((Object)(object)((Component)item).GetComponentInParent<PhysGrabCart>()) && !Object.op_Implicit((Object)(object)((Component)item).GetComponentInParent<Enemy>()) && !Object.op_Implicit((Object)(object)((Component)item).GetComponentInParent<PlayerAvatar>()) && !Object.op_Implicit((Object)(object)((Component)item).GetComponent<PlayerTumble>()))
				{
					ValuableObject component = ((Component)item).GetComponent<ValuableObject>();
					if (!Object.op_Implicit((Object)(object)component) || !RuntimeSupport.Get<bool>(component, "committedToExtraction"))
					{
						int num2 = nextLoadSlot++;
						((Vector3)(ref val2))..ctor(((float)(num2 % 2) - 0.5f) * 0.45f, 0.25f + (float)(num2 / 4) * 0.35f, ((float)(num2 / 2 % 2) - 0.5f) * 0.45f);
						item.OverrideIndestructible(2f);
						item.Teleport(val.position + val.rotation * val2, ((Component)item).transform.rotation);
						hashSet.Add(item);
						num++;
						lastLoadAt = Time.unscaledTime;
					}
				}
			}
			reason = ((num > 0) ? (num + " objeto(s) carregado(s). Confira o espaço no carrinho.") : "Nenhum objeto solto disponível, ou limite de 12 posições atingido.");
			status = reason;
			return num > 0;
		}

		public static void UnloadAtExtraction()
		{
			//IL_0023: 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_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: 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_00d2: 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_00d7: 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_011e: 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)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			RuntimeSupport.RequireHost();
			if (!Ready || !Usable(selected))
			{
				return;
			}
			ExtractionPoint val = NearestExtraction(((Component)selected).transform.position);
			if (Object.op_Implicit((Object)(object)val))
			{
				Vector3 val2 = ((Component)val).transform.position - ((Component)selected).transform.position;
				if (!(((Vector3)(ref val2)).sqrMagnitude > 36f))
				{
					PhysGrabObject[] array = (from o in Contents(selected)
						where Object.op_Implicit((Object)(object)((Component)o).GetComponent<ValuableObject>())
						select o).ToArray();
					InvalidateCargo(selected);
					Vector3 val3 = (Object.op_Implicit((Object)(object)val.extractionArea) ? val.extractionArea.transform.position : ((Component)val).transform.position);
					for (int num = 0; num < array.Length; num++)
					{
						array[num].OverrideIndestructible(2f);
						array[num].Teleport(val3 + new Vector3((float)(num % 3 - 1) * 0.4f, 0.6f + (float)(num / 9) * 0.3f, (float)(num / 3 % 3 - 1) * 0.4f), ((Component)array[num]).transform.rotation);
					}
					status = array.Length + " valores descarregados. A extração mantém a contagem e as regras nativas.";
					return;
				}
			}
			status = "Leve o carrinho a até 6 m da extração.";
		}

		public static void OpenExtraction()
		{
			//IL_0034: 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)
			RuntimeSupport.RequireHost();
			if (Ready)
			{
				OpenNearestExtraction(Object.op_Implicit((Object)(object)selected) ? ((Component)selected).transform.position : ((Component)RuntimeSupport.LocalPlayer).transform.position);
			}
		}

		public static void OpenNearestExtraction(Vector3 origin)
		{
			//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)
			RuntimeSupport.RequireHost();
			if (!Ready || !Object.op_Implicit((Object)(object)RoundDirector.instance))
			{
				return;
			}
			if (RuntimeSupport.Get<bool>(RoundDirector.instance, "extractionPointActive"))
			{
				RuntimeSupport.Status = (status = "Já existe uma extração ativa; conclua-a antes de abrir outra.");
				return;
			}
			ExtractionPoint val = (from p in SceneObjectIndex.Population<ExtractionPoint>()
				where Object.op_Implicit((Object)(object)p) && ((Component)p).gameObject.activeInHierarchy && (int)RuntimeSupport.Get<State>(p, "currentState") == 1 && !RuntimeSupport.Get<bool>(p, "isLocked")
				select p).OrderBy(delegate(ExtractionPoint p)
			{
				//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_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)
				Vector3 val2 = ((Component)p).transform.position - origin;
				return ((Vector3)(ref val2)).sqrMagnitude;
			}).FirstOrDefault();
			if (!Object.op_Implicit((Object)(object)val))
			{
				RuntimeSupport.Status = (status = "Nenhuma extração livre e destravada disponível.");
				return;
			}
			val.OnClick();
			RuntimeSupport.Status = (status = "Comando enviado à extração pelo fluxo nativo.");
		}

		public static void RideSelected()
		{
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: 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)
			RuntimeSupport.RequireHost();
			if (Ready && Usable(selected))
			{
				Bounds[] array = (from c in ((Component)selected).GetComponentsInChildren<Collider>()
					where Object.op_Implicit((Object)(object)c) && !c.isTrigger
					select c.bounds).ToArray();
				float num = ((array.Length == 0) ? (((Component)selected).transform.position.y + 1f) : array.Max((Bounds b) => ((Bounds)(ref b)).max.y));
				HostTools.Teleport(RuntimeSupport.LocalPlayer, new Vector3(((Component)selected).transform.position.x, num + 0.2f, ((Component)selected).transform.position.z));
				riding = selected;
				status = "Carona ligada. Pule ou afaste-se para sair.";
			}
		}

		public static void DrawPanel()
		{
			HudTheme.Hint(motors.Count + " em movimento · cada carrinho mantém seu destino.");
			if (!Ready)
			{
				HudTheme.Empty("Entre na sua partida", "Os comandos ficam disponíveis quando seu personagem e o mapa estiverem prontos.", 11);
				return;
			}
			HudTheme.BeginCard();
			if (Object.op_Implicit((Object)(object)selected))
			{
				HudTheme.Section((selected.isSmallCart ? "Carrinho de bolso" : "Carrinho") + " · " + (Array.IndexOf(carts, selected) + 1) + "/" + carts.Length);
			}
			else
			{
				HudTheme.Empty("Escolha um carrinho", "Use Selecionar próximo. Tire o carrinho de bolso do inventário antes de usá-lo.", 11);
			}
			HudTheme.Button("Selecionar próximo", SelectNext, enabled: true, !Object.op_Implicit((Object)(object)selected));
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			HudTheme.Button("Até mim", delegate
			{
				SendSelected(Destination.Host);
			}, Object.op_Implicit((Object)(object)selected), primary: true);
			HudTheme.Button("À extração", delegate
			{
				SendSelected(Destination.Extraction);
			}, Object.op_Implicit((Object)(object)selected));
			HudTheme.Button("Ao caminhão", delegate
			{
				SendSelected(Destination.Truck);
			}, Object.op_Implicit((Object)(object)selected));
			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			HudTheme.Button("Parar este", delegate
			{
				SendSelected(Destination.Stopped);
			}, Object.op_Implicit((Object)(object)selected));
			HudTheme.Button("Pegar carona", RideSelected, Object.op_Implicit((Object)(object)selected));
			GUILayout.EndHorizontal();
			HudTheme.EndCard();
			HudTheme.BeginCard();
			HudTheme.Section("Cuide da carga");
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			HudTheme.Button("Carregar valores", LoadNearby, Object.op_Implicit((Object)(object)selected));
			HudTheme.Button("Descarregar na extração", UnloadAtExtraction, Object.op_Implicit((Object)(object)selected));
			GUILayout.EndHorizontal();
			HudTheme.Button("Abrir extração", OpenExtraction);
			HudTheme.Hint("Até 8 valores próximos por comando. Descarregue perto da extração; o dinheiro segue o fluxo normal do jogo.");
			HudTheme.EndCard();
			if (HudTheme.Foldout("carrinhos_ajustes", "Velocidade, proteção e atalhos"))
			{
				GUILayout.Label("Velocidade · " + speed.Value.ToString("0.0") + " m/s", Array.Empty<GUILayoutOption>());
				speed.Value = GUILayout.HorizontalSlider(speed.Value, 1f, 10f, Array.Empty<GUILayoutOption>());
				protectCargo.Value = HudTheme.Toggle(protectCargo.Value, "Proteger a carga", "Enquanto o carrinho estiver em movimento.");
				shortcuts.Value = HudTheme.Toggle(shortcuts.Value, "Atalhos de carrinho", "J / K / L / U / I");
				HudTheme.Hint("Cada carrinho mantém seu destino. Portas fechadas e obstáculos podem impedir o caminho.");
			}
			HudTheme.Button("Parar todos", StopAll, enabled: true, primary: false, danger: true);
			HudTheme.Notice(status);
		}

		public static void Shutdown()
		{
			StopAll();
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			harmony = null;
			selected = null;
			carts = Array.Empty<PhysGrabCart>();
			motorBuffer.Clear();
			removedMotors.Clear();
			queriedCargo.Clear();
			distinctCargo.Clear();
			Array.Clear(cargoHits, 0, cargoHits.Length);
			room = null;
		}
	}
	internal static class ConfigurationProfiles
	{
		[Serializable]
		private sealed class Entry
		{
			public string key;

			public string value;
		}

		[Serializable]
		private sealed class Saved
		{
			public string name;

			public Entry[] entries;
		}

		private sealed class Setting
		{
			internal string Key;

			internal string Label;

			internal bool Host;

			internal ConfigEntryBase Config;
		}

		private static readonly List<Setting> settings = new List<Setting>();

		private static readonly string[] Keys = new string[11]
		{
			"Jogador/Invencivel", "Jogador/StaminaInfinitaEmPe", "Jogador/ForcaAmpliada", "Jogador/AlcanceAmpliado", "Jogador/IgnoradoPelosInimigos", "Jogador/EvitarQuedas", "Movimento/CorrerAgachado", "Movimento/StaminaInfinitaAgachado", "Voo/SaltosIlimitados", "Pessoal/VelocidadePersonalizada",
			"Pessoal/MultiplicadorVelocidade"
		};

		private static readonly string[] Labels = new string[11]
		{
			"Invencível", "Fôlego infinito", "Superforça", "Pegar de longe", "Invisível à IA", "Evitar quedas", "Correr agachado", "Fôlego agachado", "Saltos ilimitados", "Velocidade personalizada",
			"Multiplicador de velocidade"
		};

		private static ConfigEntry<string>[] slots;

		private static Saved preview;

		private static int slot;

		private static string name = "Meu perfil";

		internal static void Initialize(ConfigFile config)
		{
			settings.Clear();
			for (int i = 0; i < Keys.Length; i++)
			{
				string key = Keys[i];
				ConfigEntryBase value = ((IEnumerable<KeyValuePair<ConfigDefinition, ConfigEntryBase>>)config).FirstOrDefault((KeyValuePair<ConfigDefinition, ConfigEntryBase> p) => p.Key.Section + "/" + p.Key.Key == key).Value;
				if (value != null)
				{
					settings.Add(new Setting
					{
						Key = key,
						Label = Labels[i],
						Config = value,
						Host = (i == 2 || i == 4)
					});
				}
			}
			slots = (from num in Enumerable.Range(1, 5)
				select config.Bind<string>("Perfis pessoais", "Slot" + num, "", "Perfil pessoal salvo pelo R.O.P.E. Não altera progresso nem rede.")).ToArray();
		}

		private static Saved Capture(string title)
		{
			return new Saved
			{
				name = title,
				entries = settings.Select((Setting s) => new Entry
				{
					key = s.Key,
					value = s.Config.GetSerializedValue()
				}).ToArray()
			};
		}

		private static Saved BuiltIn(int mode)
		{
			Saved saved = new Saved();
			saved.name = (new string[3] { "Normal", "Exploração", "Caos" })[mode];
			saved.entries = settings.Select((Setting s) => new Entry
			{
				key = s.Key,
				value = ((!s.Key.EndsWith("MultiplicadorVelocidade")) ? ((mode == 2 || (mode == 1 && (s.Key.Contains("Stamina") || s.Key.Contains("CorrerAgachado") || s.Key.Contains("SaltosIlimitados") || s.Key.Contains("AlcanceAmpliado")))) ? "true" : "false") : ((mode == 2) ? "2" : "1"))
			}).ToArray();
			return saved;
		}

		private static bool Parse(Setting setting, string serialized, out object value)
		{
			value = null;
			float result2;
			if (setting.Config.SettingType == typeof(bool) && bool.TryParse(serialized, out var result))
			{
				value = result;
			}
			else if (setting.Config.SettingType == typeof(float) && float.TryParse(serialized, NumberStyles.Float, CultureInfo.InvariantCulture, out result2) && !float.IsNaN(result2) && !float.IsInfinity(result2))
			{
				value = result2;
			}
			if (value != null)
			{
				if (setting.Config.Description.AcceptableValues != null)
				{
					return setting.Config.Description.AcceptableValues.IsValid(value);
				}
				return true;
			}
			return false;
		}

		private static List<KeyValuePair<Setting, object>> Changes()
		{
			List<KeyValuePair<Setting, object>> list = new List<KeyValuePair<Setting, object>>();
			if (preview == null || preview.entries == null)
			{
				return list;
			}
			foreach (Entry entry in preview.entries.Take(32))
			{
				if (entry != null)
				{
					Setting s = settings.FirstOrDefault((Setting x) => x.Key == entry.key);
					if (s != null && Parse(s, entry.value, out var value) && !object.Equals(s.Config.BoxedValue, value) && !list.Any((KeyValuePair<Setting, object> p) => p.Key == s))
					{
						list.Add(new KeyValuePair<Setting, object>(s, value));
					}
				}
			}
			return list;
		}

		private static string Display(object value)
		{
			if (!(value is bool))
			{
				return Convert.ToString(value, CultureInfo.InvariantCulture);
			}
			if (!(bool)value)
			{
				return "Desligado";
			}
			return "Ligado";
		}

		private static void Apply()
		{
			List<KeyValuePair<Setting, object>> list = Changes();
			int num = 0;
			int num2 = 0;
			foreach (KeyValuePair<Setting, object> item in list)
			{
				if (item.Key.Host && !RuntimeSupport.IsHost)
				{
					num2++;
					continue;
				}
				item.Key.Config.BoxedValue = item.Value;
				num++;
			}
			RuntimeSupport.Status = num + " ajuste(s) aplicado(s)." + ((num2 > 0) ? (" " + num2 + " ajuste(s) de anfitrião ignorado(s).") : "");
			preview = null;
		}

		private static void LoadSlot()
		{
			try
			{
				string value = slots[slot].Value;
				if (value.Length > 16000)
				{
					throw new FormatException();
				}
				Saved saved = JsonUtility.FromJson<Saved>(value);
				if (saved == null || saved.entries == null || saved.entries.Length > 32 || saved.entries.Any((Entry e) => e == null || string.IsNullOrEmpty(e.key) || e.value == null))
				{
					throw new FormatException();
				}
				Entry[] entries = saved.entries;
				foreach (Entry entry in entries)
				{
					Setting setting = settings.FirstOrDefault((Setting s) => s.Key == entry.key);
					if (setting != null && !Parse(setting, entry.value, out var _))
					{
						throw new FormatException();
					}
				}
				preview = saved;
			}
			catch
			{
				preview = null;
				RuntimeSupport.Status = "Este espaço ainda não tem um perfil válido.";
			}
		}

		internal static void DrawPanel()
		{
			HudTheme.Section("Seu jeito de jogar", "Escolha e confira antes de aplicar.");
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			for (int i = 0; i < 3; i++)
			{
				int mode = i;
				string text = (new string[3] { "Normal", "Exploração", "Caos" })[i];
				HudTheme.Button(text, delegate
				{
					preview = BuiltIn(mode);
				}, enabled: true, preview != null && preview.name == text);
			}
			GUILayout.EndHorizontal();
			if (preview != null)
			{
				string text2 = RuntimeSupport.Clean(preview.name);
				if (text2.Length > 32)
				{
					text2 = text2.Substring(0, 32);
				}
				HudTheme.BeginCard();
				HudTheme.Section("Conferir · " + text2);
				List<KeyValuePair<Setting, object>> list = (from c in Changes()
					where !c.Key.Host || RuntimeSupport.IsHost
					select c).ToList();
				foreach (KeyValuePair<Setting, object> item in list)
				{
					GUILayout.Label(item.Key.Label + ": " + Display(item.Key.Config.BoxedValue) + " → " + Display(item.Value), Array.Empty<GUILayoutOption>());
				}
				if (list.Count == 0)
				{
					HudTheme.Hint("Seus ajustes já correspondem a este perfil.");
				}
				GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
				HudTheme.Button("Aplicar mudanças", Apply, list.Count > 0, primary: true);
				HudTheme.Button("Cancelar", delegate
				{
					preview = null;
				});
				GUILayout.EndHorizontal();
				HudTheme.EndCard();
			}
			GUILayout.Space(12f);
			if (HudTheme.Foldout("profiles.saved", "Meus perfis"))
			{
				HudTheme.BeginCard();
				slot = HudTheme.Tabs(slot, new string[5] { "1", "2", "3", "4", "5" });
				HudTheme.Hint("Nome do perfil");
				name = RuntimeSupport.TextField("ProfileName", name, 32);
				GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
				HudTheme.Button("Salvar neste espaço", delegate
				{
					slots[slot].Value = JsonUtility.ToJson((object)Capture(string.IsNullOrWhiteSpace(name) ? "Meu perfil" : name.Trim()));
					RuntimeSupport.Status = "Perfil guardado no espaço " + (slot + 1) + ".";
				});
				HudTheme.Button("Conferir salvo", LoadSlot, !string.IsNullOrEmpty(slots[slot].Value));
				GUILayout.EndHorizontal();
				HudTheme.Hint("Guarda poderes e movimento, sem alterar seu progresso.");
				HudTheme.EndCard();
			}
			QuickActions.DrawManager();
			if (HudTheme.Foldout("profiles.feedback", "Som e animação"))
			{
				UiFeedback.DrawPanel();
			}
		}

		internal static void Shutdown()
		{
			settings.Clear();
			preview = null;
		}
	}
	internal static class ControlPanel
	{
		private const int You = 12;

		private const int Room = 13;

		private const int Settings = 14;

		private const int Tools = 15;

		private const int Favorites = 16;

		private static readonly string[] Titles = new string[17]
		{
			"Início", "Meu personagem", "Criar", "Pessoas", "Aparência", "Objeto", "Partida", "Minha visão", "Expedição", "Ajustes",
			"Carrinhos", "Alvos", "Você", "Sala", "Ajustes", "Ferramentas", "Meus atalhos"
		};

		private static readonly int[] Navigation = new int[4] { 0, 12, 13, 14 };

		private static readonly int[] SearchOrder = new int[12]
		{
			0, 1, 4, 7, 8, 2, 3, 5, 10, 11,
			6, 9
		};

		private static readonly string[] SystemTitles = new string[4] { "Salvamentos", "Meu estilo", "Teclas", "Ajuda" };

		private static readonly string[] PersonalTabs = new string[4] { "Poderes", "Movimento", "Áudio", "Inventário" };

		private static readonly string[] TeamTabs = new string[2] { "Pessoas", "Painel da equipe" };

		private static readonly string[] WorldTabs = new string[4] { "Mapa", "Entradas", "Progresso", "Eventos" };

		private static readonly string[] VisualTabs = new string[3] { "Câmera", "Marcadores", "Equipe" };

		private static readonly string[] SearchTerms = new string[12]
		{
			"atalhos início favoritos recentes", "poderes força invisível vida fôlego energia velocidade áudio microfone voz ruído som aviso entrada slots inventário voo voar atravessar paredes pular saltos agachar agachado correr corrida sobrecarga bateria combate", "spawn criar itens monstros armas prévia posicionar favoritos recentes", "jogadores teleportar trazer expulsar melhorias equipe", "skin copiar cor aparência acessórios", "objeto bateria peso valor congelar desfazer seleção grupo", "mapa mundo sala late join entrada progresso nome público eventos ondas monstros", "câmera terceira pessoa marcadores cores mapa visual filtros caídos bateria valor equipe painel", "expedição trilha caminhão desafios medalhas balanço relatório", "salvar salvamentos diagnóstico sistema perfis atalhos teclas favoritos sons animação",
			"carrinho caminhão extração carregar", "inimigo alvo poderes órbita arma seguir orbe barreira"
		};

		private static readonly string[] HostSearchIndex = BuildSearchIndex(host: true);

		private static readonly string[] GuestSearchIndex = BuildSearchIndex(host: false);

		private static readonly Dictionary<string, GUIContent> tooltips = new Dictionary<string, GUIContent>(StringComparer.Ordinal);

		private static readonly List<int> searchResults = new List<int>(SearchOrder.Length);

		private static readonly char[] SearchSeparators = new char[1] { ' ' };

		private static string searchCacheText;

		private static string searchQuery = "";

		private static bool searchCacheHost;

		private static CompareInfo searchCompareInfo;

		private static Vector2 scroll;

		private static int lastPage = -1;

		private static int worldTab;

		private static int visualTab;

		private static int teamTab;

		private static int systemTab;

		private static int personalTab;

		private static int movementTab;

		private static int quickTab;

		private static string search = "";

		private static bool searchOpen;

		private static bool focusSearch;

		private const float CanvasWidth = 1280f;

		private const float CanvasHeight = 800f;

		private const float ContentX = 252f;

		private const float ContentY = 162f;

		private const float ContentWidth = 1004f;

		private const float ContentHeight = 552f;

		private const float CardHeight = 158f;

		private const float CardGap = 12f;

		private const float TabBarHeight = 68f;

		internal static string PageTitle(int page)
		{
			if (page == 9)
			{
				return SystemTitles[Mathf.Clamp(systemTab, 0, 3)];
			}
			return Titles[Mathf.Clamp(page, 0, Titles.Length - 1)];
		}

		private static bool PageVisible(int page)
		{
			if (!RuntimeSupport.IsHost)
			{
				if (page != 2 && page != 3 && page != 5 && page != 6 && page != 10 && page != 11 && page != 13)
				{
					return page != 15;
				}
				return false;
			}
			return true;
		}

		private static int Group(int page)
		{
			switch (page)
			{
			case 0:
			case 16:
				return 0;
			case 1:
			case 4:
			case 7:
			case 8:
			case 12:
				return 12;
			case 9:
			case 14:
				return 14;
			default:
				return 13;
			}
		}

		private static int Parent(int page)
		{
			switch (page)
			{
			case 15:
				return 13;
			case 5:
			case 10:
			case 11:
				return 15;
			case 12:
			case 13:
			case 14:
			case 16:
				return 0;
			default:
				return Group(page);
			}
		}

		private static void ResetSearchCache()
		{
			searchCacheText = null;
			searchQuery = "";
			searchCompareInfo = null;
			searchResults.Clear();
		}

		private static void CloseSearch()
		{
			search = "";
			searchOpen = false;
			focusSearch = false;
			ResetSearchCache();
			GUI.FocusControl((string)null);
		}

		internal static void OnOpen()
		{
			//IL_001b: 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)
			search = "";
			searchOpen = false;
			focusSearch = false;
			ResetSearchCache();
			scroll = Vector2.zero;
			lastPage = -1;
		}

		private static GUIContent Tooltip(string value)
		{
			//IL_001b: 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_0022: Expected O, but got Unknown
			//IL_0027: Expected O, but got Unknown
			if (!tooltips.TryGetValue(value, out var value2))
			{
				Dictionary<string, GUIContent> dictionary = tooltips;
				GUIContent val = new GUIContent("", value);
				value2 = val;
				dictionary.Add(value, val);
			}
			return value2;
		}

		internal static int Draw(int page, Action close, Action openObject, Action<string, Action> module)
		{
			//IL_074a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0756: Unknown result type (might be due to invalid IL or missing references)
			//IL_0763: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: 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)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: 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_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0310: Unknown result type (might be due to invalid IL or missing references)
			//IL_0335: Unknown result type (might be due to invalid IL or missing references)
			//IL_0341: Unknown result type (might be due to invalid IL or missing references)
			//IL_0366: Unknown result type (might be due to invalid IL or missing references)
			//IL_0372: Unknown result type (might be due to invalid IL or missing references)
			//IL_0397: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_042b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0437: 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_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_0473: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_052b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0530: Unknown result type (might be due to invalid IL or missing references)
			//IL_0556: Unknown result type (might be due to invalid IL or missing references)
			//IL_0562: Unknown result type (might be due to invalid IL or missing references)
			//IL_0644: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0672: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_072b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0734: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_061d: Unknown result type (might be due to invalid IL or missing references)
			if (!PageVisible(page) || (page == 9 && systemTab == 0 && !RuntimeSupport.IsHost))
			{
				page = 0;
			}
			float num = Mathf.Max(0.3f, Mathf.Min(1.15f, Mathf.Min((float)(Screen.width - 32) / 1280f, (float)(Screen.height - 32) / 800f)));
			Matrix4x4 matrix = GUI.matrix;
			GUISkin skin = GUI.skin;
			Color backgroundColor = GUI.backgroundColor;
			bool enabled = GUI.enabled;
			Color color = GUI.color;
			HudTheme.Fill(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), new Color(0f, 0f, 0f, 0.62f));
			GUI.matrix = Matrix4x4.TRS(new Vector3(((float)Screen.width - 1280f * num) / 2f, ((float)Screen.height - 800f * num) / 2f, 0f), Quaternion.identity, new Vector3(num, num, 1f));
			GUI.skin = HudTheme.Skin;
			GUI.backgroundColor = Color.white;
			try
			{
				HudTheme.Box(new Rect(0f, 0f, 1280f, 800f), HudTheme.Panel);
				HudTheme.Box(new Rect(8f, 8f, 224f, 784f), HudTheme.Ink);
				HudTheme.Brand(new Rect(18f, 24f, 204f, 76f));
				int num2 = 0;
				int[] navigation = Navigation;
				Rect val = default(Rect);
				foreach (int num3 in navigation)
				{
					if (PageVisible(num3))
					{
						((Rect)(ref val))..ctor(18f, (float)(156 + num2++ * 76), 204f, 60f);
						bool flag = Group(page) == num3;
						if (flag)
						{
							HudTheme.Box(val, HudTheme.Orange);
						}
						else if (((Rect)(ref val)).Contains(Event.current.mousePosition))
						{
							HudTheme.Box(val, HudTheme.Card);
						}
						if (GUI.Button(val, Tooltip(Titles[num3]), GUIStyle.none))
						{
							page = num3;
							CloseSearch();
							UiFeedback.Click();
						}
						NavigationIcons.Draw(new Rect(((Rect)(ref val)).x + 16f, ((Rect)(ref val)).y + 15f, 30f, 30f), num3 switch
						{
							14 => 9, 
							13 => 3, 
							12 => 1, 
							_ => 0, 
						}, flag ? HudTheme.Ink : HudTheme.White);
						HudTheme.Text(new Rect(((Rect)(ref val)).x + 60f, ((Rect)(ref val)).y, 132f, ((Rect)(ref val)).height), Titles[num3], 21, flag ? HudTheme.Ink : HudTheme.White, flag, (TextAnchor)3);
					}
				}
				HudTheme.Text(new Rect(30f, 688f, 176f, 24f), RuntimeSupport.IsHost ? "SUA SALA" : "CONVIDADO", 13, HudTheme.Muted, bold: true, (TextAnchor)0);
				HudTheme.Text(new Rect(30f, 725f, 176f, 20f), "R / Esc para fechar", 13, HudTheme.Muted, bold: false, (TextAnchor)0);
				HudTheme.Text(new Rect(30f, 755f, 176f, 20f), "v0.6.9", 12, HudTheme.Muted, bold: false, (TextAnchor)0);
				HudTheme.Text(new Rect(252f, 26f, 560f, 56f), searchOpen ? "O que você procura?" : ((page == 0) ? "Vamos jogar?" : PageTitle(page)), 36, HudTheme.White, bold: true, (TextAnchor)0);
				if (searchOpen)
				{
					GUI.SetNextControlName("RepoGeral_Text_Search");
					search = GUI.TextField(new Rect(828f, 28f, 328f, 44f), search, 40);
					if (string.IsNullOrEmpty(search))
					{
						HudTheme.Text(new Rect(840f, 37f, 300f, 26f), "Ex.: voar, aparência, equipe", 16, HudTheme.Muted, bold: false, (TextAnchor)0);
					}
					if (focusSearch)
					{
						GUI.FocusControl("RepoGeral_Text_Search");
						focusSearch = false;
					}
					if (HudTheme.Button(new Rect(1164f, 28f, 48f, 44f), "×", primary: false, "Fechar busca"))
					{
						CloseSearch();
					}
				}
				else if (HudTheme.Button(new Rect(1084f, 28f, 128f, 44f), "Buscar", primary: false, "Encontrar uma função"))
				{
					searchOpen = true;
					focusSearch = true;
					ShortcutSettings.Cancel();
				}
				if (HudTheme.Button(new Rect(1224f, 28f, 42f, 44f), "×", primary: false, "Fechar painel · R / Esc"))
				{
					CloseSearch();
					close();
				}
				if (ShortcutSettings.Capturing && (page != 9 || systemTab != 2 || searchOpen))
				{
					ShortcutSettings.Cancel();
				}
				if (page != lastPage)
				{
					scroll = Vector2.zero;
					lastPage = page;
				}
				if (searchOpen)
				{
					HudTheme.Text(new Rect(252f, 100f, 1004f, 36f), "Busque pelo que quer fazer.", 17, HudTheme.Muted, bold: false, (TextAnchor)0);
					if (!string.IsNullOrWhiteSpace(search))
					{
						page = Search(page);
					}
				}
				else
				{
					if (page != 0 && page != 12 && page != 13 && page != 14)
					{
						int num4 = Parent(page);
						if (HudTheme.Button(new Rect(252f, 100f, 112f, 44f), "‹ Voltar"))
						{
							page = num4;
							GUI.FocusControl((string)null);
						}
						HudTheme.Text(new Rect(382f, 100f, 820f, 44f), Titles[num4] + "  /  " + PageTitle(page), 16, HudTheme.Muted, bold: false, (TextAnchor)3);
					}
					else
					{
						HudTheme.Text(new Rect(252f, 89f, 740f, 40f), page switch
						{
							13 => "O que vamos fazer juntos?", 
							12 => "Seu robô, do seu jeito.", 
							0 => "Seus favoritos. Um clique e pronto.", 
							_ => "Deixe tudo do seu jeito.", 
						}, 18, HudTheme.Muted, bold: false, (TextAnchor)0);
					}
					switch (page)
					{
					case 0:
						page = Home(openObject, page);
						break;
					case 12:
					case 13:
					case 14:
					case 15:
						page = DrawHub(page);
						break;
					default:
						if (page == 16)
						{
							page = DrawFavorites(page);
						}
						else
						{
							DrawModule(page, openObject, module);
						}
						break;
					}
				}
				HudTheme.Fill(new Rect(252f, 732f, 1004f, 1f), HudTheme.Line);
				string value = ((Time.unscaledTime - RuntimeSupport.StatusChangedAt < 5f && RuntimeSupport.StatusRevision > 0) ? RuntimeSupport.Status : GUI.tooltip);
				if (string.IsNullOrWhiteSpace(value))
				{
					value = "Tudo à mão.";
				}
				HudTheme.Text(new Rect(252f, 749f, 1004f, 30f), value, 14, HudTheme.Muted, bold: false, (TextAnchor)0);
				return page;
			}
			finally
			{
				GUI.matrix = matrix;
				GUI.skin = skin;
				GUI.backgroundColor = backgroundColor;
				GUI.enabled = enabled;
				GUI.color = color;
			}
		}

		private static bool HasPageTabs(int page)
		{
			if (page != 1 && page != 3 && page != 6)
			{
				return page == 7;
			}
			return true;
		}

		private static void DrawPageTabs(int page)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.BeginArea(new Rect(252f, 162f, 1004f, 68f));
			try
			{
				int num;
				int num2;
				switch (page)
				{
				case 1:
					num = personalTab;
					num2 = (personalTab = HudTheme.Tabs(personalTab, PersonalTabs));
					break;
				case 3:
					num = teamTab;
					num2 = (teamTab = HudTheme.Tabs(teamTab, TeamTabs));
					break;
				case 6:
					num = worldTab;
					num2 = (worldTab = HudTheme.Tabs(worldTa