Decompiled source of ValheimMenu v1.1.2

ValheimMenu.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyVersion("0.0.0.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 ValheimMenu
{
	internal sealed class CameraBlur
	{
		private Camera _cam;

		private Behaviour _dof;

		private bool _dofWasEnabled;

		private Component _post;

		private FieldInfo _profileField;

		private ScriptableObject _originalProfile;

		private ScriptableObject _tempProfile;

		private bool _active;

		internal void Suppress(Camera cam)
		{
			if ((Object)(object)cam == (Object)null)
			{
				return;
			}
			if (!CampConfig.SharpCamera.Value)
			{
				Restore();
				return;
			}
			if (!_active || (Object)(object)_cam != (Object)(object)cam)
			{
				Restore();
				_cam = cam;
				Capture();
				_active = true;
			}
			if ((Object)(object)_dof != (Object)null && _dof.enabled)
			{
				_dof.enabled = false;
			}
		}

		internal void Restore()
		{
			if (!_active)
			{
				return;
			}
			_active = false;
			if ((Object)(object)_dof != (Object)null)
			{
				_dof.enabled = _dofWasEnabled;
			}
			if ((Object)(object)_post != (Object)null && _profileField != null && (Object)(object)_originalProfile != (Object)null)
			{
				try
				{
					_profileField.SetValue(_post, _originalProfile);
				}
				catch (Exception ex)
				{
					Plugin.Log.LogDebug((object)("[Câmera] restaurar perfil: " + ex.Message));
				}
			}
			if ((Object)(object)_tempProfile != (Object)null)
			{
				Object.Destroy((Object)(object)_tempProfile);
			}
			_dof = null;
			_post = null;
			_profileField = null;
			_originalProfile = null;
			_tempProfile = null;
			_cam = null;
		}

		private void Capture()
		{
			Component[] components = ((Component)_cam).GetComponents<Component>();
			foreach (Component val in components)
			{
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				string name = ((object)val).GetType().Name;
				if ((Object)(object)_dof == (Object)null && name == "DepthOfField")
				{
					Behaviour val2 = (Behaviour)(object)((val is Behaviour) ? val : null);
					if (val2 != null)
					{
						_dof = val2;
						_dofWasEnabled = val2.enabled;
						continue;
					}
				}
				if ((Object)(object)_post == (Object)null && name == "PostProcessingBehaviour")
				{
					_post = val;
				}
			}
			if ((Object)(object)_post == (Object)null)
			{
				return;
			}
			try
			{
				_profileField = AccessTools.Field(((object)_post).GetType(), "profile");
				ref ScriptableObject originalProfile = ref _originalProfile;
				object? obj = _profileField?.GetValue(_post);
				originalProfile = (ScriptableObject)((obj is ScriptableObject) ? obj : null);
				if (!((Object)(object)_originalProfile == (Object)null))
				{
					_tempProfile = Object.Instantiate<ScriptableObject>(_originalProfile);
					((Object)_tempProfile).name = "ValheimMenu_SharpProfile";
					object obj2 = AccessTools.Field(((object)_tempProfile).GetType(), "motionBlur")?.GetValue(_tempProfile);
					(obj2?.GetType().GetProperty("enabled"))?.SetValue(obj2, false);
					object obj3 = AccessTools.Field(((object)_tempProfile).GetType(), "depthOfField")?.GetValue(_tempProfile);
					(obj3?.GetType().GetProperty("enabled"))?.SetValue(obj3, false);
					_profileField.SetValue(_post, _tempProfile);
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogDebug((object)("[Câmera] perfil de pós-processo: " + ex.Message));
				if ((Object)(object)_tempProfile != (Object)null)
				{
					Object.Destroy((Object)(object)_tempProfile);
				}
				_tempProfile = null;
				_originalProfile = null;
			}
		}
	}
	[HarmonyPatch(typeof(FejdStartup), "Start")]
	internal static class Camp_FejdStartup_Start
	{
		private static void Postfix(FejdStartup __instance)
		{
			if ((Object)(object)((Component)__instance).GetComponent<CampfireSelect>() == (Object)null)
			{
				((Component)__instance).gameObject.AddComponent<CampfireSelect>().Init(__instance);
			}
			if ((Object)(object)((Component)__instance).GetComponent<MainMenuDecor>() == (Object)null)
			{
				((Component)__instance).gameObject.AddComponent<MainMenuDecor>().Init(__instance);
			}
			if ((Object)(object)((Component)__instance).GetComponent<MenuSkin>() == (Object)null)
			{
				((Component)__instance).gameObject.AddComponent<MenuSkin>().Init(__instance);
			}
		}
	}
	[HarmonyPatch]
	internal static class Skin_FejdStartup_ScreenOpened
	{
		private static readonly string[] Methods = new string[5] { "OnButtonSettings", "ShowStartGame", "ShowCharacterSelection", "OnCinematics", "UpdateWorldList" };

		private static IEnumerable<MethodBase> TargetMethods()
		{
			string[] methods = Methods;
			foreach (string text in methods)
			{
				MethodBase methodBase = null;
				try
				{
					methodBase = AccessTools.Method(typeof(FejdStartup), text, (Type[])null, (Type[])null);
				}
				catch (AmbiguousMatchException)
				{
				}
				if (methodBase != null)
				{
					yield return methodBase;
				}
			}
		}

		private static void Postfix()
		{
			MenuSkin.ScanNow();
		}
	}
	[HarmonyPatch]
	internal static class Camp_FejdStartup_UpdateCamera
	{
		private static MethodBase TargetMethod()
		{
			return AccessTools.Method(typeof(FejdStartup), "UpdateCamera", (Type[])null, (Type[])null);
		}

		private static bool Prepare()
		{
			return TargetMethod() != null;
		}

		private static bool Prefix()
		{
			return !CampfireSelect.OwnsCamera;
		}
	}
	[HarmonyPatch(typeof(FejdStartup), "OnCharacterStart")]
	internal static class Camp_FejdStartup_OnCharacterStart
	{
		private static bool Prefix()
		{
			if (CampfireSelect.PassThroughStart)
			{
				return true;
			}
			CampfireSelect instance = CampfireSelect.Instance;
			if ((Object)(object)instance == (Object)null || !CampfireSelect.OwnsCamera)
			{
				return true;
			}
			if (instance.IsTravelling)
			{
				return false;
			}
			return !instance.TryBeginFocusFromStart();
		}
	}
	[HarmonyPatch(typeof(FejdStartup), "OnCharacterLeft")]
	internal static class Camp_FejdStartup_OnCharacterLeft
	{
		private static bool Prefix()
		{
			if ((Object)(object)CampfireSelect.Instance != (Object)null)
			{
				return !CampfireSelect.Instance.StepRoster(-1);
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(FejdStartup), "OnCharacterRight")]
	internal static class Camp_FejdStartup_OnCharacterRight
	{
		private static bool Prefix()
		{
			if ((Object)(object)CampfireSelect.Instance != (Object)null)
			{
				return !CampfireSelect.Instance.StepRoster(1);
			}
			return true;
		}
	}
	[HarmonyPatch]
	internal static class Camp_FejdStartup_SetupCharacterPreview
	{
		private static MethodBase TargetMethod()
		{
			return AccessTools.Method(typeof(FejdStartup), "SetupCharacterPreview", (Type[])null, (Type[])null);
		}

		private static bool Prepare()
		{
			return TargetMethod() != null;
		}

		private static void Postfix()
		{
			CampfireSelect instance = CampfireSelect.Instance;
			if (!((Object)(object)instance == (Object)null) && ((CampfireSelect.OwnsCamera && instance.InCharacterSelect()) || (CampfireSelect.CampActive && !instance.InCreation())))
			{
				instance.HidePreview();
			}
		}
	}
	[HarmonyPatch]
	internal static class Camp_FejdStartup_ClearCharacterPreview
	{
		private static readonly FieldRef<FejdStartup, GameObject> InstanceRef = SafeRef();

		private static FieldRef<FejdStartup, GameObject> SafeRef()
		{
			try
			{
				return AccessTools.FieldRefAccess<FejdStartup, GameObject>("m_playerInstance");
			}
			catch
			{
				return null;
			}
		}

		private static MethodBase TargetMethod()
		{
			return AccessTools.Method(typeof(FejdStartup), "ClearCharacterPreview", (Type[])null, (Type[])null);
		}

		private static bool Prepare()
		{
			if (TargetMethod() != null)
			{
				return InstanceRef != null;
			}
			return false;
		}

		private static bool Prefix(FejdStartup __instance)
		{
			if (!CampfireSelect.CampActive)
			{
				return true;
			}
			GameObject val = InstanceRef.Invoke(__instance);
			if ((Object)(object)val != (Object)null)
			{
				Object.Destroy((Object)(object)val);
			}
			InstanceRef.Invoke(__instance) = null;
			return false;
		}
	}
	[HarmonyPatch]
	internal static class Camp_FejdStartup_UpdateCharacterList
	{
		private static MethodBase TargetMethod()
		{
			return AccessTools.Method(typeof(FejdStartup), "UpdateCharacterList", (Type[])null, (Type[])null);
		}

		private static bool Prepare()
		{
			return TargetMethod() != null;
		}

		private static void Postfix()
		{
			RosterOrder.Invalidate();
		}
	}
	internal static class CampConfig
	{
		internal static ConfigEntry<bool> Enabled;

		internal static ConfigEntry<int> MaxSeats;

		internal static ConfigEntry<float> SeatRadius;

		internal static ConfigEntry<float> SeatArc;

		internal static ConfigEntry<float> CameraDistance;

		internal static ConfigEntry<float> CameraHeight;

		internal static ConfigEntry<float> CameraSmooth;

		internal static ConfigEntry<float> FocusDuration;

		internal static ConfigEntry<float> FocusDistance;

		internal static ConfigEntry<Color> NameColor;

		internal static ConfigEntry<Color> SelectedColor;

		internal static ConfigEntry<Color> SeatedColor;

		internal static ConfigEntry<int> NameSize;

		internal static ConfigEntry<bool> ShowRoster;

		internal static ConfigEntry<bool> SharpCamera;

		internal static ConfigEntry<string> RosterTitle;

		internal static ConfigEntry<string> RosterHint;

		internal static ConfigEntry<bool> ShowOnMainMenu;

		internal static void Bind(ConfigFile cfg)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Expected O, but got Unknown
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Expected O, but got Unknown
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: 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_0215: Expected O, but got Unknown
			Enabled = cfg.Bind<bool>("5 - Fogueira", "Enabled", true, "Seleção de personagem na fogueira / Campfire character selection");
			MaxSeats = cfg.Bind<int>("5 - Fogueira", "MaxSeats", 4, new ConfigDescription("Quantos personagens (do topo da lista) sentam na fogueira / How many characters (top of the list) sit at the campfire", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 8), Array.Empty<object>()));
			SeatRadius = cfg.Bind<float>("5 - Fogueira", "SeatRadius", 2.3f, "Distância dos personagens até a fogueira (m) / Distance from the campfire (m)");
			SeatArc = cfg.Bind<float>("5 - Fogueira", "SeatArc", 62f, new ConfigDescription("Abertura do arco de assentos (graus pra cada lado) / Seat arc (degrees to each side)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10f, 170f), Array.Empty<object>()));
			CameraDistance = cfg.Bind<float>("5 - Fogueira", "CameraDistance", 1f, new ConfigDescription("Multiplicador da distância da câmera / Camera distance multiplier", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 2.5f), Array.Empty<object>()));
			CameraHeight = cfg.Bind<float>("5 - Fogueira", "CameraHeight", 1.7f, "Altura da câmera (m) / Camera height (m)");
			CameraSmooth = cfg.Bind<float>("5 - Fogueira", "CameraSmooth", 3.5f, "Suavidade da câmera (maior = mais rápido) / Camera smoothing (higher = faster)");
			FocusDuration = cfg.Bind<float>("5 - Fogueira", "FocusDuration", 1.3f, "Duração da câmera indo até o personagem (s) / Camera move duration to the character (s)");
			FocusDistance = cfg.Bind<float>("5 - Fogueira", "FocusDistance", 2.1f, "Distância da câmera no close (m) / Close-up camera distance (m)");
			NameColor = cfg.Bind<Color>("5 - Fogueira", "NameColor", new Color(0.88f, 0.88f, 0.88f, 0.9f), "Cor do nome em cima da cabeça / Name color above the head");
			SelectedColor = cfg.Bind<Color>("5 - Fogueira", "SelectedColor", new Color(1f, 0.78f, 0.35f, 1f), "Cor do nome selecionado / Selected name color");
			SeatedColor = cfg.Bind<Color>("5 - Fogueira", "SeatedColor", new Color(1f, 0.62f, 0.2f, 0.9f), "Cor do losango dos que sentam na fogueira (lista) / Diamond color of seated characters (list)");
			NameSize = cfg.Bind<int>("5 - Fogueira", "NameSize", 30, new ConfigDescription("Tamanho do nome em cima da cabeça / Name size above the head", (AcceptableValueBase)(object)new AcceptableValueRange<int>(12, 72), Array.Empty<object>()));
			ShowRoster = cfg.Bind<bool>("5 - Fogueira", "ShowRoster", true, "Mostra a lista de personagens à direita / Show the character list on the right");
			ShowOnMainMenu = cfg.Bind<bool>("5 - Fogueira", "ShowOnMainMenu", true, "Personagens sentados na fogueira no menu principal / Characters sitting at the campfire on the main menu");
			RosterTitle = cfg.Bind<string>("5 - Fogueira", "RosterTitle", "", "Título da lista (vazio = automático PT/EN) / List title (empty = automatic PT/EN)");
			RosterHint = cfg.Bind<string>("5 - Fogueira", "RosterHint", "", "Dica embaixo da lista, {0} = assentos, \\n quebra linha (vazio = automático) / Hint below the list, {0} = seats, \\n = new line (empty = automatic)");
			SharpCamera = cfg.Bind<bool>("5 - Fogueira", "SharpCamera", true, "Desliga o desfoque (Depth of Field / motion blur) na fogueira / Disables blur (Depth of Field / motion blur) at the campfire");
		}
	}
	internal sealed class CampfireSelect : MonoBehaviour
	{
		private enum Phase
		{
			Off,
			Camp,
			Focus,
			Hold
		}

		internal sealed class Sitter
		{
			public PlayerProfile Profile;

			public int Slot;

			public GameObject Model;

			public Animator Animator;

			public Transform Head;

			public Quaternion SeatRotation;

			public Vector3 HomePos;

			public bool Standing;

			public bool Visible = true;

			public float LastShown;
		}

		private static readonly FieldRef<FejdStartup, List<PlayerProfile>> ProfilesRef = SafeRef<List<PlayerProfile>>("m_profiles");

		private static readonly FieldRef<FejdStartup, int> ProfileIndexRef = SafeRef<int>("m_profileIndex");

		private static readonly MethodInfo UpdateCharacterListMethod = AccessTools.Method(typeof(FejdStartup), "UpdateCharacterList", (Type[])null, (Type[])null);

		private static readonly MethodInfo OnCharacterStartMethod = AccessTools.Method(typeof(FejdStartup), "OnCharacterStart", (Type[])null, (Type[])null);

		private static readonly FieldInfo LeftButtonField = AccessTools.Field(typeof(FejdStartup), "m_csLeftButton");

		private static readonly FieldInfo RightButtonField = AccessTools.Field(typeof(FejdStartup), "m_csRightButton");

		internal static CampfireSelect Instance;

		private bool _ambient;

		internal static bool PassThroughStart;

		private FejdStartup _menu;

		private Camera _cam;

		private Phase _phase;

		private readonly List<Sitter> _sitters = new List<Sitter>();

		private Sitter _hover;

		private PlayerProfile _uiHover;

		private Sitter _focus;

		private CampUi _ui;

		private readonly CameraBlur _blur = new CameraBlur();

		private Vector3 _center;

		private Vector3 _away;

		private bool _campReady;

		private Vector3 _campPos;

		private Quaternion _campRot;

		private Vector3 _shotFromPos;

		private Vector3 _shotToPos;

		private Quaternion _shotFromRot;

		private Quaternion _shotToRot;

		private Quaternion _actorFrom;

		private Quaternion _actorTo;

		private float _shotStart;

		private int _layoutSeats = -1;

		private float _layoutRadius;

		private float _layoutArc;

		private static readonly int SitHash = Animator.StringToHash("Base Layer.Emote_sit");

		private static readonly int MoveHash = Animator.StringToHash("Base Layer.Movement");

		private bool _dragging;

		private Vector3 _lastMouse;

		private readonly List<RaycastResult> _uiHits = new List<RaycastResult>();

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

		private static readonly MethodInfo JoyRightXMethod = AccessTools.Method(AccessTools.TypeByName("ZInput"), "GetJoyRightStickX", (Type[])null, (Type[])null);

		private readonly List<Sitter> _seated = new List<Sitter>();

		private readonly Dictionary<PlayerProfile, Sitter> _solo = new Dictionary<PlayerProfile, Sitter>();

		private const int SoloCacheMax = 2;

		private const int SoloSlot = 100;

		internal static bool OwnsCamera
		{
			get
			{
				if ((Object)(object)Instance != (Object)null)
				{
					return Instance._phase != Phase.Off;
				}
				return false;
			}
		}

		internal static bool CampActive
		{
			get
			{
				if ((Object)(object)Instance != (Object)null)
				{
					if (Instance._phase == Phase.Off)
					{
						return Instance._ambient;
					}
					return true;
				}
				return false;
			}
		}

		internal bool IsTravelling
		{
			get
			{
				if (_phase != Phase.Focus)
				{
					return _phase == Phase.Hold;
				}
				return true;
			}
		}

		internal IReadOnlyList<Sitter> Sitters => _sitters;

		internal Camera Cam => _cam;

		private static FieldRef<FejdStartup, T> SafeRef<T>(string field)
		{
			try
			{
				return AccessTools.FieldRefAccess<FejdStartup, T>(field);
			}
			catch
			{
				return null;
			}
		}

		internal void Init(FejdStartup menu)
		{
			_menu = menu;
			Instance = this;
			_ui = new CampUi(this, ((Component)menu).transform);
		}

		private void OnDestroy()
		{
			ClearSitters();
			_ui?.Destroy();
			_blur.Restore();
			if ((Object)(object)Instance == (Object)(object)this)
			{
				Instance = null;
			}
			PassThroughStart = false;
		}

		private void Update()
		{
			if ((Object)(object)_menu == (Object)null)
			{
				return;
			}
			if ((Object)(object)_cam == (Object)null)
			{
				_cam = Camera.main;
			}
			if (!CampConfig.Enabled.Value || !((Object)(object)_cam != (Object)null) || !InCharacterSelect() || ProfileCount() <= 0)
			{
				bool flag = CampConfig.Enabled.Value && CampConfig.ShowOnMainMenu.Value && (Object)(object)_cam != (Object)null && (Object)(object)_menu.m_mainMenu != (Object)null && _menu.m_mainMenu.activeInHierarchy;
				if ((Object)(object)_menu.m_newCharacterPanel != (Object)null && _menu.m_newCharacterPanel.activeInHierarchy)
				{
					ShowPreviewForCreation();
				}
				if (_phase == Phase.Camp)
				{
					Release(flag);
				}
				if ((_phase == Phase.Focus || _phase == Phase.Hold) && !InWorldSelect())
				{
					Release(flag);
				}
				if (_phase == Phase.Off)
				{
					_ambient = flag && EnsureProfiles() > 0;
					if (_ambient)
					{
						if (!_campReady)
						{
							SetupCamp();
						}
						SyncSitters();
						HidePreview();
					}
					else if (_sitters.Count > 0)
					{
						ClearSitters();
					}
				}
				_ui.Tick(visible: false);
				return;
			}
			_ambient = false;
			if (_phase == Phase.Off || _phase == Phase.Hold)
			{
				if (_phase == Phase.Hold)
				{
					SitAllDown();
				}
				_phase = Phase.Camp;
				_focus = null;
			}
			if (!_campReady)
			{
				SetupCamp();
			}
			SetArrowsVisible(visible: false);
			SyncSitters();
			SyncArrowInteractable();
			HidePreview();
			bool flag2 = (Object)(object)_menu.m_removeCharacterDialog != (Object)null && _menu.m_removeCharacterDialog.activeInHierarchy;
			if (_phase == Phase.Camp)
			{
				ComputeCampShot();
				if (!flag2)
				{
					HandlePointer();
				}
			}
			_ui.Tick(_phase == Phase.Camp && !flag2);
		}

		private void LateUpdate()
		{
			//IL_0073: 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_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: 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_00e5: 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_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			if (_phase == Phase.Off || (Object)(object)_cam == (Object)null)
			{
				return;
			}
			_blur.Suppress(_cam);
			Transform transform = ((Component)_cam).transform;
			switch (_phase)
			{
			case Phase.Camp:
			{
				float num4 = 1f - Mathf.Exp((0f - CampConfig.CameraSmooth.Value) * Time.unscaledDeltaTime);
				transform.SetPositionAndRotation(Vector3.Lerp(transform.position, _campPos, num4), Quaternion.Slerp(transform.rotation, _campRot, num4));
				break;
			}
			case Phase.Focus:
			{
				float num = Mathf.Max(0.1f, CampConfig.FocusDuration.Value);
				float num2 = Mathf.Clamp01((Time.unscaledTime - _shotStart) / num);
				float num3 = Mathf.SmoothStep(0f, 1f, num2);
				transform.SetPositionAndRotation(Vector3.Lerp(_shotFromPos, _shotToPos, num3), Quaternion.Slerp(_shotFromRot, _shotToRot, num3));
				if ((Object)(object)_focus?.Model != (Object)null)
				{
					_focus.Model.transform.rotation = Quaternion.Slerp(_actorFrom, _actorTo, Mathf.SmoothStep(0f, 1f, Mathf.Clamp01(num2 * 1.6f)));
				}
				if (num2 >= 1f)
				{
					EnterWorldSelect();
				}
				break;
			}
			case Phase.Hold:
				transform.SetPositionAndRotation(_shotToPos, _shotToRot);
				RotateFocused();
				break;
			}
			_ui.UpdateNames(_phase == Phase.Camp);
		}

		private void RotateFocused()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_focus?.Model == (Object)null))
			{
				Transform transform = _focus.Model.transform;
				Vector3 mousePosition = Input.mousePosition;
				if (Input.GetMouseButtonDown(0))
				{
					_dragging = !PointerOverPanel();
				}
				else if (!Input.GetMouseButton(0))
				{
					_dragging = false;
				}
				if (_dragging)
				{
					transform.Rotate(0f, (0f - (mousePosition.x - _lastMouse.x)) * _menu.m_characterRotateSpeed * 0.1f, 0f);
				}
				_lastMouse = mousePosition;
				float num = JoyRightX();
				if (Mathf.Abs(num) > 0.05f)
				{
					transform.Rotate(0f, (0f - num) * _menu.m_characterRotateSpeedGamepad * Time.unscaledDeltaTime, 0f);
				}
			}
		}

		private bool PointerOverPanel()
		{
			//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_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			//IL_0053: 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_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: 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_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: 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_00ed: Unknown result type (might be due to invalid IL or missing references)
			EventSystem current = EventSystem.current;
			if ((Object)(object)current == (Object)null)
			{
				return false;
			}
			PointerEventData val = new PointerEventData(current)
			{
				position = Vector2.op_Implicit(Input.mousePosition)
			};
			_uiHits.Clear();
			current.RaycastAll(val, _uiHits);
			foreach (RaycastResult uiHit in _uiHits)
			{
				RaycastResult current2 = uiHit;
				if ((Object)(object)((RaycastResult)(ref current2)).gameObject == (Object)null)
				{
					continue;
				}
				Transform transform = ((RaycastResult)(ref current2)).gameObject.transform;
				RectTransform val2 = (RectTransform)(object)((transform is RectTransform) ? transform : null);
				if (val2 != null)
				{
					val2.GetWorldCorners(_uiCorners);
					Camera obj = (((Object)(object)current2.module != (Object)null) ? current2.module.eventCamera : null);
					Vector2 val3 = RectTransformUtility.WorldToScreenPoint(obj, _uiCorners[0]);
					Vector2 val4 = RectTransformUtility.WorldToScreenPoint(obj, _uiCorners[2]);
					float num = Mathf.Abs(val4.x - val3.x);
					float num2 = Mathf.Abs(val4.y - val3.y);
					if (!(num >= (float)Screen.width * 0.8f) || !(num2 >= (float)Screen.height * 0.8f))
					{
						return true;
					}
				}
			}
			return false;
		}

		private static float JoyRightX()
		{
			if (JoyRightXMethod == null)
			{
				return 0f;
			}
			try
			{
				ParameterInfo[] parameters = JoyRightXMethod.GetParameters();
				object[] array = new object[parameters.Length];
				for (int i = 0; i < parameters.Length; i++)
				{
					array[i] = (parameters[i].HasDefaultValue ? parameters[i].DefaultValue : null);
				}
				return (JoyRightXMethod.Invoke(null, array) is float num) ? num : 0f;
			}
			catch
			{
				return 0f;
			}
		}

		internal bool InCreation()
		{
			if ((Object)(object)_menu.m_newCharacterPanel != (Object)null)
			{
				return _menu.m_newCharacterPanel.activeInHierarchy;
			}
			return false;
		}

		internal bool InCharacterSelect()
		{
			if ((Object)(object)_menu.m_characterSelectScreen == (Object)null || !_menu.m_characterSelectScreen.activeInHierarchy)
			{
				return false;
			}
			if ((Object)(object)_menu.m_newCharacterPanel != (Object)null && _menu.m_newCharacterPanel.activeInHierarchy)
			{
				return false;
			}
			if ((Object)(object)_menu.m_selectCharacterPanel != (Object)null && !_menu.m_selectCharacterPanel.activeInHierarchy)
			{
				return false;
			}
			return true;
		}

		private bool InWorldSelect()
		{
			if (((Object)(object)_menu.m_characterSelectScreen == (Object)null || !_menu.m_characterSelectScreen.activeInHierarchy) && ((Object)(object)_menu.m_mainMenu == (Object)null || !_menu.m_mainMenu.activeInHierarchy))
			{
				if (!((Object)(object)_menu.m_manageSavesMenu == (Object)null))
				{
					return !_menu.m_manageSavesMenu.IsVisible();
				}
				return true;
			}
			return false;
		}

		internal List<PlayerProfile> Profiles()
		{
			if (ProfilesRef == null)
			{
				return null;
			}
			return ProfilesRef.Invoke(_menu);
		}

		private int ProfileCount()
		{
			return Profiles()?.Count ?? 0;
		}

		private int EnsureProfiles()
		{
			if (ProfilesRef == null)
			{
				return 0;
			}
			if (ProfilesRef.Invoke(_menu) == null)
			{
				try
				{
					ProfilesRef.Invoke(_menu) = SaveSystem.GetAllPlayerProfiles();
				}
				catch (Exception ex)
				{
					Plugin.Log.LogDebug((object)("[Fogueira] perfis: " + ex.Message));
				}
			}
			return ProfileCount();
		}

		internal PlayerProfile SelectedProfile()
		{
			List<PlayerProfile> list = Profiles();
			if (list == null || list.Count == 0 || ProfileIndexRef == null)
			{
				return null;
			}
			return list[Mathf.Clamp(ProfileIndexRef.Invoke(_menu), 0, list.Count - 1)];
		}

		internal bool StepRoster(int dir)
		{
			if (IsTravelling)
			{
				return true;
			}
			if (_phase != Phase.Camp)
			{
				return false;
			}
			List<PlayerProfile> list = RosterOrder.Ordered(Profiles());
			if (list == null || list.Count == 0)
			{
				return false;
			}
			int num = list.IndexOf(SelectedProfile());
			int num2 = Mathf.Clamp(((num >= 0) ? num : 0) + dir, 0, list.Count - 1);
			if (num2 != num)
			{
				Select(list[num2]);
			}
			return true;
		}

		internal void Select(PlayerProfile profile)
		{
			List<PlayerProfile> list = Profiles();
			if (list == null || ProfileIndexRef == null)
			{
				return;
			}
			int num = list.IndexOf(profile);
			if (num < 0 || num == ProfileIndexRef.Invoke(_menu))
			{
				return;
			}
			ProfileIndexRef.Invoke(_menu) = num;
			try
			{
				UpdateCharacterListMethod?.Invoke(_menu, null);
			}
			catch (Exception ex)
			{
				Plugin.Log.LogDebug((object)("[Fogueira] UpdateCharacterList: " + ex.Message));
			}
		}

		private void Release(bool keepSitters = false)
		{
			_phase = Phase.Off;
			_focus = null;
			_hover = null;
			_uiHover = null;
			if (keepSitters)
			{
				SitAllDown();
			}
			else
			{
				ClearSitters();
			}
			if (!keepSitters)
			{
				RestorePreview();
			}
			_blur.Restore();
			SetArrowsVisible(visible: true);
			RestoreArrowInteractable();
		}

		private void RestoreArrowInteractable()
		{
			int num = Profiles()?.Count ?? 0;
			int num2 = ((ProfileIndexRef != null && (Object)(object)_menu != (Object)null) ? ProfileIndexRef.Invoke(_menu) : 0);
			object? obj = LeftButtonField?.GetValue(_menu);
			Selectable val = (Selectable)((obj is Selectable) ? obj : null);
			if (val != null)
			{
				val.interactable = num2 > 0;
			}
			object? obj2 = RightButtonField?.GetValue(_menu);
			Selectable val2 = (Selectable)((obj2 is Selectable) ? obj2 : null);
			if (val2 != null)
			{
				val2.interactable = num2 < num - 1;
			}
		}

		private void SyncArrowInteractable()
		{
			List<PlayerProfile> list = RosterOrder.Ordered(Profiles());
			if (list != null)
			{
				int num = list.IndexOf(SelectedProfile());
				object? obj = LeftButtonField?.GetValue(_menu);
				Selectable val = (Selectable)((obj is Selectable) ? obj : null);
				if (val != null)
				{
					val.interactable = num > 0;
				}
				object? obj2 = RightButtonField?.GetValue(_menu);
				Selectable val2 = (Selectable)((obj2 is Selectable) ? obj2 : null);
				if (val2 != null)
				{
					val2.interactable = num >= 0 && num < list.Count - 1;
				}
			}
		}

		private void SetArrowsVisible(bool visible)
		{
			FieldInfo[] array = new FieldInfo[2] { LeftButtonField, RightButtonField };
			foreach (FieldInfo fieldInfo in array)
			{
				if (!(fieldInfo == null))
				{
					Component val = null;
					try
					{
						object? value = fieldInfo.GetValue(_menu);
						val = (Component)((value is Component) ? value : null);
					}
					catch
					{
					}
					if ((Object)(object)val != (Object)null && val.gameObject.activeSelf != visible)
					{
						val.gameObject.SetActive(visible);
					}
				}
			}
		}

		private void SetupCamp()
		{
			//IL_0047: 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_0030: 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_003f: 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_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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: 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_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: 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_00ec: Unknown result type (might be due to invalid IL or missing references)
			Transform characterPreviewPoint = _menu.m_characterPreviewPoint;
			Vector3 val = (((Object)(object)characterPreviewPoint != (Object)null) ? characterPreviewPoint.position : (((Component)_cam).transform.position + ((Component)_cam).transform.forward * 5f));
			_center = FindFire(val, out var source);
			_center.y = val.y;
			Vector3 val2 = (((Object)(object)_menu.m_cameraMarkerCharacter != (Object)null) ? _menu.m_cameraMarkerCharacter.position : ((Component)_cam).transform.position);
			_away = Vector3.ProjectOnPlane(_center - val2, Vector3.up);
			if (((Vector3)(ref _away)).sqrMagnitude < 0.01f)
			{
				_away = (((Object)(object)characterPreviewPoint != (Object)null) ? (-characterPreviewPoint.forward) : Vector3.forward);
			}
			((Vector3)(ref _away)).Normalize();
			ComputeCampShot();
			_campReady = true;
			Plugin.Log.LogDebug((object)$"[Fogueira] centro {_center} ({source})");
		}

		private void ComputeCampShot()
		{
			//IL_0093: 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_009f: 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_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//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_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			float value = CampConfig.SeatRadius.Value;
			float num = CampConfig.SeatArc.Value * (MathF.PI / 180f);
			float num2 = value * Mathf.Sin(Mathf.Min(num, MathF.PI / 2f)) + 0.9f;
			float num3 = Mathf.Atan(Mathf.Tan(_cam.fieldOfView * 0.5f * (MathF.PI / 180f)) * Mathf.Max(1f, _cam.aspect));
			float num4 = (num2 / Mathf.Tan(num3) + 1.2f) * CampConfig.CameraDistance.Value;
			num4 = Mathf.Max(3.5f, num4);
			_campPos = _center - _away * num4 + Vector3.up * CampConfig.CameraHeight.Value;
			Vector3 val = _center + _away * (value * 0.35f) + Vector3.up * 0.75f;
			_campRot = Quaternion.LookRotation(val - _campPos, Vector3.up);
		}

		private static Vector3 FindFire(Vector3 origin, out string source)
		{
			//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_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: 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)
			//IL_0187: 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_0192: 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_017a: Unknown result type (might be due to invalid IL or missing references)
			Scene activeScene = SceneManager.GetActiveScene();
			Transform val = null;
			float num = 324f;
			GameObject[] rootGameObjects = ((Scene)(ref activeScene)).GetRootGameObjects();
			Vector3 val3;
			for (int i = 0; i < rootGameObjects.Length; i++)
			{
				Transform[] componentsInChildren = rootGameObjects[i].GetComponentsInChildren<Transform>(true);
				foreach (Transform val2 in componentsInChildren)
				{
					string text = ((Object)val2).name.ToLowerInvariant();
					if (text.StartsWith("fire_pit") || text.StartsWith("campfire") || text.StartsWith("firepit") || text == "fire")
					{
						val3 = val2.position - origin;
						float sqrMagnitude = ((Vector3)(ref val3)).sqrMagnitude;
						if (sqrMagnitude < num)
						{
							num = sqrMagnitude;
							val = val2;
						}
					}
				}
			}
			if ((Object)(object)val != (Object)null)
			{
				source = ((Object)val).name;
				return val.position;
			}
			float num2 = 100f;
			ParticleSystem val4 = null;
			ParticleSystem[] array = Object.FindObjectsByType<ParticleSystem>((FindObjectsSortMode)0);
			foreach (ParticleSystem val5 in array)
			{
				string text2 = ((Object)val5).name.ToLowerInvariant();
				if (text2.Contains("fire") || text2.Contains("flame"))
				{
					val3 = ((Component)val5).transform.position - origin;
					float sqrMagnitude2 = ((Vector3)(ref val3)).sqrMagnitude;
					if (sqrMagnitude2 < num2)
					{
						num2 = sqrMagnitude2;
						val4 = val5;
					}
				}
			}
			if ((Object)(object)val4 != (Object)null)
			{
				source = "partícula " + ((Object)val4).name;
				return ((Component)val4).transform.position;
			}
			source = "sem fogueira, na frente do preview";
			return origin + Vector3.forward * 2.2f;
		}

		private void SyncSitters()
		{
			//IL_00e7: 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_00f0: 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_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: 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)
			List<PlayerProfile> list = Profiles();
			if (_uiHover != null && (list == null || !list.Contains(_uiHover)))
			{
				_uiHover = null;
			}
			List<PlayerProfile> list2 = RosterOrder.Ordered(list);
			int num = Mathf.Min(CampConfig.MaxSeats.Value, list2.Count);
			PlayerProfile val = SelectedProfile();
			if (_layoutSeats != num || !Mathf.Approximately(_layoutRadius, CampConfig.SeatRadius.Value) || !Mathf.Approximately(_layoutArc, CampConfig.SeatArc.Value))
			{
				_layoutSeats = num;
				_layoutRadius = CampConfig.SeatRadius.Value;
				_layoutArc = CampConfig.SeatArc.Value;
				foreach (Sitter item in AllSitters())
				{
					if (!((Object)(object)item.Model == (Object)null))
					{
						SeatPose(item.Slot, num, out var pos, out var rot);
						item.HomePos = pos;
						item.SeatRotation = rot;
						item.Model.transform.rotation = rot;
						PlaceModel(item);
					}
				}
			}
			for (int num2 = _seated.Count - 1; num2 >= 0; num2--)
			{
				Sitter sitter = _seated[num2];
				if (!((Object)(object)sitter.Model != (Object)null) || sitter.Slot >= num || list2[sitter.Slot] != sitter.Profile)
				{
					DestroySitter(sitter);
					_seated.RemoveAt(num2);
				}
			}
			int slot;
			for (slot = 0; slot < num; slot++)
			{
				if (!_seated.Exists((Sitter x) => x.Slot == slot))
				{
					SeatPose(slot, num, out var pos2, out var rot2);
					Sitter sitter2 = SpawnSitter(list2[slot], slot, pos2, rot2);
					if (sitter2 != null)
					{
						_seated.Add(sitter2);
					}
				}
			}
			PlayerProfile val2 = null;
			if (_phase != Phase.Off && val != null && !IsSeated(list2, num, val))
			{
				val2 = val;
			}
			if (val2 != null && !_solo.ContainsKey(val2))
			{
				SeatPose(100, num, out var pos3, out var rot3);
				Sitter sitter3 = SpawnSitter(val2, 100, pos3, rot3);
				if (sitter3 != null)
				{
					_solo[val2] = sitter3;
				}
			}
			foreach (Sitter item2 in _seated)
			{
				SetVisible(item2, val2 == null);
			}
			foreach (KeyValuePair<PlayerProfile, Sitter> item3 in _solo)
			{
				SetVisible(item3.Value, item3.Key == val2);
			}
			PruneSoloCache(list, val2);
			_sitters.Clear();
			foreach (Sitter item4 in AllSitters())
			{
				if (item4.Visible && (Object)(object)item4.Model != (Object)null)
				{
					_sitters.Add(item4);
				}
			}
			if (_hover != null && !_hover.Visible)
			{
				_hover = null;
			}
			RefreshStanding();
		}

		private static bool IsSeated(List<PlayerProfile> ordered, int seats, PlayerProfile p)
		{
			for (int i = 0; i < seats; i++)
			{
				if (ordered[i] == p)
				{
					return true;
				}
			}
			return false;
		}

		private IEnumerable<Sitter> AllSitters()
		{
			foreach (Sitter item in _seated)
			{
				yield return item;
			}
			foreach (Sitter value in _solo.Values)
			{
				yield return value;
			}
		}

		private void SetVisible(Sitter s, bool visible)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)s.Model == (Object)null) && s.Visible != visible)
			{
				s.Visible = visible;
				if (visible)
				{
					s.LastShown = Time.unscaledTime;
					s.Model.transform.rotation = s.SeatRotation;
					SetSitting(s, sit: true, instant: true);
				}
				PlaceModel(s);
			}
		}

		private static void PlaceModel(Sitter s)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: 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_0037: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)s.Model == (Object)null))
			{
				s.Model.transform.position = (s.Visible ? s.HomePos : (s.HomePos + Vector3.down * 500f));
			}
		}

		private void PruneSoloCache(List<PlayerProfile> profiles, PlayerProfile keep)
		{
			List<PlayerProfile> list = null;
			foreach (KeyValuePair<PlayerProfile, Sitter> item in _solo)
			{
				if (profiles == null || !profiles.Contains(item.Key) || (Object)(object)item.Value.Model == (Object)null)
				{
					(list ?? (list = new List<PlayerProfile>())).Add(item.Key);
				}
			}
			if (list != null)
			{
				foreach (PlayerProfile item2 in list)
				{
					DestroySitter(_solo[item2]);
					_solo.Remove(item2);
				}
			}
			while (_solo.Count > 2)
			{
				PlayerProfile val = null;
				float num = float.MaxValue;
				foreach (KeyValuePair<PlayerProfile, Sitter> item3 in _solo)
				{
					if (item3.Key != keep && item3.Value.LastShown < num)
					{
						num = item3.Value.LastShown;
						val = item3.Key;
					}
				}
				if (val != null)
				{
					DestroySitter(_solo[val]);
					_solo.Remove(val);
					continue;
				}
				break;
			}
		}

		private void DestroySitter(Sitter s)
		{
			if (s == _hover)
			{
				_hover = null;
			}
			if (s == _focus)
			{
				_focus = null;
			}
			if ((Object)(object)s.Model != (Object)null)
			{
				Object.Destroy((Object)(object)s.Model);
			}
		}

		private void SeatPose(int slot, int seats, out Vector3 pos, out Quaternion rot)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: 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_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: 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_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_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: 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_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			float value = CampConfig.SeatRadius.Value;
			if (slot == 100)
			{
				pos = SnapToGround(_center + _away * value);
				rot = Quaternion.LookRotation(Vector3.ProjectOnPlane(_center - pos, Vector3.up), Vector3.up);
				return;
			}
			float value2 = CampConfig.SeatArc.Value;
			float num = ((seats <= 1) ? 0.5f : ((float)slot / (float)(seats - 1)));
			Vector3 val = Quaternion.AngleAxis(Mathf.Lerp(0f - value2, value2, num), Vector3.up) * _away;
			pos = SnapToGround(_center + val * value);
			rot = Quaternion.LookRotation(Vector3.ProjectOnPlane(_center - pos, Vector3.up), Vector3.up);
		}

		private Sitter SpawnSitter(PlayerProfile profile, int slot, Vector3 pos, Quaternion rot)
		{
			//IL_0019: 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_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: 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)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = null;
			bool forceDisableInit = ZNetView.m_forceDisableInit;
			try
			{
				ZNetView.m_forceDisableInit = true;
				val = Object.Instantiate<GameObject>(_menu.m_playerPrefab, pos, rot);
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("[Fogueira] falha criando " + ((profile != null) ? profile.GetName() : null) + ": " + ex.Message));
				if ((Object)(object)val != (Object)null)
				{
					Object.Destroy((Object)(object)val);
				}
				return null;
			}
			finally
			{
				ZNetView.m_forceDisableInit = forceDisableInit;
			}
			((Object)val).name = "ValheimMenu_Sitter_" + slot;
			FootStep[] componentsInChildren = val.GetComponentsInChildren<FootStep>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren[i]);
			}
			Rigidbody component = val.GetComponent<Rigidbody>();
			if ((Object)(object)component != (Object)null)
			{
				Object.Destroy((Object)(object)component);
			}
			Collider[] componentsInChildren2 = val.GetComponentsInChildren<Collider>(true);
			for (int i = 0; i < componentsInChildren2.Length; i++)
			{
				componentsInChildren2[i].enabled = false;
			}
			Animator componentInChildren = val.GetComponentInChildren<Animator>();
			Animator[] componentsInChildren3 = val.GetComponentsInChildren<Animator>(true);
			foreach (Animator obj in componentsInChildren3)
			{
				obj.updateMode = (AnimatorUpdateMode)0;
				obj.cullingMode = (AnimatorCullingMode)0;
			}
			Player component2 = val.GetComponent<Player>();
			try
			{
				profile.LoadPlayerData(component2);
			}
			catch (Exception ex2)
			{
				Plugin.Log.LogWarning((object)("[Fogueira] dados de " + profile.GetName() + ": " + ex2.Message));
			}
			if ((Object)(object)component2 != (Object)null)
			{
				((Behaviour)component2).enabled = false;
			}
			Sitter sitter = new Sitter
			{
				Profile = profile,
				Slot = slot,
				Model = val,
				Animator = componentInChildren,
				Head = FindHead(val.transform, componentInChildren),
				SeatRotation = rot,
				HomePos = pos,
				LastShown = Time.unscaledTime
			};
			SetSitting(sitter, sit: true, instant: true);
			return sitter;
		}

		private void SetSitting(Sitter s, bool sit, bool instant)
		{
			if ((Object)(object)s.Animator == (Object)null)
			{
				return;
			}
			s.Standing = !sit;
			s.Animator.SetBool("emote_sit", sit);
			if (sit)
			{
				s.Animator.ResetTrigger("emote_stop");
			}
			int num = (sit ? SitHash : MoveHash);
			if (s.Animator.HasState(0, num))
			{
				if (instant)
				{
					s.Animator.Play(num, 0, Random.value);
				}
				else
				{
					s.Animator.CrossFadeInFixedTime(num, 0.35f, 0);
				}
			}
		}

		private void RefreshStanding()
		{
			PlayerProfile val = SelectedProfile();
			foreach (Sitter sitter in _sitters)
			{
				bool flag = sitter == _hover || sitter == _focus || sitter.Profile == _uiHover || (sitter.Profile == val && _phase != Phase.Off);
				if (flag != sitter.Standing)
				{
					SetSitting(sitter, !flag, instant: false);
				}
			}
		}

		private void SitAllDown()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			foreach (Sitter item in AllSitters())
			{
				if ((Object)(object)item.Model != (Object)null)
				{
					item.Model.transform.rotation = item.SeatRotation;
				}
				if (item.Standing)
				{
					SetSitting(item, sit: true, instant: false);
				}
			}
		}

		private void ClearSitters()
		{
			foreach (Sitter item in AllSitters())
			{
				if ((Object)(object)item.Model != (Object)null)
				{
					Object.Destroy((Object)(object)item.Model);
				}
			}
			_seated.Clear();
			_solo.Clear();
			_sitters.Clear();
			_hover = null;
			_layoutSeats = -1;
		}

		private static Transform FindHead(Transform root, Animator anim)
		{
			if ((Object)(object)anim != (Object)null && anim.isHuman)
			{
				Transform boneTransform = anim.GetBoneTransform((HumanBodyBones)10);
				if ((Object)(object)boneTransform != (Object)null)
				{
					return boneTransform;
				}
			}
			Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren<Transform>(true);
			foreach (Transform val in componentsInChildren)
			{
				if (((Object)val).name.Equals("Head", StringComparison.OrdinalIgnoreCase))
				{
					return val;
				}
			}
			return null;
		}

		private static Vector3 SnapToGround(Vector3 p)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			int mask = LayerMask.GetMask(new string[3] { "terrain", "static_solid", "Default" });
			RaycastHit val = default(RaycastHit);
			if (Physics.Raycast(p + Vector3.up * 3f, Vector3.down, ref val, 6f, mask, (QueryTriggerInteraction)1))
			{
				p.y = ((RaycastHit)(ref val)).point.y;
			}
			return p;
		}

		internal Vector3 HeadPos(Sitter s)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: 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)
			if ((Object)(object)s.Head != (Object)null)
			{
				return s.Head.position;
			}
			return s.Model.transform.position + Vector3.up * (s.Standing ? 1.75f : 1.15f);
		}

		internal void SetUiHover(PlayerProfile p)
		{
			_uiHover = p;
			RefreshStanding();
		}

		internal void OnRosterClick(PlayerProfile p)
		{
			if (_phase == Phase.Camp && p != SelectedProfile())
			{
				Select(p);
			}
		}

		private void HandlePointer()
		{
			Sitter sitter = (((Object)(object)EventSystem.current != (Object)null && EventSystem.current.IsPointerOverGameObject()) ? null : PickUnderMouse());
			if (sitter != _hover)
			{
				_hover = sitter;
				RefreshStanding();
			}
			if (sitter != null && Input.GetMouseButtonDown(0) && sitter.Profile != SelectedProfile())
			{
				UiSfx.Click();
				Select(sitter.Profile);
			}
		}

		private Sitter PickUnderMouse()
		{
			//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_004c: 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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: 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)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			Vector3 mousePosition = Input.mousePosition;
			Sitter result = null;
			float num = float.MaxValue;
			foreach (Sitter sitter in _sitters)
			{
				if ((Object)(object)sitter.Model == (Object)null)
				{
					continue;
				}
				Vector3 val = _cam.WorldToScreenPoint(sitter.Model.transform.position);
				Vector3 val2 = _cam.WorldToScreenPoint(HeadPos(sitter) + Vector3.up * 0.25f);
				if (!(val.z <= 0f) && !(val2.z <= 0f))
				{
					float num2 = Mathf.Abs(val2.y - val.y);
					float num3 = Mathf.Max(18f, num2 * 0.24f);
					float num4 = Mathf.Min(val.y, val2.y);
					float num5 = Mathf.Max(val.y, val2.y);
					float num6 = (val.x + val2.x) * 0.5f;
					if (!(mousePosition.x < num6 - num3) && !(mousePosition.x > num6 + num3) && !(mousePosition.y < num4) && !(mousePosition.y > num5) && val.z < num)
					{
						num = val.z;
						result = sitter;
					}
				}
			}
			return result;
		}

		internal bool TryBeginFocusFromStart()
		{
			if (_phase != Phase.Camp)
			{
				return false;
			}
			PlayerProfile selected = SelectedProfile();
			Sitter sitter = _sitters.Find((Sitter x) => x.Profile == selected);
			if (sitter == null || (Object)(object)sitter.Model == (Object)null)
			{
				return false;
			}
			BeginFocus(sitter);
			return true;
		}

		private void BeginFocus(Sitter s)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_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_006d: 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_0094: 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_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: 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_00fb: Unknown result type (might be due to invalid IL or missing references)
			//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_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: 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_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: 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_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: 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_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: 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)
			_focus = s;
			_hover = null;
			_uiHover = null;
			_phase = Phase.Focus;
			_shotStart = Time.unscaledTime;
			Transform transform = ((Component)_cam).transform;
			_shotFromPos = transform.position;
			_shotFromRot = transform.rotation;
			Vector3 position = s.Model.transform.position;
			Vector3 val = Vector3.ProjectOnPlane(_campPos - position, Vector3.up);
			if (((Vector3)(ref val)).sqrMagnitude < 0.01f)
			{
				val = -_away;
			}
			((Vector3)(ref val)).Normalize();
			Vector3 val2 = Vector3.Cross(Vector3.up, val);
			Vector3 normalized = ((Vector3)(ref val2)).normalized;
			float value = CampConfig.FocusDistance.Value;
			_shotToPos = position + val * value + Vector3.up * 1.5f - normalized * (value * 0.28f);
			Vector3 val3 = position + Vector3.up * 1.2f - normalized * (value * 0.28f) + normalized * 0.35f;
			_shotToRot = Quaternion.LookRotation(val3 - _shotToPos, Vector3.up);
			_actorFrom = s.Model.transform.rotation;
			_actorTo = Quaternion.LookRotation(val, Vector3.up);
			RefreshStanding();
			if ((Object)(object)EventSystem.current != (Object)null)
			{
				EventSystem.current.SetSelectedGameObject((GameObject)null);
			}
		}

		private void EnterWorldSelect()
		{
			_phase = Phase.Hold;
			PassThroughStart = true;
			try
			{
				OnCharacterStartMethod?.Invoke(_menu, null);
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("[Fogueira] OnCharacterStart: " + ex.Message));
			}
			finally
			{
				PassThroughStart = false;
			}
		}

		internal void HidePreview()
		{
			GameObject val = null;
			Player previewPlayer = _menu.GetPreviewPlayer();
			if ((Object)(object)previewPlayer != (Object)null)
			{
				val = ((Component)previewPlayer).gameObject;
			}
			if (!((Object)(object)val == (Object)null) && val.activeSelf)
			{
				val.SetActive(false);
			}
		}

		private void ShowPreviewForCreation()
		{
			GameObject val = null;
			Player previewPlayer = _menu.GetPreviewPlayer();
			if ((Object)(object)previewPlayer != (Object)null)
			{
				val = ((Component)previewPlayer).gameObject;
			}
			if ((Object)(object)val != (Object)null && !val.activeSelf)
			{
				val.SetActive(true);
			}
		}

		private void RestorePreview()
		{
			if ((Object)(object)_menu == (Object)null || !InCharacterSelect())
			{
				return;
			}
			try
			{
				UpdateCharacterListMethod?.Invoke(_menu, null);
			}
			catch (Exception ex)
			{
				Plugin.Log.LogDebug((object)("[Fogueira] restaurar preview: " + ex.Message));
			}
		}
	}
	internal static class RosterOrder
	{
		private static List<string> _keys;

		private static readonly FieldRef<PlayerProfile, string> FilenameRef = SafeFilename();

		private static int _version;

		private static List<PlayerProfile> _cacheSource;

		private static int _cacheCount = -1;

		private static int _cacheVersion = -1;

		private static List<PlayerProfile> _cacheResult = new List<PlayerProfile>();

		private static string FilePath => Path.Combine(Paths.ConfigPath, "ValheimMenu", "roster_order.txt");

		private static FieldRef<PlayerProfile, string> SafeFilename()
		{
			try
			{
				return AccessTools.FieldRefAccess<PlayerProfile, string>("m_filename");
			}
			catch
			{
				return null;
			}
		}

		internal static string Key(PlayerProfile p)
		{
			string text = null;
			try
			{
				FieldRef<PlayerProfile, string> filenameRef = FilenameRef;
				text = ((filenameRef != null) ? filenameRef.Invoke(p) : null);
			}
			catch
			{
			}
			if (!string.IsNullOrEmpty(text))
			{
				return text;
			}
			return p.GetName();
		}

		private static List<string> Keys()
		{
			if (_keys != null)
			{
				return _keys;
			}
			_keys = new List<string>();
			try
			{
				if (File.Exists(FilePath))
				{
					_keys.AddRange(from l in File.ReadAllLines(FilePath)
						select l.Trim() into l
						where l.Length > 0
						select l);
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("[Lista] não leu ordem: " + ex.Message));
			}
			return _keys;
		}

		internal static List<PlayerProfile> Ordered(List<PlayerProfile> profiles)
		{
			if (profiles == null)
			{
				return new List<PlayerProfile>();
			}
			if (profiles == _cacheSource && profiles.Count == _cacheCount && _cacheVersion == _version)
			{
				return _cacheResult;
			}
			List<PlayerProfile> list = new List<PlayerProfile>();
			Dictionary<string, PlayerProfile> dictionary = new Dictionary<string, PlayerProfile>();
			foreach (PlayerProfile profile in profiles)
			{
				dictionary[Key(profile)] = profile;
			}
			foreach (string item in Keys())
			{
				if (dictionary.TryGetValue(item, out var value) && !list.Contains(value))
				{
					list.Add(value);
				}
			}
			foreach (PlayerProfile profile2 in profiles)
			{
				if (!list.Contains(profile2))
				{
					list.Add(profile2);
				}
			}
			_cacheSource = profiles;
			_cacheCount = profiles.Count;
			_cacheVersion = _version;
			_cacheResult = list;
			return list;
		}

		internal static void Invalidate()
		{
			_version++;
		}

		internal static void Save(IEnumerable<PlayerProfile> ordered)
		{
			_keys = ordered.Select(Key).ToList();
			_version++;
			try
			{
				Directory.CreateDirectory(Path.GetDirectoryName(FilePath));
				File.WriteAllLines(FilePath, _keys);
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("[Lista] não salvou ordem: " + ex.Message));
			}
		}
	}
	internal static class UiSfx
	{
		private static GameObject _click;

		private static float _nextAllowed;

		internal static void Click()
		{
			if (!(Time.unscaledTime < _nextAllowed))
			{
				GameObject val = ClickPrefab();
				if (!((Object)(object)val == (Object)null))
				{
					_nextAllowed = Time.unscaledTime + 0.05f;
					Object.Instantiate<GameObject>(val);
				}
			}
		}

		private static GameObject ClickPrefab()
		{
			if ((Object)(object)_click != (Object)null)
			{
				return _click;
			}
			if ((Object)(object)FejdStartup.instance == (Object)null)
			{
				return null;
			}
			Type type = AccessTools.TypeByName("ButtonSfx");
			if (type == null)
			{
				return null;
			}
			FieldInfo fieldInfo = AccessTools.Field(type, "m_sfxPrefab");
			if (fieldInfo == null)
			{
				return null;
			}
			Component[] componentsInChildren = ((Component)FejdStartup.instance).GetComponentsInChildren(type, true);
			foreach (Component obj in componentsInChildren)
			{
				object? value = fieldInfo.GetValue(obj);
				GameObject val = (GameObject)((value is GameObject) ? value : null);
				if (val != null && (Object)(object)val != (Object)null)
				{
					_click = val;
					break;
				}
			}
			return _click;
		}
	}
	internal sealed class RosterRow : MonoBehaviour, IPointerClickHandler, IEventSystemHandler, IPointerEnterHandler, IPointerExitHandler, IBeginDragHandler, IDragHandler, IEndDragHandler
	{
		internal CampUi Owner;

		internal PlayerProfile Profile;

		internal RectTransform Visual;

		internal CanvasGroup VisualGroup;

		internal Image Glow;

		internal Image[] Grip;

		internal Image SelIcon;

		internal Image SeatIcon;

		internal TextMeshProUGUI Name;

		internal Image Divider;

		internal bool Hovered;

		internal float Offset;

		internal float Flash;

		internal float HoverT;

		public void OnPointerClick(PointerEventData e)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			if ((int)e.button == 0 && !e.dragging)
			{
				Owner.RowClicked(this);
			}
		}

		public void OnPointerEnter(PointerEventData e)
		{
			Hovered = true;
			Owner.RowHover(this, enter: true);
		}

		public void OnPointerExit(PointerEventData e)
		{
			Hovered = false;
			Owner.RowHover(this, enter: false);
		}

		public void OnBeginDrag(PointerEventData e)
		{
			Owner.RowBeginDrag(this, e);
		}

		public void OnDrag(PointerEventData e)
		{
			Owner.RowDrag(this, e);
		}

		public void OnEndDrag(PointerEventData e)
		{
			Owner.RowEndDrag(this);
		}
	}
	internal sealed class CampUi
	{
		private static readonly Color Gold = new Color(0.95f, 0.8f, 0.4f, 1f);

		private static readonly Color TextNormal = new Color(0.85f, 0.82f, 0.75f, 1f);

		private static readonly Color TextSelected = new Color(1f, 0.9f, 0.6f, 1f);

		private static readonly Color TextSecondary = new Color(0.72f, 0.7f, 0.66f, 0.85f);

		private const float RowHeight = 44f;

		private const float PanelWidth = 320f;

		private readonly CampfireSelect _owner;

		private GameObject _root;

		private RectTransform _rootRect;

		private CanvasGroup _group;

		private RectTransform _names;

		private RectTransform _panel;

		private RectTransform _viewport;

		private RectTransform _content;

		private ScrollRect _scroll;

		private TextMeshProUGUI _hint;

		private TMP_FontAsset _font;

		private Sprite _rounded;

		private Sprite _separator;

		private readonly List<RosterRow> _rows = new List<RosterRow>();

		private float _dragEndedAt = -10f;

		private TextMeshProUGUI _rosterTitle;

		private int _hintSeats = -1;

		private string _lastTitleCfg;

		private string _lastHintCfg;

		private bool _lastPt;

		private readonly List<CampfireSelect.Sitter> _deadBuf = new List<CampfireSelect.Sitter>();

		private readonly Dictionary<CampfireSelect.Sitter, TextMeshProUGUI> _labels = new Dictionary<CampfireSelect.Sitter, TextMeshProUGUI>();

		private string _signature = "";

		private List<PlayerProfile> _lastOrdered;

		private float _alpha;

		private RosterRow _dragging;

		private RectTransform _ghost;

		private CanvasGroup _ghostGroup;

		private TextMeshProUGUI _ghostName;

		private Vector2 _ghostTarget;

		private float _ghostT;

		private static TMP_FontAsset _cachedFont;

		private static Sprite _roundedCache;

		internal CampUi(CampfireSelect owner, Transform parent)
		{
			_owner = owner;
		}

		internal void Destroy()
		{
			if ((Object)(object)_root != (Object)null)
			{
				Object.Destroy((Object)(object)_root);
			}
			_root = null;
		}

		private void Build()
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: 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_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0309: Unknown result type (might be due to invalid IL or missing references)
			//IL_0327: Unknown result type (might be due to invalid IL or missing references)
			//IL_0349: Unknown result type (might be due to invalid IL or missing references)
			//IL_036e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0383: Unknown result type (might be due to invalid IL or missing references)
			//IL_0398: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0405: Unknown result type (might be due to invalid IL or missing references)
			//IL_0410: Unknown result type (might be due to invalid IL or missing references)
			//IL_0425: 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_0470: Unknown result type (might be due to invalid IL or missing references)
			//IL_049e: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_04eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0505: Unknown result type (might be due to invalid IL or missing references)
			//IL_051f: Unknown result type (might be due to invalid IL or missing references)
			//IL_052f: Unknown result type (might be due to invalid IL or missing references)
			//IL_055a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0564: Expected O, but got Unknown
			//IL_05ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0627: Unknown result type (might be due to invalid IL or missing references)
			//IL_0647: Unknown result type (might be due to invalid IL or missing references)
			//IL_0655: Unknown result type (might be due to invalid IL or missing references)
			//IL_06aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0720: Unknown result type (might be due to invalid IL or missing references)
			//IL_072c: Unknown result type (might be due to invalid IL or missing references)
			//IL_073a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0745: Unknown result type (might be due to invalid IL or missing references)
			_font = FindFont();
			_rounded = MakeRoundedSprite();
			_separator = FindSeparatorSprite();
			_root = new GameObject("ValheimMenu_CampUI", new Type[1] { typeof(RectTransform) });
			_rootRect = (RectTransform)_root.transform;
			Canvas obj = _root.AddComponent<Canvas>();
			obj.renderMode = (RenderMode)0;
			obj.sortingOrder = 40;
			CanvasScaler obj2 = _root.AddComponent<CanvasScaler>();
			obj2.uiScaleMode = (ScaleMode)1;
			obj2.referenceResolution = new Vector2(1920f, 1080f);
			obj2.matchWidthOrHeight = 0.5f;
			_root.AddComponent<GraphicRaycaster>();
			_group = _root.AddComponent<CanvasGroup>();
			_group.alpha = 0f;
			_names = NewRect("Names", _root.transform);
			Stretch(_names);
			_panel = NewRect("Roster", _root.transform);
			RectTransform panel = _panel;
			RectTransform panel2 = _panel;
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(1f, 0.5f);
			panel2.anchorMax = val;
			panel.anchorMin = val;
			_panel.pivot = new Vector2(1f, 0.5f);
			_panel.anchoredPosition = new Vector2(-58f, 30f);
			_panel.sizeDelta = new Vector2(320f, 600f);
			RectTransform obj3 = NewRect("Background", (Transform)(object)_panel);
			Stretch(obj3);
			obj3.offsetMin = new Vector2(-18f, -16f);
			obj3.offsetMax = new Vector2(18f, 16f);
			Image obj4 = ((Component)obj3).gameObject.AddComponent<Image>();
			obj4.sprite = _rounded;
			obj4.type = (Type)1;
			((Graphic)obj4).color = new Color(0.01f, 0.01f, 0.01f, 0.82f);
			((Graphic)obj4).raycastTarget = false;
			TextMeshProUGUI val2 = (_rosterTitle = Text("Title", (Transform)(object)_panel, Texts.RosterTitle, 24f, Gold));
			((TMP_Text)val2).fontStyle = (FontStyles)1;
			((TMP_Text)val2).characterSpacing = 2f;
			((TMP_Text)val2).alignment = (TextAlignmentOptions)514;
			((TMP_Text)val2).enableAutoSizing = true;
			((TMP_Text)val2).fontSizeMin = 16f;
			((TMP_Text)val2).fontSizeMax = 24f;
			RectTransform rectTransform = ((TMP_Text)val2).rectTransform;
			rectTransform.anchorMin = new Vector2(0f, 1f);
			rectTransform.anchorMax = new Vector2(1f, 1f);
			rectTransform.pivot = new Vector2(0.5f, 1f);
			rectTransform.anchoredPosition = Vector2.zero;
			rectTransform.sizeDelta = new Vector2(0f, 40f);
			AddSeparator(_panel, -46f, 0f);
			AddDiamond(_panel, new Vector2(0.5f, 1f), new Vector2(0f, -41f), 12f, new Color(1f, 0.78f, 0.35f, 1f));
			_hint = Text("Hint", (Transform)(object)_panel, "", 14f, TextSecondary);
			RectTransform rectTransform2 = ((TMP_Text)_hint).rectTransform;
			rectTransform2.anchorMin = new Vector2(0f, 0f);
			rectTransform2.anchorMax = new Vector2(1f, 0f);
			rectTransform2.pivot = new Vector2(0.5f, 0f);
			rectTransform2.anchoredPosition = new Vector2(0f, 0f);
			rectTransform2.sizeDelta = new Vector2(0f, 40f);
			((TMP_Text)_hint).alignment = (TextAlignmentOptions)514;
			((TMP_Text)_hint).textWrappingMode = (TextWrappingModes)1;
			((TMP_Text)_hint).fontStyle = (FontStyles)2;
			RectTransform val3 = NewRect("Scroll", (Transform)(object)_panel);
			val3.anchorMin = Vector2.zero;
			val3.anchorMax = Vector2.one;
			val3.offsetMin = new Vector2(0f, 46f);
			val3.offsetMax = new Vector2(0f, -62f);
			_viewport = NewRect("Viewport", (Transform)(object)val3);
			Stretch(_viewport);
			_viewport.offsetMax = new Vector2(-12f, 0f);
			((Graphic)((Component)_viewport).gameObject.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.001f);
			((Component)_viewport).gameObject.AddComponent<RectMask2D>().softness = new Vector2Int(0, 18);
			_content = NewRect("Content", (Transform)(object)_viewport);
			_content.anchorMin = new Vector2(0f, 1f);
			_content.anchorMax = new Vector2(1f, 1f);
			_content.pivot = new Vector2(0.5f, 1f);
			_content.sizeDelta = Vector2.zero;
			VerticalLayoutGroup obj5 = ((Component)_content).gameObject.AddComponent<VerticalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)obj5).spacing = 2f;
			((LayoutGroup)obj5).padding = new RectOffset(0, 0, 8, 12);
			((HorizontalOrVerticalLayoutGroup)obj5).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)obj5).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj5).childForceExpandHeight = false;
			((HorizontalOrVerticalLayoutGroup)obj5).childForceExpandWidth = true;
			((Component)_content).gameObject.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2;
			RectTransform val4 = NewRect("Scrollbar", (Transform)(object)val3);
			val4.anchorMin = new Vector2(1f, 0f);
			val4.anchorMax = new Vector2(1f, 1f);
			val4.pivot = new Vector2(1f, 0.5f);
			val4.sizeDelta = new Vector2(4f, -16f);
			Image obj6 = ((Component)val4).gameObject.AddComponent<Image>();
			obj6.sprite = _rounded;
			obj6.type = (Type)1;
			((Graphic)obj6).color = new Color(1f, 1f, 1f, 0.06f);
			Scrollbar val5 = ((Component)val4).gameObject.AddComponent<Scrollbar>();
			val5.direction = (Direction)2;
			Navigation navigation = default(Navigation);
			((Navigation)(ref navigation)).mode = (Mode)0;
			((Selectable)val5).navigation = navigation;
			RectTransform val6 = NewRect("Area", (Transform)(object)val4);
			Stretch(val6);
			RectTransform val7 = NewRect("Handle", (Transform)(object)val6);
			Stretch(val7);
			Image val8 = ((Component)val7).gameObject.AddComponent<Image>();
			val8.sprite = _rounded;
			val8.type = (Type)1;
			((Graphic)val8).color = Color.white;
			val5.handleRect = val7;
			((Selectable)val5).targetGraphic = (Graphic)(object)val8;
			ColorBlock colors = ((Selectable)val5).colors;
			((ColorBlock)(ref colors)).normalColor = new Color(Gold.r, Gold.g, Gold.b, 0.45f);
			((ColorBlock)(ref colors)).highlightedColor = new Color(Gold.r, Gold.g, Gold.b, 0.85f);
			((ColorBlock)(ref colors)).pressedColor = Gold;
			((ColorBlock)(ref colors)).selectedColor = ((ColorBlock)(ref colors)).normalColor;
			((Selectable)val5).colors = colors;
			_scroll = ((Component)val3).gameObject.AddComponent<ScrollRect>();
			_scroll.viewport = _viewport;
			_scroll.content = _content;
			_scroll.horizontal = false;
			_scroll.vertical = true;
			_scroll.movementType = (MovementType)2;
			_scroll.scrollSensitivity = 40f;
			_scroll.verticalScrollbar = val5;
			_scroll.verticalScrollbarVisibility = (ScrollbarVisibility)1;
			BuildGhost();
		}

		private void RebuildRows(List<PlayerProfile> ordered)
		{
			//IL_0080: 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_017e: 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_01c1: 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_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: 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_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0322: Unknown result type (might be due to invalid IL or missing references)
			//IL_0358: Unknown result type (might be due to invalid IL or missing references)
			//IL_0378: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0400: Unknown result type (might be due to invalid IL or missing references)
			//IL_040f: Unknown result type (might be due to invalid IL or missing references)
			//IL_041e: Unknown result type (might be due to invalid IL or missing references)
			foreach (RosterRow row in _rows)
			{
				if ((Object)(object)row != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)row).gameObject);
				}
			}
			_rows.Clear();
			foreach (PlayerProfile item in ordered)
			{
				RectTransform val = NewRect("Row", (Transform)(object)_content);
				val.pivot = new Vector2(0.5f, 0.5f);
				((Component)val).gameObject.AddComponent<LayoutElement>().preferredHeight = 44f;
				((Graphic)((Component)val).gameObject.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0f);
				RosterRow rosterRow = ((Component)val).gameObject.AddComponent<RosterRow>();
				rosterRow.Owner = this;
				rosterRow.Profile = item;
				rosterRow.Visual = NewRect("Visual", (Transform)(object)val);
				Stretch(rosterRow.Visual);
				rosterRow.VisualGroup = ((Component)rosterRow.Visual).gameObject.AddComponent<CanvasGroup>();
				rosterRow.VisualGroup.blocksRaycasts = false;
				rosterRow.Glow = ((Component)rosterRow.Visual).gameObject.AddComponent<Image>();
				rosterRow.Glow.sprite = _rounded;
				rosterRow.Glow.type = (Type)1;
				((Graphic)rosterRow.Glow).color = new Color(0f, 0f, 0f, 0f);
				((Graphic)rosterRow.Glow).raycastTarget = false;
				rosterRow.Visual.offsetMin = new Vector2(10f, 2f);
				rosterRow.Visual.offsetMax = new Vector2(-10f, -2f);
				rosterRow.Grip = (Image[])(object)new Image[3];
				for (int i = 0; i < 3; i++)
				{
					rosterRow.Grip[i] = Bar("Grip" + i, (Transform)(object)rosterRow.Visual, new Vector2(0f, 0.5f), new Vector2(0f, 0.5f), new Vector2(0f, 0.5f), new Vector2(12f, (float)(1 - i) * 5f), new Vector2(12f, 2f));
					rosterRow.Grip[i].sprite = _rounded;
					rosterRow.Grip[i].type = (Type)1;
				}
				rosterRow.SelIcon = AddDiamond(rosterRow.Visual, new Vector2(0f, 0.5f), new Vector2(38f, 0f), 10f, TextSelected);
				rosterRow.SeatIcon = AddDiamond(rosterRow.Visual, new Vector2(1f, 0.5f), new Vector2(-20f, 0f), 7f, CampConfig.SeatedColor.Value);
				rosterRow.Name = Text("Name", (Transform)(object)rosterRow.Visual, item.GetName(), 22f, TextNormal);
				Stretch(((TMP_Text)rosterRow.Name).rectTransform);
				((TMP_Text)rosterRow.Name).rectTransform.offsetMin = new Vector2(48f, 0f);
				((TMP_Text)rosterRow.Name).rectTransform.offsetMax = new Vector2(-48f, 0f);
				((TMP_Text)rosterRow.Name).alignment = (TextAlignmentOptions)514;
				((TMP_Text)rosterRow.Name).enableAutoSizing = true;
				((TMP_Text)rosterRow.Name).fontSizeMin = 14f;
				((TMP_Text)rosterRow.Name).fontSizeMax = 22f;
				((TMP_Text)rosterRow.Name).overflowMode = (TextOverflowModes)1;
				rosterRow.Divider = Bar("Divider", (Transform)(object)val, new Vector2(0.15f, 0f), new Vector2(0.85f, 0f), new Vector2(0.5f, 0.5f), new Vector2(0f, -1f), new Vector2(0f, 8f));
				if ((Object)(object)_separator != (Object)null)
				{
					rosterRow.Divider.sprite = _separator;
					rosterRow.Divider.type = (Type)1;
				}
				_rows.Add(rosterRow);
			}
		}

		private void BuildGhost()
		{
			//IL_0038: 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_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: 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)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: 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)
			_ghost = NewRect("DragGhost", _root.transform);
			RectTransform ghost = _ghost;
			RectTransform ghost2 = _ghost;
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(0.5f, 0.5f);
			ghost2.anchorMax = val;
			ghost.anchorMin = val;
			_ghost.pivot = new Vector2(0.5f, 0.5f);
			_ghost.sizeDelta = new Vector2(300f, 44f);
			_ghostGroup = ((Component)_ghost).gameObject.AddComponent<CanvasGroup>();
			_ghostGroup.blocksRaycasts = false;
			_ghostGroup.alpha = 0f;
			Image obj = ((Component)_ghost).gameObject.AddComponent<Image>();
			obj.sprite = _rounded;
			obj.type = (Type)1;
			((Graphic)obj).color = new Color(0.08f, 0.06f, 0.03f, 0.88f);
			((Graphic)obj).raycastTarget = false;
			RectTransform obj2 = NewRect("Edge", (Transform)(object)_ghost);
			Stretch(obj2);
			obj2.offsetMin = new Vector2(-1.5f, -1.5f);
			obj2.offsetMax = new Vector2(1.5f, 1.5f);
			((Transform)obj2).SetAsFirstSibling();
			Image obj3 = ((Component)obj2).gameObject.AddComponent<Image>();
			obj3.sprite = _rounded;
			obj3.type = (Type)1;
			((Graphic)obj3).color = new Color(Gold.r, Gold.g, Gold.b, 0.75f);
			((Graphic)obj3).raycastTarget = false;
			AddDiamond(_ghost, new Vector2(0f, 0.5f), new Vector2(26f, 0f), 10f, TextSelected);
			AddDiamond(_ghost, new Vector2(1f, 0.5f), new Vector2(-26f, 0f), 10f, TextSelected);
			_ghostName = Text("Name", (Transform)(object)_ghost, "", 24f, TextSelected);
			Stretch(((TMP_Text)_ghostName).rectTransform);
			((TMP_Text)_ghostName).rectTransform.offsetMin = new Vector2(40f, 0f);
			((TMP_Text)_ghostName).rectTransform.offsetMax = new Vector2(-40f, 0f);
			((TMP_Text)_ghostName).alignment = (TextAlignmentOptions)514;
			((TMP_Text)_ghostName).fontStyle = (FontStyles)1;
			((Component)_ghost).gameObject.SetActive(false);
		}

		internal void Tick(bool visible)
		{
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_034a: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_046d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0466: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_root == (Object)null)
			{
				if (!visible)
				{
					return;
				}
				Build();
			}
			float unscaledDeltaTime = Time.unscaledDeltaTime;
			_alpha = Mathf.MoveTowards(_alpha, visible ? 1f : 0f, unscaledDeltaTime * 5f);
			_group.alpha = _alpha;
			_group.blocksRaycasts = visible;
			_group.interactable = visible;
			((Component)_panel).gameObject.SetActive(CampConfig.ShowRoster.Value);
			if (!visible)
			{
				if ((Object)(object)_dragging != (Object)null)
				{
					CancelDrag();
				}
				return;
			}
			List<PlayerProfile> list = RosterOrder.Ordered(_owner.Profiles());
			if ((Object)(object)_dragging == (Object)null && list != _lastOrdered)
			{
				_lastOrdered = list;
				string text = Signature(list);
				if (text != _signature)
				{
					_signature = text;
					RebuildRows(list);
				}
			}
			else
			{
				AutoScrollWhileDragging();
			}
			int value = CampConfig.MaxSeats.Value;
			bool portuguese = Texts.Portuguese;
			if (value != _hintSeats || portuguese != _lastPt || (object)CampConfig.RosterTitle.Value != _lastTitleCfg || (object)CampConfig.RosterHint.Value != _lastHintCfg)
			{
				_hintSeats = value;
				_lastPt = portuguese;
				_lastTitleCfg = CampConfig.RosterTitle.Value;
				_lastHintCfg = CampConfig.RosterHint.Value;
				((TMP_Text)_hint).text = Texts.RosterHint(value);
				if ((Object)(object)_rosterTitle != (Object)null)
				{
					((TMP_Text)_rosterTitle).text = Texts.RosterTitle;
				}
			}
			PlayerProfile val = _owner.SelectedProfile();
			float num = 1f - Mathf.Exp(-14f * unscaledDeltaTime);
			Color color = default(Color);
			foreach (RosterRow row in _rows)
			{
				int siblingIndex = ((Component)row).transform.GetSiblingIndex();
				bool active = siblingIndex < value;
				bool flag = row.Profile == val;
				bool flag2 = (Object)(object)row == (Object)(object)_dragging;
				bool flag3 = !flag2 && (Object)(object)_dragging == (Object)null && row.Hovered;
				row.Offset = Mathf.Lerp(row.Offset, 0f, num);
				row.HoverT = Mathf.MoveTowards(row.HoverT, flag3 ? 1f : 0f, unscaledDeltaTime * 7f);
				row.Flash = Mathf.MoveTowards(row.Flash, 0f, unscaledDeltaTime * 2.2f);
				row.Visual.anchoredPosition = new Vector2(0f, row.Offset);
				float num2 = (flag2 ? 0.16f : (0.07f * row.HoverT + 0.22f * row.Flash));
				((Graphic)row.Glow).color = new Color(Gold.r, Gold.g, Gold.b, num2);
				((Color)(ref color))..ctor(Gold.r, Gold.g, Gold.b, 0.65f * row.HoverT);
				Image[] grip = row.Grip;
				for (int i = 0; i < grip.Length; i++)
				{
					((Graphic)grip[i]).color = color;
				}
				row.VisualGroup.alpha = (flag2 ? 0.28f : 1f);
				((Component)row.SelIcon).gameObject.SetActive(flag);
				((Component)row.SeatIcon).gameObject.SetActive(active);
				((Graphic)row.SeatIcon).color = CampConfig.SeatedColor.Value;
				((Graphic)row.Name).color = (flag ? TextSelected : Color.Lerp(TextNormal, Color.white, row.HoverT * 0.6f));
				((TMP_Text)row.Name).fontStyle = (FontStyles)(flag ? 1 : 0);
				bool active2 = siblingIndex == value - 1 && siblingIndex < _rows.Count - 1;
				((Component)row.Divider).gameObject.SetActive(active2);
				((Graphic)row.Divider).color = (Color)(((Object)(object)_separator != (Object)null) ? Color.white : new Color(Gold.r, Gold.g, Gold.b, 0.45f));
			}
			TickGhost(unscaledDeltaTime);
		}

		internal void UpdateNames(bool show)
		{
			//IL_0191: 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_01bb: 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_01da: 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_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0316: Unknown result type (might be due to invalid IL or missing references)
			//IL_030a: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_root == (Object)null)
			{
				return;
			}
			Camera cam = _owner.Cam;
			IReadOnlyList<CampfireSelect.Sitter> sitters = _owner.Sitters;
			if (_labels.Count > 0)
			{
				_deadBuf.Clear();
				foreach (CampfireSelect.Sitter key in _labels.Keys)
				{
					bool flag = false;
					for (int i = 0; i < sitters.Count; i++)
					{
						if (sitters[i] == key)
						{
							flag = true;
							break;
						}
					}
					if (!flag)
					{
						_deadBuf.Add(key);
					}
				}
				foreach (CampfireSelect.Sitter item in _deadBuf)
				{
					if ((Object)(object)_labels[item] != (Object)null)
					{
						Object.Destroy((Object)(object)((Component)_labels[item]).gameObject);
					}
					_labels.Remove(item);
				}
			}
			PlayerProfile val = _owner.SelectedProfile();
			Vector2 anchoredPosition = default(Vector2);
			foreach (CampfireSelect.Sitter item2 in sitters)
			{
				if (!_labels.TryGetValue(item2, out var value) || (Object)(object)