Decompiled source of ZoneScouter v1.6.0

ZoneScouter.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
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.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("ZoneScouter")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ZoneScouter")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("185751b7-5cae-480a-8e9c-d8ec87ce481f")]
[assembly: AssemblyFileVersion("1.6.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.6.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 ZoneScouter
{
	public static class SectorInfoPanelController
	{
		private static readonly Dictionary<Vector2i, int> SectorToIndexCache = new Dictionary<Vector2i, int>();

		private static Coroutine _updateSectorInfoPanelCoroutine;

		private static Coroutine _updateSectorZdoCountGridCoroutine;

		public static SectorInfoPanel SectorInfoPanel { get; private set; }

		public static SectorZdoCountGrid SectorZdoCountGrid { get; private set; }

		public static void ToggleSectorInfoPanel()
		{
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			if (_updateSectorInfoPanelCoroutine != null)
			{
				((MonoBehaviour)Hud.m_instance.Ref<Hud>()).StopCoroutine(_updateSectorInfoPanelCoroutine);
				_updateSectorInfoPanelCoroutine = null;
			}
			if (Object.op_Implicit((Object)(object)SectorInfoPanel?.Panel))
			{
				Object.Destroy((Object)(object)SectorInfoPanel.Panel);
				SectorInfoPanel = null;
			}
			if (PluginConfig.IsModEnabled.Value && PluginConfig.ShowSectorInfoPanel.Value && Object.op_Implicit((Object)(object)Hud.m_instance))
			{
				SectorInfoPanel = new SectorInfoPanel(((Component)Hud.m_instance).transform);
				((Transform)SectorInfoPanel.Panel.RectTransform().SetAnchorMin(new Vector2(0.5f, 1f)).SetAnchorMax(new Vector2(0.5f, 1f))
					.SetPivot(new Vector2(0.5f, 1f))
					.SetPosition(PluginConfig.SectorInfoPanelPosition.Value)
					.SetSizeDelta(new Vector2(200f, 200f))).SetAsFirstSibling();
				SectorInfoPanel.PanelDragger.OnPanelEndDrag += OnSectorInfoPanelEndDrag;
				SectorInfoPanel.Panel.SetActive(true);
				_updateSectorInfoPanelCoroutine = ((MonoBehaviour)Hud.m_instance).StartCoroutine(UpdateSectorInfoPanelCoroutine());
			}
			ToggleSectorZdoCountGrid();
		}

		public static void OnSectorInfoPanelEndDrag(object sender, Vector3 position)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			PluginConfig.SectorInfoPanelPosition.Value = Vector2.op_Implicit(position);
		}

		public static void ToggleSectorZdoCountGrid()
		{
			if (_updateSectorZdoCountGridCoroutine != null && Object.op_Implicit((Object)(object)Hud.m_instance))
			{
				((MonoBehaviour)Hud.m_instance).StopCoroutine(_updateSectorZdoCountGridCoroutine);
				_updateSectorZdoCountGridCoroutine = null;
			}
			if (Object.op_Implicit((Object)(object)SectorZdoCountGrid?.Grid))
			{
				Object.Destroy((Object)(object)SectorZdoCountGrid.Grid);
				SectorZdoCountGrid = null;
			}
			if (PluginConfig.IsModEnabled.Value && PluginConfig.ShowSectorInfoPanel.Value && PluginConfig.ShowSectorZdoCountGrid.Value && Object.op_Implicit((Object)(object)SectorInfoPanel?.Panel))
			{
				SectorZdoCountGrid = new SectorZdoCountGrid(SectorInfoPanel.Panel.transform, PluginConfig.SectorZdoCountGridSize.Value);
				SectorZdoCountGrid.Grid.SetActive(true);
				_updateSectorZdoCountGridCoroutine = ((MonoBehaviour)Hud.m_instance).StartCoroutine(UpdateSectorZdoCountGrid());
			}
		}

		private static long GetSectorZdoCount(Vector2i sector)
		{
			//IL_0005: 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_0020: Unknown result type (might be due to invalid IL or missing references)
			if (!SectorToIndexCache.TryGetValue(sector, out var value))
			{
				value = ZDOMan.s_instance.SectorToIndex(sector);
				SectorToIndexCache[sector] = value;
			}
			if (value < 0)
			{
				return 0L;
			}
			return ZDOMan.s_instance.m_objectsBySector[value]?.Count ?? 0;
		}

		private static IEnumerator UpdateSectorInfoPanelCoroutine()
		{
			WaitForSeconds waitInterval = new WaitForSeconds(0.25f);
			Vector3 lastPosition = Vector3.positiveInfinity;
			Vector2i lastSector = new Vector2i(int.MinValue, int.MaxValue);
			long lastZdoCount = long.MaxValue;
			uint lastNextUid = uint.MaxValue;
			while (true)
			{
				yield return waitInterval;
				if (Object.op_Implicit((Object)(object)ZoneSystem.m_instance) && Object.op_Implicit((Object)(object)Player.m_localPlayer) && Object.op_Implicit((Object)(object)SectorInfoPanel?.Panel))
				{
					uint nextUid = ZDOMan.s_instance.m_nextUid;
					if (nextUid != lastNextUid)
					{
						SectorInfoPanel.ZdoManagerNextId.Value.SetText($"{nextUid:D}");
						lastNextUid = nextUid;
					}
					Vector3 position = ((Component)Player.m_localPlayer).transform.position;
					if (position != lastPosition)
					{
						lastPosition = position;
						SectorInfoPanel.PositionX.Value.SetText($"{position.x:F0}");
						SectorInfoPanel.PositionY.Value.SetText($"{position.y:F0}");
						SectorInfoPanel.PositionZ.Value.SetText($"{position.z:F0}");
					}
					Vector2i zone = ZoneSystemUtils.GetZone(position);
					long sectorZdoCount = GetSectorZdoCount(zone);
					if (!(zone == lastSector) || sectorZdoCount != lastZdoCount)
					{
						lastSector = zone;
						lastZdoCount = sectorZdoCount;
						SectorInfoPanel.SectorXY.Value.SetText($"{zone.x},{zone.y}");
						SectorInfoPanel.SectorZdoCount.Value.SetText($"{sectorZdoCount}");
					}
				}
			}
		}

		private static IEnumerator UpdateSectorZdoCountGrid()
		{
			if (!Object.op_Implicit((Object)(object)SectorZdoCountGrid?.Grid))
			{
				yield break;
			}
			WaitForSeconds waitInterval = new WaitForSeconds(1f);
			int size = SectorZdoCountGrid.Size;
			int offset = Mathf.FloorToInt((float)size / 2f);
			Vector2i val = default(Vector2i);
			while (Object.op_Implicit((Object)(object)SectorZdoCountGrid?.Grid))
			{
				if (!Object.op_Implicit((Object)(object)Player.m_localPlayer))
				{
					yield return waitInterval;
					continue;
				}
				Vector2i zone = ZoneSystemUtils.GetZone(((Component)Player.m_localPlayer).transform.position);
				for (int i = 0; i < size; i++)
				{
					for (int j = 0; j < size; j++)
					{
						((Vector2i)(ref val))..ctor(zone.x + i - offset, zone.y - j + offset);
						SectorZdoCountCell sectorZdoCountCell = SectorZdoCountGrid.Cells[j, i];
						sectorZdoCountCell.ZdoCount.SetText($"{GetSectorZdoCount(val)}");
						sectorZdoCountCell.Sector.SetText($"{val.x},{val.y}");
					}
				}
				yield return waitInterval;
			}
		}
	}
	public static class ZoneSystemUtils
	{
		private static Func<ZoneSystem, Vector3, Vector2i> _getZoneFunc;

		private static Func<Vector3, Vector2i> _getZoneStaticFunc;

		private static Func<ZoneSystem, Vector2i, Vector3> _getZonePosFunc;

		private static Func<Vector2i, Vector3> _getZonePosStaticFunc;

		private static MethodInfo _getZoneMethod;

		private static MethodInfo _getZonePosMethod;

		public static Vector2i GetZone(Vector3 point)
		{
			//IL_0022: 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_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			if (_getZoneMethod.IsStatic)
			{
				return _getZoneStaticFunc(point);
			}
			return _getZoneFunc(ZoneSystem.m_instance, point);
		}

		public static Vector3 GetZonePos(Vector2i zoneId)
		{
			//IL_0022: 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_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			if (_getZonePosMethod.IsStatic)
			{
				return _getZonePosStaticFunc(zoneId);
			}
			return _getZonePosFunc(ZoneSystem.m_instance, zoneId);
		}

		public static void SetupUtils()
		{
			_getZoneMethod = AccessTools.Method(typeof(ZoneSystem), "GetZone", new Type[1] { typeof(Vector3) }, (Type[])null);
			if (_getZoneMethod.IsStatic)
			{
				_getZoneStaticFunc = (Func<Vector3, Vector2i>)Delegate.CreateDelegate(typeof(Func<Vector3, Vector2i>), _getZoneMethod);
			}
			else
			{
				_getZoneFunc = (Func<ZoneSystem, Vector3, Vector2i>)Delegate.CreateDelegate(typeof(Func<ZoneSystem, Vector3, Vector2i>), _getZoneMethod);
			}
			_getZonePosMethod = AccessTools.Method(typeof(ZoneSystem), "GetZonePos", new Type[1] { typeof(Vector2i) }, (Type[])null);
			if (_getZonePosMethod.IsStatic)
			{
				_getZonePosStaticFunc = (Func<Vector2i, Vector3>)Delegate.CreateDelegate(typeof(Func<Vector2i, Vector3>), _getZonePosMethod);
			}
			else
			{
				_getZonePosFunc = (Func<ZoneSystem, Vector2i, Vector3>)Delegate.CreateDelegate(typeof(Func<ZoneSystem, Vector2i, Vector3>), _getZonePosMethod);
			}
		}
	}
	[HarmonyPatch(typeof(Hud))]
	internal static class HudPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("Awake")]
		private static void AwakePostfix()
		{
			if (PluginConfig.IsModEnabled.Value)
			{
				SectorInfoPanelController.ToggleSectorInfoPanel();
				SectorBoundaries.ToggleSectorBoundaries();
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("Update")]
		private static void UpdatePostfix()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			if (PluginConfig.IsModEnabled.Value)
			{
				KeyboardShortcut value = PluginConfig.ToggleSectorBoundariesShortcut.Value;
				if (((KeyboardShortcut)(ref value)).IsDown())
				{
					PluginConfig.ShowSectorBoundaries.Value = !PluginConfig.ShowSectorBoundaries.Value;
				}
			}
		}
	}
	[HarmonyPatch(typeof(Menu))]
	internal static class MenuPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("Start")]
		private static void StartPostfix(ref Menu __instance)
		{
			if (!PluginConfig.IsModEnabled.Value)
			{
				return;
			}
			Image val = default(Image);
			foreach (GameObject item in ((Component)__instance.m_menuDialog).gameObject.Children())
			{
				if (((Object)item).name.StartsWith("darken") && item.TryGetComponent<Image>(ref val))
				{
					((Graphic)val).raycastTarget = false;
				}
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("Show")]
		private static void ShowPostfix()
		{
			if (PluginConfig.IsModEnabled.Value)
			{
				SectorInfoPanelController.SectorInfoPanel?.ToggleCopyButtons(toggleOn: true);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("Hide")]
		private static void HidePostfix()
		{
			if (PluginConfig.IsModEnabled.Value)
			{
				SectorInfoPanelController.SectorInfoPanel?.ToggleCopyButtons(toggleOn: false);
			}
		}
	}
	public static class PluginConfig
	{
		public enum GridSize
		{
			ThreeByThree = 3,
			FiveByFive = 5
		}

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

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

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

		public static ConfigEntry<Color> SectorInfoPanelBackgroundColor { get; private set; }

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

		public static ConfigEntry<Color> PositionValueXTextColor { get; private set; }

		public static ConfigEntry<Color> PositionValueYTextColor { get; private set; }

		public static ConfigEntry<Color> PositionValueZTextColor { get; private set; }

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

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

		public static ConfigEntry<GridSize> SectorZdoCountGridSize { get; private set; }

		public static ConfigEntry<Color> CellZdoCountBackgroundImageColor { get; private set; }

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

		public static ConfigEntry<Color> CellZdoCountTextColor { get; private set; }

		public static ConfigEntry<Color> CellSectorBackgroundImageColor { get; private set; }

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

		public static ConfigEntry<Color> CellSectorTextColor { get; private set; }

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

		public static ConfigEntry<Color> SectorBoundaryColor { get; private set; }

		public static ConfigEntry<KeyboardShortcut> ToggleSectorBoundariesShortcut { get; private set; }

		public static void BindConfig(ConfigFile config)
		{
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_043d: Unknown result type (might be due to invalid IL or missing references)
			//IL_049b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0547: Unknown result type (might be due to invalid IL or missing references)
			//IL_05eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_063b: 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>(SectorInfoPanelController.ToggleSectorInfoPanel);
			IsModEnabled.OnSettingChanged<bool>(SectorBoundaries.ToggleSectorBoundaries);
			ShowSectorInfoPanel = config.BindInOrder("SectorInfoPanel", "showSectorInfoPanel", defaultValue: true, "Show the SectorInfoPanel on the Hud.");
			ShowSectorInfoPanel.OnSettingChanged<bool>(SectorInfoPanelController.ToggleSectorInfoPanel);
			SectorInfoPanelPosition = config.BindInOrder<Vector2>("SectorInfoPanel", "sectorInfoPanelPosition", new Vector2(0f, -25f), "SectorInfoPanel position (relative to pivot/anchors).");
			SectorInfoPanelPosition.OnSettingChanged(delegate(Vector2 position)
			{
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				SectorInfoPanelController.SectorInfoPanel?.Panel.Ref<GameObject>()?.RectTransform().SetPosition(position);
			});
			SectorInfoPanelBackgroundColor = config.BindInOrder<Color>("SectorInfoPanel", "sectorInfoPanelBackgroundColor", new Color(0f, 0f, 0f, 0.9f), "SectorInfoPanel background color.");
			SectorInfoPanelBackgroundColor.OnSettingChanged(delegate(Color color)
			{
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				SectorInfoPanelController.SectorInfoPanel?.Panel.Ref<GameObject>()?.Image().SetColor(color);
			});
			SectorInfoPanelFontSize = config.BindInOrder("SectorInfoPanel.Font", "sectorInfoPanelFontSize", 16, "SectorInfoPanel font size.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(2, 64));
			SectorInfoPanelFontSize.OnSettingChanged<int>(SetSectorInfoPanelStyle);
			PositionValueXTextColor = config.BindInOrder<Color>("SectorInfoPanel.PositionRow", "positionValueXTextColor", new Color(1f, 0.878f, 0.51f), "SectorInfoPanel.PositionRow.X value text color.");
			PositionValueXTextColor.OnSettingChanged<Color>(SetSectorInfoPanelStyle);
			PositionValueYTextColor = config.BindInOrder<Color>("SectorInfoPanel.PositionRow", "positionValueYTextColor", new Color(0.565f, 0.792f, 0.976f), "SectorInfoPanel.PositionRow.Y value text color.");
			PositionValueYTextColor.OnSettingChanged<Color>(SetSectorInfoPanelStyle);
			PositionValueZTextColor = config.BindInOrder<Color>("SectorInfoPanel.PositionRow", "positionValueZTextColor", new Color(0.647f, 0.839f, 0.655f), "SectorInfoPanel.PositionRow.Z value text color.");
			PositionValueZTextColor.OnSettingChanged<Color>(SetSectorInfoPanelStyle);
			ShowZDOManagerContent = config.BindInOrder("SectorInfoPanel.ZDOManagerContent", "showZDOManagerContent", defaultValue: false, "Show SectorInfoPanel.ZDOManager content.");
			ShowZDOManagerContent.OnSettingChanged(delegate(bool toggleOn)
			{
				SectorInfoPanelController.SectorInfoPanel?.ToggleZDOManagerContent(toggleOn);
			});
			ShowSectorZdoCountGrid = config.BindInOrder("SectorZdoCountGrid", "showSectorZdoCountGrid", defaultValue: false, "Show the SectorZdoCount grid in the SectorInfo panel.");
			ShowSectorZdoCountGrid.OnSettingChanged<bool>(SectorInfoPanelController.ToggleSectorZdoCountGrid);
			SectorZdoCountGridSize = config.BindInOrder("SectorZdoCountGrid", "sectorZdoCountGridSize", GridSize.ThreeByThree, "Size of the SectorZdoCount grid.");
			SectorZdoCountGridSize.OnSettingChanged<GridSize>(SectorInfoPanelController.ToggleSectorZdoCountGrid);
			CellZdoCountBackgroundImageColor = config.BindInOrder<Color>("SectorZdoCountGrid", "cellZdoCountBackgroundImageColor", Color.clear, "SectorZdoCountCell.ZdoCount.Background.Image color.");
			CellZdoCountBackgroundImageColor.OnSettingChanged<Color>(SetSectorZDOCountGridCellStyle);
			CellZdoCountTextFontSize = config.BindInOrder("SectorZdoCountGrid", "cellZdoCountTextFontSize", 16, "SectorZdoCountCell.ZdoCount.Text font size.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(2, 64));
			CellZdoCountTextFontSize.OnSettingChanged<int>(SetSectorZDOCountGridCellStyle);
			CellZdoCountTextColor = config.BindInOrder<Color>("SectorZdoCountGrid", "cellZdoCountTextColor", Color.white, "SectorZdoCountCell.ZdoCount.Text color.");
			CellZdoCountTextColor.OnSettingChanged<Color>(SetSectorZDOCountGridCellStyle);
			CellSectorBackgroundImageColor = config.BindInOrder<Color>("SectorZdoCountGrid", "cellSectorBackgroundImageColor", new Color(0.5f, 0.5f, 0.5f, 0.5f), "SectorZdoCountCell.Sector.Background.Image color.");
			CellSectorBackgroundImageColor.OnSettingChanged<Color>(SetSectorZDOCountGridCellStyle);
			CellSectorTextFontSize = config.BindInOrder("SectorZdoCountGrid", "cellSectorTextFontSize", 16, "SectorZdoCountCell.Sector.Text font size.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(2, 64));
			CellSectorTextFontSize.OnSettingChanged<int>(SetSectorZDOCountGridCellStyle);
			CellSectorTextColor = config.BindInOrder<Color>("SectorZdoCountGrid", "cellSectorTextColor", new Color(0.9f, 0.9f, 0.9f, 1f), "SectorZdoCountCell.Sector.Text color.");
			CellSectorTextColor.OnSettingChanged<Color>(SetSectorZDOCountGridCellStyle);
			ShowSectorBoundaries = config.BindInOrder("SectorBoundary", "showSectorBoundaries", defaultValue: false, "Shows sector boundaries using semi-transparent walls at each boundary.");
			ShowSectorBoundaries.OnSettingChanged<bool>(SectorBoundaries.ToggleSectorBoundaries);
			SectorBoundaryColor = config.BindInOrder<Color>("SectorBoundary", "sectorBoundaryColor", new Color(1f, 0f, 1f, 1f), "Color to use for the sector boundary walls.");
			SectorBoundaryColor.OnSettingChanged((Action<Color>)SectorBoundaries.SetBoundaryColor);
			ToggleSectorBoundariesShortcut = config.BindInOrder<KeyboardShortcut>("SectorBoundary", "toggleSectorBoundariesShortcut", new KeyboardShortcut((KeyCode)0, Array.Empty<KeyCode>()), "Shortcut to toggle on/off sector boundaries.");
			static void SetSectorInfoPanelStyle()
			{
				SectorInfoPanelController.SectorInfoPanel?.SetPanelStyle();
			}
			static void SetSectorZDOCountGridCellStyle()
			{
				SectorInfoPanelController.SectorZdoCountGrid?.SetCellStyle();
			}
		}
	}
	public static class SectorBoundaries
	{
		private static readonly Lazy<Shader> DistortionShader = new Lazy<Shader>((Func<Shader>)(() => Shader.Find("Custom/Distortion")));

		private static readonly Vector2i UnsetSector = new Vector2i(int.MaxValue, int.MaxValue);

		private static Coroutine _updateBoundaryCubeCoroutine;

		private static Vector2i _lastBoundarySector = UnsetSector;

		private static GameObject _boundaryCube;

		private static readonly List<MeshRenderer> _boundaryWallRendererCache = new List<MeshRenderer>();

		public static void ToggleSectorBoundaries()
		{
			TearDown();
			StartUp();
		}

		public static void SetBoundaryColor(Color targetColor)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			if (!PluginConfig.IsModEnabled.Value || !Object.op_Implicit((Object)(object)_boundaryCube))
			{
				return;
			}
			foreach (MeshRenderer item in _boundaryWallRendererCache)
			{
				((Renderer)item).material.SetColor("_Color", targetColor);
			}
		}

		private static void TearDown()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			if (_updateBoundaryCubeCoroutine != null && Object.op_Implicit((Object)(object)Hud.m_instance))
			{
				((MonoBehaviour)Hud.m_instance).StopCoroutine(_updateBoundaryCubeCoroutine);
			}
			_updateBoundaryCubeCoroutine = null;
			_lastBoundarySector = UnsetSector;
			if (Object.op_Implicit((Object)(object)_boundaryCube))
			{
				Object.Destroy((Object)(object)_boundaryCube);
			}
			_boundaryCube = null;
			_boundaryWallRendererCache.Clear();
		}

		private static void StartUp()
		{
			if (PluginConfig.IsModEnabled.Value && PluginConfig.ShowSectorBoundaries.Value && Object.op_Implicit((Object)(object)Hud.m_instance))
			{
				_boundaryCube = CreateBoundaryCube();
				_boundaryWallRendererCache.AddRange(from child in _boundaryCube.Children()
					select child.GetComponent<MeshRenderer>());
				_updateBoundaryCubeCoroutine = ((MonoBehaviour)Hud.m_instance).StartCoroutine(UpdateBoundaryCubeCoroutine());
			}
		}

		private static IEnumerator UpdateBoundaryCubeCoroutine()
		{
			WaitForSeconds waitInterval = new WaitForSeconds(1f);
			while (true)
			{
				if (!Object.op_Implicit((Object)(object)ZoneSystem.m_instance) || !Object.op_Implicit((Object)(object)Player.m_localPlayer))
				{
					_lastBoundarySector = UnsetSector;
					yield return waitInterval;
					continue;
				}
				Vector2i zone = ZoneSystemUtils.GetZone(((Component)Player.m_localPlayer).transform.position);
				if (zone != _lastBoundarySector)
				{
					_boundaryCube.transform.position = ZoneSystemUtils.GetZonePos(zone);
					_lastBoundarySector = zone;
				}
				yield return waitInterval;
			}
		}

		private static GameObject CreateBoundaryCube()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: 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_002a: 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_0048: Expected O, but got Unknown
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: 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_00a6: Expected O, but got Unknown
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Expected O, but got Unknown
			//IL_00d7: Expected O, but got Unknown
			GameObject val = new GameObject("BoundaryCube");
			val.transform.position = Vector3.zero;
			CreateBoundaryCubeWall(val, new Vector3(32f, 256f, 0f), new Vector3(0.1f, 512f, 64f));
			CreateBoundaryCubeWall(val, new Vector3(-32f, 256f, 0f), new Vector3(0.1f, 512f, 64f));
			CreateBoundaryCubeWall(val, new Vector3(0f, 256f, 32f), new Vector3(64f, 512f, 0.1f));
			CreateBoundaryCubeWall(val, new Vector3(0f, 256f, -32f), new Vector3(64f, 512f, 0.1f));
			return val;
		}

		private static GameObject CreateBoundaryCubeWall(GameObject cube, Vector3 position, Vector3 scale)
		{
			//IL_0029: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = GameObject.CreatePrimitive((PrimitiveType)3);
			((Object)obj).name = "BoundaryCube.Wall";
			obj.transform.SetParent(cube.transform, false);
			obj.transform.localPosition = position;
			obj.transform.localScale = scale;
			MeshRenderer component = obj.GetComponent<MeshRenderer>();
			((Renderer)component).material.SetColor("_Color", PluginConfig.SectorBoundaryColor.Value);
			((Renderer)component).material.shader = DistortionShader.Value;
			Object.Destroy((Object)(object)obj.GetComponentInChildren<Collider>());
			return obj;
		}
	}
	public sealed class ButtonCell
	{
		private static readonly Lazy<ColorBlock> _buttonColorBlock = new Lazy<ColorBlock>((Func<ColorBlock>)delegate
		{
			//IL_0002: 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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			ColorBlock result = default(ColorBlock);
			((ColorBlock)(ref result)).normalColor = new Color(0f, 0f, 0f, 0.3f);
			((ColorBlock)(ref result)).highlightedColor = new Color(0.565f, 0.792f, 0.976f, 0.3f);
			((ColorBlock)(ref result)).disabledColor = new Color(0.5f, 0.5f, 0.5f, 0.3f);
			((ColorBlock)(ref result)).pressedColor = new Color(1f, 0.878f, 0.51f, 0.3f);
			((ColorBlock)(ref result)).selectedColor = new Color(0.647f, 0.839f, 0.655f, 0.3f);
			((ColorBlock)(ref result)).colorMultiplier = 1f;
			((ColorBlock)(ref result)).fadeDuration = 0.1f;
			return result;
		});

		public GameObject Cell { get; private set; }

		public Image Background { get; private set; }

		public TMP_Text Label { get; private set; }

		public Button Button { get; private set; }

		public ButtonCell(Transform parentTransform)
		{
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			Cell = CreateChildCell(parentTransform);
			Background = CreateChildBackground(Cell.transform).Image();
			Label = CreateChildLabel(((Component)Background).transform);
			Button = Cell.AddComponent<Button>();
			((Selectable)(object)Button).SetNavigationMode((Mode)0).SetTargetGraphic((Graphic)(object)Background).SetColors(_buttonColorBlock.Value);
		}

		private GameObject CreateChildCell(Transform parentTransform)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Expected O, but got Unknown
			GameObject val = new GameObject("Cell", new Type[1] { typeof(RectTransform) });
			GameObjectExtensions.SetParent(val, parentTransform);
			val.AddComponent<VerticalLayoutGroup>().SetChildControl(true, true).SetChildForceExpand(false, false)
				.SetSpacing(0f)
				.SetChildAlignment((TextAnchor)4);
			val.AddComponent<ContentSizeFitter>().SetHorizontalFit((FitMode)0).SetVerticalFit((FitMode)2);
			return val;
		}

		private GameObject CreateChildBackground(Transform parentTransform)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Expected O, but got Unknown
			GameObject val = new GameObject("Background", new Type[1] { typeof(RectTransform) });
			GameObjectExtensions.SetParent(val, parentTransform);
			val.AddComponent<HorizontalLayoutGroup>().SetChildControl(true, true).SetChildForceExpand(false, false)
				.SetPadding(4, 4, 2, 2)
				.SetChildAlignment((TextAnchor)4);
			val.AddComponent<Image>().SetType((Type)1).SetSprite(UIBuilder.CreateRoundedCornerSprite(200, 200, 5))
				.SetColor(Color.white);
			return val;
		}

		private TMP_Text CreateChildLabel(Transform parentTransform)
		{
			TMP_Text obj = UIBuilder.CreateTMPLabel(parentTransform);
			((Object)obj).name = "Label";
			obj.SetAlignment<TMP_Text>((TextAlignmentOptions)514).SetText("Button");
			((Component)obj).gameObject.AddComponent<LayoutElement>().SetFlexible(1f);
			return obj;
		}
	}
	public sealed class SectorInfoPanel
	{
		public sealed class ContentRow
		{
			public GameObject Row { get; private set; }

			public ContentRow(Transform parentTransform)
			{
				Row = CreateChildRow(parentTransform);
			}

			private GameObject CreateChildRow(Transform parentTransform)
			{
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0025: Expected O, but got Unknown
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_0060: Expected O, but got Unknown
				GameObject val = new GameObject("Row", new Type[1] { typeof(RectTransform) });
				GameObjectExtensions.SetParent(val, parentTransform);
				val.AddComponent<HorizontalLayoutGroup>().SetChildControl(true, true).SetChildForceExpand(true, false)
					.SetSpacing(6f)
					.SetChildAlignment((TextAnchor)4);
				return val;
			}
		}

		public GameObject Panel { get; private set; }

		public ContentRow PositionContent { get; private set; }

		public ValueWithLabel PositionX { get; private set; }

		public ValueWithLabel PositionY { get; private set; }

		public ValueWithLabel PositionZ { get; private set; }

		public ButtonCell CopyPositionButton { get; private set; }

		public ContentRow SectorContent { get; private set; }

		public ValueWithLabel SectorXY { get; private set; }

		public ValueWithLabel SectorZdoCount { get; private set; }

		public ContentRow ZdoManagerContent { get; private set; }

		public ValueWithLabel ZdoManagerNextId { get; private set; }

		public PanelDragger PanelDragger { get; private set; }

		public SectorInfoPanel(Transform parentTransform)
		{
			Panel = CreatePanel(parentTransform);
			PositionContent = new ContentRow(Panel.transform);
			PositionX = new ValueWithLabel(PositionContent.Row.transform);
			PositionX.Label.SetText("X");
			PositionY = new ValueWithLabel(PositionContent.Row.transform);
			PositionY.Label.SetText("Y");
			PositionZ = new ValueWithLabel(PositionContent.Row.transform);
			PositionZ.Label.SetText("Z");
			CreateCopyPositionButton();
			SectorContent = new ContentRow(Panel.transform);
			SectorXY = new ValueWithLabel(SectorContent.Row.transform);
			SectorXY.Label.SetText("Sector");
			SectorZdoCount = new ValueWithLabel(SectorContent.Row.transform);
			SectorZdoCount.Label.SetText("ZDOs");
			ZdoManagerContent = new ContentRow(Panel.transform);
			ZdoManagerNextId = new ValueWithLabel(ZdoManagerContent.Row.transform);
			ZdoManagerNextId.Label.SetText("NextId");
			SetPanelStyle();
			ToggleZDOManagerContent(PluginConfig.ShowZDOManagerContent.Value);
			PanelDragger = Panel.AddComponent<PanelDragger>();
			PanelDragger.TargetRectTransform = Panel.GetComponent<RectTransform>();
		}

		private void CreateCopyPositionButton()
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: 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_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Expected O, but got Unknown
			CopyPositionButton = new ButtonCell(PositionContent.Row.transform);
			CopyPositionButton.Cell.AddComponent<LayoutElement>().SetIgnoreLayout(ignoreLayout: true);
			CopyPositionButton.Cell.GetComponent<RectTransform>().SetAnchorMin(new Vector2(1f, 0.5f)).SetAnchorMax(new Vector2(1f, 0.5f))
				.SetPivot(new Vector2(0f, 0.5f))
				.SetPosition(new Vector2(10f, 0f))
				.SetSizeDelta(new Vector2(80f, 0f));
			CopyPositionButton.Label.text = "Copy";
			((UnityEvent)CopyPositionButton.Button.onClick).AddListener(new UnityAction(CopyPositionToClipboard));
		}

		private void CopyPositionToClipboard()
		{
			string text2 = (GUIUtility.systemCopyBuffer = (ZInput.GetKey((KeyCode)304, false) ? ("Position (XZY): " + PositionX.Value.text + " " + PositionZ.Value.text + " " + PositionY.Value.text) : ("Position (XYZ): " + PositionX.Value.text + " " + PositionY.Value.text + " " + PositionZ.Value.text)));
			((Terminal)Chat.instance).AddString("Copied to clipboard: " + text2);
		}

		public void ToggleCopyButtons(bool toggleOn)
		{
			CopyPositionButton.Cell.gameObject.SetActive(toggleOn);
		}

		public void SetPanelStyle()
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: 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_0139: 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_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: 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_02e8: Unknown result type (might be due to invalid IL or missing references)
			int value = PluginConfig.SectorInfoPanelFontSize.Value;
			PositionX.Label.SetFontSize<TMP_Text>((float)value);
			PositionX.Value.SetFontSize<TMP_Text>((float)value);
			PositionX.Value.SetColor<TMP_Text>(PluginConfig.PositionValueXTextColor.Value);
			PositionX.FitValueToText("-00000");
			PositionX.Row.Image().SetColor(PluginConfig.PositionValueXTextColor.Value.SetAlpha(0.1f));
			PositionY.Label.SetFontSize<TMP_Text>((float)value);
			PositionY.Value.SetFontSize<TMP_Text>((float)value);
			PositionY.Value.SetColor<TMP_Text>(PluginConfig.PositionValueYTextColor.Value);
			PositionY.FitValueToText("-00000");
			PositionY.Row.Image().SetColor(PluginConfig.PositionValueYTextColor.Value.SetAlpha(0.1f));
			PositionZ.Label.SetFontSize<TMP_Text>((float)value);
			PositionZ.Value.SetFontSize<TMP_Text>((float)value);
			PositionZ.Value.SetColor<TMP_Text>(PluginConfig.PositionValueZTextColor.Value);
			PositionZ.FitValueToText("-00000");
			PositionZ.Row.Image().SetColor(PluginConfig.PositionValueZTextColor.Value.SetAlpha(0.1f));
			SectorXY.Label.SetFontSize<TMP_Text>((float)value);
			SectorXY.Value.SetFontSize<TMP_Text>((float)value);
			SectorXY.Value.SetColor<TMP_Text>(PluginConfig.PositionValueXTextColor.Value);
			SectorXY.FitValueToText("-123,-123");
			SectorXY.Row.Image().SetColor(PluginConfig.PositionValueXTextColor.Value.SetAlpha(0.1f));
			SectorZdoCount.Label.SetFontSize<TMP_Text>((float)value);
			SectorZdoCount.Value.SetFontSize<TMP_Text>((float)value);
			SectorZdoCount.Value.SetColor<TMP_Text>(PluginConfig.PositionValueYTextColor.Value);
			SectorZdoCount.FitValueToText("123456");
			SectorZdoCount.Row.Image().SetColor(PluginConfig.PositionValueYTextColor.Value.SetAlpha(0.1f));
			ZdoManagerNextId.Label.SetFontSize<TMP_Text>((float)value);
			ZdoManagerNextId.Value.SetFontSize<TMP_Text>((float)value);
			ZdoManagerNextId.Value.SetColor<TMP_Text>(PluginConfig.PositionValueZTextColor.Value);
			ZdoManagerNextId.FitValueToText("1234567890");
			ZdoManagerNextId.Row.Image().SetColor(PluginConfig.PositionValueZTextColor.Value.SetAlpha(0.1f));
		}

		public void ToggleZDOManagerContent(bool toggleOn)
		{
			GameObject row = ZdoManagerContent.Row;
			if (row != null)
			{
				row.SetActive(toggleOn);
			}
		}

		private GameObject CreatePanel(Transform parentTransform)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0026: 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_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Expected O, but got Unknown
			GameObject val = new GameObject("SectorInfo.Panel", new Type[1] { typeof(RectTransform) });
			GameObjectExtensions.SetParent(val, parentTransform);
			val.AddComponent<VerticalLayoutGroup>().SetChildControl(true, true).SetChildForceExpand(true, false)
				.SetPadding(6, 6, 6, 6)
				.SetSpacing(6f);
			val.AddComponent<ContentSizeFitter>().SetHorizontalFit((FitMode)2).SetVerticalFit((FitMode)2);
			val.AddComponent<Image>().SetType((Type)1).SetSprite(UIBuilder.CreateSuperellipse(200, 200, 12f))
				.SetColor(PluginConfig.SectorInfoPanelBackgroundColor.Value);
			val.AddComponent<CanvasGroup>().SetBlocksRaycasts(blocksRaycasts: true);
			return val;
		}
	}
	public sealed class SectorZdoCountGrid
	{
		private readonly List<SectorZdoCountCell> _cells = new List<SectorZdoCountCell>();

		public GameObject Grid { get; private set; }

		public int Size { get; private set; }

		public GameObject[] Rows { get; private set; }

		public SectorZdoCountCell[,] Cells { get; private set; }

		public SectorZdoCountGrid(Transform parentTransform, PluginConfig.GridSize gridSize)
		{
			Size = GetSize(gridSize);
			Grid = CreateChildGrid(parentTransform);
			Rows = (GameObject[])(object)new GameObject[Size];
			Cells = new SectorZdoCountCell[Size, Size];
			for (int i = 0; i < Size; i++)
			{
				GameObject val = CreateSectorZdoCountGridRow(Grid.transform);
				for (int j = 0; j < Size; j++)
				{
					SectorZdoCountCell sectorZdoCountCell = new SectorZdoCountCell(val.transform);
					Cells[i, j] = sectorZdoCountCell;
					_cells.Add(sectorZdoCountCell);
				}
			}
		}

		private static int GetSize(PluginConfig.GridSize gridSize)
		{
			return gridSize switch
			{
				PluginConfig.GridSize.ThreeByThree => 3, 
				PluginConfig.GridSize.FiveByFive => 5, 
				_ => 1, 
			};
		}

		public void SetCellStyle()
		{
			foreach (SectorZdoCountCell cell in _cells)
			{
				cell.SetCellStyle();
			}
		}

		private GameObject CreateChildGrid(Transform parentTransform)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			GameObject val = new GameObject("Grid", new Type[1] { typeof(RectTransform) });
			GameObjectExtensions.SetParent(val, parentTransform);
			val.AddComponent<VerticalLayoutGroup>().SetChildControl(true, true).SetChildForceExpand(false, false)
				.SetChildAlignment((TextAnchor)4)
				.SetSpacing(6f);
			return val;
		}

		private GameObject CreateSectorZdoCountGridRow(Transform parentTransform)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			GameObject val = new GameObject("SectorZdoCountGrid.Row", new Type[1] { typeof(RectTransform) });
			GameObjectExtensions.SetParent(val, parentTransform);
			val.AddComponent<HorizontalLayoutGroup>().SetChildControl(true, true).SetChildForceExpand(false, false)
				.SetChildAlignment((TextAnchor)4)
				.SetSpacing(6f);
			return val;
		}
	}
	public sealed class SectorZdoCountCell
	{
		public GameObject Cell { get; private set; }

		public Image ZdoCountBackground { get; private set; }

		public TMP_Text ZdoCount { get; private set; }

		public Image SectorBackground { get; private set; }

		public TMP_Text Sector { get; private set; }

		public SectorZdoCountCell(Transform parentTransform)
		{
			Cell = CreateChildCell(parentTransform);
			ZdoCountBackground = CreateChildBackground(Cell.transform).Image();
			ZdoCount = CreateChildLabel(((Component)ZdoCountBackground).transform);
			SectorBackground = CreateChildBackground(Cell.transform).Image();
			Sector = CreateChildLabel(((Component)SectorBackground).transform);
			SetCellStyle(setPreferredWidth: true);
		}

		public void SetCellStyle(bool setPreferredWidth = false)
		{
			//IL_000b: 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)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			ZdoCountBackground.SetColor(PluginConfig.CellZdoCountBackgroundImageColor.Value);
			ZdoCount.SetColor<TMP_Text>(PluginConfig.CellZdoCountTextColor.Value);
			if (ZdoCount.fontSize != (float)PluginConfig.CellZdoCountTextFontSize.Value || setPreferredWidth)
			{
				ZdoCount.SetFontSize<TMP_Text>((float)PluginConfig.CellZdoCountTextFontSize.Value);
				((Component)ZdoCount).GetComponent<LayoutElement>().SetFlexible(1f).SetPreferred(ZdoCount.GetPreferredValues("12345").x);
			}
			SectorBackground.SetColor(PluginConfig.CellSectorBackgroundImageColor.Value);
			Sector.SetColor<TMP_Text>(PluginConfig.CellSectorTextColor.Value);
			if (Sector.fontSize != (float)PluginConfig.CellSectorTextFontSize.Value || setPreferredWidth)
			{
				Sector.SetFontSize<TMP_Text>((float)PluginConfig.CellSectorTextFontSize.Value);
				((Component)Sector).GetComponent<LayoutElement>().SetFlexible(1f).SetPreferred(Sector.GetPreferredValues("-123,-123").x);
			}
		}

		private GameObject CreateChildCell(Transform parentTransform)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Expected O, but got Unknown
			GameObject val = new GameObject("Cell", new Type[1] { typeof(RectTransform) });
			GameObjectExtensions.SetParent(val, parentTransform);
			val.AddComponent<VerticalLayoutGroup>().SetChildControl(true, true).SetChildForceExpand(false, false)
				.SetSpacing(0f)
				.SetChildAlignment((TextAnchor)4);
			val.AddComponent<ContentSizeFitter>().SetHorizontalFit((FitMode)0).SetVerticalFit((FitMode)2);
			val.AddComponent<Image>().SetType((Type)1).SetSprite(UIBuilder.CreateRoundedCornerSprite(200, 200, 10))
				.SetColor(new Color(0f, 0f, 0f, 0.3f));
			return val;
		}

		private GameObject CreateChildBackground(Transform parentTransform)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Expected O, but got Unknown
			GameObject val = new GameObject("Background", new Type[1] { typeof(RectTransform) });
			GameObjectExtensions.SetParent(val, parentTransform);
			val.AddComponent<HorizontalLayoutGroup>().SetChildControl(true, true).SetChildForceExpand(false, false)
				.SetPadding(4, 4, 2, 2)
				.SetChildAlignment((TextAnchor)4);
			val.AddComponent<Image>().SetType((Type)1).SetSprite(UIBuilder.CreateRoundedCornerSprite(200, 200, 5))
				.SetColor(Color.clear);
			return val;
		}

		private TMP_Text CreateChildLabel(Transform parentTransform)
		{
			TMP_Text obj = UIBuilder.CreateTMPLabel(parentTransform);
			((Object)obj).name = "Label";
			obj.SetAlignment<TMP_Text>((TextAlignmentOptions)514).SetText("123");
			((Component)obj).gameObject.AddComponent<LayoutElement>().SetFlexible(1f);
			return obj;
		}
	}
	public sealed class ValueWithLabel
	{
		public GameObject Row { get; private set; }

		public TMP_Text Value { get; private set; }

		public TMP_Text Label { get; private set; }

		public ValueWithLabel(Transform parentTransform)
		{
			Row = CreateChildRow(parentTransform);
			Value = CreateChildValue(Row.transform);
			Label = CreateChildLabel(Row.transform);
		}

		public ValueWithLabel FitValueToText(string longestText)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			((Component)(object)Value).GetOrAddComponent<LayoutElement>().SetFlexible(1f).SetPreferred(Value.GetPreferredValues(longestText).x);
			return this;
		}

		private GameObject CreateChildRow(Transform parentTransform)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0026: 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_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Expected O, but got Unknown
			GameObject val = new GameObject("Row", new Type[1] { typeof(RectTransform) });
			GameObjectExtensions.SetParent(val, parentTransform);
			val.AddComponent<HorizontalLayoutGroup>().SetChildControl(true, true).SetChildForceExpand(false, false)
				.SetPadding(8, 8, 4, 4)
				.SetSpacing(8f);
			val.AddComponent<Image>().SetType((Type)1).SetSprite(UIBuilder.CreateRoundedCornerSprite(200, 200, 5))
				.SetColor(new Color(0f, 0f, 0f, 0.1f));
			return val;
		}

		private TMP_Text CreateChildValue(Transform parentTransform)
		{
			TMP_Text obj = UIBuilder.CreateTMPLabel(parentTransform);
			((Object)obj).name = "Value";
			obj.SetFontSize<TMP_Text>((float)PluginConfig.SectorInfoPanelFontSize.Value).SetAlignment<TMP_Text>((TextAlignmentOptions)260).SetText("0");
			((Component)obj).gameObject.AddComponent<LayoutElement>().SetPreferred(50f);
			return obj;
		}

		private TMP_Text CreateChildLabel(Transform parentTransform)
		{
			TMP_Text obj = UIBuilder.CreateTMPLabel(parentTransform);
			((Object)obj).name = "Label";
			obj.SetFontSize<TMP_Text>((float)PluginConfig.SectorInfoPanelFontSize.Value).SetAlignment<TMP_Text>((TextAlignmentOptions)257).SetText("X");
			return obj;
		}
	}
	[BepInPlugin("redseiko.valheim.zonescouter", "ZoneScouter", "1.6.0")]
	public sealed class ZoneScouter : BaseUnityPlugin
	{
		public const string PluginGuid = "redseiko.valheim.zonescouter";

		public const string PluginName = "ZoneScouter";

		public const string PluginVersion = "1.6.0";

		private void Awake()
		{
			PluginConfig.BindConfig(((BaseUnityPlugin)this).Config);
			ZoneSystemUtils.SetupUtils();
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "redseiko.valheim.zonescouter");
		}
	}
}
namespace ComfyLib
{
	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 ObjectExtensions
	{
		public static T FirstByNameOrThrow<T>(this T[] unityObjects, string name) where T : Object
		{
			foreach (T val in unityObjects)
			{
				if (((Object)val).name == name)
				{
					return val;
				}
			}
			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 sealed class PanelDragger : MonoBehaviour, IBeginDragHandler, IEventSystemHandler, IDragHandler, IEndDragHandler
	{
		public RectTransform TargetRectTransform;

		private Vector2 _lastMousePosition;

		public event EventHandler<Vector3> OnPanelEndDrag;

		public void OnBeginDrag(PointerEventData eventData)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			_lastMousePosition = eventData.position;
		}

		public void OnDrag(PointerEventData eventData)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: 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_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_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = eventData.position - _lastMousePosition;
			RectTransform targetRectTransform = TargetRectTransform;
			((Transform)targetRectTransform).position = ((Transform)targetRectTransform).position + new Vector3(val.x, val.y, 0f);
			_lastMousePosition = eventData.position;
		}

		public void OnEndDrag(PointerEventData eventData)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			this.OnPanelEndDrag?.Invoke(this, Vector2.op_Implicit(TargetRectTransform.anchoredPosition));
		}
	}
	public static class UIBuilder
	{
		private static readonly Lazy<TextGenerator> CachedTextGenerator = new Lazy<TextGenerator>();

		private static readonly Dictionary<string, Sprite> _spriteCache = new Dictionary<string, Sprite>();

		private static readonly Color32 ColorWhite = Color32.op_Implicit(Color.white);

		private static readonly Color32 ColorClear = Color32.op_Implicit(Color.clear);

		public static TMP_Text CreateTMPLabel(Transform parentTransform)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			TextMeshProUGUI obj = Object.Instantiate<TextMeshProUGUI>(UnifiedPopup.instance.bodyText, parentTransform);
			((Object)obj).name = "Label";
			((TMP_Text)obj).enableAutoSizing = false;
			((TMP_Text)obj).fontSize = 16f;
			((TMP_Text)obj).overflowMode = (TextOverflowModes)0;
			((TMP_Text)obj).textWrappingMode = (TextWrappingModes)0;
			((Graphic)obj).color = Color.white;
			((TMP_Text)obj).text = string.Empty;
			return (TMP_Text)(object)obj;
		}

		public static GameObject CreateRowSpacer(Transform parentTransform)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			GameObject val = new GameObject(((Object)parentTransform).name + ".Spacer", new Type[1] { typeof(RectTransform) });
			GameObjectExtensions.SetParent(val, parentTransform);
			val.AddComponent<LayoutElement>().SetFlexible(1f);
			return val;
		}

		public static float GetTextPreferredWidth(Text text)
		{
			return GetTextPreferredWidth(text, text.text);
		}

		public static float GetTextPreferredWidth(Text text, string value)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			TextGenerator value2 = CachedTextGenerator.Value;
			Rect rect = ((Graphic)text).rectTransform.rect;
			return value2.GetPreferredWidth(value, text.GetGenerationSettings(((Rect)(ref rect)).size));
		}

		public static Sprite CreateRoundedCornerSprite(int width, int height, int radius)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_00ad: 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_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			string text = $"RoundedCorner-{width}w-{height}h-{radius}r";
			if (_spriteCache.TryGetValue(text, out var value))
			{
				return value;
			}
			Texture2D val = Texture2DExtensions.SetName(new Texture2D(width, height), text).SetWrapMode((TextureWrapMode)1).SetFilterMode((FilterMode)2);
			Color32[] array = (Color32[])(object)new Color32[width * height];
			for (int i = 0; i < width; i++)
			{
				for (int j = 0; j < height; j++)
				{
					array[i * width + j] = (IsCornerPixel(i, j, width, height, radius) ? ColorClear : ColorWhite);
				}
			}
			val.SetPixels32(array);
			val.Apply();
			int k;
			for (k = 0; k < width && !(Color32.op_Implicit(array[k]) == Color.white); k++)
			{
			}
			int l;
			for (l = 0; l < height && !(Color32.op_Implicit(array[l * width]) == Color.white); l++)
			{
			}
			value = Sprite.Create(val, new Rect(0f, 0f, (float)width, (float)height), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0, new Vector4((float)k, (float)l, (float)k, (float)l)).SetName(text);
			_spriteCache[text] = value;
			return value;
		}

		private static bool IsCornerPixel(int x, int y, int w, int h, int rad)
		{
			if (rad == 0)
			{
				return false;
			}
			int num = Math.Min(x, w - x);
			int num2 = Math.Min(y, h - y);
			if (num == 0 && num2 == 0)
			{
				return true;
			}
			if (num > rad || num2 > rad)
			{
				return false;
			}
			num = rad - num;
			num2 = rad - num2;
			return Math.Round(Math.Sqrt(num * num + num2 * num2)) > (double)rad;
		}

		public static Sprite CreateSuperellipse(int width, int height, float exponent)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: 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_0151: 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_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Unknown result type (might be due to invalid IL or missing references)
			string text = $"Superellipse-{width}w-{height}h-{exponent}e";
			if (_spriteCache.TryGetValue(text, out var value))
			{
				return value;
			}
			Texture2D val = Texture2DExtensions.SetName(new Texture2D(width, height), text).SetWrapMode((TextureWrapMode)1).SetFilterMode((FilterMode)2);
			Color32[] array = (Color32[])(object)new Color32[width * height];
			int num = width / 2;
			int num2 = height / 2;
			float num3 = 1f * ((float)width / 2f);
			float num4 = 1f * ((float)height / 2f);
			for (int i = 0; i < num; i++)
			{
				for (int j = 0; j < num2; j++)
				{
					Color32 val2 = Color32.op_Implicit((Mathf.Pow(Mathf.Abs((float)i / num3), exponent) + Mathf.Pow(Mathf.Abs((float)j / num4), exponent) > 1f) ? Color.clear : Color.white);
					int x2 = i + num;
					int x3 = -i + num - 1;
					int y2 = -j + num2 - 1;
					int y3 = j + num2;
					array[XYToIndex(x2, y3)] = val2;
					array[XYToIndex(x2, y2)] = val2;
					array[XYToIndex(x3, y2)] = val2;
					array[XYToIndex(x3, y3)] = val2;
				}
			}
			val.SetPixels32(array);
			val.Apply();
			int k;
			for (k = 0; k < width && !(Color32.op_Implicit(array[k]) == Color.white); k++)
			{
			}
			int l;
			for (l = 0; l < height && !(Color32.op_Implicit(array[l * width]) == Color.white); l++)
			{
			}
			value = Sprite.Create(val, new Rect(0f, 0f, (float)width, (float)height), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0, new Vector4((float)k, (float)l, (float)k, (float)l)).SetName(text);
			_spriteCache[text] = value;
			return value;
			int XYToIndex(int x, int y)
			{
				return x + y * width;
			}
		}
	}
	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 GameObjectExtensions
	{
		public static GameObject SetName(this GameObject gameObject, string name)
		{
			((Object)gameObject).name = name;
			return gameObject;
		}

		public static GameObject SetParent(this GameObject gameObject, Transform transform, bool worldPositionStays = false)
		{
			gameObject.transform.SetParent(transform, worldPositionStays);
			return gameObject;
		}

		public static IEnumerable<GameObject> Children(this GameObject gameObject)
		{
			if (!Object.op_Implicit((Object)(object)gameObject))
			{
				return Array.Empty<GameObject>();
			}
			return from Transform t in (IEnumerable)gameObject.transform
				select ((Component)t).gameObject;
		}

		public static T GetOrAddComponent<T>(this Component component) where T : Component
		{
			T result = default(T);
			if (!component.gameObject.TryGetComponent<T>(ref result))
			{
				return component.gameObject.AddComponent<T>();
			}
			return result;
		}

		public static T GetOrAddComponent<T>(this GameObject gameObject) where T : Component
		{
			T result = default(T);
			if (!gameObject.TryGetComponent<T>(ref result))
			{
				return gameObject.AddComponent<T>();
			}
			return result;
		}

		public static Button Button(this GameObject gameObject)
		{
			GameObject obj = gameObject.Ref<GameObject>();
			if (obj == null)
			{
				return null;
			}
			return obj.GetComponent<Button>();
		}

		public static Image Image(this GameObject gameObject)
		{
			GameObject obj = gameObject.Ref<GameObject>();
			if (obj == null)
			{
				return null;
			}
			return obj.GetComponent<Image>();
		}

		public static LayoutElement LayoutElement(this GameObject gameObject)
		{
			GameObject obj = gameObject.Ref<GameObject>();
			if (obj == null)
			{
				return null;
			}
			return obj.GetComponent<LayoutElement>();
		}

		public static RectTransform RectTransform(this GameObject gameObject)
		{
			GameObject obj = gameObject.Ref<GameObject>();
			if (obj == null)
			{
				return null;
			}
			return obj.GetComponent<RectTransform>();
		}

		public static Text Text(this GameObject gameObject)
		{
			GameObject obj = gameObject.Ref<GameObject>();
			if (obj == null)
			{
				return null;
			}
			return obj.GetComponent<Text>();
		}
	}
	public static class GridLayoutGroupExtensions
	{
		public static GridLayoutGroup SetCellSize(this GridLayoutGroup layoutGroup, Vector2 cellSize)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			layoutGroup.cellSize = cellSize;
			return layoutGroup;
		}

		public static GridLayoutGroup SetPadding(this GridLayoutGroup layoutGroup, int? left = null, int? right = null, int? top = null, int? bottom = null)
		{
			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)layoutGroup).padding.left = left.Value;
			}
			if (right.HasValue)
			{
				((LayoutGroup)layoutGroup).padding.right = right.Value;
			}
			if (top.HasValue)
			{
				((LayoutGroup)layoutGroup).padding.top = top.Value;
			}
			if (bottom.HasValue)
			{
				((LayoutGroup)layoutGroup).padding.bottom = bottom.Value;
			}
			return layoutGroup;
		}
	}
	public static class HorizontalLayoutGroupExtensions
	{
		public static HorizontalLayoutGroup SetChildControl(this HorizontalLayoutGroup layoutGroup, bool? width = null, bool? height = null)
		{
			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 HorizontalLayoutGroup SetChildForceExpand(this HorizontalLayoutGroup layoutGroup, bool? width = null, bool? height = null)
		{
			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 HorizontalLayoutGroup SetChildAlignment(this HorizontalLayoutGroup layoutGroup, TextAnchor alignment)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			((LayoutGroup)layoutGroup).childAlignment = alignment;
			return layoutGroup;
		}

		public static HorizontalLayoutGroup SetPadding(this HorizontalLayoutGroup layoutGroup, int? left = null, int? right = null, int? top = null, int? bottom = null)
		{
			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)layoutGroup).padding.left = left.Value;
			}
			if (right.HasValue)
			{
				((LayoutGroup)layoutGroup).padding.right = right.Value;
			}
			if (top.HasValue)
			{
				((LayoutGroup)layoutGroup).padding.top = top.Value;
			}
			if (bottom.HasValue)
			{
				((LayoutGroup)layoutGroup).padding.bottom = bottom.Value;
			}
			return layoutGroup;
		}

		public static HorizontalLayoutGroup SetSpacing(this HorizontalLayoutGroup layoutGroup, float spacing)
		{
			((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 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 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 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 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 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 SetIgnoreLayout(this LayoutElement layoutElement, bool ignoreLayout)
		{
			layoutElement.ignoreLayout = ignoreLayout;
			return layoutElement;
		}
	}
	public static class MaskExtensions
	{
		public static Mask SetShowMaskGraphic(this Mask mask, bool showMaskGraphic)
		{
			mask.showMaskGraphic = showMaskGraphic;
			return mask;
		}
	}
	public static class OutlineExtensions
	{
		public static Outline SetEffectColor(this Outline outline, Color effectColor)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			((Shadow)outline).effectColor = effectColor;
			return outline;
		}

		public static Outline SetEffectDistance(this Outline outline, Vector2 effectDistance)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			((Shadow)outline).effectDistance = effectDistance;
			return outline;
		}

		public static Outline SetUseGraphicAlpha(this Outline outline, bool useGraphicAlpha)
		{
			((Shadow)outline).useGraphicAlpha = useGraphicAlpha;
			return outline;
		}
	}
	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 SelectableExtensions
	{
		public static Selectable SetColors(this Selectable selectable, ColorBlock colors)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			selectable.colors = colors;
			return selectable;
		}

		public static Selectable SetImage(this Selectable selectable, Image image)
		{
			selectable.image = image;
			return selectable;
		}

		public static Selectable SetTargetGraphic(this Selectable selectable, Graphic graphic)
		{
			selectable.targetGraphic = graphic;
			return selectable;
		}

		public static Selectable SetNavigationMode(this Selectable selectable, Mode mode)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			Navigation navigation = selectable.navigation;
			((Navigation)(ref navigation)).mode = mode;
			selectable.navigation = navigation;
			return selectable;
		}
	}
	public static class ScrollRectExtensions
	{
		public static ScrollRect SetScrollSensitivity(this ScrollRect scrollRect, float sensitivity)
		{
			scrollRect.scrollSensitivity = sensitivity;
			return scrollRect;
		}

		public static ScrollRect SetVerticalScrollPosition(this ScrollRect scrollRect, float position)
		{
			scrollRect.verticalNormalizedPosition = position;
			return scrollRect;
		}

		public static ScrollRect SetViewport(this ScrollRect scrollRect, RectTransform viewport)
		{
			scrollRect.viewport = viewport;
			return scrollRect;
		}

		public static ScrollRect SetContent(this ScrollRect scrollRect, RectTransform content)
		{
			scrollRect.content = content;
			return scrollRect;
		}

		public static ScrollRect SetHorizontal(this ScrollRect scrollRect, bool horizontal)
		{
			scrollRect.horizontal = horizontal;
			return scrollRect;
		}

		public static ScrollRect SetVertical(this ScrollRect scrollRect, bool vertical)
		{
			scrollRect.vertical = vertical;
			return scrollRect;
		}
	}
	public static class SpriteExtensions
	{
		public static Sprite SetName(this Sprite sprite, string name)
		{
			((Object)sprite).name = name;
			return sprite;
		}
	}
	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 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 SetName(this Texture2D texture, string name)
		{
			((Object)texture).name = name;
			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 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 class VerticalLayoutGroupExtensions
	{
		public static VerticalLayoutGroup SetChildControl(this VerticalLayoutGroup layoutGroup, bool? width = null, bool? height = null)
		{
			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 VerticalLayoutGroup SetChildForceExpand(this VerticalLayoutGroup layoutGroup, bool? width = null, bool? height = null)
		{
			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 VerticalLayoutGroup SetChildAlignment(this VerticalLayoutGroup layoutGroup, TextAnchor alignment)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			((LayoutGroup)layoutGroup).childAlignment = alignment;
			return layoutGroup;
		}

		public static VerticalLayoutGroup SetPadding(this VerticalLayoutGroup layoutGroup, int? left = null, int? right = null, int? top = null, int? bottom = null)
		{
			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)layoutGroup).padding.left = left.Value;
			}
			if (right.HasValue)
			{
				((LayoutGroup)layoutGroup).padding.right = right.Value;
			}
			if (top.HasValue)
			{
				((LayoutGroup)layoutGroup).padding.top = top.Value;
			}
			if (bottom.HasValue)
			{
				((LayoutGroup)layoutGroup).padding.bottom = bottom.Value;
			}
			return layoutGroup;
		}

		public static VerticalLayoutGroup SetSpacing(this VerticalLayoutGroup layoutGroup, float spacing)
		{
			((HorizontalOrVerticalLayoutGroup)layoutGroup).spacing = spacing;
			return layoutGroup;
		}
	}
	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;
		}
	}
}