Decompiled source of SkillsReworked v2.2.0

SkillsReworked.dll

Decompiled 3 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using Groups;
using HarmonyLib;
using JetBrains.Annotations;
using Jotunn;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Extensions;
using Jotunn.Managers;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using SkillsReworked.Api;
using SkillsReworked.Bootstrap;
using SkillsReworked.Commands;
using SkillsReworked.Infrastructure.Networking;
using SkillsReworked.Integration.Groups;
using SkillsReworked.Integration.JotunnSync;
using SkillsReworked.Integration.Party;
using SkillsReworked.Integration.SkillManager;
using SkillsReworked.Integration.SocialSystem;
using SkillsReworked.Persistence;
using SkillsReworked.Systems.Attributes;
using SkillsReworked.Systems.Common;
using SkillsReworked.Systems.Costs;
using SkillsReworked.Systems.Migration;
using SkillsReworked.Systems.Prestige;
using SkillsReworked.Systems.Progression;
using SkillsReworked.Systems.Rebirth;
using SkillsReworked.Systems.Reset;
using SkillsReworked.Systems.Rewards;
using SkillsReworked.UI.Dialogs;
using SkillsReworked.UI.Gamepad;
using SkillsReworked.UI.LevelHud;
using SkillsReworked.UI.SkillPanel;
using SkillsReworked.UI.SkillPanel.Admin;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: IgnoresAccessChecksTo("assembly_guiutils")]
[assembly: IgnoresAccessChecksTo("assembly_utils")]
[assembly: IgnoresAccessChecksTo("assembly_valheim")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("SkillsReworked")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+3dcfb829ed3aad1d5986daa8216ab4d0e33a8f49")]
[assembly: AssemblyProduct("SkillsReworked")]
[assembly: AssemblyTitle("SkillsReworked")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[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 SkillsReworked.UI.SkillPanel
{
	public class BlinkingTextEffect : MonoBehaviour
	{
		public Text Target;

		public Color ColorA = Color.white;

		public Color ColorB = Color.white;

		public float Speed = 2f;

		private void Update()
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)Target == (Object)null))
			{
				float num = (Mathf.Sin(Time.unscaledTime * Speed) + 1f) * 0.5f;
				((Graphic)Target).color = Color.Lerp(ColorA, ColorB, num);
			}
		}

		public static Color Darken(Color c, float factor)
		{
			//IL_0000: 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_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			return new Color(c.r * factor, c.g * factor, c.b * factor, c.a);
		}

		public static void SetActive(Text target, bool active, Color colorA, Color colorB, Color restColor, float speed = 5f)
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: 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_0034: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)target == (Object)null)
			{
				return;
			}
			if (!active)
			{
				BlinkingTextEffect component = ((Component)target).GetComponent<BlinkingTextEffect>();
				if ((Object)(object)component != (Object)null)
				{
					((Behaviour)component).enabled = false;
				}
				((Graphic)target).color = restColor;
				return;
			}
			BlinkingTextEffect blinkingTextEffect = ((Component)target).GetComponent<BlinkingTextEffect>();
			if ((Object)(object)blinkingTextEffect == (Object)null)
			{
				blinkingTextEffect = ((Component)target).gameObject.AddComponent<BlinkingTextEffect>();
			}
			blinkingTextEffect.Target = target;
			blinkingTextEffect.ColorA = colorA;
			blinkingTextEffect.ColorB = colorB;
			blinkingTextEffect.Speed = speed;
			((Behaviour)blinkingTextEffect).enabled = true;
		}
	}
	public static class SkillListLayout
	{
		private struct Row
		{
			public GameObject Object;

			public SkillRowStyle Style;

			public SkillRowKind Kind;

			public AttributeId Attribute;

			public SkillType SkillType;
		}

		private static readonly List<Row> Rows = new List<Row>();

		private static readonly HashSet<AttributeId> Expanded = new HashSet<AttributeId>();

		private static SkillsDialog _dialog;

		private static GameObject _noAttributeHeader;

		public static bool IsAdminMode { get; private set; }

		public static bool IsCollapsed(AttributeId attribute)
		{
			return !Expanded.Contains(attribute);
		}

		public static void Build(SkillsDialog dialog, List<Skill> skillList)
		{
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: 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_00e0: 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_01d5: 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)
			if (!SkillUiController.SuppressAutoScroll)
			{
				Expanded.Clear();
			}
			_dialog = dialog;
			AdminAssignmentSession.Validate();
			IsAdminMode = AdminAssignmentSession.IsAvailable;
			AdminRowDecorations.DestroyAll();
			Rows.Clear();
			SkillRowController.DestroyAll();
			for (int i = 0; i < skillList.Count && i < dialog.m_elements.Count; i++)
			{
				GameObject val = dialog.m_elements[i];
				if ((Object)(object)val == (Object)null || skillList[i]?.m_info == null)
				{
					continue;
				}
				SkillType skill = skillList[i].m_info.m_skill;
				Row row = new Row
				{
					Object = val,
					SkillType = skill,
					Style = SkillRowStyle.For(val)
				};
				AttributeId attribute;
				AttributeId attribute2;
				if (skill == SkillsReworkedPlugin.LevelSkillType)
				{
					row.Kind = SkillRowKind.Level;
				}
				else if (AttributeRegistry.TryGetAttribute(skill, out attribute))
				{
					row.Kind = ((AttributeMappingService.IsActive(attribute) || IsAdminMode) ? SkillRowKind.Attribute : SkillRowKind.Hidden);
					row.Attribute = attribute;
				}
				else if (AttributeMappingService.TryGetAttributeFor(skill, out attribute2))
				{
					row.Kind = SkillRowKind.Skill;
					row.Attribute = attribute2;
				}
				else
				{
					row.Kind = SkillRowKind.Vanilla;
				}
				row.Style.Apply(row.Kind, IsAdminMode && IsSkillRow(row));
				Transform transform = val.transform;
				RectTransform val2 = (RectTransform)(object)((transform is RectTransform) ? transform : null);
				if (val2 != null)
				{
					if (IsAdminMode && row.Kind == SkillRowKind.Attribute)
					{
						AdminRowDecorations.DecorateAttribute(val2, row.Attribute);
					}
					else if (IsAdminMode && (row.Kind == SkillRowKind.Skill || row.Kind == SkillRowKind.Vanilla))
					{
						AdminRowDecorations.DecorateSkill(val2, skill);
					}
					else if (row.Kind == SkillRowKind.Attribute)
					{
						SkillRowDecorator.AddButtons(val2, skill, row.Attribute);
					}
				}
				Rows.Add(row);
			}
			EnsureNoAttributeHeader(dialog);
			AdminRowDecorations.Refresh();
			Relayout();
			RefreshPreview();
		}

		private static void EnsureNoAttributeHeader(SkillsDialog dialog)
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Expected O, but got Unknown
			//IL_00c2: 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_00dc: 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_00f9: 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_014c: 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)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			if (!IsAdminMode)
			{
				if ((Object)(object)_noAttributeHeader != (Object)null)
				{
					Object.Destroy((Object)(object)_noAttributeHeader);
				}
				_noAttributeHeader = null;
			}
			else if (!((Object)(object)_noAttributeHeader != (Object)null) && dialog.m_elements.Count != 0)
			{
				RectTransform val = (RectTransform)dialog.m_elements[0].transform;
				_noAttributeHeader = new GameObject("SkillsReworked_NoAttributeHeader", new Type[2]
				{
					typeof(RectTransform),
					typeof(Image)
				});
				RectTransform val2 = (RectTransform)_noAttributeHeader.transform;
				((Transform)val2).SetParent((Transform)(object)dialog.m_listRoot, false);
				val2.anchorMin = val.anchorMin;
				val2.anchorMax = val.anchorMax;
				val2.pivot = val.pivot;
				val2.sizeDelta = new Vector2(val.sizeDelta.x, dialog.m_spacing);
				((Graphic)_noAttributeHeader.GetComponent<Image>()).color = new Color(0f, 0f, 0f, 0.01f);
				((Graphic)GUIManager.Instance.CreateText(Localization.instance.Localize("$m2_sr_admin_no_attribute"), (Transform)(object)val2, new Vector2(0f, 0.5f), new Vector2(0f, 0.5f), new Vector2(110f, 0f), GUIManager.Instance.AveriaSerifBold, 16, GUIManager.Instance.ValheimOrange, true, Color.black, 200f, dialog.m_spacing, false).GetComponent<Text>()).raycastTarget = false;
				AdminRowDecorations.CreateDropGlow(val2);
			}
		}

		public static bool TryGetDropTarget(GameObject hovered, out AttributeId? target, out GameObject headerRow)
		{
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			target = null;
			headerRow = null;
			if (!IsAdminMode)
			{
				return false;
			}
			Transform val = (((Object)(object)hovered != (Object)null) ? hovered.transform : null);
			while ((Object)(object)val != (Object)null)
			{
				if ((Object)(object)_noAttributeHeader != (Object)null && (Object)(object)((Component)val).gameObject == (Object)(object)_noAttributeHeader)
				{
					headerRow = _noAttributeHeader;
					return true;
				}
				foreach (Row row in Rows)
				{
					if ((Object)(object)row.Object != (Object)(object)((Component)val).gameObject)
					{
						continue;
					}
					switch (row.Kind)
					{
					case SkillRowKind.Attribute:
						target = row.Attribute;
						headerRow = row.Object;
						return true;
					case SkillRowKind.Skill:
					case SkillRowKind.Vanilla:
						target = AdminAssignmentSession.GetEffectiveAttribute(row.SkillType);
						headerRow = (target.HasValue ? HeaderOf(target.Value) : _noAttributeHeader);
						return true;
					default:
						return false;
					}
				}
				val = val.parent;
			}
			return false;
		}

		private static GameObject HeaderOf(AttributeId attribute)
		{
			foreach (Row row in Rows)
			{
				if (row.Kind == SkillRowKind.Attribute && row.Attribute == attribute)
				{
					return row.Object;
				}
			}
			return null;
		}

		public static void Toggle(AttributeId attribute)
		{
			if (!Expanded.Remove(attribute))
			{
				Expanded.Add(attribute);
			}
			Relayout();
			foreach (SkillRowController activeController in SkillRowController.ActiveControllers)
			{
				activeController.RefreshCollapseArrow();
			}
		}

		public static void ShowPendingOrder()
		{
			Relayout();
		}

		private static void Relayout()
		{
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_dialog == (Object)null)
			{
				return;
			}
			if (IsAdminMode)
			{
				RelayoutAdmin();
				return;
			}
			int num = 0;
			foreach (Row row in Rows)
			{
				if ((Object)(object)row.Object == (Object)null)
				{
					continue;
				}
				bool flag = ((row.Kind == SkillRowKind.Skill) ? Expanded.Contains(row.Attribute) : (row.Kind != SkillRowKind.Hidden));
				row.Object.SetActive(flag);
				if (flag)
				{
					Transform transform = row.Object.transform;
					RectTransform val = (RectTransform)(object)((transform is RectTransform) ? transform : null);
					if (val != null)
					{
						val.anchoredPosition = new Vector2(0f, (float)(-num) * _dialog.m_spacing);
					}
					num++;
				}
			}
			_dialog.m_listRoot.SetSizeWithCurrentAnchors((Axis)1, Mathf.Max(_dialog.m_baseListSize, (float)num * _dialog.m_spacing));
		}

		private static void RelayoutAdmin()
		{
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			int index = 0;
			foreach (Row row in Rows)
			{
				if (row.Kind == SkillRowKind.Level)
				{
					Place(row.Object, row.Style, SkillRowKind.Level);
				}
			}
			AttributeId[] all = AttributeRegistry.All;
			foreach (AttributeId attributeId in all)
			{
				foreach (Row row2 in Rows)
				{
					if (row2.Kind == SkillRowKind.Attribute && row2.Attribute == attributeId)
					{
						Place(row2.Object, row2.Style, SkillRowKind.Attribute);
					}
				}
				foreach (Row item in SkillRowsIn(attributeId))
				{
					Place(item.Object, item.Style, SkillRowKind.Skill);
				}
			}
			if ((Object)(object)_noAttributeHeader != (Object)null)
			{
				((RectTransform)_noAttributeHeader.transform).anchoredPosition = new Vector2(0f, (float)(-(index++)) * _dialog.m_spacing);
			}
			foreach (Row item2 in SkillRowsIn(null))
			{
				Place(item2.Object, item2.Style, SkillRowKind.Vanilla);
			}
			_dialog.m_listRoot.SetSizeWithCurrentAnchors((Axis)1, Mathf.Max(_dialog.m_baseListSize, (float)index * _dialog.m_spacing));
			void Place(GameObject obj, SkillRowStyle style, SkillRowKind kind)
			{
				//IL_0034: 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)
				if (!((Object)(object)obj == (Object)null))
				{
					obj.SetActive(true);
					style?.Apply(kind, kind == SkillRowKind.Skill || kind == SkillRowKind.Vanilla);
					((RectTransform)obj.transform).anchoredPosition = new Vector2(0f, (float)(-(index++)) * _dialog.m_spacing);
				}
			}
		}

		private static IEnumerable<Row> SkillRowsIn(AttributeId? group)
		{
			foreach (Row row in Rows)
			{
				if (IsSkillRow(row) && !AdminAssignmentSession.IsAttributeChanged(row.SkillType) && AdminAssignmentSession.GetCurrentAttribute(row.SkillType) == group)
				{
					yield return row;
				}
			}
			foreach (KeyValuePair<SkillType, AttributeId?> move in AdminAssignmentSession.PendingAttributes)
			{
				if (move.Value != group)
				{
					continue;
				}
				foreach (Row row2 in Rows)
				{
					if (IsSkillRow(row2) && row2.SkillType == move.Key)
					{
						yield return row2;
					}
				}
			}
		}

		private static bool IsSkillRow(Row row)
		{
			return row.Kind == SkillRowKind.Skill || row.Kind == SkillRowKind.Vanilla;
		}

		public static void RefreshPreview()
		{
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			if (IsAdminMode)
			{
				return;
			}
			Player val = SkillUiController.CurrentPlayer ?? Player.m_localPlayer;
			Skills val2 = (((Object)(object)val != (Object)null) ? ((Character)val).GetSkills() : null);
			if ((Object)(object)val2 == (Object)null)
			{
				return;
			}
			foreach (Row row in Rows)
			{
				if (!((Object)(object)row.Object == (Object)null) && !((Object)(object)row.Style == (Object)null) && (row.Kind == SkillRowKind.Attribute || row.Kind == SkillRowKind.Skill))
				{
					int allocated = SkillUiController.GetAllocated(AttributeRegistry.GetSkillType(row.Attribute));
					Skill value;
					int num = (val2.m_skillData.TryGetValue(row.SkillType, out value) ? Mathf.FloorToInt(value.m_level) : 0);
					int plannedLevel = Mathf.Min(num + allocated, 100);
					row.Style.ShowLevel(num, plannedLevel, val2.GetSkillLevel(row.SkillType));
				}
			}
		}
	}
	public class SkillRowController : MonoBehaviour
	{
		public static readonly List<SkillRowController> ActiveControllers = new List<SkillRowController>();

		public SkillType SkillType;

		public AttributeId Attribute;

		public Text CounterText;

		public InputField CounterInput;

		internal GameObject PlusButtonObj;

		internal GameObject MinusButtonObj;

		internal GameObject CounterTextObj;

		internal GameObject ToggleButtonObj;

		internal readonly List<GameObject> GamepadHintObjs = new List<GameObject>();

		private void Awake()
		{
			ActiveControllers.Add(this);
		}

		private void OnDestroy()
		{
			ActiveControllers.Remove(this);
		}

		public void RefreshCounter()
		{
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00ee: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)CounterText == (Object)null)
			{
				return;
			}
			bool flag = IsSkillMaxed();
			if ((Object)(object)PlusButtonObj != (Object)null)
			{
				PlusButtonObj.SetActive(!flag);
			}
			if ((Object)(object)MinusButtonObj != (Object)null)
			{
				MinusButtonObj.SetActive(!flag);
			}
			if ((Object)(object)CounterTextObj != (Object)null)
			{
				CounterTextObj.SetActive(!flag);
			}
			if (!flag)
			{
				int allocated = SkillUiController.GetAllocated(SkillType);
				if ((Object)(object)CounterInput != (Object)null)
				{
					CounterInput.text = allocated.ToString();
				}
				else
				{
					CounterText.text = allocated.ToString();
				}
				BlinkingTextEffect.SetActive(CounterText, allocated > 0, BlinkingTextEffect.Darken(SkillUiController.PlannedColor, 0.55f), SkillUiController.PlannedColor, Color.white);
			}
		}

		public void ShowGamepadHints(bool show)
		{
			foreach (GameObject gamepadHintObj in GamepadHintObjs)
			{
				if ((Object)(object)gamepadHintObj != (Object)null)
				{
					gamepadHintObj.SetActive(show);
				}
			}
		}

		public void RefreshCollapseArrow()
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			Text val = (((Object)(object)ToggleButtonObj != (Object)null) ? ToggleButtonObj.GetComponentInChildren<Text>() : null);
			if ((Object)(object)val != (Object)null)
			{
				((Transform)((Graphic)val).rectTransform).localRotation = Quaternion.Euler(0f, 0f, SkillListLayout.IsCollapsed(Attribute) ? 0f : (-90f));
			}
		}

		private bool IsSkillMaxed()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			Player val = SkillUiController.CurrentPlayer ?? Player.m_localPlayer;
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			Skills skills = ((Character)val).GetSkills();
			Skill val2 = ((skills != null) ? skills.GetSkill(SkillType) : null);
			if (val2 == null)
			{
				return false;
			}
			return val2.m_level >= 100f;
		}

		public static void DestroyAll()
		{
			List<SkillRowController> list = new List<SkillRowController>(ActiveControllers);
			ActiveControllers.Clear();
			foreach (SkillRowController item in list)
			{
				if (!((Object)(object)item == (Object)null))
				{
					if ((Object)(object)item.PlusButtonObj != (Object)null)
					{
						Object.Destroy((Object)(object)item.PlusButtonObj);
					}
					if ((Object)(object)item.MinusButtonObj != (Object)null)
					{
						Object.Destroy((Object)(object)item.MinusButtonObj);
					}
					if ((Object)(object)item.CounterTextObj != (Object)null)
					{
						Object.Destroy((Object)(object)item.CounterTextObj);
					}
					if ((Object)(object)item.ToggleButtonObj != (Object)null)
					{
						Object.Destroy((Object)(object)item.ToggleButtonObj);
					}
					Object.Destroy((Object)(object)item);
				}
			}
		}
	}
	public static class SkillRowDecorator
	{
		public static void AddButtons(RectTransform row, SkillType skillType, AttributeId attribute)
		{
			//IL_002d: 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)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: 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_0098: Expected O, but got Unknown
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Expected O, but got Unknown
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Expected O, but got Unknown
			if ((Object)(object)row == (Object)null)
			{
				return;
			}
			SkillRowController skillRowController = ((Component)row).gameObject.AddComponent<SkillRowController>();
			skillRowController.SkillType = skillType;
			skillRowController.Attribute = attribute;
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(0f, 0.5f);
			GameObject val2 = GUIManager.Instance.CreateButton(">", (Transform)(object)row, val, val, new Vector2(142f, 0f), 18f, 24f);
			((UnityEvent)val2.GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				SkillListLayout.Toggle(attribute);
			});
			skillRowController.ToggleButtonObj = val2;
			skillRowController.RefreshCollapseArrow();
			GameObject val3 = GUIManager.Instance.CreateButton("+", (Transform)(object)row, val, val, new Vector2(190f, 0f), 24f, 24f);
			GameObject val4 = GUIManager.Instance.CreateButton("-", (Transform)(object)row, val, val, new Vector2(165f, 0f), 24f, 24f);
			GameObject val5 = CreateCounterInputField(row, val);
			skillRowController.CounterInput = val5.GetComponent<InputField>();
			skillRowController.CounterText = skillRowController.CounterInput.textComponent;
			skillRowController.PlusButtonObj = val3;
			skillRowController.MinusButtonObj = val4;
			skillRowController.CounterTextObj = val5;
			skillRowController.RefreshCounter();
			AddGamepadHint(skillRowController, val2, "JoyButtonA");
			AddGamepadHint(skillRowController, val4, "JoyDPadLeft");
			AddGamepadHint(skillRowController, val3, "JoyDPadRight");
			SkillRowController ctrl = skillRowController;
			((UnityEvent)val3.GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				//IL_0044: Unknown result type (might be due to invalid IL or missing references)
				//IL_0092: Unknown result type (might be due to invalid IL or missing references)
				//IL_0066: Unknown result type (might be due to invalid IL or missing references)
				Player val6 = SkillUiController.CurrentPlayer ?? Player.m_localPlayer;
				if (!((Object)(object)val6 == (Object)null) && SkillUiController.GetCurrentUnspent() > 0)
				{
					Skills skills = ((Character)val6).GetSkills();
					Skill val7 = ((skills != null) ? skills.GetSkill(ctrl.SkillType) : null);
					if (val7 != null)
					{
						float num = val7.m_level + (float)SkillUiController.GetAllocated(ctrl.SkillType) + 1f;
						if (num > 100f)
						{
							return;
						}
					}
					SkillUiController.ChangeAllocated(ctrl.SkillType, 1);
					ctrl.RefreshCounter();
					SkillUiController.RefreshPointsBadge();
				}
			});
			((UnityEvent)val4.GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				//IL_0007: 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)
				if (SkillUiController.GetAllocated(ctrl.SkillType) > 0)
				{
					SkillUiController.ChangeAllocated(ctrl.SkillType, -1);
					ctrl.RefreshCounter();
					SkillUiController.RefreshPointsBadge();
				}
			});
			bool suppressCounterInputEvent = false;
			((UnityEvent<string>)(object)skillRowController.CounterInput.onValueChanged).AddListener((UnityAction<string>)delegate(string value)
			{
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0041: Unknown result type (might be due to invalid IL or missing references)
				if (!suppressCounterInputEvent)
				{
					int.TryParse(value, out var result);
					int maxAllocatable = SkillUiController.GetMaxAllocatable(ctrl.SkillType);
					int num = Mathf.Clamp(result, 0, maxAllocatable);
					suppressCounterInputEvent = true;
					try
					{
						SkillUiController.SetAllocated(ctrl.SkillType, num);
						ctrl.RefreshCounter();
						if (num != result)
						{
							ctrl.CounterInput.caretPosition = ctrl.CounterInput.text.Length;
						}
					}
					finally
					{
						suppressCounterInputEvent = false;
					}
					SkillUiController.RefreshPointsBadge();
				}
			});
			((UnityEvent<string>)(object)skillRowController.CounterInput.onEndEdit).AddListener((UnityAction<string>)delegate(string value)
			{
				//IL_0010: 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)
				int.TryParse(value, out var result);
				int maxAllocatable = SkillUiController.GetMaxAllocatable(ctrl.SkillType);
				int value2 = Mathf.Clamp(result, 0, maxAllocatable);
				SkillUiController.SetAllocated(ctrl.SkillType, value2);
				ctrl.RefreshCounter();
				SkillUiController.RefreshPointsBadge();
			});
		}

		private static void AddGamepadHint(SkillRowController controller, GameObject button, string glyph)
		{
			//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)
			GameObject val = GamepadHints.CreateHint(button.transform, glyph);
			if (!((Object)(object)val == (Object)null))
			{
				val.transform.localScale = Vector3.one * 0.6f;
				controller.GamepadHintObjs.Add(val);
			}
		}

		private static GameObject CreateCounterInputField(RectTransform row, Vector2 anchor)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Expected O, but got Unknown
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Expected O, but got Unknown
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Counter", new Type[3]
			{
				typeof(RectTransform),
				typeof(Image),
				typeof(InputField)
			});
			val.transform.SetParent((Transform)(object)row, false);
			RectTransform val2 = (RectTransform)val.transform;
			val2.anchorMin = anchor;
			val2.anchorMax = anchor;
			val2.pivot = new Vector2(0.5f, 0.5f);
			val2.anchoredPosition = new Vector2(219f, 0f);
			val2.sizeDelta = new Vector2(30f, 20f);
			Image component = val.GetComponent<Image>();
			component.sprite = GUIManager.Instance.GetSprite("text_field");
			component.type = (Type)1;
			((Graphic)component).color = new Color(1f, 1f, 1f, 0.15f);
			((Graphic)component).raycastTarget = true;
			InputField component2 = val.GetComponent<InputField>();
			component2.lineType = (LineType)0;
			component2.contentType = (ContentType)2;
			component2.characterLimit = 3;
			GameObject val3 = new GameObject("Text", new Type[2]
			{
				typeof(RectTransform),
				typeof(Text)
			});
			val3.transform.SetParent(val.transform, false);
			RectTransform val4 = (RectTransform)val3.transform;
			val4.anchorMin = Vector2.zero;
			val4.anchorMax = Vector2.one;
			val4.offsetMin = Vector2.zero;
			val4.offsetMax = Vector2.zero;
			Text component3 = val3.GetComponent<Text>();
			component3.text = "0";
			component3.font = GUIManager.Instance.AveriaSerifBold;
			component3.fontSize = 16;
			((Graphic)component3).color = Color.white;
			component3.alignment = (TextAnchor)4;
			component3.supportRichText = false;
			Outline val5 = val3.AddComponent<Outline>();
			((Shadow)val5).effectColor = Color.black;
			component2.textComponent = component3;
			return val;
		}
	}
	public enum SkillRowKind
	{
		Level,
		Attribute,
		Skill,
		Vanilla,
		Hidden
	}
	public class SkillRowStyle : MonoBehaviour
	{
		private const float HeaderNameWidth = 96f;

		private const float SkillIndent = 18f;

		private const float SkillIconSize = 26f;

		private const float AdminNameRight = 109f;

		private RectTransform _iconBkg;

		private RectTransform _icon;

		private RectTransform _name;

		private Vector2 _iconBkgPos;

		private Vector2 _iconBkgSize;

		private Vector2 _iconSize;

		private Vector2 _namePos;

		private float _nameWidth;

		private TMP_Text _levelText;

		private Color _levelColor;

		private GuiBar _totalBar;

		public static SkillRowStyle For(GameObject row)
		{
			SkillRowStyle skillRowStyle = row.GetComponent<SkillRowStyle>();
			if ((Object)(object)skillRowStyle == (Object)null)
			{
				skillRowStyle = row.AddComponent<SkillRowStyle>();
				skillRowStyle.Capture();
			}
			return skillRowStyle;
		}

		private void Capture()
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			ref RectTransform iconBkg = ref _iconBkg;
			Transform obj = Utils.FindChild(((Component)this).transform, "icon_bkg", (IterativeSearchType)0);
			iconBkg = (RectTransform)(object)((obj is RectTransform) ? obj : null);
			ref RectTransform icon = ref _icon;
			Transform obj2 = Utils.FindChild(((Component)this).transform, "icon", (IterativeSearchType)0);
			icon = (RectTransform)(object)((obj2 is RectTransform) ? obj2 : null);
			ref RectTransform name = ref _name;
			Transform obj3 = Utils.FindChild(((Component)this).transform, "name", (IterativeSearchType)0);
			name = (RectTransform)(object)((obj3 is RectTransform) ? obj3 : null);
			if ((Object)(object)_iconBkg != (Object)null)
			{
				_iconBkgPos = _iconBkg.anchoredPosition;
				_iconBkgSize = _iconBkg.sizeDelta;
			}
			if ((Object)(object)_icon != (Object)null)
			{
				_iconSize = _icon.sizeDelta;
			}
			if ((Object)(object)_name != (Object)null)
			{
				_namePos = _name.anchoredPosition;
				Rect rect = _name.rect;
				_nameWidth = ((Rect)(ref rect)).width;
			}
			Transform obj4 = Utils.FindChild(((Component)this).transform, "leveltext", (IterativeSearchType)0);
			_levelText = ((obj4 != null) ? ((Component)obj4).GetComponent<TMP_Text>() : null);
			if ((Object)(object)_levelText != (Object)null)
			{
				_levelColor = ((Graphic)_levelText).color;
			}
			Transform obj5 = Utils.FindChild(((Component)this).transform, "levelbar_total", (IterativeSearchType)0);
			_totalBar = ((obj5 != null) ? ((Component)obj5).GetComponent<GuiBar>() : null);
		}

		public void Apply(SkillRowKind kind)
		{
			Apply(kind, admin: false);
		}

		public void Apply(SkillRowKind kind, bool admin)
		{
			//IL_002e: 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_003e: 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_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			bool flag = kind == SkillRowKind.Skill;
			float num = (flag ? 18f : 0f);
			if ((Object)(object)_iconBkg != (Object)null)
			{
				_iconBkg.anchoredPosition = _iconBkgPos + new Vector2(num, 0f);
				_iconBkg.sizeDelta = (Vector2)(flag ? new Vector2(26f, 26f) : _iconBkgSize);
			}
			if ((Object)(object)_icon != (Object)null)
			{
				_icon.sizeDelta = (Vector2)(flag ? new Vector2(26f, 26f) : _iconSize);
			}
			if ((Object)(object)_levelText != (Object)null && kind != SkillRowKind.Attribute && kind != SkillRowKind.Skill)
			{
				((Graphic)_levelText).color = _levelColor;
			}
			if ((Object)(object)_name != (Object)null)
			{
				float num2 = _namePos.x - _name.pivot.x * _nameWidth + num;
				float num3 = (admin ? Mathf.Max(20f, 109f - num2) : ((kind == SkillRowKind.Attribute) ? Mathf.Min(_nameWidth, 96f) : (_nameWidth - num)));
				_name.SetSizeWithCurrentAnchors((Axis)0, num3);
				_name.anchoredPosition = new Vector2(num2 + _name.pivot.x * num3, _namePos.y);
			}
		}

		public void ShowLevel(int currentLevel, int plannedLevel, float totalLevel)
		{
			//IL_0046: 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)
			bool flag = plannedLevel != currentLevel;
			if ((Object)(object)_levelText != (Object)null)
			{
				_levelText.text = (flag ? plannedLevel : currentLevel).ToString();
				((Graphic)_levelText).color = (flag ? SkillUiController.PlannedColor : _levelColor);
			}
			if ((Object)(object)_totalBar != (Object)null)
			{
				_totalBar.SetValue(Mathf.Max(totalLevel, (float)plannedLevel) / 100f);
			}
		}
	}
	public static class SkillUiController
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static UnityAction <0>__OnApplyConfirm;

			public static UnityAction <1>__OnApplyCancel;

			public static UnityAction <2>__OnRebirthConfirm;

			public static UnityAction <3>__OnRebirthCancel;

			public static UnityAction <4>__OnPrestigeConfirm;

			public static UnityAction <5>__OnPrestigeCancel;
		}

		public static Player CurrentPlayer;

		public static int BaseAvailablePoints;

		public static Text PointsText;

		public static Text PrestigeText;

		public static readonly Color PlannedColor = new Color(0.561f, 0.773f, 0.941f, 1f);

		private static readonly Dictionary<SkillType, int> _pendingAllocations = new Dictionary<SkillType, int>();

		public static float LastScrollPos = 1f;

		public static bool SuppressAutoScroll = false;

		public static RectTransform RootPanel;

		public static SkillsDialog CurrentDialog;

		private static GameObject _rebirthDialogRoot;

		private static GameObject _applyDialogRoot;

		private static GameObject _prestigeDialogRoot;

		private static Text _applyDialogLabel;

		private static Text _prestigeDialogLabel;

		public static GameObject PrestigeIconRoot;

		public static GameObject PointsBadgeRoot;

		public static Button PrestigeButton;

		public static Button ApplyButton;

		public static Button RebirthButton;

		public static bool IsDialogOpen => DialogInputBlock.IsBlocking;

		public static void Initialize(Player player, Text pointsText)
		{
			CurrentPlayer = player;
			PointsText = pointsText;
			BaseAvailablePoints = ((!((Object)(object)player == (Object)null)) ? AttributePointService.GetAvailablePoints(player) : 0);
			if (!SuppressAutoScroll || GetTotalAllocated() > BaseAvailablePoints)
			{
				ResetAllocated();
			}
			if (!SuppressAutoScroll)
			{
				HideDialog(_applyDialogRoot);
				HideDialog(_rebirthDialogRoot);
				HideDialog(_prestigeDialogRoot);
			}
			RefreshPointsBadge();
			RefreshPrestigeLabel();
			RefreshActionButtons();
		}

		public static int GetAllocated(SkillType type)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			int value;
			return _pendingAllocations.TryGetValue(type, out value) ? value : 0;
		}

		public static void ChangeAllocated(SkillType type, int delta)
		{
			//IL_0002: 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_001d: Unknown result type (might be due to invalid IL or missing references)
			int num = Mathf.Max(0, GetAllocated(type) + delta);
			if (num == 0)
			{
				_pendingAllocations.Remove(type);
			}
			else
			{
				_pendingAllocations[type] = num;
			}
			RefreshRebirthResetButton();
			SkillListLayout.RefreshPreview();
		}

		public static void SetAllocated(SkillType type, int value)
		{
			//IL_0024: 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)
			int num = Mathf.Max(0, value);
			if (num == 0)
			{
				_pendingAllocations.Remove(type);
			}
			else
			{
				_pendingAllocations[type] = num;
			}
			RefreshRebirthResetButton();
			SkillListLayout.RefreshPreview();
		}

		public static int GetMaxAllocatable(SkillType type)
		{
			//IL_0029: 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)
			if ((Object)(object)CurrentPlayer == (Object)null)
			{
				return 0;
			}
			Skills skills = ((Character)CurrentPlayer).GetSkills();
			Skill val = ((skills != null) ? skills.GetSkill(type) : null);
			if (val == null)
			{
				return 0;
			}
			float num = 100f;
			int num2 = Mathf.Max(0, Mathf.FloorToInt(num - val.m_level));
			int num3 = GetCurrentUnspent() + GetAllocated(type);
			return Mathf.Min(num2, num3);
		}

		public static void ResetAllocated()
		{
			_pendingAllocations.Clear();
			foreach (SkillRowController activeController in SkillRowController.ActiveControllers)
			{
				activeController.RefreshCounter();
			}
			RefreshRebirthResetButton();
			SkillListLayout.RefreshPreview();
		}

		public static int GetTotalAllocated()
		{
			return _pendingAllocations.Values.Sum();
		}

		public static int GetCurrentUnspent()
		{
			int num = BaseAvailablePoints - GetTotalAllocated();
			return Mathf.Max(0, num);
		}

		public static void RefreshPointsBadge()
		{
			//IL_0038: 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_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)PointsText == (Object)null))
			{
				PointsText.text = GetCurrentUnspent().ToString();
				BlinkingTextEffect.SetActive(PointsText, GetTotalAllocated() > 0, BlinkingTextEffect.Darken(PlannedColor, 0.55f), PlannedColor, Color.white);
			}
		}

		public static void RefreshPrestigeLabel()
		{
			if (!((Object)(object)PrestigeText == (Object)null) && !((Object)(object)CurrentPlayer == (Object)null))
			{
				int num = (ModConfig.PrestigeEnabled ? PlayerProgressionStore.GetPrestigeRank(CurrentPlayer) : 0);
				PrestigeText.text = num.ToString();
			}
		}

		public static void OnRebirthOrResetClicked()
		{
			if (GetTotalAllocated() > 0)
			{
				OnResetClicked();
			}
			else
			{
				OnRebirthRequested();
			}
		}

		public static void RefreshRebirthResetButton()
		{
			if (!((Object)(object)RebirthButton == (Object)null))
			{
				Text componentInChildren = ((Component)RebirthButton).GetComponentInChildren<Text>();
				if (!((Object)(object)componentInChildren == (Object)null))
				{
					componentInChildren.text = Localization.instance.Localize((GetTotalAllocated() > 0) ? "$m2_sr_btn_reset" : "$m2_sr_btn_rebirth");
				}
			}
		}

		public static void RefreshActionButtons()
		{
			string failureMessage;
			bool active = ModConfig.PrestigeEnabled && (Object)(object)CurrentPlayer != (Object)null && PrestigeFlow.CanStart(CurrentPlayer, out failureMessage);
			if ((Object)(object)PrestigeButton != (Object)null)
			{
				((Component)PrestigeButton).gameObject.SetActive(active);
			}
			bool anyActive = AttributeMappingService.AnyActive;
			if ((Object)(object)PointsBadgeRoot != (Object)null)
			{
				PointsBadgeRoot.SetActive(anyActive);
			}
			if ((Object)(object)ApplyButton != (Object)null)
			{
				((Component)ApplyButton).gameObject.SetActive(anyActive);
			}
			if ((Object)(object)RebirthButton != (Object)null)
			{
				((Component)RebirthButton).gameObject.SetActive(anyActive);
			}
		}

		public static void RefreshLocalizedButtons()
		{
			RefreshPointsBadge();
			RefreshRebirthResetButton();
			RefreshActionButtons();
			if ((Object)(object)ApplyButton != (Object)null)
			{
				Text componentInChildren = ((Component)ApplyButton).GetComponentInChildren<Text>();
				if ((Object)(object)componentInChildren != (Object)null)
				{
					componentInChildren.text = Localization.instance.Localize("$m2_sr_btn_apply");
				}
			}
			if ((Object)(object)PrestigeButton != (Object)null)
			{
				Text componentInChildren2 = ((Component)PrestigeButton).GetComponentInChildren<Text>();
				if ((Object)(object)componentInChildren2 != (Object)null)
				{
					componentInChildren2.text = Localization.instance.Localize("$m2_sr_btn_prestige");
				}
			}
			GameObject[] array = new GameObject[3];
			Button applyButton = ApplyButton;
			array[0] = ((applyButton != null) ? ((Component)applyButton).gameObject : null);
			Button rebirthButton = RebirthButton;
			array[1] = ((rebirthButton != null) ? ((Component)rebirthButton).gameObject : null);
			Button prestigeButton = PrestigeButton;
			array[2] = ((prestigeButton != null) ? ((Component)prestigeButton).gameObject : null);
			AdjustButtonWidths((GameObject[])(object)array);
		}

		internal static void AdjustButtonWidths(params GameObject[] buttons)
		{
			if (buttons == null || buttons.Length == 0)
			{
				return;
			}
			float num = 20f;
			float num2 = 0f;
			Canvas.ForceUpdateCanvases();
			foreach (GameObject val in buttons)
			{
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				Text componentInChildren = val.GetComponentInChildren<Text>();
				if (!((Object)(object)componentInChildren == (Object)null))
				{
					float num3 = componentInChildren.preferredWidth + num;
					if (num3 > num2)
					{
						num2 = num3;
					}
				}
			}
			num2 = Mathf.Max(num2, 80f);
			foreach (GameObject val2 in buttons)
			{
				if (!((Object)(object)val2 == (Object)null))
				{
					Transform transform = val2.transform;
					RectTransform val3 = (RectTransform)(object)((transform is RectTransform) ? transform : null);
					if (!((Object)(object)val3 == (Object)null))
					{
						val3.SetSizeWithCurrentAnchors((Axis)0, num2);
					}
				}
			}
		}

		public static void OnApplyRequested()
		{
			if ((Object)(object)CurrentPlayer == (Object)null)
			{
				return;
			}
			int totalAllocated = GetTotalAllocated();
			if (totalAllocated <= 0)
			{
				string text = Localization.instance.Localize("$m2_sr_no_points_allocated");
				((Character)CurrentPlayer).Message((MessageType)2, text, 0, (Sprite)null, false);
				return;
			}
			EnsureApplyDialog();
			if ((Object)(object)_applyDialogLabel != (Object)null)
			{
				string format = Localization.instance.Localize("$m2_sr_apply_dialog_text");
				_applyDialogLabel.text = string.Format(format, totalAllocated, BaseAvailablePoints);
			}
			ShowDialog(_applyDialogRoot);
		}

		public static void OnResetClicked()
		{
			ResetAllocated();
			RefreshPointsBadge();
			RefreshDialogSoft();
		}

		public static void OnRebirthRequested()
		{
			if (!((Object)(object)CurrentPlayer == (Object)null))
			{
				EnsureRebirthDialog();
				ShowDialog(_rebirthDialogRoot);
			}
		}

		public static void OnPrestigeRequested()
		{
			if ((Object)(object)CurrentPlayer == (Object)null)
			{
				return;
			}
			if (!PrestigeFlow.CanStart(CurrentPlayer, out var failureMessage))
			{
				if (!string.IsNullOrEmpty(failureMessage))
				{
					((Character)CurrentPlayer).Message((MessageType)2, failureMessage, 0, (Sprite)null, false);
				}
				return;
			}
			EnsurePrestigeDialog();
			if ((Object)(object)_prestigeDialogLabel != (Object)null)
			{
				int num = PlayerProgressionStore.GetPrestigeRank(CurrentPlayer) + 1;
				string text = Localization.instance.Localize("$m2_sr_prestige_confirm_text");
				if (!AttributePointService.PrestigeAddsPoints)
				{
					int num2 = text.IndexOf('\n');
					if (num2 >= 0)
					{
						text = text.Substring(0, num2);
					}
				}
				_prestigeDialogLabel.text = string.Format(text, num, ModConfig.PrestigeMilestonePoints, ModConfig.MilestoneInterval);
			}
			ShowDialog(_prestigeDialogRoot);
		}

		public static void RefreshDialogSoft()
		{
			if (!((Object)(object)CurrentDialog == (Object)null) && !((Object)(object)CurrentPlayer == (Object)null) && ((Component)CurrentDialog).gameObject.activeInHierarchy)
			{
				ScrollRect skillListScrollRect = CurrentDialog.skillListScrollRect;
				if ((Object)(object)skillListScrollRect != (Object)null)
				{
					LastScrollPos = skillListScrollRect.verticalNormalizedPosition;
				}
				SuppressAutoScroll = true;
				CurrentDialog.Setup(CurrentPlayer);
				SuppressAutoScroll = false;
				if ((Object)(object)skillListScrollRect != (Object)null)
				{
					skillListScrollRect.verticalNormalizedPosition = LastScrollPos;
				}
				RefreshPointsBadge();
				RefreshPrestigeLabel();
			}
		}

		private static void ApplyAllocatedPoints()
		{
			if (!((Object)(object)CurrentPlayer == (Object)null))
			{
				List<AttributeAllocationFlow.AttributePointAllocation> pendingAllocations = GetPendingAllocations();
				if (AttributeAllocationFlow.Apply(CurrentPlayer, pendingAllocations).Changed)
				{
					RefreshAfterProgressionChange(CurrentPlayer);
				}
			}
		}

		private static List<AttributeAllocationFlow.AttributePointAllocation> GetPendingAllocations()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			List<AttributeAllocationFlow.AttributePointAllocation> list = new List<AttributeAllocationFlow.AttributePointAllocation>();
			foreach (KeyValuePair<SkillType, int> pendingAllocation in _pendingAllocations)
			{
				if (pendingAllocation.Value > 0 && AttributeRegistry.TryGetAttribute(pendingAllocation.Key, out var attribute))
				{
					list.Add(new AttributeAllocationFlow.AttributePointAllocation
					{
						Attribute = attribute,
						Points = pendingAllocation.Value
					});
				}
			}
			return list;
		}

		public static void RefreshAfterProgressionChange(Player player)
		{
			if (!((Object)(object)player == (Object)null))
			{
				CurrentPlayer = player;
				BaseAvailablePoints = AttributePointService.GetAvailablePoints(player);
				ResetAllocated();
				RefreshPointsBadge();
				RefreshPrestigeLabel();
				RefreshDialogSoft();
				if ((Object)(object)player == (Object)(object)Player.m_localPlayer)
				{
					LevelXpHudController.RefreshForLocalPlayer();
				}
			}
		}

		private static void DispatchFlowResult(FlowExecutionResult result)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)CurrentPlayer == (Object)null || result == null)
			{
				return;
			}
			foreach (FlowNotification notification in result.Notifications)
			{
				((Character)CurrentPlayer).Message(notification.MessageType, notification.Message, 0, (Sprite)null, false);
			}
		}

		private static RectTransform GetDialogParent()
		{
			return (RectTransform)(((object)RootPanel) ?? ((object)/*isinst with value type is only supported in some contexts*/));
		}

		private static void ShowDialog(GameObject dialogRoot)
		{
			if ((Object)(object)dialogRoot != (Object)null)
			{
				dialogRoot.SetActive(true);
			}
		}

		private static void HideDialog(GameObject dialogRoot)
		{
			if ((Object)(object)dialogRoot != (Object)null)
			{
				dialogRoot.SetActive(false);
			}
		}

		private static void EnsureApplyDialog()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Expected O, but got Unknown
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			if (!((Object)(object)_applyDialogRoot != (Object)null))
			{
				RectTransform dialogParent = GetDialogParent();
				Vector2 size = new Vector2(400f, 150f);
				string initialText = Localization.instance.Localize("$m2_sr_apply_dialog_title");
				object obj = <>O.<0>__OnApplyConfirm;
				if (obj == null)
				{
					UnityAction val = OnApplyConfirm;
					<>O.<0>__OnApplyConfirm = val;
					obj = (object)val;
				}
				object obj2 = <>O.<1>__OnApplyCancel;
				if (obj2 == null)
				{
					UnityAction val2 = OnApplyCancel;
					<>O.<1>__OnApplyCancel = val2;
					obj2 = (object)val2;
				}
				ConfirmationDialogFactory.DialogReferences dialogReferences = ConfirmationDialogFactory.Create("SkillsReworked_ApplyDialog", dialogParent, size, initialText, 320f, 80f, (UnityAction)obj, (UnityAction)obj2);
				_applyDialogRoot = dialogReferences.Root;
				_applyDialogLabel = dialogReferences.Label;
			}
		}

		private static void EnsureRebirthDialog()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Expected O, but got Unknown
			if (!((Object)(object)_rebirthDialogRoot != (Object)null))
			{
				RectTransform dialogParent = GetDialogParent();
				Vector2 size = new Vector2(400f, 150f);
				string initialText = Localization.instance.Localize("$m2_sr_rebirth_confirm_text");
				object obj = <>O.<2>__OnRebirthConfirm;
				if (obj == null)
				{
					UnityAction val = OnRebirthConfirm;
					<>O.<2>__OnRebirthConfirm = val;
					obj = (object)val;
				}
				object obj2 = <>O.<3>__OnRebirthCancel;
				if (obj2 == null)
				{
					UnityAction val2 = OnRebirthCancel;
					<>O.<3>__OnRebirthCancel = val2;
					obj2 = (object)val2;
				}
				_rebirthDialogRoot = ConfirmationDialogFactory.Create("SkillsReworked_RebirthDialog", dialogParent, size, initialText, 280f, 80f, (UnityAction)obj, (UnityAction)obj2).Root;
			}
		}

		private static void EnsurePrestigeDialog()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Expected O, but got Unknown
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			if (!((Object)(object)_prestigeDialogRoot != (Object)null))
			{
				RectTransform dialogParent = GetDialogParent();
				Vector2 size = new Vector2(420f, 170f);
				string initialText = Localization.instance.Localize("$m2_sr_prestige_confirm_text");
				object obj = <>O.<4>__OnPrestigeConfirm;
				if (obj == null)
				{
					UnityAction val = OnPrestigeConfirm;
					<>O.<4>__OnPrestigeConfirm = val;
					obj = (object)val;
				}
				object obj2 = <>O.<5>__OnPrestigeCancel;
				if (obj2 == null)
				{
					UnityAction val2 = OnPrestigeCancel;
					<>O.<5>__OnPrestigeCancel = val2;
					obj2 = (object)val2;
				}
				ConfirmationDialogFactory.DialogReferences dialogReferences = ConfirmationDialogFactory.Create("SkillsReworked_PrestigeDialog", dialogParent, size, initialText, 320f, 90f, (UnityAction)obj, (UnityAction)obj2);
				_prestigeDialogRoot = dialogReferences.Root;
				_prestigeDialogLabel = dialogReferences.Label;
			}
		}

		private static void OnApplyConfirm()
		{
			ApplyAllocatedPoints();
			HideDialog(_applyDialogRoot);
		}

		private static void OnApplyCancel()
		{
			HideDialog(_applyDialogRoot);
		}

		private static void OnRebirthConfirm()
		{
			FlowExecutionResult flowExecutionResult = RebirthFlow.Execute(CurrentPlayer);
			HideDialog(_rebirthDialogRoot);
			DispatchFlowResult(flowExecutionResult);
			if (flowExecutionResult.Success)
			{
				RefreshAfterProgressionChange(CurrentPlayer);
			}
		}

		private static void OnRebirthCancel()
		{
			HideDialog(_rebirthDialogRoot);
		}

		private static void OnPrestigeConfirm()
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			FlowExecutionResult flowExecutionResult = PrestigeFlow.Execute(CurrentPlayer);
			HideDialog(_prestigeDialogRoot);
			DispatchFlowResult(flowExecutionResult);
			if (flowExecutionResult.Success)
			{
				RefreshAfterProgressionChange(CurrentPlayer);
				CurrentPlayer.StartEmote("roar", true);
				Vector3 centerPoint = ((Character)CurrentPlayer).GetCenterPoint();
				Vector3 position = ((Component)CurrentPlayer).transform.position;
				GameObject prefab = ZNetScene.instance.GetPrefab("vfx_MeadHasty");
				GameObject prefab2 = ZNetScene.instance.GetPrefab("sfx_gdking_scream");
				if ((Object)(object)prefab != (Object)null)
				{
					ZNetScene.instance.SpawnObject(centerPoint, Quaternion.identity, prefab);
				}
				if ((Object)(object)prefab2 != (Object)null)
				{
					ZNetScene.instance.SpawnObject(position, Quaternion.identity, prefab2);
				}
			}
		}

		private static void OnPrestigeCancel()
		{
			HideDialog(_prestigeDialogRoot);
		}
	}
	public static class UiSpriteHelper
	{
		private static bool _cached;

		private static Sprite _workbenchStarSprite;

		private static Type _workbenchStarType;

		private static float _workbenchStarPPU;

		private static bool _workbenchStarPreserveAspect;

		private static Material _workbenchStarMaterial;

		private static Sprite _circleSprite;

		public static Sprite GetCircleSprite()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_circleSprite != (Object)null)
			{
				return _circleSprite;
			}
			Texture2D val = new Texture2D(128, 128, (TextureFormat)4, false);
			((Texture)val).filterMode = (FilterMode)1;
			float num = 63.5f;
			float num2 = num - 1f;
			for (int i = 0; i < 128; i++)
			{
				for (int j = 0; j < 128; j++)
				{
					float num3 = (float)j - num;
					float num4 = (float)i - num;
					float num5 = Mathf.Sqrt(num3 * num3 + num4 * num4);
					float num6 = Mathf.Clamp01(num2 + 1.5f - num5);
					val.SetPixel(j, i, new Color(1f, 1f, 1f, num6));
				}
			}
			val.Apply(false, true);
			_circleSprite = Sprite.Create(val, new Rect(0f, 0f, 128f, 128f), new Vector2(0.5f, 0.5f), 100f);
			return _circleSprite;
		}

		public static void ApplyWorkbenchLevelStar(Image target)
		{
			//IL_0090: 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_0065: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)target == (Object)null))
			{
				CacheWorkbenchStarOnce();
				if ((Object)(object)_workbenchStarSprite != (Object)null)
				{
					target.sprite = _workbenchStarSprite;
					target.type = _workbenchStarType;
					target.pixelsPerUnitMultiplier = _workbenchStarPPU;
					target.preserveAspect = _workbenchStarPreserveAspect;
					((Graphic)target).material = _workbenchStarMaterial;
					((Graphic)target).color = Color.white;
				}
				else
				{
					target.sprite = null;
					target.type = (Type)1;
					target.preserveAspect = false;
					((Graphic)target).color = GUIManager.Instance.ValheimOrange;
				}
			}
		}

		private static void CacheWorkbenchStarOnce()
		{
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			if (_cached)
			{
				return;
			}
			_cached = true;
			InventoryGui instance = InventoryGui.instance;
			if ((Object)(object)instance == (Object)null)
			{
				Logger.LogWarning((object)"[SkillsReworked.UI.SkillPanel.UiSpriteHelper] InventoryGui.instance is null");
				return;
			}
			RectTransform crafting = instance.m_crafting;
			if ((Object)(object)crafting == (Object)null)
			{
				Logger.LogWarning((object)"[SkillsReworked.UI.SkillPanel.UiSpriteHelper] InventoryGui.m_crafting is null");
				return;
			}
			Transform val = ((Transform)crafting).Find("Level");
			if ((Object)(object)val == (Object)null)
			{
				Transform[] componentsInChildren = ((Component)crafting).GetComponentsInChildren<Transform>(true);
				foreach (Transform val2 in componentsInChildren)
				{
					if (((Object)val2).name == "Level")
					{
						val = val2;
						break;
					}
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				Logger.LogWarning((object)"[SkillsReworked.UI.SkillPanel.UiSpriteHelper] Could not find 'Level' under InventoryGui.m_crafting");
				return;
			}
			Image component = ((Component)val).GetComponent<Image>();
			if ((Object)(object)component == (Object)null)
			{
				Logger.LogWarning((object)"[SkillsReworked.UI.SkillPanel.UiSpriteHelper] 'Level' does not have an Image component");
				return;
			}
			_workbenchStarSprite = component.sprite;
			_workbenchStarType = component.type;
			_workbenchStarPPU = component.pixelsPerUnitMultiplier;
			_workbenchStarPreserveAspect = component.preserveAspect;
			_workbenchStarMaterial = ((Graphic)component).material;
		}
	}
}
namespace SkillsReworked.UI.SkillPanel.Admin
{
	public static class AdminAssignmentSession
	{
		public sealed class Copy
		{
			internal readonly Dictionary<SkillType, AttributeId?> Attributes;

