Decompiled source of EvuMinimap v0.2.2

EvuMinimap.Core.dll

Decompiled 3 days ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("evu")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Copyright (c) 2026 imevul")]
[assembly: AssemblyDescription("Client-side Valheim minimap size and position.")]
[assembly: AssemblyFileVersion("0.2.2.0")]
[assembly: AssemblyInformationalVersion("0.2.2+d3816e2d1241111eed9dd9359c792d714464ad7e")]
[assembly: AssemblyProduct("EvuMinimap")]
[assembly: AssemblyTitle("EvuMinimap.Core")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/EvuMods/EvuMinimap")]
[assembly: AssemblyVersion("0.2.2.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class IsReadOnlyAttribute : Attribute
	{
	}
	[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 EvuMinimap.Core
{
	public static class AppearanceMath
	{
		public const float MinAspect = 0.5f;

		public const float MaxAspect = 2f;

		public static float ClampAlpha(float alpha)
		{
			if (float.IsNaN(alpha) || alpha < 0f)
			{
				return 0f;
			}
			if (alpha > 1f)
			{
				return 1f;
			}
			return alpha;
		}

		public static float ClampCornerRadius(float radius)
		{
			if (float.IsNaN(radius) || radius < 0f)
			{
				return 0f;
			}
			if (radius > 1f)
			{
				return 1f;
			}
			return radius;
		}

		public static float ClampAspect(float aspect)
		{
			if (float.IsNaN(aspect) || aspect < 0.5f)
			{
				return 0.5f;
			}
			if (aspect > 2f)
			{
				return 2f;
			}
			return aspect;
		}

		public static ClipWindow ClipWindowFor(float aspect)
		{
			aspect = ClampAspect(aspect);
			if (aspect >= 1f)
			{
				float num = 1f / aspect;
				return new ClipWindow(0f, (1f - num) * 0.5f, 1f, num);
			}
			float num2 = aspect;
			return new ClipWindow((1f - num2) * 0.5f, 0f, num2, 1f);
		}
	}
	public readonly struct ClipWindow
	{
		public float X { get; }

		public float Y { get; }

		public float Width { get; }

		public float Height { get; }

		public ClipWindow(float x, float y, float width, float height)
		{
			X = x;
			Y = y;
			Width = width;
			Height = height;
		}
	}
	public enum ClearanceSide
	{
		Left,
		Below
	}
	public static class BuffPlacement
	{
		private enum Side
		{
			Below,
			Above,
			Left,
			Right
		}

		public const float Gap = 8f;

		public static HudRect Place(HudRect map, HudRect vanillaBuffs, ParentRect parent, bool reposition, ClearanceSide prefer = ClearanceSide.Left)
		{
			return Place(map, map, vanillaBuffs, parent, reposition, prefer);
		}

		public static HudRect Place(HudRect map, HudRect blocking, HudRect vanillaBuffs, ParentRect parent, bool reposition, ClearanceSide prefer)
		{
			if (!reposition || !blocking.Intersects(vanillaBuffs, 8f))
			{
				return vanillaBuffs;
			}
			if (prefer == ClearanceSide.Below)
			{
				HudRect hudRect = Slide(vanillaBuffs, vanillaBuffs.X, map.Y - 8f - vanillaBuffs.Height);
				if (Fits(hudRect, map, parent))
				{
					return hudRect;
				}
			}
			else
			{
				HudRect hudRect2 = Slide(vanillaBuffs, map.X - 8f - vanillaBuffs.Width, vanillaBuffs.Y);
				if (Fits(hudRect2, map, parent))
				{
					return hudRect2;
				}
			}
			HudRect below = Slide(vanillaBuffs, vanillaBuffs.X, map.Y - 8f - vanillaBuffs.Height);
			HudRect above = Slide(vanillaBuffs, vanillaBuffs.X, map.Top + 8f);
			HudRect right = Slide(vanillaBuffs, map.Right + 8f, vanillaBuffs.Y);
			if (TryBestFit(map, parent, below, above, right, out var placed))
			{
				return placed;
			}
			return Roomiest(map, vanillaBuffs, parent);
		}

		private static bool TryBestFit(HudRect map, ParentRect parent, HudRect below, HudRect above, HudRect right, out HudRect placed)
		{
			placed = default(HudRect);
			bool found = false;
			float bestSpace = float.NegativeInfinity;
			Consider(below, FreeBelow(map, parent), map, parent, ref found, ref bestSpace, ref placed);
			Consider(above, FreeAbove(map, parent), map, parent, ref found, ref bestSpace, ref placed);
			Consider(right, FreeRight(map, parent), map, parent, ref found, ref bestSpace, ref placed);
			return found;
		}

		private static void Consider(HudRect candidate, float space, HudRect map, ParentRect parent, ref bool found, ref float bestSpace, ref HudRect placed)
		{
			if (Fits(candidate, map, parent) && !(space < bestSpace))
			{
				found = true;
				bestSpace = space;
				placed = candidate;
			}
		}

		private static HudRect Roomiest(HudRect map, HudRect vanillaBuffs, ParentRect parent)
		{
			float num = FreeBelow(map, parent);
			float num2 = FreeAbove(map, parent);
			float num3 = FreeLeft(map, parent);
			float num4 = FreeRight(map, parent);
			float num5 = num3;
			Side side = Side.Left;
			if (num > num5)
			{
				num5 = num;
				side = Side.Below;
			}
			if (num2 > num5)
			{
				num5 = num2;
				side = Side.Above;
			}
			if (num4 > num5)
			{
				side = Side.Right;
			}
			float width = vanillaBuffs.Width;
			float height = vanillaBuffs.Height;
			float x;
			float y;
			switch (side)
			{
			case Side.Above:
				x = map.X + (map.Width - width) * 0.5f;
				y = map.Top + 8f;
				break;
			case Side.Left:
				x = map.X - 8f - width;
				y = map.Y + (map.Height - height) * 0.5f;
				break;
			case Side.Right:
				x = map.Right + 8f;
				y = map.Y + (map.Height - height) * 0.5f;
				break;
			default:
				x = map.X + (map.Width - width) * 0.5f;
				y = map.Y - 8f - height;
				break;
			}
			return Clamp(new HudRect(x, y, width, height), parent);
		}

		private static HudRect Clamp(HudRect rect, ParentRect parent)
		{
			float num = rect.X;
			float num2 = rect.Y;
			if (rect.Width <= parent.Width)
			{
				if (num < parent.X)
				{
					num = parent.X;
				}
				if (num + rect.Width > parent.Right)
				{
					num = parent.Right - rect.Width;
				}
			}
			else
			{
				num = parent.X;
			}
			if (rect.Height <= parent.Height)
			{
				if (num2 < parent.Y)
				{
					num2 = parent.Y;
				}
				if (num2 + rect.Height > parent.Top)
				{
					num2 = parent.Top - rect.Height;
				}
			}
			else
			{
				num2 = parent.Y;
			}
			return new HudRect(num, num2, rect.Width, rect.Height);
		}

		private static HudRect Slide(HudRect buff, float x, float y)
		{
			return new HudRect(x, y, buff.Width, buff.Height);
		}

		private static bool Fits(HudRect candidate, HudRect map, ParentRect parent)
		{
			if (candidate.FitsInside(parent))
			{
				return !candidate.Intersects(map, 8f);
			}
			return false;
		}

		private static float FreeBelow(HudRect map, ParentRect parent)
		{
			return map.Y - parent.Y;
		}

		private static float FreeAbove(HudRect map, ParentRect parent)
		{
			return parent.Top - map.Top;
		}

		private static float FreeLeft(HudRect map, ParentRect parent)
		{
			return map.X - parent.X;
		}

		private static float FreeRight(HudRect map, ParentRect parent)
		{
			return parent.Right - map.Right;
		}
	}
	public readonly struct HudRect
	{
		public float X { get; }

		public float Y { get; }

		public float Width { get; }

		public float Height { get; }

		public float Right => X + Width;

		public float Top => Y + Height;

		public HudRect(float x, float y, float width, float height)
		{
			X = x;
			Y = y;
			Width = width;
			Height = height;
		}

		public bool Intersects(HudRect other, float margin)
		{
			if (X - margin < other.Right - 0.5f && Right + margin > other.X + 0.5f && Y - margin < other.Top - 0.5f)
			{
				return Top + margin > other.Y + 0.5f;
			}
			return false;
		}

		public bool FitsInside(ParentRect parent)
		{
			if (X >= parent.X - 0.01f && Y >= parent.Y - 0.01f && Right <= parent.Right + 0.01f)
			{
				return Top <= parent.Top + 0.01f;
			}
			return false;
		}
	}
	public static class LayoutSolver
	{
		public static RectLayout Solve(VanillaLayout vanilla, ParentRect parent, MinimapProfile profile)
		{
			profile.Anchor.ToFractions(out var x, out var y);
			HudRect hudRect = Bounds(parent, ToLayout(vanilla));
			float num = hudRect.X + hudRect.Width * x + profile.OffsetX;
			float num2 = hudRect.Y + hudRect.Height * y + profile.OffsetY;
			parent.AnchorReference(x, y, out var x2, out var y2);
			return new RectLayout(x, y, x, y, num - x2, num2 - y2, vanilla.Width, vanilla.Height, vanilla.ScaleX * profile.Scale, vanilla.ScaleY * profile.Scale);
		}

		public static HudRect Bounds(ParentRect parent, RectLayout layout)
		{
			return Bounds(parent, new RectFields(layout.AnchorX, layout.AnchorY, layout.AnchorX, layout.AnchorY, layout.PivotX, layout.PivotY, layout.AnchoredX, layout.AnchoredY, layout.Width, layout.Height, layout.ScaleX, layout.ScaleY));
		}

		public static HudRect Bounds(ParentRect parent, RectFields fields)
		{
			float num = parent.X + parent.Width * fields.AnchorMinX;
			float num2 = parent.Y + parent.Height * fields.AnchorMinY;
			float num3 = parent.X + parent.Width * fields.AnchorMaxX;
			float num4 = parent.Y + parent.Height * fields.AnchorMaxY;
			float num5 = (num + num3) * 0.5f;
			float num6 = (num2 + num4) * 0.5f;
			float num7 = num5 + fields.AnchoredX;
			float num8 = num6 + fields.AnchoredY;
			float num9 = (num3 - num + fields.Width) * fields.ScaleX;
			float num10 = (num4 - num2 + fields.Height) * fields.ScaleY;
			return new HudRect(num7 - fields.PivotX * num9, num8 - fields.PivotY * num10, num9, num10);
		}

		private static RectLayout ToLayout(VanillaLayout vanilla)
		{
			return new RectLayout(vanilla.AnchorX, vanilla.AnchorY, vanilla.PivotX, vanilla.PivotY, vanilla.AnchoredX, vanilla.AnchoredY, vanilla.Width, vanilla.Height, vanilla.ScaleX, vanilla.ScaleY);
		}
	}
	public enum MapAnchor
	{
		TopLeft,
		Top,
		TopRight,
		Left,
		Center,
		Right,
		BottomLeft,
		Bottom,
		BottomRight
	}
	public static class MapAnchorMath
	{
		public static void ToFractions(this MapAnchor anchor, out float x, out float y)
		{
			switch (anchor)
			{
			case MapAnchor.TopLeft:
				x = 0f;
				y = 1f;
				break;
			case MapAnchor.Top:
				x = 0.5f;
				y = 1f;
				break;
			case MapAnchor.TopRight:
				x = 1f;
				y = 1f;
				break;
			case MapAnchor.Left:
				x = 0f;
				y = 0.5f;
				break;
			case MapAnchor.Center:
				x = 0.5f;
				y = 0.5f;
				break;
			case MapAnchor.Right:
				x = 1f;
				y = 0.5f;
				break;
			case MapAnchor.BottomLeft:
				x = 0f;
				y = 0f;
				break;
			case MapAnchor.Bottom:
				x = 0.5f;
				y = 0f;
				break;
			case MapAnchor.BottomRight:
				x = 1f;
				y = 0f;
				break;
			default:
				throw new ArgumentOutOfRangeException("anchor", anchor, "Unknown map anchor.");
			}
		}
	}
	public enum MapShape
	{
		None,
		Oval,
		Rectangle
	}
	public readonly struct MinimapProfile
	{
		public static MinimapProfile Vanilla { get; } = new MinimapProfile(MapAnchor.TopRight, 0f, 0f, 1f, repositionBuffs: true);

		public MapAnchor Anchor { get; }

		public float OffsetX { get; }

		public float OffsetY { get; }

		public float Scale { get; }

		public bool RepositionBuffs { get; }

		public bool RepositionShipHud { get; }

		public MapShape Shape { get; }

		public float Alpha { get; }

		public float CornerRadius { get; }

		public float Aspect { get; }

		public MinimapProfile(MapAnchor anchor, float offsetX, float offsetY, float scale, bool repositionBuffs)
			: this(anchor, offsetX, offsetY, scale, repositionBuffs, MapShape.None, 1f, 0f, 1f)
		{
		}

		public MinimapProfile(MapAnchor anchor, float offsetX, float offsetY, float scale, bool repositionBuffs, MapShape shape, float alpha, float cornerRadius, float aspect, bool repositionShipHud = true)
		{
			Anchor = anchor;
			OffsetX = offsetX;
			OffsetY = offsetY;
			Scale = ScaleMath.Clamp(scale);
			RepositionBuffs = repositionBuffs;
			RepositionShipHud = repositionShipHud;
			Shape = shape;
			Alpha = AppearanceMath.ClampAlpha(alpha);
			CornerRadius = AppearanceMath.ClampCornerRadius(cornerRadius);
			Aspect = AppearanceMath.ClampAspect(aspect);
		}

		public MinimapProfile WithScale(float scale)
		{
			return new MinimapProfile(Anchor, OffsetX, OffsetY, scale, RepositionBuffs, Shape, Alpha, CornerRadius, Aspect, RepositionShipHud);
		}
	}
	public readonly struct ParentRect
	{
		public float X { get; }

		public float Y { get; }

		public float Width { get; }

		public float Height { get; }

		public float Right => X + Width;

		public float Top => Y + Height;

		public ParentRect(float x, float y, float width, float height)
		{
			X = x;
			Y = y;
			Width = width;
			Height = height;
		}

		public void AnchorReference(float anchorX, float anchorY, out float x, out float y)
		{
			x = X + Width * anchorX;
			y = Y + Height * anchorY;
		}
	}
	public static class ProfileIndex
	{
		public const int Count = 5;

		public static int Clamp(int index)
		{
			if (index < 1)
			{
				return 1;
			}
			if (index > 5)
			{
				return 5;
			}
			return index;
		}

		public static int Cycle(int active, int direction)
		{
			int num = Clamp(active) - 1;
			int num2 = ((direction >= 0) ? 1 : (-1));
			int num3 = (num + num2) % 5;
			if (num3 < 0)
			{
				num3 += 5;
			}
			return num3 + 1;
		}
	}
	public readonly struct RectFields
	{
		public float AnchorMinX { get; }

		public float AnchorMinY { get; }

		public float AnchorMaxX { get; }

		public float AnchorMaxY { get; }

		public float PivotX { get; }

		public float PivotY { get; }

		public float AnchoredX { get; }

		public float AnchoredY { get; }

		public float Width { get; }

		public float Height { get; }

		public float ScaleX { get; }

		public float ScaleY { get; }

		public RectFields(float anchorMinX, float anchorMinY, float anchorMaxX, float anchorMaxY, float pivotX, float pivotY, float anchoredX, float anchoredY, float width, float height, float scaleX, float scaleY)
		{
			AnchorMinX = anchorMinX;
			AnchorMinY = anchorMinY;
			AnchorMaxX = anchorMaxX;
			AnchorMaxY = anchorMaxY;
			PivotX = pivotX;
			PivotY = pivotY;
			AnchoredX = anchoredX;
			AnchoredY = anchoredY;
			Width = width;
			Height = height;
			ScaleX = scaleX;
			ScaleY = scaleY;
		}
	}
	public readonly struct RectLayout
	{
		public float AnchorX { get; }

		public float AnchorY { get; }

		public float PivotX { get; }

		public float PivotY { get; }

		public float AnchoredX { get; }

		public float AnchoredY { get; }

		public float Width { get; }

		public float Height { get; }

		public float ScaleX { get; }

		public float ScaleY { get; }

		public RectLayout(float anchorX, float anchorY, float pivotX, float pivotY, float anchoredX, float anchoredY, float width, float height, float scaleX, float scaleY)
		{
			AnchorX = anchorX;
			AnchorY = anchorY;
			PivotX = pivotX;
			PivotY = pivotY;
			AnchoredX = anchoredX;
			AnchoredY = anchoredY;
			Width = width;
			Height = height;
			ScaleX = scaleX;
			ScaleY = scaleY;
		}

		public bool Approximately(RectLayout other, float epsilon = 0.01f)
		{
			if (Near(AnchorX, other.AnchorX, epsilon) && Near(AnchorY, other.AnchorY, epsilon) && Near(PivotX, other.PivotX, epsilon) && Near(PivotY, other.PivotY, epsilon) && Near(AnchoredX, other.AnchoredX, epsilon) && Near(AnchoredY, other.AnchoredY, epsilon) && Near(Width, other.Width, epsilon) && Near(Height, other.Height, epsilon) && Near(ScaleX, other.ScaleX, epsilon))
			{
				return Near(ScaleY, other.ScaleY, epsilon);
			}
			return false;
		}

		private static bool Near(float a, float b, float epsilon)
		{
			float num = a - b;
			if (num < 0f)
			{
				num = 0f - num;
			}
			return num <= epsilon;
		}
	}
	public static class ScaleMath
	{
		public const float Min = 0.5f;

		public const float Max = 5f;

		public const float DefaultStep = 0.25f;

		public static float Clamp(float scale)
		{
			if (float.IsNaN(scale) || scale < 0.5f)
			{
				return 0.5f;
			}
			if (scale > 5f)
			{
				return 5f;
			}
			return scale;
		}

		public static float Step(float scale, float step, int direction)
		{
			float num = Math.Abs(step);
			if (num <= 0f || float.IsNaN(num))
			{
				num = 0.25f;
			}
			float num2 = ((direction < 0) ? (-1f) : 1f);
			return Clamp(scale + num2 * num);
		}
	}
	public static class ShapeKey
	{
		public static int For(MapShape shape, float cornerRadius, float aspect)
		{
			int num = ((shape == MapShape.Oval) ? 100 : ((int)Math.Round(AppearanceMath.ClampCornerRadius(cornerRadius) * 100f)));
			int num2 = (int)Math.Round(AppearanceMath.ClampAspect(aspect) * 100f);
			return (int)shape * 1000000 + num * 1000 + num2;
		}
	}
	public readonly struct VanillaLayout
	{
		public float AnchorX { get; }

		public float AnchorY { get; }

		public float PivotX { get; }

		public float PivotY { get; }

		public float AnchoredX { get; }

		public float AnchoredY { get; }

		public float Width { get; }

		public float Height { get; }

		public float ScaleX { get; }

		public float ScaleY { get; }

		public VanillaLayout(float anchorX, float anchorY, float pivotX, float pivotY, float anchoredX, float anchoredY, float width, float height, float scaleX, float scaleY)
		{
			AnchorX = anchorX;
			AnchorY = anchorY;
			PivotX = pivotX;
			PivotY = pivotY;
			AnchoredX = anchoredX;
			AnchoredY = anchoredY;
			Width = width;
			Height = height;
			ScaleX = scaleX;
			ScaleY = scaleY;
		}
	}
}

EvuMinimap.dll

Decompiled 3 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using EvuMinimap.Core;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("assembly_valheim")]
[assembly: AssemblyCompany("evu")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Copyright (c) 2026 imevul")]
[assembly: AssemblyDescription("Client-side Valheim minimap size and position.")]
[assembly: AssemblyFileVersion("0.2.2.0")]
[assembly: AssemblyInformationalVersion("0.2.2+d3816e2d1241111eed9dd9359c792d714464ad7e")]
[assembly: AssemblyProduct("EvuMinimap")]
[assembly: AssemblyTitle("EvuMinimap")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/EvuMods/EvuMinimap")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.2.2.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace EvuMinimap
{
	internal static class BuffLayoutMods
	{
		private static readonly string[] Ids = new string[2] { "randyknapp.mods.minimalstatuseffects", "redseiko.valheim.statusquo" };

		public static bool BlocksBuffMove(out string mod)
		{
			Dictionary<string, PluginInfo> pluginInfos = Chainloader.PluginInfos;
			for (int i = 0; i < Ids.Length; i++)
			{
				if (pluginInfos.ContainsKey(Ids[i]))
				{
					mod = Ids[i];
					return true;
				}
			}
			mod = string.Empty;
			return false;
		}
	}
	internal sealed class ConfigurationManagerAttributes
	{
		public delegate void CustomHotkeyDrawerFunc(ConfigEntryBase setting, ref bool isCurrentlyAcceptingInput);

		public bool? ShowRangeAsPercent;

		public Action<ConfigEntryBase> CustomDrawer;

		public CustomHotkeyDrawerFunc CustomHotkeyDrawer;

		public bool? Browsable;

		public string Category;

		public object DefaultValue;

		public bool? HideDefaultButton;

		public bool? HideSettingName;

		public string Description;

		public string DispName;

		public int? Order;

		public bool? ReadOnly;

		public bool? IsAdvanced;

		public Func<object, string> ObjToStr;

		public Func<string, object> StrToObj;
	}
	internal static class HotkeyInput
	{
		private static readonly KeyCode[] WatchedModifiers;

		public static bool WasPressed(KeyboardShortcut shortcut)
		{
			//IL_0002: 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_002c: Unknown result type (might be due to invalid IL or missing references)
			if ((int)((KeyboardShortcut)(ref shortcut)).MainKey == 0 || !Input.GetKeyDown(((KeyboardShortcut)(ref shortcut)).MainKey))
			{
				return false;
			}
			List<KeyCode> list = new List<KeyCode>(((KeyboardShortcut)(ref shortcut)).Modifiers);
			for (int i = 0; i < list.Count; i++)
			{
				if (!IsHeld(list[i]))
				{
					return false;
				}
			}
			return !ExtraModifierHeld(list);
		}

		private static bool IsHeld(KeyCode key)
		{
			//IL_0000: 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)
			if (IsAlt(key))
			{
				if (!Input.GetKey((KeyCode)308))
				{
					return Input.GetKey((KeyCode)307);
				}
				return true;
			}
			return Input.GetKey(key);
		}

		private static bool ExtraModifierHeld(IEnumerable<KeyCode> configured)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			bool flag = false;
			foreach (KeyCode item in configured)
			{
				if (IsAlt(item))
				{
					flag = true;
					break;
				}
			}
			for (int i = 0; i < WatchedModifiers.Length; i++)
			{
				KeyCode val = WatchedModifiers[i];
				if (Input.GetKey(val) && !Contains(configured, val) && (!flag || !IsAlt(val)))
				{
					return true;
				}
			}
			return false;
		}

		private static bool Contains(IEnumerable<KeyCode> keys, KeyCode key)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			foreach (KeyCode key2 in keys)
			{
				if (key2 == key)
				{
					return true;
				}
			}
			return false;
		}

		private static bool IsAlt(KeyCode key)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Invalid comparison between Unknown and I4
			if ((int)key != 308)
			{
				return (int)key == 307;
			}
			return true;
		}

		static HotkeyInput()
		{
			KeyCode[] array = new KeyCode[8];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			WatchedModifiers = (KeyCode[])(object)array;
		}
	}
	internal sealed class MinimapApplier
	{
		private readonly PluginConfig _config;

		private readonly ManualLogSource _log;

		private bool _checkedConflicts;

		private bool _moveBuffs = true;

		private bool _capturedMap;

		private const float BuffVisualPad = 18f;

		private GameObject? _clip;

		private Mask? _mask;

		private Image? _maskImage;

		private bool _maskableSaved;

		private bool _savedMaskable;

		private bool _clipHooked;

		private CanvasGroup? _canvasGroup;

		private bool _ownsCanvasGroup;

		private bool _savedCanvasAlphaKnown;

		private float _savedCanvasAlpha;

		private bool _touched;

		private static readonly FieldInfo? BiomeNameField = typeof(Minimap).GetField("m_biomeNameSmall", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

		private readonly List<MaskableGraphic> _outsideMask = new List<MaskableGraphic>();

		private readonly List<bool> _outsideMaskWas = new List<bool>();

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

		private readonly List<Color> _tintBase = new List<Color>();

		private readonly HashSet<int> _tintSeen = new HashSet<int>();

		private int _tintHierarchy = -1;

		private int _tintFrame;

		private int _outsideWindId;

		private int _outsideBiomeId;

		private VanillaLayout _vanillaMap;

		private RectFields _vanillaBuffs;

		private int _buffId;

		private RectFields _vanillaShip;

		private int _shipId;

		private int _shipIconId;

		private Vector2 _shipIconVanilla;

		public MinimapApplier(PluginConfig config, ManualLogSource log)
		{
			_config = config;
			_log = log;
		}

		public void Tick()
		{
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Invalid comparison between Unknown and I4
			//IL_00a4: 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_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			if (!_config.Enabled)
			{
				ReleaseToVanilla();
				return;
			}
			NoteConflicts();
			if (Game.m_noMap)
			{
				RestoreBuffs();
				RestoreShip();
				RestoreCustomTints();
				return;
			}
			Minimap instance = Minimap.instance;
			if ((Object)(object)instance == (Object)null || (Object)(object)instance.m_smallRoot == (Object)null)
			{
				return;
			}
			RectTransform component = instance.m_smallRoot.GetComponent<RectTransform>();
			if ((Object)(object)component == (Object)null)
			{
				return;
			}
			if (!instance.m_smallRoot.activeInHierarchy || (int)instance.m_mode != 1)
			{
				RestoreBuffs();
				RestoreShip();
				RestoreCustomTints();
				return;
			}
			if (!_capturedMap)
			{
				_vanillaMap = ReadVanilla(component);
				_capturedMap = true;
			}
			Transform parent = ((Transform)component).parent;
			RectTransform val = (RectTransform)(object)((parent is RectTransform) ? parent : null);
			if (!((Object)(object)val == (Object)null))
			{
				MinimapProfile current = _config.Current;
				RectLayout layout = LayoutSolver.Solve(_vanillaMap, ReadParent(val), current);
				Apply(component, layout);
				ApplyShape(instance, ((Component)component).gameObject, current);
				if ((int)((MinimapProfile)(ref current)).Shape != 0)
				{
					KeepOutsideMask(instance);
				}
				ApplyAlpha(instance, ((Component)component).gameObject, ((MinimapProfile)(ref current)).Alpha);
				_touched = true;
				Hud instance2 = Hud.instance;
				RectTransform val2 = (((Object)(object)instance2 != (Object)null) ? instance2.m_statusEffectListRoot : null);
				if ((Object)(object)val2 == (Object)null || !_moveBuffs || !((MinimapProfile)(ref current)).RepositionBuffs)
				{
					RestoreBuffs();
				}
				else
				{
					PlacePiece(val, layout, val2, ref _vanillaBuffs, ref _buffId, (ClearanceSide)0);
				}
				RectTransform val3 = ShipRect(instance2);
				if ((Object)(object)val3 == (Object)null || !((MinimapProfile)(ref current)).RepositionShipHud)
				{
					RestoreShip();
					return;
				}
				PlacePiece(val, layout, val3, ref _vanillaShip, ref _shipId, (ClearanceSide)1, padFirst: true);
				SyncShipIcon(instance2, val3);
			}
		}

		private void ReleaseToVanilla()
		{
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			if (!_touched && !_capturedMap && (Object)(object)_clip == (Object)null && _buffId == 0 && _shipId == 0 && _shipIconId == 0 && (Object)(object)_canvasGroup == (Object)null && _tinted.Count == 0 && _outsideMask.Count == 0)
			{
				return;
			}
			Minimap instance = Minimap.instance;
			if ((Object)(object)instance == (Object)null || (Object)(object)instance.m_smallRoot == (Object)null)
			{
				return;
			}
			GameObject smallRoot = instance.m_smallRoot;
			RectTransform component = smallRoot.GetComponent<RectTransform>();
			if (!((Object)(object)component == (Object)null))
			{
				if (_capturedMap)
				{
					WriteVanilla(component, _vanillaMap);
					_capturedMap = false;
				}
				RestoreOutsideMask();
				ReleaseClip(smallRoot);
				UseLiveMapMaterial(instance, clip: false);
				RestoreAlpha(smallRoot);
				RestoreCustomTints();
				ClearTintTracking();
				if (RestoreBuffs() && RestoreShip())
				{
					_buffId = 0;
					_shipId = 0;
					_shipIconId = 0;
					_touched = false;
				}
			}
		}

		private void NoteConflicts()
		{
			if (!_checkedConflicts)
			{
				_checkedConflicts = true;
				if (BuffLayoutMods.BlocksBuffMove(out string mod))
				{
					_moveBuffs = false;
					_log.LogInfo((object)("Leaving buff icons alone because " + mod + " is loaded."));
				}
			}
		}

		private void ApplyShape(Minimap minimap, GameObject root, MinimapProfile profile)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			if ((int)((MinimapProfile)(ref profile)).Shape == 0)
			{
				ReleaseClip(root);
				UseLiveMapMaterial(minimap, clip: false);
				RestoreOutsideMask();
				return;
			}
			EnsureClip(root);
			if (!((Object)(object)_mask == (Object)null) && !((Object)(object)_maskImage == (Object)null))
			{
				if (!((Behaviour)_mask).enabled)
				{
					((Behaviour)_mask).enabled = true;
				}
				Sprite val = ShapeMaskSprites.Get(((MinimapProfile)(ref profile)).Shape, ((MinimapProfile)(ref profile)).CornerRadius, ((MinimapProfile)(ref profile)).Aspect);
				if ((Object)(object)_maskImage.sprite != (Object)(object)val)
				{
					_maskImage.sprite = val;
				}
				if ((int)_maskImage.type != 0)
				{
					_maskImage.type = (Type)0;
				}
				if (_maskImage.preserveAspect)
				{
					_maskImage.preserveAspect = false;
				}
				UseLiveMapMaterial(minimap, clip: true);
			}
		}

		private void EnsureClip(GameObject root)
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Expected O, but got Unknown
			//IL_0079: 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_008f: 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_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_clip != (Object)null))
			{
				List<Transform> list = new List<Transform>(root.transform.childCount);
				for (int i = 0; i < root.transform.childCount; i++)
				{
					list.Add(root.transform.GetChild(i));
				}
				GameObject val = new GameObject("EvuMinimapClip");
				val.layer = root.layer;
				RectTransform val2 = val.AddComponent<RectTransform>();
				((Transform)val2).SetParent(root.transform, false);
				val2.anchorMin = Vector2.zero;
				val2.anchorMax = Vector2.one;
				val2.offsetMin = Vector2.zero;
				val2.offsetMax = Vector2.zero;
				val2.pivot = new Vector2(0.5f, 0.5f);
				((Transform)val2).localScale = Vector3.one;
				for (int j = 0; j < list.Count; j++)
				{
					list[j].SetParent((Transform)(object)val2, true);
				}
				Image val3 = val.AddComponent<Image>();
				((Graphic)val3).raycastTarget = false;
				((Graphic)val3).color = Color.white;
				val3.type = (Type)0;
				val3.preserveAspect = false;
				Mask val4 = val.AddComponent<Mask>();
				val4.showMaskGraphic = false;
				_clip = val;
				_mask = val4;
				_maskImage = val3;
			}
		}

		private void ReleaseClip(GameObject root)
		{
			if (!((Object)(object)_clip == (Object)null))
			{
				Transform transform = _clip.transform;
				List<Transform> list = new List<Transform>(transform.childCount);
				for (int i = 0; i < transform.childCount; i++)
				{
					list.Add(transform.GetChild(i));
				}
				for (int j = 0; j < list.Count; j++)
				{
					list[j].SetParent(root.transform, true);
				}
				Object.Destroy((Object)(object)_clip);
				_clip = null;
				_mask = null;
				_maskImage = null;
				_clipHooked = false;
			}
		}

		private void KeepOutsideMask(Minimap minimap)
		{
			RectTransform windMarker = minimap.m_windMarker;
			Component val = BiomeName(minimap);
			int num = (((Object)(object)windMarker != (Object)null) ? ((Object)windMarker).GetInstanceID() : 0);
			int num2 = (((Object)(object)val != (Object)null) ? ((Object)val).GetInstanceID() : 0);
			if (num != _outsideWindId || num2 != _outsideBiomeId)
			{
				_outsideWindId = num;
				_outsideBiomeId = num2;
				NoteOutside((Component?)(object)windMarker);
				NoteOutside(val);
			}
			for (int i = 0; i < _outsideMask.Count; i++)
			{
				MaskableGraphic val2 = _outsideMask[i];
				if ((Object)(object)val2 != (Object)null && val2.maskable)
				{
					val2.maskable = false;
				}
			}
		}

		private void NoteOutside(Component? root)
		{
			if ((Object)(object)root == (Object)null)
			{
				return;
			}
			MaskableGraphic[] componentsInChildren = root.GetComponentsInChildren<MaskableGraphic>(true);
			foreach (MaskableGraphic val in componentsInChildren)
			{
				if (!((Object)(object)val == (Object)null) && !_outsideMask.Contains(val))
				{
					_outsideMask.Add(val);
					_outsideMaskWas.Add(val.maskable);
				}
			}
		}

		private static Component? BiomeName(Minimap minimap)
		{
			object? obj = BiomeNameField?.GetValue(minimap);
			return (Component?)((obj is Component) ? obj : null);
		}

		private void RestoreOutsideMask()
		{
			for (int i = 0; i < _outsideMask.Count; i++)
			{
				MaskableGraphic val = _outsideMask[i];
				if ((Object)(object)val != (Object)null)
				{
					val.maskable = _outsideMaskWas[i];
				}
			}
			_outsideMask.Clear();
			_outsideMaskWas.Clear();
			_outsideWindId = 0;
			_outsideBiomeId = 0;
		}

		private void UseLiveMapMaterial(Minimap minimap, bool clip)
		{
			RawImage mapImageSmall = minimap.m_mapImageSmall;
			if ((Object)(object)mapImageSmall == (Object)null)
			{
				return;
			}
			if (!_maskableSaved)
			{
				_savedMaskable = ((MaskableGraphic)mapImageSmall).maskable;
				_maskableSaved = true;
			}
			if (!clip)
			{
				((MaskableGraphic)mapImageSmall).maskable = _savedMaskable;
				return;
			}
			if (!_clipHooked)
			{
				((MaskableGraphic)mapImageSmall).maskable = false;
				((MaskableGraphic)mapImageSmall).maskable = true;
				_clipHooked = true;
			}
			else if (!((MaskableGraphic)mapImageSmall).maskable)
			{
				((MaskableGraphic)mapImageSmall).maskable = true;
			}
			SyncMaskedMap(mapImageSmall, minimap.m_mapSmallShader);
		}

		private static void SyncMaskedMap(RawImage map, Material source)
		{
			if ((Object)(object)source == (Object)null)
			{
				return;
			}
			Material materialForRendering = ((Graphic)map).materialForRendering;
			if ((Object)(object)materialForRendering == (Object)null || (Object)(object)materialForRendering == (Object)(object)source)
			{
				return;
			}
			bool num = materialForRendering.HasProperty("_StencilComp");
			int num2 = ((num && materialForRendering.HasProperty("_Stencil")) ? materialForRendering.GetInt("_Stencil") : 0);
			int num3 = (num ? materialForRendering.GetInt("_StencilComp") : 0);
			int num4 = (materialForRendering.HasProperty("_StencilOp") ? materialForRendering.GetInt("_StencilOp") : 0);
			int num5 = (materialForRendering.HasProperty("_StencilReadMask") ? materialForRendering.GetInt("_StencilReadMask") : 255);
			int num6 = (materialForRendering.HasProperty("_StencilWriteMask") ? materialForRendering.GetInt("_StencilWriteMask") : 255);
			int num7 = (materialForRendering.HasProperty("_ColorMask") ? materialForRendering.GetInt("_ColorMask") : 15);
			materialForRendering.CopyPropertiesFromMaterial(source);
			if (num)
			{
				materialForRendering.SetInt("_Stencil", num2);
				materialForRendering.SetInt("_StencilComp", num3);
				if (materialForRendering.HasProperty("_StencilOp"))
				{
					materialForRendering.SetInt("_StencilOp", num4);
				}
				if (materialForRendering.HasProperty("_StencilReadMask"))
				{
					materialForRendering.SetInt("_StencilReadMask", num5);
				}
				if (materialForRendering.HasProperty("_StencilWriteMask"))
				{
					materialForRendering.SetInt("_StencilWriteMask", num6);
				}
				if (materialForRendering.HasProperty("_ColorMask"))
				{
					materialForRendering.SetInt("_ColorMask", num7);
				}
			}
		}

		private void ApplyAlpha(Minimap minimap, GameObject root, float alpha)
		{
			if ((Object)(object)_canvasGroup == (Object)null)
			{
				_canvasGroup = root.GetComponent<CanvasGroup>();
				if ((Object)(object)_canvasGroup == (Object)null)
				{
					_canvasGroup = root.AddComponent<CanvasGroup>();
					_ownsCanvasGroup = true;
				}
				else if (!_savedCanvasAlphaKnown)
				{
					_savedCanvasAlpha = _canvasGroup.alpha;
					_savedCanvasAlphaKnown = true;
				}
			}
			if (!Nearly(_canvasGroup.alpha, alpha))
			{
				_canvasGroup.alpha = alpha;
			}
			TintCustomShaders(root, minimap.m_mapImageSmall, alpha);
		}

		private void RestoreAlpha(GameObject root)
		{
			if ((Object)(object)_canvasGroup == (Object)null)
			{
				_canvasGroup = root.GetComponent<CanvasGroup>();
			}
			if ((Object)(object)_canvasGroup == (Object)null)
			{
				return;
			}
			if (_ownsCanvasGroup)
			{
				Object.Destroy((Object)(object)_canvasGroup);
				_canvasGroup = null;
				_ownsCanvasGroup = false;
				return;
			}
			if (_savedCanvasAlphaKnown && !Nearly(_canvasGroup.alpha, _savedCanvasAlpha))
			{
				_canvasGroup.alpha = _savedCanvasAlpha;
			}
			_canvasGroup = null;
		}

		private void TintCustomShaders(GameObject root, RawImage? map, float alpha)
		{
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			if (Nearly(alpha, 1f))
			{
				if (_tinted.Count > 0)
				{
					RestoreCustomTints();
					ClearTintTracking();
				}
				return;
			}
			int hierarchyCount = root.transform.hierarchyCount;
			_tintFrame++;
			if (hierarchyCount != _tintHierarchy || _tintFrame % 60 == 0)
			{
				_tintHierarchy = hierarchyCount;
				PruneDestroyedTints();
				_tintSeen.Clear();
				for (int i = 0; i < _tinted.Count; i++)
				{
					Graphic val = _tinted[i];
					if ((Object)(object)val != (Object)null)
					{
						_tintSeen.Add(((Object)val).GetInstanceID());
					}
				}
			}
			Graphic[] componentsInChildren = root.GetComponentsInChildren<Graphic>(true);
			foreach (Graphic val2 in componentsInChildren)
			{
				if ((Object)(object)val2 == (Object)null || (Object)(object)val2 == (Object)(object)map || !_tintSeen.Add(((Object)val2).GetInstanceID()))
				{
					continue;
				}
				Material material = val2.material;
				if (!((Object)(object)material == (Object)null) && !((Object)(object)material.shader == (Object)null) && material.HasProperty("_Color"))
				{
					string name = ((Object)material.shader).name;
					if (!name.StartsWith("UI/") && !name.StartsWith("TextMeshPro"))
					{
						Color color = material.GetColor("_Color");
						int num = BaseFor(material);
						_tinted.Add(val2);
						_tintBase.Add((num >= 0) ? _tintBase[num] : color);
					}
				}
			}
			for (int k = 0; k < _tinted.Count; k++)
			{
				Graphic val3 = _tinted[k];
				if ((Object)(object)val3 == (Object)null)
				{
					continue;
				}
				Material material2 = val3.material;
				if (!((Object)(object)material2 == (Object)null) && material2.HasProperty("_Color"))
				{
					Color val4 = _tintBase[k];
					val4.a *= alpha;
					if (material2.GetColor("_Color") != val4)
					{
						material2.SetColor("_Color", val4);
					}
				}
			}
		}

		private void RestoreCustomTints()
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < _tinted.Count; i++)
			{
				Graphic val = _tinted[i];
				if (!((Object)(object)val == (Object)null))
				{
					Material material = val.material;
					if (!((Object)(object)material == (Object)null) && material.HasProperty("_Color") && material.GetColor("_Color") != _tintBase[i])
					{
						material.SetColor("_Color", _tintBase[i]);
					}
				}
			}
		}

		private void PruneDestroyedTints()
		{
			for (int num = _tinted.Count - 1; num >= 0; num--)
			{
				if ((Object)(object)_tinted[num] == (Object)null)
				{
					_tinted.RemoveAt(num);
					_tintBase.RemoveAt(num);
				}
			}
		}

		private void ClearTintTracking()
		{
			_tinted.Clear();
			_tintBase.Clear();
			_tintSeen.Clear();
			_tintHierarchy = -1;
		}

		private int BaseFor(Material mat)
		{
			for (int i = 0; i < _tinted.Count; i++)
			{
				Graphic val = _tinted[i];
				if ((Object)(object)val != (Object)null && (Object)(object)val.material == (Object)(object)mat)
				{
					return i;
				}
			}
			return -1;
		}

		private static RectTransform? ShipRect(Hud? hud)
		{
			if (!((Object)(object)hud != (Object)null))
			{
				return null;
			}
			return hud.m_shipWindIndicatorRoot;
		}

		private void PlacePiece(RectTransform mapParent, RectLayout layout, RectTransform piece, ref RectFields vanilla, ref int id, ClearanceSide prefer, bool padFirst = false)
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: 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_0034: 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_0062: 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_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: 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_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: 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_0095: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: 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_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			Transform parent = ((Transform)piece).parent;
			RectTransform val = (RectTransform)(object)((parent is RectTransform) ? parent : null);
			RectTransform val2 = CanvasOf(mapParent);
			if (!((Object)(object)val == (Object)null) && !((Object)(object)val2 == (Object)null))
			{
				if (id != ((Object)piece).GetInstanceID())
				{
					vanilla = ReadFields(piece);
					id = ((Object)piece).GetInstanceID();
				}
				HudRect val3 = ToSpace(LayoutSolver.Bounds(ReadParent(mapParent), layout), mapParent, val2);
				HudRect val4 = (padFirst ? Inflate(val3, 18f) : val3);
				HudRect rect = LayoutSolver.Bounds(ReadParent(val), vanilla);
				HudRect val5 = ToSpace(rect, val, val2);
				ParentRect val6 = ReadParent(val2);
				HudRect rect2 = BuffPlacement.Place(val3, val4, val5, val6, true, prefer);
				if (!padFirst && (!Nearly(((HudRect)(ref rect2)).X, ((HudRect)(ref val5)).X) || !Nearly(((HudRect)(ref rect2)).Y, ((HudRect)(ref val5)).Y)))
				{
					rect2 = BuffPlacement.Place(Inflate(val3, 18f), val5, val6, true, prefer);
				}
				HudRect val7 = ToSpace(rect2, val2, val);
				WriteBuff(piece, vanilla, ((HudRect)(ref val7)).X - ((HudRect)(ref rect)).X, ((HudRect)(ref val7)).Y - ((HudRect)(ref rect)).Y);
			}
		}

		private static HudRect Inflate(HudRect rect, float pad)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			return new HudRect(((HudRect)(ref rect)).X - pad, ((HudRect)(ref rect)).Y - pad, ((HudRect)(ref rect)).Width + pad * 2f, ((HudRect)(ref rect)).Height + pad * 2f);
		}

		private void SyncShipIcon(Hud? hud, RectTransform indicator)
		{
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//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_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: 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)
			RectTransform val = (((Object)(object)hud != (Object)null) ? hud.m_shipWindIconRoot : null);
			if (!((Object)(object)val == (Object)null) && !((Object)(object)val == (Object)(object)indicator) && !((Transform)val).IsChildOf((Transform)(object)indicator) && !((Object)(object)((Transform)val).parent != (Object)(object)((Transform)indicator).parent))
			{
				if (_shipIconId != ((Object)val).GetInstanceID())
				{
					_shipIconVanilla = val.anchoredPosition;
					_shipIconId = ((Object)val).GetInstanceID();
				}
				Vector2 val2 = _shipIconVanilla + (indicator.anchoredPosition - new Vector2(((RectFields)(ref _vanillaShip)).AnchoredX, ((RectFields)(ref _vanillaShip)).AnchoredY));
				if (val.anchoredPosition != val2)
				{
					val.anchoredPosition = val2;
				}
			}
		}

		private void RestoreShipIcon()
		{
			//IL_003b: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			if (_shipIconId != 0)
			{
				Hud instance = Hud.instance;
				RectTransform val = (((Object)(object)instance != (Object)null) ? instance.m_shipWindIconRoot : null);
				if (!((Object)(object)val == (Object)null) && ((Object)val).GetInstanceID() == _shipIconId && val.anchoredPosition != _shipIconVanilla)
				{
					val.anchoredPosition = _shipIconVanilla;
				}
			}
		}

		private bool RestoreShip()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			bool num = RestorePiece(_shipId, _vanillaShip, ShipRect(Hud.instance));
			if (num)
			{
				RestoreShipIcon();
			}
			return num;
		}

		private bool RestoreBuffs()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			Hud instance = Hud.instance;
			RectTransform piece = (((Object)(object)instance != (Object)null) ? instance.m_statusEffectListRoot : null);
			return RestorePiece(_buffId, _vanillaBuffs, piece);
		}

		private bool RestorePiece(int id, RectFields saved, RectTransform? piece)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			if (id == 0)
			{
				return true;
			}
			if ((Object)(object)piece == (Object)null)
			{
				return false;
			}
			if (((Object)piece).GetInstanceID() != id)
			{
				return true;
			}
			WriteBuff(piece, saved, 0f, 0f);
			return true;
		}

		private static VanillaLayout ReadVanilla(RectTransform rect)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: 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)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			RectFields val = ReadFields(rect);
			if (Nearly(((RectFields)(ref val)).AnchorMinX, ((RectFields)(ref val)).AnchorMaxX) && Nearly(((RectFields)(ref val)).AnchorMinY, ((RectFields)(ref val)).AnchorMaxY))
			{
				return new VanillaLayout(((RectFields)(ref val)).AnchorMinX, ((RectFields)(ref val)).AnchorMinY, ((RectFields)(ref val)).PivotX, ((RectFields)(ref val)).PivotY, ((RectFields)(ref val)).AnchoredX, ((RectFields)(ref val)).AnchoredY, ((RectFields)(ref val)).Width, ((RectFields)(ref val)).Height, ((RectFields)(ref val)).ScaleX, ((RectFields)(ref val)).ScaleY);
			}
			Transform parent = ((Transform)rect).parent;
			RectTransform val2 = (RectTransform)(object)((parent is RectTransform) ? parent : null);
			if ((Object)(object)val2 == (Object)null)
			{
				return new VanillaLayout(0.5f, 0.5f, ((RectFields)(ref val)).PivotX, ((RectFields)(ref val)).PivotY, ((RectFields)(ref val)).AnchoredX, ((RectFields)(ref val)).AnchoredY, ((RectFields)(ref val)).Width, ((RectFields)(ref val)).Height, ((RectFields)(ref val)).ScaleX, ((RectFields)(ref val)).ScaleY);
			}
			HudRect val3 = LayoutSolver.Bounds(ReadParent(val2), val);
			float num = (Nearly(((RectFields)(ref val)).ScaleX, 0f) ? 1f : ((RectFields)(ref val)).ScaleX);
			float num2 = (Nearly(((RectFields)(ref val)).ScaleY, 0f) ? 1f : ((RectFields)(ref val)).ScaleY);
			ParentRect val4 = ReadParent(val2);
			float num3 = default(float);
			float num4 = default(float);
			((ParentRect)(ref val4)).AnchorReference(((RectFields)(ref val)).PivotX, ((RectFields)(ref val)).PivotY, ref num3, ref num4);
			float num5 = ((HudRect)(ref val3)).X + ((HudRect)(ref val3)).Width * ((RectFields)(ref val)).PivotX;
			float num6 = ((HudRect)(ref val3)).Y + ((HudRect)(ref val3)).Height * ((RectFields)(ref val)).PivotY;
			return new VanillaLayout(((RectFields)(ref val)).PivotX, ((RectFields)(ref val)).PivotY, ((RectFields)(ref val)).PivotX, ((RectFields)(ref val)).PivotY, num5 - num3, num6 - num4, ((HudRect)(ref val3)).Width / num, ((HudRect)(ref val3)).Height / num2, ((RectFields)(ref val)).ScaleX, ((RectFields)(ref val)).ScaleY);
		}

		private static void Apply(RectTransform rect, RectLayout layout)
		{
			//IL_0001: 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_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: 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_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: 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_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			if (!Matches(rect, layout))
			{
				Vector2 val = default(Vector2);
				((Vector2)(ref val))..ctor(((RectLayout)(ref layout)).AnchorX, ((RectLayout)(ref layout)).AnchorY);
				rect.anchorMin = Vector2.zero;
				rect.anchorMax = Vector2.one;
				rect.anchorMin = val;
				rect.anchorMax = val;
				rect.pivot = val;
				rect.sizeDelta = new Vector2(((RectLayout)(ref layout)).Width, ((RectLayout)(ref layout)).Height);
				Vector3 localScale = ((Transform)rect).localScale;
				((Transform)rect).localScale = new Vector3(((RectLayout)(ref layout)).ScaleX, ((RectLayout)(ref layout)).ScaleY, localScale.z);
				rect.anchoredPosition = new Vector2(((RectLayout)(ref layout)).AnchoredX, ((RectLayout)(ref layout)).AnchoredY);
			}
		}

		private static void WriteVanilla(RectTransform rect, VanillaLayout layout)
		{
			//IL_0001: 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)
			//IL_0160: 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_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: 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_0071: 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_00a9: 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_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: 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)
			if (!Nearly(rect.anchorMin.x, ((VanillaLayout)(ref layout)).AnchorX) || !Nearly(rect.anchorMin.y, ((VanillaLayout)(ref layout)).AnchorY) || !Nearly(rect.anchorMax.x, ((VanillaLayout)(ref layout)).AnchorX) || !Nearly(rect.anchorMax.y, ((VanillaLayout)(ref layout)).AnchorY) || !Nearly(rect.pivot.x, ((VanillaLayout)(ref layout)).PivotX) || !Nearly(rect.pivot.y, ((VanillaLayout)(ref layout)).PivotY) || !Nearly(rect.anchoredPosition.x, ((VanillaLayout)(ref layout)).AnchoredX) || !Nearly(rect.anchoredPosition.y, ((VanillaLayout)(ref layout)).AnchoredY) || !Nearly(rect.sizeDelta.x, ((VanillaLayout)(ref layout)).Width) || !Nearly(rect.sizeDelta.y, ((VanillaLayout)(ref layout)).Height) || !Nearly(((Transform)rect).localScale.x, ((VanillaLayout)(ref layout)).ScaleX) || !Nearly(((Transform)rect).localScale.y, ((VanillaLayout)(ref layout)).ScaleY))
			{
				Vector2 val = default(Vector2);
				((Vector2)(ref val))..ctor(((VanillaLayout)(ref layout)).AnchorX, ((VanillaLayout)(ref layout)).AnchorY);
				rect.anchorMin = Vector2.zero;
				rect.anchorMax = Vector2.one;
				rect.anchorMin = val;
				rect.anchorMax = val;
				rect.pivot = new Vector2(((VanillaLayout)(ref layout)).PivotX, ((VanillaLayout)(ref layout)).PivotY);
				rect.sizeDelta = new Vector2(((VanillaLayout)(ref layout)).Width, ((VanillaLayout)(ref layout)).Height);
				Vector3 localScale = ((Transform)rect).localScale;
				((Transform)rect).localScale = new Vector3(((VanillaLayout)(ref layout)).ScaleX, ((VanillaLayout)(ref layout)).ScaleY, localScale.z);
				rect.anchoredPosition = new Vector2(((VanillaLayout)(ref layout)).AnchoredX, ((VanillaLayout)(ref layout)).AnchoredY);
			}
		}

		private static void WriteBuff(RectTransform rect, RectFields saved, float deltaX, float deltaY)
		{
			//IL_0015: 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_002c: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: 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_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			float num = ((RectFields)(ref saved)).AnchoredX + deltaX;
			float num2 = ((RectFields)(ref saved)).AnchoredY + deltaY;
			if (!Matches(rect, saved, num, num2))
			{
				rect.anchorMin = Vector2.zero;
				rect.anchorMax = Vector2.one;
				rect.anchorMin = new Vector2(((RectFields)(ref saved)).AnchorMinX, ((RectFields)(ref saved)).AnchorMinY);
				rect.anchorMax = new Vector2(((RectFields)(ref saved)).AnchorMaxX, ((RectFields)(ref saved)).AnchorMaxY);
				rect.pivot = new Vector2(((RectFields)(ref saved)).PivotX, ((RectFields)(ref saved)).PivotY);
				rect.sizeDelta = new Vector2(((RectFields)(ref saved)).Width, ((RectFields)(ref saved)).Height);
				Vector3 localScale = ((Transform)rect).localScale;
				((Transform)rect).localScale = new Vector3(((RectFields)(ref saved)).ScaleX, ((RectFields)(ref saved)).ScaleY, localScale.z);
				rect.anchoredPosition = new Vector2(num, num2);
			}
		}

		private static bool Matches(RectTransform rect, RectLayout layout)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: 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_0071: 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_00a9: 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_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: 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)
			if (Nearly(rect.anchorMin.x, ((RectLayout)(ref layout)).AnchorX) && Nearly(rect.anchorMin.y, ((RectLayout)(ref layout)).AnchorY) && Nearly(rect.anchorMax.x, ((RectLayout)(ref layout)).AnchorX) && Nearly(rect.anchorMax.y, ((RectLayout)(ref layout)).AnchorY) && Nearly(rect.pivot.x, ((RectLayout)(ref layout)).PivotX) && Nearly(rect.pivot.y, ((RectLayout)(ref layout)).PivotY) && Nearly(rect.anchoredPosition.x, ((RectLayout)(ref layout)).AnchoredX) && Nearly(rect.anchoredPosition.y, ((RectLayout)(ref layout)).AnchoredY) && Nearly(rect.sizeDelta.x, ((RectLayout)(ref layout)).Width) && Nearly(rect.sizeDelta.y, ((RectLayout)(ref layout)).Height) && Nearly(((Transform)rect).localScale.x, ((RectLayout)(ref layout)).ScaleX))
			{
				return Nearly(((Transform)rect).localScale.y, ((RectLayout)(ref layout)).ScaleY);
			}
			return false;
		}

		private static bool Matches(RectTransform rect, RectFields saved, float anchoredX, float anchoredY)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: 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_0071: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: 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_0101: 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)
			if (Nearly(rect.anchorMin.x, ((RectFields)(ref saved)).AnchorMinX) && Nearly(rect.anchorMin.y, ((RectFields)(ref saved)).AnchorMinY) && Nearly(rect.anchorMax.x, ((RectFields)(ref saved)).AnchorMaxX) && Nearly(rect.anchorMax.y, ((RectFields)(ref saved)).AnchorMaxY) && Nearly(rect.pivot.x, ((RectFields)(ref saved)).PivotX) && Nearly(rect.pivot.y, ((RectFields)(ref saved)).PivotY) && Nearly(rect.anchoredPosition.x, anchoredX) && Nearly(rect.anchoredPosition.y, anchoredY) && Nearly(rect.sizeDelta.x, ((RectFields)(ref saved)).Width) && Nearly(rect.sizeDelta.y, ((RectFields)(ref saved)).Height) && Nearly(((Transform)rect).localScale.x, ((RectFields)(ref saved)).ScaleX))
			{
				return Nearly(((Transform)rect).localScale.y, ((RectFields)(ref saved)).ScaleY);
			}
			return false;
		}

		private static RectFields ReadFields(RectTransform rect)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: 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_0055: 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_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			Vector3 localScale = ((Transform)rect).localScale;
			return new RectFields(rect.anchorMin.x, rect.anchorMin.y, rect.anchorMax.x, rect.anchorMax.y, rect.pivot.x, rect.pivot.y, rect.anchoredPosition.x, rect.anchoredPosition.y, rect.sizeDelta.x, rect.sizeDelta.y, localScale.x, localScale.y);
		}

		private static ParentRect ReadParent(RectTransform parent)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			Rect rect = parent.rect;
			return new ParentRect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width, ((Rect)(ref rect)).height);
		}

		private static RectTransform? CanvasOf(RectTransform rect)
		{
			Canvas componentInParent = ((Component)rect).GetComponentInParent<Canvas>();
			if ((Object)(object)componentInParent == (Object)null)
			{
				Transform parent = ((Transform)rect).parent;
				return (RectTransform?)(object)((parent is RectTransform) ? parent : null);
			}
			Transform obj = (((Object)(object)componentInParent.rootCanvas != (Object)null) ? ((Component)componentInParent.rootCanvas).transform : ((Component)componentInParent).transform);
			return (RectTransform?)(object)((obj is RectTransform) ? obj : null);
		}

		private static HudRect ToSpace(HudRect rect, RectTransform from, RectTransform to)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: 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_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_0049: 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)
			//IL_0056: 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_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = ((Transform)to).InverseTransformPoint(((Transform)from).TransformPoint(new Vector3(((HudRect)(ref rect)).X, ((HudRect)(ref rect)).Y, 0f)));
			Vector3 val2 = ((Transform)to).InverseTransformPoint(((Transform)from).TransformPoint(new Vector3(((HudRect)(ref rect)).Right, ((HudRect)(ref rect)).Top, 0f)));
			return new HudRect(val.x, val.y, val2.x - val.x, val2.y - val.y);
		}

		private static bool Nearly(float left, float right)
		{
			float num = left - right;
			if (num < 0f)
			{
				num = 0f - num;
			}
			return num <= 0.01f;
		}
	}
	[BepInPlugin("evu.evuminimap", "EvuMinimap", "0.2.2")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public sealed class Plugin : BaseUnityPlugin
	{
		private PluginConfig? _settings;

		private MinimapApplier? _applier;

		private void Awake()
		{
			if (ServerGuard.IsDedicatedServer)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Dedicated server detected. EvuMinimap stays inactive.");
				return;
			}
			_settings = new PluginConfig(((BaseUnityPlugin)this).Config, ((BaseUnityPlugin)this).Logger);
			_applier = new MinimapApplier(_settings, ((BaseUnityPlugin)this).Logger);
		}

		private void Update()
		{
			_settings?.PollHotkeys();
		}

		private void LateUpdate()
		{
			_applier?.Tick();
		}
	}
	internal sealed class PluginConfig
	{
		private sealed class ProfileSlot
		{
			private readonly ConfigEntry<float> _scale;

			private readonly ConfigEntry<MapAnchor> _anchor;

			private readonly ConfigEntry<float> _offsetX;

			private readonly ConfigEntry<float> _offsetY;

			private readonly ConfigEntry<bool> _repositionBuffs;

			private readonly ConfigEntry<bool> _repositionShipHud;

			private readonly ConfigEntry<MapShape> _shape;

			private readonly ConfigEntry<float> _alpha;

			private readonly ConfigEntry<float> _cornerRadius;

			private readonly ConfigEntry<float> _aspect;

			private readonly ConfigurationManagerAttributes _aspectAttributes;

			private readonly ConfigurationManagerAttributes _cornerAttributes;

			public ConfigEntry<float> Scale => _scale;

			private ProfileSlot(ConfigEntry<float> scale, ConfigEntry<MapAnchor> anchor, ConfigEntry<float> offsetX, ConfigEntry<float> offsetY, ConfigEntry<bool> repositionBuffs, ConfigEntry<bool> repositionShipHud, ConfigEntry<MapShape> shape, ConfigEntry<float> alpha, ConfigEntry<float> cornerRadius, ConfigEntry<float> aspect, ConfigurationManagerAttributes aspectAttributes, ConfigurationManagerAttributes cornerAttributes)
			{
				_scale = scale;
				_anchor = anchor;
				_offsetX = offsetX;
				_offsetY = offsetY;
				_repositionBuffs = repositionBuffs;
				_repositionShipHud = repositionShipHud;
				_shape = shape;
				_alpha = alpha;
				_cornerRadius = cornerRadius;
				_aspect = aspect;
				_aspectAttributes = aspectAttributes;
				_cornerAttributes = cornerAttributes;
				_shape.SettingChanged += OnShapeChanged;
				UpdateLocks();
			}

			private void OnShapeChanged(object sender, EventArgs args)
			{
				UpdateLocks();
			}

			private void UpdateLocks()
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Invalid comparison between Unknown and I4
				//IL_0032: Unknown result type (might be due to invalid IL or missing references)
				//IL_0038: Invalid comparison between Unknown and I4
				bool flag = (int)_shape.Value > 0;
				_aspectAttributes.ReadOnly = !flag;
				_cornerAttributes.ReadOnly = !flag || (int)_shape.Value == 1;
			}

			public static ProfileSlot Bind(ConfigFile config, int index, Action<ConfigEntry<float>, Func<float, float>> clamp)
			{
				//IL_0055: Unknown result type (might be due to invalid IL or missing references)
				//IL_005f: Expected O, but got Unknown
				//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cc: Expected O, but got Unknown
				//IL_0120: Unknown result type (might be due to invalid IL or missing references)
				//IL_012a: Expected O, but got Unknown
				//IL_0155: Unknown result type (might be due to invalid IL or missing references)
				//IL_015f: Expected O, but got Unknown
				//IL_019c: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a6: Expected O, but got Unknown
				//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ed: Expected O, but got Unknown
				//IL_0218: Unknown result type (might be due to invalid IL or missing references)
				//IL_0222: Expected O, but got Unknown
				//IL_0258: Unknown result type (might be due to invalid IL or missing references)
				//IL_0262: Expected O, but got Unknown
				//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
				//IL_02c1: Expected O, but got Unknown
				//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
				//IL_02f8: Expected O, but got Unknown
				string text = ((index == 0) ? "Minimap" : ("Minimap " + (index + 1)));
				ConfigEntry<MapShape> shape = config.Bind<MapShape>(text, "ShapeMask", (MapShape)0, new ConfigDescription("Extra clip on the small map. None keeps Valheim's shape, including changes from other mods. Oval is round, and aspect can stretch it. Rectangle uses corner radius.", (AcceptableValueBase)null, new object[1]
				{
					new ConfigurationManagerAttributes
					{
						Order = 100,
						DispName = "Shape mask"
					}
				}));
				float num = 1f;
				ConfigEntry<float> val = default(ConfigEntry<float>);
				bool flag = config.TryGetEntry<float>(text, "Alpha", ref val);
				if (flag)
				{
					num = val.Value;
				}
				ConfigEntry<float> val2 = config.Bind<float>(text, "IconAlpha", num, new ConfigDescription("Opacity of the frame, pins, and markers. Does not fade the terrain.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), new object[1]
				{
					new ConfigurationManagerAttributes
					{
						Order = 96,
						DispName = "Icon alpha"
					}
				}));
				if (flag)
				{
					config.Remove(((ConfigEntryBase)val).Definition);
					config.Save();
				}
				ConfigEntry<float> val3 = config.Bind<float>(text, "Scale", 1f, new ConfigDescription("Minimap size relative to vanilla. 1 is the original size.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 5f), new object[1]
				{
					new ConfigurationManagerAttributes
					{
						Order = 90
					}
				}));
				ConfigEntry<MapAnchor> anchor = config.Bind<MapAnchor>(text, "Anchor", (MapAnchor)2, new ConfigDescription("Point of the minimap that stays in place when the size changes. Top-right grows down-left.", (AcceptableValueBase)null, new object[1]
				{
					new ConfigurationManagerAttributes
					{
						Order = 80
					}
				}));
				ConfigEntry<float> offsetX = config.Bind<float>(text, "OffsetX", 0f, new ConfigDescription("Moves the anchor horizontally, in HUD units, from its vanilla position.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-4000f, 4000f), new object[1]
				{
					new ConfigurationManagerAttributes
					{
						Order = 70
					}
				}));
				ConfigEntry<float> offsetY = config.Bind<float>(text, "OffsetY", 0f, new ConfigDescription("Moves the anchor vertically, in HUD units, from its vanilla position.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-4000f, 4000f), new object[1]
				{
					new ConfigurationManagerAttributes
					{
						Order = 60
					}
				}));
				ConfigEntry<bool> repositionBuffs = config.Bind<bool>(text, "RepositionBuffIcons", true, new ConfigDescription("Slide buff icons off the minimap when they overlap it. Icons stay put when the map does not cover them.", (AcceptableValueBase)null, new object[1]
				{
					new ConfigurationManagerAttributes
					{
						Order = 50
					}
				}));
				ConfigEntry<bool> repositionShipHud = config.Bind<bool>(text, "RepositionShipHud", true, new ConfigDescription("Slide the boat wind panel below the minimap when they overlap, if that spot fits on screen. Otherwise it moves to the side with the most room. It stays put when the map does not cover it.", (AcceptableValueBase)null, new object[1]
				{
					new ConfigurationManagerAttributes
					{
						Order = 45,
						DispName = "Move ship wind"
					}
				}));
				ConfigurationManagerAttributes configurationManagerAttributes = new ConfigurationManagerAttributes
				{
					Order = 40
				};
				ConfigurationManagerAttributes configurationManagerAttributes2 = new ConfigurationManagerAttributes
				{
					Order = 30
				};
				ConfigEntry<float> val4 = config.Bind<float>(text, "Aspect", 1f, new ConfigDescription("Width relative to height of the shape mask. The map and icons stay 1:1. Above 1 hides more of the top and bottom. Below 1 hides more of the sides. Locked while shape mask is None.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 2f), new object[1] { configurationManagerAttributes }));
				ConfigEntry<float> val5 = config.Bind<float>(text, "CornerRadius", 0f, new ConfigDescription("Corner roundness of the rectangle mask. 0 is sharp. 1 is a capsule. Locked for None and oval.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), new object[1] { configurationManagerAttributes2 }));
				clamp(val3, ScaleMath.Clamp);
				clamp(val2, AppearanceMath.ClampAlpha);
				clamp(val4, AppearanceMath.ClampAspect);
				clamp(val5, AppearanceMath.ClampCornerRadius);
				return new ProfileSlot(val3, anchor, offsetX, offsetY, repositionBuffs, repositionShipHud, shape, val2, val5, val4, configurationManagerAttributes, configurationManagerAttributes2);
			}

			public MinimapProfile Read()
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_003d: Unknown result type (might be due to invalid IL or missing references)
				//IL_006e: Unknown result type (might be due to invalid IL or missing references)
				return new MinimapProfile(_anchor.Value, _offsetX.Value, _offsetY.Value, _scale.Value, _repositionBuffs.Value, _shape.Value, _alpha.Value, _cornerRadius.Value, _aspect.Value, _repositionShipHud.Value);
			}

			public void Write(MinimapProfile profile)
			{
				//IL_001a: 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)
				_scale.Value = ((MinimapProfile)(ref profile)).Scale;
				_anchor.Value = ((MinimapProfile)(ref profile)).Anchor;
				_offsetX.Value = ((MinimapProfile)(ref profile)).OffsetX;
				_offsetY.Value = ((MinimapProfile)(ref profile)).OffsetY;
				_repositionBuffs.Value = ((MinimapProfile)(ref profile)).RepositionBuffs;
				_repositionShipHud.Value = ((MinimapProfile)(ref profile)).RepositionShipHud;
				_shape.Value = ((MinimapProfile)(ref profile)).Shape;
				_alpha.Value = ((MinimapProfile)(ref profile)).Alpha;
				_cornerRadius.Value = ((MinimapProfile)(ref profile)).CornerRadius;
				_aspect.Value = ((MinimapProfile)(ref profile)).Aspect;
			}
		}

		private readonly ProfileSlot[] _slots;

		private readonly ConfigEntry<int> _active;

		private readonly ConfigEntry<float> _scaleStep;

		private readonly ConfigEntry<KeyboardShortcut> _increase;

		private readonly ConfigEntry<KeyboardShortcut> _decrease;

		private readonly ConfigEntry<KeyboardShortcut> _nextProfile;

		private readonly ConfigEntry<KeyboardShortcut> _previousProfile;

		private readonly ConfigEntry<bool> _reset;

		private readonly ConfigEntry<bool> _enabled;

		private readonly ManualLogSource _log;

		private bool _updating;

		public MinimapProfile Current => ActiveSlot().Read();

		public bool Enabled => _enabled.Value;

		public PluginConfig(ConfigFile config, ManualLogSource log)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Expected O, but got Unknown
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Expected O, but got Unknown
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Expected O, but got Unknown
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Expected O, but got Unknown
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Expected O, but got Unknown
			//IL_0243: 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_0273: Expected O, but got Unknown
			//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02da: Expected O, but got Unknown
			_log = log;
			MigrateShapeNames(config);
			_enabled = config.Bind<bool>("General", "Enabled", true, new ConfigDescription("When off, the small minimap, buff strip, and ship wind panel stay vanilla. Saved profiles and hotkeys remain in this file and apply again when this is on.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 100
				}
			}));
			_slots = new ProfileSlot[5];
			for (int i = 0; i < _slots.Length; i++)
			{
				_slots[i] = ProfileSlot.Bind(config, i, ClampFloat);
			}
			_active = config.Bind<int>("Profiles", "Active", 1, new ConfigDescription("Which saved minimap profile is shown. Alt+Numpad multiply and divide cycle it.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 5), new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 100
				}
			}));
			_scaleStep = config.Bind<float>("Minimap", "ScaleStep", 0.25f, new ConfigDescription("How much the size hotkeys change the scale of the active profile.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 1f), new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 10,
					IsAdvanced = true
				}
			}));
			_increase = config.Bind<KeyboardShortcut>("Hotkeys", "IncreaseSize", new KeyboardShortcut((KeyCode)270, (KeyCode[])(object)new KeyCode[1] { (KeyCode)308 }), new ConfigDescription("Increase the active profile's scale by one step. Either Alt key works.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 40
				}
			}));
			_decrease = config.Bind<KeyboardShortcut>("Hotkeys", "DecreaseSize", new KeyboardShortcut((KeyCode)269, (KeyCode[])(object)new KeyCode[1] { (KeyCode)308 }), new ConfigDescription("Decrease the active profile's scale by one step. Either Alt key works.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 30
				}
			}));
			_nextProfile = config.Bind<KeyboardShortcut>("Hotkeys", "NextProfile", new KeyboardShortcut((KeyCode)268, (KeyCode[])(object)new KeyCode[1] { (KeyCode)308 }), new ConfigDescription("Switch to the next minimap profile. Either Alt key works.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 20
				}
			}));
			_previousProfile = config.Bind<KeyboardShortcut>("Hotkeys", "PreviousProfile", new KeyboardShortcut((KeyCode)267, (KeyCode[])(object)new KeyCode[1] { (KeyCode)308 }), new ConfigDescription("Switch to the previous minimap profile. Either Alt key works.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 10
				}
			}));
			_reset = config.Bind<bool>("Actions", "ResetToVanilla", false, new ConfigDescription("Restore the active profile: scale, anchor, offset, buff reposition, ship wind, shape mask, and icon alpha. Hotkeys and the other profiles are kept.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 100,
					HideDefaultButton = true,
					HideSettingName = true,
					CustomDrawer = DrawReset
				}
			}));
			QuietClamp(_active, (Func<int, int>)ProfileIndex.Clamp);
			QuietClamp(_scaleStep, ClampStepValue);
			_active.SettingChanged += delegate
			{
				OnActiveChanged();
			};
			_scaleStep.SettingChanged += delegate
			{
				QuietClamp(_scaleStep, ClampStepValue);
			};
			_reset.SettingChanged += delegate
			{
				if (_reset.Value)
				{
					ApplyVanilla();
				}
			};
		}

		public void PollHotkeys()
		{
			//IL_001b: 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_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			if (_enabled.Value && !InputFocused())
			{
				if (HotkeyInput.WasPressed(_increase.Value))
				{
					SetScale(ScaleMath.Step(ActiveSlot().Scale.Value, _scaleStep.Value, 1));
				}
				else if (HotkeyInput.WasPressed(_decrease.Value))
				{
					SetScale(ScaleMath.Step(ActiveSlot().Scale.Value, _scaleStep.Value, -1));
				}
				else if (HotkeyInput.WasPressed(_nextProfile.Value))
				{
					SetActive(ProfileIndex.Cycle(_active.Value, 1));
				}
				else if (HotkeyInput.WasPressed(_previousProfile.Value))
				{
					SetActive(ProfileIndex.Cycle(_active.Value, -1));
				}
			}
		}

		private static bool InputFocused()
		{
			if (Console.IsVisible())
			{
				return true;
			}
			Chat instance = Chat.instance;
			if ((Object)(object)instance != (Object)null && instance.HasFocus())
			{
				return true;
			}
			return TextInput.IsVisible();
		}

		public void ApplyVanilla()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			if (_updating)
			{
				return;
			}
			_updating = true;
			try
			{
				ActiveSlot().Write(MinimapProfile.Vanilla);
				if (_reset.Value)
				{
					_reset.Value = false;
				}
			}
			finally
			{
				_updating = false;
			}
		}

		private void DrawReset(ConfigEntryBase entry)
		{
			if (GUILayout.Button("Reset to vanilla", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }))
			{
				ApplyVanilla();
			}
		}

		private void SetScale(float scale)
		{
			ConfigEntry<float> scale2 = ActiveSlot().Scale;
			if (!(Math.Abs(scale2.Value - scale) < 0.0001f))
			{
				scale2.Value = scale;
			}
		}

		private void SetActive(int index)
		{
			index = ProfileIndex.Clamp(index);
			if (_active.Value != index)
			{
				_active.Value = index;
			}
		}

		private void OnActiveChanged()
		{
			if (_updating)
			{
				return;
			}
			int num = ProfileIndex.Clamp(_active.Value);
			if (num != _active.Value)
			{
				_updating = true;
				try
				{
					_active.Value = num;
				}
				finally
				{
					_updating = false;
				}
			}
			if (_enabled.Value)
			{
				string text = "Switched to Minimap Profile " + num;
				_log.LogInfo((object)text);
				MessageHud instance = MessageHud.instance;
				if ((Object)(object)instance != (Object)null)
				{
					instance.ShowMessage((MessageType)1, text, 0, (Sprite)null, false, true);
				}
			}
		}

		private ProfileSlot ActiveSlot()
		{
			return _slots[ProfileIndex.Clamp(_active.Value) - 1];
		}

		private void QuietClamp(ConfigEntry<int> entry, Func<int, int> clamp)
		{
			if (_updating)
			{
				return;
			}
			int num = clamp(entry.Value);
			if (num == entry.Value)
			{
				return;
			}
			_updating = true;
			try
			{
				entry.Value = num;
			}
			finally
			{
				_updating = false;
			}
		}

		private void QuietClamp(ConfigEntry<float> entry, Func<float, float> clamp)
		{
			if (_updating)
			{
				return;
			}
			float num = clamp(entry.Value);
			if (Math.Abs(num - entry.Value) < 0.0001f)
			{
				return;
			}
			_updating = true;
			try
			{
				entry.Value = num;
			}
			finally
			{
				_updating = false;
			}
		}

		private void ClampFloat(ConfigEntry<float> entry, Func<float, float> clamp)
		{
			entry.SettingChanged += delegate
			{
				QuietClamp(entry, clamp);
			};
		}

		private static float ClampStepValue(float step)
		{
			if (float.IsNaN(step) || step < 0.05f)
			{
				return 0.05f;
			}
			if (step > 1f)
			{
				return 1f;
			}
			return step;
		}

		private static void MigrateShapeNames(ConfigFile config)
		{
			string configFilePath = config.ConfigFilePath;
			if (!string.IsNullOrEmpty(configFilePath) && File.Exists(configFilePath))
			{
				string text = File.ReadAllText(configFilePath);
				string text2 = text.Replace("ShapeMask = Circle", "ShapeMask = Oval").Replace("ShapeMask = Square", "ShapeMask = Rectangle");
				if (!(text2 == text))
				{
					File.WriteAllText(configFilePath, text2);
					config.Reload();
				}
			}
		}
	}
	internal static class PluginInfo
	{
		public const string Guid = "evu.evuminimap";

		public const string Name = "EvuMinimap";

		public const string Version = "0.2.2";
	}
	internal static class ServerGuard
	{
		public static bool IsDedicatedServer
		{
			get
			{
				string[] commandLineArgs = Environment.GetCommandLineArgs();
				if (commandLineArgs == null || commandLineArgs.Length == 0 || string.IsNullOrEmpty(commandLineArgs[0]))
				{
					return false;
				}
				string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(commandLineArgs[0]);
				if (fileNameWithoutExtension.IndexOf("valheim_server", StringComparison.OrdinalIgnoreCase) < 0)
				{
					return fileNameWithoutExtension.IndexOf("valheim-server", StringComparison.OrdinalIgnoreCase) >= 0;
				}
				return true;
			}
		}
	}
	internal static class ShapeMaskSprites
	{
		private const int Size = 128;

		private static readonly Dictionary<int, Sprite> Cache = new Dictionary<int, Sprite>();

		public static Sprite Get(MapShape shape, float cornerRadius, float aspect)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Invalid comparison between Unknown and I4
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			int key = ShapeKey.For(shape, cornerRadius, aspect);
			if (Cache.TryGetValue(key, out Sprite value))
			{
				return value;
			}
			float radius = (((int)shape == 1) ? 1f : AppearanceMath.ClampCornerRadius(cornerRadius));
			Sprite val = Create(shape, radius, AppearanceMath.ClampAspect(aspect));
			Cache[key] = val;
			return val;
		}

		private static Sprite Create(MapShape shape, float radius, float aspect)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			//IL_016b: 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_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Invalid comparison between Unknown and I4
			//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)
			ClipWindow val = AppearanceMath.ClipWindowFor(aspect);
			float num = ((ClipWindow)(ref val)).X * 128f;
			float num2 = ((ClipWindow)(ref val)).Y * 128f;
			float num3 = ((ClipWindow)(ref val)).Width * 128f;
			float num4 = ((ClipWindow)(ref val)).Height * 128f;
			Texture2D val2 = new Texture2D(128, 128, (TextureFormat)4, false);
			Color32[] array = (Color32[])(object)new Color32[16384];
			float limit = radius * 0.5f * Math.Min(num3, num4);
			float centerX = num + num3 * 0.5f;
			float centerY = num2 + num4 * 0.5f;
			float radiusX = num3 * 0.5f;
			float radiusY = num4 * 0.5f;
			for (int i = 0; i < 128; i++)
			{
				for (int j = 0; j < 128; j++)
				{
					float px = (float)j + 0.5f;
					float py = (float)i + 0.5f;
					bool flag = (((int)shape == 1) ? InsideEllipse(px, py, centerX, centerY, radiusX, radiusY) : InsideRoundedRect(px, py, num, num2, num3, num4, limit));
					array[i * 128 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)(flag ? byte.MaxValue : 0));
				}
			}
			val2.SetPixels32(array);
			val2.Apply(false, false);
			((Object)val2).hideFlags = (HideFlags)61;
			Sprite obj = Sprite.Create(val2, new Rect(0f, 0f, 128f, 128f), new Vector2(0.5f, 0.5f), 100f);
			((Object)obj).hideFlags = (HideFlags)61;
			return obj;
		}

		private static bool InsideEllipse(float px, float py, float centerX, float centerY, float radiusX, float radiusY)
		{
			if (radiusX <= 0f || radiusY <= 0f)
			{
				return false;
			}
			float num = (px - centerX) / radiusX;
			float num2 = (py - centerY) / radiusY;
			return num * num + num2 * num2 <= 1f;
		}

		private static bool InsideRoundedRect(float px, float py, float left, float bottom, float width, float height, float limit)
		{
			float num = px - left;
			float num2 = py - bottom;
			if (num < 0f || num2 < 0f || num > width || num2 > height)
			{
				return false;
			}
			float num3 = ((num < limit) ? limit : ((num > width - limit) ? (width - limit) : num));
			float num4 = ((num2 < limit) ? limit : ((num2 > height - limit) ? (height - limit) : num2));
			float num5 = num - num3;
			float num6 = num2 - num4;
			return num5 * num5 + num6 * num6 <= limit * limit;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}