Decompiled source of BetterMinimap v1.1.1

plugins/BetterMinimap.dll

Decompiled 3 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
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: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("AndrewSha")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: AssemblyInformationalVersion("1.1.1+a4f077ab3b90cacd504ab899c0e02dc3251d67ef")]
[assembly: AssemblyProduct("BetterMinimap")]
[assembly: AssemblyTitle("BetterMinimap")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/Xoma163/BetterMinimap")]
[assembly: AssemblyVersion("1.1.1.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Shtab.RotatingMinimap
{
	internal sealed class Compass
	{
		private readonly GameObject _root;

		private readonly RectTransform[] _lines = (RectTransform[])(object)new RectTransform[2];

		private readonly DashedLineGraphic[] _lineGraphics = new DashedLineGraphic[2];

		private readonly RectTransform[] _labels = (RectTransform[])(object)new RectTransform[4];

		private readonly HudContrast _contrast = new HudContrast();

		public Compass(Minimap map)
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Expected O, but got Unknown
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			TMP_Text componentInChildren = ((Component)map).GetComponentInChildren<TMP_Text>(true);
			_root = new GameObject("ShtabCompass", new Type[1] { typeof(RectTransform) });
			RectTransform val = (RectTransform)_root.transform;
			((Transform)val).SetParent(((Component)map.m_mapImageSmall).transform, false);
			val.anchorMin = Vector2.zero;
			val.anchorMax = Vector2.one;
			val.offsetMin = (val.offsetMax = Vector2.zero);
			string[] array = new string[4] { "N", "E", "S", "W" };
			Vector2 val3 = default(Vector2);
			for (int i = 0; i < 2; i++)
			{
				GameObject val2 = new GameObject((i == 0) ? "NorthSouth" : "EastWest", new Type[1] { typeof(RectTransform) });
				val2.transform.SetParent((Transform)(object)val, false);
				DashedLineGraphic dashedLineGraphic = val2.AddComponent<DashedLineGraphic>();
				((Graphic)dashedLineGraphic).raycastTarget = false;
				((Graphic)dashedLineGraphic).color = new Color(1f, 0.96f, 0.85f, 0.3f);
				RectTransform rectTransform = ((Graphic)dashedLineGraphic).rectTransform;
				((Vector2)(ref val3))..ctor(0.5f, 0.5f);
				rectTransform.pivot = val3;
				Vector2 anchorMin = (rectTransform.anchorMax = val3);
				rectTransform.anchorMin = anchorMin;
				_lines[i] = rectTransform;
				_lineGraphics[i] = dashedLineGraphic;
			}
			for (int j = 0; j < 4; j++)
			{
				GameObject val5 = new GameObject(array[j], new Type[1] { typeof(RectTransform) });
				val5.transform.SetParent((Transform)(object)val, false);
				TextMeshProUGUI val6 = val5.AddComponent<TextMeshProUGUI>();
				if (Object.op_Implicit((Object)(object)componentInChildren) && Object.op_Implicit((Object)(object)componentInChildren.font))
				{
					((TMP_Text)val6).font = componentInChildren.font;
				}
				((TMP_Text)val6).text = array[j];
				((TMP_Text)val6).fontSize = 18f;
				((TMP_Text)val6).fontStyle = (FontStyles)1;
				((TMP_Text)val6).alignment = (TextAlignmentOptions)514;
				((Graphic)val6).color = (Color)((j == 0) ? new Color(1f, 0.87f, 0.4f) : Color.white);
				((Graphic)val6).raycastTarget = false;
				RectTransform rectTransform2 = ((TMP_Text)val6).rectTransform;
				((Vector2)(ref val3))..ctor(0.5f, 0.5f);
				rectTransform2.pivot = val3;
				Vector2 anchorMin = (rectTransform2.anchorMax = val3);
				rectTransform2.anchorMin = anchorMin;
				rectTransform2.sizeDelta = new Vector2(24f, 24f);
				_labels[j] = rectTransform2;
				_contrast.Apply((Component?)(object)val6);
			}
		}

		public void Show(bool visible, Rect area, float heading, bool showLines, bool showLetters, bool round, Color lineColor, float thickness, bool dashed)
		{
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: 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)
			if (!Object.op_Implicit((Object)(object)_root))
			{
				return;
			}
			_root.SetActive(visible);
			if (visible)
			{
				for (int i = 0; i < 2; i++)
				{
					((Component)_lines[i]).gameObject.SetActive(showLines);
					float num = heading - (float)i * 90f;
					(double, double) tuple = MapMath.CompassEdge(((Rect)(ref area)).width, ((Rect)(ref area)).height, num, 2.0, round);
					float num2 = (float)Math.Sqrt(tuple.Item1 * tuple.Item1 + tuple.Item2 * tuple.Item2) * 2f;
					_lines[i].sizeDelta = new Vector2(thickness, num2);
					((Graphic)_lineGraphics[i]).color = lineColor;
					_lineGraphics[i].SetDashed(dashed);
					((Transform)_lines[i]).localRotation = Quaternion.Euler(0f, 0f, num);
				}
				for (int j = 0; j < 4; j++)
				{
					((Component)_labels[j]).gameObject.SetActive(showLetters);
					(double, double) tuple2 = MapMath.CompassEdge(((Rect)(ref area)).width, ((Rect)(ref area)).height, heading - (float)j * 90f, 16.0, round);
					_labels[j].anchoredPosition = new Vector2((float)tuple2.Item1, (float)tuple2.Item2);
				}
			}
		}

		public void Destroy()
		{
			_contrast.Dispose();
			if (Object.op_Implicit((Object)(object)_root))
			{
				Object.Destroy((Object)(object)_root);
			}
		}
	}
	public sealed class DashedLineGraphic : MaskableGraphic
	{
		private bool _dashed = true;

		public void SetDashed(bool dashed)
		{
			if (_dashed != dashed)
			{
				_dashed = dashed;
				((Graphic)this).SetVerticesDirty();
			}
		}

		protected override void OnPopulateMesh(VertexHelper mesh)
		{
			//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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: 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)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: 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_0142: Unknown result type (might be due to invalid IL or missing references)
			mesh.Clear();
			Rect rect = ((Graphic)this).rectTransform.rect;
			IEnumerable<(double Start, double End)> enumerable2;
			if (!_dashed)
			{
				IEnumerable<(double, double)> enumerable = new(double, double)[1] { ((0.0 - (double)((Rect)(ref rect)).height) / 2.0, (double)((Rect)(ref rect)).height / 2.0) };
				enumerable2 = enumerable;
			}
			else
			{
				enumerable2 = MapMath.DashRanges(((Rect)(ref rect)).height);
			}
			foreach (var item in enumerable2)
			{
				int currentVertCount = mesh.currentVertCount;
				float num = ((Rect)(ref rect)).center.y + (float)item.Start;
				float num2 = ((Rect)(ref rect)).center.y + (float)item.End;
				mesh.AddVert(new Vector3(((Rect)(ref rect)).xMin, num), Color32.op_Implicit(((Graphic)this).color), Vector4.op_Implicit(Vector2.zero));
				mesh.AddVert(new Vector3(((Rect)(ref rect)).xMin, num2), Color32.op_Implicit(((Graphic)this).color), Vector4.op_Implicit(Vector2.zero));
				mesh.AddVert(new Vector3(((Rect)(ref rect)).xMax, num2), Color32.op_Implicit(((Graphic)this).color), Vector4.op_Implicit(Vector2.zero));
				mesh.AddVert(new Vector3(((Rect)(ref rect)).xMax, num), Color32.op_Implicit(((Graphic)this).color), Vector4.op_Implicit(Vector2.zero));
				mesh.AddTriangle(currentVertCount, currentVertCount + 1, currentVertCount + 2);
				mesh.AddTriangle(currentVertCount + 2, currentVertCount + 3, currentVertCount);
			}
		}
	}
	public sealed class ExternalImageShadow : MonoBehaviour
	{
		private Image? _source;

		private readonly Image[] _copies = (Image[])(object)new Image[8];

		private static readonly Vector2[] Offsets = (Vector2[])(object)new Vector2[8]
		{
			new Vector2(-1f, 0f),
			new Vector2(1f, 0f),
			new Vector2(0f, -1f),
			new Vector2(0f, 1f),
			new Vector2(-0.7071f, -0.7071f),
			new Vector2(-0.7071f, 0.7071f),
			new Vector2(0.7071f, -0.7071f),
			new Vector2(0.7071f, 0.7071f)
		};

		public void Initialize(Image source)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			_source = source;
			for (int i = 0; i < _copies.Length; i++)
			{
				GameObject val = new GameObject("BetterMinimapWindShadow", new Type[1] { typeof(RectTransform) });
				val.SetActive(false);
				val.transform.SetParent(((Component)source).transform.parent, false);
				val.transform.SetSiblingIndex(((Component)source).transform.GetSiblingIndex());
				Image val2 = val.AddComponent<Image>();
				((Graphic)val2).raycastTarget = false;
				((MaskableGraphic)val2).maskable = false;
				_copies[i] = val2;
				val.SetActive(true);
				((MaskableGraphic)val2).RecalculateClipping();
				((MaskableGraphic)val2).RecalculateMasking();
				((Graphic)val2).canvasRenderer.DisableRectClipping();
				((Graphic)val2).canvasRenderer.cull = false;
			}
			LateUpdate();
		}

		private void LateUpdate()
		{
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: 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_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: 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_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)_source))
			{
				return;
			}
			Image source = _source;
			RectTransform rectTransform = ((Graphic)source).rectTransform;
			for (int i = 0; i < _copies.Length; i++)
			{
				Image val = _copies[i];
				if (Object.op_Implicit((Object)(object)val))
				{
					((Behaviour)val).enabled = ((Behaviour)source).enabled && ((Component)source).gameObject.activeInHierarchy;
					val.sprite = (Object.op_Implicit((Object)(object)source.overrideSprite) ? source.overrideSprite : source.sprite);
					val.type = source.type;
					val.preserveAspect = source.preserveAspect;
					val.fillAmount = source.fillAmount;
					val.fillMethod = source.fillMethod;
					val.fillOrigin = source.fillOrigin;
					val.fillClockwise = source.fillClockwise;
					((Graphic)val).color = new Color(0f, 0f, 0f, ((Graphic)source).color.a * 0.85f);
					RectTransform rectTransform2 = ((Graphic)val).rectTransform;
					rectTransform2.anchorMin = rectTransform.anchorMin;
					rectTransform2.anchorMax = rectTransform.anchorMax;
					rectTransform2.pivot = rectTransform.pivot;
					rectTransform2.sizeDelta = rectTransform.sizeDelta;
					rectTransform2.anchoredPosition3D = rectTransform.anchoredPosition3D + Vector2.op_Implicit(Offsets[i] * 1.25f);
					((Transform)rectTransform2).localScale = ((Transform)rectTransform).localScale;
					((Transform)rectTransform2).localRotation = ((Transform)rectTransform).localRotation;
				}
			}
		}

		private void OnDisable()
		{
			Image[] copies = _copies;
			foreach (Image val in copies)
			{
				if (Object.op_Implicit((Object)(object)val))
				{
					((Behaviour)val).enabled = false;
				}
			}
		}

		public void Clear()
		{
			((Behaviour)this).enabled = false;
			_source = null;
			Image[] copies = _copies;
			foreach (Image val in copies)
			{
				if (Object.op_Implicit((Object)(object)val))
				{
					((Behaviour)val).enabled = false;
					Object.Destroy((Object)(object)((Component)val).gameObject);
				}
			}
		}

		private void OnDestroy()
		{
			Clear();
		}
	}
	public sealed class ExternalTextShadow : MonoBehaviour
	{
		private TMP_Text? _source;

		private bool _respectMask;

		private readonly TextMeshProUGUI[] _copies = (TextMeshProUGUI[])(object)new TextMeshProUGUI[8];

		private static readonly Vector2[] Offsets = (Vector2[])(object)new Vector2[8]
		{
			new Vector2(-1f, 0f),
			new Vector2(1f, 0f),
			new Vector2(0f, -1f),
			new Vector2(0f, 1f),
			new Vector2(-0.7071f, -0.7071f),
			new Vector2(-0.7071f, 0.7071f),
			new Vector2(0.7071f, -0.7071f),
			new Vector2(0.7071f, 0.7071f)
		};

		public float PixelWidth { get; set; } = 2f;

		public void Initialize(TMP_Text source, bool respectMask = false)
		{
			//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_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			_source = source;
			_respectMask = respectMask;
			for (int i = 0; i < _copies.Length; i++)
			{
				GameObject val = new GameObject("BetterMinimapBiomeOutline", new Type[1] { typeof(RectTransform) });
				val.SetActive(false);
				val.transform.SetParent(source.transform.parent, false);
				val.transform.SetSiblingIndex(source.transform.GetSiblingIndex());
				TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>();
				((Graphic)val2).raycastTarget = false;
				((MaskableGraphic)val2).maskable = respectMask && ((MaskableGraphic)source).maskable;
				((TMP_Text)val2).overrideColorTags = true;
				_copies[i] = val2;
				val.SetActive(true);
				((MaskableGraphic)val2).RecalculateClipping();
				((MaskableGraphic)val2).RecalculateMasking();
				if (!respectMask)
				{
					val2.canvasRenderer.DisableRectClipping();
					val2.canvasRenderer.cull = false;
				}
			}
			LateUpdate();
		}

		private void LateUpdate()
		{
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)_source))
			{
				return;
			}
			TMP_Text source = _source;
			RectTransform rectTransform = source.rectTransform;
			(Vector2, Vector2) tuple = ScreenPixelOffsets.InParent(rectTransform);
			string text = source.text;
			for (int i = 0; i < _copies.Length; i++)
			{
				TextMeshProUGUI val = _copies[i];
				if (!Object.op_Implicit((Object)(object)val))
				{
					continue;
				}
				bool flag = ((Behaviour)source).enabled && ((Component)source).gameObject.activeInHierarchy;
				((Component)val).gameObject.SetActive(flag);
				if (flag)
				{
					((TMP_Text)val).font = source.font;
					if (Object.op_Implicit((Object)(object)source.font))
					{
						((TMP_Text)val).fontSharedMaterial = ((TMP_Asset)source.font).material;
					}
					((TMP_Text)val).text = text;
					((TMP_Text)val).richText = source.richText;
					((MaskableGraphic)val).maskable = _respectMask && ((MaskableGraphic)source).maskable;
					((TMP_Text)val).isRightToLeftText = source.isRightToLeftText;
					((TMP_Text)val).fontSize = source.fontSize;
					((TMP_Text)val).fontStyle = source.fontStyle;
					((TMP_Text)val).fontWeight = source.fontWeight;
					((TMP_Text)val).enableAutoSizing = source.enableAutoSizing;
					((TMP_Text)val).fontSizeMin = source.fontSizeMin;
					((TMP_Text)val).fontSizeMax = source.fontSizeMax;
					((TMP_Text)val).alignment = source.alignment;
					((TMP_Text)val).characterSpacing = source.characterSpacing;
					((TMP_Text)val).wordSpacing = source.wordSpacing;
					((TMP_Text)val).lineSpacing = source.lineSpacing;
					((TMP_Text)val).paragraphSpacing = source.paragraphSpacing;
					((TMP_Text)val).margin = source.margin;
					((TMP_Text)val).textWrappingMode = source.textWrappingMode;
					((TMP_Text)val).overflowMode = source.overflowMode;
					((Graphic)val).color = new Color(0f, 0f, 0f, ((Graphic)source).color.a * 0.85f);
					RectTransform rectTransform2 = ((TMP_Text)val).rectTransform;
					if ((Object)(object)((Transform)rectTransform2).parent != (Object)(object)((Transform)rectTransform).parent)
					{
						((Transform)rectTransform2).SetParent(((Transform)rectTransform).parent, false);
						((Transform)rectTransform2).SetSiblingIndex(((Transform)rectTransform).GetSiblingIndex());
					}
					rectTransform2.anchorMin = rectTransform.anchorMin;
					rectTransform2.anchorMax = rectTransform.anchorMax;
					rectTransform2.pivot = rectTransform.pivot;
					rectTransform2.sizeDelta = rectTransform.sizeDelta;
					rectTransform2.anchoredPosition3D = rectTransform.anchoredPosition3D + Vector2.op_Implicit((tuple.Item1 * Offsets[i].x + tuple.Item2 * Offsets[i].y) * PixelWidth);
					((Transform)rectTransform2).localScale = ((Transform)rectTransform).localScale;
					((Transform)rectTransform2).localRotation = ((Transform)rectTransform).localRotation;
				}
			}
		}

		private void OnDisable()
		{
			TextMeshProUGUI[] copies = _copies;
			foreach (TextMeshProUGUI val in copies)
			{
				if (Object.op_Implicit((Object)(object)val))
				{
					((Component)val).gameObject.SetActive(false);
				}
			}
		}

		public void Clear()
		{
			((Behaviour)this).enabled = false;
			_source = null;
			TextMeshProUGUI[] copies = _copies;
			foreach (TextMeshProUGUI val in copies)
			{
				if (Object.op_Implicit((Object)(object)val))
				{
					((Component)val).gameObject.SetActive(false);
					Object.Destroy((Object)(object)((Component)val).gameObject);
				}
			}
		}

		private void OnDestroy()
		{
			Clear();
		}
	}
	internal sealed class HudContrast : IDisposable
	{
		private readonly List<Action> _restore = new List<Action>();

		private readonly HashSet<Graphic> _seen = new HashSet<Graphic>();

		public void Apply(Component? root, bool outline = false)
		{
			//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_00ed: Expected O, but got Unknown
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)root))
			{
				return;
			}
			Graphic[] componentsInChildren = root.GetComponentsInChildren<Graphic>(true);
			foreach (Graphic val in componentsInChildren)
			{
				if (!_seen.Add(val))
				{
					continue;
				}
				TMP_Text text = (TMP_Text)(object)((val is TMP_Text) ? val : null);
				if (text != null)
				{
					if (outline)
					{
						ExternalTextShadow shadow = ((Component)text).gameObject.AddComponent<ExternalTextShadow>();
						shadow.Initialize(text);
						_restore.Add(delegate
						{
							if (Object.op_Implicit((Object)(object)shadow))
							{
								shadow.Clear();
								Object.Destroy((Object)(object)shadow);
							}
						});
						continue;
					}
					Material original = text.fontSharedMaterial;
					if (!Object.op_Implicit((Object)(object)original) || !original.HasProperty("_UnderlayColor"))
					{
						continue;
					}
					Material outlined = new Material(original)
					{
						name = "BetterMinimapTextShadow"
					};
					outlined.SetColor("_UnderlayColor", new Color(0f, 0f, 0f, 0.9f));
					outlined.SetFloat("_UnderlayOffsetX", 0f);
					outlined.SetFloat("_UnderlayOffsetY", 0f);
					outlined.SetFloat("_UnderlayDilate", 0.25f);
					outlined.SetFloat("_UnderlaySoftness", outline ? 0.03f : 0.15f);
					outlined.DisableKeyword("UNDERLAY_INNER");
					outlined.EnableKeyword("UNDERLAY_ON");
					text.fontSharedMaterial = outlined;
					text.UpdateMeshPadding();
					_restore.Add(delegate
					{
						if (Object.op_Implicit((Object)(object)text) && (Object)(object)text.fontSharedMaterial == (Object)(object)outlined)
						{
							text.fontSharedMaterial = original;
							text.UpdateMeshPadding();
						}
						if (Object.op_Implicit((Object)(object)outlined))
						{
							Object.Destroy((Object)(object)outlined);
						}
					});
					continue;
				}
				Image val2 = (Image)(object)((val is Image) ? val : null);
				if (val2 == null)
				{
					continue;
				}
				ExternalImageShadow shadow2 = ((Component)val2).gameObject.AddComponent<ExternalImageShadow>();
				shadow2.Initialize(val2);
				_restore.Add(delegate
				{
					if (Object.op_Implicit((Object)(object)shadow2))
					{
						shadow2.Clear();
						Object.Destroy((Object)(object)shadow2);
					}
				});
			}
		}

		public void Dispose()
		{
			for (int num = _restore.Count - 1; num >= 0; num--)
			{
				_restore[num]();
			}
			_restore.Clear();
			_seen.Clear();
		}
	}
	public enum HudSlotContent
	{
		Empty,
		Biome,
		Wind,
		Coordinates
	}
	internal static class HudSlots
	{
		public const double Gap = 2.0;

		public const float CoordinatesFontSize = 9f;

		public static double BiomeHeight(double preferredHeight)
		{
			return Math.Max(26.0, Math.Ceiling(preferredHeight + 4.0));
		}

		public static double CenterOffset(int slot, double ownHeight, double innerHeight)
		{
			if (slot < 0 || slot > 3)
			{
				throw new ArgumentOutOfRangeException("slot");
			}
			double num = 2.0 + ownHeight / 2.0;
			if ((slot == 0 || slot == 3) && innerHeight > 0.0)
			{
				num += innerHeight + 2.0;
			}
			if (slot >= 2)
			{
				return 0.0 - num;
			}
			return num;
		}

		public static HudSlotContent[] Migrate(string biome, string wind)
		{
			HudSlotContent[] array = new HudSlotContent[4];
			int num = ((!(biome == "Below")) ? 1 : 2);
			array[num] = HudSlotContent.Biome;
			bool flag = wind == "Top" || wind == "TopLeft" || wind == "TopRight";
			int num2 = (flag ? 1 : 2);
			if (num2 == num)
			{
				num2 = ((!flag) ? 3 : 0);
			}
			array[num2] = HudSlotContent.Wind;
			return array;
		}

		public static HudSlotContent MigrateCoordinates(HudSlotContent content, bool hadSwitch, bool enabled)
		{
			if (!hadSwitch || enabled || content != HudSlotContent.Coordinates)
			{
				return content;
			}
			return HudSlotContent.Empty;
		}

		public static double ViewportShift(double top, double bottom, double min, double max)
		{
			if (top - bottom > max - min)
			{
				return max - top;
			}
			if (top > max)
			{
				return max - top;
			}
			if (bottom < min)
			{
				return min - bottom;
			}
			return 0.0;
		}
	}
	internal sealed class HudSpacing : IDisposable
	{
		private sealed class SlotView : IDisposable
		{
			private readonly RectTransform _root;

			private readonly TextMeshProUGUI _text;

			private Vector3 _coordinates;

			private string? _coordinateText;

			private readonly RectTransform _wind;

			private readonly ExternalTextShadow _textShadow;

			private readonly HudContrast _contrast = new HudContrast();

			public SlotView(Transform parent, TMP_Text? biome, RectTransform wind, int index)
			{
				//IL_003b: 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)
				//IL_004f: Expected O, but got Unknown
				//IL_0074: Unknown result type (might be due to invalid IL or missing references)
				//IL_007a: Expected O, but got Unknown
				//IL_0109: Unknown result type (might be due to invalid IL or missing references)
				//IL_011e: Unknown result type (might be due to invalid IL or missing references)
				//IL_013e: 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_0144: Unknown result type (might be due to invalid IL or missing references)
				//IL_014a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0196: Unknown result type (might be due to invalid IL or missing references)
				//IL_019c: Unknown result type (might be due to invalid IL or missing references)
				//IL_019d: Unknown result type (might be due to invalid IL or missing references)
				//IL_019e: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
				_root = (RectTransform)new GameObject("BetterMinimapSlot" + (index + 1), new Type[1] { typeof(RectTransform) }).transform;
				((Transform)_root).SetParent(parent, false);
				GameObject val = new GameObject("Label", new Type[1] { typeof(RectTransform) });
				val.transform.SetParent((Transform)(object)_root, false);
				_text = val.AddComponent<TextMeshProUGUI>();
				if (Object.op_Implicit((Object)(object)biome) && Object.op_Implicit((Object)(object)biome.font))
				{
					((TMP_Text)_text).font = biome.font;
				}
				((TMP_Text)_text).alignment = (TextAlignmentOptions)514;
				((TMP_Text)_text).textWrappingMode = (TextWrappingModes)0;
				((TMP_Text)_text).overflowMode = (TextOverflowModes)0;
				((Graphic)_text).raycastTarget = false;
				((MaskableGraphic)_text).maskable = false;
				((TMP_Text)_text).rectTransform.anchorMin = Vector2.zero;
				((TMP_Text)_text).rectTransform.anchorMax = Vector2.one;
				((TMP_Text)_text).rectTransform.offsetMin = (((TMP_Text)_text).rectTransform.offsetMax = Vector2.zero);
				_wind = Object.Instantiate<RectTransform>(wind, (Transform)(object)_root, false);
				((Object)_wind).name = "Wind";
				RectTransform wind2 = _wind;
				RectTransform wind3 = _wind;
				RectTransform wind4 = _wind;
				Vector2 val2 = default(Vector2);
				((Vector2)(ref val2))..ctor(0.5f, 0.5f);
				wind4.pivot = val2;
				wind2.anchorMin = (wind3.anchorMax = val2);
				RectTransform wind5 = _wind;
				Rect rect = wind.rect;
				wind5.sizeDelta = ((Rect)(ref rect)).size;
				_wind.anchoredPosition3D = Vector3.zero;
				Graphic[] componentsInChildren = ((Component)_wind).GetComponentsInChildren<Graphic>(true);
				foreach (Graphic obj in componentsInChildren)
				{
					obj.raycastTarget = false;
					MaskableGraphic val4 = (MaskableGraphic)(object)((obj is MaskableGraphic) ? obj : null);
					if (val4 != null)
					{
						val4.maskable = false;
					}
				}
				_contrast.Apply((Component?)(object)_text, outline: true);
				_textShadow = ((Component)_text).GetComponent<ExternalTextShadow>();
				_contrast.Apply((Component?)(object)_wind, outline: true);
			}

			public float Show(HudSlotContent content, TMP_Text? biome, RectTransform wind, Vector3 position, float heading)
			{
				//IL_003f: 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)
				//IL_004a: Unknown result type (might be due to invalid IL or missing references)
				//IL_005a: Unknown result type (might be due to invalid IL or missing references)
				//IL_005f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0062: Unknown result type (might be due to invalid IL or missing references)
				//IL_0067: Unknown result type (might be due to invalid IL or missing references)
				//IL_0075: Unknown result type (might be due to invalid IL or missing references)
				//IL_008a: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
				//IL_0116: Unknown result type (might be due to invalid IL or missing references)
				//IL_011e: 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_01a3: Unknown result type (might be due to invalid IL or missing references)
				//IL_01af: Unknown result type (might be due to invalid IL or missing references)
				//IL_0132: 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_01d7: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
				//IL_01fe: 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_01ca: Unknown result type (might be due to invalid IL or missing references)
				//IL_0183: Unknown result type (might be due to invalid IL or missing references)
				bool flag = content == HudSlotContent.Wind;
				((Component)_wind).gameObject.SetActive(flag);
				((Component)_text).gameObject.SetActive(!flag);
				if (flag)
				{
					((Transform)_wind).rotation = Quaternion.Euler(0f, 0f, heading) * ((Transform)wind).rotation;
					Rect rect = _wind.rect;
					Vector2 size = ((Rect)(ref rect)).size;
					return ((Vector2)(ref size)).magnitude * Mathf.Max(Mathf.Abs(((Transform)_wind).localScale.x), Mathf.Abs(((Transform)_wind).localScale.y));
				}
				((TMP_Text)_text).enableAutoSizing = false;
				((TMP_Text)_text).fontSize = ((content == HudSlotContent.Biome && Object.op_Implicit((Object)(object)biome)) ? biome.fontSize : 9f);
				_textShadow.PixelWidth = ((content == HudSlotContent.Coordinates) ? 3 : 2);
				((TMP_Text)_text).fontStyle = (FontStyles)((content == HudSlotContent.Biome && Object.op_Implicit((Object)(object)biome)) ? ((int)biome.fontStyle) : 0);
				((Graphic)_text).color = ((content == HudSlotContent.Biome && Object.op_Implicit((Object)(object)biome)) ? ((Graphic)biome).color : Color.white);
				if (content == HudSlotContent.Biome)
				{
					Color color = ((Graphic)_text).color;
					color.a = 1f;
					((Graphic)_text).color = color;
					((TMP_Text)_text).text = (Object.op_Implicit((Object)(object)biome) ? biome.text : "");
					return (float)HudSlots.BiomeHeight(((TMP_Text)_text).GetPreferredValues(((TMP_Text)_text).text).y);
				}
				Vector3 val = default(Vector3);
				((Vector3)(ref val))..ctor(Mathf.Round(position.x), Mathf.Round(position.y), Mathf.Round(position.z));
				if (_coordinateText == null || val != _coordinates)
				{
					_coordinates = val;
					_coordinateText = string.Format(CultureInfo.InvariantCulture, "X: {0:0}  Y: {1:0}  Z: {2:0}", val.x, val.y, val.z);
				}
				((TMP_Text)_text).text = _coordinateText;
				return Mathf.Max(10f, ((TMP_Text)_text).fontSize * 1.2f);
			}

			public void Place(Vector3 position, float width, float height)
			{
				//IL_0006: 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)
				((Transform)_root).position = position;
				_root.sizeDelta = new Vector2(width, height);
			}

			public void SetVisible(bool visible)
			{
				((Component)_root).gameObject.SetActive(visible);
			}

			public void Dispose()
			{
				_contrast.Dispose();
				if (Object.op_Implicit((Object)(object)_root))
				{
					((Component)_root).gameObject.SetActive(false);
					Object.Destroy((Object)(object)((Component)_root).gameObject);
				}
			}
		}

		private readonly Minimap _map;

		private readonly MapScaleView _scale;

		private readonly Transform _root;

		private readonly TMP_Text? _biome;

		private readonly SlotView?[] _slots = new SlotView[4];

		private readonly float[] _heights = new float[4];

		private readonly bool[] _visible = new bool[4];

		private RectTransform? _buffs;

		private Vector2 _buffBase;

		private Vector2 _buffLast;

		private bool _buffShifted;

		private bool _hidden;

		private readonly Graphic[] _originalGraphics;

		private readonly bool[] _originalEnabled;

		public float ZoomIndicatorOffset { get; private set; }

		public HudSpacing(Minimap map, MapScaleView scale)
		{
			_map = map;
			_scale = scale;
			_root = ((Component)map.m_mapImageSmall).transform.parent;
			_biome = map.m_biomeNameSmall;
			List<Graphic> list = new List<Graphic>();
			if (Object.op_Implicit((Object)(object)_biome))
			{
				list.AddRange(((Component)_biome).GetComponentsInChildren<Graphic>(true));
			}
			if (Object.op_Implicit((Object)(object)map.m_windMarker))
			{
				list.AddRange(((Component)map.m_windMarker).GetComponentsInChildren<Graphic>(true));
			}
			_originalGraphics = list.ToArray();
			_originalEnabled = new bool[_originalGraphics.Length];
		}

		public void BeforeMap()
		{
			_scale.RestorePosition();
			if (!_hidden)
			{
				return;
			}
			for (int i = 0; i < _originalGraphics.Length; i++)
			{
				if (Object.op_Implicit((Object)(object)_originalGraphics[i]))
				{
					((Behaviour)_originalGraphics[i]).enabled = _originalEnabled[i];
				}
			}
			_hidden = false;
		}

		public void Apply(int percent, HudSlotContent[] contents, float heading, bool showMinimap)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Invalid comparison between Unknown and I4
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			bool flag = showMinimap && Object.op_Implicit((Object)(object)_map) && (int)_map.m_mode == 1 && Object.op_Implicit((Object)(object)Player.m_localPlayer) && Object.op_Implicit((Object)(object)_map.m_mapImageSmall) && ((Component)_map.m_mapImageSmall).gameObject.activeInHierarchy;
			BeforeMap();
			ZoomIndicatorOffset = 0f;
			for (int i = 0; i < 4; i++)
			{
				bool flag2 = flag && contents[i] != HudSlotContent.Empty;
				_visible[i] = flag2;
				_heights[i] = 0f;
				if (flag2)
				{
					if (_slots[i] == null)
					{
						_slots[i] = new SlotView(_root, _biome, _map.m_windMarker, i);
					}
					_heights[i] = _slots[i].Show(contents[i], _biome, _map.m_windMarker, ((Component)Player.m_localPlayer).transform.position, heading);
				}
				_slots[i]?.SetVisible(flag2);
			}
			if (flag)
			{
				RectTransform rectTransform = ((Graphic)_map.m_mapImageSmall).rectTransform;
				Rect rect = rectTransform.rect;
				float num = 0f;
				float num2 = 0f;
				for (int j = 0; j < 4; j++)
				{
					if (_visible[j])
					{
						float num3 = Mathf.Abs((float)HudSlots.CenterOffset(j, _heights[j], _heights[(j < 2) ? 1 : 2])) + _heights[j] / 2f;
						if (j < 2)
						{
							num = Mathf.Max(num, num3);
						}
						else
						{
							num2 = Mathf.Max(num2, num3);
						}
					}
				}
				_scale.FitVertical(rectTransform, num, num2 + 32f);
				for (int k = 0; k < 4; k++)
				{
					if (_visible[k])
					{
						float num4 = (float)HudSlots.CenterOffset(k, _heights[k], _heights[(k < 2) ? 1 : 2]);
						_slots[k].Place(((Transform)rectTransform).TransformPoint(new Vector3(((Rect)(ref rect)).center.x, ((k < 2) ? ((Rect)(ref rect)).yMax : ((Rect)(ref rect)).yMin) + num4, 0f)), ((Rect)(ref rect)).width, _heights[k]);
						if (k >= 2)
						{
							ZoomIndicatorOffset = Mathf.Max(ZoomIndicatorOffset, 0f - num4 + _heights[k] / 2f);
						}
					}
				}
				for (int l = 0; l < _originalGraphics.Length; l++)
				{
					if (Object.op_Implicit((Object)(object)_originalGraphics[l]))
					{
						_originalEnabled[l] = ((Behaviour)_originalGraphics[l]).enabled;
						((Behaviour)_originalGraphics[l]).enabled = false;
					}
				}
				_hidden = true;
			}
			PlaceBuffs(flag, percent);
		}

		private void PlaceBuffs(bool small, int percent)
		{
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			Hud instance = Hud.instance;
			RectTransform val = (Object.op_Implicit((Object)(object)instance) ? instance.m_statusEffectListRoot : null);
			if ((Object)(object)_buffs != (Object)(object)val)
			{
				RestoreBuffs();
				_buffs = val;
			}
			if (!small || percent <= 100 || !Object.op_Implicit((Object)(object)_buffs) || !Object.op_Implicit((Object)(object)((Transform)_buffs).parent))
			{
				RestoreBuffs();
				return;
			}
			Vector2 anchoredPosition = _buffs.anchoredPosition;
			if (!_buffShifted || !Mathf.Approximately(anchoredPosition.x, _buffLast.x))
			{
				_buffBase.x = anchoredPosition.x;
			}
			_buffBase.y = anchoredPosition.y;
			float x = ((Transform)_buffs).parent.InverseTransformVector(_scale.LeftExpansionWorld(percent)).x;
			_buffLast = _buffBase - new Vector2(Mathf.Max(0f, x), 0f);
			_buffs.anchoredPosition = _buffLast;
			_buffShifted = true;
		}

		private void RestoreBuffs()
		{
			//IL_001b: 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)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			if (_buffShifted && Object.op_Implicit((Object)(object)_buffs))
			{
				Vector2 anchoredPosition = _buffs.anchoredPosition;
				if (Mathf.Approximately(anchoredPosition.x, _buffLast.x))
				{
					_buffs.anchoredPosition = new Vector2(_buffBase.x, anchoredPosition.y);
				}
			}
			_buffShifted = false;
		}

		public void Dispose()
		{
			BeforeMap();
			RestoreBuffs();
			SlotView[] slots = _slots;
			for (int i = 0; i < slots.Length; i++)
			{
				slots[i]?.Dispose();
			}
			_buffs = null;
		}
	}
	internal sealed class MapBorderView : IDisposable
	{
		private readonly Minimap _map;

		private readonly MapBorderGraphic _graphic;

		public MapBorderView(Minimap map)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			//IL_0072: 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_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			_map = map;
			GameObject val = new GameObject("BetterMinimapBorder", new Type[1] { typeof(RectTransform) });
			val.transform.SetParent(((Component)map.m_mapImageSmall).transform, false);
			_graphic = val.AddComponent<MapBorderGraphic>();
			((Graphic)_graphic).raycastTarget = false;
			((MaskableGraphic)_graphic).maskable = false;
			RectTransform rectTransform = ((Graphic)_graphic).rectTransform;
			rectTransform.anchorMin = Vector2.zero;
			rectTransform.anchorMax = Vector2.one;
			rectTransform.offsetMin = (rectTransform.offsetMax = Vector2.zero);
			((MaskableGraphic)_graphic).RecalculateClipping();
			((MaskableGraphic)_graphic).RecalculateMasking();
			((Graphic)_graphic).canvasRenderer.DisableRectClipping();
		}

		public void Update(bool round)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Invalid comparison between Unknown and I4
			((Component)_graphic).gameObject.SetActive((int)_map.m_mode == 1 && Object.op_Implicit((Object)(object)Player.m_localPlayer) && ((Component)_map.m_mapImageSmall).gameObject.activeInHierarchy);
			_graphic.SetRound(round);
		}

		public void Dispose()
		{
			if (Object.op_Implicit((Object)(object)_graphic))
			{
				((Component)_graphic).gameObject.SetActive(false);
				Object.Destroy((Object)(object)((Component)_graphic).gameObject);
			}
		}
	}
	public sealed class MapBorderGraphic : MaskableGraphic
	{
		private bool _round;

		public void SetRound(bool round)
		{
			if (_round != round)
			{
				_round = round;
				((Graphic)this).SetVerticesDirty();
			}
		}

		protected override void OnPopulateMesh(VertexHelper vh)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			vh.Clear();
			Band(vh, -0.6f, 0.9f, new Color32((byte)137, (byte)91, (byte)48, byte.MaxValue));
		}

		private void Band(VertexHelper vh, float outerInset, float innerInset, Color32 tint)
		{
			//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_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			Rect rect = ((Graphic)this).rectTransform.rect;
			if (!(((Rect)(ref rect)).width <= 3f) && !(((Rect)(ref rect)).height <= 3f))
			{
				int num = (_round ? 256 : 4);
				for (int i = 0; i < num; i++)
				{
					int currentVertCount = vh.currentVertCount;
					vh.AddVert(Point(rect, i, num, outerInset), tint, Vector4.op_Implicit(Vector2.zero));
					vh.AddVert(Point(rect, i + 1, num, outerInset), tint, Vector4.op_Implicit(Vector2.zero));
					vh.AddVert(Point(rect, i + 1, num, innerInset), tint, Vector4.op_Implicit(Vector2.zero));
					vh.AddVert(Point(rect, i, num, innerInset), tint, Vector4.op_Implicit(Vector2.zero));
					vh.AddTriangle(currentVertCount, currentVertCount + 1, currentVertCount + 2);
					vh.AddTriangle(currentVertCount, currentVertCount + 2, currentVertCount + 3);
				}
			}
		}

		private Vector3 Point(Rect rect, int index, int segments, float inset)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			if (_round)
			{
				(double, double) tuple = MapFrameGeometry.CirclePoint(((Rect)(ref rect)).width, ((Rect)(ref rect)).height, index, inset);
				return Vector2.op_Implicit(((Rect)(ref rect)).center + new Vector2((float)tuple.Item1, (float)tuple.Item2));
			}
			int num = index % 4;
			return new Vector3((num == 0 || num == 3) ? (((Rect)(ref rect)).xMin + inset) : (((Rect)(ref rect)).xMax - inset), (num < 2) ? (((Rect)(ref rect)).yMin + inset) : (((Rect)(ref rect)).yMax - inset), 0f);
		}
	}
	internal static class MapFrameGeometry
	{
		public const int Segments = 256;

		public const float OuterInset = -0.6f;

		public const float InnerInset = 0.9f;

		public const float MaskInset = 0.15f;

		public static (double X, double Y) CirclePoint(double width, double height, int index, double inset)
		{
			double num = (double)index * Math.PI * 2.0 / 256.0;
			double num2 = Math.Max(0.0, Math.Min(width, height) / 2.0 - inset);
			return (X: Math.Cos(num) * num2, Y: Math.Sin(num) * num2);
		}
	}
	internal sealed class MapLightingView : IDisposable
	{
		private readonly RawImage _image;

		private Material? _source;

		private Material? _material;

		public MapLightingView(Minimap map)
		{
			_image = map.m_mapImageSmall;
		}

		public void Apply(MapLighting mode, float dayFraction)
		{
			//IL_0083: 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_0098: Expected O, but got Unknown
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: 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_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)_image))
			{
				return;
			}
			if (!Object.op_Implicit((Object)(object)_material) || (Object)(object)((Graphic)_image).material != (Object)(object)_material)
			{
				Dispose();
				_source = ((Graphic)_image).material;
				if (!Object.op_Implicit((Object)(object)_source) || !_source.HasProperty("_lightColor") || !_source.HasProperty("_ambientLightColor"))
				{
					return;
				}
				_material = new Material(_source)
				{
					name = "BetterMinimapLighting"
				};
				((Graphic)_image).material = _material;
			}
			_material.CopyPropertiesFromMaterial(_source);
			float num = mode switch
			{
				MapLighting.Night => 0f, 
				MapLighting.Day => 1f, 
				_ => (float)MapMath.Daylight(dayFraction), 
			};
			Color color = _source.GetColor("_lightColor");
			Color color2 = _source.GetColor("_ambientLightColor");
			_material.SetColor("_lightColor", color * Mathf.Lerp(0.25f, 1f, num));
			_material.SetColor("_ambientLightColor", Color.Lerp(new Color(color2.r * 0.38f, color2.g * 0.45f, color2.b * 0.62f, color2.a), color2, num));
		}

		public void Dispose()
		{
			if (Object.op_Implicit((Object)(object)_image) && Object.op_Implicit((Object)(object)_material) && (Object)(object)((Graphic)_image).material == (Object)(object)_material)
			{
				((Graphic)_image).material = _source;
			}
			if (Object.op_Implicit((Object)(object)_material))
			{
				Object.Destroy((Object)(object)_material);
			}
			_material = null;
			_source = null;
		}
	}
	public sealed class MapMaskGraphic : MaskableGraphic
	{
		private bool _round = true;

		public void SetRound(bool round)
		{
			if (_round != round)
			{
				_round = round;
				((Graphic)this).SetVerticesDirty();
			}
		}

		protected override void OnPopulateMesh(VertexHelper vh)
		{
			//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_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: 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_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			vh.Clear();
			Rect rect = ((Graphic)this).rectTransform.rect;
			if (((Rect)(ref rect)).width <= 0f || ((Rect)(ref rect)).height <= 0f)
			{
				return;
			}
			if (!_round)
			{
				vh.AddVert(new Vector3(((Rect)(ref rect)).xMin, ((Rect)(ref rect)).yMin), Color32.op_Implicit(Color.white), Vector4.op_Implicit(Vector2.zero));
				vh.AddVert(new Vector3(((Rect)(ref rect)).xMin, ((Rect)(ref rect)).yMax), Color32.op_Implicit(Color.white), Vector4.op_Implicit(Vector2.zero));
				vh.AddVert(new Vector3(((Rect)(ref rect)).xMax, ((Rect)(ref rect)).yMax), Color32.op_Implicit(Color.white), Vector4.op_Implicit(Vector2.zero));
				vh.AddVert(new Vector3(((Rect)(ref rect)).xMax, ((Rect)(ref rect)).yMin), Color32.op_Implicit(Color.white), Vector4.op_Implicit(Vector2.zero));
				vh.AddTriangle(0, 1, 2);
				vh.AddTriangle(0, 2, 3);
				return;
			}
			vh.AddVert(Vector2.op_Implicit(((Rect)(ref rect)).center), Color32.op_Implicit(Color.white), Vector4.op_Implicit(Vector2.zero));
			for (int i = 0; i < 256; i++)
			{
				(double, double) tuple = MapFrameGeometry.CirclePoint(((Rect)(ref rect)).width, ((Rect)(ref rect)).height, i, 0.15000000596046448);
				vh.AddVert(Vector2.op_Implicit(((Rect)(ref rect)).center + new Vector2((float)tuple.Item1, (float)tuple.Item2)), Color32.op_Implicit(Color.white), Vector4.op_Implicit(Vector2.zero));
			}
			for (int j = 0; j < 256; j++)
			{
				vh.AddTriangle(0, j + 1, (j + 1) % 256 + 1);
			}
		}
	}
	internal static class MapMath
	{
		public static double Daylight(double fraction)
		{
			if (double.IsNaN(fraction) || double.IsInfinity(fraction))
			{
				return 1.0;
			}
			fraction -= Math.Floor(fraction);
			double num = 0.0 - Math.Cos(fraction * 2.0 * Math.PI);
			double num2 = Math.Max(0.0, Math.Min(1.0, (num + 0.25) / 0.5));
			return num2 * num2 * (3.0 - 2.0 * num2);
		}

		public static (double X, double Y) Rotate(double x, double y, double degrees)
		{
			double num = degrees * Math.PI / 180.0;
			double num2 = Math.Cos(num);
			double num3 = Math.Sin(num);
			return (X: x * num2 - y * num3, Y: x * num3 + y * num2);
		}

		public static (double X, double Y) MapToScreen(double u, double v, double centerU, double centerV, double spanU, double spanV, double width, double height, double heading)
		{
			return Rotate((u - centerU) / spanU * width, (v - centerV) / spanV * height, heading);
		}

		public static (double U, double V) ScreenToMap(double x, double y, double centerU, double centerV, double spanU, double spanV, double width, double height, double heading)
		{
			(double, double) tuple = Rotate(x, y, 0.0 - heading);
			return (U: centerU + tuple.Item1 / width * spanU, V: centerV + tuple.Item2 / height * spanV);
		}

		public static bool Inside(double x, double y, double width, double height)
		{
			if (Math.Abs(x) < width / 2.0)
			{
				return Math.Abs(y) < height / 2.0;
			}
			return false;
		}

		public static (double X, double Y) NorthEdge(double width, double height, double heading, double inset)
		{
			(double, double) tuple = Rotate(0.0, 1.0, heading);
			double num = Math.Max(0.0, width / 2.0 - inset);
			double num2 = Math.Max(0.0, height / 2.0 - inset);
			double val = ((Math.Abs(tuple.Item1) < 1E-10) ? double.PositiveInfinity : (num / Math.Abs(tuple.Item1)));
			double val2 = ((Math.Abs(tuple.Item2) < 1E-10) ? double.PositiveInfinity : (num2 / Math.Abs(tuple.Item2)));
			double num3 = Math.Min(val, val2);
			return (X: tuple.Item1 * num3, Y: tuple.Item2 * num3);
		}

		public static double ZoomStep(double current, bool zoomIn, bool zoomOut, double factor)
		{
			if (zoomIn != zoomOut)
			{
				if (!zoomIn)
				{
					return current * factor;
				}
				return current / factor;
			}
			return current;
		}

		public static double AnchoredZoomStep(double current, double baseline, bool zoomIn, bool zoomOut, double factor)
		{
			if (zoomIn == zoomOut || current <= 0.0 || baseline <= 0.0 || factor <= 1.0)
			{
				return current;
			}
			double num = Math.Log(baseline / current) / Math.Log(factor);
			double y = (zoomIn ? (Math.Floor(num + 1E-05) + 1.0) : (Math.Ceiling(num - 1E-05) - 1.0));
			return baseline / Math.Pow(factor, y);
		}

		public static double ClampZoom(double value, double baseline, double min, double max)
		{
			if (double.IsNaN(value) || double.IsInfinity(value))
			{
				value = 1.0;
			}
			if (min > max)
			{
				double num = max;
				max = min;
				min = num;
			}
			double val = baseline / Math.Max(0.1, max);
			double val2 = ((min <= 0.0) ? 1.0 : (baseline / min));
			val2 = Math.Min(1.0, Math.Max(val, val2));
			return Math.Max(val, Math.Min(val2, value));
		}

		public static double RoundSetting(double value, double min, double max)
		{
			if (!double.IsNaN(value) && !double.IsInfinity(value))
			{
				return Math.Max(min, Math.Min(max, Math.Round(value, 1, MidpointRounding.AwayFromZero)));
			}
			return min;
		}

		public static (double X, double Y) CompassEdge(double width, double height, double heading, double inset, bool round)
		{
			if (!round)
			{
				return NorthEdge(width, height, heading, inset);
			}
			(double, double) tuple = Rotate(0.0, 1.0, heading);
			double num = Math.Max(0.0, Math.Min(width, height) / 2.0 - inset);
			return (X: tuple.Item1 * num, Y: tuple.Item2 * num);
		}

		public static bool InsideCircle(double x, double y, double width, double height)
		{
			return x * x + y * y < Math.Pow(Math.Min(width, height) / 2.0, 2.0);
		}

		public static double ScaleFactor(int percent)
		{
			return (double)Math.Max(50, Math.Min(150, percent)) / 100.0;
		}

		public static double BuffShift(double width, double originalScale, double pivot, int percent)
		{
			return Math.Max(0.0, width * originalScale * pivot * (ScaleFactor(percent) - 1.0));
		}

		public static IEnumerable<(double Start, double End)> DashRanges(double length)
		{
			if (!double.IsNaN(length) && !double.IsInfinity(length) && !(length <= 0.0))
			{
				double half = length / 2.0;
				for (double start = 5.0; start < half; start += 9.0)
				{
					double end = Math.Min(start + 4.0, half);
					yield return (Start: start, End: end);
					yield return (Start: 0.0 - end, End: 0.0 - start);
				}
			}
		}
	}
	internal sealed class MapScaleView : IDisposable
	{
		private readonly Transform _root;

		private readonly Vector3 _original;

		private Vector3 _basePosition;

		private Vector3 _lastPosition;

		private bool _shifted;

		public MapScaleView(Minimap map)
		{
			//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)
			_root = ((Component)map.m_mapImageSmall).transform.parent;
			_original = _root.localScale;
		}

		public void Apply(int percent)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)_root))
			{
				float num = (float)MapMath.ScaleFactor(percent);
				_root.localScale = new Vector3(_original.x * num, _original.y * num, _original.z);
			}
		}

		public void Dispose()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			RestorePosition();
			if (Object.op_Implicit((Object)(object)_root))
			{
				_root.localScale = _original;
			}
		}

		public void RestorePosition()
		{
			//IL_001b: 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_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			if (_shifted && Object.op_Implicit((Object)(object)_root))
			{
				Vector3 val = _root.localPosition - _lastPosition;
				if (((Vector3)(ref val)).sqrMagnitude < 0.001f)
				{
					_root.localPosition = _basePosition;
				}
			}
			_shifted = false;
		}

		public void FitVertical(RectTransform map, float above, float below)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: 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_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: 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_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			RestorePosition();
			if (!Object.op_Implicit((Object)(object)_root))
			{
				return;
			}
			Canvas componentInParent = ((Component)_root).GetComponentInParent<Canvas>();
			if (!Object.op_Implicit((Object)(object)componentInParent))
			{
				return;
			}
			Transform transform = ((Component)componentInParent.rootCanvas).transform;
			RectTransform val = (RectTransform)(object)((transform is RectTransform) ? transform : null);
			if (val != null)
			{
				Rect rect = map.rect;
				float y = ((Transform)val).InverseTransformPoint(((Transform)map).TransformPoint(new Vector3(((Rect)(ref rect)).center.x, ((Rect)(ref rect)).yMax + above, 0f))).y;
				float y2 = ((Transform)val).InverseTransformPoint(((Transform)map).TransformPoint(new Vector3(((Rect)(ref rect)).center.x, ((Rect)(ref rect)).yMin - below, 0f))).y;
				double top = y;
				double bottom = y2;
				Rect rect2 = val.rect;
				double min = ((Rect)(ref rect2)).yMin + 8f;
				rect2 = val.rect;
				float num = (float)HudSlots.ViewportShift(top, bottom, min, ((Rect)(ref rect2)).yMax - 8f);
				if (!(Mathf.Abs(num) < 0.01f))
				{
					_basePosition = _root.localPosition;
					Transform root = _root;
					root.position += ((Transform)val).TransformVector(new Vector3(0f, num, 0f));
					_lastPosition = _root.localPosition;
					_shifted = true;
				}
			}
		}

		public Vector3 LeftExpansionWorld(int percent)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: 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)
			if (Object.op_Implicit((Object)(object)_root) && Object.op_Implicit((Object)(object)_root.parent))
			{
				Transform root = _root;
				RectTransform val = (RectTransform)(object)((root is RectTransform) ? root : null);
				if (val != null)
				{
					Rect rect = val.rect;
					float num = (float)MapMath.BuffShift(((Rect)(ref rect)).width, _original.x, val.pivot.x, percent);
					return _root.parent.TransformVector(new Vector3(num, 0f, 0f));
				}
			}
			return Vector3.zero;
		}
	}
	internal sealed class MapShapeView : IDisposable
	{
		private sealed class Layout
		{
			private readonly RectTransform _item;

			private readonly Transform _parent;

			private readonly int _index;

			private readonly Vector2 _min;

			private readonly Vector2 _max;

			private readonly Vector2 _pivot;

			private readonly Vector2 _size;

			private readonly Vector3 _position;

			private readonly Vector3 _scale;

			private readonly Quaternion _rotation;

			public Layout(RectTransform item)
			{
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_0038: Unknown result type (might be due to invalid IL or missing references)
				//IL_003f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0044: Unknown result type (might be due to invalid IL or missing references)
				//IL_004b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0050: 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_0063: Unknown result type (might be due to invalid IL or missing references)
				//IL_0068: Unknown result type (might be due to invalid IL or missing references)
				//IL_006f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0074: Unknown result type (might be due to invalid IL or missing references)
				_item = item;
				_parent = ((Transform)item).parent;
				_index = ((Transform)item).GetSiblingIndex();
				_min = item.anchorMin;
				_max = item.anchorMax;
				_pivot = item.pivot;
				_size = item.sizeDelta;
				_position = item.anchoredPosition3D;
				_scale = ((Transform)item).localScale;
				_rotation = ((Transform)item).localRotation;
			}

			public void Restore()
			{
				//IL_0045: Unknown result type (might be due to invalid IL or missing references)
				//IL_0056: Unknown result type (might be due to invalid IL or missing references)
				//IL_0067: 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_0089: Unknown result type (might be due to invalid IL or missing references)
				//IL_009a: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
				if (Object.op_Implicit((Object)(object)_item) && Object.op_Implicit((Object)(object)_parent))
				{
					((Transform)_item).SetParent(_parent, false);
					((Transform)_item).SetSiblingIndex(_index);
					_item.anchorMin = _min;
					_item.anchorMax = _max;
					_item.pivot = _pivot;
					_item.sizeDelta = _size;
					_item.anchoredPosition3D = _position;
					((Transform)_item).localScale = _scale;
					((Transform)_item).localRotation = _rotation;
				}
			}
		}

		private readonly Minimap _map;

		private GameObject? _clip;

		private bool _mapMaskable;

		private readonly List<Layout> _moved = new List<Layout>();

		private readonly List<Graphic> _hiddenFrames = new List<Graphic>();

		private readonly List<(MaskableGraphic Graphic, bool Maskable)> _outside = new List<(MaskableGraphic, bool)>();

		private static readonly string[] StencilNames = new string[6] { "_Stencil", "_StencilComp", "_StencilOp", "_StencilReadMask", "_StencilWriteMask", "_ColorMask" };

		private readonly int[] _stencil = new int[StencilNames.Length];

		public MapShapeView(Minimap map)
		{
			_map = map;
		}

		public void Apply(bool round)
		{
			if (!Object.op_Implicit((Object)(object)_map) || !Object.op_Implicit((Object)(object)_map.m_mapImageSmall))
			{
				return;
			}
			if (!round)
			{
				Dispose();
				return;
			}
			if (!Object.op_Implicit((Object)(object)_clip))
			{
				Create();
			}
			RawImage mapImageSmall = _map.m_mapImageSmall;
			Material material = ((Graphic)mapImageSmall).material;
			Material materialForRendering = ((Graphic)mapImageSmall).materialForRendering;
			if (!Object.op_Implicit((Object)(object)material) || !Object.op_Implicit((Object)(object)materialForRendering) || (Object)(object)material == (Object)(object)materialForRendering)
			{
				return;
			}
			for (int i = 0; i < StencilNames.Length; i++)
			{
				if (materialForRendering.HasProperty(StencilNames[i]))
				{
					_stencil[i] = materialForRendering.GetInt(StencilNames[i]);
				}
			}
			materialForRendering.CopyPropertiesFromMaterial(material);
			for (int j = 0; j < StencilNames.Length; j++)
			{
				if (materialForRendering.HasProperty(StencilNames[j]))
				{
					materialForRendering.SetInt(StencilNames[j], _stencil[j]);
				}
			}
		}

		private void Create()
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: 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_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_030a: Unknown result type (might be due to invalid IL or missing references)
			RectTransform rectTransform = ((Graphic)_map.m_mapImageSmall).rectTransform;
			_mapMaskable = ((MaskableGraphic)_map.m_mapImageSmall).maskable;
			_clip = new GameObject("BetterMinimapCircle", new Type[1] { typeof(RectTransform) });
			RectTransform val = (RectTransform)_clip.transform;
			((Transform)val).SetParent(((Transform)rectTransform).parent, false);
			((Transform)val).SetSiblingIndex(((Transform)rectTransform).GetSiblingIndex());
			val.anchorMin = rectTransform.anchorMin;
			val.anchorMax = rectTransform.anchorMax;
			val.pivot = rectTransform.pivot;
			val.sizeDelta = rectTransform.sizeDelta;
			val.anchoredPosition3D = rectTransform.anchoredPosition3D;
			((Transform)val).localRotation = ((Transform)rectTransform).localRotation;
			((Transform)val).localScale = ((Transform)rectTransform).localScale;
			MapMaskGraphic mapMaskGraphic = _clip.AddComponent<MapMaskGraphic>();
			((Graphic)mapMaskGraphic).raycastTarget = false;
			_clip.AddComponent<Mask>().showMaskGraphic = false;
			Vector3[] array = (Vector3[])(object)new Vector3[4];
			Graphic[] componentsInChildren = ((Component)((Transform)rectTransform).parent).GetComponentsInChildren<Graphic>(true);
			Bounds val3 = default(Bounds);
			foreach (Graphic val2 in componentsInChildren)
			{
				if (((Behaviour)val2).enabled && !(val2.color.a <= 0f) && !((Object)(object)val2 == (Object)(object)mapMaskGraphic) && !((Object)(object)val2 == (Object)(object)_map.m_mapImageSmall) && !(val2 is TMP_Text) && !(val2 is Text) && !(val2 is MapBorderGraphic) && !(val2 is MapMaskGraphic) && !((Component)val2).transform.IsChildOf((Transform)(object)_map.m_smallMarker) && !((Component)val2).transform.IsChildOf((Transform)(object)_map.m_smallShipMarker) && !((Component)val2).transform.IsChildOf((Transform)(object)_map.m_pinRootSmall) && !((Component)val2).transform.IsChildOf((Transform)(object)_map.m_pinNameRootSmall) && !((Component)val2).transform.IsChildOf((Transform)(object)_map.m_windMarker))
				{
					val2.rectTransform.GetWorldCorners(array);
					((Bounds)(ref val3))..ctor(((Transform)rectTransform).InverseTransformPoint(array[0]), Vector3.zero);
					for (int j = 1; j < array.Length; j++)
					{
						((Bounds)(ref val3)).Encapsulate(((Transform)rectTransform).InverseTransformPoint(array[j]));
					}
					Rect rect = rectTransform.rect;
					if (Mathf.Abs(((Bounds)(ref val3)).center.x - ((Rect)(ref rect)).center.x) < 5f && Mathf.Abs(((Bounds)(ref val3)).center.y - ((Rect)(ref rect)).center.y) < 5f && ((Bounds)(ref val3)).size.x >= ((Rect)(ref rect)).width * 0.95f && ((Bounds)(ref val3)).size.x <= ((Rect)(ref rect)).width * 1.15f && ((Bounds)(ref val3)).size.y >= ((Rect)(ref rect)).height * 0.95f && ((Bounds)(ref val3)).size.y <= ((Rect)(ref rect)).height * 1.15f)
					{
						_hiddenFrames.Add(val2);
						((Behaviour)val2).enabled = false;
					}
				}
			}
			Move(rectTransform, (Transform)(object)val);
			Move(_map.m_pinRootSmall, (Transform)(object)val);
			Move(_map.m_pinNameRootSmall, (Transform)(object)val);
			Move(_map.m_smallMarker, (Transform)(object)val);
			Move(_map.m_smallShipMarker, (Transform)(object)val);
			((MaskableGraphic)_map.m_mapImageSmall).maskable = true;
			((MaskableGraphic)_map.m_mapImageSmall).RecalculateMasking();
			object? obj = AccessTools.Field(typeof(Minimap), "m_biomeNameSmall")?.GetValue(_map);
			Component root = (Component)((obj is Component) ? obj : null);
			KeepOutsideMask(root);
		}

		private void KeepOutsideMask(Component? root)
		{
			if (Object.op_Implicit((Object)(object)root))
			{
				MaskableGraphic[] componentsInChildren = root.GetComponentsInChildren<MaskableGraphic>(true);
				foreach (MaskableGraphic val in componentsInChildren)
				{
					_outside.Add((val, val.maskable));
					val.maskable = false;
					val.RecalculateMasking();
				}
			}
		}

		private void Move(RectTransform item, Transform target)
		{
			if (Object.op_Implicit((Object)(object)item) && !((Transform)item).IsChildOf(target))
			{
				_moved.Add(new Layout(item));
				((Transform)item).SetParent(target, true);
			}
		}

		public void Dispose()
		{
			for (int num = _moved.Count - 1; num >= 0; num--)
			{
				_moved[num].Restore();
			}
			_moved.Clear();
			foreach (Graphic hiddenFrame in _hiddenFrames)
			{
				if (Object.op_Implicit((Object)(object)hiddenFrame))
				{
					((Behaviour)hiddenFrame).enabled = true;
				}
			}
			_hiddenFrames.Clear();
			foreach (var item in _outside)
			{
				if (Object.op_Implicit((Object)(object)item.Graphic))
				{
					item.Graphic.maskable = item.Maskable;
					item.Graphic.RecalculateMasking();
				}
			}
			_outside.Clear();
			if (Object.op_Implicit((Object)(object)_clip) && Object.op_Implicit((Object)(object)_map) && Object.op_Implicit((Object)(object)_map.m_mapImageSmall))
			{
				((MaskableGraphic)_map.m_mapImageSmall).maskable = _mapMaskable;
				((MaskableGraphic)_map.m_mapImageSmall).RecalculateMasking();
			}
			if (Object.op_Implicit((Object)(object)_clip))
			{
				_clip.SetActive(false);
				Object.Destroy((Object)(object)_clip);
			}
			_clip = null;
		}
	}
	public sealed class MapUvRotation : BaseMeshEffect
	{
		private float _heading;

		internal void SetHeading(float value)
		{
			if (!Mathf.Approximately(value, _heading))
			{
				_heading = value;
				if (Object.op_Implicit((Object)(object)((BaseMeshEffect)this).graphic))
				{
					((BaseMeshEffect)this).graphic.SetVerticesDirty();
				}
			}
		}

		public override void ModifyMesh(VertexHelper mesh)
		{
			//IL_0030: 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_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: 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_0075: 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_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: 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_00b5: 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)
			if (!((UIBehaviour)this).IsActive() || Mathf.Approximately(_heading, 0f))
			{
				return;
			}
			Graphic graphic = ((BaseMeshEffect)this).graphic;
			RawImage val = (RawImage)(object)((graphic is RawImage) ? graphic : null);
			if (val == null)
			{
				return;
			}
			Rect rect = ((Graphic)val).rectTransform.rect;
			Rect uvRect = val.uvRect;
			if (!(((Rect)(ref rect)).width <= 0f) && !(((Rect)(ref rect)).height <= 0f))
			{
				UIVertex val2 = default(UIVertex);
				for (int i = 0; i < mesh.currentVertCount; i++)
				{
					mesh.PopulateUIVertex(ref val2, i);
					(double, double) tuple = MapMath.ScreenToMap(val2.position.x - ((Rect)(ref rect)).center.x, val2.position.y - ((Rect)(ref rect)).center.y, ((Rect)(ref uvRect)).center.x, ((Rect)(ref uvRect)).center.y, ((Rect)(ref uvRect)).width, ((Rect)(ref uvRect)).height, ((Rect)(ref rect)).width, ((Rect)(ref rect)).height, _heading);
					val2.uv0.x = (float)tuple.Item1;
					val2.uv0.y = (float)tuple.Item2;
					mesh.SetUIVertex(val2, i);
				}
			}
		}
	}
	internal static class MinimapProjection
	{
		public static bool TryProject(Minimap map, RawImage image, Vector3 world, float heading, out Vector2 point)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: 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)
			//IL_0103: 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)
			point = Vector2.zero;
			Rect uvRect = image.uvRect;
			Rect rect = ((Graphic)image).rectTransform.rect;
			if (((Rect)(ref uvRect)).width <= 0f || ((Rect)(ref uvRect)).height <= 0f || ((Rect)(ref rect)).width <= 0f || ((Rect)(ref rect)).height <= 0f || map.m_pixelSize <= 0f || map.m_textureSize <= 0)
			{
				return false;
			}
			double u = (world.x / map.m_pixelSize + (float)(map.m_textureSize / 2)) / (float)map.m_textureSize;
			double v = (world.z / map.m_pixelSize + (float)(map.m_textureSize / 2)) / (float)map.m_textureSize;
			(double, double) tuple = MapMath.MapToScreen(u, v, ((Rect)(ref uvRect)).center.x, ((Rect)(ref uvRect)).center.y, ((Rect)(ref uvRect)).width, ((Rect)(ref uvRect)).height, ((Rect)(ref rect)).width, ((Rect)(ref rect)).height, heading);
			point = new Vector2((float)tuple.Item1, (float)tuple.Item2);
			return true;
		}
	}
	internal sealed class MinimapVisibility : IDisposable
	{
		private readonly GameObject _root;

		private CanvasGroup? _group;

		private bool _owned;

		private bool _hidden;

		private bool _interactable;

		private bool _blocksRaycasts;

		private float _alpha;

		public MinimapVisibility(Minimap map)
		{
			_root = map.m_smallRoot;
		}

		public void Apply(bool visible)
		{
			if (visible)
			{
				Restore();
			}
			else
			{
				if (!Object.op_Implicit((Object)(object)_root))
				{
					return;
				}
				if (!Object.op_Implicit((Object)(object)_group))
				{
					_group = _root.GetComponent<CanvasGroup>();
					_owned = !Object.op_Implicit((Object)(object)_group);
					if (_owned)
					{
						_group = _root.AddComponent<CanvasGroup>();
					}
				}
				if (!_hidden)
				{
					_alpha = _group.alpha;
					_interactable = _group.interactable;
					_blocksRaycasts = _group.blocksRaycasts;
					_hidden = true;
				}
				_group.alpha = 0f;
				_group.interactable = false;
				_group.blocksRaycasts = false;
			}
		}

		private void Restore()
		{
			if (_hidden)
			{
				if (Object.op_Implicit((Object)(object)_group))
				{
					_group.alpha = _alpha;
					_group.interactable = _interactable;
					_group.blocksRaycasts = _blocksRaycasts;
				}
				_hidden = false;
			}
		}

		public void Dispose()
		{
			Restore();
			if (_owned && Object.op_Implicit((Object)(object)_group))
			{
				Object.Destroy((Object)(object)_group);
			}
			_group = null;
			_owned = false;
		}
	}
	internal static class ModManagerBridge
	{
		private static FieldInfo? _pageField;

		private static FieldInfo? _contentField;

		private static MethodInfo? _buildPage;

		private static MethodInfo? _setPending;

		private static MethodInfo? _makeButton;

		private static MethodInfo? _endCapture;

		private static MethodInfo? _addText;

		private static int _presetIndex = -1;

		private static FieldInfo? _saveField;

		private static FieldInfo? _statusField;

		private static Harmony? _harmony;

		private static bool _available;

		private static bool _resetZoomPending;

		public static void Install()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			Uninstall();
			Type type = AccessTools.TypeByName("StoreAndCraft.ModManagerPanel");
			if (type == null)
			{
				return;
			}
			_harmony = new Harmony("net.shtab.rotatingminimap.settings");
			try
			{
				MethodInfo methodInfo = RequireMethod(type, "BuildPage");
				MethodInfo methodInfo2 = RequireMethod(type, "BuildNumber", typeof(RectTransform), typeof(ConfigEntryBase), typeof(bool), typeof(double), typeof(double), typeof(bool));
				MethodInfo methodInfo3 = RequireMethod(type, "SetPending", typeof(ConfigEntryBase), typeof(object));
				MethodInfo methodInfo4 = RequireMethod(typeof(Slider), "Set", typeof(float), typeof(bool));
				MethodInfo methodInfo5 = RequireMethod(type, "ValueText", typeof(ConfigEntryBase), typeof(object));
				MethodInfo methodInfo6 = RequireMethod(type, "AddEntryRow", typeof(ConfigEntryBase));
				MethodInfo methodInfo7 = RequireMethod(type, "AddHeader", typeof(string));
				_addText = RequireMethod(type, "AddText", typeof(string), typeof(Color), typeof(float));
				MethodInfo methodInfo8 = RequireMethod(type, "Save");
				MethodInfo methodInfo9 = RequireMethod(type, "Rebuild");
				MethodInfo methodInfo10 = RequireMethod(type, "Close");
				_pageField = RequireField(type, "_page");
				if (RequireField(_pageField.FieldType, "Entries").FieldType != typeof(List<ConfigEntryBase>))
				{
					throw new MissingFieldException("Entries type");
				}
				_contentField = RequireField(type, "_content", typeof(RectTransform));
				_saveField = RequireField(type, "_save", typeof(Button));
				_statusField = RequireField(type, "_status", typeof(TextMeshProUGUI));
				_endCapture = RequireMethod(type, "EndCapture");
				_makeButton = RequireMethod(AccessTools.TypeByName("StoreAndCraft.SettingsPanel") ?? throw new TypeLoadException("SettingsPanel"), "MakeButton", typeof(RectTransform), typeof(string), typeof(string), typeof(UnityAction));
				if (_makeButton.ReturnType != typeof(Button))
				{
					throw new MissingMethodException("MakeButton return type");
				}
				MethodInfo methodInfo11 = RequireMethod(AccessTools.TypeByName("StoreAndCraft.Loc") ?? throw new TypeLoadException("Loc"), "T", typeof(string), typeof(string));
				_buildPage = methodInfo;
				_setPending = methodInfo3;
				_harmony.Patch((MethodBase)methodInfo, Patch("SortPage"), Patch("AddResetButton"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				_harmony.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, Patch("MarkSlider"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				_harmony.Patch((MethodBase)methodInfo3, Patch("RoundPending"), Patch("KeepResetSaveEnabled"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				_harmony.Patch((MethodBase)methodInfo4, Patch("SnapSlider"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				_harmony.Patch((MethodBase)methodInfo5, (HarmonyMethod)null, Patch("TranslateChoice"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				_harmony.Patch((MethodBase)methodInfo6, (HarmonyMethod)null, Patch("TranslateRow"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				_harmony.Patch((MethodBase)methodInfo7, Patch("TranslateHeader"), Patch("AddSectionHint"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				_harmony.Patch((MethodBase)methodInfo11, (HarmonyMethod)null, Patch("TranslatePanelText"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				_harmony.Patch((MethodBase)methodInfo8, (HarmonyMethod)null, Patch("AfterSave"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				_harmony.Patch((MethodBase)methodInfo9, Patch("CancelReset"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				_harmony.Patch((MethodBase)methodInfo10, Patch("CancelReset"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				_available = true;
			}
			catch
			{
				Uninstall();
				throw;
			}
		}

		private static MethodInfo RequireMethod(Type type, string name, params Type[] args)
		{
			return AccessTools.Method(type, name, args, (Type[])null) ?? throw new MissingMethodException(type.FullName, name);
		}

		private static FieldInfo RequireField(Type type, string name, Type? expected = null)
		{
			FieldInfo fieldInfo = AccessTools.Field(type, name) ?? throw new MissingFieldException(type.FullName, name);
			if (expected != null && fieldInfo.FieldType != expected)
			{
				throw new MissingFieldException(type.FullName, name);
			}
			return fieldInfo;
		}

		public static void Uninstall()
		{
			_available = false;
			CancelReset();
			Harmony? harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			_harmony = null;
		}

		private static void Safe(Action action)
		{
			if (!_available)
			{
				return;
			}
			try
			{
				action();
			}
			catch (Exception error)
			{
				try
				{
					Uninstall();
				}
				catch (Exception error2)
				{
					Plugin.Instance?.WarnSettings(error2);
				}
				Plugin.Instance?.WarnSettings(error);
			}
		}

		private static HarmonyMethod Patch(string method)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			return new HarmonyMethod(typeof(ModManagerBridge), method, (Type[])null);
		}

		private static bool Own(ConfigEntryBase entry)
		{
			if ((Object)(object)Plugin.Instance != (Object)null)
			{
				return entry.ConfigFile == ((BaseUnityPlugin)Plugin.Instance).Config;
			}
			return false;
		}

		private static bool ZoomNumber(ConfigEntryBase entry)
		{
			if (Own(entry) && entry.SettingType == typeof(float))
			{
				if (!(entry.Definition.Section == "3. Масштаб и управление"))
				{
					return entry.Definition.Key == "Толщина линии";
				}
				return true;
			}
			return false;
		}

		private static List<ConfigEntryBase>? OwnEntries()
		{
			object obj = _pageField?.GetValue(null);
			if (obj == null)
			{
				return null;
			}
			if (!(AccessTools.Field(obj.GetType(), "Entries")?.GetValue(obj) is List<ConfigEntryBase> { Count: not 0 } list) || list.Exists((ConfigEntryBase entry) => !Own(entry)))
			{
				return null;
			}
			return list;
		}

		private static void AddResetButton()
		{
			Safe(AddResetButtonCore);
		}

		private static void AddResetButtonCore()
		{
			if (OwnEntries() != null && !(_makeButton == null))
			{
				object? obj = _contentField?.GetValue(null);
				RectTransform val = (RectTransform)((obj is RectTransform) ? obj : null);
				if (Object.op_Implicit((Object)(object)val))
				{
					AddPresetButton(val, vanilla: true, _presetIndex);
					AddPresetButton(val, vanilla: false, (_presetIndex < 0) ? (-1) : (_presetIndex + 1));
				}
			}
		}

		private static void AddPresetButton(RectTransform content, bool vanilla, int siblingIndex)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Expected O, but got Unknown
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Expected O, but got Unknown
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("BetterMinimapResetDefaults", new Type[2]
			{
				typeof(RectTransform),
				typeof(LayoutElement)
			});
			val.transform.SetParent((Transform)(object)content, false);
			if (siblingIndex >= 0)
			{
				val.transform.SetSiblingIndex(siblingIndex);
			}
			LayoutElement component = val.GetComponent<LayoutElement>();
			float minHeight = (component.preferredHeight = 54f);
			component.minHeight = minHeight;
			component.flexibleWidth = 1f;
			object? obj = _makeButton.Invoke(null, new object[4]
			{
				(object)(RectTransform)val.transform,
				vanilla ? "ResetVanilla" : "ResetModDefaults",
				SettingsText.ResetLabel(vanilla, UiLanguage.Russian),
				(object)(UnityAction)delegate
				{
					ResetDefaults(vanilla);
				}
			});
			Button val2 = (Button)((obj is Button) ? obj : null);
			if (!Object.op_Implicit((Object)(object)val2))
			{
				Object.Destroy((Object)(object)val);
				return;
			}
			RectTransform val3 = (RectTransform)((Component)val2).transform;
			val3.anchorMin = Vector2.zero;
			val3.anchorMax = Vector2.one;
			val3.offsetMin = new Vector2(8f, 4f);
			val3.offsetMax = new Vector2(-8f, -4f);
		}

		private static void ResetDefaults(bool vanilla)
		{
			Safe(delegate
			{
				ResetDefaultsCore(vanilla);
			});
		}

		private static void ResetDefaultsCore(bool vanilla)
		{
			List<ConfigEntryBase> list = OwnEntries();
			object? obj = _contentField?.GetValue(null);
			RectTransform val = (RectTransform)((obj is RectTransform) ? obj : null);
			if (list == null || !Object.op_Implicit((Object)(object)val) || _setPending == null || _buildPage == null)
			{
				return;
			}
			_endCapture?.Invoke(null, null);
			_resetZoomPending = true;
			foreach (ConfigEntryBase item in list)
			{
				if (ResetPreset.Includes(item.Definition.Key))
				{
					_setPending.Invoke(null, new object[2]
					{
						item,
						ResetPreset.Value(item.Definition.Key, item.DefaultValue, vanilla)
					});
				}
			}
			for (int num = ((Transform)val).childCount - 1; num >= 0; num--)
			{
				GameObject gameObject = ((Component)((Transform)val).GetChild(num)).gameObject;
				gameObject.SetActive(false);
				Object.Destroy((Object)(object)gameObject);
			}
			_buildPage.Invoke(null, null);
			LayoutRebuilder.ForceRebuildLayoutImmediate(val);
			ScrollRect componentInParent = ((Component)val).GetComponentInParent<ScrollRect>();
			if (Object.op_Implicit((Object