Decompiled source of Carturs Character Select v1.0.0

plugins/CarturCharSelect/CarturCharSelect.dll

Decompiled 3 days ago
using System;
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 BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using SoftReferenceableAssets;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("CarturCharSelect")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0+6e6b146d8c9381f423355da2d5bb411ed95799eb")]
[assembly: AssemblyProduct("CarturCharSelect")]
[assembly: AssemblyTitle("CarturCharSelect")]
[assembly: AssemblyVersion("0.1.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 CarturCharSelect
{
	public static class Core
	{
		internal static ManualLogSource Log;

		internal static string AssetsDir;

		private const string Slot = "CarturCharSelect.Owner";

		private static readonly string Me = typeof(Core).Assembly.GetName().Name;

		internal static bool Active
		{
			get
			{
				if (AppDomain.CurrentDomain.GetData("CarturCharSelect.Owner") is string text)
				{
					return text.EndsWith("|" + Me);
				}
				return false;
			}
		}

		public static void Install(ManualLogSource log, string assetsDir, int priority)
		{
			Log = log;
			AssetsDir = assetsDir;
			if (AccessTools.Field(typeof(Runtime), "s_assetLoader")?.GetValue(null) == null)
			{
				Runtime.MakeAllAssetsLoadable();
			}
			if (!(AppDomain.CurrentDomain.GetData("CarturCharSelect.Owner") is string text) || int.Parse(text.Substring(0, text.IndexOf('|'))) < priority)
			{
				AppDomain.CurrentDomain.SetData("CarturCharSelect.Owner", priority + "|" + Me);
			}
			try
			{
				Harmony.CreateAndPatchAll(typeof(Patches), "com.jekkle.valheim.carturcharselect." + Me);
				Log.LogInfo((object)"character select: patched FejdStartup.UpdateCharacterList + ClearCharacterPreview (runs unless another Cartur copy outranks this one)");
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("character select not patched, vanilla screen stays: " + ex.Message));
			}
		}
	}
	internal static class Patches
	{
		[HarmonyPatch(typeof(FejdStartup), "UpdateCharacterList")]
		[HarmonyPostfix]
		private static void Refresh(FejdStartup __instance)
		{
			if (!Core.Active)
			{
				return;
			}
			try
			{
				CharScreen.For(__instance)?.Refresh();
			}
			catch (Exception ex)
			{
				Core.Log.LogWarning((object)("refresh failed: " + ex));
			}
		}

		[HarmonyPatch(typeof(FejdStartup), "ClearCharacterPreview")]
		[HarmonyPrefix]
		private static bool NoPuff(FejdStartup __instance)
		{
			if (!Core.Active || (Object)(object)CharScreen.Instance == (Object)null || !__instance.m_selectCharacterPanel.activeInHierarchy)
			{
				return true;
			}
			GameObject val = CharScreen.Preview.Invoke(__instance);
			if ((Object)(object)val != (Object)null)
			{
				Object.Destroy((Object)(object)val);
			}
			CharScreen.Preview.Invoke(__instance) = null;
			return false;
		}
	}
	internal sealed class CharScreen : MonoBehaviour
	{
		private sealed class Slot
		{
			public PlayerProfile P;

			public Player Player;

			public Animator Anim;

			public Vector3 Pos;

			public bool Sit;

			public bool Owned;

			public Transform Seat;

			public string SeatAnim;

			public Vector3 Stand;

			public int Phase;

			public int StartHash;

			public int EmoteHash;

			public float Started;
		}

		private sealed class Row
		{
			public PlayerProfile P;

			public Image Bg;

			public GameObject Bar;
		}

		internal static CharScreen Instance;

		internal static readonly FieldRef<FejdStartup, List<PlayerProfile>> Profiles = AccessTools.FieldRefAccess<FejdStartup, List<PlayerProfile>>("m_profiles");

		internal static readonly FieldRef<FejdStartup, int> Index = AccessTools.FieldRefAccess<FejdStartup, int>("m_profileIndex");

		internal static readonly FieldRef<FejdStartup, GameObject> Preview = AccessTools.FieldRefAccess<FejdStartup, GameObject>("m_playerInstance");

		private static readonly FieldRef<Character, Animator> Anim = AccessTools.FieldRefAccess<Character, Animator>("m_animator");

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

		private static readonly int SitHash = Animator.StringToHash("emote_sit");

		private static readonly int EmoteTag = Animator.StringToHash("emote");

		private static readonly string[] Wanted = new string[8] { "wave", "challenge", "flex", "cheer", "thumbsup", "bow", "roar", "headbang" };

		private const int LineupSize = 5;

		private static readonly float[] Radii = new float[1] { 2.3f };

		private static readonly float[] Angles = new float[1] { -60f };

		private static readonly (float angle, float radius, float yaw)[] Logs = new(float, float, float)[2]
		{
			(140f, 2.5f, 20f),
			(-120f, 2.5f, -20f)
		};

		private const float CameraBack = 1.2f;

		private const float CameraLeft = 0.5f;

		private const float StandOut = 0.65f;

		private static readonly (int log, int seat)[] Seats = new(int, int)[5]
		{
			(-1, -1),
			(0, 0),
			(1, 0),
			(0, 1),
			(1, 1)
		};

		private FejdStartup _fs;

		private Transform _fire;

		private Camera _cam;

		private Vector3 _camHome;

		private bool _camPulled;

		private RectTransform _panel;

		private RectTransform _content;

		private TMP_FontAsset _font;

		private string _listKey;

		private string _lineupKey;

		private List<PlayerProfile> _source;

		private PlayerProfile _scrolledTo;

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

		private readonly List<Slot> _slots = new List<Slot>();

		private string[] _emotes;

		private Slot _hovered;

		private const float DrawHold = 3f;

		private static readonly MethodInfo ShowHands = AccessTools.Method(typeof(Humanoid), "ShowHandItems", (Type[])null, (Type[])null);

		private static readonly FieldRef<Humanoid, ItemData> HiddenRight = AccessTools.FieldRefAccess<Humanoid, ItemData>("m_hiddenRightItem");

		private static readonly FieldRef<Humanoid, ItemData> HiddenLeft = AccessTools.FieldRefAccess<Humanoid, ItemData>("m_hiddenLeftItem");

		private static readonly int EquipHip = Animator.StringToHash("equip_hip");

		private const string BenchPath = "Assets/GameElements/Pieces/piece_logbench01.prefab";

		private readonly List<GameObject> _benches = new List<GameObject>();

		private const float DoubleClick = 0.4f;

		private PlayerProfile _lastClick;

		private float _lastClickTime;

		private const float PanelW = 420f;

		private const float PanelH = 776f;

		private const float RulePx = 20f;

		private const float RulePxPerUnit = 2.5f;

		private static readonly Rect BandBox = Rect.MinMaxRect(16f, 12f, 404f, 50f);

		private static readonly Rect TitleBox = Rect.MinMaxRect(24f, 12f, 396f, 50f);

		private static readonly Rect HintBox = Rect.MinMaxRect(24f, 54f, 396f, 72f);

		private static readonly Rect ListBox = Rect.MinMaxRect(24f, 80f, 384f, 548f);

		private static readonly Rect BarBox = Rect.MinMaxRect(390f, 80f, 393f, 548f);

		private static readonly Rect StartBox = Rect.MinMaxRect(24f, 562f, 396f, 610f);

		private static readonly Rect NewBox = Rect.MinMaxRect(24f, 620f, 396f, 660f);

		private static readonly Rect RemoveBox = Rect.MinMaxRect(24f, 670f, 205f, 708f);

		private static readonly Rect SavesBox = Rect.MinMaxRect(215f, 670f, 396f, 708f);

		private static readonly Rect BackBox = Rect.MinMaxRect(24f, 718f, 396f, 756f);

		private const float RowH = 36f;

		private const float RowGap = 2f;

		private const float SlidePx = 2f;

		private const float SlideTime = 0.15f;

		private static readonly Color Fallback = Hex(1708556, 0.94f);

		private static Color RowNormal = Hex(2102798, 0.9f);

		private static Color Thumb = Hex(9136404);

		private static Color RowHover = Hex(2891283, 0.95f);

		private static Color RowSelected = Hex(2891283, 0.95f);

		private static Color RowSelectedHover = Hex(3680022);

		private static Color Gold = Hex(15255626);

		private static Color Mark = Hex(14719520);

		private static Color Muted = Hex(11047024);

		private static Color Meta = Hex(10125384, 0.65f);

		private static Color HintColor = Hex(12098120, 0.5f);

		private static Color Band = Hex(3352595, 0.95f);

		private static Color BandRule = Hex(9136404, 0.7f);

		private static Color Separator = new Color(0f, 0f, 0f, 0.33f);

		private static Color ShadowColor = new Color(0f, 0f, 0f, 0.4f);

		private static float TitleSize = 21f;

		private static float TitleSpacing = 8f;

		private static float HintSize = 10f;

		private static float HintSpacing = 2f;

		private static float NameSize = 15f;

		private static float MetaSize = 10f;

		private static float BarWidth = 4f;

		private static float ShadowBlur = 9f;

		private static float ShadowDrop = 4f;

		private const string RuneGuid = "com.jekkle.valheim.carturruneui";

		private static bool s_rune;

		private static float s_runePx = 1f;

		private Color _accent;

		private const string CauldronPath = "Assets/GameElements/Pieces/piece_cauldron.prefab";

		private GameObject _cauldron;

		private static readonly string[] CoolLights = new string[2] { "Spotlight_trees", "Spotlight_mountain" };

		private static readonly Color CoolTo = new Color(0.82f, 0.88f, 1f);

		private readonly List<(Light light, Color color, float intensity)> _warm = new List<(Light, Color, float)>();

		private bool _cooled;

		private GameObject _logo;

		private static Color Edge = Color.black;

		private bool _rowHover;

		private RectTransform _view;

		private TMP_Text _empty;

		private float _canvasH;

		private static Sprite s_button;

		private bool _seatFailed;

		private static readonly FieldInfo[] LabelColours = new FieldInfo[2]
		{
			AccessTools.Field(typeof(ButtonTextColor), "m_defaultColor"),
			AccessTools.Field(typeof(ButtonTextColor), "m_defaultMeshColor")
		};

		internal static CharScreen For(FejdStartup fs)
		{
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Expected O, but got Unknown
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Instance != (Object)null && (Object)(object)Instance._fs == (Object)(object)fs)
			{
				return Instance;
			}
			GameObject val = GameObject.Find("MenuFire");
			Camera val2 = (((Object)(object)fs.m_mainCamera != (Object)null) ? fs.m_mainCamera.GetComponent<Camera>() : null);
			Canvas componentInParent = fs.m_selectCharacterPanel.GetComponentInParent<Canvas>();
			Canvas val3 = ((componentInParent != null) ? componentInParent.rootCanvas : null);
			if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null || (Object)(object)val3 == (Object)null)
			{
				Core.Log.LogWarning((object)$"start scene not as expected (fire {(Object)(object)val != (Object)null}, camera {(Object)(object)val2 != (Object)null}, canvas {(Object)(object)val3 != (Object)null}) - vanilla character select left alone");
				return null;
			}
			if ((Object)(object)Instance != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)Instance).gameObject);
			}
			GameObject val4 = new GameObject("CarturCharSelect");
			Instance = val4.AddComponent<CharScreen>();
			Instance._fs = fs;
			Instance._fire = val.transform;
			Instance._cam = val2;
			Instance._camHome = fs.m_cameraMarkerCharacter.position;
			Instance._font = fs.m_csName.font;
			try
			{
				Instance.BuildPanel(((Component)val3).transform);
				Instance.Scenery();
			}
			catch
			{
				Object.Destroy((Object)(object)val4);
				Instance = null;
				throw;
			}
			return Instance;
		}

		private void OnDestroy()
		{
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Instance == (Object)(object)this)
			{
				Instance = null;
			}
			if ((Object)(object)_panel != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)_panel).gameObject);
			}
			if ((Object)(object)_logo != (Object)null)
			{
				Object.Destroy((Object)(object)_logo);
			}
			if ((Object)(object)_cauldron != (Object)null)
			{
				Object.Destroy((Object)(object)_cauldron);
			}
			if ((Object)(object)_fs != (Object)null && (Object)(object)_fs.m_cameraMarkerCharacter != (Object)null)
			{
				_fs.m_cameraMarkerCharacter.position = _camHome;
			}
			foreach (GameObject bench in _benches)
			{
				if ((Object)(object)bench != (Object)null)
				{
					Object.Destroy((Object)(object)bench);
				}
			}
			foreach (Slot slot in _slots)
			{
				if (slot.Owned && (Object)(object)slot.Player != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)slot.Player).gameObject);
				}
			}
		}

		internal void Refresh()
		{
			//IL_0199: 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_0393: Unknown result type (might be due to invalid IL or missing references)
			//IL_0395: Unknown result type (might be due to invalid IL or missing references)
			//IL_033d: Unknown result type (might be due to invalid IL or missing references)
			//IL_033f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0353: Unknown result type (might be due to invalid IL or missing references)
			//IL_035c: Unknown result type (might be due to invalid IL or missing references)
			List<PlayerProfile> list = Profiles.Invoke(_fs) ?? new List<PlayerProfile>();
			int num = Index.Invoke(_fs);
			PlayerProfile val = ((num >= 0 && num < list.Count) ? list[num] : null);
			((Component)_fs.m_csLeftButton).gameObject.SetActive(false);
			((Component)_fs.m_csRightButton).gameObject.SetActive(false);
			((Component)_fs.m_csName).gameObject.SetActive(false);
			((Component)_fs.m_csFileSource).gameObject.SetActive(false);
			Transform obj = _fs.m_selectCharacterPanel.transform.Find("Topic");
			if (obj != null)
			{
				((Component)obj).gameObject.SetActive(false);
			}
			List<PlayerProfile> list2 = list.OrderByDescending(LastPlayed).ToList();
			if (list != _source)
			{
				_source = list;
				_listKey = (_lineupKey = null);
			}
			string text = string.Join("|", list2.Select((PlayerProfile p) => p.GetFilename()));
			if (text != _listKey)
			{
				_listKey = text;
				BuildRows(list2);
			}
			for (int num2 = 0; num2 < _rows.Count; num2++)
			{
				bool flag = _rows[num2].P == val;
				((Graphic)_rows[num2].Bg).color = (flag ? RowSelected : RowNormal);
				_rows[num2].Bar.SetActive(flag);
				if (flag && val != _scrolledTo)
				{
					_scrolledTo = val;
					ScrollTo(num2);
				}
			}
			((Component)_empty).gameObject.SetActive(list.Count == 0);
			List<PlayerProfile> list3 = list2.Take(5).ToList();
			if (val != null && !list3.Contains(val))
			{
				if (list3.Count == 5)
				{
					list3[4] = val;
				}
				else
				{
					list3.Add(val);
				}
			}
			string text2 = string.Join("|", list3.Select((PlayerProfile p) => p.GetFilename()));
			if (text2 != _lineupKey)
			{
				_lineupKey = text2;
				BuildLineup(list3);
			}
			GameObject val2 = Preview.Invoke(_fs);
			Rigidbody val3 = default(Rigidbody);
			foreach (Slot slot in _slots)
			{
				if (slot.P == val && (Object)(object)val2 != (Object)null)
				{
					if (!((Object)(object)slot.Player != (Object)null) || !((Object)(object)((Component)slot.Player).gameObject == (Object)(object)val2))
					{
						if (slot.Owned && (Object)(object)slot.Player != (Object)null)
						{
							Object.Destroy((Object)(object)((Component)slot.Player).gameObject);
						}
						Pose(slot, out var at, out var rot);
						val2.transform.SetPositionAndRotation(at, rot);
						if (val2.TryGetComponent<Rigidbody>(ref val3))
						{
							val3.position = at;
							val3.rotation = rot;
						}
						Use(slot, val2.GetComponent<Player>(), owned: false);
					}
				}
				else if (!slot.Owned)
				{
					Pose(slot, out var at2, out var rot2);
					Use(slot, Spawn(slot.P, at2, rot2), owned: true);
				}
			}
			foreach (Slot slot2 in _slots)
			{
				slot2.Sit = (Object)(object)slot2.Seat != (Object)null;
			}
		}

		private static void Draw(Slot s, bool draw)
		{
			if (draw)
			{
				ShowHands?.Invoke(s.Player, new object[2] { false, false });
			}
			else
			{
				((Humanoid)s.Player).HideHandItems(false, false);
			}
			if (s.Anim.parameters.Any((AnimatorControllerParameter p) => p.nameHash == EquipHip))
			{
				s.Anim.SetTrigger(EquipHip);
			}
		}

		private void PullCamera(bool pulled)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			_camPulled = pulled;
			Transform cameraMarkerCharacter = _fs.m_cameraMarkerCharacter;
			Vector3 forward = cameraMarkerCharacter.forward;
			forward.y = 0f;
			((Vector3)(ref forward)).Normalize();
			Vector3 val = Vector3.Cross(Vector3.up, forward);
			cameraMarkerCharacter.position = (pulled ? (_camHome - forward * 1.2f - val * 0.5f) : _camHome);
		}

		private void Pose(Slot s, out Vector3 at, out Quaternion rot)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: 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_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)s.Seat != (Object)null)
			{
				at = s.Seat.position;
				rot = s.Seat.rotation;
			}
			else
			{
				at = s.Pos;
				rot = Facing(s.Pos, _fire.position);
			}
		}

		private Chair[] Bench(Vector3 centre, float yaw)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: 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_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: 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)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: 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)
			GameObject val = LoadPrefab("Assets/GameElements/Pieces/piece_logbench01.prefab");
			if ((Object)(object)val == (Object)null)
			{
				return null;
			}
			ZNetView.m_forceDisableInit = true;
			GameObject val2;
			try
			{
				val2 = Object.Instantiate<GameObject>(val, centre, Quaternion.identity);
			}
			finally
			{
				ZNetView.m_forceDisableInit = false;
			}
			_benches.Add(val2);
			Chair[] array = (from c in val2.GetComponentsInChildren<Chair>()
				where (Object)(object)c.m_attachPoint != (Object)null
				select c).ToArray();
			if (array.Length == 0)
			{
				Core.Log.LogWarning((object)"log bench has no seat - sitters on the ground");
				return null;
			}
			Quaternion val3 = Quaternion.Inverse(val2.transform.rotation) * array[0].m_attachPoint.rotation;
			val2.transform.rotation = Quaternion.Euler(0f, yaw, 0f) * Facing(centre, _fire.position) * Quaternion.Inverse(val3);
			Vector3 val4 = array.Aggregate(Vector3.zero, (Vector3 v, Chair c) => v + c.m_attachPoint.position) / (float)array.Length;
			Vector3 val5 = centre - val4;
			val5.y = 0f;
			Transform transform = val2.transform;
			transform.position += val5;
			Vector3 eye = _fs.m_cameraMarkerCharacter.position;
			return array.OrderBy((Chair c) => Vector3.Distance(c.m_attachPoint.position, eye)).ToArray();
		}

		private static GameObject LoadPrefab(string path)
		{
			//IL_0028: 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)
			if (!Runtime.GetAllAssetPathsInBundleMappedToAssetID().TryGetValue(path, out var value))
			{
				Core.Log.LogWarning((object)("not loadable (SoftRef extended manifest not read): " + path));
				return null;
			}
			SoftReference<GameObject> val = default(SoftReference<GameObject>);
			val..ctor(value);
			val.Load();
			return val.Asset;
		}

		private static Quaternion Facing(Vector3 from, Vector3 to)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = to - from;
			val.y = 0f;
			return Quaternion.LookRotation(val);
		}

		private static void Use(Slot s, Player p, bool owned)
		{
			if ((Object)(object)p != (Object)null)
			{
				((Humanoid)p).HideHandItems(false, false);
			}
			s.Player = p;
			s.Anim = (((Object)(object)p != (Object)null) ? Anim.Invoke((Character)(object)p) : null);
			s.Owned = owned;
			s.Phase = 0;
		}

		private static DateTime LastPlayed(PlayerProfile p)
		{
			SaveWithBackups val = default(SaveWithBackups);
			if (!SaveSystem.TryGetSaveByName(p.GetFilename(), (SaveDataType)1, ref val) || val.IsDeleted)
			{
				return DateTime.MinValue;
			}
			return val.PrimaryFile.LastModified;
		}

		private void Click(PlayerProfile p)
		{
			bool flag = p == _lastClick && Time.unscaledTime - _lastClickTime < 0.4f;
			_lastClick = (flag ? null : p);
			_lastClickTime = Time.unscaledTime;
			Select(p);
			if (flag && Index.Invoke(_fs) >= 0)
			{
				_fs.OnCharacterStart();
			}
		}

		private void Select(PlayerProfile p)
		{
			int num = Profiles.Invoke(_fs).IndexOf(p);
			if (num >= 0 && num != Index.Invoke(_fs))
			{
				Index.Invoke(_fs) = num;
				UpdateList.Invoke(_fs, null);
			}
		}

		private void BuildLineup(List<PlayerProfile> pick)
		{
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: 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_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: 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_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: 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_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: 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_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: 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_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02de: Unknown result type (might be due to invalid IL or missing references)
			foreach (Slot slot2 in _slots)
			{
				if (slot2.Owned && (Object)(object)slot2.Player != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)slot2.Player).gameObject);
				}
			}
			_slots.Clear();
			foreach (GameObject bench in _benches)
			{
				if ((Object)(object)bench != (Object)null)
				{
					Object.Destroy((Object)(object)bench);
				}
			}
			_benches.Clear();
			_hovered = null;
			Vector3 position = _fire.position;
			Vector3 val = _camHome - position;
			val.y = 0f;
			((Vector3)(ref val)).Normalize();
			List<Chair[]> list = new List<Chair[]>();
			(float, float, float)[] logs = Logs;
			for (int i = 0; i < logs.Length; i++)
			{
				(float, float, float) tuple = logs[i];
				float item = tuple.Item1;
				float item2 = tuple.Item2;
				float item3 = tuple.Item3;
				Vector3 val2 = position + Quaternion.Euler(0f, item, 0f) * val * item2;
				val2.y = Ground(val2);
				list.Add((pick.Count > 1) ? Bench(val2, item3) : null);
			}
			for (int j = 0; j < pick.Count; j++)
			{
				Slot slot = new Slot
				{
					P = pick[j]
				};
				(int log, int seat) tuple2 = Seats[j];
				int item4 = tuple2.log;
				int item5 = tuple2.seat;
				Chair val3 = ((item4 >= 0 && list[item4] != null && item5 < list[item4].Length) ? list[item4][item5] : null);
				if ((Object)(object)val3 != (Object)null)
				{
					slot.Seat = val3.m_attachPoint;
					slot.SeatAnim = val3.m_attachAnimation;
					slot.Pos = val3.m_attachPoint.position;
					Vector3 forward = val3.m_attachPoint.forward;
					forward.y = 0f;
					Vector3 val4 = slot.Pos + ((Vector3)(ref forward)).normalized * 0.65f;
					val4.y = Ground(val4);
					slot.Stand = val4;
				}
				else
				{
					int num = Mathf.Min(j, Angles.Length - 1);
					Vector3 pos = position + Quaternion.Euler(0f, Angles[num], 0f) * val * Radii[num];
					pos.y = Ground(pos);
					slot.Pos = pos;
				}
				Pose(slot, out var at, out var rot);
				Use(slot, Spawn(pick[j], at, rot), owned: true);
				_slots.Add(slot);
			}
			if (_emotes == null && _slots.Count > 0 && (Object)(object)_slots[0].Anim != (Object)null)
			{
				HashSet<string> have = new HashSet<string>(from p in _slots[0].Anim.parameters
					where (int)p.type == 9
					select p.name);
				_emotes = Wanted.Where((string e) => have.Contains("emote_" + e)).ToArray();
				if (_emotes.Length == 0)
				{
					Core.Log.LogWarning((object)"none of the hover emotes exist on the player animator - hover does nothing");
				}
			}
		}

		private float Ground(Vector3 pos)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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_0100: 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_00da: Unknown result type (might be due to invalid IL or missing references)
			float num = float.NegativeInfinity;
			RaycastHit[] array = Physics.RaycastAll(pos + Vector3.up * 3f, Vector3.down, 6f);
			for (int i = 0; i < array.Length; i++)
			{
				RaycastHit h = array[i];
				if ((Object)(object)((Component)((RaycastHit)(ref h)).collider).GetComponentInParent<Player>() == (Object)null && (Object)(object)((Component)((RaycastHit)(ref h)).collider).GetComponentInParent<Chair>() == (Object)null && !_benches.Any((GameObject b) => (Object)(object)b != (Object)null && ((Component)((RaycastHit)(ref h)).collider).transform.IsChildOf(b.transform)) && ((Object)(object)_cauldron == (Object)null || !((Component)((RaycastHit)(ref h)).collider).transform.IsChildOf(_cauldron.transform)) && ((RaycastHit)(ref h)).point.y > num)
				{
					num = ((RaycastHit)(ref h)).point.y;
				}
			}
			if (!(num > float.NegativeInfinity))
			{
				return _fire.position.y;
			}
			return num;
		}

		private Player Spawn(PlayerProfile p, Vector3 pos, Quaternion rot)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			ZNetView.m_forceDisableInit = true;
			GameObject val;
			try
			{
				val = Object.Instantiate<GameObject>(_fs.m_playerPrefab, pos, rot);
			}
			finally
			{
				ZNetView.m_forceDisableInit = false;
			}
			Object.Destroy((Object)(object)val.GetComponent<Rigidbody>());
			Animator[] componentsInChildren = val.GetComponentsInChildren<Animator>();
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				componentsInChildren[i].updateMode = (AnimatorUpdateMode)0;
			}
			Player component = val.GetComponent<Player>();
			try
			{
				p.LoadPlayerData(component);
			}
			catch (Exception ex)
			{
				Core.Log.LogWarning((object)("could not load " + p.GetFilename() + " for the fire: " + ex.Message));
			}
			return component;
		}

		private void Play(Slot s)
		{
			//IL_0068: 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_011d: Unknown result type (might be due to invalid IL or missing references)
			if (s != null && !((Object)(object)s.Anim == (Object)null) && s.Phase == 0 && _emotes != null && _emotes.Length != 0)
			{
				s.Anim.SetBool(SitHash, false);
				if ((Object)(object)s.Seat != (Object)null)
				{
					s.Anim.SetBool(s.SeatAnim, false);
					((Component)s.Player).transform.position = s.Stand;
				}
				if ((HiddenRight.Invoke((Humanoid)(object)s.Player) != null || HiddenLeft.Invoke((Humanoid)(object)s.Player) != null) && Random.value < 0.5f)
				{
					Draw(s, draw: true);
					s.Started = Time.time;
					s.Phase = 3;
					return;
				}
				string text = _emotes[Random.Range(0, _emotes.Length)];
				s.Anim.SetTrigger("emote_stop");
				s.Anim.ResetTrigger("emote_stop");
				s.Anim.SetTrigger("emote_" + text);
				AnimatorStateInfo currentAnimatorStateInfo = s.Anim.GetCurrentAnimatorStateInfo(0);
				s.StartHash = ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).fullPathHash;
				s.Started = Time.time;
				s.Phase = 1;
			}
		}

		private void Update()
		{
			//IL_0239: 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_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			bool flag = !_fs.m_newCharacterPanel.activeInHierarchy;
			if (flag != _camPulled)
			{
				PullCamera(flag);
			}
			foreach (Slot slot3 in _slots)
			{
				if ((Object)(object)slot3.Player != (Object)null && ((Component)slot3.Player).gameObject.activeSelf != flag)
				{
					((Component)slot3.Player).gameObject.SetActive(flag);
				}
			}
			foreach (GameObject bench in _benches)
			{
				if ((Object)(object)bench != (Object)null && bench.activeSelf != flag)
				{
					bench.SetActive(flag);
				}
			}
			bool activeInHierarchy = _fs.m_selectCharacterPanel.activeInHierarchy;
			if (((Component)_panel).gameObject.activeSelf != activeInHierarchy)
			{
				((Component)_panel).gameObject.SetActive(activeInHierarchy);
			}
			if ((Object)(object)_logo != (Object)null && _logo.activeSelf != activeInHierarchy)
			{
				_logo.SetActive(activeInHierarchy);
			}
			if (activeInHierarchy != _cooled)
			{
				Cool(activeInHierarchy);
			}
			if (activeInHierarchy)
			{
				FitPanel();
			}
			if (!flag)
			{
				return;
			}
			foreach (Slot slot4 in _slots)
			{
				Animate(slot4);
			}
			if (!activeInHierarchy)
			{
				return;
			}
			int num = (ZInput.GetButtonDown("JoyDPadUp") ? (-1) : (ZInput.GetButtonDown("JoyDPadDown") ? 1 : 0));
			if (num != 0 && _rows.Count > 0)
			{
				int num2 = _rows.FindIndex((Row r) => r.Bar.activeSelf);
				Select(_rows[Mathf.Clamp(num2 + num, 0, _rows.Count - 1)].P);
			}
			Slot slot = null;
			if ((Object)(object)EventSystem.current == (Object)null || !EventSystem.current.IsPointerOverGameObject())
			{
				Ray val = _cam.ScreenPointToRay(ZInput.pointerPosition);
				float num3 = float.PositiveInfinity;
				RaycastHit[] array = Physics.RaycastAll(val, 30f);
				for (int num4 = 0; num4 < array.Length; num4++)
				{
					RaycastHit val2 = array[num4];
					Player pl = ((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent<Player>();
					Slot slot2 = (((Object)(object)pl == (Object)null) ? null : _slots.FirstOrDefault((Slot x) => (Object)(object)x.Player == (Object)(object)pl));
					if (slot2 != null && ((RaycastHit)(ref val2)).distance < num3)
					{
						num3 = ((RaycastHit)(ref val2)).distance;
						slot = slot2;
					}
				}
			}
			if (slot != null && ZInput.GetMouseButtonDown(0))
			{
				Click(slot.P);
			}
			if (slot != null && slot != _hovered)
			{
				Play(slot);
			}
			if (slot != null || !_rowHover)
			{
				_hovered = slot;
			}
		}

		private void Animate(Slot s)
		{
			//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_011d: 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_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)s.Anim == (Object)null || !s.Anim.isInitialized)
			{
				return;
			}
			AnimatorStateInfo currentAnimatorStateInfo = s.Anim.GetCurrentAnimatorStateInfo(0);
			if (s.Phase == 1 && ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).fullPathHash != s.StartHash && ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).tagHash == EmoteTag)
			{
				s.Phase = 2;
				s.EmoteHash = ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).fullPathHash;
			}
			else if (s.Phase == 3)
			{
				if (Time.time - s.Started > 3f)
				{
					Draw(s, draw: false);
					s.Phase = 0;
				}
			}
			else if ((s.Phase == 2 && ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).fullPathHash != s.EmoteHash) || (s.Phase != 0 && Time.time - s.Started > 6f))
			{
				s.Phase = 0;
			}
			if ((Object)(object)s.Seat != (Object)null)
			{
				bool flag = s.Phase == 0;
				if (s.Anim.GetBool(s.SeatAnim) != flag)
				{
					s.Anim.SetBool(s.SeatAnim, flag);
					if (flag)
					{
						((Component)s.Player).transform.SetPositionAndRotation(s.Seat.position, s.Seat.rotation);
					}
				}
				if (flag)
				{
					return;
				}
			}
			else
			{
				bool flag2 = s.Sit && s.Phase == 0;
				if (s.Anim.GetBool(SitHash) != flag2)
				{
					s.Anim.SetBool(SitHash, flag2);
				}
			}
			if (s.Owned || s.Phase != 0)
			{
				Vector3 val = ((s.Phase != 0) ? ((Component)_cam).transform.position : _fire.position) - ((Component)s.Player).transform.position;
				val.y = 0f;
				if (((Vector3)(ref val)).sqrMagnitude > 0.01f)
				{
					((Component)s.Player).transform.rotation = Quaternion.RotateTowards(((Component)s.Player).transform.rotation, Quaternion.LookRotation(val), 360f * Time.deltaTime);
				}
			}
		}

		private void Rune(Canvas canvas)
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: 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_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_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: 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_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: 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_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: 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_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			s_rune = true;
			s_runePx = Mathf.Max(1f, canvas.scaleFactor);
			Color val = ((AccessTools.Field(AccessTools.TypeByName("CarturRuneUI.Theme"), "Accent")?.GetValue(null) is Color val2) ? val2 : Color32.op_Implicit(new Color32(byte.MaxValue, (byte)183, (byte)92, byte.MaxValue)));
			object? obj = AccessTools.Property(AccessTools.TypeByName("CarturRuneUI.Fonts"), "Regular")?.GetValue(null);
			TMP_FontAsset val3 = (TMP_FontAsset)((obj is TMP_FontAsset) ? obj : null);
			if (val3 != null)
			{
				_font = val3;
			}
			_accent = val;
			RowNormal = new Color(0.054f, 0.054f, 0.054f, 0f);
			Thumb = val;
			Edge = new Color(val.r, val.g, val.b, 0.4f);
			RowHover = new Color(1f, 1f, 1f, 0.05f);
			RowSelected = Hex(1710618);
			RowSelectedHover = Hex(2236962);
			Gold = new Color(1f, 0.82f, 0f);
			Mark = val;
			Muted = new Color(0.72f, 0.72f, 0.72f);
			Meta = new Color(1f, 0.82f, 0f, 0.45f);
			HintColor = new Color(1f, 0.82f, 0f, 0.4f);
			Band = Hex(1315860);
			BandRule = new Color(val.r, val.g, val.b, 0.4f);
			Separator = new Color(1f, 1f, 1f, 0.05f);
			ShadowColor = new Color(0f, 0f, 0f, 0.55f);
			TitleSize = 20f;
			TitleSpacing = 12f;
			HintSize = 11f;
			HintSpacing = 3f;
			NameSize = 17f;
			MetaSize = 12f;
			BarWidth = 2.5f;
			ShadowBlur = 6f;
			ShadowDrop = 3f;
		}

		private void Scenery()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			Light[] array = Object.FindObjectsOfType<Light>();
			foreach (Light val in array)
			{
				if (CoolLights.Contains(((Object)val).name))
				{
					_warm.Add((val, val.color, val.intensity));
				}
			}
			try
			{
				GameObject val2 = LoadPrefab("Assets/GameElements/Pieces/piece_cauldron.prefab");
				if ((Object)(object)val2 == (Object)null)
				{
					return;
				}
				ZNetView.m_forceDisableInit = true;
				try
				{
					_cauldron = Object.Instantiate<GameObject>(val2, _fire.position, Quaternion.identity);
				}
				finally
				{
					ZNetView.m_forceDisableInit = false;
				}
				CraftingStation component = _cauldron.GetComponent<CraftingStation>();
				if ((Object)(object)component != (Object)null)
				{
					GameObject areaMarker = component.m_areaMarker;
					if (areaMarker != null)
					{
						areaMarker.SetActive(false);
					}
					GameObject haveFireObject = component.m_haveFireObject;
					if (haveFireObject != null)
					{
						haveFireObject.SetActive(true);
					}
				}
			}
			catch (Exception ex)
			{
				Core.Log.LogWarning((object)("no cauldron over the fire: " + ex.Message));
			}
		}

		private void Cool(bool on)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: 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)
			_cooled = on;
			foreach (var item in _warm)
			{
				if (!((Object)(object)item.light == (Object)null))
				{
					item.light.color = (on ? Color.Lerp(item.color, CoolTo, 0.33f) : item.color);
					item.light.intensity = (on ? (item.intensity * 0.85f) : item.intensity);
				}
			}
		}

		private void RuneLogo()
		{
			//IL_0051: 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_005a: 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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: 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_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: 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)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			object? obj = AccessTools.Property(AccessTools.TypeByName("CarturRuneUI.Fonts"), "Bold")?.GetValue(null);
			TMP_FontAsset val = (TMP_FontAsset)((obj is TMP_FontAsset) ? obj : null);
			RectTransform val2 = Rect("RuneUI_Logo", ((Transform)_panel).parent);
			Vector2 val3 = default(Vector2);
			((Vector2)(ref val3))..ctor(1f, 0f);
			val2.pivot = val3;
			Vector2 anchorMin = (val2.anchorMax = val3);
			val2.anchorMin = anchorMin;
			val2.sizeDelta = new Vector2(260f, 80f);
			val2.anchoredPosition = new Vector2(-24f, 16f);
			_logo = ((Component)val2).gameObject;
			_logo.SetActive(false);
			TMP_Text obj2 = Text((Transform)(object)val2, "CARTUR'S", 16f, Color.white);
			obj2.alignment = (TextAlignmentOptions)514;
			obj2.characterSpacing = 8f;
			Fill(obj2.rectTransform, new Vector2(0f, 1f), Vector2.one, new Vector2(0f, -22f), Vector2.zero);
			TMP_Text val5 = Text((Transform)(object)val2, "RUNE<color=#FFFFFF>UI</color>", 45f, _accent);
			if ((Object)(object)val != (Object)null)
			{
				val5.font = val;
			}
			val5.richText = true;
			val5.alignment = (TextAlignmentOptions)514;
			Fill(val5.rectTransform, Vector2.zero, new Vector2(1f, 1f), Vector2.zero, new Vector2(0f, -20f));
		}

		private static Sprite Hollow()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			return Flat(Color.clear);
		}

		private static Sprite Soft()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(32, 32, (TextureFormat)4, false)
			{
				wrapMode = (TextureWrapMode)1
			};
			for (int i = 0; i < 32; i++)
			{
				for (int j = 0; j < 32; j++)
				{
					float num = Mathf.Min(Mathf.Min(j, 31 - j), Mathf.Min(i, 31 - i));
					float num2 = Mathf.SmoothStep(0f, 1f, Mathf.Clamp01(num / 15f));
					val.SetPixel(j, i, new Color(1f, 1f, 1f, num2));
				}
			}
			val.Apply();
			return Sprite.Create(val, new Rect(0f, 0f, 32f, 32f), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0, new Vector4(15f, 15f, 15f, 15f));
		}

		private static Sprite Gradient(Color top, Color bottom)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//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_0023: 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_0060: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(1, 32, (TextureFormat)4, false)
			{
				wrapMode = (TextureWrapMode)1
			};
			for (int i = 0; i < 32; i++)
			{
				val.SetPixel(0, i, Color.Lerp(bottom, top, (float)i / 31f));
			}
			val.Apply();
			return Sprite.Create(val, new Rect(0f, 0f, 1f, 32f), new Vector2(0.5f, 0.5f));
		}

		private static Sprite Flat(Color fill)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return Flat(fill, Edge);
		}

		private static Sprite Flat(Color fill, Color edge)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			//IL_005f: 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_008e: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(3, 3, (TextureFormat)4, false)
			{
				filterMode = (FilterMode)0,
				wrapMode = (TextureWrapMode)1
			};
			for (int i = 0; i < 3; i++)
			{
				for (int j = 0; j < 3; j++)
				{
					val.SetPixel(j, i, (j == 1 && i == 1) ? fill : edge);
				}
			}
			val.Apply();
			Sprite obj = Sprite.Create(val, new Rect(0f, 0f, 3f, 3f), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0, new Vector4(1f, 1f, 1f, 1f));
			((Object)obj).name = "ccs_" + ColorUtility.ToHtmlStringRGBA(fill) + "_" + ColorUtility.ToHtmlStringRGBA(edge);
			return obj;
		}

		private static Color Hex(int rgb, float a = 1f)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			return new Color((float)((rgb >> 16) & 0xFF) / 255f, (float)((rgb >> 8) & 0xFF) / 255f, (float)(rgb & 0xFF) / 255f, a);
		}

		private static void Box(RectTransform rt, Rect u)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: 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_005d: Unknown result type (might be due to invalid IL or missing references)
			Vector2 anchorMin = (rt.anchorMax = Vector2.zero);
			rt.anchorMin = anchorMin;
			rt.pivot = new Vector2(0.5f, 0.5f);
			rt.offsetMin = new Vector2(((Rect)(ref u)).xMin, 776f - ((Rect)(ref u)).yMax);
			rt.offsetMax = new Vector2(((Rect)(ref u)).xMax, 776f - ((Rect)(ref u)).yMin);
		}

		private static Image Frame(GameObject go, string file)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			Image val = go.AddComponent<Image>();
			if (s_rune)
			{
				val.sprite = Flat(new Color(0.054f, 0.054f, 0.054f, 1f));
				val.type = (Type)1;
				val.pixelsPerUnitMultiplier = s_runePx;
				return val;
			}
			Sprite val2 = LoadSprite(file, 20f);
			if ((Object)(object)val2 == (Object)null)
			{
				((Graphic)val).color = Fallback;
				return val;
			}
			val.sprite = val2;
			val.type = (Type)1;
			val.pixelsPerUnitMultiplier = 2.5f;
			return val;
		}

		private void BuildPanel(Transform canvas)
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: 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_0068: 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_0099: 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_00fe: 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_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)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: 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_02e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0318: Unknown result type (might be due to invalid IL or missing references)
			//IL_033d: 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_037d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0418: Unknown result type (might be due to invalid IL or missing references)
			//IL_0432: Unknown result type (might be due to invalid IL or missing references)
			//IL_0442: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0511: Unknown result type (might be due to invalid IL or missing references)
			//IL_053b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0540: Unknown result type (might be due to invalid IL or missing references)
			//IL_0545: Unknown result type (might be due to invalid IL or missing references)
			//IL_054a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0563: Unknown result type (might be due to invalid IL or missing references)
			//IL_059b: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_061a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0630: Unknown result type (might be due to invalid IL or missing references)
			//IL_0646: Unknown result type (might be due to invalid IL or missing references)
			//IL_065c: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: 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_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0686: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0828: Unknown result type (might be due to invalid IL or missing references)
			//IL_082a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0854: Unknown result type (might be due to invalid IL or missing references)
			//IL_0873: Unknown result type (might be due to invalid IL or missing references)
			//IL_087b: Unknown result type (might be due to invalid IL or missing references)
			//IL_087e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0888: Unknown result type (might be due to invalid IL or missing references)
			//IL_088e: Unknown result type (might be due to invalid IL or missing references)
			//IL_089f: Unknown result type (might be due to invalid IL or missing references)
			//IL_08a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_08b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_08f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0907: Unknown result type (might be due to invalid IL or missing references)
			s_rune = false;
			if (Chainloader.PluginInfos.ContainsKey("com.jekkle.valheim.carturruneui"))
			{
				Rune(((Component)canvas).GetComponent<Canvas>());
			}
			_panel = Rect("CarturCharSelect_Menu", canvas);
			RectTransform panel = _panel;
			RectTransform panel2 = _panel;
			RectTransform panel3 = _panel;
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(1f, 0.5f);
			panel3.pivot = val;
			Vector2 anchorMin = (panel2.anchorMax = val);
			panel.anchorMin = anchorMin;
			_panel.sizeDelta = new Vector2(420f, 776f);
			_panel.anchoredPosition = new Vector2(-32f, 0f);
			Canvas obj = ((Component)_panel).gameObject.AddComponent<Canvas>();
			obj.overridePixelPerfect = true;
			obj.pixelPerfect = true;
			((Component)_panel).gameObject.AddComponent<GraphicRaycaster>();
			RectTransform obj2 = Rect("Shadow", (Transform)(object)_panel);
			Fill(obj2, Vector2.zero, Vector2.one, new Vector2(0f - ShadowBlur, 0f - ShadowBlur - ShadowDrop), new Vector2(ShadowBlur, ShadowBlur - ShadowDrop));
			Image obj3 = ((Component)obj2).gameObject.AddComponent<Image>();
			obj3.sprite = Soft();
			obj3.type = (Type)1;
			((Graphic)obj3).color = ShadowColor;
			((Graphic)obj3).raycastTarget = false;
			RectTransform obj4 = Rect("Frame", (Transform)(object)_panel);
			Fill(obj4, Vector2.zero, Vector2.one, Vector2.zero, Vector2.zero);
			Frame(((Component)obj4).gameObject, "well.png");
			if (!s_rune)
			{
				RectTransform obj5 = Rect("Shade", (Transform)(object)_panel);
				Fill(obj5, Vector2.zero, Vector2.one, new Vector2(8f, 8f), new Vector2(-8f, -8f));
				Image obj6 = ((Component)obj5).gameObject.AddComponent<Image>();
				obj6.sprite = Gradient(new Color(0f, 0f, 0f, 0f), new Color(0f, 0f, 0f, 0.35f));
				((Graphic)obj6).raycastTarget = false;
				RectTransform obj7 = Rect("Highlight", (Transform)(object)_panel);
				Fill(obj7, new Vector2(0f, 1f), Vector2.one, new Vector2(8f, -9f), new Vector2(-8f, -8f));
				((Graphic)((Component)obj7).gameObject.AddComponent<Image>()).color = new Color(0.55f, 0.41f, 0.08f, 0.25f);
			}
			RectTransform val3 = Rect("Band", (Transform)(object)_panel);
			Box(val3, BandBox);
			((Graphic)((Component)val3).gameObject.AddComponent<Image>()).color = Band;
			RectTransform obj8 = Rect("Rule", (Transform)(object)val3);
			Fill(obj8, Vector2.zero, new Vector2(1f, 0f), Vector2.zero, new Vector2(0f, 1f));
			((Graphic)((Component)obj8).gameObject.AddComponent<Image>()).color = BandRule;
			TMP_Text obj9 = Text((Transform)(object)_panel, "CHARACTERS", TitleSize, Gold);
			obj9.characterSpacing = TitleSpacing;
			obj9.alignment = (TextAlignmentOptions)514;
			Box(obj9.rectTransform, TitleBox);
			TMP_Text obj10 = Text((Transform)(object)_panel, "Double-click a character to play", HintSize, HintColor);
			obj10.characterSpacing = HintSpacing;
			obj10.alignment = (TextAlignmentOptions)514;
			Box(obj10.rectTransform, HintBox);
			_view = Rect("Viewport", (Transform)(object)_panel);
			Box(_view, ListBox);
			((Component)_view).gameObject.AddComponent<RectMask2D>();
			((Graphic)((Component)_view).gameObject.AddComponent<Image>()).color = Color.clear;
			_content = Rect("Content", (Transform)(object)_view);
			_content.anchorMin = new Vector2(0f, 1f);
			_content.anchorMax = new Vector2(1f, 1f);
			_content.pivot = new Vector2(0.5f, 1f);
			_content.sizeDelta = Vector2.zero;
			VerticalLayoutGroup obj11 = ((Component)_content).gameObject.AddComponent<VerticalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)obj11).spacing = 2f;
			bool childControlHeight = (((HorizontalOrVerticalLayoutGroup)obj11).childControlWidth = true);
			((HorizontalOrVerticalLayoutGroup)obj11).childControlHeight = childControlHeight;
			((HorizontalOrVerticalLayoutGroup)obj11).childForceExpandHeight = false;
			((Component)_content).gameObject.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2;
			ScrollRect obj12 = ((Component)_view).gameObject.AddComponent<ScrollRect>();
			obj12.viewport = _view;
			obj12.content = _content;
			obj12.horizontal = false;
			obj12.movementType = (MovementType)2;
			obj12.scrollSensitivity = 40f;
			RectTransform val4 = Rect("Scrollbar", (Transform)(object)_panel);
			Box(val4, BarBox);
			((Graphic)((Component)val4).gameObject.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.5f);
			Scrollbar val5 = ((Component)val4).gameObject.AddComponent<Scrollbar>();
			val5.direction = (Direction)2;
			RectTransform val6 = Rect("Handle", (Transform)(object)val4);
			Fill(val6, Vector2.zero, Vector2.one, Vector2.zero, Vector2.zero);
			Image val7 = ((Component)val6).gameObject.AddComponent<Image>();
			((Graphic)val7).color = Thumb;
			val5.handleRect = val6;
			((Selectable)val5).targetGraphic = (Graphic)(object)val7;
			obj12.verticalScrollbar = val5;
			obj12.verticalScrollbarVisibility = (ScrollbarVisibility)1;
			_empty = Text((Transform)(object)_view, "No characters yet", 18f, Muted);
			_empty.alignment = (TextAlignmentOptions)514;
			Fill(_empty.rectTransform, Vector2.zero, Vector2.one, Vector2.zero, Vector2.zero);
			Transform val8 = _fs.m_selectCharacterPanel.transform.Find("BottomWindow");
			s_button = LoadSprite("button_thin.png", 20f);
			Seat(_fs.m_csStartButton, StartBox);
			Seat(_fs.m_csNewBigButton, StartBox);
			Seat(_fs.m_csNewButton, NewBox);
			Seat(_fs.m_csRemoveButton, RemoveBox);
			object b;
			if (val8 == null)
			{
				b = null;
			}
			else
			{
				Transform obj13 = val8.Find("ManageSaves");
				b = ((obj13 != null) ? ((Component)obj13).GetComponent<Button>() : null);
			}
			Seat((Button)b, SavesBox);
			object b2;
			if (val8 == null)
			{
				b2 = null;
			}
			else
			{
				Transform obj14 = val8.Find("Back");
				b2 = ((obj14 != null) ? ((Component)obj14).GetComponent<Button>() : null);
			}
			Seat((Button)b2, BackBox);
			if (_seatFailed)
			{
				Core.Log.LogWarning((object)"vanilla button bar left up: not every button could be moved into the menu");
			}
			else if (val8 != null)
			{
				((Component)val8).gameObject.SetActive(false);
			}
			if (s_rune)
			{
				RuneLogo();
			}
			if (s_rune)
			{
				AccessTools.Method(AccessTools.TypeByName("CarturRuneUI.Skin"), "Apply", (Type[])null, (Type[])null)?.Invoke(null, new object[2]
				{
					_panel,
					new Transform[0]
				});
			}
			if (s_rune)
			{
				Button[] componentsInChildren = ((Component)_panel).GetComponentsInChildren<Button>(true);
				Color val10 = default(Color);
				Color edge = default(Color);
				foreach (Button val9 in componentsInChildren)
				{
					if (!((Object)(object)((Component)val9).transform.parent != (Object)(object)_panel))
					{
						bool flag2 = (Object)(object)val9 == (Object)(object)_fs.m_csStartButton || (Object)(object)val9 == (Object)(object)_fs.m_csNewBigButton;
						((Color)(ref val10))..ctor(0.07f, 0.07f, 0.07f, 1f);
						Color val11 = (flag2 ? Color.Lerp(val10, _accent, 0.18f) : val10);
						((Color)(ref edge))..ctor(_accent.r, _accent.g, _accent.b, flag2 ? 0.8f : 0.4f);
						Image component = ((Component)val9).GetComponent<Image>();
						if (!((Object)(object)component == (Object)null))
						{
							component.sprite = Flat(val11, edge);
							component.overrideSprite = null;
							component.type = (Type)1;
							component.pixelsPerUnitMultiplier = s_runePx;
							((Graphic)component).color = Color.white;
							((Selectable)val9).targetGraphic = (Graphic)(object)component;
							((Selectable)val9).transition = (Transition)2;
							SpriteState spriteState = default(SpriteState);
							((SpriteState)(ref spriteState)).highlightedSprite = Flat(Color.Lerp(val11, _accent, 0.14f), _accent);
							((SpriteState)(ref spriteState)).pressedSprite = Flat(Color.Lerp(val10, Color.black, 0.4f), _accent);
							((SpriteState)(ref spriteState)).selectedSprite = component.sprite;
							((SpriteState)(ref spriteState)).disabledSprite = Flat(val10, new Color(_accent.r, _accent.g, _accent.b, 0.15f));
							((Selectable)val9).spriteState = spriteState;
						}
					}
				}
			}
			if (s_rune)
			{
				Button val12 = ((IEnumerable<Button>)((Component)_panel).GetComponentsInChildren<Button>(true)).FirstOrDefault((Func<Button, bool>)((Button x) => ((Object)x).name == "Back"));
				if ((Object)(object)val12 != (Object)null)
				{
					Label(val12, null, 0.6f);
				}
			}
			((Component)_panel).gameObject.SetActive(false);
		}

		private void FitPanel()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			Rect rect = ((RectTransform)((Transform)_panel).parent).rect;
			float height = ((Rect)(ref rect)).height;
			if (!Mathf.Approximately(height, _canvasH))
			{
				_canvasH = height;
				float num = Mathf.Min(1f, 0.86f * height / 776f);
				((Transform)_panel).localScale = new Vector3(num, num, 1f);
				float num2 = (height - 776f * num) * 0.5f;
				if ((Object)(object)_logo != (Object)null)
				{
					_logo.transform.localScale = Vector3.one * Mathf.Clamp01(num2 / 100f);
				}
			}
		}

		private static Sprite LoadSprite(string file, float border)
		{
			//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_0041: Expected O, but got Unknown
			//IL_00cc: 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_00eb: Unknown result type (might be due to invalid IL or missing references)
			string text = Path.Combine(Core.AssetsDir, file);
			if (!File.Exists(text))
			{
				Core.Log.LogWarning((object)("missing " + text + " - plain panel instead"));
				return null;
			}
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false)
			{
				wrapMode = (TextureWrapMode)1
			};
			MethodInfo methodInfo = AccessTools.TypeByName("UnityEngine.ImageConversion")?.GetMethods(BindingFlags.Static | BindingFlags.Public).FirstOrDefault((MethodInfo m) => m.Name == "LoadImage" && m.GetParameters().Length == 3 && m.GetParameters()[1].ParameterType == typeof(byte[]));
			if (methodInfo == null || !(bool)methodInfo.Invoke(null, new object[3]
			{
				val,
				File.ReadAllBytes(text),
				false
			}))
			{
				return null;
			}
			return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0, new Vector4(border, border, border, border));
		}

		private void Seat(Button b, Rect px)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: 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_0045: Expected O, but got Unknown
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Invalid comparison between Unknown and I4
			//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_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Invalid comparison between Unknown and I4
			//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_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: 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_00f9: 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_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)b == (Object)null)
			{
				_seatFailed = true;
				return;
			}
			RectTransform val = (RectTransform)((Component)b).transform;
			((Transform)val).SetParent((Transform)(object)_panel, false);
			((Transform)val).localScale = Vector3.one;
			((Transform)val).localRotation = Quaternion.identity;
			Box(val, px);
			if (s_rune)
			{
				int num;
				if ((int)((Selectable)b).transition == 2)
				{
					SpriteState spriteState = ((Selectable)b).spriteState;
					num = (((Object)(object)((SpriteState)(ref spriteState)).highlightedSprite != (Object)null) ? 1 : 0);
				}
				else
				{
					num = 0;
				}
				int num2;
				if ((int)((Selectable)b).transition == 1 && (Object)(object)((Selectable)b).targetGraphic != (Object)null)
				{
					ColorBlock colors = ((Selectable)b).colors;
					Color highlightedColor = ((ColorBlock)(ref colors)).highlightedColor;
					colors = ((Selectable)b).colors;
					num2 = ((highlightedColor != ((ColorBlock)(ref colors)).normalColor) ? 1 : 0);
				}
				else
				{
					num2 = 0;
				}
				bool flag = (byte)num2 != 0;
				if (((uint)num | (flag ? 1u : 0u)) != 0)
				{
					return;
				}
			}
			Image component = ((Component)b).GetComponent<Image>();
			if (!s_rune && (Object)(object)component != (Object)null && (Object)(object)s_button != (Object)null)
			{
				component.sprite = s_button;
				component.overrideSprite = null;
				component.type = (Type)1;
				component.pixelsPerUnitMultiplier = 3.2f;
				((Graphic)component).color = Color.white;
			}
			((Selectable)b).targetGraphic = (Graphic)(((Object)(object)component != (Object)null) ? ((object)component) : ((object)((Component)b).GetComponent<Graphic>()));
			((Selectable)b).transition = (Transition)1;
			ColorBlock colors2 = ((Selectable)b).colors;
			Color val2 = default(Color);
			((Color)(ref val2))..ctor(0.66f, 0.64f, 0.6f, 1f);
			((ColorBlock)(ref colors2)).selectedColor = val2;
			((ColorBlock)(ref colors2)).normalColor = val2;
			((ColorBlock)(ref colors2)).highlightedColor = new Color(1f, 0.92f, 0.72f, 1f);
			((ColorBlock)(ref colors2)).pressedColor = new Color(0.55f, 0.5f, 0.42f, 1f);
			((ColorBlock)(ref colors2)).disabledColor = new Color(0.45f, 0.45f, 0.45f, 0.6f);
			((ColorBlock)(ref colors2)).colorMultiplier = 1.3f;
			((ColorBlock)(ref colors2)).fadeDuration = 0.08f;
			((Selectable)b).colors = colors2;
			if (!s_rune)
			{
				bool flag2 = (Object)(object)b == (Object)(object)_fs.m_csStartButton || (Object)(object)b == (Object)(object)_fs.m_csNewBigButton;
				if (flag2)
				{
					((Color)(ref val2))..ctor(0.77f, 0.71f, 0.58f, 1f);
					((ColorBlock)(ref colors2)).selectedColor = val2;
					((ColorBlock)(ref colors2)).normalColor = val2;
					((Selectable)b).colors = colors2;
				}
				Label(b, flag2 ? 15f : 12f, flag2 ? 1f : 0.8f);
			}
		}

		private static void Label(Button b, float? size, float alpha)
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			Color val = default(Color);
			((Color)(ref val))..ctor(Gold.r, Gold.g, Gold.b, alpha);
			TMP_Text[] componentsInChildren = ((Component)b).GetComponentsInChildren<TMP_Text>(true);
			foreach (TMP_Text val2 in componentsInChildren)
			{
				if (!((Object)val2.transform.parent).name.StartsWith("gamepad_hint"))
				{
					((Graphic)val2).color = val;
					if (size.HasValue)
					{
						val2.enableAutoSizing = false;
						val2.fontSize = size.Value;
					}
				}
			}
			ButtonTextColor[] componentsInChildren2 = ((Component)b).GetComponentsInChildren<ButtonTextColor>(true);
			foreach (ButtonTextColor obj in componentsInChildren2)
			{
				FieldInfo[] labelColours = LabelColours;
				for (int j = 0; j < labelColours.Length; j++)
				{
					labelColours[j]?.SetValue(obj, val);
				}
			}
		}

		private static string Source(PlayerProfile p)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			if ((int)p.m_fileSource != 4)
			{
				return "Local";
			}
			return "Cloud";
		}

		private static string Played(PlayerProfile p)
		{
			DateTime dateTime = LastPlayed(p);
			if (!(dateTime == DateTime.MinValue))
			{
				return "Last played " + dateTime.ToString("d MMM yyyy");
			}
			return "";
		}

		private void ScrollTo(int row)
		{
			//IL_000f: 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_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_002a: 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_0063: Unknown result type (might be due to invalid IL or missing references)
			float num = (float)row * 38f;
			Rect rect = _view.rect;
			float height = ((Rect)(ref rect)).height;
			Vector2 anchoredPosition = _content.anchoredPosition;
			if (num < anchoredPosition.y)
			{
				anchoredPosition.y = num;
			}
			else if (num + 36f > anchoredPosition.y + height)
			{
				anchoredPosition.y = num + 36f - height;
			}
			_content.anchoredPosition = anchoredPosition;
		}

		private void BuildRows(List<PlayerProfile> recent)
		{
			//IL_00bb: 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_00ec: Expected O, but got Unknown
			//IL_0104: 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_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: 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_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0302: Unknown result type (might be due to invalid IL or missing references)
			//IL_0326: Unknown result type (might be due to invalid IL or missing references)
			//IL_032b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0330: Unknown result type (might be due to invalid IL or missing references)
			//IL_033f: Unknown result type (might be due to invalid IL or missing references)
			foreach (Row row in _rows)
			{
				Object.Destroy((Object)(object)((Component)row.Bg).gameObject);
			}
			_rows.Clear();
			foreach (PlayerProfile p in recent)
			{
				RectTransform val = Rect("Row", (Transform)(object)_content);
				((Component)val).gameObject.AddComponent<LayoutElement>().preferredHeight = 36f;
				Image bg = ((Component)val).gameObject.AddComponent<Image>();
				((Graphic)bg).color = RowNormal;
				((UnityEvent)((Component)val).gameObject.AddComponent<Button>().onClick).AddListener((UnityAction)delegate
				{
					Click(p);
				});
				RectTransform mark = Rect("Selected", (Transform)(object)val);
				Fill(mark, Vector2.zero, new Vector2(0f, 1f), Vector2.zero, new Vector2(BarWidth, 0f));
				((Graphic)((Component)mark).gameObject.AddComponent<Image>()).color = Mark;
				((Component)mark).gameObject.SetActive(false);
				RectTransform obj = Rect("Separator", (Transform)(object)val);
				Fill(obj, Vector2.zero, new Vector2(1f, 0f), Vector2.zero, new Vector2(0f, 1f));
				Image obj2 = ((Component)obj).gameObject.AddComponent<Image>();
				((Graphic)obj2).color = Separator;
				((Graphic)obj2).raycastTarget = false;
				RectTransform val2 = Rect("Body", (Transform)(object)val);
				Fill(val2, Vector2.zero, Vector2.one, Vector2.zero, Vector2.zero);
				RowEvents hover = ((Component)val).gameObject.AddComponent<RowEvents>();
				hover.Body = val2;
				hover.Enter = delegate
				{
					//IL_0040: 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)
					_rowHover = true;
					hover.Slide = 2f;
					((Graphic)bg).color = (((Component)mark).gameObject.activeSelf ? RowSelectedHover : RowHover);
					Slot slot = _slots.FirstOrDefault((Slot x) => x.P == p);
					if (slot != null && slot != _hovered)
					{
						Play(slot);
					}
					_hovered = slot;
				};
				hover.Exit = delegate
				{
					//IL_0051: 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)
					_rowHover = false;
					_hovered = null;
					hover.Slide = 0f;
					((Graphic)bg).color = (((Component)mark).gameObject.activeSelf ? RowSelected : RowNormal);
				};
				Fill(Text((Transform)(object)val2, p.GetName(), NameSize, Gold).rectTransform, Vector2.zero, new Vector2(0.4f, 1f), new Vector2(14f, 0f), Vector2.zero);
				TMP_Text obj3 = Text((Transform)(object)val2, Source(p).ToUpperInvariant(), MetaSize, Meta);
				obj3.characterSpacing = 2f;
				obj3.alignment = (TextAlignmentOptions)514;
				Fill(obj3.rectTransform, new Vector2(0.4f, 0f), new Vector2(0.55f, 1f), Vector2.zero, Vector2.zero);
				TMP_Text obj4 = Text((Transform)(object)val2, Played(p), MetaSize, Meta);
				obj4.alignment = (TextAlignmentOptions)4100;
				Fill(obj4.rectTransform, new Vector2(0.55f, 0f), Vector2.one, Vector2.zero, new Vector2(-12f, 0f));
				_rows.Add(new Row
				{
					P = p,
					Bg = bg,
					Bar = ((Component)mark).gameObject
				});
			}
		}

		private static RectTransform Rect(string name, Transform parent)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) });
			val.transform.SetParent(parent, false);
			return (RectTransform)val.transform;
		}

		private static void Fill(RectTransform rt, Vector2 min, Vector2 max, Vector2 offMin, Vector2 offMax)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			rt.anchorMin = min;
			rt.anchorMax = max;
			rt.offsetMin = offMin;
			rt.offsetMax = offMax;
		}

		private TMP_Text Text(Transform parent, string s, float size, Color c)
		{
			//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_004a: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Text", new Type[1] { typeof(RectTransform) });
			val.transform.SetParent(parent, false);
			TextMeshProUGUI obj = val.AddComponent<TextMeshProUGUI>();
			((TMP_Text)obj).font = _font;
			((TMP_Text)obj).text = s;
			((TMP_Text)obj).fontSize = size;
			((Graphic)obj).color = c;
			((Graphic)obj).raycastTarget = false;
			((TMP_Text)obj).alignment = (TextAlignmentOptions)4097;
			((TMP_Text)obj).textWrappingMode = (TextWrappingModes)0;
			((TMP_Text)obj).overflowMode = (TextOverflowModes)1;
			return (TMP_Text)(object)obj;
		}
	}
	internal sealed class RowEvents : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler
	{
		public Action Enter;

		public Action Exit;

		public RectTransform Body;

		public float Slide;

		private void Update()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)Body == (Object)null))
			{
				Vector2 anchoredPosition = Body.anchoredPosition;
				if (!Mathf.Approximately(anchoredPosition.x, Slide))
				{
					anchoredPosition.x = Mathf.MoveTowards(anchoredPosition.x, Slide, Time.unscaledDeltaTime * 2f / 0.15f);
					Body.anchoredPosition = anchoredPosition;
				}
			}
		}

		public void OnPointerEnter(PointerEventData e)
		{
			Enter?.Invoke();
		}

		public void OnPointerExit(PointerEventData e)
		{
			Exit?.Invoke();
		}
	}
	[BepInPlugin("com.jekkle.valheim.carturcharselect", "Cartur's Character Select", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string Guid = "com.jekkle.valheim.carturcharselect";

		public const string PluginVersion = "1.0.0";

		private void Awake()
		{
			Core.Install(((BaseUnityPlugin)this).Logger, Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "Assets"), 2);
		}
	}
}