			internal readonly Dictionary<SkillType, bool> Xp;

			internal Copy(Dictionary<SkillType, AttributeId?> attributes, Dictionary<SkillType, bool> xp)
			{
				Attributes = new Dictionary<SkillType, AttributeId?>(attributes);
				Xp = new Dictionary<SkillType, bool>(xp);
			}
		}

		private static readonly Dictionary<SkillType, AttributeId?> Attributes = new Dictionary<SkillType, AttributeId?>();

		private static readonly Dictionary<SkillType, bool> XpWanted = new Dictionary<SkillType, bool>();

		private static ZNet _session;

		public static IReadOnlyDictionary<SkillType, AttributeId?> PendingAttributes => Attributes;

		public static IReadOnlyDictionary<SkillType, bool> PendingXp => XpWanted;

		public static bool IsAvailable => ModConfig.AdminEditEnabled && Player.m_debugMode && (Object)(object)Console.instance != (Object)null && ((Terminal)Console.instance).IsCheatsEnabled();

		public static int ChangeCount => Attributes.Count + XpWanted.Count;

		public static void Validate()
		{
			if (ChangeCount > 0 && (!IsAvailable || (Object)(object)_session != (Object)(object)ZNet.instance))
			{
				Discard();
			}
		}

		public static AttributeId? GetCurrentAttribute(SkillType type)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			AttributeId attribute;
			return AttributeMappingService.TryGetAttributeFor(type, out attribute) ? new AttributeId?(attribute) : ((AttributeId?)null);
		}

