Decompiled source of EulersRuler v1.9.0

EulersRuler.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using ComfyLib;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("EulersRuler")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("EulersRuler")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("86a1824a-1bbe-404b-a4e3-f619d06ca938")]
[assembly: AssemblyFileVersion("1.9.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.9.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 EulersRuler
{
	public static class PanelUtils
	{
		public static readonly Gradient HealthPercentGradient = CreateHealthPercentGradient();

		public static readonly Gradient StabilityPercentGradient = CreateStabilityPercentGradient();

		public static void CreatePanels(Hud hud)
		{
			HoverPiecePanel.CreatePanel(hud);
			PlacementGhostPanel.CreatePanel(hud);
		}

		public static void TogglePanels(bool toggleOn)
		{
			HoverPiecePanel.DestroyPanel();
			PlacementGhostPanel.DestroyPanel();
			if (toggleOn && Object.op_Implicit((Object)(object)Hud.m_instance))
			{
				CreatePanels(Hud.m_instance);
			}
		}

		public static IEnumerator UpdatePropertiesCoroutine()
		{
			WaitForSeconds waitInterval = new WaitForSeconds(0.25f);
			while (true)
			{
				yield return waitInterval;
				if (PluginConfig.IsModEnabled.Value && Object.op_Implicit((Object)(object)Player.m_localPlayer))
				{
					HoverPiecePanel.UpdateProperties(Player.m_localPlayer.m_hoveringPiece, PluginConfig.HoverPiecePanelEnabledRows.Value);
					PlacementGhostPanel.UpdateProperties(Player.m_localPlayer.m_placementGhost, PluginConfig.PlacementGhostPanelEnabledRows.Value);
				}
			}
		}

		public static Gradient CreateHealthPercentGradient()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: 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_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: 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_00b8: Unknown result type (might be due to invalid IL or missing references)
			Gradient val = new Gradient();
			val.SetKeys((GradientColorKey[])(object)new GradientColorKey[3]
			{
				new GradientColorKey(new Color(0.937f, 0.325f, 0.314f, 1f), 0.25f),
				new GradientColorKey(new Color(1f, 0.933f, 0.345f, 1f), 0.5f),
				new GradientColorKey(new Color(0.612f, 0.8f, 0.396f, 1f), 1f)
			}, (GradientAlphaKey[])(object)new GradientAlphaKey[2]
			{
				new GradientAlphaKey(1f, 0f),
				new GradientAlphaKey(1f, 1f)
			});
			return val;
		}

		public static Gradient CreateStabilityPercentGradient()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: 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_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: 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_00b8: Unknown result type (might be due to invalid IL or missing references)
			Gradient val = new Gradient();
			val.SetKeys((GradientColorKey[])(object)new GradientColorKey[3]
			{
				new GradientColorKey(new Color(0.937f, 0.325f, 0.314f, 1f), 0.25f),
				new GradientColorKey(new Color(1f, 0.933f, 0.345f, 1f), 0.5f),
				new GradientColorKey(new Color(0.392f, 0.71f, 0.965f, 1f), 1f)
			}, (GradientAlphaKey[])(object)new GradientAlphaKey[2]
			{
				new GradientAlphaKey(1f, 0f),
				new GradientAlphaKey(1f, 1f)
			});
			return val;
		}
	}
	[BepInPlugin("redseiko.valheim.eulersruler", "EulersRuler", "1.9.0")]
	public sealed class EulersRuler : BaseUnityPlugin
	{
		public const string PluginGUID = "redseiko.valheim.eulersruler";

		public const string PluginName = "EulersRuler";

		public const string PluginVersion = "1.9.0";

		private void Awake()
		{
			PluginConfig.BindConfig(((BaseUnityPlugin)this).Config);
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "redseiko.valheim.eulersruler");
		}
	}
	public static class PluginConfig
	{
		[Flags]
		public enum HoverPiecePanelRow
		{
			None = 0,
			Name = 1,
			Health = 2,
			Stability = 4,
			Euler = 8,
			Quaternion = 0x10,
			PieceName = 0x20
		}

		[Flags]
		public enum PlacementGhostPanelRow
		{
			None = 0,
			Name = 1,
			Euler = 2,
			Quaternion = 4,
			PieceName = 0x20,
			Distance = 0x40,
			Position = 0x80
		}

		public static ConfigEntry<bool> IsModEnabled { get; private set; }

		public static ConfigEntry<Vector2> HoverPiecePanelPosition { get; private set; }

		public static ConfigEntry<HoverPiecePanelRow> HoverPiecePanelEnabledRows { get; private set; }

		public static ConfigEntry<int> HoverPiecePanelFontSize { get; private set; }

		public static ConfigEntry<bool> ShowHoverPieceHealthBar { get; private set; }

		public static ConfigEntry<Vector2> PlacementGhostPanelPosition { get; private set; }

		public static ConfigEntry<PlacementGhostPanelRow> PlacementGhostPanelEnabledRows { get; private set; }

		public static ConfigEntry<int> PlacementGhostPanelFontSize { get; private set; }

		public static void BindConfig(ConfigFile config)
		{
			//IL_005b: 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)
			IsModEnabled = config.BindInOrder("_Global", "isModEnabled", defaultValue: true, "Globally enable or disable this mod.");
			IsModEnabled.OnSettingChanged<bool>(PanelUtils.TogglePanels);
			HoverPiecePanelPosition = config.BindInOrder<Vector2>("HoverPiece.Panel", "hoverPiecePanelPosition", new Vector2(0f, 150f), "Position of the HoverPiece properties panel.");
			HoverPiecePanelPosition.OnSettingChanged((Action<Vector2>)HoverPiecePanel.SetPosition);
			HoverPiecePanelEnabledRows = config.BindInOrder("HoverPiece.Panel", "hoverPiecePanelEnabledRows", HoverPiecePanelRow.Name | HoverPiecePanelRow.Health | HoverPiecePanelRow.Stability, "Which rows to display on the HoverPiece properties panel.");
			HoverPiecePanelFontSize = config.BindInOrder("HoverPiece.Panel", "hoverPiecePanelFontSize", 18, "Font size for the HoverPiece properties panel.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(6, 32));
			HoverPiecePanelFontSize.OnSettingChanged<int>(HoverPiecePanel.SetFontSize);
			ShowHoverPieceHealthBar = config.BindInOrder("HoverPiece.HealthBar", "showHoverPieceHealthBar", defaultValue: true, "Show the vanilla hover piece HealthBar.");
			PlacementGhostPanelPosition = config.BindInOrder<Vector2>("PlacementGhost.Panel", "placementGhostPanelPosition", new Vector2(150f, 0f), "Position of the PlacementGhost properties panel.");
			PlacementGhostPanelPosition.OnSettingChanged((Action<Vector2>)PlacementGhostPanel.SetPosition);
			PlacementGhostPanelEnabledRows = config.BindInOrder("PlacementGhost.Panel", "placementGhostPanelEnabledRows", PlacementGhostPanelRow.Name | PlacementGhostPanelRow.Euler | PlacementGhostPanelRow.Quaternion, "Which rows to display on the PlacementGhost properties panel.");
			PlacementGhostPanelFontSize = config.BindInOrder("PlacementGhost.Panel", "placementGhostPanelFontSize", 18, "Font size for the PlacementGhost properties panel.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(6, 32));
			PlacementGhostPanelFontSize.OnSettingChanged<int>(PlacementGhostPanel.SetFontSize);
		}
	}
	[HarmonyPatch(typeof(Hud))]
	internal static class HudPatch
	{
		private static GameObject _pieceHealthRoot;

		private static GuiBar _pieceHealthBar;

		[HarmonyPostfix]
		[HarmonyPatch("Awake")]
		private static void AwakePostfix(ref Hud __instance)
		{
			if (PluginConfig.IsModEnabled.Value)
			{
				PanelUtils.CreatePanels(__instance);
			}
			_pieceHealthRoot = ((Component)__instance.m_pieceHealthRoot).gameObject;
			_pieceHealthBar = __instance.m_pieceHealthBar;
			((MonoBehaviour)__instance).StartCoroutine(PanelUtils.UpdatePropertiesCoroutine());
		}

		[HarmonyPostfix]
		[HarmonyPatch("UpdateCrosshair")]
		private static void UpdateCrosshairPostfix(Hud __instance)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			if (PluginConfig.IsModEnabled.Value && _pieceHealthRoot.activeSelf)
			{
				if (PluginConfig.ShowHoverPieceHealthBar.Value)
				{
					_pieceHealthBar.SetColor(PanelUtils.HealthPercentGradient.Evaluate(_pieceHealthBar.m_value));
				}
				else
				{
					_pieceHealthRoot.SetActive(false);
				}
			}
		}
	}
	public static class HoverPiecePanel
	{
		private static TwoColumnPanel _hoverPiecePanel;

		private static TMP_Text _pieceNameTextLabel;

		private static TMP_Text _pieceNameTextValue;

		private static TMP_Text _pieceHealthTextLabel;

		private static TMP_Text _pieceHealthTextValue;

		private static TMP_Text _pieceStabilityTextLabel;

		private static TMP_Text _pieceStabilityTextValue;

		private static TMP_Text _pieceEulerTextLabel;

		private static TMP_Text _pieceEulerTextValue;

		private static TMP_Text _pieceQuaternionTextLabel;

		private static TMP_Text _pieceQuaternionTextValue;

		public static void CreatePanel(Hud hud)
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			_hoverPiecePanel = new TwoColumnPanel(((Component)hud.m_crosshair).transform).AddPanelRow(out _pieceNameTextLabel, out _pieceNameTextValue).AddPanelRow(out _pieceHealthTextLabel, out _pieceHealthTextValue).AddPanelRow(out _pieceStabilityTextLabel, out _pieceStabilityTextValue)
				.AddPanelRow(out _pieceEulerTextLabel, out _pieceEulerTextValue)
				.AddPanelRow(out _pieceQuaternionTextLabel, out _pieceQuaternionTextValue)
				.SetPosition(PluginConfig.HoverPiecePanelPosition.Value)
				.SetAnchors(new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(0.5f, 0f))
				.SetFontSize(PluginConfig.HoverPiecePanelFontSize.Value);
			_pieceNameTextLabel.text = "Piece ◈";
			_pieceHealthTextLabel.text = "Health ♡";
			_pieceStabilityTextLabel.text = "Stability ☖";
			_pieceEulerTextLabel.text = "Euler ⦿";
			_pieceQuaternionTextLabel.text = "Quaternion ⌘";
		}

		public static void DestroyPanel()
		{
			_hoverPiecePanel?.DestroyPanel();
		}

		public static void SetPosition(Vector2 position)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			_hoverPiecePanel?.SetPosition(position);
		}

		public static void SetFontSize(int fontSize)
		{
			_hoverPiecePanel?.SetFontSize(fontSize);
		}

		public static void UpdateProperties(Piece piece, PluginConfig.HoverPiecePanelRow enabledRows)
		{
			if (Object.op_Implicit((Object)(object)_hoverPiecePanel?.Panel))
			{
				WearNTear wearNTear = default(WearNTear);
				if (!Object.op_Implicit((Object)(object)piece) || !Object.op_Implicit((Object)(object)piece.m_nview) || !piece.m_nview.IsValid() || !((Component)piece).TryGetComponent<WearNTear>(ref wearNTear))
				{
					_hoverPiecePanel?.SetActive(active: false);
					return;
				}
				_hoverPiecePanel.SetActive(active: true);
				UpdateHoverPieceNameRow(piece, enabledRows.HasFlag(PluginConfig.HoverPiecePanelRow.Name), enabledRows.HasFlag(PluginConfig.HoverPiecePanelRow.PieceName));
				UpdateHoverPieceHealthRow(wearNTear, enabledRows.HasFlag(PluginConfig.HoverPiecePanelRow.Health));
				UpdateHoverPieceStabilityRow(wearNTear, enabledRows.HasFlag(PluginConfig.HoverPiecePanelRow.Stability));
				UpdateHoverPieceEulerRow(wearNTear, enabledRows.HasFlag(PluginConfig.HoverPiecePanelRow.Euler));
				UpdateHoverPieceQuaternionRow(wearNTear, enabledRows.HasFlag(PluginConfig.HoverPiecePanelRow.Quaternion));
			}
		}

		private static void UpdateHoverPieceNameRow(Piece piece, bool isRowEnabled, bool isPieceNameEnabled)
		{
			((Component)_pieceNameTextLabel).gameObject.SetActive(isRowEnabled);
			((Component)_pieceNameTextValue).gameObject.SetActive(isRowEnabled);
			if (isRowEnabled)
			{
				_pieceNameTextValue.text = "<color=#FFCA28>" + Localization.instance.Localize(piece.m_name) + "</color>";
				if (isPieceNameEnabled)
				{
					TMP_Text pieceNameTextValue = _pieceNameTextValue;
					pieceNameTextValue.text = pieceNameTextValue.text + " (<color=#FFCA28>" + Utils.GetPrefabName(((Component)piece).gameObject) + "</color>)";
				}
			}
		}

		private static void UpdateHoverPieceHealthRow(WearNTear wearNTear, bool isRowEnabled)
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			((Component)_pieceHealthTextLabel).gameObject.SetActive(isRowEnabled);
			((Component)_pieceHealthTextValue).gameObject.SetActive(isRowEnabled);
			if (isRowEnabled)
			{
				float @float = wearNTear.m_nview.m_zdo.GetFloat(ZDOVars.s_health, wearNTear.m_health);
				float num = Mathf.Clamp01(@float / wearNTear.m_health);
				_pieceHealthTextValue.text = string.Format("<color=#{0}>{1}</color> /<color={2}>{3}</color> (<color=#{0}>{4:0%}</color>)", ColorUtility.ToHtmlStringRGB(PanelUtils.HealthPercentGradient.Evaluate(num)), ((double)Mathf.Abs(@float) > 1000000000.0) ? @float.ToString("G5") : @float.ToString("N0"), "#FAFAFA", wearNTear.m_health, num);
			}
		}

		private static void UpdateHoverPieceStabilityRow(WearNTear wearNTear, bool isRowEnabled)
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			((Component)_pieceStabilityTextLabel).gameObject.SetActive(isRowEnabled);
			((Component)_pieceStabilityTextValue).gameObject.SetActive(isRowEnabled);
			if (isRowEnabled)
			{
				float support = wearNTear.GetSupport();
				float maxSupport = wearNTear.GetMaxSupport();
				float num = Mathf.Clamp01(support / maxSupport);
				_pieceStabilityTextValue.text = string.Format("<color=#{0}>{1:N0}</color> /<color={2}>{3}</color> (<color=#{0}>{4:0%}</color>)", ColorUtility.ToHtmlStringRGB(PanelUtils.StabilityPercentGradient.Evaluate(num)), support, "#FAFAFA", maxSupport, num);
			}
		}

		private static void UpdateHoverPieceEulerRow(WearNTear wearNTear, bool isRowEnabled)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			((Component)_pieceEulerTextLabel).gameObject.SetActive(isRowEnabled);
			((Component)_pieceEulerTextValue).gameObject.SetActive(isRowEnabled);
			if (isRowEnabled)
			{
				TMP_Text pieceEulerTextValue = _pieceEulerTextValue;
				Quaternion rotation = ((Component)wearNTear).transform.rotation;
				pieceEulerTextValue.text = $"<color=#CFD8DC>{((Quaternion)(ref rotation)).eulerAngles}</color>";
			}
		}

		private static void UpdateHoverPieceQuaternionRow(WearNTear wearNTear, bool isRowEnabled)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			((Component)_pieceQuaternionTextLabel).gameObject.SetActive(isRowEnabled);
			((Component)_pieceQuaternionTextValue).gameObject.SetActive(isRowEnabled);
			if (isRowEnabled)
			{
				_pieceQuaternionTextValue.text = $"<color=#D7CCC8>{((Component)wearNTear).transform.rotation:N2}</color>";
			}
		}
	}
	public static class PlacementGhostPanel
	{
		private static TwoColumnPanel _placementGhostPanel;

		private static PluginConfig.PlacementGhostPanelRow _lastEnabledRows;

		public static TwoColumnPanel.LabelRow GhostNameRow { get; private set; }

		public static TwoColumnPanel.LabelRow GhostEulerRow { get; private set; }

		public static TwoColumnPanel.LabelRow GhostQuaternionRow { get; private set; }

		public static TwoColumnPanel.LabelRow GhostDistanceRow { get; private set; }

		public static void CreatePanel(Hud hud)
		{
			//IL_0051: 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_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			_placementGhostPanel = new TwoColumnPanel(((Component)hud.m_crosshair).transform);
			GhostNameRow = _placementGhostPanel.AddLabelRow();
			((TMP_Text)GhostNameRow.LeftLabel).text = "Placing ▥";
			((Graphic)GhostNameRow.RightLabel).color = new Color(1f, 0.79f, 0.15f);
			GhostEulerRow = _placementGhostPanel.AddLabelRow();
			((TMP_Text)GhostEulerRow.LeftLabel).text = "Euler ⦿";
			((Graphic)GhostEulerRow.RightLabel).color = new Color(0.81f, 0.84f, 0.86f);
			GhostQuaternionRow = _placementGhostPanel.AddLabelRow();
			((TMP_Text)GhostQuaternionRow.LeftLabel).text = "Quaternion ⌘";
			((Graphic)GhostQuaternionRow.RightLabel).color = new Color(0.84f, 0.8f, 0.78f);
			GhostDistanceRow = _placementGhostPanel.AddLabelRow();
			((TMP_Text)GhostDistanceRow.LeftLabel).text = "Distance ➡";
			((Graphic)GhostDistanceRow.RightLabel).color = new Color(1f, 0.79f, 0.15f);
			_placementGhostPanel.SetPosition(PluginConfig.PlacementGhostPanelPosition.Value).SetAnchors(new Vector2(0f, 0.5f), new Vector2(0f, 0.5f), new Vector2(0f, 0.5f)).SetFontSize(PluginConfig.PlacementGhostPanelFontSize.Value);
		}

		public static void DestroyPanel()
		{
			_placementGhostPanel?.DestroyPanel();
		}

		public static void SetPosition(Vector2 position)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			_placementGhostPanel?.SetPosition(position);
		}

		public static void SetFontSize(int fontSize)
		{
			_placementGhostPanel?.SetFontSize(fontSize);
		}

		public static void UpdateProperties(GameObject placementGhost, PluginConfig.PlacementGhostPanelRow enabledRows)
		{
			if (Object.op_Implicit((Object)(object)_placementGhostPanel?.Panel))
			{
				Piece piece = default(Piece);
				if (!Object.op_Implicit((Object)(object)placementGhost) || enabledRows == PluginConfig.PlacementGhostPanelRow.None || !placementGhost.TryGetComponent<Piece>(ref piece))
				{
					_placementGhostPanel.SetActive(active: false);
					return;
				}
				_placementGhostPanel.SetActive(active: true);
				SetupGhostRows(enabledRows);
				UpdateGhostRows(placementGhost, piece, enabledRows);
			}
		}

		private static void SetupGhostRows(PluginConfig.PlacementGhostPanelRow enabledRows)
		{
			if (enabledRows != _lastEnabledRows)
			{
				GhostNameRow.SetActive(enabledRows.HasFlag(PluginConfig.PlacementGhostPanelRow.Name));
				GhostEulerRow.SetActive(enabledRows.HasFlag(PluginConfig.PlacementGhostPanelRow.Euler));
				GhostQuaternionRow.SetActive(enabledRows.HasFlag(PluginConfig.PlacementGhostPanelRow.Quaternion));
				GhostDistanceRow.SetActive(enabledRows.HasFlag(PluginConfig.PlacementGhostPanelRow.Distance));
				_lastEnabledRows = enabledRows;
			}
		}

		private static void UpdateGhostRows(GameObject placementGhost, Piece piece, PluginConfig.PlacementGhostPanelRow enabledRows)
		{
			if (enabledRows.HasFlag(PluginConfig.PlacementGhostPanelRow.Name))
			{
				UpdateGhostNameRow(piece, enabledRows.HasFlag(PluginConfig.PlacementGhostPanelRow.PieceName));
			}
			if (enabledRows.HasFlag(PluginConfig.PlacementGhostPanelRow.Euler))
			{
				UpdateGhostEulerRow(placementGhost);
			}
			if (enabledRows.HasFlag(PluginConfig.PlacementGhostPanelRow.Quaternion))
			{
				UpdateGhostQuaternionRow(placementGhost);
			}
			if (enabledRows.HasFlag(PluginConfig.PlacementGhostPanelRow.Distance))
			{
				UpdateGhostDistanceRow(placementGhost, enabledRows.HasFlag(PluginConfig.PlacementGhostPanelRow.Position));
			}
		}

		private static void UpdateGhostNameRow(Piece piece, bool showPrefabName)
		{
			if (showPrefabName)
			{
				((TMP_Text)GhostNameRow.RightLabel).text = Localization.instance.Localize(piece.m_name) + " (" + Utils.GetPrefabName(((Component)piece).gameObject) + ")";
			}
			else
			{
				((TMP_Text)GhostNameRow.RightLabel).text = Localization.instance.Localize(piece.m_name);
			}
		}

		private static void UpdateGhostEulerRow(GameObject placementGhost)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			TextMeshProUGUI rightLabel = GhostEulerRow.RightLabel;
			Quaternion rotation = placementGhost.transform.rotation;
			Vector3 eulerAngles = ((Quaternion)(ref rotation)).eulerAngles;
			((TMP_Text)rightLabel).text = ((object)(Vector3)(ref eulerAngles)).ToString();
		}

		private static void UpdateGhostQuaternionRow(GameObject placementGhost)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			TextMeshProUGUI rightLabel = GhostQuaternionRow.RightLabel;
			Quaternion rotation = placementGhost.transform.rotation;
			((TMP_Text)rightLabel).text = ((Quaternion)(ref rotation)).ToString("N2");
		}

		private static void UpdateGhostDistanceRow(GameObject placementGhost, bool showPosition)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			float num = (Object.op_Implicit((Object)(object)Player.m_localPlayer) ? Vector3.Distance(((Component)Player.m_localPlayer).transform.position, placementGhost.transform.position) : 0f);
			if (showPosition)
			{
				((TMP_Text)GhostDistanceRow.RightLabel).text = $"{num:N2} • {placementGhost.transform.position:F0}";
			}
			else
			{
				((TMP_Text)GhostDistanceRow.RightLabel).text = num.ToString("N2");
			}
		}
	}
	public class TwoColumnPanel
	{
		public sealed class LabelRow
		{
			public TextMeshProUGUI LeftLabel { get; }

			public TextMeshProUGUI RightLabel { get; }

			public LabelRow(Transform leftParentTransform, Transform rightParentTransform)
			{
				LeftLabel = UIBuilder.CreateTMPLabel(leftParentTransform);
				((Object)LeftLabel).name = "LeftLabel";
				RightLabel = UIBuilder.CreateTMPLabel(rightParentTransform);
				((Object)RightLabel).name = "RightLabel";
			}

			public void SetActive(bool active)
			{
				((Component)LeftLabel).gameObject.SetActive(active);
				((Component)RightLabel).gameObject.SetActive(active);
			}
		}

		private int _textFontSize = 18;

		private GameObject _leftColumn;

		private GameObject _rightColumn;

		public GameObject Panel { get; private set; }

		internal TwoColumnPanel(Transform parent)
		{
			CreatePanel(parent);
		}

		internal void DestroyPanel()
		{
			Object.Destroy((Object)(object)Panel);
		}

		internal void SetActive(bool active)
		{
			if (Object.op_Implicit((Object)(object)Panel) && Panel.activeSelf != active)
			{
				Panel.SetActive(active);
			}
		}

		internal TwoColumnPanel SetPosition(Vector2 position)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			Panel.GetComponent<RectTransform>().anchoredPosition = position;
			return this;
		}

		internal TwoColumnPanel SetAnchors(Vector2 anchorMin, Vector2 anchorMax, Vector2 pivot)
		{
			//IL_000c: 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_0019: Unknown result type (might be due to invalid IL or missing references)
			RectTransform component = Panel.GetComponent<RectTransform>();
			component.anchorMin = anchorMin;
			component.anchorMax = anchorMax;
			component.pivot = pivot;
			return this;
		}

		public TwoColumnPanel SetFontSize(int fontSize)
		{
			_textFontSize = fontSize;
			TMP_Text[] componentsInChildren = Panel.GetComponentsInChildren<TMP_Text>();
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				SetFontSize(componentsInChildren[i], fontSize);
			}
			return this;
		}

		private static void SetFontSize(TMP_Text label, int fontSize)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			label.fontSize = fontSize;
			label.rectTransform.sizeDelta = label.GetPreferredValues("123") + new Vector2(0f, 4f);
		}

		private void CreatePanel(Transform parent)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_0040: 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_00a2: Expected O, but got Unknown
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Expected O, but got Unknown
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			Panel = new GameObject("TwoColumnPanel", new Type[1] { typeof(RectTransform) });
			Panel.transform.SetParent(parent, false);
			Panel.GetComponent<RectTransform>().SetSizeDelta(Vector2.zero);
			Panel.AddComponent<HorizontalLayoutGroup>().SetSpacing<HorizontalLayoutGroup>(6f).SetChildAlignment<HorizontalLayoutGroup>((TextAnchor)1);
			Panel.AddComponent<ContentSizeFitter>().SetHorizontalFit((FitMode)2).SetVerticalFit((FitMode)2);
			_leftColumn = new GameObject("LeftColumn", new Type[1] { typeof(RectTransform) });
			_leftColumn.transform.SetParent(Panel.transform, false);
			_leftColumn.GetComponent<RectTransform>().SetSizeDelta(Vector2.zero);
			_leftColumn.AddComponent<VerticalLayoutGroup>().SetChildControl<VerticalLayoutGroup>((bool?)true, (bool?)false).SetChildForceExpand<VerticalLayoutGroup>((bool?)true, (bool?)false)
				.SetChildAlignment<VerticalLayoutGroup>((TextAnchor)3)
				.SetSpacing<VerticalLayoutGroup>(6f);
			_leftColumn.AddComponent<ContentSizeFitter>().SetHorizontalFit((FitMode)2).SetVerticalFit((FitMode)2);
			_rightColumn = new GameObject("RightColumn", new Type[1] { typeof(RectTransform) });
			_rightColumn.transform.SetParent(Panel.transform, false);
			_rightColumn.GetComponent<RectTransform>().SetSizeDelta(Vector2.zero);
			_rightColumn.AddComponent<VerticalLayoutGroup>().SetChildControl<VerticalLayoutGroup>((bool?)true, (bool?)false).SetChildForceExpand<VerticalLayoutGroup>((bool?)true, (bool?)false)
				.SetChildAlignment<VerticalLayoutGroup>((TextAnchor)3)
				.SetSpacing<VerticalLayoutGroup>(6f);
			_rightColumn.AddComponent<ContentSizeFitter>().SetHorizontalFit((FitMode)2).SetVerticalFit((FitMode)2);
		}

		public TwoColumnPanel AddPanelRow(out TMP_Text leftText, out TMP_Text rightText)
		{
			leftText = (TMP_Text)(object)UIBuilder.CreateTMPLabel(_leftColumn.transform);
			((Object)leftText).name = "LeftText";
			leftText.alignment = (TextAlignmentOptions)516;
			SetFontSize(leftText, _textFontSize);
			rightText = (TMP_Text)(object)UIBuilder.CreateTMPLabel(_rightColumn.transform);
			((Object)rightText).name = "RightText";
			rightText.alignment = (TextAlignmentOptions)513;
			SetFontSize(rightText, _textFontSize);
			return this;
		}

		public LabelRow AddLabelRow()
		{
			LabelRow labelRow = new LabelRow(_leftColumn.transform, _rightColumn.transform);
			((TMP_Text)labelRow.LeftLabel).alignment = (TextAlignmentOptions)516;
			SetFontSize((TMP_Text)(object)labelRow.LeftLabel, _textFontSize);
			((TMP_Text)labelRow.RightLabel).alignment = (TextAlignmentOptions)513;
			SetFontSize((TMP_Text)(object)labelRow.RightLabel, _textFontSize);
			return labelRow;
		}
	}
}
namespace ComfyLib
{
	public static class ObjectExtensions
	{
		public static T FirstByNameOrThrow<T>(this IEnumerable<T> unityObjects, string name) where T : Object
		{
			foreach (T unityObject in unityObjects)
			{
				if (((Object)unityObject).name == name)
				{
					return unityObject;
				}
			}
			throw new InvalidOperationException($"Could not find Unity object of type {typeof(T)} with name: {name}");
		}

