Decompiled source of TalentTree v2.0.1

TalentTree.dll

Decompiled 12 hours ago
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Data;
using System.Data.SqlTypes;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Dynamic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Numerics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Linq;
using BepInEx;
using BepInEx.Configuration;
using Core;
using HarmonyLib;
using Integration;
using JetBrains.Annotations;
using Jotunn;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using Newtonsoft.Json.Bson;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Linq.JsonPath;
using Newtonsoft.Json.Schema;
using Newtonsoft.Json.Serialization;
using Newtonsoft.Json.Utilities;
using Patches;
using SkillsReworked.Api;
using SkillsReworked.Systems.Prestige;
using SkillsReworked.Systems.Rebirth;
using SkillsReworked.Systems.Rewards;
using TMPro;
using Talents;
using Talents.Berserker;
using Talents.Berserker.Effects;
using Talents.Berserker.Patches;
using Talents.Bulwark;
using Talents.Bulwark.Effects;
using Talents.Hunter;
using Talents.Hunter.Effects;
using Talents.Shared;
using Talents.Valkyrie;
using Talents.Warcaller;
using Talents.Warcaller.Effects;
using Talents.Warcaller.Patches;
using Talents.Warrior;
using Talents.Warrior.Effects;
using Talents.Warrior.Patches;
using UI;
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("TalentTree")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+f654e504757199c155064d6c1bc7765ce1a0096e")]
[assembly: AssemblyProduct("TalentTree")]
[assembly: AssemblyTitle("TalentTree")]
[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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 UI
{
	internal static class TalentWindowFooterBuilder
	{
		internal sealed class Result
		{
			public Button ApplyButton;

			public Text ApplyBtnLabel;

			public Button ResetButton;

			public Text ResetBtnLabel;
		}

		public static Result Build(Transform panel, TalentUiLayout layout)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: 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)
			Result result = new Result();
			var (val, applyButton, applyBtnLabel) = UiFactory.CreateButtonBottomCenter(panel, "ApplyButton", JotunnLocalization.T("tt_ui_apply"), layout.ApplyButtonOffset, layout.ApplyButtonSize);
			val.SetActive(false);
			result.ApplyButton = applyButton;
			result.ApplyBtnLabel = applyBtnLabel;
			var (val2, resetButton, resetBtnLabel) = UiFactory.CreateButtonBottomCenter(panel, "ResetButton", JotunnLocalization.T("tt_ui_reset_draft"), layout.ResetButtonOffset, layout.ResetButtonSize);
			val2.SetActive(false);
			result.ResetButton = resetButton;
			result.ResetBtnLabel = resetBtnLabel;
			return result;
		}
	}
	internal static class TalentWindowHeaderBuilder
	{
		internal sealed class Result
		{
			public Text TitleText;

			public Text PointsText;

			public Button CloseButton;

			public Button StatsButton;

			public Text StatsBtnLabel;
		}

		public static Result Build(Transform panel, TalentUiLayout layout)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			Result result = new Result();
			var (val, val2) = UiFactory.CreateTextTopCenter(panel, "Title", JotunnLocalization.T("tt_ui_talents_title"), layout.TitleOffset, layout.TitleSize, GUIManager.Instance.AveriaSerifBold, layout.TitleFontSize, GUIManager.Instance.ValheimOrange, outline: true, Color.black);
			val2.alignment = (TextAnchor)4;
			result.TitleText = val2;
			Button item = UiFactory.CreateButtonTopRight(panel, "CloseButton", "X", layout.CloseButtonOffset, layout.CloseButtonSize).button;
			result.CloseButton = item;
			Text item2 = UiFactory.CreateNumberToken(panel, "Points", UiFactory.Presets.TopLeft, layout.PointsTokenOffset, layout.PointsTokenSize, GUIManager.Instance.ValheimOrange, GUIManager.Instance.AveriaSerifBold, layout.PointsTokenFontSize, Color.white).number;
			item2.text = "0";
			result.PointsText = item2;
			(GameObject go, Button button, Text label) tuple2 = UiFactory.CreateButtonTopLeft(panel, "StatsButton", JotunnLocalization.T("tt_ui_stats"), layout.StatsButtonOffset, layout.StatsButtonSize);
			Button item3 = tuple2.button;
			Text item4 = tuple2.label;
			result.StatsButton = item3;
			result.StatsBtnLabel = item4;
			return result;
		}
	}
	internal static class TalentWindowSearchBuilder
	{
		internal sealed class Result
		{
			public InputField SearchInput;

			public RectTransform SearchInputRt;

			public GameObject SearchDropdown;

			public RectTransform SearchDropdownRt;
		}

		public static Result Build(Transform panel, TalentUiLayout layout, TalentUiTheme theme)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected O, but got Unknown
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Expected O, but got Unknown
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Expected O, but got Unknown
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_02de: Unknown result type (might be due to invalid IL or missing references)
			//IL_0319: Unknown result type (might be due to invalid IL or missing references)
			//IL_0354: Unknown result type (might be due to invalid IL or missing references)
			//IL_035e: Expected O, but got Unknown
			Result result = new Result();
			GameObject val = new GameObject("SearchBox", new Type[3]
			{
				typeof(RectTransform),
				typeof(Image),
				typeof(InputField)
			});
			val.transform.SetParent(panel, false);
			result.SearchInputRt = (RectTransform)val.transform;
			UiFactory.SetTopRight(result.SearchInputRt, layout.SearchOffset, layout.SearchSize);
			Image component = val.GetComponent<Image>();
			component.sprite = GUIManager.Instance.GetSprite("text_field");
			component.type = (Type)1;
			((Graphic)component).color = theme.SearchBoxBackground;
			((Graphic)component).raycastTarget = true;
			result.SearchInput = val.GetComponent<InputField>();
			result.SearchInput.lineType = (LineType)0;
			result.SearchInput.characterLimit = layout.SearchCharacterLimit;
			RectTransform val2 = UiFactory.CreateRect("Text", val.transform);
			UiFactory.SetRectStretch(val2, new Vector2(layout.SearchTextPaddingX, layout.SearchTextPaddingY), new Vector2(0f - layout.SearchTextPaddingX, 0f - layout.SearchTextPaddingY));
			Text val3 = ((Component)val2).gameObject.AddComponent<Text>();
			val3.text = "";
			val3.font = GUIManager.Instance.AveriaSerifBold;
			val3.fontSize = layout.SearchFontSize;
			((Graphic)val3).color = Color.white;
			val3.alignment = (TextAnchor)3;
			val3.supportRichText = false;
			result.SearchInput.textComponent = val3;
			RectTransform val4 = UiFactory.CreateRect("Placeholder", val.transform);
			UiFactory.SetRectStretch(val4, val2.offsetMin, val2.offsetMax);
			Text val5 = ((Component)val4).gameObject.AddComponent<Text>();
			val5.text = JotunnLocalization.T("tt_ui_search_placeholder");
			val5.font = GUIManager.Instance.AveriaSerifBold;
			val5.fontSize = layout.SearchFontSize;
			((Graphic)val5).color = theme.SearchPlaceholderColor;
			val5.alignment = (TextAnchor)3;
			((Graphic)val5).raycastTarget = false;
			result.SearchInput.placeholder = (Graphic)(object)val5;
			result.SearchDropdown = new GameObject("SearchDropdown", new Type[4]
			{
				typeof(RectTransform),
				typeof(Image),
				typeof(VerticalLayoutGroup),
				typeof(ContentSizeFitter)
			});
			result.SearchDropdown.transform.SetParent(panel, false);
			result.SearchDropdownRt = (RectTransform)result.SearchDropdown.transform;
			UiFactory.SetTopRight(result.SearchDropdownRt, new Vector2(result.SearchInputRt.anchoredPosition.x, result.SearchInputRt.anchoredPosition.y - result.SearchInputRt.sizeDelta.y - layout.SearchDropdownGap), new Vector2(result.SearchInputRt.sizeDelta.x, layout.SearchDropdownInitialHeight));
			Image component2 = result.SearchDropdown.GetComponent<Image>();
			component2.sprite = GUIManager.Instance.GetSprite("text_field");
			component2.type = (Type)1;
			((Graphic)component2).color = theme.SearchDropdownBackground;
			((Graphic)component2).raycastTarget = true;
			VerticalLayoutGroup component3 = result.SearchDropdown.GetComponent<VerticalLayoutGroup>();
			((LayoutGroup)component3).padding = new RectOffset(layout.SearchDropdownPadding, layout.SearchDropdownPadding, layout.SearchDropdownPadding, layout.SearchDropdownPadding);
			((HorizontalOrVerticalLayoutGroup)component3).spacing = layout.SearchDropdownSpacing;
			((HorizontalOrVerticalLayoutGroup)component3).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)component3).childForceExpandHeight = false;
			((HorizontalOrVerticalLayoutGroup)component3).childForceExpandWidth = true;
			((LayoutGroup)component3).childAlignment = (TextAnchor)0;
			ContentSizeFitter component4 = result.SearchDropdown.GetComponent<ContentSizeFitter>();
			component4.horizontalFit = (FitMode)0;
			component4.verticalFit = (FitMode)2;
			result.SearchDropdown.SetActive(false);
			return result;
		}
	}
	internal static class TalentWindowTreeAreaBuilder
	{
		internal sealed class Result
		{
			public ScrollRect ScrollRect;

			public RectTransform ViewportRt;

			public RectTransform ContentRt;

			public RectTransform WorldRt;

			public RectTransform PathsRootRt;

			public RectTransform NodesRootRt;

			public MouseWheelZoomToCursor Zoom;
		}

		public static Result Build(Transform panel, TalentUiLayout layout, TalentUiTheme theme)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: 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: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			Result result = new Result();
			RectTransform val = UiFactory.CreateRect("TalentTree_Area", panel);
			UiFactory.SetRectStretch(val, layout.TreeAreaPaddingMin, layout.TreeAreaPaddingMax);
			Image val2 = ((Component)val).gameObject.AddComponent<Image>();
			val2.sprite = GUIManager.Instance.GetSprite("Background");
			((Graphic)val2).color = theme.TreeBackground;
			((Graphic)val2).raycastTarget = true;
			result.ViewportRt = UiFactory.CreateRect("Viewport", (Transform)(object)val);
			UiFactory.SetRectStretch(result.ViewportRt, layout.ViewportPaddingMin, layout.ViewportPaddingMax);
			((Graphic)((Component)result.ViewportRt).gameObject.AddComponent<Image>()).color = theme.ViewportMaskTint;
			((Component)result.ViewportRt).gameObject.AddComponent<Mask>().showMaskGraphic = false;
			result.ContentRt = UiFactory.CreateRect("Content", (Transform)(object)result.ViewportRt);
			UiFactory.SetCenter(result.ContentRt, Vector2.zero, layout.ContentSize);
			((Transform)result.ContentRt).localScale = Vector3.one;
			result.WorldRt = UiFactory.CreateRect("World", (Transform)(object)result.ContentRt);
			UiFactory.SetCenter(result.WorldRt, Vector2.zero, result.ContentRt.sizeDelta);
			result.PathsRootRt = UiFactory.CreateRect("PathsRoot", (Transform)(object)result.WorldRt);
			result.NodesRootRt = UiFactory.CreateRect("NodesRoot", (Transform)(object)result.WorldRt);
			UiFactory.SetRectStretch(result.PathsRootRt, Vector2.zero, Vector2.zero);
			UiFactory.SetRectStretch(result.NodesRootRt, Vector2.zero, Vector2.zero);
			((Component)result.PathsRootRt).transform.SetAsFirstSibling();
			((Component)result.NodesRootRt).transform.SetAsLastSibling();
			result.ScrollRect = ((Component)val).gameObject.AddComponent<ScrollRect>();
			result.ScrollRect.viewport = result.ViewportRt;
			result.ScrollRect.content = result.ContentRt;
			result.ScrollRect.horizontal = true;
			result.ScrollRect.vertical = true;
			result.ScrollRect.movementType = (MovementType)2;
			result.ScrollRect.inertia = true;
			result.ScrollRect.scrollSensitivity = 0f;
			result.Zoom = ((Component)result.ViewportRt).gameObject.AddComponent<MouseWheelZoomToCursor>();
			result.Zoom.Initialize(result.ViewportRt, result.ContentRt, result.ScrollRect, layout);
			return result;
		}
	}
	internal sealed class TalentSearchController
	{
		private sealed class SearchItem
		{
			public string Id;

			public string Name;

			public string IdLower;

			public string NameLower;

			public string HaystackLower;
		}

		private struct SearchMatch
		{
			public SearchItem Item;

			public int Score;
		}

		private sealed class SuggestionEntry
		{
			public GameObject Go;

			public Button Button;

			public Image Background;

			public Text Label;

			public string Id;
		}

		private sealed class SuggestionPointerDownCatcher : MonoBehaviour, IPointerDownHandler, IEventSystemHandler
		{
			public TalentSearchController Owner;

			public int Index;

			public void OnPointerDown(PointerEventData eventData)
			{
				Owner._suppressEndEditOnce = true;
				Owner.SelectByIndex(Index);
			}
		}

		private const int DefaultIndexCapacity = 256;

		private const int DefaultMatchBufferCapacity = 256;

		private const int DefaultSuggestionsCapacity = 16;

		private const int ScorePrefixNameBase = 1000;

		private const int ScoreContainsNameBase = 800;

		private const int ScorePrefixIdBase = 600;

		private const int ScoreContainsIdBase = 400;

		private const int ScoreContainsHaystackBase = 200;

		private readonly TalentUiTheme _theme;

		private readonly TalentUiLayout _layout;

		private readonly List<SearchItem> _index = new List<SearchItem>(256);

		private readonly List<SearchMatch> _matchBuffer = new List<SearchMatch>(256);

		private readonly List<SuggestionEntry> _suggestions = new List<SuggestionEntry>(16);

		private readonly InputField _input;

		private readonly RectTransform _inputRt;

		private readonly GameObject _dropdown;

		private readonly RectTransform _dropdownRt;

		private bool _suppressSearchEvents;

		private bool _suppressEndEditOnce;

		private bool _selecting;

		private bool _pendingHide;

		private int _selectedSuggestionIndex = -1;

		private Func<TalentDefinition, string> _displayName;

		private Action<string> _onSelected;

		public bool IsDropdownVisible => (Object)(object)_dropdown != (Object)null && _dropdown.activeSelf;

		public TalentSearchController(InputField input, RectTransform inputRt, GameObject dropdown, RectTransform dropdownRt, TalentUiTheme theme = null, TalentUiLayout layout = null)
		{
			_input = input;
			_inputRt = inputRt;
			_dropdown = dropdown;
			_dropdownRt = dropdownRt;
			_theme = theme ?? TalentUiTheme.Default;
			_layout = layout ?? TalentUiLayout.Default;
		}

		public void Bind(Func<TalentDefinition, string> displayName, Action<string> onSelected)
		{
			_displayName = displayName;
			_onSelected = onSelected;
			((UnityEventBase)_input.onValueChanged).RemoveAllListeners();
			((UnityEventBase)_input.onEndEdit).RemoveAllListeners();
			((UnityEvent<string>)(object)_input.onValueChanged).AddListener((UnityAction<string>)OnSearchChanged);
			((UnityEvent<string>)(object)_input.onEndEdit).AddListener((UnityAction<string>)OnSearchEndEdit);
		}

		public void RebuildIndex(IEnumerable<TalentDefinition> defs)
		{
			_index.Clear();
			foreach (TalentDefinition def in defs)
			{
				if (def != null && def.Tier != NodeTier.Minor)
				{
					string text = def.Id ?? "";
					string text2 = ((_displayName != null) ? _displayName(def) : (def.NameKey ?? text));
					string text3 = text.ToLowerInvariant();
					string text4 = (text2 ?? "").ToLowerInvariant();
					_index.Add(new SearchItem
					{
						Id = text,
						Name = text2,
						IdLower = text3,
						NameLower = text4,
						HaystackLower = text3 + " " + text4
					});
				}
			}
		}

		public void Clear()
		{
			_suppressSearchEvents = true;
			try
			{
				_input.text = "";
			}
			finally
			{
				_suppressSearchEvents = false;
			}
			HideDropdown();
		}

		public void HideDropdown()
		{
			_pendingHide = false;
			if ((Object)(object)_dropdown != (Object)null)
			{
				_dropdown.SetActive(false);
			}
			_selectedSuggestionIndex = -1;
		}

		public void Tick()
		{
			if ((Object)(object)_input == (Object)null || (Object)(object)_dropdown == (Object)null)
			{
				return;
			}
			if (_pendingHide)
			{
				_pendingHide = false;
				if (!_selecting)
				{
					HideDropdown();
				}
			}
			else if (_dropdown.activeSelf && _input.isFocused)
			{
				if (Input.GetKeyDown((KeyCode)274))
				{
					_selectedSuggestionIndex = Mathf.Clamp(_selectedSuggestionIndex + 1, 0, GetVisibleSuggestionCount() - 1);
					ApplySuggestionHighlight();
				}
				else if (Input.GetKeyDown((KeyCode)273))
				{
					_selectedSuggestionIndex = Mathf.Clamp(_selectedSuggestionIndex - 1, 0, GetVisibleSuggestionCount() - 1);
					ApplySuggestionHighlight();
				}
				else if (IsSubmitKeyDown())
				{
					TrySelectCurrentSuggestion();
				}
				else if (Input.GetKeyDown((KeyCode)27))
				{
					HideDropdown();
					_input.DeactivateInputField();
				}
			}
		}

		private void OnSearchEndEdit(string value)
		{
			if (!_selecting)
			{
				if (_suppressEndEditOnce)
				{
					_suppressEndEditOnce = false;
				}
				else if (!IsSubmitKeyDown() || !TrySelectCurrentSuggestion())
				{
					_pendingHide = true;
				}
			}
		}

		private void OnSearchChanged(string raw)
		{
			if (!_suppressSearchEvents && !_selecting)
			{
				if (string.IsNullOrWhiteSpace(raw))
				{
					HideDropdown();
				}
				else
				{
					UpdateSuggestions(raw);
				}
			}
		}

		private void UpdateSuggestions(string raw)
		{
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			_matchBuffer.Clear();
			string text = raw.Trim().ToLowerInvariant();
			if (text.Length == 0)
			{
				HideDropdown();
				return;
			}
			for (int i = 0; i < _index.Count; i++)
			{
				SearchItem item = _index[i];
				int num = ScoreMatch(item, text);
				if (num > 0)
				{
					_matchBuffer.Add(new SearchMatch
					{
						Item = item,
						Score = num
					});
				}
			}
			if (_matchBuffer.Count == 0)
			{
				HideDropdown();
				return;
			}
			_matchBuffer.Sort((SearchMatch a, SearchMatch b) => b.Score.CompareTo(a.Score));
			int num2 = Mathf.Min(_layout.SearchMaxSuggestions, _matchBuffer.Count);
			EnsureSuggestionEntries(num2);
			for (int num3 = 0; num3 < num2; num3++)
			{
				SearchMatch searchMatch = _matchBuffer[num3];
				SuggestionEntry suggestionEntry = _suggestions[num3];
				suggestionEntry.Id = searchMatch.Item.Id;
				suggestionEntry.Label.text = searchMatch.Item.Name;
				suggestionEntry.Go.SetActive(true);
			}
			for (int num4 = num2; num4 < _suggestions.Count; num4++)
			{
				_suggestions[num4].Go.SetActive(false);
			}
			_selectedSuggestionIndex = 0;
			ApplySuggestionHighlight();
			if ((Object)(object)_dropdownRt != (Object)null && (Object)(object)_inputRt != (Object)null)
			{
				_dropdownRt.anchoredPosition = new Vector2(_inputRt.anchoredPosition.x, _inputRt.anchoredPosition.y - _inputRt.sizeDelta.y - _layout.SearchDropdownGap);
			}
			_dropdown.SetActive(true);
		}

		private int ScoreMatch(SearchItem item, string q)
		{
			if (item.NameLower.StartsWith(q))
			{
				return 1000 - item.NameLower.Length;
			}
			if (item.NameLower.Contains(q))
			{
				return 800 - item.NameLower.Length;
			}
			if (item.IdLower.StartsWith(q))
			{
				return 600 - item.IdLower.Length;
			}
			if (item.IdLower.Contains(q))
			{
				return 400 - item.IdLower.Length;
			}
			if (item.HaystackLower.Contains(q))
			{
				return 200 - item.HaystackLower.Length;
			}
			return 0;
		}

		private int GetVisibleSuggestionCount()
		{
			int num = 0;
			for (int i = 0; i < _suggestions.Count; i++)
			{
				if (_suggestions[i].Go.activeSelf)
				{
					num++;
				}
			}
			return num;
		}

		private void ApplySuggestionHighlight()
		{
			//IL_005f: 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)
			for (int i = 0; i < _suggestions.Count; i++)
			{
				SuggestionEntry suggestionEntry = _suggestions[i];
				if (suggestionEntry.Go.activeSelf)
				{
					bool flag = i == _selectedSuggestionIndex;
					if ((Object)(object)suggestionEntry.Background != (Object)null)
					{
						((Graphic)suggestionEntry.Background).color = (flag ? _theme.SuggestionSelected : _theme.SuggestionNormal);
					}
				}
			}
		}

		private void EnsureSuggestionEntries(int count)
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Expected O, but got Unknown
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Expected O, but got Unknown
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Expected O, but got Unknown
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			while (_suggestions.Count < count)
			{
				int count2 = _suggestions.Count;
				GameObject val = new GameObject($"Row_{count2}", new Type[3]
				{
					typeof(RectTransform),
					typeof(Image),
					typeof(LayoutElement)
				});
				val.transform.SetParent(_dropdown.transform, false);
				RectTransform val2 = (RectTransform)val.transform;
				val2.sizeDelta = new Vector2(0f, _layout.SuggestionRowHeight);
				LayoutElement component = val.GetComponent<LayoutElement>();
				component.minHeight = _layout.SuggestionRowHeight;
				component.preferredHeight = _layout.SuggestionRowHeight;
				component.flexibleHeight = 0f;
				Image component2 = val.GetComponent<Image>();
				((Graphic)component2).color = _theme.SuggestionNormal;
				((Graphic)component2).raycastTarget = true;
				Button val3 = val.AddComponent<Button>();
				((Selectable)val3).transition = (Transition)0;
				SuggestionPointerDownCatcher suggestionPointerDownCatcher = val.AddComponent<SuggestionPointerDownCatcher>();
				suggestionPointerDownCatcher.Owner = this;
				suggestionPointerDownCatcher.Index = count2;
				GameObject val4 = new GameObject("Label", new Type[2]
				{
					typeof(RectTransform),
					typeof(Text)
				});
				val4.transform.SetParent(val.transform, false);
				RectTransform rt = (RectTransform)val4.transform;
				UiFactory.SetRectStretch(rt, new Vector2(_layout.SuggestionLabelPaddingX, 0f), new Vector2(0f - _layout.SuggestionLabelPaddingX, 0f));
				Text component3 = val4.GetComponent<Text>();
				component3.text = "";
				component3.font = GUIManager.Instance.AveriaSerifBold;
				component3.fontSize = _layout.SuggestionFontSize;
				((Graphic)component3).color = Color.white;
				component3.alignment = (TextAnchor)3;
				component3.supportRichText = false;
				((Graphic)component3).raycastTarget = false;
				SuggestionEntry item = new SuggestionEntry
				{
					Go = val,
					Button = val3,
					Background = component2,
					Label = component3,
					Id = null
				};
				_suggestions.Add(item);
			}
		}

		private void SelectByIndex(int index)
		{
			if (index >= 0 && index < _suggestions.Count && _suggestions[index].Go.activeSelf)
			{
				_selectedSuggestionIndex = index;
				ApplySuggestionHighlight();
				TrySelectCurrentSuggestion();
			}
		}

		private bool TrySelectCurrentSuggestion()
		{
			int visibleSuggestionCount = GetVisibleSuggestionCount();
			if (visibleSuggestionCount <= 0)
			{
				return false;
			}
			_selectedSuggestionIndex = Mathf.Clamp(_selectedSuggestionIndex, 0, visibleSuggestionCount - 1);
			SuggestionEntry suggestionEntry = _suggestions[_selectedSuggestionIndex];
			if (string.IsNullOrEmpty(suggestionEntry.Id))
			{
				return false;
			}
			_selecting = true;
			try
			{
				HideDropdown();
				_input.DeactivateInputField();
				_onSelected?.Invoke(suggestionEntry.Id);
			}
			finally
			{
				_selecting = false;
			}
			return true;
		}

		private static bool IsSubmitKeyDown()
		{
			return Input.GetKeyDown((KeyCode)13) || Input.GetKeyDown((KeyCode)271);
		}
	}
	internal static class TalentTreeLayoutCoordinator
	{
		public static float TreeBaseSize { get; private set; }

		public static float AutoFitZoom { get; private set; }

		private static TalentUiLayout Layout => TalentUiLayout.Default;

		private static Vector2 ComputeContentSize(float vpW, float vpH)
		{
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Max(vpW, vpH);
			float num2 = Layout.ScrollExtraPadding * (vpW / num);
			float num3 = Layout.ScrollExtraPadding * (vpH / num);
			float num4 = TreeBaseSize + 2f * num2;
			float num5 = TreeBaseSize + 2f * num3;
			float num6 = Mathf.Max(0.01f, Layout.StartZoom);
			float num7 = (vpW - vpH) / num6;
			float num8 = ((num7 > 0f) ? (num4 + num7) : num4);
			float num9 = ((num7 > 0f) ? num5 : (num5 - num7));
			return new Vector2(num8, num9);
		}

		public static RadialLayout.LayoutResult ApplyRadialLayout(TalentTreeView tree)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			string[] orderedIds = SectorRegistry.GetOrderedIds();
			RadialLayout.LayoutResult layoutResult = RadialLayout.ComputePositionsNoOverlap(TalentRegistry.All, orderedIds, RadialLayoutParams.FromLayout(Layout));
			foreach (KeyValuePair<string, Vector2> position in layoutResult.Positions)
			{
				tree.SetNodePosition(position.Key, position.Value);
			}
			return layoutResult;
		}

		public static void ResizeWorldToFit(float maxRadius, TalentWindowView view)
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			TreeBaseSize = Mathf.Max(Layout.MinWorldSize, maxRadius * 2f + Layout.WorldPadding);
			float num = TreeBaseSize;
			float num2 = TreeBaseSize;
			Rect rect;
			if ((Object)(object)view?.ViewportRt != (Object)null)
			{
				rect = view.ViewportRt.rect;
				float width = ((Rect)(ref rect)).width;
				rect = view.ViewportRt.rect;
				float height = ((Rect)(ref rect)).height;
				if (width > 0f && height > 0f)
				{
					Vector2 val = ComputeContentSize(width, height);
					num = val.x;
					num2 = val.y;
				}
			}
			if ((Object)(object)view?.ContentRt != (Object)null)
			{
				view.ContentRt.sizeDelta = new Vector2(num, num2);
			}
			if ((Object)(object)view?.WorldRt != (Object)null)
			{
				view.WorldRt.sizeDelta = new Vector2(num, num2);
			}
			if ((Object)(object)view?.PathsRootRt != (Object)null)
			{
				SetupWorldLayer(view.PathsRootRt, num, num2);
			}
			if ((Object)(object)view?.NodesRootRt != (Object)null)
			{
				SetupWorldLayer(view.NodesRootRt, num, num2);
			}
			if ((Object)(object)view?.ScrollRect != (Object)null)
			{
				view.ScrollRect.normalizedPosition = new Vector2(0.5f, 0.5f);
			}
			AutoFitZoom = Layout.StartZoom;
			if ((Object)(object)view?.ViewportRt != (Object)null && TreeBaseSize > 0f)
			{
				rect = view.ViewportRt.rect;
				float width2 = ((Rect)(ref rect)).width;
				rect = view.ViewportRt.rect;
				float height2 = ((Rect)(ref rect)).height;
				if (width2 > 0f && height2 > 0f)
				{
					float num3 = Mathf.Min(width2 / TreeBaseSize, height2 / TreeBaseSize) * 0.9f;
					AutoFitZoom = Mathf.Clamp(num3, Layout.MinZoom, Layout.MaxZoom);
				}
			}
		}

		public static SectorLabelTracker InitSectorLabelTracker(TalentWindowView view, RadialLayout.LayoutResult layoutResult, Dictionary<string, RectTransform> nodeRects, SectorLabelTracker existing)
		{
			if ((Object)(object)existing != (Object)null)
			{
				existing.Cleanup();
				Object.Destroy((Object)(object)existing);
			}
			if ((Object)(object)view?.ViewportRt == (Object)null || (Object)(object)view?.WorldRt == (Object)null || (Object)(object)view?.ContentRt == (Object)null)
			{
				return null;
			}
			Transform parent = ((Transform)view.ViewportRt).parent;
			GameObject val = ((parent != null) ? ((Component)parent).gameObject : null) ?? ((Component)view.ViewportRt).gameObject;
			SectorLabelTracker sectorLabelTracker = val.AddComponent<SectorLabelTracker>();
			sectorLabelTracker.Initialize(view.WorldRt, view.ViewportRt, view.ContentRt, layoutResult.SectorMidAngles, layoutResult.Positions, nodeRects);
			return sectorLabelTracker;
		}

		public static void RecalculateForViewport(TalentWindowView view)
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)view?.ViewportRt == (Object)null || (Object)(object)view?.ContentRt == (Object)null || TreeBaseSize <= 0f)
			{
				return;
			}
			Rect rect = view.ViewportRt.rect;
			float width = ((Rect)(ref rect)).width;
			rect = view.ViewportRt.rect;
			float height = ((Rect)(ref rect)).height;
			if (!(width <= 0f) && !(height <= 0f))
			{
				Vector2 sizeDelta = ComputeContentSize(width, height);
				view.ContentRt.sizeDelta = sizeDelta;
				if ((Object)(object)view.WorldRt != (Object)null)
				{
					view.WorldRt.sizeDelta = sizeDelta;
				}
				float num = Mathf.Min(width / TreeBaseSize, height / TreeBaseSize) * 0.9f;
				AutoFitZoom = Mathf.Clamp(num, Layout.MinZoom, Layout.MaxZoom);
			}
		}

		private static void SetupWorldLayer(RectTransform rt, float width, float height)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)rt == (Object)null))
			{
				UiFactory.SetCenter(rt, Vector2.zero, new Vector2(width, height));
			}
		}
	}
	public static class TalentWindow
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static Action <0>__Tick;

			public static UnityAction <1>__Toggle;

			public static UnityAction <2>__ToggleStats;

			public static UnityAction <3>__OnApplyClicked;

			public static UnityAction <4>__OnResetDraftClicked;

			public static Action <5>__HidePreview;

			public static Action<string, bool> <6>__ShowHoverPreview;

			public static Action<string> <7>__CenterOnNode;

			public static Action <8>__Refresh;

			public static Func<TalentDefinition, string> <9>__GetTalentDisplayName;
		}

		private static TalentWindowView _view;

		private static TalentTreeView _tree;

		private static TalentTreePathView _paths;

		private static TalentHoverTooltip _hoverTooltip;

		private static StatsPanelView _statsPanel;

		private static TalentApplyConfirmDialog _applyConfirmDialog;

		private static TalentSearchController _search;

		private static SectorLabelTracker _sectorTracker;

		private static Dictionary<string, RectTransform> _nodeRects;

		private static TalentWindowHoverController _hover;

		private static TalentWindowSelectionController _selection;

		private static bool _statsOpen;

		private static GameObject _updaterHost;

		private static UpdateLoopRunner _loop;

		private static bool _pendingBuild;

		private static bool _pendingOpen;

		private static bool _loggedGuiNotReady;

		private static TalentUiLayout Layout => TalentUiLayout.Default;

		public static bool IsOpen => (Object)(object)_view?.Root != (Object)null && _view.Root.activeSelf;

		public static void EnsureBuilt()
		{
			if (GUIManager.Instance == null)
			{
				return;
			}
			EnsureUpdateLoop();
			if (_view != null && (Object)(object)_view.Root == (Object)null)
			{
				_view = null;
			}
			if ((Object)(object)GUIManager.CustomGUIFront == (Object)null)
			{
				_pendingBuild = true;
				return;
			}
			if (_view != null && (Object)(object)_view.Root != (Object)null && (Object)(object)_view.Root.transform.parent != (Object)(object)GUIManager.CustomGUIFront.transform)
			{
				Object.Destroy((Object)(object)_view.Root);
				_view = null;
			}
			if (_view != null)
			{
				return;
			}
			try
			{
				BuildUI();
			}
			catch (Exception arg)
			{
				Logger.LogError((object)$"Failed building Talent window UI: {arg}");
				_view = null;
			}
		}

		private static void EnsureUpdateLoop()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			if (!((Object)(object)_loop != (Object)null))
			{
				_updaterHost = new GameObject("TalentTree_UpdateLoop");
				Object.DontDestroyOnLoad((Object)(object)_updaterHost);
				_loop = _updaterHost.AddComponent<UpdateLoopRunner>();
				_loop.Tick = Tick;
			}
		}

		public static void Toggle()
		{
			EnsureBuilt();
			if ((Object)(object)_view?.Root == (Object)null)
			{
				_pendingBuild = true;
				_pendingOpen = true;
				if (!_loggedGuiNotReady)
				{
					Logger.LogWarning((object)"Talent window UI is not ready yet (Custom GUI is rebuilding). It will open automatically once available.");
					_loggedGuiNotReady = true;
				}
				return;
			}
			_loggedGuiNotReady = false;
			bool flag = !_view.Root.activeSelf;
			_view.Root.SetActive(flag);
			GUIManager.BlockInput(flag);
			if (flag)
			{
				OnOpened();
			}
		}

		private static void EnsureGuiScaler()
		{
			GameObject customGUIFront = GUIManager.CustomGUIFront;
			if (!((Object)(object)customGUIFront == (Object)null) && !((Object)(object)customGUIFront.GetComponent<GuiScaler>() != (Object)null))
			{
				customGUIFront.AddComponent<GuiScaler>();
			}
		}

		private static void BuildUI()
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Expected O, but got Unknown
			//IL_00d7: 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_00e2: Expected O, but got Unknown
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Expected O, but got Unknown
			EnsureGuiScaler();
			_view = TalentWindowView.Build();
			_view.ApplyLocalization();
			if ((Object)(object)_view.CloseButton != (Object)null)
			{
				ButtonClickedEvent onClick = _view.CloseButton.onClick;
				object obj = <>O.<1>__Toggle;
				if (obj == null)
				{
					UnityAction val = Toggle;
					<>O.<1>__Toggle = val;
					obj = (object)val;
				}
				((UnityEvent)onClick).AddListener((UnityAction)obj);
			}
			if ((Object)(object)_view.StatsButton != (Object)null)
			{
				ButtonClickedEvent onClick2 = _view.StatsButton.onClick;
				object obj2 = <>O.<2>__ToggleStats;
				if (obj2 == null)
				{
					UnityAction val2 = ToggleStats;
					<>O.<2>__ToggleStats = val2;
					obj2 = (object)val2;
				}
				((UnityEvent)onClick2).AddListener((UnityAction)obj2);
			}
			if ((Object)(object)_view.ApplyButton != (Object)null)
			{
				ButtonClickedEvent onClick3 = _view.ApplyButton.onClick;
				object obj3 = <>O.<3>__OnApplyClicked;
				if (obj3 == null)
				{
					UnityAction val3 = OnApplyClicked;
					<>O.<3>__OnApplyClicked = val3;
					obj3 = (object)val3;
				}
				((UnityEvent)onClick3).AddListener((UnityAction)obj3);
			}
			if ((Object)(object)_view.ResetButton != (Object)null)
			{
				ButtonClickedEvent onClick4 = _view.ResetButton.onClick;
				object obj4 = <>O.<4>__OnResetDraftClicked;
				if (obj4 == null)
				{
					UnityAction val4 = OnResetDraftClicked;
					<>O.<4>__OnResetDraftClicked = val4;
					obj4 = (object)val4;
				}
				((UnityEvent)onClick4).AddListener((UnityAction)obj4);
			}
			JotunnLocalization.LocalizationUpdated += delegate
			{
				_view?.ApplyLocalization();
				_statsPanel?.ApplyLocalization();
				_sectorTracker?.RefreshLabelText();
				_hoverTooltip?.ApplyLocalization();
				_applyConfirmDialog?.ApplyLocalization();
				if (_search != null)
				{
					_search.RebuildIndex(TalentRegistry.All);
				}
				if (IsOpen)
				{
					Refresh();
				}
			};
			_hover = new TalentWindowHoverController(Layout, () => _selection != null && _selection.Pinned, delegate(string id)
			{
				ShowHoverPreview(id);
			}, HidePreview);
			_selection = new TalentWindowSelectionController(_hover, ShowHoverPreview, HidePreview, CenterOnNode, Refresh);
			_tree = new TalentTreeView();
			_tree.Build(_view.NodesRootRt);
			_tree.NodeClicked += _selection.OnNodeClicked;
			_tree.NodeHoverEnter += _hover.OnNodeHoverEnter;
			_tree.NodeHoverExit += _hover.OnNodeHoverExit;
			RadialLayout.LayoutResult layoutResult = TalentTreeLayoutCoordinator.ApplyRadialLayout(_tree);
			_tree.CorrectIconRotations();
			_nodeRects = _tree.GetNodeRects();
			TalentTreeLayoutCoordinator.ResizeWorldToFit(layoutResult.MaxRadius, _view);
			_sectorTracker = TalentTreeLayoutCoordinator.InitSectorLabelTracker(_view, layoutResult, _nodeRects, _sectorTracker);
			_paths = new TalentTreePathView();
			_paths.Build(_view.PathsRootRt, _nodeRects);
			_paths.RebuildTransforms();
			_statsPanel = new StatsPanelView();
			_statsPanel.Build(_view.PanelRect, Layout);
			_statsPanel.ApplyLocalization();
			_statsPanel.SetVisible(visible: false);
			_hoverTooltip = new TalentHoverTooltip();
			_hoverTooltip.Build(_view.PanelRect);
			_hoverTooltip.SelectRequested += _selection.StageById;
			_hoverTooltip.SelectAllRequested += _selection.StageAllById;
			_hoverTooltip.DeselectRequested += _selection.UnstageById;
			_hoverTooltip.Hide();
			_applyConfirmDialog = new TalentApplyConfirmDialog();
			_applyConfirmDialog.Build(_view.PanelRect, delegate
			{
				_selection?.ApplyDraft();
			});
			if ((Object)(object)_view.PanelClickCatcher != (Object)null)
			{
				_view.PanelClickCatcher.Clicked += _selection.OnPanelClicked;
			}
			_search = new TalentSearchController(_view.SearchInput, _view.SearchInputRt, _view.SearchDropdown, _view.SearchDropdownRt, TalentUiTheme.Default, Layout);
			_search.Bind(GetTalentDisplayName, _selection.SelectTalent);
			_search.RebuildIndex(TalentRegistry.All);
			ApplyZOrder();
		}

		private static void ApplyZOrder()
		{
			RectTransform searchInputRt = _view.SearchInputRt;
			if (searchInputRt != null)
			{
				((Transform)searchInputRt).SetAsLastSibling();
			}
			RectTransform searchDropdownRt = _view.SearchDropdownRt;
			if (searchDropdownRt != null)
			{
				((Transform)searchDropdownRt).SetAsLastSibling();
			}
			StatsPanelView statsPanel = _statsPanel;
			if (statsPanel != null)
			{
				GameObject root = statsPanel.Root;
				if (root != null)
				{
					root.transform.SetAsLastSibling();
				}
			}
			TalentHoverTooltip hoverTooltip = _hoverTooltip;
			if (hoverTooltip != null)
			{
				GameObject root2 = hoverTooltip.Root;
				if (root2 != null)
				{
					root2.transform.SetAsLastSibling();
				}
			}
			TalentApplyConfirmDialog applyConfirmDialog = _applyConfirmDialog;
			if (applyConfirmDialog != null)
			{
				GameObject root3 = applyConfirmDialog.Root;
				if (root3 != null)
				{
					root3.transform.SetAsLastSibling();
				}
			}
		}

		private static void OnOpened()
		{
			_selection?.ResetOnOpen();
			_hover?.Reset();
			_statsOpen = false;
			_hoverTooltip?.Hide();
			_statsPanel?.SetVisible(visible: false);
			_applyConfirmDialog?.Hide();
			_tree?.ClearAllHighlights();
			UpdateDraftButtonsInteractable();
			TalentTreeLayoutCoordinator.RecalculateForViewport(_view);
			float autoFitZoom = TalentTreeLayoutCoordinator.AutoFitZoom;
			float num = ((autoFitZoom > 0f) ? autoFitZoom : Layout.StartZoom);
			num = Mathf.Max(num, Layout.MinZoom);
			_view?.Zoom?.SetScale(num);
			if ((Object)(object)_view?.Zoom != (Object)null)
			{
				_view.Zoom.Initialize(_view.ViewportRt, _view.ContentRt, _view.ScrollRect, Layout.MinZoom, Layout.MaxZoom, Layout.ZoomFactorPerStep, Layout.MouseWheelDeadzone);
				_view.Zoom.SetScale(num);
			}
			_search?.Clear();
			_search?.RebuildIndex(TalentRegistry.All);
			Refresh();
		}

		private static void Tick()
		{
			if (_pendingBuild || _pendingOpen)
			{
				if (_view != null && (Object)(object)_view.Root == (Object)null)
				{
					_view = null;
				}
				if (GUIManager.Instance != null && (Object)(object)GUIManager.CustomGUIFront != (Object)null)
				{
					EnsureBuilt();
					_pendingBuild = false;
					_loggedGuiNotReady = false;
					if (_pendingOpen && (Object)(object)_view?.Root != (Object)null)
					{
						_pendingOpen = false;
						if (!_view.Root.activeSelf)
						{
							_view.Root.SetActive(true);
							GUIManager.BlockInput(true);
							OnOpened();
						}
					}
				}
			}
			if (!IsOpen)
			{
				return;
			}
			if (ZInput.GetKeyDown((KeyCode)27, true) || Input.GetKeyDown((KeyCode)27))
			{
				if (_applyConfirmDialog != null && _applyConfirmDialog.IsVisible)
				{
					_applyConfirmDialog.Hide();
				}
				else if (_search != null && _search.IsDropdownVisible)
				{
					_search.HideDropdown();
				}
				else
				{
					if (_selection == null || !_selection.Pinned)
					{
						Toggle();
						return;
					}
					_selection.CloseAndUnpin();
				}
			}
			_search?.Tick();
			_hoverTooltip?.Tick();
			if (_hoverTooltip != null && _nodeRects != null && _selection != null && _hover != null)
			{
				string text = (_selection.Pinned ? _selection.SelectedId : _hover.CandidateId);
				if (!string.IsNullOrEmpty(text) && _nodeRects.TryGetValue(text, out var value))
				{
					_hoverTooltip.UpdatePosition(value);
				}
			}
			_hover?.Tick();
		}

		private static void HidePreview()
		{
			_hoverTooltip?.Hide();
			_tree?.ClearAllHighlights();
		}

		private static void ShowHoverPreview(string id, bool pinned = false)
		{
			if (!((Object)(object)Player.m_localPlayer == (Object)null) && TalentRegistry.TryGet(id, out var def))
			{
				_tree.ClearAllHighlights();
				_tree.SetHighlighted(id, on: true, Layout.SelectedNodeScale);
				TalentRuntime rt = TalentRuntimeService.Get(Player.m_localPlayer);
				int value = 0;
				int value2 = 0;
				rt?.State.Ranks.TryGetValue(id, out value);
				rt?.DraftRanks.TryGetValue(id, out value2);
				bool canUnlock = rt != null && TalentWindowSelectionController.CanUnlock(rt, def);
				Func<string, int> getRank = ((rt != null) ? new Func<string, int>(rt.GetEffectiveRank) : null);
				int value4;
				Func<string, int> committedRank = ((rt != null) ? ((Func<string, int>)((string tid) => rt.State.Ranks.TryGetValue(tid, out value4) ? value4 : 0)) : null);
				if (_nodeRects != null && _nodeRects.TryGetValue(id, out var value3))
				{
					_hoverTooltip?.ShowFor(def, value3, value, value2, getRank, committedRank, canUnlock, pinned);
				}
			}
		}

		private static void CenterOnNode(string id)
		{
			//IL_00a0: 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_00b1: Unknown result type (might be due to invalid IL or missing references)
			//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_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: 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_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_view?.ContentRt == (Object)null || (Object)(object)_view.ViewportRt == (Object)null)
			{
				return;
			}
			if (_nodeRects == null && _tree != null)
			{
				_nodeRects = _tree.GetNodeRects();
			}
			if (_nodeRects != null && _nodeRects.TryGetValue(id, out var value) && !((Object)(object)value == (Object)null))
			{
				float x = ((Transform)_view.ContentRt).localScale.x;
				Vector2 anchoredPosition = value.anchoredPosition;
				Vector2 val = -anchoredPosition * x;
				float num = _view.ContentRt.sizeDelta.x * x;
				float num2 = _view.ContentRt.sizeDelta.y * x;
				Rect rect = _view.ViewportRt.rect;
				float width = ((Rect)(ref rect)).width;
				rect = _view.ViewportRt.rect;
				float height = ((Rect)(ref rect)).height;
				float num3 = Mathf.Max(0f, (num - width) * 0.5f);
				float num4 = Mathf.Max(0f, (num2 - height) * 0.5f);
				val.x = Mathf.Clamp(val.x, 0f - num3, num3);
				val.y = Mathf.Clamp(val.y, 0f - num4, num4);
				_view.ContentRt.anchoredPosition = val;
				if ((Object)(object)_view.ScrollRect != (Object)null)
				{
					_view.ScrollRect.velocity = Vector2.zero;
				}
			}
		}

		private static void OnApplyClicked()
		{
			if (!((Object)(object)Player.m_localPlayer == (Object)null))
			{
				int pendingCost = TalentDraftService.GetPendingCost(Player.m_localPlayer);
				if (pendingCost > 0)
				{
					int availableBeforeApply = TalentPointBudgetService.GetAvailablePoints(Player.m_localPlayer) + pendingCost;
					_applyConfirmDialog?.Show(pendingCost, availableBeforeApply);
				}
			}
		}

		private static void OnResetDraftClicked()
		{
			_selection?.ResetDraft();
		}

		private static void UpdateDraftButtonsInteractable()
		{
			bool active = TalentWindowSelectionController.HasPendingDraft();
			TalentWindowView view = _view;
			if (view != null)
			{
				Button applyButton = view.ApplyButton;
				if (applyButton != null)
				{
					((Component)applyButton).gameObject.SetActive(active);
				}
			}
			TalentWindowView view2 = _view;
			if (view2 != null)
			{
				Button resetButton = view2.ResetButton;
				if (resetButton != null)
				{
					((Component)resetButton).gameObject.SetActive(active);
				}
			}
		}

		private static void ToggleStats()
		{
			if ((Object)(object)Player.m_localPlayer == (Object)null)
			{
				return;
			}
			_statsOpen = !_statsOpen;
			_statsPanel?.SetVisible(_statsOpen);
			if (_statsOpen)
			{
				TalentRuntime talentRuntime = TalentRuntimeService.Get(Player.m_localPlayer);
				if (talentRuntime != null)
				{
					_statsPanel?.Refresh(talentRuntime);
				}
			}
		}

		private static void Refresh()
		{
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Player.m_localPlayer == (Object)null)
			{
				return;
			}
			TalentRuntime talentRuntime = TalentRuntimeService.Get(Player.m_localPlayer);
			if (talentRuntime != null)
			{
				if ((Object)(object)_view?.PointsText != (Object)null)
				{
					int availablePoints = TalentPointBudgetService.GetAvailablePoints(Player.m_localPlayer, talentRuntime);
					_view.PointsText.text = availablePoints.ToString();
					Color plannedTextColor = TalentUiTheme.Default.PlannedTextColor;
					BlinkingTextEffect.SetActive(_view.PointsText, TalentDraftService.HasPendingDraft(Player.m_localPlayer), BlinkingTextEffect.Darken(plannedTextColor, 0.55f), plannedTextColor, Color.white);
				}
				_tree.UpdateVisuals(talentRuntime, Player.m_localPlayer);
				_paths.UpdateVisuals(talentRuntime, Player.m_localPlayer);
				if (_statsOpen)
				{
					_statsPanel?.Refresh(talentRuntime);
				}
				if (_selection != null && _selection.Pinned && !string.IsNullOrEmpty(_selection.SelectedId))
				{
					ShowHoverPreview(_selection.SelectedId, pinned: true);
				}
				UpdateDraftButtonsInteractable();
			}
		}

		private static string GetTalentDisplayName(TalentDefinition def)
		{
			if (def == null)
			{
				return string.Empty;
			}
			return JotunnLocalization.TranslateSmart(def.NameKey) ?? def.Id ?? string.Empty;
		}
	}
	internal sealed class TalentWindowHoverController
	{
		private readonly TalentUiLayout _layout;

		private readonly Func<bool> _isPinned;

		private readonly Action<string> _showPreview;

		private readonly Action _hidePreview;

		private float _enterAt;

		private bool _previewShown;

		public string CandidateId { get; private set; }

		public TalentWindowHoverController(TalentUiLayout layout, Func<bool> isPinned, Action<string> showPreview, Action hidePreview)
		{
			_layout = layout;
			_isPinned = isPinned;
			_showPreview = showPreview;
			_hidePreview = hidePreview;
		}

		public void OnNodeHoverEnter(string id)
		{
			if (!_isPinned())
			{
				_hidePreview();
				CandidateId = id;
				_enterAt = Time.unscaledTime;
				_previewShown = false;
			}
		}

		public void OnNodeHoverExit(string id)
		{
			if (!_isPinned() && !(CandidateId != id))
			{
				Reset();
				_hidePreview();
			}
		}

		public void Tick()
		{
			if (!_isPinned() && !string.IsNullOrEmpty(CandidateId) && !_previewShown && !QuickSkillInput.IsAnyHeld() && Time.unscaledTime - _enterAt >= _layout.HoverDelaySeconds)
			{
				_showPreview(CandidateId);
				_previewShown = true;
			}
		}

		public void Reset()
		{
			CandidateId = null;
			_previewShown = false;
		}

		public void AdoptClick(string id)
		{
			CandidateId = id;
			_previewShown = true;
		}
	}
	internal sealed class TalentWindowSelectionController
	{
		private readonly TalentWindowHoverController _hover;

		private readonly Action<string, bool> _showPreview;

		private readonly Action _hidePreview;

		private readonly Action<string> _centerOnNode;

		private readonly Action _refresh;

		private int _nodeClickedFrame = -1;

		public bool Pinned { get; private set; }

		public string SelectedId { get; private set; }

		public TalentWindowSelectionController(TalentWindowHoverController hover, Action<string, bool> showPreview, Action hidePreview, Action<string> centerOnNode, Action refresh)
		{
			_hover = hover;
			_showPreview = showPreview;
			_hidePreview = hidePreview;
			_centerOnNode = centerOnNode;
			_refresh = refresh;
		}

		public void ResetOnOpen()
		{
			Pinned = false;
			SelectedId = null;
		}

		public void OnNodeClicked(string id)
		{
			if (!((Object)(object)Player.m_localPlayer == (Object)null) && TalentRegistry.TryGet(id, out var _))
			{
				if (QuickSkillInput.IsDeselectHeld())
				{
					UnstageAllById(id);
					return;
				}
				if (QuickSkillInput.IsSelectAllHeld())
				{
					StageAllById(id);
					return;
				}
				Pinned = true;
				SelectedId = id;
				_hover.AdoptClick(id);
				_nodeClickedFrame = Time.frameCount;
				_showPreview(id, arg2: true);
				_refresh();
			}
		}

		public void SelectTalent(string id)
		{
			if (!string.IsNullOrEmpty(id))
			{
				_hidePreview();
				_centerOnNode(id);
				OnNodeClicked(id);
			}
		}

		public void StageById(string id)
		{
			if (!((Object)(object)Player.m_localPlayer == (Object)null) && !string.IsNullOrEmpty(id) && TalentDraftService.TryStage(Player.m_localPlayer, id, out var _))
			{
				_refresh();
			}
		}

		public void StageAllById(string id)
		{
			if (!((Object)(object)Player.m_localPlayer == (Object)null) && !string.IsNullOrEmpty(id))
			{
				TalentDraftService.StageAll(Player.m_localPlayer, id);
				_refresh();
			}
		}

		public void UnstageById(string id)
		{
			if (!((Object)(object)Player.m_localPlayer == (Object)null) && !string.IsNullOrEmpty(id) && TalentDraftService.TryUnstage(Player.m_localPlayer, id))
			{
				_refresh();
			}
		}

		public void UnstageAllById(string id)
		{
			if (!((Object)(object)Player.m_localPlayer == (Object)null) && !string.IsNullOrEmpty(id) && TalentDraftService.TryUnstageAll(Player.m_localPlayer, id))
			{
				_refresh();
			}
		}

		public void ApplyDraft()
		{
			if (!((Object)(object)Player.m_localPlayer == (Object)null))
			{
				TalentDraftService.ApplyDraft(Player.m_localPlayer);
				_refresh();
			}
		}

		public void ResetDraft()
		{
			if (!((Object)(object)Player.m_localPlayer == (Object)null))
			{
				TalentDraftService.ResetDraft(Player.m_localPlayer);
				_refresh();
			}
		}

		public static bool HasPendingDraft()
		{
			return (Object)(object)Player.m_localPlayer != (Object)null && TalentDraftService.HasPendingDraft(Player.m_localPlayer);
		}

		public static bool CanUnlock(TalentRuntime rt, TalentDefinition def)
		{
			if ((Object)(object)Player.m_localPlayer == (Object)null)
			{
				return false;
			}
			string reason;
			return TalentUnlockService.CanUnlock(Player.m_localPlayer, rt, def, out reason);
		}

		public void OnPanelClicked()
		{
			if (Pinned && _nodeClickedFrame != Time.frameCount)
			{
				CloseAndUnpin();
			}
		}

		public void CloseAndUnpin()
		{
			Pinned = false;
			SelectedId = null;
			_hover.Reset();
			_hidePreview();
			_refresh();
		}
	}
	internal static class QuickSkillInput
	{
		public static bool IsSelectAllHeld()
		{
			return Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303);
		}

		public static bool IsDeselectHeld()
		{
			return Input.GetKey((KeyCode)306) || Input.GetKey((KeyCode)305);
		}

		public static bool IsAnyHeld()
		{
			return IsSelectAllHeld() || IsDeselectHeld();
		}
	}
	internal static class UiFactory
	{
		internal readonly struct RectPreset
		{
			public readonly Vector2 AnchorMin;

			public readonly Vector2 AnchorMax;

			public readonly Vector2 Pivot;

			public RectPreset(Vector2 anchorMin, Vector2 anchorMax, Vector2 pivot)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				//IL_0009: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: 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_0011: Unknown result type (might be due to invalid IL or missing references)
				AnchorMin = anchorMin;
				AnchorMax = anchorMax;
				Pivot = pivot;
			}
		}

		internal static class Presets
		{
			public static readonly RectPreset TopLeft = new RectPreset(new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(0f, 1f));

			public static readonly RectPreset TopCenter = new RectPreset(new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0.5f, 1f));

			public static readonly RectPreset TopRight = new RectPreset(new Vector2(1f, 1f), new Vector2(1f, 1f), new Vector2(1f, 1f));

			public static readonly RectPreset Center = new RectPreset(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f));

			public static readonly RectPreset BottomLeft = new RectPreset(new Vector2(0f, 0f), new Vector2(0f, 0f), new Vector2(0f, 0f));

			public static readonly RectPreset BottomCenter = new RectPreset(new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(0.5f, 0f));

			public static readonly RectPreset BottomRight = new RectPreset(new Vector2(1f, 0f), new Vector2(1f, 0f), new Vector2(1f, 0f));

			public static readonly RectPreset StretchFull = new RectPreset(new Vector2(0f, 0f), new Vector2(1f, 1f), new Vector2(0.5f, 0.5f));

			public static readonly RectPreset StretchXTop = new RectPreset(new Vector2(0f, 1f), new Vector2(1f, 1f), new Vector2(0.5f, 1f));

			public static readonly RectPreset StretchYRight = new RectPreset(new Vector2(1f, 0f), new Vector2(1f, 1f), new Vector2(1f, 0.5f));
		}

		private static Sprite _whiteSprite;

		private static Sprite _circleSprite;

		private static Sprite _circleMaskSprite;

		private static Sprite _diamondSprite;

		public static Sprite GetWhiteSprite()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_0025: 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_005d: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_whiteSprite != (Object)null)
			{
				return _whiteSprite;
			}
			Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false);
			val.SetPixel(0, 0, Color.white);
			val.Apply(false, true);
			_whiteSprite = Sprite.Create(val, new Rect(0f, 0f, 1f, 1f), new Vector2(0.5f, 0.5f), 100f);
			((Object)_whiteSprite).name = "RuntimeWhiteSprite";
			return _whiteSprite;
		}

		public static Sprite GetCircleSprite()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_circleSprite != (Object)null)
			{
				return _circleSprite;
			}
			Texture2D val = new Texture2D(256, 256, (TextureFormat)4, false);
			((Texture)val).filterMode = (FilterMode)1;
			float num = 127.5f;
			float num2 = num - 1f;
			for (int i = 0; i < 256; i++)
			{
				for (int j = 0; j < 256; 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, 256f, 256f), new Vector2(0.5f, 0.5f));
			((Object)_circleSprite).name = "RuntimeCircleSprite";
			return _circleSprite;
		}

		public static Sprite GetDiamondSprite()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_diamondSprite != (Object)null)
			{
				return _diamondSprite;
			}
			Texture2D val = new Texture2D(256, 256, (TextureFormat)4, false);
			((Texture)val).filterMode = (FilterMode)1;
			float num = 127.5f;
			float num2 = num * 0.92f;
			for (int i = 0; i < 256; i++)
			{
				for (int j = 0; j < 256; j++)
				{
					float num3 = Mathf.Abs((float)j - num) + Mathf.Abs((float)i - num);
					float num4 = Mathf.Clamp01((num2 - num3) / 1.4142135f + 0.5f);
					val.SetPixel(j, i, new Color(1f, 1f, 1f, num4));
				}
			}
			val.Apply(false, true);
			_diamondSprite = Sprite.Create(val, new Rect(0f, 0f, 256f, 256f), new Vector2(0.5f, 0.5f));
			((Object)_diamondSprite).name = "RuntimeDiamondSprite";
			return _diamondSprite;
		}

		public static Sprite GetCircleMaskSprite()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_circleMaskSprite != (Object)null)
			{
				return _circleMaskSprite;
			}
			Texture2D val = new Texture2D(256, 256, (TextureFormat)4, false);
			((Texture)val).filterMode = (FilterMode)0;
			float num = 127.5f;
			float num2 = num - 1f;
			for (int i = 0; i < 256; i++)
			{
				for (int j = 0; j < 256; j++)
				{
					float num3 = (float)j - num;
					float num4 = (float)i - num;
					float num5 = Mathf.Sqrt(num3 * num3 + num4 * num4);
					float num6 = ((num5 <= num2) ? 1f : 0f);
					val.SetPixel(j, i, new Color(1f, 1f, 1f, num6));
				}
			}
			val.Apply(false, true);
			_circleMaskSprite = Sprite.Create(val, new Rect(0f, 0f, 256f, 256f), new Vector2(0.5f, 0.5f));
			((Object)_circleMaskSprite).name = "RuntimeCircleMaskSprite";
			return _circleMaskSprite;
		}

		private static void ApplyPivot(GameObject go, Vector2 pivot)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			RectTransform val = (((Object)(object)go != (Object)null) ? go.GetComponent<RectTransform>() : null);
			if ((Object)(object)val != (Object)null)
			{
				val.pivot = pivot;
			}
		}

		public static GameObject CreateRoot(string name, Transform parent, bool startActive = false)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			GameObject val = new GameObject(name);
			val.transform.SetParent(parent, false);
			val.SetActive(startActive);
			return val;
		}

		public static RectTransform CreateRect(string name, Transform parent)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) });
			val.transform.SetParent(parent, false);
			return (RectTransform)val.transform;
		}

		public static RectTransform SetRect(RectTransform rt, Vector2 anchorMin, Vector2 anchorMax, Vector2 pivot, Vector2 anchoredPosition, Vector2 sizeDelta)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			rt.anchorMin = anchorMin;
			rt.anchorMax = anchorMax;
			rt.pivot = pivot;
			rt.anchoredPosition = anchoredPosition;
			rt.sizeDelta = sizeDelta;
			return rt;
		}

		public static RectTransform SetRect(RectTransform rt, RectPreset preset, Vector2 anchoredPosition, Vector2 sizeDelta)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			return SetRect(rt, preset.AnchorMin, preset.AnchorMax, preset.Pivot, anchoredPosition, sizeDelta);
		}

		public static RectTransform SetTopLeft(RectTransform rt, Vector2 anchoredPosition, Vector2 sizeDelta)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return SetRect(rt, Presets.TopLeft, anchoredPosition, sizeDelta);
		}

		public static RectTransform SetTopCenter(RectTransform rt, Vector2 anchoredPosition, Vector2 sizeDelta)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return SetRect(rt, Presets.TopCenter, anchoredPosition, sizeDelta);
		}

		public static RectTransform SetTopRight(RectTransform rt, Vector2 anchoredPosition, Vector2 sizeDelta)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return SetRect(rt, Presets.TopRight, anchoredPosition, sizeDelta);
		}

		public static RectTransform SetCenter(RectTransform rt, Vector2 anchoredPosition, Vector2 sizeDelta)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return SetRect(rt, Presets.Center, anchoredPosition, sizeDelta);
		}

		public static RectTransform SetBottomLeft(RectTransform rt, Vector2 anchoredPosition, Vector2 sizeDelta)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return SetRect(rt, Presets.BottomLeft, anchoredPosition, sizeDelta);
		}

		public static RectTransform SetBottomCenter(RectTransform rt, Vector2 anchoredPosition, Vector2 sizeDelta)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return SetRect(rt, Presets.BottomCenter, anchoredPosition, sizeDelta);
		}

		public static RectTransform SetBottomRight(RectTransform rt, Vector2 anchoredPosition, Vector2 sizeDelta)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return SetRect(rt, Presets.BottomRight, anchoredPosition, sizeDelta);
		}

		public static GameObject CreateWoodPanel(Transform parent, string name, RectPreset preset, Vector2 position, Vector2 size, bool draggable)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: 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_001c: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = CreateWoodPanel(parent, name, preset.AnchorMin, preset.AnchorMax, position, size, draggable);
			ApplyPivot(val, preset.Pivot);
			return val;
		}

		public static GameObject CreateWoodPanelCenter(Transform parent, string name, Vector2 position, Vector2 size, bool draggable)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			return CreateWoodPanel(parent, name, Presets.Center, position, size, draggable);
		}

		public static GameObject CreateWoodPanel(Transform parent, string name, Vector2 anchorMin, Vector2 anchorMax, Vector2 position, Vector2 size, bool draggable)
		{
			//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_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = GUIManager.Instance.CreateWoodpanel(parent, anchorMin, anchorMax, position, size.x, size.y, draggable);
			((Object)val).name = name;
			return val;
		}

		public static (GameObject go, Text text) CreateText(Transform parent, string name, string text, RectPreset preset, Vector2 position, Vector2 size, Font font, int fontSize, Color color, bool outline, Color outlineColor)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: 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)
			var (val, item) = CreateText(parent, name, text, preset.AnchorMin, preset.AnchorMax, position, size, font, fontSize, color, outline, outlineColor);
			ApplyPivot(val, preset.Pivot);
			return (go: val, text: item);
		}

		public static (GameObject go, Text text) CreateTextTopLeft(Transform parent, string name, string text, Vector2 position, Vector2 size, Font font, int fontSize, Color color, bool outline, Color outlineColor)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			return CreateText(parent, name, text, Presets.TopLeft, position, size, font, fontSize, color, outline, outlineColor);
		}

		public static (GameObject go, Text text) CreateTextTopCenter(Transform parent, string name, string text, Vector2 position, Vector2 size, Font font, int fontSize, Color color, bool outline, Color outlineColor)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			return CreateText(parent, name, text, Presets.TopCenter, position, size, font, fontSize, color, outline, outlineColor);
		}

		public static (GameObject go, Text text) CreateTextTopRight(Transform parent, string name, string text, Vector2 position, Vector2 size, Font font, int fontSize, Color color, bool outline, Color outlineColor)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			return CreateText(parent, name, text, Presets.TopRight, position, size, font, fontSize, color, outline, outlineColor);
		}

		public static (GameObject go, Text text) CreateText(Transform parent, string name, string text, Vector2 anchorMin, Vector2 anchorMax, Vector2 position, Vector2 size, Font font, int fontSize, Color color, bool outline, Color outlineColor)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: 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_001e: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = GUIManager.Instance.CreateText(text, parent, anchorMin, anchorMax, position, font, fontSize, color, outline, outlineColor, size.x, size.y, false);
			((Object)val).name = name;
			return (go: val, text: val.GetComponent<Text>());
		}

		public static (GameObject go, Button button, Text label) CreateButton(Transform parent, string name, string caption, RectPreset preset, Vector2 position, Vector2 size)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			var (val, item, item2) = CreateButton(parent, name, caption, preset.AnchorMin, preset.AnchorMax, position, size);
			ApplyPivot(val, preset.Pivot);
			return (go: val, button: item, label: item2);
		}

		public static (GameObject go, Button button, Text label) CreateButtonTopLeft(Transform parent, string name, string caption, Vector2 position, Vector2 size)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			return CreateButton(parent, name, caption, Presets.TopLeft, position, size);
		}

		public static (GameObject go, Button button, Text label) CreateButtonTopRight(Transform parent, string name, string caption, Vector2 position, Vector2 size)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			return CreateButton(parent, name, caption, Presets.TopRight, position, size);
		}

		public static (GameObject go, Button button, Text label) CreateButtonTopCenter(Transform parent, string name, string caption, Vector2 position, Vector2 size)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			return CreateButton(parent, name, caption, Presets.TopCenter, position, size);
		}

		public static (GameObject go, Button button, Text label) CreateButtonBottomCenter(Transform parent, string name, string caption, Vector2 position, Vector2 size)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			return CreateButton(parent, name, caption, Presets.BottomCenter, position, size);
		}

		public static (GameObject go, Button button, Text label) CreateButton(Transform parent, string name, string caption, Vector2 anchorMin, Vector2 anchorMax, Vector2 position, Vector2 size)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = GUIManager.Instance.CreateButton(caption, parent, anchorMin, anchorMax, position, size.x, size.y);
			((Object)val).name = name;
			Button item = val.GetComponent<Button>() ?? val.GetComponentInChildren<Button>(true);
			Text componentInChildren = val.GetComponentInChildren<Text>(true);
			return (go: val, button: item, label: componentInChildren);
		}

		public static (GameObject go, Image background, Text number) CreateNumberToken(Transform parent, string name, RectPreset preset, Vector2 position, float diameter, Color backgroundColor, Font font, int fontSize, Color textColor)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			//IL_0059: 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_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) });
			val.transform.SetParent(parent, false);
			SetRect((RectTransform)val.transform, preset, position, new Vector2(diameter, diameter));
			Image val2 = val.AddComponent<Image>();
			val2.sprite = GetCircleSprite();
			((Graphic)val2).color = backgroundColor;
			((Graphic)val2).raycastTarget = false;
			Text item = CreateText(val.transform, "Number", "", Presets.Center, Vector2.zero, new Vector2(diameter, diameter), font, fontSize, textColor, outline: true, Color.black).text;
			item.alignment = (TextAnchor)4;
			((Graphic)item).raycastTarget = false;
			return (go: val, background: val2, number: item);
		}

		public static RectTransform SetRectStretch(RectTransform rt, Vector2 offsetMin, Vector2 offsetMax)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			rt.anchorMin = Vector2.zero;
			rt.anchorMax = Vector2.one;
			rt.pivot = new Vector2(0.5f, 0.5f);
			rt.offsetMin = offsetMin;
			rt.offsetMax = offsetMax;
			return rt;
		}

		public static RectTransform SetStretchXTop(RectTransform rt, float left, float right, float top, float height)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			rt.anchorMin = new Vector2(0f, 1f);
			rt.anchorMax = new Vector2(1f, 1f);
			rt.pivot = new Vector2(0.5f, 1f);
			rt.offsetMin = new Vector2(left, 0f - (top + height));
			rt.offsetMax = new Vector2(0f - right, 0f - top);
			return rt;
		}

		public static RectTransform SetStretchYRight(RectTransform rt, float width, float marginRight, float marginTop, float marginBottom)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			rt.anchorMin = new Vector2(1f, 0f);
			rt.anchorMax = new Vector2(1f, 1f);
			rt.pivot = new Vector2(1f, 0.5f);
			rt.sizeDelta = new Vector2(width, 0f);
			rt.offsetMin = new Vector2(0f - (width + marginRight), marginBottom);
			rt.offsetMax = new Vector2(0f - marginRight, 0f - marginTop);
			return rt;
		}

		public static (GameObject go, Text text) CreateTextStretchXTop(Transform parent, string name, string text, float left, float right, float top, float height, Font font, int fontSize, Color color, bool outline, Color outlineColor, Vector2 dummySize)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: 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)
			var (val, item) = CreateText(parent, name, text, Presets.StretchXTop, Vector2.zero, dummySize, font, fontSize, color, outline, outlineColor);
			SetStretchXTop(val.GetComponent<RectTransform>(), left, right, top, height);
			return (go: val, text: item);
		}
	}
	internal sealed class UpdateLoopRunner : MonoBehaviour
	{
		public Action Tick;

		private void Update()
		{
			Tick?.Invoke();
		}
	}
	internal sealed class MouseWheelZoomToCursor : MonoBehaviour, IScrollHandler, IEventSystemHandler
	{
		private RectTransform _viewport;

		private RectTransform _content;

		public float MinScale { get; private set; }

		public float MaxScale { get; private set; }

		public float ZoomFactorPerStep { get; private set; }

		public float WheelDeadzone { get; private set; }

		public void Initialize(RectTransform viewport, RectTransform content, ScrollRect scrollRect = null, TalentUiLayout layout = null)
		{
			layout = layout ?? TalentUiLayout.Default;
			Initialize(viewport, content, scrollRect, layout.MinZoom, layout.MaxZoom, layout.ZoomFactorPerStep, layout.MouseWheelDeadzone);
		}

		public void Initialize(RectTransform viewport, RectTransform content, ScrollRect scrollRect, float minScale, float maxScale, float zoomFactorPerStep, float wheelDeadzone)
		{
			_viewport = viewport;
			_content = content;
			MinScale = minScale;
			MaxScale = maxScale;
			ZoomFactorPerStep = zoomFactorPerStep;
			WheelDeadzone = wheelDeadzone;
			if ((Object)(object)scrollRect != (Object)null)
			{
				scrollRect.scrollSensitivity = 0f;
			}
		}

		public void SetScale(float scale)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_content == (Object)null))
			{
				float num = Mathf.Clamp(scale, MinScale, MaxScale);
				((Transform)_content).localScale = new Vector3(num, num, 1f);
			}
		}

		public void OnScroll(PointerEventData eventData)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: 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)
			if ((Object)(object)_viewport == (Object)null || (Object)(object)_content == (Object)null)
			{
				return;
			}
			float y = eventData.scrollDelta.y;
			if (!(Mathf.Abs(y) < WheelDeadzone))
			{
				float x = ((Transform)_content).localScale.x;
				float num = ((y > 0f) ? (1f + ZoomFactorPerStep) : (1f - ZoomFactorPerStep));
				float num2 = Mathf.Clamp(x * num, MinScale, MaxScale);
				if (!Mathf.Approximately(num2, x))
				{
					Vector2 val = default(Vector2);
					RectTransformUtility.ScreenPointToLocalPointInRectangle(_viewport, eventData.position, eventData.pressEventCamera, ref val);
					float num3 = num2 / x;
					Vector2 anchoredPosition = val + (_content.anchoredPosition - val) * num3;
					((Transform)_content).localScale = new Vector3(num2, num2, 1f);
					_content.anchoredPosition = anchoredPosition;
				}
			}
		}
	}
	internal sealed class PanelClickCatcher : MonoBehaviour, IPointerClickHandler, IEventSystemHandler
	{
		public event Action Clicked;

		public void OnPointerClick(PointerEventData eventData)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Invalid comparison between Unknown and I4
			if ((int)eventData.button <= 0 && !((Object)(object)eventData.pointerPress != (Object)(object)((Component)this).gameObject))
			{
				this.Clicked?.Invoke();
			}
		}
	}
	public sealed class PolarGridConfig
	{
		public int Sectors = 6;

		public float InnerRadius;

		public float RingSpacing = 1200f;

		public float StartAngleDeg;
	}
	public static class PolarGrid
	{
		public const float FullCircleDeg = 360f;

		public static int Slots(PolarGridConfig cfg, int ring)
		{
			return 2 * Mathf.Max(1, cfg.Sectors) * Mathf.Max(1, ring);
		}

		public static int SlotsPerSector(int ring)
		{
			return 2 * Mathf.Max(1, ring);
		}

		public static int AnchorJ(int anchorMultiple, int ring)
		{
			return anchorMultiple * Mathf.Max(1, ring);
		}

		public static int SlotIndex(int sectorIndex, int ring, int j)
		{
			return sectorIndex * SlotsPerSector(ring) + j;
		}

		public static int NormalizeSlot(PolarGridConfig cfg, int ring, int slotIndex)
		{
			int num = Slots(cfg, ring);
			return (slotIndex % num + num) % num;
		}

		public static float Radius(PolarGridConfig cfg, int ring)
		{
			return cfg.InnerRadius + (float)Mathf.Max(1, ring) * cfg.RingSpacing;
		}

		public static float AngleDeg(PolarGridConfig cfg, int ring, int slotIndex)
		{
			return cfg.StartAngleDeg + (float)slotIndex * 360f / (float)Slots(cfg, Mathf.Max(1, ring)) - 90f;
		}

		public static float SlotAngleDeg(PolarGridConfig cfg, int sectorIndex, int ring, int j)
		{
			return AngleDeg(cfg, ring, SlotIndex(sectorIndex, ring, j));
		}

		public static float SectorSpanDeg(PolarGridConfig cfg)
		{
			return 360f / (float)Mathf.Max(1, cfg.Sectors);
		}

		public static float SectorMidDeg(PolarGridConfig cfg, int sectorIndex)
		{
			return cfg.StartAngleDeg + (float)sectorIndex * SectorSpanDeg(cfg) + SectorSpanDeg(cfg) * 0.5f - 90f;
		}

		public static float ArcSpacing(PolarGridConfig cfg, int ring)
		{
			return (float)Math.PI * 2f * Radius(cfg, ring) / (float)Slots(cfg, ring);
		}

		public static Vector2 ToPosition(float angleDeg, float radius)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			float num = angleDeg * ((float)Math.PI / 180f);
			return new Vector2(Mathf.Cos(num) * radius, Mathf.Sin(num) * radius);
		}
	}
	public struct SectorRingKey : IEquatable<SectorRingKey>
	{
		public string SectorId;

		public int Ring;

		public bool Equals(SectorRingKey other)
		{
			return SectorId == other.SectorId && Ring == other.Ring;
		}

		public override bool Equals(object obj)
		{
			return obj is SectorRingKey other && Equals(other);
		}

		public override int GetHashCode()
		{
			return ((SectorId?.GetHashCode() ?? 0) * 397) ^ Ring;
		}
	}
	public static class RadialLayout
	{
		public sealed class LayoutResult
		{
			public readonly Dictionary<string, Vector2> Positions = new Dictionary<string, Vector2>();

			public readonly Dictionary<string, float> SectorMidAngles = new Dictionary<string, float>();

			public float MaxRadius;
		}

		private struct PlacedNode
		{
			public int Slot;

			public float Size;

			public string Id;
		}

		public static Dictionary<SectorRingKey, List<TalentDefinition>> GroupBySectorRing(IEnumerable<TalentDefinition> defs)
		{
			Dictionary<SectorRingKey, List<TalentDefinition>> dictionary = new Dictionary<SectorRingKey, List<TalentDefinition>>();
			foreach (TalentDefinition def in defs)
			{
				SectorRingKey key = new SectorRingKey
				{
					SectorId = def.SectorId,
					Ring = def.Ring
				};
				if (!dictionary.TryGetValue(key, out var value))
				{
					value = (dictionary[key] = new List<TalentDefinition>());
				}
				value.Add(def);
			}
			return dictionary;
		}

		internal static float NodeSizeOf(TalentDefinition def, RadialLayoutParams p)
		{
			return def.Tier switch
			{
				NodeTier.Minor => p.MinorNodeSize, 
				NodeTier.Mid => p.MidNodeSize, 
				_ => p.NodeSize, 
			};
		}

		public static LayoutResult ComputePositionsNoOverlap(IEnumerable<TalentDefinition> defs, string[] sectorOrder, RadialLayoutParams p)
		{
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			LayoutResult layoutResult = new LayoutResult();
			if (defs == null || p == null)
			{
				return layoutResult;
			}
			string[] array = sectorOrder ?? Array.Empty<string>();
			if (array.Length == 0)
			{
				return layoutResult;
			}
			PolarGridConfig cfg = new PolarGridConfig
			{
				Sectors = array.Length,
				InnerRadius = p.InnerRadius,
				RingSpacing = p.RingSpacing,
				StartAngleDeg = p.SectorStartOffsetDeg
			};
			Dictionary<string, int> dictionary = new Dictionary<string, int>(array.Length);
			for (int i = 0; i < array.Length; i++)
			{
				dictionary[array[i]] = i;
				layoutResult.SectorMidAngles[array[i]] = PolarGrid.SectorMidDeg(cfg, i);
			}
			Dictionary<SectorRingKey, List<TalentDefinition>> dictionary2 = GroupBySectorRing(defs);
			Dictionary<int, List<PlacedNode>> dictionary3 = new Dictionary<int, List<PlacedNode>>();
			foreach (KeyValuePair<SectorRingKey, List<TalentDefinition>> item in dictionary2)
			{
				if (!dictionary.TryGetValue(item.Key.SectorId, out var value))
				{
					continue;
				}
				int ring = item.Key.Ring;
				float num = PolarGrid.Radius(cfg, ring);
				if (!dictionary3.TryGetValue(ring, out var value2))
				{
					value2 = (dictionary3[ring] = new List<PlacedNode>());
				}
				foreach (TalentDefinition item2 in item.Value)
				{
					int slot = SlotIndexFor(cfg, value, ring, item2);
					float angleDeg = PolarGrid.AngleDeg(cfg, ring, slot);
					float num2 = NodeSizeOf(item2, p);
					PlacedNode placedNode = value2.Find((PlacedNode n) => n.Slot == slot);
					if (placedNode.Id != null)
					{
						Logger.LogError((object)($"Ring {ring}: '{item2.Id}' and '{placedNode.Id}' resolve to the same " + $"slot {slot} and would render on top of each other."));
					}
					else
					{
						value2.Add(new PlacedNode
						{
							Slot = slot,
							Size = num2,
							Id = item2.Id
						});
					}
					layoutResult.Positions[item2.Id] = PolarGrid.ToPosition(angleDeg, num);
					layoutResult.MaxRadius = Mathf.Max(layoutResult.MaxRadius, num + num2 * 0.5f);
				}
			}
			WarnOnOverlap(cfg, dictionary3);
			return layoutResult;
		}

		private static int SlotIndexFor(PolarGridConfig cfg, int sectorIndex, int ring, TalentDefinition def)
		{
			int ring2 = Mathf.Max(1, ring);
			int num = PolarGrid.AnchorJ((int)def.Anchor, ring2) + def.Steps;
			if (num < -1 || num > PolarGrid.SlotsPerSector(ring2) + 1)
			{
				Logger.LogError((object)($"'{def.Id}' on ring {ring}: {def.Anchor} {def.Steps:+#;-#;0} lands on " + $"slot {num} of {PolarGrid.SlotsPerSector(ring2)}, outside its own sector. " + "Steps are half a node wide — a full lane is two."));
			}
			return PolarGrid.NormalizeSlot(cfg, ring2, PolarGrid.SlotIndex(sectorIndex, ring2, num));
		}

		private static void WarnOnOverlap(PolarGridConfig cfg, Dictionary<int, List<PlacedNode>> byRing)
		{
			foreach (KeyValuePair<int, List<PlacedNode>> item in byRing)
			{
				List<PlacedNode> value = item.Value;
				if (value.Count < 2)
				{
					continue;
				}
				value.Sort((PlacedNode a, PlacedNode b) => a.Slot.CompareTo(b.Slot));
				int num = PolarGrid.Slots(cfg, item.Key);
				for (int num2 = 0; num2 < value.Count; num2++)
				{
					PlacedNode placedNode = value[num2];
					PlacedNode placedNode2 = value[(num2 + 1) % value.Count];
					int num3 = ((num2 + 1 < value.Count) ? (placedNode2.Slot - placedNode.Slot) : (placedNode2.Slot + num - placedNode.Slot));
					if (num3 > 0)
					{
						float num4 = (placedNode.Size + placedNode2.Size) * 0.5f;
						float num5 = ChordBetween(cfg, item.Key, num3);
						if (!(num5 >= num4))
						{
							Logger.LogError((object)($"Ring {item.Key}: '{placedNode.Id}' and '{placedNode2.Id}' are {num5:F0} apart but " + $"need {num4:F0} for their sizes ({placedNode.Size:F0} and {placedNode2.Size:F0}) — " + "they overlap. Move one a full lane away, or give the pair a smaller tier."));
						}
					}
				}
			}
		}

		private static float ChordBetween(PolarGridConfig cfg, int ring, int steps)
		{
			float num = (float)Math.PI * (float)steps / (float)PolarGrid.Slots(cfg, ring);
			return 2f * PolarGrid.Radius(cfg, ring) * Mathf.Sin(num);
		}
	}
	public sealed class RadialLayoutParams
	{
		public float InnerRadius;

		public float RingSpacing;

		public float NodeSize;

		public float MinorNodeSize;

		public float MidNodeSize;

		public float NodePadding;

		public float SectorStartOffsetDeg;

		internal static RadialLayoutParams FromLayout(TalentUiLayout layout)
		{
			return new RadialLayoutParams
			{
				InnerRadius = layout.InnerRadius,
				RingSpacing = layout.RingSpacing,
				NodeSize = layout.NodeSize,
				MinorNodeSize = layout.MinorNodeSize,
				MidNodeSize = layout.MidNodeSize,
				NodePadding = layout.NodePadding,
				SectorStartOffsetDeg = layout.SectorStartOffsetDeg
			};
		}
	}
	internal sealed class TalentUiLayout
	{
		public float WindowScreenFillRatio = 0.85f;

		public Vector2 TitleOffset = new Vector2(0f, -30f);

		public Vector2 TitleSize = new Vector2(500f, 40f);

		public int TitleFontSize = 28;

		public Vector2 CloseButtonOffset = new Vector2(-20f, -20f);

		public Vector2 CloseButtonSize = new Vector2(40f, 40f);

		public Vector2 PointsTokenOffset = new Vector2(30f, -30f);

		public float Po