		public static AttributeId? GetEffectiveAttribute(SkillType type)
		{
			//IL_0005: 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)
			AttributeId? value;
			return Attributes.TryGetValue(type, out value) ? value : GetCurrentAttribute(type);
		}

		public static bool IsAttributeChanged(SkillType type)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return Attributes.ContainsKey(type);
		}

		public static void Assign(SkillType type, AttributeId? target)
		{
			//IL_000d: 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_003e: 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)
			_session = ZNet.instance;
			if (target == GetCurrentAttribute(type))
			{
				Attributes.Remove(type);
			}
			else
			{
				Attributes[type] = target;
			}
			if (target.HasValue)
			{
				XpWanted.Remove(type);
			}
		}

		public static bool GetEffectiveXp(SkillType type)
		{
			//IL_0005: 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)
			bool value;
			return XpWanted.TryGetValue(type, out value) ? value : AttributeMappingService.GrantsLevelXp(type);
		}

		public static bool IsXpChanged(SkillType type)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return XpWanted.ContainsKey(type);
		}

		public static void ToggleXp(SkillType type)
		{
			//IL_000b: 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_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			_session = ZNet.instance;
			bool flag = !GetEffectiveXp(type);
			if (flag == AttributeMappingService.GrantsLevelXp(type))
			{
				XpWanted.Remove(type);
			}
			else
			{
				XpWanted[type] = flag;
			}
		}

		public static void Discard()
		{
			Attributes.Clear();
			XpWanted.Clear();
		}

		public static Copy Snapshot()
		{
			return new Copy(Attributes, XpWanted);
		}

		public static void Restore(Copy copy)
		{
			//IL_0025: 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)
			Discard();
			foreach (KeyValuePair<SkillType, AttributeId?> attribute in copy.Attributes)
			{
				Attributes[attribute.Key] = attribute.Value;
			}
			foreach (KeyValuePair<SkillType, bool> item in copy.Xp)
			{
				XpWanted[item.Key] = item.Value;
			}
		}

		public static List<string> Describe()
		{
			//IL_0032: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
			List<string> list = new List<string>();
			Localization instance = Localization.instance;
			foreach (KeyValuePair<SkillType, AttributeId?> attribute in Attributes)
			{
				list.Add(string.Format(instance.Localize("$m2_sr_admin_change_attribute"), AttributeMappingService.GetDisplayName(attribute.Key), AttributeLabel(GetCurrentAttribute(attribute.Key)), AttributeLabel(attribute.Value)));
			}
			foreach (KeyValuePair<SkillType, bool> item in XpWanted)
			{
				string text = (item.Value ? "$m2_sr_admin_change_xp_on" : "$m2_sr_admin_change_xp_off");
				list.Add(string.Format(instance.Localize(text), AttributeMappingService.GetDisplayName(item.Key)));
			}
			return list;
		}

		public static string AttributeLabel(AttributeId? attribute)
		{
			return attribute.HasValue ? AttributeRegistry.GetDisplayName(attribute.Value) : Localization.instance.Localize("$m2_sr_admin_none");
		}
	}
	public static class AdminEditBar
	{
		private class AvailabilityWatcher : MonoBehaviour
		{
			private bool _last;

			private void OnEnable()
			{
				_last = AdminAssignmentSession.IsAvailable;
			}

			private void Update()
			{
				bool isAvailable = AdminAssignmentSession.IsAvailable;
				if (isAvailable != _last)
				{
					_last = isAvailable;
					if (!isAvailable)
					{
						AdminAssignmentSession.Discard();
					}
					SkillUiController.RefreshDialogSoft();
				}
			}
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static UnityAction <0>__ShowConfirmation;

			public static UnityAction <1>__OnConfirm;
		}

		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static Func<AttributeMappingService.UnresolvedEntry, string> <>9__14_0;

			public static UnityAction <>9__15_0;

			public static UnityAction <>9__16_0;

			internal string <RefreshUnresolved>b__14_0(AttributeMappingService.UnresolvedEntry e)
			{
				return "'" + e.Text + "'";
			}

			internal void <Build>b__15_0()
			{
				AdminAssignmentSession.Discard();
				SkillUiController.RefreshDialogSoft();
			}

			internal void <ShowConfirmation>b__16_0()
			{
				_dialog.SetActive(false);
			}
		}

		private const int MaxSummaryLines = 8;

		private static GameObject _root;

		private static Button _apply;

		private static Button _discard;

		private static Text _unresolved;

		private static GameObject _dialog;

		private static Text _dialogLabel;

		private const float DialogWidth = 400f;

		private const float TextWidth = 340f;

		private const float TextTop = 20f;

		private const float ButtonArea = 75f;

		private const float MinTextHeight = 80f;

		public static void Sync(RectTransform frame)
		{
			if ((Object)(object)frame == (Object)null)
			{
				return;
			}
			if ((Object)(object)_root == (Object)null)
			{
				Build(frame);
			}
			bool isAdminMode = SkillListLayout.IsAdminMode;
			_root.SetActive(isAdminMode);
			if (!isAdminMode)
			{
				if ((Object)(object)_dialog != (Object)null)
				{
					_dialog.SetActive(false);
				}
				return;
			}
			Button[] array = (Button[])(object)new Button[3]
			{
				SkillUiController.ApplyButton,
				SkillUiController.RebirthButton,
				SkillUiController.PrestigeButton
			};
			foreach (Button val in array)
			{
				if ((Object)(object)val != (Object)null)
				{
					((Component)val).gameObject.SetActive(false);
				}
			}
			if ((Object)(object)SkillUiController.PointsBadgeRoot != (Object)null)
			{
				SkillUiController.PointsBadgeRoot.SetActive(false);
			}
			CopyGeometry(SkillUiController.ApplyButton, _apply);
			CopyGeometry(SkillUiController.RebirthButton, _discard);
			RefreshUnresolved();
		}

		private static void CopyGeometry(Button from, Button to)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: 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_0068: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)from == (Object)null) && !((Object)(object)to == (Object)null))
			{
				RectTransform val = (RectTransform)((Component)from).transform;
				RectTransform val2 = (RectTransform)((Component)to).transform;
				val2.anchorMin = val.anchorMin;
				val2.anchorMax = val.anchorMax;
				val2.pivot = val.pivot;
				val2.sizeDelta = val.sizeDelta;
				val2.anchoredPosition = val.anchoredPosition;
			}
		}

		private static void RefreshUnresolved()
		{
			IReadOnlyList<AttributeMappingService.UnresolvedEntry> unresolvedEntries = AttributeMappingService.GetUnresolvedEntries();
			((Component)_unresolved).gameObject.SetActive(unresolvedEntries.Count > 0);
			if (unresolvedEntries.Count != 0)
			{
				string text = string.Join(", ", from e in unresolvedEntries.Take(4)
					select "'" + e.Text + "'");
				if (unresolvedEntries.Count > 4)
				{
					text += " …";
				}
				_unresolved.text = string.Format(Localization.instance.Localize("$m2_sr_admin_unresolved"), text);
			}
		}

		private static void Build(RectTransform frame)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			//IL_003d: 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_0055: 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_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Expected O, but got Unknown
			//IL_016d: 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_018b: 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_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Expected O, but got Unknown
			_root = new GameObject("SkillsReworked_AdminBar", new Type[1] { typeof(RectTransform) });
			RectTransform val = (RectTransform)_root.transform;
			((Transform)val).SetParent((Transform)(object)frame, false);
			val.anchorMin = Vector2.zero;
			val.anchorMax = Vector2.one;
			val.offsetMin = Vector2.zero;
			val.offsetMax = Vector2.zero;
			GameObject val2 = GUIManager.Instance.CreateButton(Localization.instance.Localize("$m2_sr_admin_discard"), (Transform)(object)val, Vector2.zero, Vector2.zero, Vector2.zero, 80f, 28f);
			_discard = val2.GetComponent<Button>();
			ButtonClickedEvent onClick = _discard.onClick;
			object obj = <>c.<>9__15_0;
			if (obj == null)
			{
				UnityAction val3 = delegate
				{
					AdminAssignmentSession.Discard();
					SkillUiController.RefreshDialogSoft();
				};
				<>c.<>9__15_0 = val3;
				obj = (object)val3;
			}
			((UnityEvent)onClick).AddListener((UnityAction)obj);
			GameObject val4 = GUIManager.Instance.CreateButton(Localization.instance.Localize("$m2_sr_btn_apply"), (Transform)(object)val, new Vector2(1f, 0f), new Vector2(1f, 0f), Vector2.zero, 80f, 28f);
			_apply = val4.GetComponent<Button>();
			ButtonClickedEvent onClick2 = _apply.onClick;
			object obj2 = <>O.<0>__ShowConfirmation;
			if (obj2 == null)
			{
				UnityAction val5 = ShowConfirmation;
				<>O.<0>__ShowConfirmation = val5;
				obj2 = (object)val5;
			}
			((UnityEvent)onClick2).AddListener((UnityAction)obj2);
			GameObject val6 = GUIManager.Instance.CreateText(string.Empty, (Transform)(object)val, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -30f), GUIManager.Instance.AveriaSerifBold, 14, new Color(1f, 0.35f, 0.3f, 1f), true, Color.black, 380f, 20f, false);
			_unresolved = val6.GetComponent<Text>();
			_unresolved.alignment = (TextAnchor)4;
			((Graphic)_unresolved).raycastTarget = false;
			if ((Object)(object)((Component)frame).GetComponent<AvailabilityWatcher>() == (Object)null)
			{
				((Component)frame).gameObject.AddComponent<AvailabilityWatcher>();
			}
		}

		private static void ShowConfirmation()
		{
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Expected O, but got Unknown
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Expected O, but got Unknown
			if (AdminAssignmentSession.ChangeCount == 0)
			{
				Player localPlayer = Player.m_localPlayer;
				if ((Object)(object)localPlayer != (Object)null)
				{
					((Character)localPlayer).Message((MessageType)2, Localization.instance.Localize("$m2_sr_admin_no_changes"), 0, (Sprite)null, false);
				}
				return;
			}
			if ((Object)(object)_dialog == (Object)null)
			{
				RectTransform parent = (RectTransform)(((Object)(object)SkillUiController.RootPanel != (Object)null) ? ((object)SkillUiController.RootPanel) : ((object)(RectTransform)GUIManager.CustomGUIFront.transform));
				Vector2 size = new Vector2(400f, 175f);
				string empty = string.Empty;
				object obj = <>O.<1>__OnConfirm;
				if (obj == null)
				{
					UnityAction val = OnConfirm;
					<>O.<1>__OnConfirm = val;
					obj = (object)val;
				}
				object obj2 = <>c.<>9__16_0;
				if (obj2 == null)
				{
					UnityAction val2 = delegate
					{
						_dialog.SetActive(false);
					};
					<>c.<>9__16_0 = val2;
					obj2 = (object)val2;
				}
				ConfirmationDialogFactory.DialogReferences dialogReferences = ConfirmationDialogFactory.Create("SkillsReworked_AdminConfirm", parent, size, empty, 340f, 80f, (UnityAction)obj, (UnityAction)obj2);
				_dialog = dialogReferences.Root;
				_dialogLabel = dialogReferences.Label;
				_dialogLabel.horizontalOverflow = (HorizontalWrapMode)0;
			}
			List<string> list = AdminAssignmentSession.Describe();
			List<string> list2 = new List<string>
			{
				Localization.instance.Localize("$m2_sr_admin_confirm_title"),
				string.Empty
			};
			list2.AddRange(list.Take(8));
			if (list.Count > 8)
			{
				list2.Add(string.Format(Localization.instance.Localize("$m2_sr_admin_more"), list.Count - 8));
			}
			list2.Add(string.Empty);
			list2.Add(Localization.instance.Localize("$m2_sr_admin_warning"));
			_dialogLabel.text = string.Join("\n", list2);
			FitDialogToText();
			_dialog.SetActive(true);
		}

		private static void FitDialogToText()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			RectTransform rectTransform = ((Graphic)_dialogLabel).rectTransform;
			rectTransform.pivot = new Vector2(0.5f, 1f);
			rectTransform.anchoredPosition = new Vector2(0f, -20f);
			rectTransform.sizeDelta = new Vector2(340f, 80f);
			float num = Mathf.Max(80f, LayoutUtility.GetPreferredHeight(rectTransform));
			rectTransform.sizeDelta = new Vector2(340f, num);
			((RectTransform)_dialog.transform).sizeDelta = new Vector2(400f, 20f + num + 75f);
		}

		private static void OnConfirm()
		{
			_dialog.SetActive(false);
			AttributeConfigWriter.Result result = AttributeConfigWriter.Apply();
			if (1 == 0)
			{
			}
			string text = result switch
			{
				AttributeConfigWriter.Result.Applied => "$m2_sr_admin_applied", 
				AttributeConfigWriter.Result.NotAdmin => "$m2_sr_admin_not_admin", 
				AttributeConfigWriter.Result.SyncFailed => "$m2_sr_admin_sync_failed", 
				_ => "$m2_sr_admin_nothing_changed", 
			};
			if (1 == 0)
			{
			}
			string text2 = text;
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer != (Object)null)
			{
				((Character)localPlayer).Message((MessageType)2, Localization.instance.Localize(text2), 0, (Sprite)null, false);
			}
			if (result == AttributeConfigWriter.Result.NothingChanged)
			{
				SkillUiController.RefreshDialogSoft();
			}
		}
	}
	public static class AdminRowDecorations
	{
		private class Decorated
		{
			public GameObject Row;

			public SkillType Type;

			public bool IsAttribute;

			public TMP_Text Name;

			public Color NameColor;

			public Text XpLabel;

			public GameObject XpButton;

			public readonly List<GameObject> Added = new List<GameObject>();
		}

		public static readonly Color ChangedColor = new Color(1f, 0.85f, 0.2f, 1f);

		public const string DropGlowName = "SkillsReworked_DropGlow";

		private static readonly List<Decorated> Rows = new List<Decorated>();

		private static readonly Vector2 Left = new Vector2(0f, 0.5f);

		public static void DecorateAttribute(RectTransform row, AttributeId attribute)
		{
			Decorated decorated = Begin(row);
			decorated.IsAttribute = true;
			decorated.Added.Add(CreateDropGlow(row));
		}

		public static GameObject CreateDropGlow(RectTransform row)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("SkillsReworked_DropGlow", new Type[2]
			{
				typeof(RectTransform),
				typeof(Image)
			});
			RectTransform val2 = (RectTransform)val.transform;
			((Transform)val2).SetParent((Transform)(object)row, false);
			((Transform)val2).SetAsFirstSibling();
			val2.anchorMin = Vector2.zero;
			val2.anchorMax = Vector2.one;
			val2.offsetMin = Vector2.zero;
			val2.offsetMax = Vector2.zero;
			Image component = val.GetComponent<Image>();
			((Graphic)component).color = Color.clear;
			((Graphic)component).raycastTarget = false;
			return val;
		}

		public static void DecorateSkill(RectTransform row, SkillType type)
		{
			//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_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_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Expected O, but got Unknown
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			Decorated decorated = Begin(row);
			decorated.Type = type;
			decorated.XpButton = GUIManager.Instance.CreateButton("XP", (Transform)(object)row, Left, Left, new Vector2(124f, 0f), 26f, 22f);
			((UnityEvent)decorated.XpButton.GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				AdminAssignmentSession.ToggleXp(type);
				Refresh();
			});
			decorated.XpLabel = decorated.XpButton.GetComponentInChildren<Text>();
			decorated.Added.Add(decorated.XpButton);
			SkillRowDragHandler.Attach(((Component)row).gameObject, type);
		}

		public static void Refresh()
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: 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)
			foreach (Decorated row in Rows)
			{
				if (!((Object)(object)row.Row == (Object)null) && !row.IsAttribute)
				{
					AttributeId? effectiveAttribute = AdminAssignmentSession.GetEffectiveAttribute(row.Type);
					bool flag = AdminAssignmentSession.IsAttributeChanged(row.Type) || AdminAssignmentSession.IsXpChanged(row.Type);
					row.XpButton.SetActive(!effectiveAttribute.HasValue);
					bool effectiveXp = AdminAssignmentSession.GetEffectiveXp(row.Type);
					((Graphic)row.XpLabel).color = (AdminAssignmentSession.IsXpChanged(row.Type) ? ChangedColor : (effectiveXp ? Color.white : Color.gray));
					if ((Object)(object)row.Name != (Object)null)
					{
						((Graphic)row.Name).color = (flag ? ChangedColor : row.NameColor);
					}
				}
			}
		}

		public static void DestroyAll()
		{
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			foreach (Decorated row in Rows)
			{
				foreach (GameObject item in row.Added)
				{
					if ((Object)(object)item != (Object)null)
					{
						Object.Destroy((Object)(object)item);
					}
				}
				if ((Object)(object)row.Name != (Object)null)
				{
					((Graphic)row.Name).color = row.NameColor;
				}
				if ((Object)(object)row.Row != (Object)null)
				{
					SkillRowDragHandler.Detach(row.Row);
				}
			}
			Rows.Clear();
		}

		private static Decorated Begin(RectTransform row)
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			Decorated obj = new Decorated
			{
				Row = ((Component)row).gameObject
			};
			Transform obj2 = Utils.FindChild((Transform)(object)row, "name", (IterativeSearchType)0);
			obj.Name = ((obj2 != null) ? ((Component)obj2).GetComponent<TMP_Text>() : null);
			Decorated decorated = obj;
			if ((Object)(object)decorated.Name != (Object)null)
			{
				decorated.NameColor = ((Graphic)decorated.Name).color;
			}
			Rows.Add(decorated);
			return decorated;
		}
	}
	public class SkillRowDragHandler : MonoBehaviour, IBeginDragHandler, IEventSystemHandler, IDragHandler, IEndDragHandler
	{
		private const float EdgeSize = 40f;

		private const float EdgeScrollSpeed = 1.5f;

		private SkillType _type;

		private GameObject _ghost;

		private GameObject _highlighted;

		private Vector2 _pointer;

		private Camera _eventCamera;

		private bool _dragging;

		public static void Attach(GameObject row, SkillType type)
		{
			//IL_001b: 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)
			SkillRowDragHandler skillRowDragHandler = row.GetComponent<SkillRowDragHandler>();
			if ((Object)(object)skillRowDragHandler == (Object)null)
			{
				skillRowDragHandler = row.AddComponent<SkillRowDragHandler>();
			}
			skillRowDragHandler._type = type;
			((Behaviour)skillRowDragHandler).enabled = true;
		}

		public static void Detach(GameObject row)
		{
			SkillRowDragHandler component = row.GetComponent<SkillRowDragHandler>();
			if ((Object)(object)component != (Object)null)
			{
				component.EndDrag();
				((Behaviour)component).enabled = false;
			}
		}

		public void OnBeginDrag(PointerEventData eventData)
		{
			//IL_002f: 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_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: 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)
			if (SkillListLayout.IsAdminMode)
			{
				RectTransform rootPanel = SkillUiController.RootPanel;
				if (!((Object)(object)rootPanel == (Object)null))
				{
					_ghost = GUIManager.Instance.CreateText(AttributeMappingService.GetDisplayName(_type), (Transform)(object)rootPanel, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), Vector2.zero, GUIManager.Instance.AveriaSerifBold, 18, AdminRowDecorations.ChangedColor, true, Color.black, 220f, 30f, false);
					((Graphic)_ghost.GetComponent<Text>()).raycastTarget = false;
					_dragging = true;
					OnDrag(eventData);
				}
			}
		}

		public void OnDrag(PointerEventData eventData)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: 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)
			if (_dragging)
			{
				_pointer = eventData.position;
				_eventCamera = eventData.pressEventCamera;
				MoveGhost(_eventCamera);
				RaycastResult pointerCurrentRaycast = eventData.pointerCurrentRaycast;
				SkillListLayout.TryGetDropTarget(((RaycastResult)(ref pointerCurrentRaycast)).gameObject, out var _, out var headerRow);
				Highlight(headerRow);
			}
		}

		public void OnEndDrag(PointerEventData eventData)
		{
			//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_002e: Unknown result type (might be due to invalid IL or missing references)
			if (_dragging)
			{
				RaycastResult pointerCurrentRaycast = eventData.pointerCurrentRaycast;
				if (SkillListLayout.TryGetDropTarget(((RaycastResult)(ref pointerCurrentRaycast)).gameObject, out var target, out var _))
				{
					AdminAssignmentSession.Assign(_type, target);
					AdminRowDecorations.Refresh();
					SkillListLayout.ShowPendingOrder();
				}
				EndDrag();
			}
		}

		private void Update()
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			if (!_dragging)
			{
				return;
			}
			ScrollRect val = (((Object)(object)SkillUiController.CurrentDialog != (Object)null) ? SkillUiController.CurrentDialog.skillListScrollRect : null);
			Vector2 val2 = default(Vector2);
			if (!((Object)(object)val == (Object)null) && !((Object)(object)val.viewport == (Object)null) && RectTransformUtility.ScreenPointToLocalPointInRectangle(val.viewport, _pointer, _eventCamera, ref val2))
			{
				Rect rect = val.viewport.rect;
				float num = ((val2.y > ((Rect)(ref rect)).yMax - 40f) ? 1f : ((val2.y < ((Rect)(ref rect)).yMin + 40f) ? (-1f) : 0f));
				if (num != 0f && !((Object)(object)val.content == (Object)null))
				{
					Rect rect2 = val.content.rect;
					float num2 = Mathf.Max(1f, ((Rect)(ref rect2)).height - ((Rect)(ref rect)).height);
					float num3 = 1.5f * ((Rect)(ref rect)).height / num2 * Time.unscaledDeltaTime;
					val.verticalNormalizedPosition = Mathf.Clamp01(val.verticalNormalizedPosition + num * num3);
				}
			}
		}

		private void MoveGhost(Camera camera)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			//IL_0032: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_ghost == (Object)null))
			{
				RectTransform val = (RectTransform)_ghost.transform;
				RectTransform val2 = (RectTransform)((Transform)val).parent;
				Vector2 val3 = default(Vector2);
				if (RectTransformUtility.ScreenPointToLocalPointInRectangle(val2, _pointer, camera, ref val3))
				{
					val.anchoredPosition = val3 + new Vector2(0f, 20f);
				}
			}
		}

		private void Highlight(GameObject header)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: 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_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)header == (Object)(object)_highlighted))
			{
				ClearHighlight();
				Image val = Glow(header);
				if (!((Object)(object)val == (Object)null))
				{
					_highlighted = header;
					Color changedColor = AdminRowDecorations.ChangedColor;
					((Graphic)val).color = new Color(changedColor.r, changedColor.g, changedColor.b, 0.35f);
				}
			}
		}

		private void ClearHighlight()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			Image val = Glow(_highlighted);
			if ((Object)(object)val != (Object)null)
			{
				((Graphic)val).color = Color.clear;
			}
			_highlighted = null;
		}

		private static Image Glow(GameObject header)
		{
			Transform val = (((Object)(object)header != (Object)null) ? header.transform.Find("SkillsReworked_DropGlow") : null);
			return ((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<Image>() : null;
		}

		private void EndDrag()
		{
			_dragging = false;
			ClearHighlight();
			if ((Object)(object)_ghost != (Object)null)
			{
				Object.Destroy((Object)(object)_ghost);
			}
			_ghost = null;
		}

		private void OnDisable()
		{
			EndDrag();
		}
	}
}
namespace SkillsReworked.UI.LevelHud
{
	public static class LevelXpHudController
	{
		private class HudData
		{
			public RectTransform Root;