		public static T Ref<T>(this T unityObject) where T : Object
		{
			if (!Object.op_Implicit((Object)(object)unityObject))
			{
				return default(T);
			}
			return unityObject;
		}
	}
	public static class ConfigFileExtensions
	{
		internal sealed class ConfigurationManagerAttributes
		{
			public Action<ConfigEntryBase> CustomDrawer;

			public bool? Browsable;

			public bool? HideDefaultButton;

			public bool? HideSettingName;

			public bool? IsAdvanced;

			public int? Order;

			public bool? ReadOnly;
		}

		private static readonly Dictionary<string, int> _sectionToSettingOrder = new Dictionary<string, int>();

		private static int GetSettingOrder(string section)
		{
			if (!_sectionToSettingOrder.TryGetValue(section, out var value))
			{
				value = 0;
			}
			_sectionToSettingOrder[section] = value - 1;
			return value;
		}

		public static ConfigEntry<T> BindInOrder<T>(this ConfigFile config, string section, string key, T defaultValue, string description, AcceptableValueBase acceptableValues, bool browsable = true, bool hideDefaultButton = false, bool hideSettingName = false, bool isAdvanced = false, bool readOnly = false)
		{
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Expected O, but got Unknown
			return config.Bind<T>(section, key, defaultValue, new ConfigDescription(description, acceptableValues, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Browsable = browsable,
					CustomDrawer = null,
					HideDefaultButton = hideDefaultButton,
					HideSettingName = hideSettingName,
					IsAdvanced = isAdvanced,
					Order = GetSettingOrder(section),
					ReadOnly = readOnly
				}
			}));
		}

		public static ConfigEntry<T> BindInOrder<T>(this ConfigFile config, string section, string key, T defaultValue, string description, Action<ConfigEntryBase> customDrawer = null, bool browsable = true, bool hideDefaultButton = false, bool hideSettingName = false, bool isAdvanced = false, bool readOnly = false)
		{
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Expected O, but got Unknown
			return config.Bind<T>(section, key, defaultValue, new ConfigDescription(description, (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Browsable = browsable,
					CustomDrawer = customDrawer,
					HideDefaultButton = hideDefaultButton,
					HideSettingName = hideSettingName,
					IsAdvanced = isAdvanced,
					Order = GetSettingOrder(section),
					ReadOnly = readOnly
				}
			}));
		}

		public static void OnSettingChanged<T>(this ConfigEntry<T> configEntry, Action settingChangedHandler)
		{
			configEntry.SettingChanged += delegate
			{
				settingChangedHandler();
			};
		}

		public static void OnSettingChanged<T>(this ConfigEntry<T> configEntry, Action<T> settingChangedHandler)
		{
			configEntry.SettingChanged += delegate(object _, EventArgs eventArgs)
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				settingChangedHandler((T)((SettingChangedEventArgs)eventArgs).ChangedSetting.BoxedValue);
			};
		}

		public static void OnSettingChanged<T>(this ConfigEntry<T> configEntry, Action<ConfigEntry<T>> settingChangedHandler)
		{
			configEntry.SettingChanged += delegate(object _, EventArgs eventArgs)
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				settingChangedHandler((ConfigEntry<T>)((SettingChangedEventArgs)eventArgs).ChangedSetting.BoxedValue);
			};
		}
	}
	public static class UIBuilder
	{
		public static TextMeshProUGUI CreateTMPLabel(Transform parentTransform)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			TextMeshProUGUI obj = Object.Instantiate<TextMeshProUGUI>(UnifiedPopup.instance.bodyText, parentTransform, false);
			((Object)obj).name = "Label";
			((TMP_Text)obj).fontSize = 16f;
			((TMP_Text)obj).richText = true;
			((Graphic)obj).color = Color.white;
			((TMP_Text)obj).enableAutoSizing = false;
			((TMP_Text)obj).textWrappingMode = (TextWrappingModes)0;
			((TMP_Text)obj).overflowMode = (TextOverflowModes)0;
			((TMP_Text)obj).text = string.Empty;
			return obj;
		}
	}
	public static class CanvasGroupExtensions
	{
		public static CanvasGroup SetAlpha(this CanvasGroup canvasGroup, float alpha)
		{
			canvasGroup.alpha = alpha;
			return canvasGroup;
		}

		public static CanvasGroup SetBlocksRaycasts(this CanvasGroup canvasGroup, bool blocksRaycasts)
		{
			canvasGroup.blocksRaycasts = blocksRaycasts;
			return canvasGroup;
		}
	}
	public static class ColorExtensions
	{
		public static Color SetAlpha(this Color color, float alpha)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			color.a = alpha;
			return color;
		}
	}
	public static class ContentSizeFitterExtensions
	{
		public static ContentSizeFitter SetHorizontalFit(this ContentSizeFitter fitter, FitMode fitMode)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			fitter.horizontalFit = fitMode;
			return fitter;
		}

		public static ContentSizeFitter SetVerticalFit(this ContentSizeFitter fitter, FitMode fitMode)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			fitter.verticalFit = fitMode;
			return fitter;
		}
	}
	public static class LayoutGroupExtensions
	{
		public static T SetChildAlignment<T>(this T layoutGroup, TextAnchor alignment) where T : HorizontalOrVerticalLayoutGroup
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((LayoutGroup)(object)layoutGroup).childAlignment = alignment;
			return layoutGroup;
		}

		public static T SetChildControl<T>(this T layoutGroup, bool? width = null, bool? height = null) where T : HorizontalOrVerticalLayoutGroup
		{
			if (!width.HasValue && !height.HasValue)
			{
				throw new ArgumentException("Value for width or height must be provided.");
			}
			if (width.HasValue)
			{
				((HorizontalOrVerticalLayoutGroup)layoutGroup).childControlWidth = width.Value;
			}
			if (height.HasValue)
			{
				((HorizontalOrVerticalLayoutGroup)layoutGroup).childControlHeight = height.Value;
			}
			return layoutGroup;
		}

		public static T SetChildForceExpand<T>(this T layoutGroup, bool? width = null, bool? height = null) where T : HorizontalOrVerticalLayoutGroup
		{
			if (!width.HasValue && !height.HasValue)
			{
				throw new ArgumentException("Value for width or height must be provided.");
			}
			if (width.HasValue)
			{
				((HorizontalOrVerticalLayoutGroup)layoutGroup).childForceExpandWidth = width.Value;
			}
			if (height.HasValue)
			{
				((HorizontalOrVerticalLayoutGroup)layoutGroup).childForceExpandHeight = height.Value;
			}
			return layoutGroup;
		}

		public static T SetPadding<T>(this T layoutGroup, int? left = null, int? right = null, int? top = null, int? bottom = null) where T : HorizontalOrVerticalLayoutGroup
		{
			if (!left.HasValue && !right.HasValue && !top.HasValue && !bottom.HasValue)
			{
				throw new ArgumentException("Value for left, right, top or bottom must be provided.");
			}
			if (left.HasValue)
			{
				((LayoutGroup)(object)layoutGroup).padding.left = left.Value;
			}
			if (right.HasValue)
			{
				((LayoutGroup)(object)layoutGroup).padding.right = right.Value;
			}
			if (top.HasValue)
			{
				((LayoutGroup)(object)layoutGroup).padding.top = top.Value;
			}
			if (bottom.HasValue)
			{
				((LayoutGroup)(object)layoutGroup).padding.bottom = bottom.Value;
			}
			return layoutGroup;
		}

		public static T SetSpacing<T>(this T layoutGroup, float spacing) where T : HorizontalOrVerticalLayoutGroup
		{
			((HorizontalOrVerticalLayoutGroup)layoutGroup).spacing = spacing;
			return layoutGroup;
		}
	}
	public static class ImageExtensions
	{
		public static Image SetColor(this Image image, Color color)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			((Graphic)image).color = color;
			return image;
		}

		public static Image SetFillAmount(this Image image, float amount)
		{
			image.fillAmount = amount;
			return image;
		}

		public static Image SetFillCenter(this Image image, bool fillCenter)
		{
			image.fillCenter = fillCenter;
			return image;
		}

		public static Image SetFillMethod(this Image image, FillMethod fillMethod)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			image.fillMethod = fillMethod;
			return image;
		}

		public static Image SetFillOrigin(this Image image, OriginHorizontal origin)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected I4, but got Unknown
			image.fillOrigin = (int)origin;
			return image;
		}

		public static Image SetFillOrigin(this Image image, OriginVertical origin)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected I4, but got Unknown
			image.fillOrigin = (int)origin;
			return image;
		}

		public static Image SetMaskable(this Image image, bool maskable)
		{
			((MaskableGraphic)image).maskable = maskable;
			return image;
		}

		public static Image SetMaterial(this Image image, Material material)
		{
			((Graphic)image).material = material;
			return image;
		}

		public static Image SetPixelsPerUnitMultiplier(this Image image, float pixelsPerUnitMultiplier)
		{
			image.pixelsPerUnitMultiplier = pixelsPerUnitMultiplier;
			return image;
		}

		public static Image SetPreserveAspect(this Image image, bool preserveAspect)
		{
			image.preserveAspect = preserveAspect;
			return image;
		}

		public static Image SetRaycastTarget(this Image image, bool raycastTarget)
		{
			((Graphic)image).raycastTarget = raycastTarget;
			return image;
		}

		public static Image SetSprite(this Image image, Sprite sprite)
		{
			image.sprite = sprite;
			return image;
		}

		public static Image SetType(this Image image, Type type)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			image.type = type;
			return image;
		}
	}
	public static class LayoutElementExtensions
	{
		public static LayoutElement SetFlexible(this LayoutElement layoutElement, float? width = null, float? height = null)
		{
			if (!width.HasValue && !height.HasValue)
			{
				throw new ArgumentException("Value for width or height must be provided.");
			}
			if (width.HasValue)
			{
				layoutElement.flexibleWidth = width.Value;
			}
			if (height.HasValue)
			{
				layoutElement.flexibleHeight = height.Value;
			}
			return layoutElement;
		}

		public static LayoutElement SetIgnoreLayout(this LayoutElement layoutElement, bool ignoreLayout)
		{
			layoutElement.ignoreLayout = ignoreLayout;
			return layoutElement;
		}

		public static LayoutElement SetMinimum(this LayoutElement layoutElement, float? width = null, float? height = null)
		{
			if (!width.HasValue && !height.HasValue)
			{
				throw new ArgumentException("Value for width or height must be provided.");
			}
			if (width.HasValue)
			{
				layoutElement.minWidth = width.Value;
			}
			if (height.HasValue)
			{
				layoutElement.minHeight = height.Value;
			}
			return layoutElement;
		}

		public static LayoutElement SetPreferred(this LayoutElement layoutElement, float? width = null, float? height = null)
		{
			if (!width.HasValue && !height.HasValue)
			{
				throw new ArgumentException("Value for width or height must be provided.");
			}
			if (width.HasValue)
			{
				layoutElement.preferredWidth = width.Value;
			}
			if (height.HasValue)
			{
				layoutElement.preferredHeight = height.Value;
			}
			return layoutElement;
		}
	}
	public static class RectMask2DExtensions
	{
		public static RectMask2D SetSoftness(this RectMask2D rectMask2d, Vector2Int softness)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			rectMask2d.softness = softness;
			return rectMask2d;
		}
	}
	public static class RectTransformExtensions
	{
		public static RectTransform SetAnchorMin(this RectTransform rectTransform, Vector2 anchorMin)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			rectTransform.anchorMin = anchorMin;
			return rectTransform;
		}

		public static RectTransform SetAnchorMax(this RectTransform rectTransform, Vector2 anchorMax)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			rectTransform.anchorMax = anchorMax;
			return rectTransform;
		}

		public static RectTransform SetPivot(this RectTransform rectTransform, Vector2 pivot)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			rectTransform.pivot = pivot;
			return rectTransform;
		}

		public static RectTransform SetPosition(this RectTransform rectTransform, Vector2 position)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			rectTransform.anchoredPosition = position;
			return rectTransform;
		}

		public static RectTransform SetSizeDelta(this RectTransform rectTransform, Vector2 sizeDelta)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			rectTransform.sizeDelta = sizeDelta;
			return rectTransform;
		}
	}
	public static class ScrollbarExtensions
	{
		public static T SetDirection<T>(this T scrollbar, Direction direction) where T : Scrollbar
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((Scrollbar)scrollbar).direction = direction;
			return scrollbar;
		}

		public static T SetHandleRect<T>(this T scrollbar, RectTransform handleRect) where T : Scrollbar
		{
			((Scrollbar)scrollbar).handleRect = handleRect;
			return scrollbar;
		}
	}
	public static class SelectableExtensions
	{
		public static T SetColors<T>(this T selectable, ColorBlock colors) where T : Selectable
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((Selectable)selectable).colors = colors;
			return selectable;
		}

		public static T SetImage<T>(this T selectable, Image image) where T : Selectable
		{
			((Selectable)selectable).image = image;
			return selectable;
		}

		public static T SetInteractable<T>(this T selectable, bool interactable) where T : Selectable
		{
			((Selectable)selectable).interactable = interactable;
			return selectable;
		}

		public static T SetSpriteState<T>(this T selectable, SpriteState spriteState) where T : Selectable
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((Selectable)selectable).spriteState = spriteState;
			return selectable;
		}

		public static T SetTargetGraphic<T>(this T selectable, Graphic graphic) where T : Selectable
		{
			((Selectable)selectable).targetGraphic = graphic;
			return selectable;
		}

		public static T SetTransition<T>(this T selectable, Transition transition) where T : Selectable
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((Selectable)selectable).transition = transition;
			return selectable;
		}

		public static T SetNavigationMode<T>(this T selectable, Mode mode) where T : Selectable
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: 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)
			Navigation navigation = ((Selectable)selectable).navigation;
			((Navigation)(ref navigation)).mode = mode;
			((Selectable)selectable).navigation = navigation;
			return selectable;
		}
	}
	public static class SliderExtensions
	{
		public static T SetDirection<T>(this T slider, Direction direction) where T : Slider
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((Slider)slider).direction = direction;
			return slider;
		}

		public static T SetFillRect<T>(this T slider, RectTransform fillRect) where T : Slider
		{
			((Slider)slider).fillRect = fillRect;
			return slider;
		}

		public static T SetHandleRect<T>(this T slider, RectTransform handleRect) where T : Slider
		{
			((Slider)slider).handleRect = handleRect;
			return slider;
		}

		public static T SetMaxValue<T>(this T slider, float maxValue) where T : Slider
		{
			((Slider)slider).maxValue = maxValue;
			return slider;
		}

		public static T SetMinValue<T>(this T slider, float minValue) where T : Slider
		{
			((Slider)slider).minValue = minValue;
			return slider;
		}

		public static T SetWholeNumbers<T>(this T slider, bool wholeNumbers) where T : Slider
		{
			((Slider)slider).wholeNumbers = wholeNumbers;
			return slider;
		}
	}
	public static class ScrollRectExtensions
	{
		public static T SetContent<T>(this T scrollRect, RectTransform content) where T : ScrollRect
		{
			((ScrollRect)scrollRect).content = content;
			return scrollRect;
		}

		public static T SetHorizontal<T>(this T scrollRect, bool horizontal) where T : ScrollRect
		{
			((ScrollRect)scrollRect).horizontal = horizontal;
			return scrollRect;
		}

		public static T SetMovementType<T>(this T scrollRect, MovementType movementType) where T : ScrollRect
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((ScrollRect)scrollRect).movementType = movementType;
			return scrollRect;
		}

		public static T SetScrollSensitivity<T>(this T scrollRect, float sensitivity) where T : ScrollRect
		{
			((ScrollRect)scrollRect).scrollSensitivity = sensitivity;
			return scrollRect;
		}

		public static T SetVertical<T>(this T scrollRect, bool vertical) where T : ScrollRect
		{
			((ScrollRect)scrollRect).vertical = vertical;
			return scrollRect;
		}

		public static T SetVerticalScrollbar<T>(this T scrollRect, Scrollbar verticalScrollbar) where T : ScrollRect
		{
			((ScrollRect)scrollRect).verticalScrollbar = verticalScrollbar;
			return scrollRect;
		}

		public static T SetVerticalScrollPosition<T>(this T scrollRect, float position) where T : ScrollRect
		{
			((ScrollRect)scrollRect).verticalNormalizedPosition = position;
			return scrollRect;
		}

		public static T SetVerticalScrollbarVisibility<T>(this T scrollRect, ScrollbarVisibility visibility) where T : ScrollRect
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((ScrollRect)scrollRect).verticalScrollbarVisibility = visibility;
			return scrollRect;
		}

		public static T SetViewport<T>(this T scrollRect, RectTransform viewport) where T : ScrollRect
		{
			((ScrollRect)scrollRect).viewport = viewport;
			return scrollRect;
		}
	}
	public static class TextMeshProExtensions
	{
		public static T SetAlignment<T>(this T tmpText, TextAlignmentOptions alignment) where T : TMP_Text
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((TMP_Text)tmpText).alignment = alignment;
			return tmpText;
		}

		public static T SetColor<T>(this T tmpText, Color color) where T : TMP_Text
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((Graphic)(object)tmpText).color = color;
			return tmpText;
		}

		public static T SetEnableAutoSizing<T>(this T tmpText, bool enableAutoSizing) where T : TMP_Text
		{
			((TMP_Text)tmpText).enableAutoSizing = enableAutoSizing;
			return tmpText;
		}

		public static T SetFont<T>(this T tmpText, TMP_FontAsset font) where T : TMP_Text
		{
			((TMP_Text)tmpText).font = font;
			return tmpText;
		}

		public static T SetFontSize<T>(this T tmpText, float fontSize) where T : TMP_Text
		{
			((TMP_Text)tmpText).fontSize = fontSize;
			return tmpText;
		}

		public static T SetFontMaterial<T>(this T tmpText, Material fontMaterial) where T : TMP_Text
		{
			((TMP_Text)tmpText).fontMaterial = fontMaterial;
			return tmpText;
		}

		public static T SetMargin<T>(this T tmpText, Vector4 margin) where T : TMP_Text
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((TMP_Text)tmpText).margin = margin;
			return tmpText;
		}

		public static T SetOverflowMode<T>(this T tmpText, TextOverflowModes overflowMode) where T : TMP_Text
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((TMP_Text)tmpText).overflowMode = overflowMode;
			return tmpText;
		}

		public static T SetRichText<T>(this T tmpText, bool richText) where T : TMP_Text
		{
			((TMP_Text)tmpText).richText = richText;
			return tmpText;
		}

		public static T SetTextWrappingMode<T>(this T tmpText, TextWrappingModes textWrappingMode) where T : TMP_Text
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((TMP_Text)tmpText).textWrappingMode = textWrappingMode;
			return tmpText;
		}
	}
	public static class Texture2DExtensions
	{
		public static Texture2D SetFilterMode(this Texture2D texture, FilterMode filterMode)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			((Texture)texture).filterMode = filterMode;
			return texture;
		}

		public static Texture2D SetWrapMode(this Texture2D texture, TextureWrapMode wrapMode)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			((Texture)texture).wrapMode = wrapMode;
			return texture;
		}
	}
	public static class ToggleExtensions
	{
		public static T SetGraphic<T>(this T toggle, Graphic graphic) where T : Toggle
		{
			((Toggle)toggle).graphic = graphic;
			return toggle;
		}

		public static T SetToggleTransition<T>(this T toggle, ToggleTransition toggleTransition) where T : Toggle
		{
			//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)
			((Toggle)toggle).toggleTransition = toggleTransition;
			return toggle;
		}
	}
	public static class UIResources
	{
		public static readonly ResourceCache<Sprite> SpriteCache = new ResourceCache<Sprite>();

		public static readonly ResourceCache<Material> MaterialCache = new ResourceCache<Material>();

		public static Sprite GetSprite(string spriteName)
		{
			return SpriteCache.GetResource(spriteName);
		}

		public static Material GetMaterial(string materialName)
		{
			return MaterialCache.GetResource(materialName);
		}
	}
	public sealed class ResourceCache<T> where T : Object
	{
		private readonly Dictionary<string, T> _cache = new Dictionary<string, T>();

		public T GetResource(string resourceName)
		{
			if (!_cache.TryGetValue(resourceName, out var value))
			{
				value = Resources.FindObjectsOfTypeAll<T>().FirstByNameOrThrow(resourceName);
				_cache[resourceName] = value;
			}
			return value;
		}
	}
}