			public RectTransform FastFill;

			public RectTransform SlowFill;

			public TMP_Text Label;

			public float LabelBaseFontSize;

			public float MaxWidth;

			public float FastFraction;

			public float SlowFraction;

			public float SlowAnimStart;

			public float SlowAnimTarget;

			public float SlowAnimElapsed;

			public float SlowAnimDuration;

			public float SlowDelayRemaining;

			public bool SlowAnimationActive;

			public int PreviousLevel;

			public bool LevelUpAnimating;

			public float LevelUpFinalTarget;
		}

		private static readonly Dictionary<Hud, HudData> Bars = new Dictionary<Hud, HudData>();

		private const float Margin = 3f;

		private const float SlowStartDelay = 0.18f;

		private const float SlowMinDuration = 0.22f;

		private const float SlowMaxDuration = 1.82f;

		private const float SlowDurationScale = 1.6f;

		public static void Register()
		{
			LevelProgressionService.OnLevelChanged += RefreshForLocalPlayer;
		}

		public static void RefreshForLocalPlayer()
		{
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			Hud instance = Hud.instance;
			if ((Object)(object)instance == (Object)null)
			{
				return;
			}
			if (!ModConfig.XpBarEnabled)
			{
				if (Bars.TryGetValue(instance, out var value))
				{
					SetActiveSafe(value, active: false);
				}
				return;
			}
			if (!Bars.TryGetValue(instance, out var value2) || (Object)(object)value2.Root == (Object)null)
			{
				CreateBarForHud(instance);
				if (!Bars.TryGetValue(instance, out value2) || (Object)(object)value2.Root == (Object)null)
				{
					return;
				}
			}
			if (!instance.IsVisible())
			{
				SetActiveSafe(value2, active: false);
				return;
			}
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				SetActiveSafe(value2, active: false);
				return;
			}
			Skills skills = ((Character)localPlayer).GetSkills();
			Skill val = ((skills != null) ? skills.GetSkill(SkillsReworkedPlugin.LevelSkillType) : null);
			if (val == null)
			{
				SetActiveSafe(value2, active: false);
				return;
			}
			int num = Mathf.FloorToInt(val.m_level);
			float currentLevelFraction = LevelXpCalculator.GetCurrentLevelFraction(val);
			float num2 = Mathf.Clamp01(currentLevelFraction);
			if (num <= 0 && num2 <= 0f)
			{
				value2.FastFraction = 0f;
				SnapSlowTo(value2, 0f);
				if ((Object)(object)value2.FastFill != (Object)null)
				{
					value2.FastFill.sizeDelta = new Vector2(0f, value2.FastFill.sizeDelta.y);
				}
				if ((Object)(object)value2.Label != (Object)null)
				{
					value2.Label.text = string.Empty;
				}
				SetActiveSafe(value2, active: false);
				return;
			}
			bool flag = (Object)(object)value2.Root != (Object)null && ((Component)value2.Root).gameObject.activeSelf;
			float fastFraction = value2.FastFraction;
			int previousLevel = value2.PreviousLevel;
			SetActiveSafe(value2, active: true);
			ApplyLayout(instance, value2);
			value2.PreviousLevel = num;
			if (value2.LevelUpAnimating)
			{
				if ((Object)(object)value2.Label != (Object)null)
				{
					value2.Label.text = $"Level {num}";
				}
				return;
			}
			value2.FastFraction = num2;
			ApplyFillWidth(value2.FastFill, value2.MaxWidth, value2.FastFraction);
			if (!flag)
			{
				SnapSlowTo(value2, num2);
			}
			else if (!Mathf.Approximately(fastFraction, num2))
			{
				bool flag2 = num > previousLevel;
				bool flag3 = num < previousLevel;
				if (flag2)
				{
					value2.FastFraction = 1f;
					ApplyFillWidth(value2.FastFill, value2.MaxWidth, 1f);
					value2.LevelUpFinalTarget = num2;
					value2.LevelUpAnimating = true;
					BeginSlowAnimation(value2, 1f, 0.18f);
				}
				else if (flag3)
				{
					value2.SlowFraction = 1f;
					ApplyFillWidth(value2.SlowFill, value2.MaxWidth, 1f);
					BeginSlowAnimation(value2, num2, 0f);
				}
				else if (num2 < fastFraction || num2 < value2.SlowFraction)
				{
					BeginSlowAnimation(value2, num2, 0f);
				}
				else
				{
					BeginSlowAnimation(value2, num2, 0.18f);
				}
			}
			if ((Object)(object)value2.Label != (Object)null)
			{
				value2.Label.text = $"Level {num}";
			}
		}

		public static void Update(float dt)
		{
			if (Bars.Count == 0)
			{
				return;
			}
			foreach (KeyValuePair<Hud, HudData> bar in Bars)
			{
				HudData value = bar.Value;
				if (value != null && !((Object)(object)value.Root == (Object)null) && ((Component)value.Root).gameObject.activeSelf && !((Object)(object)value.SlowFill == (Object)null) && value.SlowAn